[ Index ]
 

Code source de osCommerce 2.2ms2-060817

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/catalog/includes/functions/ -> whos_online.php (source)

   1  <?php
   2  /*
   3    $Id: whos_online.php,v 1.11 2003/06/20 00:12:59 hpdl Exp $
   4  
   5    osCommerce, Open Source E-Commerce Solutions
   6    http://www.oscommerce.com
   7  
   8    Copyright (c) 2003 osCommerce
   9  
  10    Released under the GNU General Public License
  11  */
  12  
  13    function tep_update_whos_online() {
  14      global $customer_id;
  15  
  16      if (tep_session_is_registered('customer_id')) {
  17        $wo_customer_id = $customer_id;
  18  
  19        $customer_query = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
  20        $customer = tep_db_fetch_array($customer_query);
  21  
  22        $wo_full_name = $customer['customers_firstname'] . ' ' . $customer['customers_lastname'];
  23      } else {
  24        $wo_customer_id = '';
  25        $wo_full_name = 'Guest';
  26      }
  27  
  28      $wo_session_id = tep_session_id();
  29      $wo_ip_address = getenv('REMOTE_ADDR');
  30      $wo_last_page_url = getenv('REQUEST_URI');
  31  
  32      $current_time = time();
  33      $xx_mins_ago = ($current_time - 900);
  34  
  35  // remove entries that have expired
  36      tep_db_query("delete from " . TABLE_WHOS_ONLINE . " where time_last_click < '" . $xx_mins_ago . "'");
  37  
  38      $stored_customer_query = tep_db_query("select count(*) as count from " . TABLE_WHOS_ONLINE . " where session_id = '" . tep_db_input($wo_session_id) . "'");
  39      $stored_customer = tep_db_fetch_array($stored_customer_query);
  40  
  41      if ($stored_customer['count'] > 0) {
  42        tep_db_query("update " . TABLE_WHOS_ONLINE . " set customer_id = '" . (int)$wo_customer_id . "', full_name = '" . tep_db_input($wo_full_name) . "', ip_address = '" . tep_db_input($wo_ip_address) . "', time_last_click = '" . tep_db_input($current_time) . "', last_page_url = '" . tep_db_input($wo_last_page_url) . "' where session_id = '" . tep_db_input($wo_session_id) . "'");
  43      } else {
  44        tep_db_query("insert into " . TABLE_WHOS_ONLINE . " (customer_id, full_name, session_id, ip_address, time_entry, time_last_click, last_page_url) values ('" . (int)$wo_customer_id . "', '" . tep_db_input($wo_full_name) . "', '" . tep_db_input($wo_session_id) . "', '" . tep_db_input($wo_ip_address) . "', '" . tep_db_input($current_time) . "', '" . tep_db_input($current_time) . "', '" . tep_db_input($wo_last_page_url) . "')");
  45      }
  46    }
  47  ?>


Généré le : Mon Nov 26 19:48:25 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics