Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Piatok, 23. október 2026

Rozdiely pre phpWebLogAnalyzer/phpWebLogAnalyzer.inc.php medzi verziami 1.11 a 1.12

verzia 1.11, 2001/12/10 21:09:45 verzia 1.12, 2001/12/18 16:15:45
Riadok 39  include("config.inc.php");
Riadok 39  include("config.inc.php");
 /*  /*
  * Ident library   * Ident library
  */   */
 include("libident/libident.php");  include_once("libident/libident.php");
   
 /*  class Web_Log {
  * phpWebLogAnalyzer global variabiles  
  */  
 $phpWebLogAnalyzer_db_handle = 0;  
 unset($phpWebLogAnalyzer_db_handle);  
   
           var $_session_timeout;
   
 /*          var $_db_handle;
  * phpWebLogAnalyzer_open_db_connection()          var $_db;
  *  
  * Opens database connection.  
  */  
 function phpWebLogAnalyzer_open_db_connection() {  
         global $phpWebLogAnalyzer_db_handle;  
         global $phpWebLogAnalyzer_MYSQL_HOST;  
         global $phpWebLogAnalyzer_MYSQL_PORT;  
         global $phpWebLogAnalyzer_MYSQL_USERNAME;  
         global $phpWebLogAnalyzer_MYSQL_PASSWORD;  
         global $phpWebLogAnalyzer_MYSQL_DATABASE;  
   
         $phpWebLogAnalyzer_db_handle = @mysql_connect(  
                         "$phpWebLogAnalyzer_MYSQL_HOST:$phpWebLogAnalyzer_MYSQL_PORT",  
                         $phpWebLogAnalyzer_MYSQL_USERNAME,  
                         $phpWebLogAnalyzer_MYSQL_PASSWORD);  
   
         if ($phpWebLogAnalyzer_db_handle == false)          function Web_Log()
                 return false;          {
                   $this->_session_timeout = 30 * 60;
   
         if (@mysql_select_db($phpWebLogAnalyzer_MYSQL_DATABASE,                  unset($this->_db_handle);
                                 $phpWebLogAnalyzer_db_handle) == false)                  unset($this->_db);
                 return false;          }
   
         return $phpWebLogAnalyzer_db_handle;          function set_session_timeout($timeout)
 }          {
                   $this->_session_timeout = $timeout;
           }
   
           function set_db($host = "", $port = "",
                           $username = "", $password = "", $name = "")
           {
                   if ($host != "")
                           $this->_db['host'] = $host;
   
                   if ($port != 0)
                           $this->_db['host'] = $host;
   
 /*                  if ($username != "")
  * phpWebLogAnalyzer_close_db_connection()                          $this->_db['username'] = $username;
  *  
  * Closes database connection.  
  */  
 function phpWebLogAnalyzer_close_db_connection() {  
         global $phpWebLogAnalyzer_db_handle;  
   
         $phpWebLogAnalyzer_db_handle = @mysql_close($phpWebLogAnalyzer_db_handle);                  if ($password != "")
                           $this->_db['password'] = $password;
   
         return $phpWebLogAnalyzer_db_handle; // true if OK, false if failed                  if ($name != "")
 }                          $this->_db['name'] = $name;
           }
   
           function set_db_handle($db_handle)
           {
                   $this->_db_handle = $db_handle;
           }
   
 /*          /*
  * phpWebLogAnalyzer_check_db_handle()           * open_db_connection()
  *           *
  * Check if database handle is still opened.           * Opens database connection.
  */           */
 function phpWebLogAnalyzer_check_db_handle() {          function open_db_connections($host = "", $port = 0,
         global $phpWebLogAnalyzer_db_handle;                          $username = "", $password = "", $name = "")
           {
                   $this->set_db($host, $port, $username, $password, $name);
   
                   $this->_db_handle = @mysql_connect(
                                   $this->_db['host']
                                   . ($this->_db['port'] != 0 ? ":" . $this->_db['port'] : ""),
                                   $this->_db['username'],
                                   $this->_db['password']);
   
         if (! isset($phpWebLogAnalyzer_db_handle)) {                  if ($this->_db_handle == false)
                 phpWebLogAnalyzer_open_db_connection()                          return false;
                         or phpWebLogAnalyzer_error("database server connection error");  
         }  
 }  
   
                   if (@mysql_select_db($this->_db['name'], $this->_db_handle) == false)
                           return false;
   
 /*                  return $this->_db_handle;
  * phpWebLogAnalyzer_register_access()          }
  *  
  * Register access. Insert one record to accesses table.  
  * Also insert records into another tables if it is neccessary.  
  */  
 function phpWebLogAnalyzer_register_access($value = 0) {  
         global $phpWebLogAnalyzer_db_handle;  
         global $phpWebLogAnalyzer_MYSQL_DATABASE;  
         global $phpWebLogAnalyzer_LOG_TABLE;  
   
         phpWebLogAnalyzer_check_db_handle();  
   
         global $REQUEST_METHOD;  
         global $QUERY_STRING;  
         global $PATH_INFO;  
         global $PATH_TRANSLATED;  
         global $CONTENT_TYPE;  
         global $CONTENT_LENGTH;  
         global $SCRIPT_NAME;  
         global $SERVER_NAME;  
         global $SERVER_PORT;  
         global $SERVER_SOFTWARE;  
         global $SERVER_PROTOCOL;  
         global $SERVER_ADMIN;  
         global $SERVER_SIGNATURE;  
         global $GATEWAY_INTERFACE;  
         global $REMOTE_HOST;  
         global $REMOTE_ADDR;  
         global $REMOTE_PORT;  
         global $AUTH_TYPE;  
         global $REMOTE_USER;  
         global $REMOTE_IDENT;  
         global $DOCUMENT_ROOT;  
         global $HTTP_ACCEPT;  
         global $HTTP_ACCEPT_CHARSET;  
         global $HTTP_ACCEPT_ENCODING;  
         global $HTTP_ACCEPT_LANGUAGE;  
         global $HTTP_CONNECTION;  
         global $HTTP_HOST;  
         global $HTTP_REFERER;  
         global $HTTP_USER_AGENT;  
         global $SCRIPT_FILENAME;  
         global $REQUEST_URI;  
   
         $ip_addr = '';  
         $hostname = '';  
         $proxy_ip_addr = '';  
         $proxy_hostname = '';  
         $ident_user = '';  
         $ident_ostype = '';  
   
         /*          /*
          * IP address & proxy server getting.           * close_db_connection()
            *
            * Closes database connection.
          */           */
   
         if (getenv('HTTP_X_FORWARDED_FOR') != '') {          function close_db_connection()
                 $ip_addr = getenv('HTTP_X_FORWARDED_FOR');          {
                 $proxy_ip_addr = getenv('REMOTE_ADDR');                  $this->_db_handle = @mysql_close($this->_db_handle);
         }                  return $this->_db_handle; // true if OK, false if failed
         else {  
                 $ip_addr = getenv('REMOTE_ADDR');  
         }          }
   
         /*          /*
          * Host name resolving.           * _check_db_handle()
            *
            * Check if database handle is still opened.
          */           */
   
         $hostname = @gethostbyaddr($ip_addr);          function _check_db_handle() {
         if (! strcmp($hostname, $ip_addr))                  if (! isset($this->_db_handle)) {
                 $hostname = '';                          $this->open_db_connection()
                                   or _error("database server connection error");
         if ($proxy_ip_addr) {                  }
                 $proxy_hostname = @gethostbyaddr($proxy_ip_addr);  
                 if (! strcmp($proxy_hostname, $proxy_ip_addr))  
                         $proxy_hostname = '';  
         }          }
   
         /*          /*
          * Ident protocol stuff           * _db_error()
            *
            * Database error handling function.
          */           */
         $ident = new Net_Ident($ip_addr, $REMOTE_PORT, $SERVER_PORT);  
   
         if ($ident->status() == 1) {  
                 // print "Ident query failed: " . $ident->error() . ".<br>\n";  
         }  
         else {  
                 $ident_user = $ident->user();  
                 $ident_ostype = $ident->osType();  
         }  
   
         $record = array ( // * - not in PHP manual  
   
                         'id' => 0, // 0 - auto_increment  
                         'value_id' => phpWebLogAnalyzer_get_id(  
                                 'weblog_values', $value),  
                         'request_method_id' => phpWebLogAnalyzer_get_id(  
                                 'weblog_request_methods', $REQUEST_METHOD),  
                         'query_string_id' => phpWebLogAnalyzer_get_id(  
                                 'weblog_query_strings', $QUERY_STRING),  
                         'path_info_id' => phpWebLogAnalyzer_get_id(  
                                 'weblog_path_infos', $PATH_INFO), // *  
                         'path_translated_id' => phpWebLogAnalyzer_get_id(  
                                 'weblog_paths_translated', $PATH_TRANSLATED),  
                         'content_type_id' => phpWebLogAnalyzer_get_id(  
                                 'weblog_content_types', $CONTENT_TYPE), // *  
                         'content_length' => $CONTENT_LENGTH, // *  
                         'script_name_id' => phpWebLogAnalyzer_get_id(  
                                 'weblog_script_names', $SCRIPT_NAME),  
                         'server_name_id' => phpWebLogAnalyzer_get_id(  
                                 'weblog_server_names', $SERVER_NAME),  
                         'server_port' => $SERVER_PORT, // *  
                         'server_software_id' => phpWebLogAnalyzer_get_id(  
                                 'weblog_server_softwares', $SERVER_SOFTWARE),  
                         'server_protocol_id' => phpWebLogAnalyzer_get_id(  
                                         'weblog_server_protocols', $SERVER_PROTOCOL),  
                         'server_admin_id' => phpWebLogAnalyzer_get_id(  
                                         'weblog_server_admins', $SERVER_ADMIN),  
                         'server_signature_id' => phpWebLogAnalyzer_get_id(  
                                         'weblog_server_signatures', $SERVER_SIGNATURE),  
                         'gateway_interface_id' => phpWebLogAnalyzer_get_id(  
                                         'weblog_gateway_interfaces', $GATEWAY_INTERFACE),  
                         'remote_host_id' => phpWebLogAnalyzer_get_id(  
                                         'weblog_remote_hosts', $hostname), // *  
                         'proxy_addr_id' => phpWebLogAnalyzer_get_id(  
                                         'weblog_remote_addrs', $proxy_ip_addr),  
                         'proxy_host_id' => phpWebLogAnalyzer_get_id(  
                                         'weblog_remote_hosts', $proxy_hostname), // *  
                         'remote_addr_id' => ($remote_addr_id =  
                                         phpWebLogAnalyzer_get_id(  
                                                 'weblog_remote_addrs', $ip_addr)),  
                         'remote_host_id' => phpWebLogAnalyzer_get_id(  
                                         'weblog_remote_hosts', $hostname), // *  
                         'remote_port' => $REMOTE_PORT,  
                         'auth_type_id' => phpWebLogAnalyzer_get_id(  
                                         'weblog_auth_types', $AUTH_TYPE), // *  
                         'remote_user_id' => phpWebLogAnalyzer_get_id(  
                                         'weblog_remote_users', $REMOTE_USER), // *  
                         'remote_ident_id' => phpWebLogAnalyzer_get_id(  
                                         'weblog_remote_idents', $REMOTE_IDENT), // *  
                         'document_root_id' => phpWebLogAnalyzer_get_id(  
                                         'weblog_document_roots', $DOCUMENT_ROOT),  
                         'http_accept_id' => phpWebLogAnalyzer_get_id(  
                                         'weblog_http_accepts', $HTTP_ACCEPT),  
                         'http_accept_charset_id' => phpWebLogAnalyzer_get_id(  
                                         'weblog_http_accept_charsets', $HTTP_ACCEPT_CHARSET),  
                         'http_accept_encoding_id' => phpWebLogAnalyzer_get_id(  
                                         'weblog_http_accept_encodings', $HTTP_ACCEPT_ENCODING),  
                         'http_accept_language_id' => phpWebLogAnalyzer_get_id(  
                                         'weblog_http_accept_languages', $HTTP_ACCEPT_LANGUAGE),  
                         'http_connection_id' => phpWebLogAnalyzer_get_id(  
                                         'weblog_http_connections', $HTTP_CONNECTION),  
                         'http_host_id' => phpWebLogAnalyzer_get_id(  
                                         'weblog_http_hosts', $HTTP_HOST),  
                         'http_referer_id' => phpWebLogAnalyzer_get_id(  
                                         'weblog_http_referers', $HTTP_REFERER),  
                         'http_user_agent_id' => ($http_user_agent_id =  
                                         phpWebLogAnalyzer_get_id(  
                                                 'weblog_http_user_agents', $HTTP_USER_AGENT)),  
                         'script_filename_id' => phpWebLogAnalyzer_get_id(  
                                         'weblog_script_filenames', $SCRIPT_FILENAME),  
                         'request_uri_id' => phpWebLogAnalyzer_get_id(  
                                         'weblog_request_uris', $REQUEST_URI),  
                         'ident_username_id' => phpWebLogAnalyzer_get_id(  
                                         'weblog_ident_usernames', $ident_user),  
                         'ident_ostype_id' => phpWebLogAnalyzer_get_id(  
                                         'weblog_ident_ostypes', $ident_ostype),  
                         'session_id' => phpWebLogAnalyzer_get_session_id(  
                                         $remote_addr_id, $http_user_agent_id)  
                                 );  
   
   
                         $keys = '';  
                         $vals = '';  
                         $count = 0;  
   
                         foreach ($record as $key => $val) {  
                                 $count++;  
                                 $sep = ($count < count($record) ? ", " : "");  
   
                                 $keys .= $key . $sep;  
                                 $vals .= ($val ? "'$val'" : "NULL") . $sep;  
                         }  
   
                         $query = "insert into $phpWebLogAnalyzer_LOG_TABLE"  
                                 ." ( datetime, $keys ) values ( sysdate(), $vals )";  
   
                         //print "$query<br>\n";          function _db_error() {
                   return _error("error during work with database server");
           }
   
                         $result = @mysql_query($query, $phpWebLogAnalyzer_db_handle)          /*
                                 or phpWebLogAnalyzer_db_error();           * _error()
            *
            * Error handling function.
            */
   
                         return;          function _error($message = "Unknown error") {
 }                  die ("<b> fatal failure</b>: " . $message
                                   . "<br>Please contact webmaster or system administrator"
                                   . " of this page with this problem.<br>");
   
 /*                  return false;
  * phpWebLogAnalyzer_get_id()          }
  *  
  * Return ID of $value in $table.  
  * If $value is not in table, record will be inserted.  
  */  
 function phpWebLogAnalyzer_get_id($table, $value) {  
   
         /*          /*
          * If you want to have 0 or "" in you database as valid values,           * register_access()
          * uncomment this and comment the next line. Otherwise 0 and "" values           *
          * will be counted as NULL.           * Register access. Insert one record to accesses table.
            * Also insert records into another tables if it is neccessary.
          */           */
           function register_access($value = 0) {
   
         // if (!isset($value) || !isset($table)) return 0;                  $this->_check_db_handle();
         if (!$value || !$table)  
                 return 0;  
   
         global $phpWebLogAnalyzer_db_handle;                  global $REQUEST_METHOD;
         phpWebLogAnalyzer_check_db_handle();                  global $QUERY_STRING;
                   global $PATH_INFO;
                   global $PATH_TRANSLATED;
                   global $CONTENT_TYPE;
                   global $CONTENT_LENGTH;
                   global $SCRIPT_NAME;
                   global $SERVER_NAME;
                   global $SERVER_PORT;
                   global $SERVER_SOFTWARE;
                   global $SERVER_PROTOCOL;
                   global $SERVER_ADMIN;
                   global $SERVER_SIGNATURE;
                   global $GATEWAY_INTERFACE;
                   global $REMOTE_HOST;
                   global $REMOTE_ADDR;
                   global $REMOTE_PORT;
                   global $AUTH_TYPE;
                   global $REMOTE_USER;
                   global $REMOTE_IDENT;
                   global $DOCUMENT_ROOT;
                   global $HTTP_ACCEPT;
                   global $HTTP_ACCEPT_CHARSET;
                   global $HTTP_ACCEPT_ENCODING;
                   global $HTTP_ACCEPT_LANGUAGE;
                   global $HTTP_CONNECTION;
                   global $HTTP_HOST;
                   global $HTTP_REFERER;
                   global $HTTP_USER_AGENT;
                   global $SCRIPT_FILENAME;
                   global $REQUEST_URI;
   
         $query = "select id from $table"                  $ip_addr = '';
                 ." where value = substring('" . addslashes($value) . "', 1, 255)"                  $hostname = '';
                 ." limit 1";                  $proxy_ip_addr = '';
         $result = @mysql_query($query, $phpWebLogAnalyzer_db_handle)                  $proxy_hostname = '';
                 or phpWebLogAnalyzer_db_error();                  $ident_user = '';
                   $ident_ostype = '';
         if ($row = @mysql_fetch_array($result))  
                 return $row[0];                  /*
                    * IP address & proxy server getting.
         $query = "insert into $table (id, value)"                   */
                 ." values (0, '" . addslashes($value) . "')";  
         $result = @mysql_query($query, $phpWebLogAnalyzer_db_handle)                  if (getenv('HTTP_X_FORWARDED_FOR') != '') {
                 or phpWebLogAnalyzer_db_error();                          $ip_addr = getenv('HTTP_X_FORWARDED_FOR');
                           $proxy_ip_addr = getenv('REMOTE_ADDR');
         $query = "select last_insert_id()";                  }
         $result = @mysql_query($query, $phpWebLogAnalyzer_db_handle)                  else {
                 or phpWebLogAnalyzer_db_error();                          $ip_addr = getenv('REMOTE_ADDR');
                   }
   
                   /*
                    * Host name resolving.
                    */
   
                   $hostname = @gethostbyaddr($ip_addr);
                   if (! strcmp($hostname, $ip_addr))
                           $hostname = '';
   
                   if ($proxy_ip_addr) {
                           $proxy_hostname = @gethostbyaddr($proxy_ip_addr);
                           if (! strcmp($proxy_hostname, $proxy_ip_addr))
                                   $proxy_hostname = '';
                   }
   
                   /*
                    * Ident protocol stuff
                    */
                   $ident = new Net_Ident($ip_addr, $REMOTE_PORT, $SERVER_PORT);
   
                   if ($ident->status() == 1) {
                           // print "Ident query failed: " . $ident->error() . ".<br>\n";
                   }
                   else {
                           $ident_user = $ident->user();
                           $ident_ostype = $ident->osType();
                   }
   
                   $record = array ( // * - not in PHP manual
   
                                   'id' => 0, // 0 - auto_increment
                                   'value_id' => _get_id(
                                           'weblog_values', $value),
                                   'request_method_id' => _get_id(
                                           'weblog_request_methods', $REQUEST_METHOD),
                                   'query_string_id' => _get_id(
                                           'weblog_query_strings', $QUERY_STRING),
                                   'path_info_id' => _get_id(
                                           'weblog_path_infos', $PATH_INFO), // *
                                   'path_translated_id' => _get_id(
                                           'weblog_paths_translated', $PATH_TRANSLATED),
                                   'content_type_id' => _get_id(
                                           'weblog_content_types', $CONTENT_TYPE), // *
                                   'content_length' => $CONTENT_LENGTH, // *
                                   'script_name_id' => _get_id(
                                           'weblog_script_names', $SCRIPT_NAME),
                                   'server_name_id' => _get_id(
                                           'weblog_server_names', $SERVER_NAME),
                                   'server_port' => $SERVER_PORT, // *
                                   'server_software_id' => _get_id(
                                           'weblog_server_softwares', $SERVER_SOFTWARE),
                                   'server_protocol_id' => _get_id(
                                                   'weblog_server_protocols', $SERVER_PROTOCOL),
                                   'server_admin_id' => _get_id(
                                                   'weblog_server_admins', $SERVER_ADMIN),
                                   'server_signature_id' => _get_id(
                                                   'weblog_server_signatures', $SERVER_SIGNATURE),
                                   'gateway_interface_id' => _get_id(
                                                   'weblog_gateway_interfaces', $GATEWAY_INTERFACE),
                                   'remote_host_id' => _get_id(
                                                   'weblog_remote_hosts', $hostname), // *
                                   'proxy_addr_id' => _get_id(
                                                   'weblog_remote_addrs', $proxy_ip_addr),
                                   'proxy_host_id' => _get_id(
                                                   'weblog_remote_hosts', $proxy_hostname), // *
                                   'remote_addr_id' => ($remote_addr_id =
                                                   _get_id(
                                                           'weblog_remote_addrs', $ip_addr)),
                                   'remote_host_id' => _get_id(
                                                   'weblog_remote_hosts', $hostname), // *
                                   'remote_port' => $REMOTE_PORT,
                                   'auth_type_id' => _get_id(
                                                   'weblog_auth_types', $AUTH_TYPE), // *
                                   'remote_user_id' => _get_id(
                                                   'weblog_remote_users', $REMOTE_USER), // *
                                   'remote_ident_id' => _get_id(
                                                   'weblog_remote_idents', $REMOTE_IDENT), // *
                                   'document_root_id' => _get_id(
                                                   'weblog_document_roots', $DOCUMENT_ROOT),
                                   'http_accept_id' => _get_id(
                                                   'weblog_http_accepts', $HTTP_ACCEPT),
                                   'http_accept_charset_id' => _get_id(
                                                   'weblog_http_accept_charsets', $HTTP_ACCEPT_CHARSET),
                                   'http_accept_encoding_id' => _get_id(
                                                   'weblog_http_accept_encodings', $HTTP_ACCEPT_ENCODING),
                                   'http_accept_language_id' => _get_id(
                                                   'weblog_http_accept_languages', $HTTP_ACCEPT_LANGUAGE),
                                   'http_connection_id' => _get_id(
                                                   'weblog_http_connections', $HTTP_CONNECTION),
                                   'http_host_id' => _get_id(
                                                   'weblog_http_hosts', $HTTP_HOST),
                                   'http_referer_id' => _get_id(
                                                   'weblog_http_referers', $HTTP_REFERER),
                                   'http_user_agent_id' => ($http_user_agent_id =
                                                   _get_id(
                                                           'weblog_http_user_agents', $HTTP_USER_AGENT)),
                                   'script_filename_id' => _get_id(
                                                   'weblog_script_filenames', $SCRIPT_FILENAME),
                                   'request_uri_id' => _get_id(
                                                   'weblog_request_uris', $REQUEST_URI),
                                   'ident_username_id' => _get_id(
                                                   'weblog_ident_usernames', $ident_user),
                                   'ident_ostype_id' => _get_id(
                                                   'weblog_ident_ostypes', $ident_ostype),
                                   'session_id' => _get_session_id(
                                                   $remote_addr_id, $http_user_agent_id)
                                           );
   
         if ($row = @mysql_fetch_array($result))  
                 return $row[0];  
   
         return 0;                                  $keys = '';
 }                                  $vals = '';
                                   $count = 0;
   
 /*                                  foreach ($record as $key => $val) {
  * phpWebLogAnalyzer_get_session_id()                                          $count++;
  *                                          $sep = ($count < count($record) ? ", " : "");
  * Returns session_id according to $remote_addr_id and $http_user_agent_id  
  * and session timeout defined in config.inc.php file.  
  */  
 function phpWebLogAnalyzer_get_session_id(  
                 $remote_addr_id, $http_user_agent_id) {  
   
         global $phpWebLogAnalyzer_SESSION_TIMEOUT;                                          $keys .= $key . $sep;
         global $phpWebLogAnalyzer_db_handle;                                          $vals .= ($val ? "'$val'" : "NULL") . $sep;
         phpWebLogAnalyzer_check_db_handle();                                  }
   
         $query = "select"                                  $query = "insert into weblog_accesses"
                 ." id, session_id,"                                          ." ( datetime, $keys ) values ( sysdate(), $vals )";
                 ." unix_timestamp(now()) - unix_timestamp(datetime) as diff_sec"  
                 ." from weblog_accesses"  
                 ." where remote_addr_id = '$remote_addr_id'"  
                 ." and http_user_agent_id = '$http_user_agent_id'"  
                 ." order by datetime desc"  
                 ." limit 1";  
   
         $result = @mysql_query($query, $phpWebLogAnalyzer_db_handle)                                  //print "$query<br>\n";
                 or phpWebLogAnalyzer_db_error();  
   
         if (($row = @mysql_fetch_array($result, MYSQL_ASSOC))                                  $result = @mysql_query($query, $this->_db_handle)
                         && ($row[diff_sec] < $phpWebLogAnalyzer_SESSION_TIMEOUT)                                          or _db_error();
                         && ($row[session_id])) {  
   
                 return $row[session_id];                                  return;
         }          }
   
         //echo "if: ". $row[diff_sec] . " &lt; "          /*
         //      . $phpWebLogAnalyzer_SESSION_TIMEOUT . "<br>";           * _get_id()
            *
            * Return ID of $value in $table.
            * If $value is not in table, record will be inserted.
            */
   
         $query = "select max(session_id) + 1 as new_session_id"          function _get_id($table, $value) {
                 ." from weblog_accesses";  
   
         $result = @mysql_query($query, $phpWebLogAnalyzer_db_handle)                  /*
                 or phpWebLogAnalyzer_db_error();                   * If you want to have 0 or "" in you database as valid values,
                    * uncomment this and comment the next line. Otherwise 0 and "" values
                    * will be counted as NULL.
                    */
   
                   // if (!isset($value) || !isset($table)) return 0;
                   if (!$value || !$table)
                           return 0;
   
                   $this->_check_db_handle();
   
                   $query = "select id from $table"
                           ." where value = substring('" . addslashes($value) . "', 1, 255)"
                           ." limit 1";
                   $result = @mysql_query($query, $this->_db_handle)
                           or _db_error();
   
                   if ($row = @mysql_fetch_array($result))
                           return $row[0];
   
                   $query = "insert into $table (id, value)"
                           ." values (0, '" . addslashes($value) . "')";
                   $result = @mysql_query($query, $this->_db_handle)
                           or _db_error();
   
                   $query = "select last_insert_id()";
                   $result = @mysql_query($query, $this->_db_handle)
                           or _db_error();
   
         if (($row = @mysql_fetch_array($result, MYSQL_ASSOC))                  if ($row = @mysql_fetch_array($result))
                         && ($row[new_session_id])) {                          return $row[0];
   
                 return $row[new_session_id];                  return 0;
         }          }
   
         return 1;          /*
 }           * _get_session_id()
            *
            * Returns session_id according to $remote_addr_id and $http_user_agent_id
            * and session timeout defined in config.inc.php file.
            */
           function _get_session_id(
                           $remote_addr_id, $http_user_agent_id) {
   
 /*                  $this->_check_db_handle();
  * phpWebLogAnalyzer_get_sessions_count()  
  *  
  */  
 function phpWebLogAnalyzer_get_sessions_count($ar = '') {  
   
         global $phpWebLogAnalyzer_db_handle;                  $query = "select"
         phpWebLogAnalyzer_check_db_handle();                          ." id, session_id,"
                           ." unix_timestamp(now()) - unix_timestamp(datetime) as diff_sec"
                           ." from weblog_accesses"
                           ." where remote_addr_id = '$remote_addr_id'"
                           ." and http_user_agent_id = '$http_user_agent_id'"
                           ." order by datetime desc"
                           ." limit 1";
   
         $list_tables = '';                  $result = @mysql_query($query, $this->_db_handle)
         $list_where = '';                          or _db_error();
   
         if (is_array($ar)) {                  if (($row = @mysql_fetch_array($result, MYSQL_ASSOC))
                 $names = array(                                  && ($row[diff_sec] < $_SESSION_TIMEOUT)
                                 'id' => array(                                  && ($row[session_id])) {
                                         'column' => 'id_id'),  
                                 'datetime' => array(  
                                         'column' => 'datetime_id'),  
                                 'value' => array(  
                                         'column' => 'value_id',  
                                         'table' => 'weblog_values'),  
                                 'request_method' => array(  
                                         'column' => 'request_method_id',  
                                         'table' => 'weblog_request_methods'),  
                                 'query_string' => array(  
                                         'column' => 'query_string_id',  
                                         'table' => 'weblog_query_strings'),  
                                 'path_info' => array(  
                                         'column' => 'path_info_id',  
                                         'table' => 'weblog_path_infos'),  
                                 'path_translated' => array(  
                                         'column' => 'path_translated_id',  
                                         'table' => 'weblog_paths_translated'),  
                                 'content_type' => array(  
                                         'column' => 'content_type_id',  
                                         'table' => 'weblog_content_types'),  
                                 'content_length' => array(  
                                                 'column' => 'content_length'),  
                                 'script_name' => array(  
                                                 'column' => 'script_name_id',  
                                                 'table' => 'weblog_script_names'),  
                                 'server_name' => array(  
                                                 'column' => 'server_name_id',  
                                                 'table' => 'weblog_server_names'),  
                                 'server_port' => array(  
                                                 'column' => 'server_port'),  
                                 'server_software' => array(  
                                                 'column' => 'server_software_id',  
                                                 'table' => 'weblog_server_softwares'),  
                                 'server_protocol' => array(  
                                                 'column' => 'server_protocol_id',  
                                                 'table' => 'weblog_server_protocols'),  
                                 'gateway_interface' => array(  
                                                 'column' => 'gateway_interface_id',  
                                                 'table' => 'weblog_gateway_interfaces'),  
                                 'proxy_addr' => array(  
                                                 'column' => 'proxy_addr_id',  
                                                 'table' => 'weblog_remote_addrs'),  
                                 'proxy_host' => array(  
                                                 'column' => 'proxy_host_id',  
                                                 'table' => 'weblog_remote_hosts'),  
                                 'remote_addr' => array(  
                                                 'column' => 'remote_addr_id',  
                                                 'table' => 'weblog_remote_addrs'),  
                                 'remote_host' => array(  
                                                 'column' => 'remote_host_id',  
                                                 'table' => 'weblog_remote_hosts'),  
                                 'remote_port' => array(  
                                                 'column' => 'remote_port_id'),  
                                 'auth_type' => array(  
                                                 'column' => 'auth_type_id',  
                                                 'table' => 'weblog_auth_types'),  
                                 'remote_user' => array(  
                                                 'column' => 'remote_user_id',  
                                                 'table' => 'weblog_remote_users'),  
                                 'remote_ident' => array(  
                                                 'column' => 'remote_ident_id',  
                                                 'table' => 'weblog_remote_idents'),  
                                 'document_root' => array(  
                                                 'column' => 'document_root_id',  
                                                 'table' => 'weblog_document_roots'),  
                                 'http_accept' => array(  
                                                 'column' => 'http_accept_id',  
                                                 'table' => 'weblog_http_accepts'),  
                                 'http_accept_charset' => array(  
                                                 'column' => 'http_accept_charset_id',  
                                                 'table' => 'weblog_http_accept_charsets'),  
                                 'http_accept_encoding' => array(  
                                                 'column' => 'http_accept_encoding_id',  
                                                 'table' => 'weblog_http_accept_encodings'),  
                                 'http_accept_language' => array(  
                                                 'column' => 'http_accept_language_id',  
                                                 'table' => 'weblog_http_accept_languages'),  
                                 'http_connection' => array(  
                                                 'column' => 'http_connection_id',  
                                                 'table' => 'weblog_http_connections'),  
                                 'http_host' => array(  
                                                 'column' => 'http_host_id',  
                                                 'table' => 'weblog_http_hosts'),  
                                 'http_referer' => array(  
                                                 'column' => 'http_referer_id',  
                                                 'table' => 'weblog_http_referers'),  
                                 'http_user_agent' => array(  
                                                 'column' => 'http_user_agent_id',  
                                                 'table' => 'weblog_http_user_agents'),  
                                 'script_filename' => array(  
                                                 'column' => 'script_filename_id',  
                                                 'table' => 'weblog_script_filenames'),  
                                 'server_admin' => array(  
                                                 'column' => 'server_admin_id',  
                                                 'table' => 'weblog_server_admins'),  
                                 'server_signature' => array(  
                                                 'column' => 'server_signature_id',  
                                                 'table' => 'weblog_server_signatures'),  
                                 'request_uri' => array(  
                                                 'column' => 'request_uri_id',  
                                                 'table' => 'weblog_request_uris'),  
                                 'ident_username' => array(  
                                                 'column' => 'ident_username_id',  
                                                 'table' => 'weblog_ident_usernames'),  
                                 'ident_ostype' => array(  
                                                 'column' => 'ident_ostype_id',  
                                                 'table' => 'weblog_ident_ostypes'),  
                                 'session' => array(  
                                                 'column' => 'session_id',  
                                                 'table' => 'weblog_sessions'),  
                                 );  
   
                                 global $phpWebLogAnalyzer_LOG_TABLE;                          return $row[session_id];
                   }
   
                                 $count = 0;                  //echo "if: ". $row[diff_sec] . " &lt; "
                   //      . $_SESSION_TIMEOUT . "<br>";
   
                                 foreach ($ar as $key => $val) {                  $query = "select max(session_id) + 1 as new_session_id"
                                         $count++;                          ." from weblog_accesses";
   
                                         if (isset($names[$key][table])) {                  $result = @mysql_query($query, $this->_db_handle)
                                                 $list_where .= "$phpWebLogAnalyzer_LOG_TABLE."                          or _db_error();
                                                         . $names[$key][column] . " = "  
                                                         . $names[$key][table] . ".id and "  
                                                         . $names[$key][table] . ".value like '$val'";  
   
                                                 $list_tables .= $names[$key][table];                  if (($row = @mysql_fetch_array($result, MYSQL_ASSOC))
                                   && ($row[new_session_id])) {
   
                                                 if ($count < count($ar))                          return $row[new_session_id];
                                                         $list_tables .= ', ';                  }
                                         }  
                                         else {  
                                                 $list_where .= $names[$key] . " = '$val'";  
                                         }  
   
                                         if ($count < count($ar))                  return 1;
                                                 $list_where .= ' and ';  
                                 }  
         }          }
   
         $query = "select"          /*
                 ." count(distinct session_id) as sessions_count"           * _get_sessions_count()
                 ." from weblog_accesses";           *
            */
           function _get_sessions_count($ar = '') {
   
         if (strlen($list_tables) > 0)                  $this->_check_db_handle();
                 $query .= ", " . $list_tables;  
   
         if (strlen($list_where) > 0)                  $list_tables = '';
                 $query .= " where " . $list_where;                  $list_where = '';
   
         //echo "<p>$query<hr>";                  if (is_array($ar)) {
                           $names = array(
                                           'id' => array(
                                                   'column' => 'id_id'),
                                           'datetime' => array(
                                                   'column' => 'datetime_id'),
                                           'value' => array(
                                                   'column' => 'value_id',
                                                   'table' => 'weblog_values'),
                                           'request_method' => array(
                                                   'column' => 'request_method_id',
                                                   'table' => 'weblog_request_methods'),
                                           'query_string' => array(
                                                   'column' => 'query_string_id',
                                                   'table' => 'weblog_query_strings'),
                                           'path_info' => array(
                                                   'column' => 'path_info_id',
                                                   'table' => 'weblog_path_infos'),
                                           'path_translated' => array(
                                                   'column' => 'path_translated_id',
                                                   'table' => 'weblog_paths_translated'),
                                           'content_type' => array(
                                                   'column' => 'content_type_id',
                                                   'table' => 'weblog_content_types'),
                                           'content_length' => array(
                                                           'column' => 'content_length'),
                                           'script_name' => array(
                                                           'column' => 'script_name_id',
                                                           'table' => 'weblog_script_names'),
                                           'server_name' => array(
                                                           'column' => 'server_name_id',
                                                           'table' => 'weblog_server_names'),
                                           'server_port' => array(
                                                           'column' => 'server_port'),
                                           'server_software' => array(
                                                           'column' => 'server_software_id',
                                                           'table' => 'weblog_server_softwares'),
                                           'server_protocol' => array(
                                                           'column' => 'server_protocol_id',
                                                           'table' => 'weblog_server_protocols'),
                                           'gateway_interface' => array(
                                                           'column' => 'gateway_interface_id',
                                                           'table' => 'weblog_gateway_interfaces'),
                                           'proxy_addr' => array(
                                                           'column' => 'proxy_addr_id',
                                                           'table' => 'weblog_remote_addrs'),
                                           'proxy_host' => array(
                                                           'column' => 'proxy_host_id',
                                                           'table' => 'weblog_remote_hosts'),
                                           'remote_addr' => array(
                                                           'column' => 'remote_addr_id',
                                                           'table' => 'weblog_remote_addrs'),
                                           'remote_host' => array(
                                                           'column' => 'remote_host_id',
                                                           'table' => 'weblog_remote_hosts'),
                                           'remote_port' => array(
                                                           'column' => 'remote_port_id'),
                                           'auth_type' => array(
                                                           'column' => 'auth_type_id',
                                                           'table' => 'weblog_auth_types'),
                                           'remote_user' => array(
                                                           'column' => 'remote_user_id',
                                                           'table' => 'weblog_remote_users'),
                                           'remote_ident' => array(
                                                           'column' => 'remote_ident_id',
                                                           'table' => 'weblog_remote_idents'),
                                           'document_root' => array(
                                                           'column' => 'document_root_id',
                                                           'table' => 'weblog_document_roots'),
                                           'http_accept' => array(
                                                           'column' => 'http_accept_id',
                                                           'table' => 'weblog_http_accepts'),
                                           'http_accept_charset' => array(
                                                           'column' => 'http_accept_charset_id',
                                                           'table' => 'weblog_http_accept_charsets'),
                                           'http_accept_encoding' => array(
                                                           'column' => 'http_accept_encoding_id',
                                                           'table' => 'weblog_http_accept_encodings'),
                                           'http_accept_language' => array(
                                                           'column' => 'http_accept_language_id',
                                                           'table' => 'weblog_http_accept_languages'),
                                           'http_connection' => array(
                                                           'column' => 'http_connection_id',
                                                           'table' => 'weblog_http_connections'),
                                           'http_host' => array(
                                                           'column' => 'http_host_id',
                                                           'table' => 'weblog_http_hosts'),
                                           'http_referer' => array(
                                                           'column' => 'http_referer_id',
                                                           'table' => 'weblog_http_referers'),
                                           'http_user_agent' => array(
                                                           'column' => 'http_user_agent_id',
                                                           'table' => 'weblog_http_user_agents'),
                                           'script_filename' => array(
                                                           'column' => 'script_filename_id',
                                                           'table' => 'weblog_script_filenames'),
                                           'server_admin' => array(
                                                           'column' => 'server_admin_id',
                                                           'table' => 'weblog_server_admins'),
                                           'server_signature' => array(
                                                           'column' => 'server_signature_id',
                                                           'table' => 'weblog_server_signatures'),
                                           'request_uri' => array(
                                                           'column' => 'request_uri_id',
                                                           'table' => 'weblog_request_uris'),
                                           'ident_username' => array(
                                                           'column' => 'ident_username_id',
                                                           'table' => 'weblog_ident_usernames'),
                                           'ident_ostype' => array(
                                                           'column' => 'ident_ostype_id',
                                                           'table' => 'weblog_ident_ostypes'),
                                           'session' => array(
                                                           'column' => 'session_id',
                                                           'table' => 'weblog_sessions'),
                                           );
   
                                           $count = 0;
   
                                           foreach ($ar as $key => $val) {
                                                   $count++;
   
                                                   if (isset($names[$key][table])) {
                                                           $list_where .= "weblog_accesses."
                                                                   . $names[$key][column] . " = "
                                                                   . $names[$key][table] . ".id and "
                                                                   . $names[$key][table] . ".value like '$val'";
   
                                                           $list_tables .= $names[$key][table];
   
                                                           if ($count < count($ar))
                                                                   $list_tables .= ', ';
                                                   }
                                                   else {
                                                           $list_where .= $names[$key] . " = '$val'";
                                                   }
   
         $result = @mysql_query($query, $phpWebLogAnalyzer_db_handle)                                                  if ($count < count($ar))
                 or phpWebLogAnalyzer_db_error();                                                          $list_where .= ' and ';
                                           }
                   }
   
         if ($row = @mysql_fetch_array($result, MYSQL_ASSOC))                  $query = "select"
                 return $row[sessions_count];                          ." count(distinct session_id) as sessions_count"
                           ." from weblog_accesses";
   
         return false;                  if (strlen($list_tables) > 0)
 }                          $query .= ", " . $list_tables;
   
 /*                  if (strlen($list_where) > 0)
  * phpWebLogAnalyzer_db_error()                          $query .= " where " . $list_where;
  *  
  * Database error handling function.  
  */  
 function phpWebLogAnalyzer_db_error() {  
         return phpWebLogAnalyzer_error("error during work with database server");  
 }  
   
                   //echo "<p>$query<hr>";
   
 /*                  $result = @mysql_query($query, $this->_db_handle)
  * phpWebLogAnalyzer_error()                          or _db_error();
  *  
  * Error handling function.                  if ($row = @mysql_fetch_array($result, MYSQL_ASSOC))
  */                          return $row[sessions_count];
 function phpWebLogAnalyzer_error($message = "Unknown error") {  
         die ("<b>phpWebLogAnalyzer fatal failure</b>: " . $message                  return false;
                         . "<br>Please contact webmaster or system administrator"          }
                         . " of this page with this problem.<br>");  
   
         return false;  
 }  }
   
 ?>  ?>

Legend:
Odstranené z verzie1.11  
zmenené riadky
  Pridané vo verzii1.12

Platon Group <platon@platon.sk> http://platon.sk/
Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok