#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2014
    Posts
    1
    Rep Power
    0

    Unhappy What could be sending GET requests to my script?


    I've made a very basic PHP script to isolate a problem I'm having. The script just receives some irrelevant POST data and then counts up to 50 with a time delay while writing to a log.

    Usually a minute into runtime the script will receive a GET request from somewhere which interrupts the response to the client. To rule out client issues I'm using Chrome Advanced Restful client to test. The request is always coming from my IP as well (I have that logged).

    What could be causing this and how can I fix it? If anyone could help me crack this, I'd be very grateful because I can't for the life of me figure it out.



    PHP Code:
    <?php

    $q 
    $_POST['q'];

    $req=$_SERVER['REQUEST_METHOD'];
    $ip $_SERVER['REMOTE_ADDR'];
    $agent $_SERVER['HTTP_USER_AGENT'];

    writelog("IP Logged: ".$ip);
    writelog("User agent: " $agent);
    writelog("Post data: " $q);
    writelog("Request method: " $req);

    if (
    $q==""){
      
    writelog ("MISFIRE!!!");
      die;
    }

    writelog("*** Error check started ***");

    for (
    $i 1$i <= 50$i++) {
         
    writelog ($i);
         
    sleep(rand(2,20)); 
    }

     function 
    writelog($towrite)
    {
      
    $tdate=date('d/m/Y H:i:s');
      
    $file 'log/testlog.txt';
      
    $current $towrite." --- ".$tdate."\n";
      
    file_put_contents($file$currentFILE_APPEND);

    writelog("*** Error check ended ***");
    ?>

    And here's a typical result of the log.

    see after the 7th entry there is a GET request.

    Code:
    IP Logged: 86.31.**.** --- 06/06/2014 10:45:57
    User agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36 --- 06/06/2014 10:45:57
    Post data: foobar --- 06/06/2014 10:45:57
    Request method: POST --- 06/06/2014 10:45:57
    *** Error check started *** --- 06/06/2014 10:45:57
    1 --- 06/06/2014 10:45:57
    2 --- 06/06/2014 10:46:05
    3 --- 06/06/2014 10:46:12
    4 --- 06/06/2014 10:46:19
    5 --- 06/06/2014 10:46:33
    6 --- 06/06/2014 10:46:37
    7 --- 06/06/2014 10:46:41
    IP Logged: 86.31.**.** --- 06/06/2014 10:46:44
    User agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36 --- 06/06/2014 10:46:44
    Post data:  --- 06/06/2014 10:46:44
    Request method: GET --- 06/06/2014 10:46:44
    MISFIRE!!! --- 06/06/2014 10:46:44
    8 --- 06/06/2014 10:47:00
    9 --- 06/06/2014 10:47:20
    10 --- 06/06/2014 10:47:24
    ... the original script will continue running until it reaches 50. The problem is that the GET response will interrupt my client if I'm using AJAX.

    This is the response headers from the restful client:

    Code:
    Date: Fri, 06 Jun 2014 10:46:44 GMT 
    Server: Apache 
    Content-Length: 20 
    Connection: close
    Content-Type: text/html
    Where could this GET request be coming from and how can I stop it interfering with my scripts?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,854
    Rep Power
    597
    The httpd log should tell you the requesting source.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.

IMN logo majestic logo threadwatch logo seochat tools logo