--- branches/pear-db/admin/include/sessionClass.php 2004/03/05 13:54:58 49 +++ branches/pear-db/admin/include/sessionClass.php 2004/03/05 22:38:33 50 @@ -24,10 +24,8 @@ var $max_duration = 43200; // Database variables -var $db_session = "libsession"; -var $db_session_srv = "localhost"; -var $db_session_usr = "libsession"; -var $db_session_pwd = "libsessionpw"; +#var $session_dsn = 'mysql://libsession:libsessionpw@localhost/libsession'; +var $session_dsn = 'pgsql://dpavlin@/libdata'; /********************************************************** @@ -41,11 +39,15 @@ **********************************************************/ function sessionClass($duration, $session_id, $staff_account) { - // Set the database connection variables - $this->con_session = @mysql_connect ( $this->db_session_srv, $this->db_session_usr, $this->db_session_pwd ) - or die ( "ERROR: Could not connect to database server!" ); - $this->result_session = mysql_select_db ( $this->db_session, $this->con_session ) - or die ( "ERROR: Could not connect to database!" ); + // Set the database connection variables + global $dsn_options; + $this->con_session =& DB::connect($this->session_dsn, $dsn_options); + if (DB::isError($db)) { + # XXX remove this! + print $db->getDebugInfo(); + + die($db->getMessage()); + } // Fetch user ip $user_ip = $GLOBALS["REMOTE_ADDR"]; @@ -102,13 +104,13 @@ . $time_expire . "')"; - // mysql_query ("LOCK TABLE session WRITE", $this->con_session); - if (!mysql_query($sql, $this->con_session)){ - mysql_query ("UNLOCK TABLES", $this->con_session); + // xx_query ("LOCK TABLE session WRITE", $this->con_session); + if (!xx_query($sql, $this->con_session)){ + xx_query ("UNLOCK TABLES", $this->con_session); $this->bailout(); } else { - mysql_query("UNLOCK TABLES", $this->con_session); + xx_query("UNLOCK TABLES", $this->con_session); } @@ -189,8 +191,8 @@ // The SQL $sql = "SELECT * FROM session where session_id = '" . $hash . "'"; - $rs = mysql_query($sql, $con_session); - $duplicate = mysql_num_rows($rs); + $rs = xx_query($sql, $con_session); + $duplicate = xx_num_rows($rs); if ($duplicate > 0) { $duplicate = 1; $hash = "0"; @@ -229,9 +231,9 @@ . "' AND user_ip = '" . $user_ip ."'"; - $rs = mysql_query($sql, $con_session); - $valid = mysql_num_rows($rs); - $row = mysql_fetch_array ($rs); + $rs = xx_query($sql, $con_session); + $valid = xx_num_rows($rs); + $row = xx_fetch_array ($rs); $time_human = $row["time_human"]; $time_unix = $row["time_unix"]; $time_expire = $row["time_expire"]; @@ -292,13 +294,13 @@ . $user_ip . "'"; - //mysql_query ("LOCK TABLE session WRITE", $con_session); - if (!mysql_query($sql, $con_session)){ - mysql_query ("UNLOCK TABLES", $con_session); + //xx_query ("LOCK TABLE session WRITE", $con_session); + if (!xx_query($sql, $con_session)){ + xx_query ("UNLOCK TABLES", $con_session); $this->bailout(); } else { - mysql_query("UNLOCK TABLES", $con_session); + xx_query("UNLOCK TABLES", $con_session); $this->setProperties($session_id, $user_ip); } @@ -329,13 +331,13 @@ $sql = "DELETE FROM session where time_expire < " . $time_unix; - if (!mysql_query($sql, $con_session)){ + if (!xx_query($sql, $con_session)){ sql_err($con_session); - mysql_query ("UNLOCK TABLES", $con_session); + xx_query ("UNLOCK TABLES", $con_session); bailout(); } else { - mysql_query("UNLOCK TABLES", $con_session); + xx_query("UNLOCK TABLES", $con_session); } } // end of function } // end of class