Problem with app, condition not working.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey guys got a problem with an app i'm working on.
App: An app to track visitors and hosts visiting certain pages in a website.
Situation: the app is to populate a table (db) with IP numbers which are to be concidered as filtered/excluded in the below snippet of code from being tracked. Problem: the below code is used to insert the actual data for the tracker from the visitor on the page its requested. However, before the actual information is submitted, there has to be a condition to see if the current visitor's IP is listed in the excluded list. My current code returns false to all, and will not input the data whether the IP is in the list or not in the table.

Culprit: Seems to be the in_array causing it or an eye-flaw from my side but cannot find it.

Any ideas?

Jimmie




//======================================================
#--> Include db config
require_once("../includes/db.class.phtml");
#--> Connect to db
$sql = new conSQL();
//======================================================
#--> Fetch current rules
$currentRulesQuery = $sql->query("SELECT host FROM filter");
if(!$currentRulesQuery){ print mysql_error(); }

#--> Result to array
#.
$currentHost = $_SERVER['REMOTE_ADDR'];

/* Obs: this loop runs all the rules *** do not edit */
while($currentRules = $sql->fetchArray($currentRulesQuery, MYSQL_ASSOC))
{

   #--> If in array
   if(!in_array($currentHost, $currentRules))

{ #-------------------------------------------#
   #--> Fetch data
   $currentSettingsQuery = $sql->query("SELECT track_control FROM define");
   if(!$currentSettingsQuery){ print mysql_error(); }


   #--> Data to var
   $currentSettings = $sql->fetchArray($currentSettingsQuery);

   if($currentSettings['track_control']==1)
       {
// Specify the tracking vars # Revision 1.0
       //======================================================
       $page = $_SERVER['PHP_SELF']; // full path
       $ip = $_SERVER['REMOTE_ADDR']; // interface protocol
       $time = date("Y-m-d H:i:s"); // current time and date
       $request_method = $_SERVER['REQUEST_METHOD']; // refer agent method
$gateway_interface = $_SERVER['GATEWAY_INTERFACE']; // refer agent gateway $server_protocol = $_SERVER['SERVER_PROTOCOL']; // host server protocol $request_time = $_SERVER['REQUEST_TIME']; // time of request ( php 5.1.0 up ) $query_string = $_SERVER['QUERY_STRING']; // query string if available $accept_charset = $_SERVER['HTTP_ACCEPT_CHARSET']; // refer agent charset $accept_encoding = $_SERVER['HTTP_ACCEPT_ENCODING']; // refer agent encoding $accept_language = $_SERVER['HTTP_ACCEPT_LANGUAGE']; // refer agent language $http_connection = $_SERVER['HTTP_CONNECTION']; // service connection
       $user_agent = $_SERVER['HTTP_USER_AGENT']; // refer agent
       #$remote_port = $_SERVER['REMOTE_PORT']; // refer agent port
       //======================================================
#--> Continue with the query
       $insertQuery = $sql->query("INSERT INTO track
(page,ip,time,request_method,gateway_interface,server_protocol,request_time,query_string,accept_charset,
       accept_encoding,accept_language,http_connection,user_agent)
VALUES ('$page',
                '$ip',
                '$time',
                '$request_method',
                '$gateway_interface',
                '$server_protocol',
                '$request_time',
                '$query_string',
                '$accept_charset',
                '$accept_encoding',
                '$accept_language',
                '$http_connection',
                '$user_agent')");
}
   }
}
   #-------------------------------------------#

           #--> Error check on query
           if(!($insertQuery)){ print mysql_error(); }
               else
                   {

                   #.
                   $sql->close();
}
   //======================================================
?>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux