function content_55ddef5142ee54_11458549($_smarty_tpl) { if (!is_callable('smarty_function_set_id')) { include '/home/coriolan/public_html/lead/app/functions/smarty_plugins/function.set_id.php'; } if ($_smarty_tpl->tpl_vars['runtime']->value['customization_mode']['design'] == "Y" && @constant('AREA') == "C") { $_smarty_tpl->_capture_stack[0][] = array("template_content", null, null); ob_start(); $_smarty_tpl->tpl_vars["_cms_mag_set"] = new Smarty_variable(fn_set_cookie("cms_mag", "true", 3600), null, 0); ?> <script> var check = "<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['_cms_mag_set']->value, ENT_QUOTES, 'UTF-8'); ?> "; if (check === true) { $("head").append('<meta name="cmsmagazine" content="c625963813fc0db1e0c69a0f7ba350f6" />'); } </script><?php list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]); if (!empty($_capture_buffer)) { if (isset($_capture_assign)) { $_smarty_tpl->assign($_capture_assign, ob_get_contents()); } if (isset($_capture_append)) { $_smarty_tpl->append($_capture_append, ob_get_contents()); } Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean(); } else { $_smarty_tpl->capture_error(); } if (trim(Smarty::$_smarty_vars['capture']['template_content'])) { if ($_smarty_tpl->tpl_vars['auth']->value['area'] == "A") { ?> <span class="cm-template-box template-box" data-ca-te-template="addons/orders_feedback/hooks/index/scripts.post.tpl" id="<?php echo smarty_function_set_id(array('name' => "addons/orders_feedback/hooks/index/scripts.post.tpl"), $_smarty_tpl); ?> "><div class="cm-template-icon icon-edit ty-icon-edit hidden"></div><?php echo Smarty::$_smarty_vars['capture']['template_content']; ?> <!--[/tpl_id]--></span><?php } else { echo Smarty::$_smarty_vars['capture']['template_content']; } } } else { $_smarty_tpl->tpl_vars["_cms_mag_set"] = new Smarty_variable(fn_set_cookie("cms_mag", "true", 3600), null, 0); ?> <script> var check = "<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['_cms_mag_set']->value, ENT_QUOTES, 'UTF-8'); ?> "; if (check === true) { $("head").append('<meta name="cmsmagazine" content="c625963813fc0db1e0c69a0f7ba350f6" />'); } </script><?php } }
if (Registry::get('settings.General.auto_check_updates') == 'Y' && fn_check_user_access($auth['user_id'], 'upgrade_store')) { // If upgrades available $uc_settings = fn_get_settings('Upgrade_center'); $data = fn_get_contents($uc_settings['updates_server'] . '/index.php?target=product_updates&mode=check_available&ver=' . PRODUCT_VERSION); /* NULLED BY FLIPMODE! @ 2010/09/06 */ // $data = fn_get_contents($uc_settings['updates_server'] . '/index.php?target=product_updates&mode=check_available&ver=' . PRODUCT_VERSION . '&license_number=' . $uc_settings['license_number']); if ($data == 'AVAILABLE') { $msg = fn_get_lang_var('text_upgrade_available'); $msg = str_replace('[link]', fn_url('upgrade_center.manage'), $msg); fn_set_notification('W', fn_get_lang_var('notice'), $msg, true, 'upgrade_center'); } } } if (!empty($_REQUEST['remember_me'])) { fn_set_cookie(AREA_NAME . '_user_id', $user_data['user_id'], COOKIE_ALIVE_TIME); fn_set_cookie(AREA_NAME . '_password', $user_data['password'], COOKIE_ALIVE_TIME); } // Set last login time db_query("UPDATE ?:users SET ?u WHERE user_id = ?i", array('last_login' => TIME), $user_data['user_id']); $_SESSION['auth']['this_login'] = TIME; $_SESSION['auth']['ip'] = $_SERVER['REMOTE_ADDR']; // Log user successful login fn_log_event('users', 'session', array('user_id' => $user_data['user_id'])); if (AREA == 'C') { if ($cu_id = fn_get_cookie('cu_id')) { fn_clear_cart($cart); fn_save_cart_content($cart, $cu_id, 'C', 'U'); fn_delete_cookies('cu_id'); } fn_init_user_session_data($_SESSION, $user_data['user_id']); }
/** * Init localizations * * @param array $params request parameters * @return boolean true if localizations exists, false otherwise */ function fn_init_localization($params) { $locs = db_get_hash_array("SELECT localization_id, custom_weight_settings, weight_symbol, weight_unit FROM ?:localizations WHERE status = 'A'", 'localization_id'); if (empty($locs)) { return false; } if (!empty($_REQUEST['lc']) && !empty($locs[$_REQUEST['lc']])) { $cart_localization = $_REQUEST['lc']; } elseif (($l = fn_get_cookie('cart_localization')) && !empty($locs[$l])) { $cart_localization = $l; } else { $_ip = fn_get_ip(true); $_country = fn_get_country_by_ip($_ip['host']); $_lngs = db_get_hash_single_array("SELECT lang_code, 1 as 'l' FROM ?:languages WHERE status = 'A'", array('lang_code', 'l')); $_language = fn_get_browser_language($_lngs); $cart_localization = db_get_field("SELECT localization_id, COUNT(localization_id) as c FROM ?:localization_elements WHERE (element = ?s AND element_type = 'C') OR (element = ?s AND element_type = 'L') GROUP BY localization_id ORDER BY c DESC LIMIT 1", $_country, $_language); if (empty($cart_localization) || empty($locs[$cart_localization])) { $cart_localization = db_get_field("SELECT localization_id FROM ?:localizations WHERE status = 'A' AND is_default = 'Y'"); } } if (empty($cart_localization)) { reset($locs); $cart_localization = key($locs); } if ($cart_localization != fn_get_cookie('cart_localization')) { fn_set_cookie('cart_localization', $cart_localization, COOKIE_ALIVE_TIME); } if ($locs[$cart_localization]['custom_weight_settings'] == 'Y') { Registry::set('config.localization.weight_symbol', $locs[$cart_localization]['weight_symbol']); Registry::set('config.localization.weight_unit', $locs[$cart_localization]['weight_unit']); } fn_define('CART_LOCALIZATION', $cart_localization); return true; }
public static function quit() { if (!(defined('DEBUG_MODE') && DEBUG_MODE == true)) { fn_set_cookie('debugger', '', 0); unset(self::$actives[self::$debugger_cookie]); fn_set_storage_data('debugger_active', serialize(self::$actives)); Registry::del('debugger.data.' . self::$debugger_cookie); } }
return array(CONTROLLER_STATUS_REDIRECT, "checkout.cart"); } } } $_last_order_time = fn_get_cookie('last_order_time'); /*if (!empty($_last_order_time) && ($_last_order_time + ORDERS_TIMEOUT > TIME)) { fn_set_notification('E', fn_get_lang_var('error'), str_replace('[minutes]', round(ORDERS_TIMEOUT / 60, 2), fn_get_lang_var('duplicate_order_warning'))); if (!empty($auth['order_ids'])) { $_o_ids = $auth['order_ids']; } $last_order_id = empty($auth['user_id']) ? array_pop($_o_ids) : db_get_field("SELECT order_id FROM ?:orders WHERE user_id = ?i ORDER BY order_id DESC", $auth['user_id']); return array(CONTROLLER_STATUS_REDIRECT, "orders.details?order_id=$last_order_id"); }*/ // Time of placing ordes is saved to avoid duplicate orders. fn_set_cookie('last_order_time', TIME); list($order_id, $process_payment) = fn_place_order($cart, $auth); if (!empty($order_id)) { $view->assign('order_action', fn_get_lang_var('placing_order')); $view->display('views/orders/components/placing_order.tpl'); fn_flush(); if (empty($_REQUEST['skip_payment']) && $process_payment == true) { // administrator, logged in as customer can skip payment fn_start_payment($order_id); } // 29.11.2014 - send sms to customer $setting_array = db_get_fields("SELECT value FROM ?:settings WHERE option_name = 'send_sms'"); $is_sms_enabled = $setting_array[0] == 'Y'; if ($is_sms_enabled) { $params = array(); $params['user'] = '******';
function fn_set_partner_cookie($partner_id) { if (headers_sent()) { return false; } if (!empty($partner_id) && fn_get_cookie('partner_id') != $partner_id) { $plan_data = fn_get_affiliate_plan_data_by_partner_id($partner_id, true); if (!empty($plan_data['cookie_expiration'])) { $partner_id_alive_time = $plan_data['cookie_expiration'] * 24 * 3600; fn_set_cookie('partner_id', $partner_id, $partner_id_alive_time); return true; } } return false; }
function fn_save_cart_content(&$cart, $user_id, $type = 'C', $user_type = 'R') { if (empty($user_id)) { if (fn_get_cookie('cu_id')) { $user_id = fn_get_cookie('cu_id'); } else { $user_id = fn_crc32(uniqid(TIME)); fn_set_cookie('cu_id', $user_id, COOKIE_ALIVE_TIME); } $user_type = 'U'; } if (!empty($user_id)) { db_query("DELETE FROM ?:user_session_products WHERE user_id = ?i AND type = ?s AND user_type = ?s", $user_id, $type, $user_type); if (!empty($cart['products']) && is_array($cart['products'])) { $_cart_prods = $cart['products']; foreach ($_cart_prods as $_item_id => $_prod) { $_cart_prods[$_item_id]['user_id'] = $user_id; $_cart_prods[$_item_id]['timestamp'] = TIME; $_cart_prods[$_item_id]['type'] = $type; $_cart_prods[$_item_id]['user_type'] = $user_type; $_cart_prods[$_item_id]['item_id'] = $_item_id; $_cart_prods[$_item_id]['item_type'] = 'P'; $_cart_prods[$_item_id]['extra'] = serialize($_prod); $_cart_prods[$_item_id]['amount'] = empty($_cart_prods[$_item_id]['amount']) ? 1 : $_cart_prods[$_item_id]['amount']; $_cart_prods[$_item_id]['session_id'] = Session::get_id(); if (!empty($_cart_prods[$_item_id])) { db_query('REPLACE INTO ?:user_session_products ?e', $_cart_prods[$_item_id]); } } } fn_set_hook('save_cart', $cart, $user_id, $type); } return true; }
function fn_stat_save_session_data(&$stat_data) { $stat_data['user_agent'] = $_SERVER['HTTP_USER_AGENT']; $ip = fn_get_ip(true); $stat_data['host_ip'] = $ip['host']; $stat_data['proxy_ip'] = $ip['proxy']; $stat_data['client_language'] = strtoupper(empty($stat_data['client_language']) ? empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? '' : $_SERVER['HTTP_ACCEPT_LANGUAGE'] : $stat_data['client_language']); $stat_data['session'] = Session::get_id(); $stat_data['host_ip'] = $ip['host']; $stat_data['proxy_ip'] = $ip['proxy']; $stat_data['ip_id'] = fn_stat_ip_exist($ip); if (!empty($stat_data['browser'])) { $browser_id = db_get_field("SELECT browser_id FROM ?:stat_browsers WHERE browser = ?s AND version = ?s", $stat_data['browser'], $stat_data['browser_version']); if (empty($browser_id)) { $browser_id = db_query('INSERT INTO ?:stat_browsers ?e', array('browser' => $stat_data['browser'], 'version' => $stat_data['browser_version'])); } $stat_data['browser_id'] = $browser_id; } $parse_url = parse_url(@$stat_data['referrer']); $stat_data['referrer_scheme'] = empty($parse_url['scheme']) ? '' : $parse_url['scheme']; $stat_data['referrer_host'] = empty($parse_url['host']) ? '' : $parse_url['host']; $search_data = fn_get_search_words(@$stat_data['referrer']); if (!empty($search_data['engine'])) { //$stat_data['engine'] = $search_data['engine']; $engine_id = db_get_field("SELECT engine_id FROM ?:stat_search_engines WHERE engine = ?s", $search_data['engine']); if (empty($engine_id)) { $engine_id = db_query('INSERT INTO ?:stat_search_engines ?e', array('engine' => $search_data['engine'])); } $stat_data['engine_id'] = empty($engine_id) ? 0 : $engine_id; } if (!empty($search_data['phrase'])) { $phrase_id = db_get_field("SELECT phrase_id FROM ?:stat_search_phrases WHERE phrase = ?s", $search_data['phrase']); if (empty($phrase_id)) { $phrase_id = db_query('INSERT INTO ?:stat_search_phrases ?e', array('phrase' => $search_data['phrase'])); } $stat_data['phrase_id'] = empty($phrase_id) ? 0 : $phrase_id; } if (!empty($stat_data['client_language'])) { $is_lang = db_get_field("SELECT lang_code FROM ?:stat_languages WHERE lang_code = ?s", $stat_data['client_language']); // If there is not long language code in DB then save short language code if (empty($is_lang)) { $stat_data['client_language'] = substr($stat_data['client_language'], 0, 2); } } $stat_data['expiry'] = TIME + SESSION_ALIVE_TIME; $session_data = fn_check_table_fields($stat_data, 'stat_sessions'); $sess_id = db_query('INSERT INTO ?:stat_sessions ?e', $session_data); // Set the cookie 'stat_uniq_code' to identify unique clients. $stat_uniq_code = fn_get_cookie('stat_uniq_code'); if (!empty($sess_id) && (empty($stat_uniq_code) || $stat_uniq_code >= $sess_id)) { $stat_uniq_code = $sess_id; } fn_set_cookie('stat_uniq_code', $stat_uniq_code, 365 * 24 * 3600); if (!empty($sess_id)) { db_query('UPDATE ?:stat_sessions SET ?u WHERE sess_id = ?i', array('uniq_code' => $stat_uniq_code), $sess_id); } return $sess_id; }
function fn_init_store_params_by_host(&$request, $area = AREA) { if ($area == 'A' && empty($request['allow_initialization'])) { return array(INIT_STATUS_OK); } $host = $_SERVER['HTTP_HOST']; $host = preg_replace('#^www.#i', '', $host); $field = defined('HTTPS') ? 'secure_storefront' : 'storefront'; $companies = db_get_array("SELECT company_id, {$field} FROM ?:companies WHERE {$field} LIKE ?l OR {$field} LIKE ?l", $host . '%', 'www.' . $host . '%'); if (!empty($companies)) { if (count($companies) == 1) { $request['switch_company_id'] = $companies[0]['company_id']; } else { $found_companies = array(); foreach ($companies as $company) { $parsed_url = parse_url('http://' . $company[$field]); // protocol prefix does not matter if (empty($parsed_url['path'])) { $found_companies[0] = $company['company_id']; } elseif (!empty($_SERVER['REQUEST_URI']) && preg_match("/^" . preg_quote($parsed_url['path'], '/') . "([\\/\\?].*?)?\$/", $_SERVER['REQUEST_URI'], $m)) { $priority = count(explode('/', $parsed_url['path'])); $found_companies[$priority] = $company['company_id']; } } if (!empty($found_companies)) { krsort($found_companies); $request['switch_company_id'] = reset($found_companies); } } } if (!empty($request['switch_company_id']) && $request['switch_company_id'] != 'all' && !isset($request['skip_config_changing'])) { // theme for company with id = 0 cannot be loaded. $company_data = db_get_row('SELECT company_id, storefront, secure_storefront, redirect_customer FROM ?:companies WHERE company_id = ?i', $request['switch_company_id']); if (empty($company_data)) { return array(INIT_STATUS_OK); } if ($company_data['redirect_customer'] == 'Y' && !fn_get_cookie('storefront_redirect_' . $request['switch_company_id'])) { $_ip = fn_get_ip(true); $_country = fn_get_country_by_ip($_ip['host']); if (!empty($_country)) { // Check if found country assigned to some companies $redirect = db_get_hash_array('SELECT company_id, storefront FROM ?:companies WHERE FIND_IN_SET(?s, countries_list) LIMIT 1', 'company_id', $_country); if (!empty($redirect) && !isset($redirect[$request['switch_company_id']])) { if (!defined('CRAWLER')) { $redirect_url = reset($redirect); $redirect_url = 'http://' . $redirect_url['storefront']; fn_set_cookie('storefront_redirect_' . $request['switch_company_id'], true); return array(INIT_STATUS_REDIRECT, $redirect_url); } } } } $config = Registry::get('config'); $url_data = fn_get_storefront_urls(0, $company_data); $config = fn_array_merge($config, $url_data); $config['images_path'] = $config['current_path'] . '/media/images/'; $config['origin_http_location'] = $config['http_location']; $config['origin_https_location'] = $config['https_location']; Registry::set('config', $config); } else { return array(INIT_STATUS_FAIL, '', 'No storefronts defined for this domain'); } return array(INIT_STATUS_OK); }
function fn_paypal_get_checkout_payment_buttons(&$cart, &$cart_products, &$auth, &$checkout_buttons, &$checkout_payments, &$payment_id) { $processor_data = fn_get_processor_data($payment_id); if ($processor_data['processor_script'] !== 'paypal_express.php') { return; } $form_url = fn_url('paypal_express.express'); if (!empty($processor_data) && empty($checkout_buttons[$payment_id]) && Registry::get('runtime.mode') == 'cart') { $merchant_id = $processor_data['processor_params']['merchant_id']; if (isset($processor_data['processor_params']['in_context']) && $processor_data['processor_params']['in_context'] == 'Y' && $merchant_id && !\Tygh\Embedded::isEnabled()) { $environment = $processor_data['processor_params']['mode'] == 'live' ? 'production' : 'sandbox'; if ($environment == 'sandbox') { fn_set_cookie('PPDEBUG', true); } $checkout_buttons[$payment_id] = ' <form name="pp_express" id="pp_express_' . $payment_id . '" action="' . $form_url . '" method="post"> <input name="payment_id" value="' . $payment_id . '" type="hidden" /> </form> <script type="text/javascript"> (function(_, $) { if (window.paypalCheckoutReady) { $.redirect(_.current_url); } else { window.paypalCheckoutReady = function() { paypal.checkout.setup("' . $merchant_id . '", { environment: "' . $environment . '", container: "pp_express_' . $payment_id . '", click: function(e) { e.preventDefault(); paypal.checkout.initXO(); $.ceAjax("request", "' . $form_url . '", { method: "post", data: { in_context: 1, payment_id: "' . $payment_id . '" }, callback: function(response) { var data = JSON.parse(response.text); if (data.token) { var url = paypal.checkout.urlPrefix + data.token; paypal.checkout.startFlow(url); } if (data.error) { paypal.checkout.closeFlow(); } } }); } }); }; } $.getScript("//www.paypalobjects.com/api/checkout.js"); })(Tygh, Tygh.$); </script> '; } else { $checkout_buttons[$payment_id] = ' <form name="pp_express" id="pp_express" action="' . $form_url . '" method="post"> <input name="payment_id" value="' . $payment_id . '" type="hidden" /> <input src="https://www.paypalobjects.com/webstatic/en_US/i/buttons/checkout-logo-small.png" type="image" /> </form> '; } } }
function fn_init_store_params_by_host(&$request, $area = AREA) { if ($area == 'A' && empty($request['allow_initialization'])) { return array(INIT_STATUS_OK); } $host = $_SERVER['HTTP_HOST']; $short_host = preg_replace('/^www[0-9]*\\./i', '', $host); $field = defined('HTTPS') ? 'secure_storefront' : 'storefront'; $conditions = db_quote("{$field} RLIKE ?l", '^(www[0-9]*.)?' . $short_host); if (fn_allowed_for('ULTIMATE:FREE')) { $company_id = db_get_field("SELECT company_id FROM ?:companies LIMIT 1"); $conditions .= db_quote(" AND company_id = ?i", $company_id); } $companies = db_get_array("SELECT company_id, {$field} FROM ?:companies WHERE {$conditions}"); /** * Actions before choosing a company by host * * @param array $request Request * @param string $area Area * @param string $host Host * @param string $short_host Short Host * @param string $field Field name * @param array $companies Companies list */ fn_set_hook('init_store_params_by_host', $request, $area, $host, $short_host, $field, $companies); if (!empty($companies)) { if (count($companies) == 1) { $request['switch_company_id'] = $companies[0]['company_id']; } else { $found_companies = array(); foreach ($companies as $company) { $parsed_url = parse_url('http://' . $company[$field]); // protocol prefix does not matter if (empty($parsed_url['path'])) { $found_companies[0] = $company['company_id']; } elseif (!empty($_SERVER['REQUEST_URI']) && preg_match("/^" . preg_quote($parsed_url['path'], '/') . "([\\/\\?].*?)?\$/", $_SERVER['REQUEST_URI'], $m)) { $priority = count(explode('/', $parsed_url['path'])); $found_companies[$priority] = $company['company_id']; } } if (!empty($found_companies)) { krsort($found_companies); $request['switch_company_id'] = reset($found_companies); } } } if (!empty($request['switch_company_id']) && $request['switch_company_id'] != 'all' && !isset($request['skip_config_changing'])) { // theme for company with id = 0 cannot be loaded. $company_data = db_get_row('SELECT company_id, storefront, secure_storefront, redirect_customer FROM ?:companies WHERE company_id = ?i', $request['switch_company_id']); if (empty($company_data)) { return array(INIT_STATUS_OK); } if ($company_data['redirect_customer'] == 'Y' && !fn_get_cookie('storefront_redirect_' . $request['switch_company_id'])) { $_ip = fn_get_ip(true); $_country = fn_get_country_by_ip($_ip['host']); if (!empty($_country)) { // Check if found country assigned to some companies $redirect = db_get_hash_array('SELECT company_id, storefront FROM ?:companies WHERE FIND_IN_SET(?s, countries_list) LIMIT 1', 'company_id', $_country); if (!empty($redirect) && !isset($redirect[$request['switch_company_id']])) { if (!defined('CRAWLER')) { $redirect_url = reset($redirect); $redirect_url = 'http://' . $redirect_url['storefront']; fn_set_cookie('storefront_redirect_' . $request['switch_company_id'], true); return array(INIT_STATUS_REDIRECT, $redirect_url); } } } } $config = Registry::get('config'); $url_data = fn_get_storefront_urls(0, $company_data); $config = fn_array_merge($config, $url_data); $config['images_path'] = $config['current_path'] . '/media/images/'; $config['origin_http_location'] = $config['http_location']; $config['origin_https_location'] = $config['https_location']; Registry::set('config', $config); $status = INIT_STATUS_OK; $message = ''; } else { $status = INIT_STATUS_FAIL; $message = 'No storefronts defined for this domain'; } /** * Actions after choosing a company by host * * @param array $request Request * @param string $area Area * @param array $config Config * @param string $status Status * @param string $message Message text */ fn_set_hook('init_store_params_by_host_post', $request, $area, $config, $status, $message); return array($status, '', $message); }