function &getSettings() { static $url_settings; if (!is_array($url_settings)) { $cache = SECache::getInstance(); // Get from cache if (is_object($cache)) { $url_settings = $cache->get('site_url_settings'); } // Get from database if (!is_array($url_settings)) { $database = SEDatabase::getInstance(); $resource = $database->database_query("SELECT url_file, url_regular, url_subdirectory FROM se_urls"); $url_settings = $database->database_load_all_assoc('url_file'); // Special case -_- $url_settings['profile'] = array('url_regular' => 'profile.php?user=$user', 'url_subdirectory' => '$user/'); // Store in cache if (is_object($cache)) { $cache->store($url_settings, 'site_url_settings'); } } } return $url_settings; }
include "include/class_misc.php"; include "include/functions_general.php"; include "include/functions_email.php"; include "include/functions_stats.php"; // JS API MOD JSON FUNCTIONS include "include/class_javascript.php"; if (!function_exists('json_encode')) { include_once "include/xmlrpc/xmlrpc.inc"; include_once "include/xmlrpc/xmlrpcs.inc"; include_once "include/xmlrpc/xmlrpc_wrappers.inc"; include_once "include/jsonrpc/jsonrpc.inc"; include_once "include/jsonrpc/jsonrpcs.inc"; include_once "include/jsonrpc/json_extension_api.inc"; } // INITIATE DATABASE CONNECTION $database =& SEDatabase::getInstance(); // Use this line if you changed the way database connection is loaded //$database = new se_database($database_host, $database_username, $database_password, $database_name); // SET LANGUAGE CHARSET $database->database_set_charset(SE_Language::info('charset')); // GET SETTINGS $setting = $database->database_fetch_assoc($database->database_query("SELECT * FROM se_settings LIMIT 1")); // Instantiate caching object $cache_object = SECache::getInstance(); // ENSURE NO SQL INJECTIONS THROUGH POST OR GET ARRAYS $_POST = security($_POST); $_GET = security($_GET); $_COOKIE = security($_COOKIE); // CREATE SESSION $session_options = @unserialize($setting['setting_session_options']); if (!empty($session_options)) {
function &getSubnetworkInfo($subnet_id) { static $subnetwork_info; if (!is_array($subnetwork_info)) { $subnetwork_info = array(); } if (!isset($subnetwork_info[$subnet_id])) { $cache = SECache::getInstance('serial', array('lifetime' => 3600)); // Get from cache if (is_object($cache)) { $subnetwork_info[$subnet_id] = $cache->get('site_subnetworks_' . $subnet_id); } // Get from database if (!is_array($subnetwork_info[$subnet_id])) { $database = SEDatabase::getInstance(); $resource = $database->database_query("SELECT subnet_id, subnet_name FROM se_subnets WHERE subnet_id='{$subnet_id}' LIMIT 1"); $subnetwork_info[$subnet_id] = $database->database_fetch_assoc($resource); // Store in cache if (is_object($cache)) { $cache->store($subnetwork_info[$subnet_id], 'site_subnetworks_' . $subnet_id); } } } return $subnetwork_info[$subnet_id]; }
function user_auth_token_check() { // We are already logged in? Why are we checking this? if ($this->user_exists) { return true; } $id = @$_COOKIE['se_auth_token']; // No auth token set, fail if (!$id) { return false; } $db =& SEDatabase::getInstance(); $ua = md5($_SERVER['HTTP_USER_AGENT']); $ip = ip2long($_SERVER['REMOTE_ADDR']); $resource = $db->database_query("SELECT session_auth_user_id, session_auth_type FROM se_session_auth WHERE session_auth_key='{$id}' && session_auth_ip='{$ip}' && session_auth_ua='{$ua}' LIMIT 1"); if (!$db->database_num_rows($resource)) { // There was an invalid key, remove it $this->user_auth_token_delete(null, true); return false; } $info = $db->database_fetch_assoc($resource); $persistent = (bool) $info['session_auth_type']; $user_id = $info['session_auth_user_id']; // Should we populate use data here? $this->SEUser(array($user_id)); $this->user_setcookies($persistent); return $user_id; }
function removeResumeKey() { $database =& SEDatabase::getInstance(); $database->database_query("DELETE FROM se_session_keys WHERE session_key_id='" . session_id() . "' LIMIT 1"); }
function gc() { $db =& SEDatabase::getInstance(); $resource = $db->database_query("DELETE FROM se_session_data WHERE session_data_expires < '" . time() . "'"); }
function &getProfileValues($user_id) { static $user_profiles; if (!is_array($user_profiles)) { $user_profiles = array(); } if (!isset($user_profiles[$user_id])) { $cache = SECache::getInstance('serial', array('lifetime' => 3600)); // Get from cache if (is_object($cache)) { $user_profiles[$user_id] = $cache->get('site_user_profiles_' . $user_id); } // Get from database if (!is_array($user_profiles[$user_id])) { $database = SEDatabase::getInstance(); $resource = $database->database_query("SELECT * FROM se_profilevalues WHERE profilevalue_user_id='{$user_id}' LIMIT 1"); $user_profiles[$user_id] = $database->database_fetch_assoc($resource); // Store in cache if (is_object($cache)) { $cache->store($user_profiles[$user_id], 'site_user_profiles_' . $user_id); } } } return $user_profiles[$user_id]; }