[TEP-COMMIT] CVS: catalog/catalog/includes/classes currencies.php,1.18,1.19 language.php,1.6,1.7 message_stack.php,1.4,1.5 session.php,1.3,1.4 session_compatible.php,1.3,1.4
cvs-OfajU3CKLf1/[email protected] Mon, 16 Feb 2004 08:18:27 +0100
| Newsgroups | gmane.comp.web.oscommerce.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /pack/cvsroots/oscommerce/catalog/catalog/includes/classes
In directory sunsite.dk:/tmp/cvs-serv16586/includes/classes
Modified Files:
currencies.php language.php message_stack.php session.php
session_compatible.php
Log Message:
use the new database class
Index: currencies.php
===================================================================
RCS file: /pack/cvsroots/oscommerce/catalog/catalog/includes/classes/currencies.php,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- currencies.php 2003/12/18 23:52:14 1.18
+++ currencies.php 2004/02/16 07:08:16 1.19
@@ -5,7 +5,7 @@
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
*/
@@ -15,16 +15,22 @@
// class constructor
function osC_Currencies() {
+ global $osC_Database;
+
$this->currencies = array();
- $currencies_query = tep_db_query("select code, title, symbol_left, symbol_right, decimal_point, thousands_point, decimal_places, value from " . TABLE_CURRENCIES);
- while ($currencies = tep_db_fetch_array($currencies_query)) {
- $this->currencies[$currencies['code']] = array('title' => $currencies['title'],
- 'symbol_left' => $currencies['symbol_left'],
- 'symbol_right' => $currencies['symbol_right'],
- 'decimal_point' => $currencies['decimal_point'],
- 'thousands_point' => $currencies['thousands_point'],
- 'decimal_places' => $currencies['decimal_places'],
- 'value' => $currencies['value']);
+
+ $Qcurrencies = $osC_Database->query('select code, title, symbol_left, symbol_right, decimal_point, thousands_point, decimal_places, value from :table_currencies');
+ $Qcurrencies->bindRaw(':table_currencies', TABLE_CURRENCIES);
+ $Qcurrencies->execute();
+
+ while ($Qcurrencies->next()) {
+ $this->currencies[$Qcurrencies->value('code')] = array('title' => $Qcurrencies->value('title'),
+ 'symbol_left' => $Qcurrencies->value('symbol_left'),
+ 'symbol_right' => $Qcurrencies->value('symbol_right'),
+ 'decimal_point' => $Qcurrencies->value('decimal_point'),
+ 'thousands_point' => $Qcurrencies->value('thousands_point'),
+ 'decimal_places' => $Qcurrencies->valueInt('decimal_places'),
+ 'value' => $Qcurrencies->valueDecimal('value'));
}
}
Index: language.php
===================================================================
RCS file: /pack/cvsroots/oscommerce/catalog/catalog/includes/classes/language.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- language.php 2003/06/28 16:53:09 1.6
+++ language.php 2004/02/16 07:08:16 1.7
@@ -5,7 +5,7 @@
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
@@ -17,6 +17,8 @@
var $languages, $catalog_languages, $browser_languages, $language;
function language($lng = '') {
+ global $osC_Database;
+
$this->languages = array('ar' => 'ar([-_][[:alpha:]]{2})?|arabic',
'bg' => 'bg|bulgarian',
'br' => 'pt[-_]br|brazilian portuguese',
@@ -56,13 +58,19 @@
'zh' => 'zh|chinese simplified');
$this->catalog_languages = array();
- $languages_query = tep_db_query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " order by sort_order");
- while ($languages = tep_db_fetch_array($languages_query)) {
- $this->catalog_languages[$languages['code']] = array('id' => $languages['languages_id'],
- 'name' => $languages['name'],
- 'image' => $languages['image'],
- 'directory' => $languages['directory']);
+
+ $Qlanguages = $osC_Database->query('select languages_id, name, code, image, directory from :table_languages order by sort_order');
+ $Qlanguages->bindRaw(':table_languages', TABLE_LANGUAGES);
+ $Qlanguages->execute();
+
+ while ($Qlanguages->next()) {
+ $this->catalog_languages[$Qlanguages->value('code')] = array('id' => $Qlanguages->valueInt('languages_id'),
+ 'name' => $Qlanguages->value('name'),
+ 'image' => $Qlanguages->value('image'),
+ 'directory' => $Qlanguages->value('directory'));
}
+
+ $Qlanguages->freeResult();
$this->browser_languages = '';
$this->language = '';
Index: message_stack.php
===================================================================
RCS file: /pack/cvsroots/oscommerce/catalog/catalog/includes/classes/message_stack.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- message_stack.php 2003/12/04 22:56:19 1.4
+++ message_stack.php 2004/02/16 07:08:16 1.5
@@ -5,28 +5,17 @@
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
*/
class messageStack {
+ var $messages;
// class constructor
function messageStack() {
- global $osC_Session;
-
$this->messages = array();
-
- if ($osC_Session->exists('messageToStack')) {
- $messageToStack = $osC_Session->value('messageToStack');
-
- for ($i=0, $n=sizeof($messageToStack); $i<$n; $i++) {
- $this->add($messageToStack[$i]['class'], $messageToStack[$i]['text'], $messageToStack[$i]['type']);
- }
-
- $osC_Session->remove('messageToStack');
- }
}
// class methods
@@ -90,6 +79,20 @@
}
return $class_size;
+ }
+
+ function loadFromSession() {
+ global $osC_Session;
+
+ if ($osC_Session->exists('messageToStack')) {
+ $messageToStack = $osC_Session->value('messageToStack');
+
+ for ($i=0, $n=sizeof($messageToStack); $i<$n; $i++) {
+ $this->add($messageToStack[$i]['class'], $messageToStack[$i]['text'], $messageToStack[$i]['type']);
+ }
+
+ $osC_Session->remove('messageToStack');
+ }
}
}
?>
Index: session.php
===================================================================
RCS file: /pack/cvsroots/oscommerce/catalog/catalog/includes/classes/session.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- session.php 2003/12/18 23:42:28 1.3
+++ session.php 2004/02/16 07:08:16 1.4
@@ -5,7 +5,7 @@
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
*/
@@ -21,7 +21,7 @@
global $cookie_path, $cookie_domain;
$this->setName('osCsid');
- $this->setSavePath(SESSION_WRITE_DIRECTORY);
+ $this->setSavePath(DIR_FS_WORK);
session_set_cookie_params(0, $cookie_path, $cookie_domain);
@@ -124,8 +124,8 @@
}
if (STORE_SESSIONS == '') {
- if (file_exists($this->save_path . '/' . $this->id)) {
- @unlink($this->save_path . '/' . $this->id);
+ if (file_exists($this->save_path . $this->id)) {
+ @unlink($this->save_path . $this->id);
}
}
@@ -161,6 +161,10 @@
}
function setSavePath($path) {
+ if (substr($path, -1) == '/') {
+ $path = substr($path, 0, -1);
+ }
+
session_save_path($path);
$this->save_path = session_save_path();
@@ -185,39 +189,80 @@
}
function _read($key) {
- $value_query = tep_db_query("select value from " . TABLE_SESSIONS . " where sesskey = '" . tep_db_input($key) . "' and expiry > '" . time() . "'");
- if (tep_db_num_rows($value_query)) {
- $value = tep_db_fetch_array($value_query);
+ global $osC_Database;
- return $value['value'];
+ $Qsession = $osC_Database->query('select value from :table_sessions where sesskey = :sesskey and expiry > :expiry');
+ $Qsession->bindRaw(':table_sessions', TABLE_SESSIONS);
+ $Qsession->bindValue(':sesskey', $key);
+ $Qsession->bindRaw(':expiry', time());
+ $Qsession->execute();
+
+ if ($Qsession->numberOfRows() > 0) {
+ $value = $Qsession->value('value');
+
+ $Qsession->freeResult();
+
+ return $value;
}
return false;
}
function _write($key, $value) {
+ global $osC_Database;
+
if (!$SESS_LIFE = get_cfg_var('session.gc_maxlifetime')) {
$SESS_LIFE = 1440;
}
$expiry = time() + $SESS_LIFE;
- $check_query = tep_db_query("select count(*) as total from " . TABLE_SESSIONS . " where sesskey = '" . tep_db_input($key) . "'");
- $check = tep_db_fetch_array($check_query);
+ $Qsession = $osC_Database->query('select count(*) as total from :table_sessions where sesskey = :sesskey');
+ $Qsession->bindRaw(':table_sessions', TABLE_SESSIONS);
+ $Qsession->bindValue(':sesskey', $key);
+ $Qsession->execute();
- if ($check['total'] > 0) {
- return tep_db_query("update " . TABLE_SESSIONS . " set expiry = '" . tep_db_input($expiry) . "', value = '" . tep_db_input($value) . "' where sesskey = '" . tep_db_input($key) . "'");
+ if ($Qsession->valueInt('total') > 0) {
+ $Qsession = $osC_Database->query('update :table_sessions set expiry = :expiry, value = :value where sesskey = :sesskey');
} else {
- return tep_db_query("insert into " . TABLE_SESSIONS . " values ('" . tep_db_input($key) . "', '" . tep_db_input($expiry) . "', '" . tep_db_input($value) . "')");
+ $Qsession = $osC_Database->query('insert into :table_sessions values (:sesskey, :expiry, :value)');
}
+ $Qsession->bindRaw(':table_sessions', TABLE_SESSIONS);
+ $Qsession->bindValue(':sesskey', $key);
+ $Qsession->bindValue(':expiry', $expiry);
+ $Qsession->bindValue(':value', $value);
+
+ if ($Qsession->execute()) {
+ $write = true;
+ } else {
+ $write = false;
+ }
+
+ $Qsession->freeResult();
+
+ return $write;
}
function _destroy($key) {
- return tep_db_query("delete from " . TABLE_SESSIONS . " where sesskey = '" . tep_db_input($key) . "'");
+ global $osC_Database;
+
+ $Qsession = $osC_Database->query('delete from :table_sessions where sesskey = :sesskey');
+ $Qsession->bindRaw(':table_sessions', TABLE_SESSIONS);
+ $Qsession->bindValue(':sesskey', $key);
+ $Qsession->execute();
+
+ $Qsession->freeResult();
}
function _gc($maxlifetime) {
- return tep_db_query("delete from " . TABLE_SESSIONS . " where expiry < '" . time() . "'");
+ global $osC_Database;
+
+ $Qsession = $osC_Database->query('delete from :table_sessions where expiry < :expiry');
+ $Qsession->bindRaw(':table_sessions', TABLE_SESSIONS);
+ $Qsession->bindValue(':expiry', time());
+ $Qsession->execute();
+
+ $Qsession->freeResult();
}
}
?>
Index: session_compatible.php
===================================================================
RCS file: /pack/cvsroots/oscommerce/catalog/catalog/includes/classes/session_compatible.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- session_compatible.php 2003/12/17 15:36:14 1.3
+++ session_compatible.php 2004/02/16 07:08:16 1.4
@@ -21,7 +21,7 @@
global $cookie_path, $cookie_domain;
$this->setName('osCsid');
- $this->setSavePath(SESSION_WRITE_DIRECTORY);
+ $this->setSavePath(DIR_FS_WORK);
session_set_cookie_params(0, $cookie_path, $cookie_domain);
@@ -136,8 +136,8 @@
}
if (STORE_SESSIONS == '') {
- if (file_exists($this->save_path . '/' . $this->id)) {
- @unlink($this->save_path . '/' . $this->id);
+ if (file_exists($this->save_path . $this->id)) {
+ @unlink($this->save_path . $this->id);
}
}
@@ -163,6 +163,10 @@
}
function setSavePath($path) {
+ if (substr($path, -1) == '/') {
+ $path = substr($path, 0, -1);
+ }
+
session_save_path($path);
$this->save_path = session_save_path();
-------------------------------------------------------
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