[TEP-COMMIT] CVS: catalog/catalog/includes/functions whos_online.php,1.12,1.13

cvs-OfajU3CKLf1/[email protected] Mon, 16 Feb 2004 08:32:05 +0100
Newsgroups gmane.comp.web.oscommerce.cvs
Message-ID <[email protected]>
Update of /pack/cvsroots/oscommerce/catalog/catalog/includes/functions
In directory sunsite.dk:/tmp/cvs-serv20966

Modified Files:
	whos_online.php 
Log Message:
use the new database class


Index: whos_online.php
===================================================================
RCS file: /pack/cvsroots/oscommerce/catalog/catalog/includes/functions/whos_online.php,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- whos_online.php	2003/11/17 18:39:22	1.12
+++ whos_online.php	2004/02/16 07:24:07	1.13
@@ -5,13 +5,13 @@
   osCommerce, Open Source E-Commerce Solutions
   http://www.oscommerce.com
 
-  Copyright (c) 2003 osCommerce
+  Copyright (c) 2004 osCommerce
 
   Released under the GNU General Public License
 */
 
   function tep_update_whos_online() {
-    global $osC_Session, $osC_Customer;
+    global $osC_Session, $osC_Customer, $osC_Database;
 
     if ($osC_Customer->isLoggedOn()) {
       $wo_customer_id = $osC_Customer->id;
@@ -29,15 +29,39 @@
     $xx_mins_ago = ($current_time - 900);
 
 // remove entries that have expired
-    tep_db_query("delete from " . TABLE_WHOS_ONLINE . " where time_last_click < '" . $xx_mins_ago . "'");
+    $Qwhosonline = $osC_Database->query('delete from :table_whos_online where time_last_click < :time_last_click');
+    $Qwhosonline->bindRaw(':table_whos_online', TABLE_WHOS_ONLINE);
+    $Qwhosonline->bindValue(':time_last_click', $xx_mins_ago);
+    $Qwhosonline->execute();
 
-    $stored_customer_query = tep_db_query("select count(*) as count from " . TABLE_WHOS_ONLINE . " where session_id = '" . tep_db_input($wo_session_id) . "'");
-    $stored_customer = tep_db_fetch_array($stored_customer_query);
+    $Qwhosonline = $osC_Database->query('select count(*) as count from :table_whos_online where session_id = :session_id');
+    $Qwhosonline->bindRaw(':table_whos_online', TABLE_WHOS_ONLINE);
+    $Qwhosonline->bindValue(':session_id', $wo_session_id);
+    $Qwhosonline->execute();
 
-    if ($stored_customer['count'] > 0) {
-      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) . "'");
+    if ($Qwhosonline->valueInt('count') > 0) {
+      $Qwhosonline = $osC_Database->query('update :table_whos_online set customer_id = :customer_id, full_name = :full_name, ip_address = :ip_address, time_last_click = :time_last_click, last_page_url = :last_page_url where session_id = :session_id');
+      $Qwhosonline->bindRaw(':table_whos_online', TABLE_WHOS_ONLINE);
+      $Qwhosonline->bindInt(':customer_id', $wo_customer_id);
+      $Qwhosonline->bindValue(':full_name', $wo_full_name);
+      $Qwhosonline->bindValue(':ip_address', $wo_ip_address);
+      $Qwhosonline->bindValue(':time_last_click', $current_time);
+      $Qwhosonline->bindValue(':last_page_url', $wo_last_page_url);
+      $Qwhosonline->bindValue(':session_id', $wo_session_id);
+      $Qwhosonline->execute();
     } else {
-      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) . "')");
+      $Qwhosonline = $osC_Database->query('insert into :table_whos_online (customer_id, full_name, session_id, ip_address, time_entry, time_last_click, last_page_url) values (:customer_id, :full_name, :session_id, :ip_address, :time_entry, :time_last_click, :last_page_url)');
+      $Qwhosonline->bindRaw(':table_whos_online', TABLE_WHOS_ONLINE);
+      $Qwhosonline->bindInt(':customer_id', $wo_customer_id);
+      $Qwhosonline->bindValue(':full_name', $wo_full_name);
+      $Qwhosonline->bindValue(':session_id', $wo_session_id);
+      $Qwhosonline->bindValue(':ip_address', $wo_ip_address);
+      $Qwhosonline->bindValue(':time_entry', $current_time);
+      $Qwhosonline->bindValue(':time_last_click', $current_time);
+      $Qwhosonline->bindValue(':last_page_url', $wo_last_page_url);
+      $Qwhosonline->execute();
     }
+
+    $Qwhosonline->freeResult();
   }
 ?>



-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click