Exemplo n.º 1
0
function is_opendb_valid_session()
{
    if (is_opendb_configured()) {
        if (get_opendb_session_var('login_time') != NULL && get_opendb_session_var('last_access_time') != NULL && get_opendb_session_var('user_id') != NULL && get_opendb_session_var('hash_check') != NULL) {
            $site_r = get_opendb_config_var('site');
            // A valid session as far as the variables go at least.
            if ($site_r['security_hash'] == get_opendb_session_var('hash_check')) {
                // idle_timeout is how long between requests a login session
                // can remain valid.  If login_timeout is set, then this controls
                // how long a session can remain active overall.
                $current_time = time();
                if (!is_numeric($site_r['login_timeout']) || $current_time - get_opendb_session_var('login_time') < $site_r['login_timeout']) {
                    if (!is_numeric($site_r['idle_timeout']) || $current_time - get_opendb_session_var('last_access_time') < $site_r['idle_timeout']) {
                        if (is_user_active(get_opendb_session_var('user_id'))) {
                            // reset the time, as we are only interested in idle session tests.
                            $_SESSION['last_access_time'] = $current_time;
                            return TRUE;
                        } else {
                            opendb_logger(OPENDB_LOG_WARN, __FILE__, __FUNCTION__, 'Invalid user encountered');
                            return FALSE;
                        }
                    }
                }
            } else {
                //if($site_r['security_hash'] == get_opendb_session_var('hash_check'))
                opendb_logger(OPENDB_LOG_WARN, __FILE__, __FUNCTION__, 'Invalid security-hash login invalidated');
                return FALSE;
            }
        }
    }
    //if(is_opendb_configured())
    //else
    return FALSE;
}
Exemplo n.º 2
0
    if (!empty($_POST)) {
        $HTTP_VARS = $_POST;
    }
}
// Strip all slashes from this array.
if (get_magic_quotes_gpc()) {
    $HTTP_VARS = stripslashes_array($HTTP_VARS);
}
//define a global browser sniffer object for use by theme and elsewhere
$_OpendbBrowserSniffer = new OpenDbBrowserSniffer();
// if the mysql[i] extension has been loaded, the db_connect function should exist
if (function_exists('db_connect')) {
    // defaults where no database access
    $_OPENDB_THEME = 'default';
    $_OPENDB_LANGUAGE = 'ENGLISH';
    if (is_opendb_configured()) {
        if (is_db_connected()) {
            // Cache often used configuration entries
            $CONFIG_VARS['logging'] = get_opendb_config_var('logging');
            // Buffer output for possible pushing through ob_gzhandler handler
            if (is_gzip_compression_enabled($PHP_SELF)) {
                ob_start('ob_gzhandler');
            }
            // Restrict cookie to site host and path.
            if (get_opendb_config_var('site', 'restrict_session_cookie_to_host_path') === TRUE) {
                session_set_cookie_params(0, get_site_path(), get_site_host());
            }
            if (get_opendb_config_var('session_handler', 'enable') === TRUE) {
                require_once "./lib/dbsession.php";
                if (strtolower(ini_get('session.save_handler')) == 'user' || ini_set('session.save_handler', 'user')) {
                    session_set_save_handler('db_session_open', 'db_session_close', 'db_session_read', 'db_session_write', 'db_session_destroy', 'db_session_gc');
Exemplo n.º 3
0
/**
	$group and $id should normally both be specified, but if
	$group is only specified, then an array of all items in the group
	will be returned.
*/
function get_opendb_config_var($group, $id = NULL, $keyid = NULL)
{
    if (is_opendb_configured()) {
        global $CONFIG_VARS;
        if ($group != NULL) {
            // override config value.
            if ($group == 'db_server' || $group == 'session_handler' || is_array($CONFIG_VARS[$group])) {
                // cached vars
                if ($id !== NULL && $keyid !== NULL) {
                    return $CONFIG_VARS[$group][$id][$keyid];
                } else {
                    if ($id !== NULL) {
                        return $CONFIG_VARS[$group][$id];
                    } else {
                        return $CONFIG_VARS[$group];
                    }
                }
                // will return an array of all config items in group
            } else {
                $group_r = get_opendb_db_config_var($group);
                if (is_array($group_r)) {
                    $CONFIG_VARS[$group] = $group_r;
                }
                if ($id !== NULL && $keyid !== NULL) {
                    return $CONFIG_VARS[$group][$id][$keyid];
                } else {
                    if ($id !== NULL) {
                        return $CONFIG_VARS[$group][$id];
                    } else {
                        return $CONFIG_VARS[$group];
                    }
                }
            }
        } else {
            //if($group!=NULL)
            return NULL;
        }
    } else {
        return NULL;
    }
}