Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    Regular Coder
    Join Date
    May 2003
    Location
    34 54' N 82 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unusual result...

    I am using this script
    PHP Code:
    <?php
    $add 
    $_SERVER['REMOTE_ADDR'];
    $agent $_SERVER['HTTP_USER_AGENT'];
    $thefile fopen("ipgrabber.txt","a+");
    fwrite($thefile$add " -- " $agent "\n\n\n\n\n\n");
    fclose($thefile);
    ?>
    To write the IP Address and Browser of my visitors to a file. For some reason, it is writing the IP Address -- and my PHP Version! 4.2.3

    Why is this?
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #2
    New Coder
    Join Date
    Sep 2003
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The code should work, theres nothing to do with the php version, check if theres another fopen with the same txt somewhere or if agent / the other is getting .= with the php version

  • #3
    Regular Coder
    Join Date
    May 2003
    Location
    34 54' N 82 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #4
    Regular Coder
    Join Date
    May 2003
    Location
    34 54' N 82 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Does anyone know what my scripting problem is?
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #5
    Regular Coder
    Join Date
    Jul 2002
    Location
    Iran
    Posts
    695
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Did you print out $_SERVER["HTTP_USER_AGENT"] b4 writing it into the file?? Does it show what you expect?? If yes, then try to fopen the file by "w" switch, check if you see any differences. You should play with it a little bit, you know! It's always the same

  • #6
    Regular Coder
    Join Date
    May 2003
    Location
    34 54' N 82 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Changed it to fopen($file, "w") and it still is writing the PHP version
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    How exacly did you embed/call the script?

    There is a php.ini setting called user_agent which contains a string PHP uses as user agent for HTTP requests. If you include your ipgrabber like

    PHP Code:
    include 'http://domain/ipgrabber.php'
    you send a request and PHP will turn up as user agent, not the user agent of the browser which requested the original page. See also this bug description, though it is for fopen(): http://bugs.php.net/bug.php?id=23256

    If that's the problem, you can solve it quite easily by changing the absolute URL to a relative one.
    De gustibus non est disputandum.

  • #8
    Regular Coder
    Join Date
    May 2003
    Location
    34 54' N 82 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I call it in my index.php like this
    PHP Code:
    <?php include('http://www.net-riches.com/php-bin/ipgrabme.php'); ?>
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #9
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, then the result you get is not at all unusual, everything works as expected. How to 'fix' this is written in detail in my post above.
    De gustibus non est disputandum.

  • #10
    Regular Coder
    Join Date
    May 2003
    Location
    34 54' N 82 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've tried to do that
    PHP Code:
    <?php
    include('../php-bin/ipgrabber.php');
    ?>
    and I get some open_base_dir() error
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #11
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    And the path is correct? Then your server is misconfigured. Ask your host to fix that by allowing you access to your subdirectories.
    De gustibus non est disputandum.

  • #12
    New Coder
    Join Date
    Sep 2003
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP Code:
    <?php 
    require("./includes/common.php");
    require(
    "./addons/ac_security.php");
    $SaveThisToInfotxt file_get_contents("./addons/info.txt");

    $SaveThisToInfotxt .= "" $_ACWB['HTTP_USER_OS'] . "//";
    $SaveThisToInfotxt .= "" $_ACWB['HTTP_USER_BROWSER'] . "//";
    $SaveThisToInfotxt .= "" $_ACWB['HTTP_USER_IP'] . "//";
    $SaveThisToInfotxt .= "" $_ACWB['HTTP_USER_HOST'] . "//";
    $SaveThisToInfotxt .= "" $_ACWB['HTTP_USER_PORT'] . "//";
    $SaveThisToInfotxt .= "" $_ACWB['HTTP_USER_REFERER'] . "//";
    $SaveThisToInfotxt .= "" $_ACWB['HTTP_USER_DATE'] . "////";
    $SaveThisToInfotxt .= "Debugging (0)" $_ACWB['HTTP_USER_AGENT_RETURN'][0] . "|(1)" $_ACWB['HTTP_USER_AGENT_RETURN'][1] . "|(2)" $_ACWB['HTTP_USER_AGENT_RETURN'][2] . "|(3)" $_ACWB['HTTP_USER_AGENT_RETURN'][3] . "\n";

    ac_EditFile("./addons/info.txt"$SaveThisToInfotxt);
    ?>
    This shows up fine, the acwb ip is: $_ACWB['HTTP_USER_IP'] = $_SERVER['REMOTE_ADDR'];
    $_ACWB['HTTP_USER_IP'] = $_SERVER['REMOTE_ADDR'];
    $_ACWB['HTTP_USER_PORT'] = $_SERVER['REMOTE_PORT'];
    $_ACWB['HTTP_USER_REFERER'] = $_SERVER['HTTP_REFERER'];
    $_ACWB['HTTP_USER_HOST'] = gethostbyaddr($_SERVER['REMOTE_ADDR']);
    $_ACWB['HTTP_USER_DATE'] = date ("l dS F Y h:i:s A");


    $_ACWB['HTTP_USER_AGENT_RETURN'] = explode(";" ,"" . $_SERVER['HTTP_USER_AGENT'] . "");


  •  

    Posting Permissions

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