Exemple #1
0
         if (!empty($added_products)) {
             Tygh::$app['view']->assign('added_products', $added_products);
             if (Registry::get('config.tweaks.disable_dhtml') && Registry::get('config.tweaks.redirect_to_cart')) {
                 Tygh::$app['view']->assign('continue_url', !empty($_REQUEST['redirect_url']) && empty($_REQUEST['appearance']['details_page']) ? $_REQUEST['redirect_url'] : $_SESSION['continue_url']);
             }
             $msg = Tygh::$app['view']->fetch('views/checkout/components/product_notification.tpl');
             fn_set_notification('I', __($product_cnt > 1 ? 'products_added_to_cart' : 'product_added_to_cart'), $msg, 'I');
             $cart['recalculate'] = true;
         } else {
             fn_set_notification('N', __('notice'), __('product_in_cart'));
         }
     }
     unset($cart['skip_notification']);
     if (Registry::get('config.tweaks.disable_dhtml') && Registry::get('config.tweaks.redirect_to_cart') && !defined('AJAX_REQUEST')) {
         if (!empty($_REQUEST['redirect_url']) && empty($_REQUEST['appearance']['details_page'])) {
             $_SESSION['continue_url'] = fn_url_remove_service_params($_REQUEST['redirect_url']);
         }
         unset($_REQUEST['redirect_url']);
     }
     return array(CONTROLLER_STATUS_OK, 'checkout.cart');
 }
 //
 // Update products quantity in the cart
 //
 if ($mode == 'update') {
     if (!empty($_REQUEST['cart_products'])) {
         foreach ($_REQUEST['cart_products'] as $_key => $_data) {
             if (empty($_data['amount']) && !isset($cart['products'][$_key]['extra']['parent'])) {
                 fn_delete_cart_product($cart, $_key);
             }
         }
Exemple #2
0
/**
 * Looks for "dispatch" parameter in REQUEST array and extracts controller, mode, action and extra parameters.
 *
 * @param array $req Request parameters
 * @param string $area Area
 * @return boolean always true
 */
function fn_get_route(&$req, $area = AREA)
{
    $result = array(INIT_STATUS_OK);
    $is_allowed_url = fn_check_requested_url();
    if (!$is_allowed_url) {
        $request_uri = fn_get_request_uri($_SERVER['REQUEST_URI']);
        $router = new Router($req);
        $router->addRoutes(fn_get_schema('routes', 'objects'));
        if ($params = $router->match($request_uri)) {
            $is_allowed_url = true;
            $req = $params;
        }
    }
    fn_set_hook('get_route', $req, $result, $area, $is_allowed_url);
    if (!$is_allowed_url) {
        $req = array('dispatch' => '_no_page');
    }
    if (!empty($req['dispatch'])) {
        $dispatch = is_array($req['dispatch']) ? key($req['dispatch']) : $req['dispatch'];
    } else {
        $dispatch = 'index.index';
    }
    rtrim($dispatch, '/.');
    $dispatch = str_replace('/', '.', $dispatch);
    $parts = explode('.', $dispatch);
    Registry::set('runtime.controller', !empty($parts[0]) ? basename($parts[0]) : 'index');
    Registry::set('runtime.mode', !empty($parts[1]) ? basename($parts[1]) : 'index');
    Registry::set('runtime.action', !empty($parts[2]) ? $parts[2] : '');
    Registry::set('runtime.dispatch_extra', !empty($parts[3]) ? $parts[3] : '');
    Registry::set('runtime.checkout', false);
    Registry::set('runtime.root_template', 'index.tpl');
    $req['dispatch'] = $dispatch;
    // URL's assignments
    Registry::set('config.current_url', fn_url_remove_service_params(Registry::get('config.' . ACCOUNT_TYPE . '_index') . (!empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '')));
    return $result;
}
Exemple #3
0
$dispatch = $_REQUEST['dispatch'];
$dynamic_object = array();
if (!empty($_REQUEST['dynamic_object'])) {
    $dynamic_object = $_REQUEST['dynamic_object'];
}
$dynamic_object_scheme = SchemesManager::getDynamicObject($dispatch, AREA, $_REQUEST);
if (!empty($dynamic_object_scheme)) {
    $dispatch = $dynamic_object_scheme['customer_dispatch'];
}
Tygh::$app['view']->assign('location_data', Location::instance()->get($dispatch, $dynamic_object, CART_LANGUAGE));
Tygh::$app['view']->assign('layout_data', Registry::get('runtime.layout'));
Tygh::$app['view']->assign('current_mode', fn_get_current_mode($_REQUEST));
// Init cart if not set
if (empty(Tygh::$app['session']['cart'])) {
    fn_clear_cart(Tygh::$app['session']['cart']);
}
if (!empty(Tygh::$app['session']['continue_url'])) {
    Tygh::$app['session']['continue_url'] = fn_url_remove_service_params(Tygh::$app['session']['continue_url']);
}
if (Registry::get('config.demo_mode') && (!empty($_REQUEST['demo_customize_theme']) && $_REQUEST['demo_customize_theme'] == 'Y' || !empty(Tygh::$app['session']['demo_customize_theme']))) {
    Tygh::$app['session']['demo_customize_theme'] = true;
    Registry::set('runtime.customization_mode.theme_editor', true);
    if (!empty($_REQUEST['demo_customize_theme'])) {
        $current_url = Registry::get('config.current_url');
        $current_url = fn_query_remove($current_url, 'demo_customize_theme');
        return array(CONTROLLER_STATUS_REDIRECT, $current_url);
    }
}
if (Registry::get('runtime.customization_mode.live_editor')) {
    Tygh::$app['view']->assign('live_editor_objects', fn_get_schema('customization', 'live_editor_objects'));
}
Exemple #4
0
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
Tygh::$app['view']->assign('descr_sl', DESCR_SL);
if (!empty($auth['user_id']) && $auth['area'] != AREA) {
    $auth = array();
    return array(CONTROLLER_STATUS_REDIRECT, fn_url());
}
if (empty($auth['user_id']) && !fn_check_permissions(Registry::get('runtime.controller'), Registry::get('runtime.mode'), 'trusted_controllers')) {
    if (Registry::get('runtime.controller') != 'index') {
        fn_set_notification('E', __('access_denied'), __('error_not_logged'));
        if (defined('AJAX_REQUEST')) {
            // We should make redirect to page which triggered AJAX-request instead of the AJAX-requested one.
            $login_form_url = 'auth.login_form';
            if (isset($_SERVER['HTTP_REFERER']) && ($referer = @parse_url($_SERVER['HTTP_REFERER'])) && isset($referer['host'], $referer['query']) && $referer['host'] == Registry::get('config.current_host')) {
                $login_form_url .= '?return_url=' . urlencode(fn_url_remove_service_params(Registry::get('config.admin_index') . '?' . $referer['query']));
            }
            Tygh::$app['ajax']->assign('force_redirection', fn_url($login_form_url));
            exit;
        }
    }
    return array(CONTROLLER_STATUS_REDIRECT, 'auth.login_form?return_url=' . urlencode(Registry::get('config.current_url')));
} elseif (!empty($auth['user_id']) && !fn_check_user_type_access_rules($auth)) {
    fn_set_notification('E', __('error'), __('error_area_access_denied'));
    return array(CONTROLLER_STATUS_DENIED);
} elseif (!empty($auth['user_id']) && !fn_check_permissions(Registry::get('runtime.controller'), Registry::get('runtime.mode'), 'trusted_controllers') && $_SERVER['REQUEST_METHOD'] != 'POST') {
    // PCI DSS Compliance
    $auth['password_change_timestamp'] = !empty($auth['password_change_timestamp']) ? $auth['password_change_timestamp'] : 0;
    $time_diff = TIME - $auth['password_change_timestamp'];
    $expire = Registry::get('settings.Security.admin_password_expiration_period') * SECONDS_IN_DAY;
    if (!isset($auth['first_expire_check'])) {
Exemple #5
0
        Development::showStub();
    }
}
if (empty($_REQUEST['product_id']) && empty($_REQUEST['category_id'])) {
    unset($_SESSION['current_category_id']);
}
$dynamic_object = array();
if (!empty($_REQUEST['dynamic_object'])) {
    $dynamic_object = $_REQUEST['dynamic_object'];
}
Registry::get('view')->assign('location_data', Location::instance()->get($_REQUEST['dispatch'], $dynamic_object, CART_LANGUAGE));
Registry::get('view')->assign('layout_data', Registry::get('runtime.layout'));
Registry::get('view')->assign('current_mode', fn_get_current_mode($_REQUEST));
// Init cart if not set
if (empty($_SESSION['cart'])) {
    fn_clear_cart($_SESSION['cart']);
}
if (!empty($_SESSION['continue_url'])) {
    $_SESSION['continue_url'] = fn_url_remove_service_params($_SESSION['continue_url']);
}
if (Registry::get('config.demo_mode') && (!empty($_REQUEST['demo_customize_theme']) && $_REQUEST['demo_customize_theme'] == 'Y' || !empty($_SESSION['demo_customize_theme']))) {
    $_SESSION['demo_customize_theme'] = true;
    Registry::set('runtime.customization_mode.theme_editor', true);
    if (!empty($_REQUEST['demo_customize_theme'])) {
        $current_url = Registry::get('config.current_url');
        $current_url = fn_query_remove($current_url, 'demo_customize_theme');
        return array(CONTROLLER_STATUS_REDIRECT, $current_url);
    }
}
//comparison list number for footer
$view->assign('comparison_list_no', count($_SESSION["comparison_list"]));
/**
 * Looks for "dispatch" parameter in REQUEST array and extracts controller, mode, action and extra parameters.
 *
 * @param array $req Request parameters
 * @param string $area Area
 * @return boolean always true
 */
function fn_get_route(&$req, $area = AREA)
{
    $result = array(INIT_STATUS_OK);
    $is_allowed_url = fn_check_requested_url();
    fn_set_hook('get_route', $req, $result, $area, $is_allowed_url);
    if (!$is_allowed_url) {
        $current_path = Registry::get('config.current_path');
        $clean_uri = substr($_SERVER['REQUEST_URI'], strlen($current_path) + 1);
        $images_substring = 'images/thumbnails/';
        if (strpos($clean_uri, $images_substring) !== false) {
            list(, $clean_uri) = explode($images_substring, $clean_uri);
            if (preg_match("/^(\\d+)[\\/]?(\\d+)?\\/(.*)\$/", $clean_uri, $m)) {
                $req['dispatch'] = 'image.thumbnail';
                $req['w'] = $m[1];
                $req['h'] = $m[2];
                $req['image_path'] = $m[3];
                $is_allowed_url = true;
            }
        }
        if (!$is_allowed_url) {
            $req = array('dispatch' => '_no_page');
        }
    }
    if (!empty($req['dispatch'])) {
        $dispatch = is_array($req['dispatch']) ? key($req['dispatch']) : $req['dispatch'];
    } else {
        $dispatch = 'index.index';
    }
    rtrim($dispatch, '/.');
    $dispatch = str_replace('/', '.', $dispatch);
    @(list($c, $m, $a, $e) = explode('.', $dispatch));
    Registry::set('runtime.controller', empty($c) ? 'index' : $c);
    Registry::set('runtime.mode', empty($m) ? 'index' : $m);
    Registry::set('runtime.action', $a);
    Registry::set('runtime.dispatch_extra', $e);
    Registry::set('runtime.checkout', false);
    Registry::set('runtime.root_template', 'index.tpl');
    $req['dispatch'] = $dispatch;
    // URL's assignments
    Registry::set('config.current_url', fn_url_remove_service_params(Registry::get('config.' . ACCOUNT_TYPE . '_index') . (!empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '')));
    return $result;
}
Exemple #7
0
         if (!empty($added_products)) {
             Tygh::$app['view']->assign('added_products', $added_products);
             if (Registry::get('config.tweaks.disable_dhtml') && Registry::get('config.tweaks.redirect_to_cart')) {
                 Tygh::$app['view']->assign('continue_url', !empty($_REQUEST['redirect_url']) && empty($_REQUEST['appearance']['details_page']) ? $_REQUEST['redirect_url'] : Tygh::$app['session']['continue_url']);
             }
             $msg = Tygh::$app['view']->fetch('views/checkout/components/product_notification.tpl');
             fn_set_notification('I', __($product_cnt > 1 ? 'products_added_to_cart' : 'product_added_to_cart'), $msg, 'I');
             $cart['recalculate'] = true;
         } else {
             fn_set_notification('N', __('notice'), __('product_in_cart'));
         }
     }
     unset($cart['skip_notification']);
     if (Registry::get('config.tweaks.disable_dhtml') && Registry::get('config.tweaks.redirect_to_cart') && !defined('AJAX_REQUEST')) {
         if (!empty($_REQUEST['redirect_url']) && empty($_REQUEST['appearance']['details_page'])) {
             Tygh::$app['session']['continue_url'] = fn_url_remove_service_params($_REQUEST['redirect_url']);
         }
         unset($_REQUEST['redirect_url']);
     }
     return array(CONTROLLER_STATUS_OK, 'checkout.cart');
 }
 //
 // Update products quantity in the cart
 //
 if ($mode == 'update') {
     if (!empty($_REQUEST['cart_products'])) {
         foreach ($_REQUEST['cart_products'] as $_key => $_data) {
             if (empty($_data['amount']) && !isset($cart['products'][$_key]['extra']['parent'])) {
                 fn_delete_cart_product($cart, $_key);
             }
         }