Jump to content

[SOLVED] help with script


landysaccount

Recommended Posts

Hello.

 

I am experiencing something weird with a script :

 

script name: check_status.php

 

require( "./includes/constants.php" ); 
    require( "./includes/functions.php" ); 
    //require( "./connections.php"); 
     
    if ( $_SERVER["HTTP_CLIENT_IP"] )             $ip = $_SERVER["HTTP_CLIENT_IP"]; 
    else if( $_SERVER["HTTP_X_FORWARDED_FOR"] )   $ip = $_SERVER["HTTP_X_FORWARDED_FOR"]; 
    else if( $_SERVER["REMOTE_ADDR"] )            $ip = $_SERVER["REMOTE_ADDR"]; 
    else                                          $ip = "UNKNOWN"; 
         
    $mac = `sudo arp -i eth1 $ip | grep : | awk '{print $3}'`; 
     
    //record visit 
    $query = "insert into network_access ( ip, mac, timevisit ) values ( '$ip', '$mac', " . time() . " )"; 

    $result = dba_connect( $query, 1 ) or 
              die( "Query: '$query', failed with error message: -- " . mysql_error() . " --" ); 
    // end visit record 
     
    // check if is a company address 
    $query = "select * from private_ip where priv_ip_address='$ip'"; 
    $result = dba_connect( $query, 1 ) or 
                      die( "Query: '$query', failed with error message: -- " . mysql_error() . " --" ); 

    // immediately send private ip's to the requested page 
    if( mysql_num_rows( $result ) >= 1 ){ 
      $location = "Location: " . $_REQUEST['requestedPage']; 
      header("$location"); 
      exit; 
    } 
     
    $query = "select dhcp_cust_id as id from dhcp where dhcp_ip='$ip'"; 
    $result = dba_connect( $query, 1 ) or 
                      die( "Query: '$query', failed with error message: -- " . mysql_error() . " --" ); 
     
    // if there isn't any match here then the user is not registered. 
      if( mysql_num_rows( $result ) == 0 ){ 
      $location = "Location: ./notregistered_mesg.php"; 
      header("$location"); 
      exit; 
    } 
    $row = mysql_fetch_array( $result ); 
     
    $query = "select customer_status as status from customer where customer_id=" . $row["id"]; 
    $result = dba_connect( $query, 1 ) or 
                      die( "Query: '$query', failed with error message: -- " . mysql_error() . " --" ); 
     
    $row = mysql_fetch_array( $result ); 
     
    if( $row["status"] == "SUSPENDIDO" ){ 
      header("Location: ./suspended_message.php"); 
      exit; 
    } 
    else 
    { 
      $location = "Location: " . $_REQUEST['requestedPage']; 
      header("$location"); 
    }

 

The user gets redirected to the requested page and all but, this script is not doing the insert to the network_access table. I don't understand why, I don't know if the page is cached on the clients but, I've tested clearing the cache and still doesnt work. If I call the script by doing:

 

http://server/check_status.php?reque...www.google.com

 

it works but since this script is called from a NoCat splash page the insert doesnt work. Any idea of what's wrong?

 

Thanks in advanced.

Link to comment
https://forums.phpfreaks.com/topic/158895-solved-help-with-script/
Share on other sites

I see your connections.php include is commented out, is that right?

 

Also, have you got error reporting and display errors switched on. You should for debugging.

 

I tested with connections.php included and still had the same problem. I do have error reporting on. The thing is, if I call the script directly the insert gets executed and the record is saved. Again, I don't know if users have that page cached and is preventing from loading the updated version??????

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.