Exemplo n.º 1
0
/**
 * Run init functions
 *
 * @param array $request $_REQUEST global variable
 * @return bool always true
 */
function fn_init(&$request)
{
    $stack = Registry::get('init_stack');
    // Cleanup stack
    Registry::set('init_stack', array());
    foreach ($stack as $function_data) {
        $function = array_shift($function_data);
        if (!is_callable($function)) {
            continue;
        }
        $result = call_user_func_array($function, $function_data);
        $status = !empty($result[0]) ? $result[0] : INIT_STATUS_OK;
        $url = !empty($result[1]) ? $result[1] : '';
        $message = !empty($result[2]) ? $result[2] : '';
        $permanent = !empty($result[3]) ? $result[3] : '';
        if ($status == INIT_STATUS_OK && !empty($url)) {
            $redirect_url = $url;
        } elseif ($status == INIT_STATUS_REDIRECT && !empty($url)) {
            $redirect_url = $url;
            break;
        } elseif ($status == INIT_STATUS_FAIL) {
            if (empty($message)) {
                $message = 'Initialization failed in <b>' . (is_array($function) ? implode('::', $function) : $function) . '</b> function';
            }
            throw new InitException($message);
        }
    }
    if (!empty($redirect_url)) {
        if (!defined('CART_LANGUAGE')) {
            fn_init_language($request);
            // we need CART_LANGUAGE in fn_url function that called in fn_redirect
        }
        fn_redirect($redirect_url, true, !empty($permanent));
    }
    $stack = Registry::get('init_stack');
    if (!empty($stack)) {
        // New init functions were added to stack. Execute them
        fn_init($request);
    }
    Debugger::init(true);
    return true;
}
Exemplo n.º 2
0
Session::init();
if (PRODUCT_TYPE == 'MULTIVENDOR') {
    if (AREA == 'A' && !empty($_SESSION['auth']['company_id'])) {
        fn_define('COMPANY_ID', $_SESSION['auth']['company_id']);
    }
}
// Init addons
fn_init_addons();
// get route to controller
fn_get_route();
// initialize store localization
if (AREA == 'C') {
    fn_init_localization($_REQUEST);
}
// initialize store language
fn_init_language($_REQUEST);
// initialize store currency
fn_init_currency($_REQUEST);
// initialize selected company
fn_init_company($_REQUEST);
// Second-level (a) cache: different for dispatch-language-currency
define('CACHE_LEVEL_LOCALE', (defined('CART_LOCALIZATION') ? CART_LOCALIZATION . '_' : '') . CART_LANGUAGE . '_' . CART_SECONDARY_CURRENCY);
// Init addon multilingual options
fn_init_addon_options();
// init revisions
if (AREA == 'A' && Registry::get('settings.General.active_revisions_objects')) {
    require DIR_CORE . 'fn.revisions.php';
    fn_init_revisions();
}
// select the skin to display
fn_init_skin($_REQUEST);