24 |
var $max_duration = 43200; |
var $max_duration = 43200; |
25 |
|
|
26 |
// Database variables |
// Database variables |
27 |
var $db_session = "libsession"; |
#var $session_dsn = 'mysql://libsession:libsessionpw@localhost/libsession'; |
28 |
var $db_session_srv = "localhost"; |
var $session_dsn = 'pgsql://dpavlin@/libdata'; |
|
var $db_session_usr = "libsession"; |
|
|
var $db_session_pwd = "libsessionpw"; |
|
29 |
|
|
30 |
|
|
31 |
/********************************************************** |
/********************************************************** |
39 |
**********************************************************/ |
**********************************************************/ |
40 |
function sessionClass($duration, $session_id, $staff_account) { |
function sessionClass($duration, $session_id, $staff_account) { |
41 |
|
|
42 |
// Set the database connection variables |
// Set the database connection variables |
43 |
$this->con_session = @mysql_connect ( $this->db_session_srv, $this->db_session_usr, $this->db_session_pwd ) |
global $dsn_options; |
44 |
or die ( "ERROR: Could not connect to database server!" ); |
$this->con_session =& DB::connect($this->session_dsn, $dsn_options); |
45 |
$this->result_session = mysql_select_db ( $this->db_session, $this->con_session ) |
if (DB::isError($db)) { |
46 |
or die ( "ERROR: Could not connect to database!" ); |
# XXX remove this! |
47 |
|
print $db->getDebugInfo(); |
48 |
|
|
49 |
|
die($db->getMessage()); |
50 |
|
} |
51 |
|
|
52 |
// Fetch user ip |
// Fetch user ip |
53 |
$user_ip = $GLOBALS["REMOTE_ADDR"]; |
$user_ip = $GLOBALS["REMOTE_ADDR"]; |
104 |
. $time_expire |
. $time_expire |
105 |
. "')"; |
. "')"; |
106 |
|
|
107 |
// mysql_query ("LOCK TABLE session WRITE", $this->con_session); |
// xx_query ("LOCK TABLE session WRITE", $this->con_session); |
108 |
if (!mysql_query($sql, $this->con_session)){ |
if (!xx_query($sql, $this->con_session)){ |
109 |
mysql_query ("UNLOCK TABLES", $this->con_session); |
xx_query ("UNLOCK TABLES", $this->con_session); |
110 |
$this->bailout(); |
$this->bailout(); |
111 |
} |
} |
112 |
else { |
else { |
113 |
mysql_query("UNLOCK TABLES", $this->con_session); |
xx_query("UNLOCK TABLES", $this->con_session); |
114 |
} |
} |
115 |
|
|
116 |
|
|
191 |
|
|
192 |
// The SQL |
// The SQL |
193 |
$sql = "SELECT * FROM session where session_id = '" . $hash . "'"; |
$sql = "SELECT * FROM session where session_id = '" . $hash . "'"; |
194 |
$rs = mysql_query($sql, $con_session); |
$rs = xx_query($sql, $con_session); |
195 |
$duplicate = mysql_num_rows($rs); |
$duplicate = xx_num_rows($rs); |
196 |
if ($duplicate > 0) { |
if ($duplicate > 0) { |
197 |
$duplicate = 1; |
$duplicate = 1; |
198 |
$hash = "0"; |
$hash = "0"; |
231 |
. "' AND user_ip = '" |
. "' AND user_ip = '" |
232 |
. $user_ip |
. $user_ip |
233 |
."'"; |
."'"; |
234 |
$rs = mysql_query($sql, $con_session); |
$rs = xx_query($sql, $con_session); |
235 |
$valid = mysql_num_rows($rs); |
$valid = xx_num_rows($rs); |
236 |
$row = mysql_fetch_array ($rs); |
$row = xx_fetch_array ($rs); |
237 |
$time_human = $row["time_human"]; |
$time_human = $row["time_human"]; |
238 |
$time_unix = $row["time_unix"]; |
$time_unix = $row["time_unix"]; |
239 |
$time_expire = $row["time_expire"]; |
$time_expire = $row["time_expire"]; |
294 |
. $user_ip |
. $user_ip |
295 |
. "'"; |
. "'"; |
296 |
|
|
297 |
//mysql_query ("LOCK TABLE session WRITE", $con_session); |
//xx_query ("LOCK TABLE session WRITE", $con_session); |
298 |
if (!mysql_query($sql, $con_session)){ |
if (!xx_query($sql, $con_session)){ |
299 |
mysql_query ("UNLOCK TABLES", $con_session); |
xx_query ("UNLOCK TABLES", $con_session); |
300 |
$this->bailout(); |
$this->bailout(); |
301 |
} |
} |
302 |
else { |
else { |
303 |
mysql_query("UNLOCK TABLES", $con_session); |
xx_query("UNLOCK TABLES", $con_session); |
304 |
$this->setProperties($session_id, $user_ip); |
$this->setProperties($session_id, $user_ip); |
305 |
} |
} |
306 |
|
|
331 |
|
|
332 |
$sql = "DELETE FROM session where time_expire < " . $time_unix; |
$sql = "DELETE FROM session where time_expire < " . $time_unix; |
333 |
|
|
334 |
if (!mysql_query($sql, $con_session)){ |
if (!xx_query($sql, $con_session)){ |
335 |
sql_err($con_session); |
sql_err($con_session); |
336 |
mysql_query ("UNLOCK TABLES", $con_session); |
xx_query ("UNLOCK TABLES", $con_session); |
337 |
bailout(); |
bailout(); |
338 |
} |
} |
339 |
else { |
else { |
340 |
mysql_query("UNLOCK TABLES", $con_session); |
xx_query("UNLOCK TABLES", $con_session); |
341 |
} |
} |
342 |
} // end of function |
} // end of function |
343 |
} // end of class |
} // end of class |