/[scire]/scire/.lib/Session.php
Gentoo

Diff of /scire/.lib/Session.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 69 Revision 70
48 } 48 }
49 function _close() { 49 function _close() {
50 $this->_gc($this->maxidle); 50 $this->_gc($this->maxidle);
51 } 51 }
52 function _read($sid) { 52 function _read($sid) {
53 $result = $this->db->select(array('data'), $table, '`sessionid` = \'' . $sid . '\' AND `expiration` > \'' . time() . '\''); 53 $result = $this->db->select(array('data'), $this->table, '`sessionid` = \'' . $sid . '\' AND `expiration` > \'' . time() . '\'');
54 if ($result && (count($result) > 0 && array_key_exists('data', $result[0]))) { 54 if ($result && (count($result) > 0 && array_key_exists('data', $result[0]))) {
55 return $result[0]['data']; 55 return $result[0]['data'];
56 } else { 56 } else {
57 $this->error = $this->db->error; 57 $this->error = $this->db->error;
58 return ''; 58 return '';
59 } 59 }
60 } 60 }
61 function _write($sid, $sdata) { 61 function _write($sid, $sdata) {
62 $expiration = time() + $this->maxidle; 62 $expiration = time() + $this->maxidle;
63 $result = $this->db->insert($table, array('sessionid' => $sid, 'expiration' => $expiration, 'data' => $sdata), array('expiration' => $expiration, 'data' => $sdata)); 63 $result = $this->db->insert($this->table, array('sessionid' => $sid, 'expiration' => $expiration, 'data' => $sdata), array('expiration' => $expiration, 'data' => $sdata));
64 if ($result) { 64 if ($result) {
65 return true; 65 return true;
66 } else { 66 } else {
67 $this->error = $this->db->error; 67 $this->error = $this->db->error;
68 return false; 68 return false;
69 } 69 }
70 } 70 }
71 function _destroy($sid) { 71 function _destroy($sid) {
72 $username = ''; 72 $username = '';
73 $result = $this->db->select(array('data'), $table, '`sessionid` = \'' . $sid . '\''); 73 $result = $this->db->select(array('data'), $this->table, '`sessionid` = \'' . $sid . '\'');
74 if ($result && (count($result) > 0 && array_key_exists('data', $result[0]))) { 74 if ($result && (count($result) > 0 && array_key_exists('data', $result[0]))) {
75 if (preg_match('/^.*username\|s:[0-9]+:"([^"]+)".*$/', $result[0]['data'], $matches)) { 75 if (preg_match('/^.*username\|s:[0-9]+:"([^"]+)".*$/', $result[0]['data'], $matches)) {
76 $username = $matches[1]; 76 $username = $matches[1];
77 } 77 }
78 } 78 }
79 $result = $this->db->delete($table, '`sessionid` = \'' . $sid . '\''); 79 $result = $this->db->delete($this->table, '`sessionid` = \'' . $sid . '\'');
80 if ($result) { 80 if ($result) {
81 if (strlen($username) > 0) { 81 if (strlen($username) > 0) {
82 $result = $this->db->delete($table, '`data` regexp \'^.*username\|s:[0-9]+:"' . $username . '".*$\''); 82 $result = $this->db->delete($this->table, '`data` regexp \'^.*username\|s:[0-9]+:"' . $username . '".*$\'');
83 if ($result) { 83 if ($result) {
84 return true; 84 return true;
85 } else { 85 } else {
86 $this->error = $this->db->error; 86 $this->error = $this->db->error;
87 return false; 87 return false;
93 $this->error = $this->db->error; 93 $this->error = $this->db->error;
94 return false; 94 return false;
95 } 95 }
96 } 96 }
97 function _gc($smaxidle) { 97 function _gc($smaxidle) {
98 $result = $this->db->delete($table, '`expiration` < \'' . time() . '\''); 98 $result = $this->db->delete($this->table, '`expiration` < \'' . time() . '\'');
99 if ($result) { 99 if ($result) {
100 return true; 100 return true;
101 } else { 101 } else {
102 $this->error = $this->db->error; 102 $this->error = $this->db->error;
103 return false; 103 return false;

Legend:
Removed from v.69  
changed lines
  Added in v.70

  ViewVC Help
Powered by ViewVC 1.1.20