P
P
PO6OT2015-09-23 20:41:58
PHP
PO6OT, 2015-09-23 20:41:58

How to optimize PHP daemon?

Error 508 Resource Limit Exceeded occurs on average 60 times/hour
Occurs on shared hosting - hostinger.ru
Occurs due to the imperfection of the daemon:
daemon.php:

<?php
if(date('His')-file_get_contents('./date')<3)
    exit;
    file_put_contents('./date', date('His'));
    $f=fopen('./lock', 'w+');
    flock($f, LOCK_EX);
function ping($action){
    $h=$_SERVER[HTTP_HOST];
    $http=fsockopen($h, 80, $e1, $e2, 1);
if($http){
    fwrite($http,
    'GET /'.$action.' HTTP/1.1'."\r\n".
    'Accept: */*'."\r\n".
    'Host: '.$h."\r\n\r\n"
    );
    fclose($http);
}
}
    ping('core.php');
    sleep(3);
    flock($f, LOCK_UN);
    ping('daemon.php');

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question