Merge branch 'develop' of https://github.com/pandorafms/pandorafms into develop
This commit is contained in:
commit
9e0e996960
|
@ -24,7 +24,10 @@ require_once ('include/functions_db.php');
|
|||
require_once ('include/auth/mysql.php');
|
||||
|
||||
// Real start
|
||||
session_start ();
|
||||
|
||||
if (session_id() == '') {
|
||||
session_start();
|
||||
}
|
||||
|
||||
// Hash login process
|
||||
if (isset ($_GET["loginhash"])) {
|
||||
|
|
|
@ -84,3 +84,13 @@ ALTER TABLE `tperfil` ADD COLUMN `vconsole_management` tinyint(1) NOT NULL DEFAU
|
|||
UPDATE `tperfil` SET `map_view` = 1, `vconsole_view` = 1 WHERE `report_view` = 1;
|
||||
UPDATE `tperfil` SET `map_edit` = 1, `vconsole_edit` = 1 WHERE `report_edit` = 1;
|
||||
UPDATE `tperfil` SET `map_management` = 1, `vconsole_management` = 1 WHERE `report_management` = 1;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tsessions_php`
|
||||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE tsessions_php (
|
||||
`id_session` CHAR(52) NOT NULL,
|
||||
`last_active` INTEGER NOT NULL,
|
||||
`data` TEXT,
|
||||
PRIMARY KEY (`id_session`)
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
|
|
@ -84,3 +84,12 @@ ALTER TABLE tperfil ADD COLUMN vconsole_management NUMBER(1, 0) DEFAULT 0 NOT NU
|
|||
UPDATE tperfil SET map_view = 1, vconsole_view = 1 WHERE report_view = 1;
|
||||
UPDATE tperfil SET map_edit = 1, vconsole_edit = 1 WHERE report_edit = 1;
|
||||
UPDATE tperfil SET map_management = 1, vconsole_management = 1 WHERE report_management = 1;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table tsessions_php
|
||||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE tsessions_php (
|
||||
id_session VARCHAR2(52) NOT NULL PRIMARY KEY,
|
||||
last_active NUMBER(20, 0) NOT NULL,
|
||||
data CLOB default ''
|
||||
);
|
||||
|
|
|
@ -82,3 +82,12 @@ ALTER TABLE "tperfil" ADD COLUMN "vconsole_management" SMALLINT NOT NULL DEFAULT
|
|||
UPDATE "tperfil" SET "map_view" = 1, "vconsole_view" = 1 WHERE "report_view" = 1;
|
||||
UPDATE "tperfil" SET "map_edit" = 1, "vconsole_edit" = 1 WHERE "report_edit" = 1;
|
||||
UPDATE "tperfil" SET "map_management" = 1, "vconsole_management" = 1 WHERE "report_management" = 1;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table tsessions_php
|
||||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE "tsessions_php" (
|
||||
"id_session" SERIAL NOT NULL PRIMARY KEY,
|
||||
"last_active" INTEGER NOT NULL,
|
||||
"data" TEXT default ''
|
||||
);
|
||||
|
|
|
@ -117,6 +117,13 @@ $row[] = __('Yes') . ' ' .
|
|||
$config_double_auth_enabled, true);
|
||||
$table->data[] = $row;
|
||||
|
||||
$row_timeout = array();
|
||||
$row_timeout[] = __('Session timeout (mins)')
|
||||
. ui_print_help_tip(__("This is defined in minutes"), true);
|
||||
if (empty($config["session_timeout"])) $config["session_timeout"] = 90;
|
||||
$row_timeout[] = html_print_input_text ('session_timeout', $config["session_timeout"], '', 10, 10, true);
|
||||
$table->data[] = $row_timeout;
|
||||
|
||||
echo '<form id="form_setup" method="post">';
|
||||
html_print_input_hidden ('update_config', 1);
|
||||
html_print_table ($table);
|
||||
|
|
|
@ -118,6 +118,11 @@ date_default_timezone_set("Europe/Madrid");
|
|||
|
||||
config_process_config();
|
||||
|
||||
config_prepare_session();
|
||||
require_once ($config["homedir"].'/include/load_session.php');
|
||||
$resultado = session_start();
|
||||
|
||||
|
||||
if (!isset($config["homeurl_static"])) {
|
||||
$config["homeurl_static"] = $config["homeurl"];
|
||||
}
|
||||
|
|
|
@ -325,6 +325,8 @@ function config_update_config () {
|
|||
$error_update[] = __('Password');
|
||||
if (!config_update_value ('double_auth_enabled', get_parameter ('double_auth_enabled')))
|
||||
$error_update[] = __('Double authentication');
|
||||
if (!config_update_value ('session_timeout', get_parameter ('session_timeout')))
|
||||
$error_update[] = __('Session timeout');
|
||||
/////////////
|
||||
break;
|
||||
case 'perf':
|
||||
|
@ -1312,6 +1314,10 @@ function config_process_config () {
|
|||
"");
|
||||
}
|
||||
|
||||
if (!isset ($config["session_timeout"])) {
|
||||
config_update_value ('session_timeout', 90);
|
||||
}
|
||||
|
||||
/* Finally, check if any value was overwritten in a form */
|
||||
config_update_config();
|
||||
}
|
||||
|
@ -1525,4 +1531,21 @@ function config_user_set_custom_config() {
|
|||
$config['metaconsole_access'] = $userinfo["metaconsole_access"];
|
||||
}
|
||||
}
|
||||
|
||||
function config_prepare_session() {
|
||||
global $config;
|
||||
|
||||
// Change the session timeout value to session_timeout minutes // 8*60*60 = 8 hours
|
||||
$sessionCookieExpireTime = $config["session_timeout"] * 60;
|
||||
ini_set('session.gc_maxlifetime', $sessionCookieExpireTime);
|
||||
session_set_cookie_params ($sessionCookieExpireTime);
|
||||
|
||||
// Reset the expiration time upon page load //session_name() is default name of session PHPSESSID
|
||||
|
||||
if (isset($_COOKIE[session_name()]))
|
||||
setcookie(session_name(), $_COOKIE[session_name()], time() + $sessionCookieExpireTime, "/");
|
||||
|
||||
ini_set("post_max_size",$config["max_file_size"]);
|
||||
ini_set("upload_max_filesize",$config["max_file_size"]);
|
||||
}
|
||||
?>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
|
||||
function mysql_session_open ($save_path, $session_name) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function mysql_session_close() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function mysql_session_read ($SessionID) {
|
||||
|
||||
$SessionID = addslashes($SessionID);
|
||||
|
||||
$sql = "SELECT data FROM tsessions_php
|
||||
WHERE id_session = '$SessionID'";
|
||||
|
||||
$session_data = db_process_sql($sql);
|
||||
|
||||
if (count($session_data) == 1) {
|
||||
return $session_data[0]['data'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function mysql_session_write ($SessionID, $val) {
|
||||
|
||||
$SessionID = addslashes($SessionID);
|
||||
$val = addslashes($val);
|
||||
|
||||
$sql = "SELECT COUNT(*) FROM tsessions_php
|
||||
WHERE id_session = '$SessionID'";
|
||||
|
||||
$SessionExists = db_process_sql ($sql);
|
||||
|
||||
$session_exists = $SessionExists[0]['COUNT(*)'];
|
||||
|
||||
if ($session_exists == 0) {
|
||||
$now = time();
|
||||
$retval_write = db_process_sql_insert ('tsessions_php', array('id_session'=>$SessionID, 'last_active'=>$now, 'data'=>$val));
|
||||
} else {
|
||||
$now = time();
|
||||
$retval_write = db_process_sql_update ('tsessions_php', array('last_active'=>$now, 'data'=>$val), array('id_session'=>$SessionID));
|
||||
}
|
||||
|
||||
return $retval_write;
|
||||
}
|
||||
|
||||
function mysql_session_destroy ($SessionID) {
|
||||
$SessionID = addslashes($SessionID);
|
||||
|
||||
$retval = db_process_sql ("DELETE FROM tsessions_php
|
||||
WHERE id_session = '$SessionID'");
|
||||
return $retval;
|
||||
}
|
||||
|
||||
function mysql_session_gc ($maxlifetime = 300) {
|
||||
global $config;
|
||||
|
||||
if (isset($config['session_timeout'])) {
|
||||
$maxlifetime = $config['session_timeout'];
|
||||
}
|
||||
|
||||
$CutoffTime = time() - $maxlifetime;
|
||||
|
||||
$retval = db_process_sql("DELETE FROM tsessions_php
|
||||
WHERE last_active < $CutoffTime");
|
||||
return $retval;
|
||||
}
|
||||
|
||||
$resultado_handler = session_set_save_handler ('mysql_session_open', 'mysql_session_close', 'mysql_session_read', 'mysql_session_write', 'mysql_session_destroy', 'mysql_session_gc');
|
||||
|
||||
?>
|
|
@ -1935,3 +1935,12 @@ CREATE TABLE talert_snmp_action (
|
|||
al_field9 CLOB default '' NOT NULL,
|
||||
al_field10 CLOB default '' NOT NULL
|
||||
);
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table tsessions_php
|
||||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE tsessions_php (
|
||||
id_session VARCHAR2(52) NOT NULL PRIMARY KEY,
|
||||
last_active NUMBER(20, 0) NOT NULL,
|
||||
data CLOB default ''
|
||||
);
|
||||
|
|
|
@ -1698,3 +1698,12 @@ CREATE TABLE "talert_snmp_action" (
|
|||
"al_field9" TEXT default '',
|
||||
"al_field10" TEXT default ''
|
||||
);
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table tsessions_php
|
||||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE "tsessions_php" (
|
||||
"id_session" SERIAL NOT NULL PRIMARY KEY,
|
||||
"last_active" INTEGER NOT NULL,
|
||||
"data" TEXT default ''
|
||||
);
|
||||
|
|
|
@ -1796,3 +1796,13 @@ CREATE TABLE IF NOT EXISTS `talert_snmp_action` (
|
|||
`al_field10` text NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tsessions_php`
|
||||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE tsessions_php (
|
||||
`id_session` CHAR(52) NOT NULL,
|
||||
`last_active` INTEGER NOT NULL,
|
||||
`data` TEXT,
|
||||
PRIMARY KEY (`id_session`)
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
|
Loading…
Reference in New Issue