function api_auth_cookies_has_auth(&$method, $key_row = null)
{
    $ok = login_check_login() ? 1 : 0;
    if (!$ok) {
        return array('ok' => 0, 'error' => 'Invalid user', 'error_code' => 400);
    }
    if (isset($method['requires_perms'])) {
        if ($method['requires_perms'] != 0) {
            return array('ok' => 0, 'error' => 'Insufficient permissions', 'error_code' => 403);
        }
    }
    return array('ok' => 1, 'user' => $GLOBALS['cfg']['user']);
}
<?
	#
	# $Id$
	#

	include("include/init.php");

	#
	# do we have a valid cookie set?
	#

	if (!login_check_login()){
		$GLOBALS['error']['badcookies'] = 1;
		$smarty->display("page_checkcookie.txt");
		exit;
	}

	#
	# where shall we bounce to?
	#

	$redir = $GLOBALS['cfg']['abs_root_url'];

	if ($_redir = get_str("redir")){
		$redir .= $_redir;
	}

	#
	# go!
	#
Exemple #3
0
{
    $out = array('ok' => 0, 'error' => $msg);
    if ($code) {
        $out['error_code'] = $code;
    }
    return $out;
}
#
# Smarty stuff
#
$GLOBALS['error'] = array();
$GLOBALS['smarty']->assign_by_ref('error', $error);
#
# Hey look! Running code! Note that db_init will try
# to automatically connect to the db_main database
# (unless you've disable the 'auto_connect' flag) and
# will blow its brains out if there's a problem.
#
db_init();
if ($this_is_webpage) {
    login_check_login();
}
if (StrToLower($_SERVER['HTTP_X_MOZ']) == 'prefetch') {
    if (!$GLOBALS['cfg']['allow_precache']) {
        error_403();
    }
}
#
# this timer stores the end of core library loading
#
$GLOBALS['timings']['init_end'] = microtime_ms();
function api_config_init_site_keys()
{
    loadlib("api_keys");
    loadlib("api_oauth2_access_tokens");
    $start = microtime_ms();
    login_check_login();
    $token = api_oauth2_access_tokens_fetch_site_token($GLOBALS['cfg']['user']);
    $GLOBALS['smarty']->assign_by_ref("site_token", $token['access_token']);
    $end = microtime_ms();
    $time = $end - $start;
    $GLOBALS['timing_keys']['user_init'] = 'WWW setup';
    $GLOBALS['timings']['user_init_count'] = 1;
    $GLOBALS['timings']['user_init_time'] = $time;
}