/
loginservice.php
30 lines (29 loc) · 1.11 KB
/
loginservice.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
/**
* @package midcom.services
* @author The Midgard Project, http://www.midgard-project.org
* @copyright The Midgard Project, http://www.midgard-project.org
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
*/
/**
* @package midcom.services
*/
class midcom_cron_loginservice extends midcom_baseclasses_components_cron_handler
{
public function _on_execute()
{
if (midcom::get()->config->get('auth_login_session_timeout')) {
$qb = new midgard_query_builder('midcom_core_login_session_db');
$qb->add_constraint('timestamp', '<', time() - midcom::get()->config->get('auth_login_session_timeout'));
$qb->set_limit(500);
foreach ($qb->execute() as $tmp) {
if (!$tmp->purge()) {
$msg = "Failed to purge login session {$tmp->id}, last Midgard error was: " . midcom_connection::get_error_string();
$this->print_error($msg, $tmp);
} else {
debug_add("Purged login session {$tmp->id}.");
}
}
}
}
}