Commit e73ad7d8 authored by tbrehm's avatar tbrehm
Browse files

Fixed a bug in javascript library related to session handling.

parent 22c1e9da
...@@ -42,6 +42,7 @@ class session { ...@@ -42,6 +42,7 @@ class session {
} }
function close () { function close () {
if (!empty($this->fieldarray)) { if (!empty($this->fieldarray)) {
$result = $this->gc(ini_get('session.gc_maxlifetime')); $result = $this->gc(ini_get('session.gc_maxlifetime'));
return $result; return $result;
...@@ -55,7 +56,7 @@ class session { ...@@ -55,7 +56,7 @@ class session {
if (is_array($rec)) { if (is_array($rec)) {
$this->session_array = $rec; $this->session_array = $rec;
return $this->session_array['session_data']; return $rec['session_data'];
} else { } else {
return ''; return '';
} }
...@@ -66,6 +67,7 @@ class session { ...@@ -66,6 +67,7 @@ class session {
if (!empty($this->session_array) && $this->session_array['session_id'] != $session_id) { if (!empty($this->session_array) && $this->session_array['session_id'] != $session_id) {
$this->session_array = array(); $this->session_array = array();
} }
if ($this->session_array['session_id'] == '') { if ($this->session_array['session_id'] == '') {
$session_id = $this->db->quote($session_id); $session_id = $this->db->quote($session_id);
...@@ -74,19 +76,21 @@ class session { ...@@ -74,19 +76,21 @@ class session {
$session_data = $this->db->quote($session_data); $session_data = $this->db->quote($session_data);
$sql = "INSERT INTO sys_session (session_id,date_created,last_updated,session_data) VALUES ('$session_id','$date_created','$last_updated','$session_data')"; $sql = "INSERT INTO sys_session (session_id,date_created,last_updated,session_data) VALUES ('$session_id','$date_created','$last_updated','$session_data')";
$this->db->query($sql); $this->db->query($sql);
} else { } else {
$session_id = $this->db->quote($session_id); $session_id = $this->db->quote($session_id);
$last_updated = date('Y-m-d H:i:s'); $last_updated = date('Y-m-d H:i:s');
$session_data = $this->db->quote($session_data); $session_data = $this->db->quote($session_data);
$sql = "UPDATE sys_session SET last_updated = '$last_updated', session_data = '$session_data' WHERE session_id = '$session_id'"; $sql = "UPDATE sys_session SET last_updated = '$last_updated', session_data = '$session_data' WHERE session_id = '$session_id'";
$this->db->query($sql); $this->db->query($sql);
} }
return true; return true;
} }
function destroy ($session_id) { function destroy ($session_id) {
$session_id = $this->db->quote($session_id); $session_id = $this->db->quote($session_id);
$sql = "DELETE FROM sys_session WHERE session_id = '$session_id'"; $sql = "DELETE FROM sys_session WHERE session_id = '$session_id'";
$this->db->query($sql); $this->db->query($sql);
...@@ -95,7 +99,7 @@ class session { ...@@ -95,7 +99,7 @@ class session {
} }
function gc ($max_lifetime) { function gc ($max_lifetime) {
$real_now = date('Y-m-d H:i:s'); $real_now = date('Y-m-d H:i:s');
$dt1 = strtotime("$real_now -$max_lifetime seconds"); $dt1 = strtotime("$real_now -$max_lifetime seconds");
$dt2 = date('Y-m-d H:i:s', $dt1); $dt2 = date('Y-m-d H:i:s', $dt1);
...@@ -106,11 +110,12 @@ class session { ...@@ -106,11 +110,12 @@ class session {
return true; return true;
} }
function __destruct () { function __destruct () {
@session_write_close(); @session_write_close();
} }
} }
?> ?>
\ No newline at end of file
<?php <?php
session_start(); session_start();
include('../../lib/config.inc.php'); include('../../lib/config.inc.php');
include_once(ISPC_ROOT_PATH.'/web/strengthmeter/lib/lang/'.$_SESSION['s']['language'].'_strengthmeter.lng'); $lang = (isset($_SESSION['s']['language']) && $_SESSION['s']['language'] != '')?$_SESSION['s']['language']:'en';
include_once(ISPC_ROOT_PATH.'/web/strengthmeter/lib/lang/'.$lang.'_strengthmeter.lng');
?> ?>
redirect = ''; redirect = '';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment