Hello.
I am experiencing something weird with a script :
script name: check_status.php
[COLOR="SeaGreen"]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");
}[/COLOR]
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?requestedPage=http://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.