Results 1 to 11 of 11
  1. #1

    Do you see a problem anywhere?

    Im in a bit of a pickle, this code worked fine on my RedHat server, but now that I moved to a CentOs powered machine, it doesn't seem to work.

    PHP Code:
    <? //start your PHP!

    //Set the date so we can store it in the text file.
    $tdate date("dS F Y h:i:s A");

    //Check if there is a referer
    if (!$HTTP_REFERER) { $HTTP_REFERER "(NONE)"; }


    //Store it in the counter.html file 

    $fp fopen("counter.html""a");
    $line "<table cellpadding=2 cellspacing=2><tr><td bgcolor=#eeeeee><small><u>IP Address:</u> $REMOTE_ADDR - <u>Date:</u> $tdate - <u>Referer:</u> <a href=$HTTP_REFERER>$HTTP_REFERER</a></small></td></tr></table>";
    fwrite($fp$line);
    fclose($fp);


    //Show what the user needs to know!
    echo "IP Address: $REMOTE_ADDR<br>";
    echo 
    "Referer: $HTTP_REFERER <br>";
    echo 
    "Browser: $HTTP_USER_AGENT";

    ?>
    It still logs the actual visits to the page into the file... but it cannot identify the remote address, referer or agent.

    Any ideas why?

  2. #2
    Join Date
    Nov 2005
    Location
    Buffalo
    Posts
    94
    If you made a script call it new script like this:
    <?php phpinfo() ?>
    And host this at the same server, are the vars your looking for set?

  3. #3
    They are virtually identical.

    This new server also caused some weird behavior with my script, some variables refused to be declared, so I had to rename them.

  4. #4
    Join Date
    Aug 2005
    Location
    England
    Posts
    87
    Maybe register_globals is affecting it? I think it should be on to use those variables. I get confused myself.

  5. #5
    Join Date
    Mar 2004
    Posts
    1,301
    After php 4.1.0 has been introduced, we use $_SERVER.

    change $HTTP_REFERER --> $_SERVER['HTTP_REFERER']

    Do the same thing for the others.

  6. #6
    Nope.... got an error

    Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

  7. #7
    Okay I got it working, but the referer always points to:

    https://66.232.97.99:2087/scripts/srvmng

    for some odd reason. That URL is in phpinfo as well under _ENV["HTTP_REFERER"] and HTTP_REFERER.

  8. #8
    register_globals = on

    problem solved.
    Last edited by o2pb; 11-19-2005 at 07:34 PM.

  9. #9
    Join Date
    Mar 2004
    Posts
    1,301
    Quote Originally Posted by o2pb
    register_globals = on

    problem solved.
    a bad decision. Read more about turning off register_global.

  10. #10
    $user_ip = getenv("REMOTE_ADDR");

    etc

  11. #11
    Join Date
    Nov 2002
    Location
    Michigan
    Posts
    695
    +1 for orbitz. Anytime variables "just appear" out of noplace in a PHP script, it should be a big warning that you have a security hole. Anyone can set variables in your script just by appending ?variable=value to the URL they are submitting.

    Register_globals is now disabled by default IIRC in PHP installations. Your old server probably still had it enabled.
    http://www.lamphowto.com/ - LAMP and LAMP+SSL HowTo
    http://www.cobaltfaqs.com/ - Cobalt FAQs and HowTos

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •