Skip to content
This repository was archived by the owner on May 24, 2022. It is now read-only.

Commit b9cd970

Browse files
committed
issue #97 modification of session timeout mechanism
Now session timeout worked =) And it is described in config file and no possibility to set it for each user differently. Furthermore added setting of session store path.
1 parent c7e1f42 commit b9cd970

File tree

5 files changed

+18
-26
lines changed

5 files changed

+18
-26
lines changed

app/classes/BaseController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function onBefore() {
6767

6868
//if auth is disabled
6969
if ($server && !$server->mongoAuth() && !$server->controlAuth()) {
70-
MUser::login("rockmongo_memo", "rockmongo_memo", xi("host"), "admin", 10800);
70+
MUser::login("rockmongo_memo", "rockmongo_memo", xi("host"), "admin");
7171
$this->_admin = MUser::userInSession();
7272
}
7373
else {
@@ -139,10 +139,10 @@ protected function _convertValue($mongodb, $dataType, $format, $value, $integerV
139139
case "long":
140140
if (class_exists("MongoInt64")) {
141141
$realValue = new MongoInt64($longValue);
142-
}
142+
}
143143
else {
144144
$realValue = $longValue;
145-
}
145+
}
146146
break;
147147
case "float":
148148
case "double":

app/controllers/login.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ public function doIndex() {
2121
$this->db = trim(xn("db"));
2222
$this->hostIndex = xi("host");
2323
$this->languages = rock_load_languages();
24-
$this->expires = array(
25-
3 => "3 " . rock_lang("hours"),
26-
720 => "1 " . rock_lang("month"),
27-
);
2824
$this->moreOptions = xi("more");
2925

3026
if ($this->isPost()) {
@@ -44,7 +40,7 @@ public function doIndex() {
4440

4541
//remember user
4642
import("models.MUser");
47-
MUser::login($this->username, $password, $this->hostIndex, $this->db, xi("expire") * 3600);
43+
MUser::login($this->username, $password, $this->hostIndex, $this->db);
4844

4945
//remember lang
5046
setcookie("ROCK_LANG", x("lang"), time() + 365 * 86400);

app/models/MUser.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ class MUser {
55
private $_password;
66
private $_hostIndex;
77
private $_db;
8-
private $_timeout;
98

109
public function __construct() {
1110

@@ -63,10 +62,6 @@ public function dbs() {
6362
return preg_split("/\\s*,\\s*/", $this->_db);
6463
}
6564

66-
public function setTimeout($timeout) {
67-
$this->_timeout = $timeout;
68-
}
69-
7065
/**
7166
* Validate User
7267
*
@@ -90,14 +85,13 @@ public function changeHost($hostIndex) {
9085
$_SESSION["login"]["index"] = $hostIndex;
9186
}
9287

93-
public static function login($username, $password, $hostIndex, $db, $timeout) {
88+
public static function login($username, $password, $hostIndex, $db) {
9489
$_SESSION["login"] = array(
9590
"username" => $username,
9691
"password" => $password,
9792
"index" => $hostIndex,
9893
"db" => $db
9994
);
100-
setcookie(session_name(), session_id(), time() + $timeout);
10195
}
10296

10397
/**

config.sample.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,19 @@
55
* Defining default options and server configuration
66
* @package rockmongo
77
*/
8-
8+
9+
// session store configurating
10+
11+
// Timeuot of session in seconds
12+
ini_set('session.gc_maxlifetime', 60*60*3); //3 hours
13+
14+
// this defines, where session files will be stored.
15+
// it is important in this case: http://php.net/manual/en/session.configuration.php#ini.session.gc-maxlifetime
16+
$currentSessionPath = ini_get('session.save_path');
17+
$save_path = $currentSessionPath . DIRECTORY_SEPARATOR . 'rockmongo';
18+
if (!is_dir($save_path)) mkdir($save_path, 0777, true);
19+
ini_set('session.save_path', $save_path);
20+
921
$MONGO = array();
1022
$MONGO["features"]["log_query"] = "on";//log queries
1123
$MONGO["features"]["theme"] = "default";//theme

themes/default/views/login/index.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,6 @@ function r_show_more_options(btn) {
6969
<?php endforeach;?>
7070
</select></td>
7171
</tr>
72-
<tr>
73-
<td><?php hm("alive"); ?>:</td>
74-
<td>
75-
<select name="expire" style="width:150px">
76-
<?php foreach ($expires as $long => $name):?>
77-
<option value="<?php h($long);?>"><?php h($name);?></option>
78-
<?php endforeach;?>
79-
</select>
80-
</td>
81-
</tr>
8272
</tbody>
8373
<tr>
8474
<td colspan="2" align="center"><input type="submit" value="<?php hm("loginandrock"); ?>"/></td>

0 commit comments

Comments
 (0)