[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
Zen Cart 源代码 whos_online.php

Zen Cart 源代码 whos_online.php




下载文件

文件名: whos_online.php
文件类型: PHP文件
文件大小: 4.34 KiB
MD5: 4e1c1b87897fe801937fd541f15b582e

whos_online.php - 关闭高亮
  1. <?php
  2. /**
  3.  * whos_online functions
  4.  *
  5.  * @package functions
  6.  * @copyright Copyright 2003-2007 Zen Cart Development Team
  7.  * @copyright Portions Copyright 2003 osCommerce
  8.  * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  9.  * @version $Id: whos_online.php 6113 2007-04-04 06:11:02Z drbyte $
  10.  */
  11. /**
  12.  * zen_update_whos_online
  13.  */
  14. function zen_update_whos_online() {
  15.   global $db;
  16.  
  17.   if (isset($_SESSION['customer_id']) && $_SESSION['customer_id']) {
  18.     $wo_customer_id = $_SESSION['customer_id'];
  19.  
  20.     $customer_query = "select customers_firstname, customers_lastname
  21.                         from " . TABLE_CUSTOMERS . "
  22.                         where customers_id = '" . (int)$_SESSION['customer_id'] . "'";
  23.  
  24.     $customer = $db->Execute($customer_query);
  25.  
  26.     $wo_full_name = $customer->fields['customers_lastname'] . ', ' . $customer->fields['customers_firstname'];
  27.   } else {
  28.     $wo_customer_id = '';
  29.     $wo_full_name = '&yen;' . 'Guest';
  30.   }
  31.  
  32.   $wo_session_id = zen_session_id();
  33.   $wo_ip_address = (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'Unknown');
  34.   $wo_user_agent = substr(zen_db_prepare_input($_SERVER['HTTP_USER_AGENT']), 0, 254);
  35.  
  36.     $_SERVER['QUERY_STRING'] = (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != '') ? $_SERVER['QUERY_STRING'] : zen_get_all_get_params();
  37.   if (isset($_SERVER['REQUEST_URI'])) {
  38.     $uri = $_SERVER['REQUEST_URI'];
  39.    } else {
  40.     if (isset($_SERVER['QUERY_STRING'])) {
  41.      $uri = $_SERVER['PHP_SELF'] .'?'. $_SERVER['QUERY_STRING'];
  42.     } else {
  43.      $uri = $_SERVER['PHP_SELF'] .'?'. $_SERVER['argv'][0];
  44.     }
  45.   }
  46.   if (substr($uri, -1)=='?') $uri = substr($uri,0,strlen($uri)-1);
  47.   $wo_last_page_url = (zen_not_null($uri) ? substr($uri, 0, 254) : 'Unknown');
  48.  
  49.   $current_time = time();
  50.   $xx_mins_ago = ($current_time - 900);
  51.  
  52.   // remove entries that have expired
  53.   $sql = "delete from " . TABLE_WHOS_ONLINE . "
  54.          where time_last_click < '" . $xx_mins_ago . "'";
  55.  
  56.   $db->Execute($sql);
  57.  
  58.   $stored_customer_query = "select count(*) as count
  59.                              from " . TABLE_WHOS_ONLINE . "
  60.                              where session_id = '" . zen_db_input($wo_session_id) . "' and ip_address='" . zen_db_input($wo_ip_address) . "'";
  61.  
  62.   $stored_customer = $db->Execute($stored_customer_query);
  63.  
  64.   if (empty($wo_session_id)) {
  65.     $wo_full_name = '&yen;' . 'Spider';
  66.   }
  67.  
  68.   if ($stored_customer->fields['count'] > 0) {
  69.     $sql = "update " . TABLE_WHOS_ONLINE . "
  70.              set customer_id = '" . (int)$wo_customer_id . "',
  71.                  full_name = '" . zen_db_input($wo_full_name) . "',
  72.                  ip_address = '" . zen_db_input($wo_ip_address) . "',
  73.                  time_last_click = '" . zen_db_input($current_time) . "',
  74.                  last_page_url = '" . zen_db_input($wo_last_page_url) . "',
  75.                  host_address = '" . zen_db_input($_SESSION['customers_host_address']) . "',
  76.                  user_agent = '" . zen_db_input($wo_user_agent) . "'
  77.              where session_id = '" . zen_db_input($wo_session_id) . "' and ip_address='" . zen_db_input($wo_ip_address) . "'";
  78.  
  79.     $db->Execute($sql);
  80.  
  81.   } else {
  82.     $sql = "insert into " . TABLE_WHOS_ONLINE . "
  83.                (customer_id, full_name, session_id, ip_address, time_entry,
  84.                 time_last_click, last_page_url, host_address, user_agent)
  85.              values ('" . (int)$wo_customer_id . "', '" . zen_db_input($wo_full_name) . "', '"
  86.                          . zen_db_input($wo_session_id) . "', '" . zen_db_input($wo_ip_address)
  87.                          . "', '" . zen_db_input($current_time) . "', '" . zen_db_input($current_time)
  88.                          . "', '" . zen_db_input($wo_last_page_url)
  89.                          . "', '" . zen_db_input($_SESSION['customers_host_address'])
  90.                          . "', '" . zen_db_input($wo_user_agent)
  91.                          . "')";
  92.  
  93.     $db->Execute($sql);
  94.   }
  95. }
  96.  
  97. function whos_online_session_recreate($old_session, $new_session) {
  98.   global $db;
  99.  
  100.   $sql = "UPDATE " . TABLE_WHOS_ONLINE . "
  101.          SET session_id = :newSessionID
  102.          WHERE session_id = :oldSessionID";
  103.   $sql = $db->bindVars($sql, ':newSessionID', $new_session, 'string');
  104.   $sql = $db->bindVars($sql, ':oldSessionID', $old_session, 'string');
  105.   $db->Execute($sql);
  106. }
  107. ?>


cron