public function __construct() { parent::__construct(); $this->db->where('remember_me', FALSE)->where('UNIX_TIMESTAMP(last_activity) <', time() - strtoseconds($this->config->nf_cookie_expire))->delete('nf_sessions'); $this->_ip_address = isset($_SERVER['HTTP_X_REAL_IP']) ? $_SERVER['HTTP_X_REAL_IP'] : $_SERVER['REMOTE_ADDR']; $this->_host_name = utf8_string(gethostbyaddr($this->_ip_address)); if (isset($_COOKIE[$this->config->nf_cookie_name]) && $this->_check_cookie($cookie = $_COOKIE[$this->config->nf_cookie_name], $last_activity)) { if (strtotime($this->config->nf_cookie_expire, $last_activity) < time()) { $this->_session_id(); } else { $this->_session_id = $cookie; } $this->db->where('session_id', $cookie)->update('nf_sessions', array('session_id' => $this->_session_id, 'ip_address' => $this->_ip_address, 'host_name' => $this->_host_name, 'last_activity' => now())); if (!is_null($time_zone = $this('session', 'time_zone'))) { set_time_zone($time_zone); $this->db->update_time_zone(); } } else { if (!is_asset() && !$this->config->ajax_url && !$this->config->ajax_header && $_SERVER['REQUEST_METHOD'] != 'OPTIONS') { $this->_session_id(); $crawler = is_crawler(); if ($crawler !== FALSE) { $this->db->insert('nf_crawlers', array('name' => $crawler, 'path' => $this->config->request_url)); } $this->db->insert('nf_sessions', array('session_id' => $this->_session_id, 'ip_address' => $this->_ip_address, 'host_name' => $this->_host_name, 'is_crawler' => $crawler !== FALSE)); $this->_user_data['session']['date'] = time(); $this->_user_data['session']['javascript'] = FALSE; $this->_user_data['session']['referer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; $this->_user_data['session']['user_agent'] = $_SERVER['HTTP_USER_AGENT']; } } statistics('nf_sessions_max_simultaneous', $this->_sessions = $this->db->select('COUNT(DISTINCT IFNULL(user_id, session_id))')->from('nf_sessions')->where('last_activity > DATE_SUB(NOW(), INTERVAL 5 MINUTE)')->where('is_crawler', FALSE)->row(), function ($a, $b) { return $a > $b; }); }
/** * enable_tmz_support() - switch to custom time zone * * @return - returns true (successful) or false (failed) */ function enable_tmz_support() { return (set_time_zone(CACTI_CUSTOM_TIME_ZONE)) ? true : false; }