Skip to content

Commit 5a35aa4

Browse files
author
Till Brehm
committed
Merge branch 'stable-3.0.5' of git.ispconfig.org:ispconfig/ispconfig3 into stable-3.0.5
2 parents 3d96c53 + a2d5721 commit 5a35aa4

File tree

10 files changed

+61
-13
lines changed

10 files changed

+61
-13
lines changed

install/sql/ispconfig3.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,5 +2217,6 @@ INSERT INTO `sys_user` (`userid`, `sys_userid`, `sys_groupid`, `sys_perm_user`,
22172217
--
22182218

22192219
INSERT INTO sys_config VALUES ('1','db','db_version','3.0.5.3');
2220+
INSERT INTO sys_config VALUES ('2','interface','session_timeout','0');
22202221

22212222
SET FOREIGN_KEY_CHECKS = 1;

install/tpl/system.ini.master

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ client_dashlets_right=
4949
customer_no_template=C[CUSTOMER_NO]
5050
customer_no_start=1
5151
customer_no_counter=0
52+
session_timeout=0

interface/lib/app.inc.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ public function __construct() {
6666
if($this->_conf['start_session'] == true) {
6767

6868
$this->uses('session');
69+
$tmp = $this->db->queryOneRecord("SELECT `value` FROM sys_config WHERE `config_id` = 2 AND `group` = 'interface' AND `name` = 'session_timeout'");
70+
if($tmp && $tmp['value'] > 0) {
71+
$this->session->set_timeout($tmp['value']);
72+
session_set_cookie_params(($tmp['value'] * 60) + 300); // make the cookie live 5 minutes longer
73+
} else {
74+
session_set_cookie_params(0); // until browser is closed
75+
}
76+
6977
session_set_save_handler( array($this->session, 'open'),
7078
array($this->session, 'close'),
7179
array($this->session, 'read'),
@@ -74,7 +82,7 @@ public function __construct() {
7482
array($this->session, 'gc'));
7583

7684
session_start();
77-
85+
7886
//* Initialize session variables
7987
if(!isset($_SESSION['s']['id']) ) $_SESSION['s']['id'] = session_id();
8088
if(empty($_SESSION['s']['theme'])) $_SESSION['s']['theme'] = $conf['theme'];

interface/lib/classes/session.inc.php

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,17 @@ class session {
3232

3333
private $session_array = array();
3434
private $db;
35+
private $timeout = 0;
3536

36-
function __construct() {
37+
function __construct($session_timeout = 0) {
3738
$this->db = new db;
39+
$this->timeout = $session_timeout;
40+
}
41+
42+
function set_timeout($session_timeout = 0) {
43+
$old_timeout = $this->timeout;
44+
$this->timeout = $session_timeout;
45+
return $old_timeout;
3846
}
3947

4048
function open ($save_path, $session_name) {
@@ -51,8 +59,12 @@ function close () {
5159
}
5260

5361
function read ($session_id) {
54-
55-
$rec = $this->db->queryOneRecord("SELECT * FROM sys_session WHERE session_id = '".$this->db->quote($session_id)."'");
62+
63+
if($this->timeout > 0) {
64+
$rec = $this->db->queryOneRecord("SELECT * FROM sys_session WHERE session_id = '".$this->db->quote($session_id)."' AND last_updated >= DATE_SUB(NOW(), INTERVAL " . intval($this->timeout) . " MINUTE)");
65+
} else {
66+
$rec = $this->db->queryOneRecord("SELECT * FROM sys_session WHERE session_id = '".$this->db->quote($session_id)."'");
67+
}
5668

5769
if (is_array($rec)) {
5870
$this->session_array = $rec;
@@ -108,12 +120,16 @@ function destroy ($session_id) {
108120

109121
function gc ($max_lifetime) {
110122

111-
$real_now = date('Y-m-d H:i:s');
112-
$dt1 = strtotime("$real_now -$max_lifetime seconds");
113-
$dt2 = date('Y-m-d H:i:s', $dt1);
123+
/*if($this->timeout > 0) {
124+
$this->db->query("DELETE FROM sys_session WHERE last_updated < DATE_SUB(NOW(), INTERVAL " . intval($this->timeout) . " MINUTE)");
125+
} else {*/
126+
$real_now = date('Y-m-d H:i:s');
127+
$dt1 = strtotime("$real_now -$max_lifetime seconds");
128+
$dt2 = date('Y-m-d H:i:s', $dt1);
114129

115-
$sql = "DELETE FROM sys_session WHERE last_updated < '$dt2'";
116-
$this->db->query($sql);
130+
$sql = "DELETE FROM sys_session WHERE last_updated < '$dt2'";
131+
$this->db->query($sql);
132+
//}
117133

118134
return true;
119135

interface/web/admin/form/system_config.tform.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,14 @@
473473
'width' => '30',
474474
'maxlength' => '255'
475475
),
476+
'session_timeout' => array (
477+
'datatype' => 'INTEGER',
478+
'formtype' => 'TEXT',
479+
'default' => '',
480+
'value' => '',
481+
'width' => '30',
482+
'maxlength' => '255'
483+
),
476484
//#################################
477485
// ENDE Datatable fields
478486
//#################################

interface/web/admin/lib/lang/de_system_config.lng

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,9 @@ $wb['reseller_dashlets_left_txt'] = 'Reseller-Dashlets links';
5959
$wb['reseller_dashlets_right_txt'] = 'Reseller-Dashlets rechts';
6060
$wb['client_dashlets_left_txt'] = 'Kunden-Dashlets links';
6161
$wb['client_dashlets_right_txt'] = 'Kunden-Dashlets rechts';
62+
$wb['customer_no_template_txt'] = 'Kundennummer-Vorlage';
63+
$wb['customer_no_template_error_regex_txt'] = 'Die Kundennummer-Vorlage enthält ungültige Zeichen';
64+
$wb['customer_no_start_txt'] = 'Kundennummer Startwert';
65+
$wb['customer_no_counter_txt'] = 'Kundennummer Zähler';
66+
$wb['session_timeout_txt'] = 'Session-Timeout (Minuten)';
6267
?>

interface/web/admin/lib/lang/en_system_config.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,5 @@ $wb['customer_no_template_txt'] = 'Customer No. template';
6363
$wb['customer_no_template_error_regex_txt'] = 'The customer No. template contains invalid characters';
6464
$wb['customer_no_start_txt'] = 'Customer No. start value';
6565
$wb['customer_no_counter_txt'] = 'Customer No. counter';
66+
$wb['session_timeout_txt'] = 'Session timeout (minutes)';
6667
?>

interface/web/admin/system_config_edit.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,17 @@ function onUpdateSave($sql) {
141141
*/
142142

143143
$new_config = $app->tform->encode($this->dataRecord, $section);
144-
if($section == 'sites' && $new_config['vhost_subdomains'] != 'y' && $server_config_array['vhost_subdomains'] == 'y') {
144+
if($section == 'sites' && $new_config['vhost_subdomains'] != 'y' && $server_config_array['sites']['vhost_subdomains'] == 'y') {
145145
// check for existing vhost subdomains, if found the mode cannot be disabled
146146
$check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_domain` WHERE `type` = 'vhostsubdomain'");
147147
if($check['cnt'] > 0) {
148148
$new_config['vhost_subdomains'] = 'y';
149149
}
150150
} elseif($section == 'mail') {
151-
if($new_config['smtp_pass'] == '') $new_config['smtp_pass'] = $server_config_array['smtp_pass'];
151+
if($new_config['smtp_pass'] == '') $new_config['smtp_pass'] = $server_config_array['mail']['smtp_pass'];
152+
} elseif($section == 'misc' && $new_config['session_timeout'] != $server_config_array['misc']['session_timeout']) {
153+
$app->db->query("DELETE FROM sys_config WHERE `config_id` = 2 AND `group` = 'interface' AND `name` = 'session_timeout'");
154+
$app->db->query("INSERT INTO sys_config (`config_id`, `group`, `name`, `value`) VALUES (2, 'interface', 'session_timeout', '" . intval($new_config['session_timeout']) . "')");
152155
}
153156
$server_config_array[$section] = $new_config;
154157
$server_config_str = $app->ini_parser->get_ini_string($server_config_array);

interface/web/admin/templates/system_config_misc_edit.htm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ <h2><tmpl_var name="list_head_txt"></h2>
8181
<label for="customer_no_counter">{tmpl_var name='customer_no_counter_txt'}</label>
8282
<input name="customer_no_counter" id="customer_no_counter" value="{tmpl_var name='customer_no_counter'}" size="30" maxlength="255" type="text" class="textInput formLengthHalf" />
8383
</div>
84-
<div class="ctrlHolder">
84+
<div class="ctrlHolder">
85+
<label for="session_timeout">{tmpl_var name='session_timeout_txt'}</label>
86+
<input name="session_timeout" id="session_timeout" value="{tmpl_var name='session_timeout'}" size="30" maxlength="255" type="text" class="textInput formLengthHalf" />
87+
</div>
88+
<div class="ctrlHolder">
8589
<p class="label">{tmpl_var name='maintenance_mode_txt'}</p>
8690
<div class="multiField">
8791
{tmpl_var name='maintenance_mode'}

interface/web/login/index.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ public function render() {
230230
$_SESSION['s']['user']['theme'] = isset($user['app_theme']) ? $user['app_theme'] : 'default';
231231
$_SESSION['s']['language'] = $user['language'];
232232
$_SESSION["s"]['theme'] = $_SESSION['s']['user']['theme'];
233-
233+
$_SESSION['s']['session_timeout'] = $server_config_array['session_timeout'];
234+
234235
if(is_file($_SESSION['s']['user']['startmodule'].'/lib/module.conf.php')) {
235236
include_once $_SESSION['s']['user']['startmodule'].'/lib/module.conf.php';
236237
$menu_dir = ISPC_WEB_PATH.'/' . $_SESSION['s']['user']['startmodule'] . '/lib/menu.d';

0 commit comments

Comments
 (0)