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 5 of 5
  1. #1
    Regular Coder ArcticFox's Avatar
    Join Date
    Jan 2004
    Location
    Vostok Station, AQ
    Posts
    602
    Thanks
    35
    Thanked 3 Times in 3 Posts

    Angry Logger Hanging Site

    I've got a logging script that keeps hanging the site. When it's installed, the page takes forever to load. When removed, the page shows instantly.

    PHP Code:
    <?php
        $server   
    'localhost'// MySQL hostname
        
    $username 'username'// MySQL username
        
    $password 'password'// MySQL password
        
    $dbname   'dbname'// MySQL db name
        
        
        
    $db mysql_connect($server$username$password) or die(mysql_error());
              
    mysql_select_db($dbname) or die(mysql_error());
        
        
    $sql 'SELECT 
                    c.country 
                FROM 
                    ip2nationCountries c,
                    ip2nation i 
                WHERE 
                    i.ip < INET_ATON("'
    .$_SERVER['REMOTE_ADDR'].'") 
                    AND 
                    c.code = i.country 
                ORDER BY 
                    i.ip DESC 
                LIMIT 0,1'
    ;
        
        list(
    $countryName) = mysql_fetch_row(mysql_query($sql));
        

        
    $db mysql_connect($server$username$password) or die(mysql_error());
              
    mysql_select_db($dbname) or die(mysql_error());
        
        
    $sql 'SELECT 
                    c.country 
                FROM 
                    ip2nationCountries c,
                    ip2nation i 
                WHERE 
                    i.ip < INET_ATON("'
    .$_SERVER['HTTP_X_FORWARDED_FOR'].'") 
                    AND 
                    c.code = i.country 
                ORDER BY 
                    i.ip DESC 
                LIMIT 0,1'
    ;
        
        list(
    $countryName2) = mysql_fetch_row(mysql_query($sql));
        
        
        
        
        
        
    $ti date("l, F jS Y - g:ia");
    $ip getenv("REMOTE_ADDR");
    $pr getenv("HTTP_X_FORWARDED_FOR");
    $ac getenv("HTTP_ACCEPT");
    $la getenv("HTTP_ACCEPT_LANGUAGE");
    $re getenv("HTTP_REFERER");
    $br getenv("HTTP_USER_AGENT");
    $se getenv("SERVER_NAME");
    $ho gethostbyaddr(getenv("REMOTE_ADDR"));

    $fp fopen("./logs.php""a+");

    if (
    strstr($_SERVER["REMOTE_ADDR"], "127.0.0.0")) {
       
    fputs($fp"
    <font style=color:#00cc00;font-variant:small-caps;font-size:14px;font-weight:bold;>AF - MAIN INDEX PAGE</font><br />
    <b>Time:</b> $ti<br />
    <b>Browser Type:</b> $br<br />
    <b>WEBMASTER</b><br />
    <hr noshade size=1 width=50% align=left />
    "
    );
    fclose($fp);}

    else {
       
    fputs($fp"
    <font style=color:#0099ff;font-variant:small-caps;font-size:14px;font-weight:bold;>MAIN INDEX PAGE</font><br />
    <b>Time:</b> $ti<br />
    <b>IP Address:</b> $ip - $countryName<br />
    <b>Match Proxy:</b> <u>$pr</u> - $countryName2<br />
    <b>HTTP Accept:</b> $ac<br />
    <b>Languages:</b> $la<br />
    <b>Referer URL:</b> <a target=_blank href=$re>$re</a><br/>
    <b>Browser Type:</b> $br<br />
    <b>Host Name:</b> $ho<br />
    <hr noshade size=1 width=50% align=left />
    "
    );
    fclose($fp);}



    if (
    strstr($_SERVER["HTTP_REFERER"], "codingforums")) {header("location: http://www.BaseStationZero.com/HOLD/ ");}
    if (
    strstr($_SERVER["HTTP_REFERER"], "dynamicdrive")) {header("location: http://www.BaseStationZero.com/HOLD/ ");}
    if (
    strstr($_SERVER["HTTP_REFERER"], "sitepoint")) {header("location: http://www.BaseStationZero.com/HOLD/ ");}

    if (
    strstr($_SERVER["REMOTE_ADDR"], "82.172.242.")) {header("location: error403.php");}
    if (
    strstr($_SERVER["REMOTE_ADDR"], "82.103.132.")) {header("location: error403.php");}
    if (
    strstr($_SERVER["REMOTE_ADDR"], "69.234.44.")) {header("location: error403.php");}
    if (
    strstr($_SERVER["REMOTE_ADDR"], "204.246.129.196")) {header("location: error403.php");}


    ?>


    I don't know what's causing it. I took out the part that pulls from the db, but that had no effect. The logs.php page is nearly empty, so it's not like that's the issue.

    Ideas?
    <div> - putting your mind in a box since 1997

  • #2
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    Taking out the MySQL queries, I was able to run the code instantly.

    Either your queries are not returning (taking a long time, or some other problem). Or it is an environment issue.

    EDIT:

    Have you tried putting in echo statements followed by a flush() to see where the script runs into a block?

  • #3
    Regular Coder ArcticFox's Avatar
    Join Date
    Jan 2004
    Location
    Vostok Station, AQ
    Posts
    602
    Thanks
    35
    Thanked 3 Times in 3 Posts

    Internet Explorer

    Ah, hah! Thanks, Aedrin.

    I did this:
    PHP Code:
    $ti date("l, F jS Y - g:ia");echo "date<br>";ob_flush();flush();
    $ip getenv("REMOTE_ADDR");echo "ip<br>";ob_flush();flush();
    $pr getenv("HTTP_X_FORWARDED_FOR");echo "pr<br>";ob_flush();flush();
    $ac getenv("HTTP_ACCEPT");echo "ac<br>";ob_flush();flush();
    $la getenv("HTTP_ACCEPT_LANGUAGE");echo "la<br>";ob_flush();flush();
    $re getenv("HTTP_REFERER");echo "re<br>";ob_flush();flush();
    $br getenv("HTTP_USER_AGENT");echo "br<br>";ob_flush();flush();
    $se getenv("SERVER_NAME");echo "se<br>";ob_flush();flush();
    $ho gethostbyaddr(getenv("REMOTE_ADDR"));echo "ho<br>";ob_flush();flush();

    $fp fopen("./logs.php""a+");;echo "fopen1<br>";ob_flush();flush(); 
    And find that this part $ho = gethostbyaddr(getenv("REMOTE_ADDR")); hangs it all up. It's not really needed, but any idea why it hangs?
    Last edited by ArcticFox; 01-24-2007 at 06:06 PM.
    <div> - putting your mind in a box since 1997

  • #4
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    It would be hard to say.

    It is possible your host does not allow PHP to use DNS services.

  • #5
    Regular Coder ArcticFox's Avatar
    Join Date
    Jan 2004
    Location
    Vostok Station, AQ
    Posts
    602
    Thanks
    35
    Thanked 3 Times in 3 Posts
    I'm not sure, it's ithium.net

    The value eventually shows up, but it just takes so long. Well, it's not needed so I'm yanking it out.

    Thanks again!
    <div> - putting your mind in a box since 1997


  •  

    Posting Permissions

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