landysaccount Posted May 20, 2009 Share Posted May 20, 2009 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 More sharing options...
trq Posted May 20, 2009 Share Posted May 20, 2009 Do you get any error message? You do realise the mac address your attempting to get is not valid? Link to comment https://forums.phpfreaks.com/topic/158895-solved-help-with-script/#findComment-838043 Share on other sites More sharing options...
landysaccount Posted May 20, 2009 Author Share Posted May 20, 2009 Do you get any error message? You do realise the mac address your attempting to get is not valid? Even if I comment that line out I'm still not able to save. I do not get any errors. Link to comment https://forums.phpfreaks.com/topic/158895-solved-help-with-script/#findComment-838049 Share on other sites More sharing options...
trq Posted May 20, 2009 Share Posted May 20, 2009 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. Link to comment https://forums.phpfreaks.com/topic/158895-solved-help-with-script/#findComment-838050 Share on other sites More sharing options...
landysaccount Posted May 20, 2009 Author Share Posted May 20, 2009 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?????? Link to comment https://forums.phpfreaks.com/topic/158895-solved-help-with-script/#findComment-838058 Share on other sites More sharing options...
landysaccount Posted May 20, 2009 Author Share Posted May 20, 2009 Never mind. I found the problem. A very stupid one. The actual script resides at a different location then the one I was editing. Sorry for the stupidity and thanks to those who tried to help. So mark this post as solved. Link to comment https://forums.phpfreaks.com/topic/158895-solved-help-with-script/#findComment-838063 Share on other sites More sharing options...
trq Posted May 20, 2009 Share Posted May 20, 2009 Never mind. I found the problem. A very stupid one. The actual script resides at a different location then the one I was editing. Sorry for the stupidity and thanks to those who tried to help. So mark this post as solved. You can do that yourself. Bottom left corner. Link to comment https://forums.phpfreaks.com/topic/158895-solved-help-with-script/#findComment-838064 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.