Esempio n. 1
0
/**
 * Gets mobile product url
 *
 * @param $product_id
 * @param string $lang_code
 * @return bool
 */
function fn_twg_exim_get_product_mobile_url($product_id, $lang_code = '')
{
    $company_id = 0;
    $company_url = '';
    if (fn_allowed_for('ULTIMATE')) {
        if (Registry::get('runtime.company_id')) {
            $company_id = Registry::get('runtime.company_id');
        } else {
            $company_id = db_get_field('SELECT company_id FROM ?:products WHERE product_id = ?i', $product_id);
        }
        $company_url = '&company_id=' . $company_id;
    } else {
        $company_url = '';
    }
    $settings = TwigmoSettings::get('customer_connections.' . $company_id);
    $use_twg = !empty($settings['access_id']) && ($settings['use_for_phones'] == 'Y' || $settings['use_for_tablets'] == 'Y');
    if ($use_twg && fn_twg_use_https_for_customer($company_id)) {
        $protocol = 'https';
    } else {
        $protocol = 'http';
    }
    $url = fn_url('products.view?product_id=' . $product_id . $company_url, 'C', $protocol, $lang_code);
    fn_set_hook('exim_get_product_url', $url, $product_id, $options, $lang_code);
    return $url;
}
 public static function getCustomerUrl($store, $protocol = 'current')
 {
     if (empty($store['secure_storefront']) or empty($store['storefront'])) {
         $config = Registry::get('config');
         $store['secure_storefront'] = $config['https_host'] . $config['https_path'];
         $store['storefront'] = $config['http_host'] . $config['http_path'];
     }
     if ($protocol == 'current') {
         $protocol = fn_twg_use_https_for_customer($store['company_id']) ? 'https' : 'http';
     }
     $url = $protocol . '://' . ($protocol == 'http' ? $store['storefront'] : $store['secure_storefront']);
     $url .= '/' . Registry::get('config.customer_index') . '?dispatch=' . self::DISPATCH;
     return $url;
 }
Esempio n. 3
-1
function fn_twigmo_before_dispatch()
{
    if ($_SERVER['REQUEST_METHOD'] == 'POST' || AREA != 'C' || !fn_twg_is_updated() || !TwigmoConnector::frontendIsConnected() || empty($_SERVER['HTTP_USER_AGENT']) || defined('AJAX_REQUEST') || $_REQUEST['dispatch'] == 'image.captcha') {
        return;
    }
    if (!isset($_SESSION['twg_state'])) {
        $_SESSION['twg_state'] = array();
    }
    $state = $_SESSION['twg_state'] = fn_twg_get_frontend_state($_REQUEST, $_SESSION['twg_state'], TwigmoSettings::get());
    if (!$state['twg_is_used']) {
        return;
    }
    if (fn_twg_use_https_for_customer() && !defined('HTTPS')) {
        fn_redirect(Registry::get('config.https_location') . '/' . Registry::get('config.current_url'));
    }
    $local_jsurl = Registry::get('config.twg.jsurl');
    $template = $local_jsurl ? 'mobile_index_dev.tpl' : 'mobile_index.tpl';
    Registry::set('runtime.root_template', 'addons/twigmo/' . $template);
    Registry::set('runtime.inside_scripts', 1);
    $view = fn_twg_get_view_object();
    $view->assign('urls', TwigmoConnector::getMobileScriptsUrls($local_jsurl));
    $view->assign('repo_revision', TwigmoSettings::get('repo_revision'));
    $view->assign('twg_state', $state);
    fn_twg_assign_google_template();
    if ($state['theme_editor_mode']) {
        header("X-Frame-Options: ");
    }
}