pandorafms/pandora_console/include/load_session.php

83 lines
2.3 KiB
PHP
Raw Normal View History

2015-04-13 11:27:23 +02:00
<?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 pandora_session_open ($save_path, $session_name) {
2015-04-13 11:27:23 +02:00
return true;
}
2015-04-13 11:27:23 +02:00
function pandora_session_close() {
2015-04-13 11:27:23 +02:00
return true;
}
2015-04-13 11:27:23 +02:00
function pandora_session_read ($session_id) {
$session_id = addslashes($session_id);
$session_data = db_get_value('data', 'tsessions_php', 'id_session', $session_id);
2015-04-13 11:27:23 +02:00
if (!empty($session_data))
return $session_data;
else
return false;
}
2015-04-13 11:27:23 +02:00
2015-05-20 17:37:39 +02:00
function pandora_session_write ($session_id, $data) {
$session_id = addslashes($session_id);
$values = array();
$values['last_active'] = time();
2015-05-20 17:37:39 +02:00
if (!empty($data))
$values['data'] = addslashes($data);
$session_exists = (bool) db_get_value('COUNT(id_session)', 'tsessions_php', 'id_session', $session_id);
if (!$session_exists) {
$values['id_session'] = $session_id;
$retval_write = db_process_sql_insert('tsessions_php', $values);
}
else {
$retval_write = db_process_sql_update('tsessions_php', $values, array('id_session' => $session_id));
}
2015-04-13 11:27:23 +02:00
return $retval_write;
}
2015-04-13 11:27:23 +02:00
function pandora_session_destroy ($session_id) {
$session_id = addslashes($session_id);
2015-05-20 17:37:39 +02:00
$retval = (bool) db_process_sql_delete('tsessions_php', array('id_session' => $session_id));
2015-04-13 11:27:23 +02:00
return $retval;
}
2015-04-13 11:27:23 +02:00
function pandora_session_gc ($max_lifetime = 300) {
2015-04-13 11:27:23 +02:00
global $config;
if (isset($config['session_timeout'])) {
$max_lifetime = $config['session_timeout'];
2015-04-13 11:27:23 +02:00
}
$time_limit = time() - $max_lifetime;
2015-05-20 17:37:39 +02:00
$retval = (bool) db_process_sql_delete('tsessions_php', array('last_active' => "<" . $time_limit));
2015-04-13 11:27:23 +02:00
return $retval;
}
$result_handler = session_set_save_handler ('pandora_session_open', 'pandora_session_close', 'pandora_session_read', 'pandora_session_write', 'pandora_session_destroy', 'pandora_session_gc');
2015-04-13 11:27:23 +02:00
?>