/** * Common functions */ function fn_yandex_metrika_sync_goals() { $oauth_token = Settings::instance()->getValue('auth_token', 'rus_yandex_metrika'); $counter_number = Settings::instance()->getValue('counter_number', 'rus_yandex_metrika'); if (empty($oauth_token) || empty($counter_number)) { return false; } $goals_scheme = fn_get_schema('rus_yandex_metrika', 'goals'); $selected_goals = Settings::instance()->getValue('collect_stats_for_goals', 'rus_yandex_metrika'); $client = new RestClient('https://api-metrika.yandex.ru/'); $ext_goals = array(); $res = $client->get("/counter/{$counter_number}/goals.json", array('oauth_token' => $oauth_token)); if (!empty($res['goals'])) { foreach ($res['goals'] as $goal) { $ext_goals[$goal['name']] = $goal; } } foreach ($goals_scheme as $goal_name => $goal) { $ext_goal_name = '[auto] ' . $goal['name']; if (!empty($ext_goals[$ext_goal_name])) { if (empty($selected_goals[$goal_name]) || $selected_goals[$goal_name] == 'N') { $client->delete("/counter/{$counter_number}/goal/" . $ext_goals[$ext_goal_name]['id'] . "?oauth_token={$oauth_token}"); } } else { if (!empty($selected_goals[$goal_name]) && $selected_goals[$goal_name] == 'Y') { $goal['name'] = $ext_goal_name; $client->post("/counter/{$counter_number}/goals?oauth_token={$oauth_token}", array('goal' => $goal)); } } } return true; }
/** * Generates menu items from scheme * @param array $request request params * @return array menu items */ public function generate($request) { $menu = fn_get_schema('menu', 'menu', 'php'); $this->_request = $request; $actions = array(); foreach ($menu as $group => &$menu_data) { // Get static section foreach ($menu_data as $root => &$items) { $items['items'] = $this->_processItems($items['items'], $root, ''); if (empty($items['items'])) { unset($menu[$group][$root]); continue; } } } unset($items, $menu_data); $menu['top'] = $this->_sort($menu['top']); $menu['central'] = $this->_sort($menu['central']); $menu = $this->_getSettingsSections($menu); fn_preload_lang_vars($this->_lang_cache); $selected = $this->_selected; /** * Changes generated menu items * * @param array $request request params * @param array $menu items * @param array $actions items Action value, if exists. See: fn_get_route * @param array $this->selected Menu item, selected by the dispatch */ fn_set_hook('backend_menu_generate_post', $request, $menu, $actions, $this->_selected); return array($menu, $actions, $this->_selected); }
/** * @param $tpl_var * @param $value * @return bool true */ public static function updateLangObjects($tpl_var, &$value) { static $translation_mode, $init = false, $schema; if (!$init) { $translation_mode = Registry::get('runtime.customization_mode.translation'); $init = true; } if ($translation_mode) { if (empty($schema)) { $schema = fn_get_schema('translate', 'schema'); } $controller = Registry::get('runtime.controller'); $mode = Registry::get('runtime.mode'); if (!empty($schema[$controller][$mode])) { foreach ($schema[$controller][$mode] as $var_name => $var) { if ($tpl_var == $var_name && self::isAllowToTranslateLanguageObject($var)) { self::prepareLangObjects($value, $var['dimension'], $var['fields'], $var['table_name'], $var['where_fields'], isset($var['inner']) ? $var['inner'] : '', isset($var['unescape']) ? $var['unescape'] : ''); } } } foreach ($schema['any']['any'] as $var_name => $var) { if ($tpl_var == $var_name && self::isAllowToTranslateLanguageObject($var)) { self::prepareLangObjects($value, $var['dimension'], $var['fields'], $var['table_name'], $var['where_fields'], isset($var['inner']) ? $var['inner'] : '', isset($var['unescape']) ? $var['unescape'] : ''); } } } return true; }
/** * Performs securing object data basing on rule list related to object type. Rule list is specified at schema file. * Note that this function checks setting about whether HTML should be sanitized or not. * If no, field rule "ACTION_SANITIZE_HTML" will be omitted and no modifications to field data will be made. * * @param string $object_type Object type specified at schema file * @param array &$object_data Array with object data passed by reference * * @return void */ public static function sanitizeObjectData($object_type, array &$object_data) { $schema = fn_get_schema('security', 'object_sanitization'); if (isset($schema[$object_type][self::SCHEMA_SECTION_FIELD_RULES])) { $object_data = self::sanitizeData($object_data, $schema[$object_type][self::SCHEMA_SECTION_FIELD_RULES], self::shouldSanitizeUserHtml() ? array() : array(self::ACTION_SANITIZE_HTML)); } }
/** * Get predefined goals */ function fn_settings_variants_addons_rus_yandex_metrika_collect_stats_for_goals() { $goals_scheme = fn_get_schema('rus_yandex_metrika', 'goals'); $goals = array(); foreach ($goals_scheme as $goal_key => $goal) { $goals[$goal_key] = $goal['name']; } return $goals; }
/** * Create new last view instance object * * @param string $area Area identifier * @return void */ public function __construct($area = AREA) { $schema_name = fn_get_area_name($area); $this->_controller = Registry::get('runtime.controller'); $this->_mode = Registry::get('runtime.mode'); $this->_action = Registry::get('runtime.action'); $common_schema = fn_get_schema('last_view', $schema_name); $this->_schema = !empty($common_schema[$this->_controller]) ? $common_schema[$this->_controller] : array(); $this->_auth =& $_SESSION['auth']; }
/** * Gets static data owner link * * @param string $section Static data section * @return array breadcrumb link data */ function fn_br_get_static_data_owner_link($section) { $result = array(); $section = empty($section) ? 'C' : $section; $schema = fn_get_schema('static_data', 'schema'); $section_data = $schema[$section]; if (!empty($section_data['owner_object']['return_url']) && !empty($section_data['owner_object']['return_url_text'])) { $result = array('link' => $section_data['owner_object']['return_url'], 'title' => __($section_data['owner_object']['return_url_text'])); } return $result; }
function fn_rus_edost_install() { $services = fn_get_schema('edost', 'services', 'php', true); foreach ($services as $service) { $service_id = db_query('INSERT INTO ?:shipping_services ?e', $service); $service['service_id'] = $service_id; foreach (Languages::getAll() as $service['lang_code'] => $lang_data) { db_query('INSERT INTO ?:shipping_service_descriptions ?e', $service); } } }
/** * Performs securing object data basing on rule list related to object type. Rule list is specified at schema file. * Note that this function checks setting about whether HTML should be sanitized or not. * If no, field rule "ACTION_SANITIZE_HTML" will be omitted and no modifications to field data will be made. * * @param string $object_type Object type specified at schema file * @param array &$object_data Array with object data passed by reference * * @return void */ public static function sanitizeObjectData($object_type, array &$object_data) { $schema = fn_get_schema('security', 'object_sanitization'); $auth =& \Tygh::$app['session']['auth']; if (isset($schema[$object_type][self::SCHEMA_SECTION_FIELD_RULES])) { $object_data = self::sanitizeData($object_data, $schema[$object_type][self::SCHEMA_SECTION_FIELD_RULES], self::shouldSanitizeUserHtml() ? array() : array(self::ACTION_SANITIZE_HTML), $changed); if ($changed && self::shouldSanitizeUserHtml() && $auth['area'] == 'A') { fn_set_notification('N', __('notice'), __('text_entered_html_was_sanitized'), 'K'); } } }
function fn_settings_variants_addons_price_list_price_list_sorting() { $schema = fn_get_schema('price_list', 'schema'); if (!empty($schema['fields'])) { foreach ($schema['fields'] as $field => $field_info) { if (!empty($field_info['sort_by'])) { $fields[$field] = $field_info['title']; } } } return $fields; }
function fn_rus_payments_uninstall() { $payments = fn_get_schema('rus_payments', 'processors'); fn_rus_payments_disable_payments($payments, true); foreach ($payments as $payment) { db_query("DELETE FROM ?:payment_processors WHERE admin_template = ?s", $payment['admin_template']); } $statuses = fn_get_schema('rus_payments', 'statuses', 'php', true); if (!empty($statuses)) { foreach ($statuses as $status_name => $status_data) { fn_delete_status(fn_get_storage_data($status_name), 'O'); } } }
function fn_import_yml2_option($yml_option_type) { static $options_type_codes = null; if (!isset($options_type_codes)) { $options_type = fn_get_schema('yml', 'options_type'); foreach ($options_type as $type_code => $type_data) { $options_type_codes[$type_data['value']] = $type_code; } } $option_type_code = false; if (isset($options_type_codes[$yml_option_type])) { $option_type_code = $options_type_codes[$yml_option_type]; } return $option_type_code; }
function fn_price_list_info() { $schema = fn_get_schema('price_list', 'schema'); if (empty($schema)) { // workaround to avoid notices when installing addon return; } $storefront_url = fn_get_storefront_url(fn_get_storefront_protocol()); if (fn_allowed_for('ULTIMATE')) { if (Registry::get('runtime.company_id') || Registry::get('runtime.simple_ultimate')) { } else { $storefront_url = ''; } } if (!empty($storefront_url)) { return __('price_list.text_regenerate', array('[buttons]' => fn_price_list_generate_buttons($schema), '[links]' => fn_price_list_generate_links($schema, $storefront_url))); } else { return __('price_list.text_select_storefront'); } }
function fn_search_get_customer_objects() { $schema = fn_get_schema('search', 'schema'); $data = array(); $objects = Registry::get('settings.General.search_objects'); fn_set_hook('customer_search_objects', $schema, $objects); if (AREA == 'A') { $objects['orders'] = 'Y'; $objects['users'] = 'Y'; $objects['pages'] = 'Y'; } foreach ($schema as $object => $object_data) { if (!empty($object_data['default']) && $object_data['default'] == true) { continue; } if (!empty($objects[$object]) && $objects[$object] == 'Y') { $data[$object] = $object_data['title']; } } return $data; }
/** * Gets numeric representation of Country/Region/City * * @param array $destination Country, Region, City of geographic place * @return int Numeric representation */ private function _getDestinationCode($destination) { $cities = fn_get_schema('edost', 'cities'); $regions = fn_get_schema('edost', 'regions'); $countries = fn_get_schema('edost', 'countries'); $origination = $this->_shipping_info['package_info']['origination']['country']; $result = ''; if ($destination['country'] != 'RU' || $origination != 'RU') { $result = !empty($countries[$destination['country']]) ? $countries[$destination['country']] : ''; } else { if (Registry::get('addons.rus_cities.status') == 'A') { if (preg_match('/^[a-zA-Z]+$/', $destination['city'])) { $lang_code = 'en'; } else { $lang_code = 'ru'; } $condition = db_quote(" d.lang_code = ?s AND d.city = ?s AND c.status = ?s", $lang_code, $destination['city'], 'A'); if (!empty($destination['state'])) { $condition .= db_quote(" AND c.state_code = ?s", $destination['state']); } if (!empty($destination['country'])) { $condition .= db_quote(" AND c.country_code = ?s", $destination['country']); } $result = db_get_field("SELECT c.city_code FROM ?:rus_city_descriptions as d LEFT JOIN ?:rus_cities as c ON c.city_id = d.city_id WHERE ?p", $condition); } if (empty($result)) { $result = !empty($cities[$destination['city']]) ? $cities[$destination['city']] : ''; if ($result == '') { $alt_city = $destination['city'] . ' (' . fn_get_state_name($destination['state'], $destination['country'], 'RU') . ')'; if (!empty($cities[$alt_city])) { $result = $cities[$alt_city]; } } if ($result == '') { $result = !empty($regions[$destination['state']]) ? $regions[$destination['state']] : ''; } } } return $result; }
/** * Generates menu items from scheme * @param array $request request params * @return array menu items */ public function generate($request) { $menu = fn_get_schema('menu', 'menu', 'php'); $this->_request = $request; $actions = array(); foreach ($menu as $group => &$menu_data) { // Get static section foreach ($menu_data as $root => &$items) { $items['items'] = $this->_processItems($items['items'], $root, ''); if (empty($items['items'])) { unset($menu[$group][$root]); continue; } } } unset($items, $menu_data); $menu['top'] = $this->_sort($menu['top']); $menu['central'] = $this->_sort($menu['central']); $menu = $this->_getSettingsSections($menu); fn_preload_lang_vars($this->_lang_cache); return array($menu, $actions, $this->_selected); }
/** * Get promotion schema * * @param string $type schema type (conditions, bonuses) * @return array schema of definite type */ function fn_promotion_get_schema($type = '') { static $schema = array(); if (empty($schema)) { $schema = fn_get_schema('promotions', 'schema'); } return !empty($type) ? $schema[$type] : $schema; }
/** * Gets part of SQL-query with codition for company_id field. * * @staticvar array $sharing_schema Local static cache for sharing schema * @param string $db_field Field name (usually table_name.company_id) * @param bool $add_and Include or not AND keyword berofe condition. * @param mixed $company_id Company ID for using in SQL condition. * @param bool $show_admin Include or not company_id == 0 in condition (used in the MultiVendor Edition) * @param bool $force_condition_for_area_c Used in the MultiVendor Edition. By default, SQL codition should be empty in the customer area. But in some cases, * this condition should be enabled in the customer area. If <i>$force_condition_for_area_c</i> is set, condtion will be formed for the customer area. * @return string Part of SQL query with company ID condition */ function fn_get_company_condition($db_field = 'company_id', $add_and = true, $company_id = '', $show_admin = false, $force_condition_for_area_c = false) { if (fn_allowed_for('ULTIMATE')) { // Completely remove company condition for sharing objects static $sharing_schema; if (empty($sharing_schema) && Registry::get('addons_initiated') === true) { $sharing_schema = fn_get_schema('sharing', 'schema'); } // Check if table was passed if (strpos($db_field, '.')) { list($table, $field) = explode('.', $db_field); $table = str_replace('?:', '', $table); // Check if the db_field table is in the schema if (isset($sharing_schema[$table])) { return ''; } } else { return ''; } if (Registry::get('runtime.company_id') && !$company_id) { $company_id = Registry::get('runtime.company_id'); } } if ($company_id === '') { $company_id = Registry::ifGet('runtime.company_id', ''); } $skip_cond = AREA == 'C' && !$force_condition_for_area_c && !fn_allowed_for('ULTIMATE'); if (!$company_id || $skip_cond) { $cond = ''; } else { $cond = $add_and ? ' AND' : ''; // FIXME 2tl show admin if ($show_admin && $company_id) { $cond .= " {$db_field} IN (0, {$company_id})"; } else { $cond .= " {$db_field} = {$company_id}"; } } return $cond; }
/** * Registers block cache * * @param string $cache_name Cache name * @param array $block_schema Block schema data * @param array $block_data Block data from DB * * @return bool Whether cache have been registered or not */ public static function registerBlockCacheIfNeeded($cache_name, $block_schema, $block_data) { // @TODO: remove Registry calls and use RenderManager::$_location instead. This method should be non-static. $dispatch = Registry::get('runtime.controller') . '.' . Registry::get('runtime.mode'); // Use parameters for current dispatch with fallback to common params if (!empty($block_schema['cache_overrides_by_dispatch'][$dispatch])) { $cache_params = $block_schema['cache_overrides_by_dispatch'][$dispatch]; } elseif (!empty($block_schema['cache'])) { $cache_params = $block_schema['cache']; } else { return false; } $cookie_data = fn_get_session_data(); $cookie_data['all'] = $cookie_data; $callable_handlers_variables = compact('block_schema', 'block_data'); $disable_cache = false; // Check conditions that disable block caching if (!empty($cache_params['disable_cache_when'])) { $disable_cache |= self::findHandlerParamsAtData($cache_params['disable_cache_when'], 'request_handlers', $_REQUEST); $disable_cache |= self::findHandlerParamsAtData($cache_params['disable_cache_when'], 'session_handlers', $_SESSION); $disable_cache |= self::findHandlerParamsAtData($cache_params['disable_cache_when'], 'cookie_handlers', $cookie_data); $disable_cache |= self::findHandlerParamsAtData($cache_params['disable_cache_when'], 'auth_handlers', $_SESSION['auth']); // Disable cache if any of callable handlers returns true if (!empty($cache_params['disable_cache_when']['callable_handlers'])) { self::execCallableHandlers(function ($handler_name, $handler_result) use(&$disable_cache) { $disable_cache |= $handler_result; }, (array) $cache_params['disable_cache_when']['callable_handlers'], $callable_handlers_variables); } } if ($disable_cache) { return false; } // Generate suffix to cache key using dependencies specified at schema $cache_key_suffix = ''; $generate_additional_level = function ($param_name, $param_value) use(&$cache_key_suffix) { $cache_key_suffix .= '|' . $param_name . '=' . md5(serialize($param_value)); }; self::findHandlerParamsAtData($cache_params, 'request_handlers', $_REQUEST, $generate_additional_level); self::findHandlerParamsAtData($cache_params, 'session_handlers', $_SESSION, $generate_additional_level); self::findHandlerParamsAtData($cache_params, 'cookie_handlers', $cookie_data, $generate_additional_level); self::findHandlerParamsAtData($cache_params, 'auth_handlers', $_SESSION['auth'], $generate_additional_level); if (!empty($cache_params['callable_handlers'])) { self::execCallableHandlers($generate_additional_level, (array) $cache_params['callable_handlers'], $callable_handlers_variables); } $cache_key_suffix .= '|path=' . Registry::get('config.current_path'); $cache_key_suffix .= Embedded::isEnabled() ? '|embedded' : ''; $cache_key_suffix = empty($cache_key_suffix) ? '' : md5($cache_key_suffix); $default_update_handlers = fn_get_schema('block_manager', 'block_cache_properties'); if (isset($cache_params['update_handlers']) && is_array($cache_params['update_handlers'])) { $handlers = array_merge($cache_params['update_handlers'], $default_update_handlers['update_handlers']); } else { $handlers = $default_update_handlers['update_handlers']; } $cache_level = isset($cache_params['cache_level']) ? $cache_params['cache_level'] : Registry::cacheLevel('html_blocks'); Registry::registerCache($cache_name, $handlers, $cache_level . '__' . $cache_key_suffix); // Check conditions that trigger block cache regeneration $regenerate_cache = false; if (!empty($cache_params['regenerate_cache_when'])) { $regenerate_cache |= self::findHandlerParamsAtData($cache_params['regenerate_cache_when'], 'request_handlers', $_REQUEST); $regenerate_cache |= self::findHandlerParamsAtData($cache_params['regenerate_cache_when'], 'session_handlers', $_SESSION); $regenerate_cache |= self::findHandlerParamsAtData($cache_params['regenerate_cache_when'], 'cookie_handlers', $cookie_data); $regenerate_cache |= self::findHandlerParamsAtData($cache_params['regenerate_cache_when'], 'auth_handlers', $_SESSION['auth']); // Regenerate cache if any of callable handlers returns true if (!empty($cache_params['regenerate_cache_when']['callable_handlers'])) { self::execCallableHandlers(function ($handler_name, $handler_result) use(&$regenerate_cache) { $regenerate_cache |= $handler_result; }, (array) $cache_params['regenerate_cache_when']['callable_handlers'], $callable_handlers_variables); } } if ($regenerate_cache) { Registry::del($cache_name); } return true; }
Tygh::$app['view']->assign('company_id', $company_id); Tygh::$app['view']->assign('company_name', $company_data['company']); Tygh::$app['view']->assign('companies', $companies); Tygh::$app['view']->assign('search', $search); Tygh::$app['view']->assign('countries', fn_get_simple_countries(true, CART_LANGUAGE)); Tygh::$app['view']->assign('states', fn_get_all_states()); } elseif ($mode == 'balance') { list($payouts, $search, $total) = fn_companies_get_payouts($_REQUEST, Registry::get('settings.Appearance.admin_elements_per_page')); Tygh::$app['view']->assign('payouts', $payouts); Tygh::$app['view']->assign('search', $search); Tygh::$app['view']->assign('total', $total); } } if (fn_allowed_for('ULTIMATE')) { if ($mode == 'get_object_share') { $sharing_schema = fn_get_schema('sharing', 'schema'); $view = Tygh::$app['view']; if (!empty($_REQUEST['object_id']) && !empty($_REQUEST['object'])) { $schema = $sharing_schema[$_REQUEST['object']]; $view->assign('selected_companies', fn_ult_get_object_shared_companies($_REQUEST['object'], $_REQUEST['object_id'])); $owner = db_get_row('SELECT * FROM ?:' . $schema['table']['name'] . ' WHERE ' . $schema['table']['key_field'] . ' = ?s', $_REQUEST['object_id']); $owner_id = isset($owner['company_id']) ? $owner['company_id'] : ''; $view->assign('result_ids', $_REQUEST['result_ids']); $view->assign('object_id', $_REQUEST['object_id']); $view->assign('owner_id', $owner_id); $view->assign('object', $_REQUEST['object']); $view->assign('schema', $schema); if (!empty($schema['no_item_text'])) { $view->assign('no_item_text', __($schema['no_item_text'])); } $view->display('views/companies/components/share_object.tpl');
/** * Updates addon status * @param string $addon Addon to update status for * @param string $status Status to change to * @param bool $show_notification Display notification if set to true * @param bool $on_install If status was changed on after ionstall process * @return bool|string True on success, old status ID if status was not changed */ function fn_update_addon_status($addon, $status, $show_notification = true, $on_install = false) { $old_status = db_get_field("SELECT status FROM ?:addons WHERE addon = ?s", $addon); $new_status = $status; $scheme = SchemesManager::getScheme($addon); // Unmanaged addons can be enabled/disabled via console only if ($scheme->getUnmanaged() && !defined('CONSOLE')) { return false; } if ($old_status != $new_status) { // Check if addon can be enabled $conflicts = db_get_fields("SELECT addon FROM ?:addons WHERE status = 'A' AND FIND_IN_SET(?s, conflicts)", $addon); if ($new_status == 'A' && !empty($conflicts)) { $scheme = SchemesManager::getScheme($addon); fn_set_notification('W', __('warning'), __('text_addon_cannot_enable', array('[addons]' => implode(', ', SchemesManager::getNames($conflicts)), '[addon_name]' => $scheme->getName()))); return $old_status; } fn_get_schema('settings', 'actions.functions', 'php', true); $func = 'fn_settings_actions_addons_' . $addon; if (function_exists($func)) { $func($new_status, $old_status, $on_install); } // If status change is allowed, update it if ($old_status != $new_status) { if ($new_status != 'D') { // Check that addon have conflicts $scheme = SchemesManager::getScheme($addon); $conflicts = db_get_field("SELECT conflicts FROM ?:addons WHERE addon = ?s", $addon); if (!empty($conflicts)) { $conflicts = explode(',', $conflicts); $lang_var = 'text_addon_confclicts_on_install'; if (!$on_install) { foreach ($conflicts as $conflict) { fn_disable_addon($conflict, $scheme->getName(), $show_notification); } $lang_var = 'text_addon_confclicts'; } fn_set_notification('W', __('warning'), __($lang_var, array('[addons]' => implode(', ', SchemesManager::getNames($conflicts)), '[addon_name]' => $scheme->getName()))); // On install we cannot enable addon with conflicts automaticly if ($on_install) { return $old_status; } } } db_query("UPDATE ?:addons SET status = ?s WHERE addon = ?s", $status, $addon); $func = 'fn_settings_actions_addons_post_' . $addon; if (function_exists($func)) { $func($status); } if ($show_notification == true) { fn_set_notification('N', __('notice'), __('status_changed')); } // Enable/disable tabs for addon ProductTabs::instance()->updateAddonTabStatus($addon, $new_status); Registry::set('addons.' . $addon . '.status', $status); } else { return $old_status; } } // Clean cache fn_clear_cache(); if ($status == 'A') { foreach (fn_get_installed_themes() as $theme_name) { $theme = Themes::factory($theme_name); $theme_manifest = $theme->getManifest(); // Precompile addon LESS files if the theme has been converted to CSS if (!empty($theme_manifest['converted_to_css']) && !$theme->convertAddonToCss($addon)) { fn_update_addon_status($addon, 'D', $show_notification, $on_install); return $old_status; } } } return true; }
<?php /*! * HybridAuth * http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth * (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html */ // ---------------------------------------------------------------------------------------- // HybridAuth Config file: http://hybridauth.sourceforge.net/userguide/Configuration.html // ---------------------------------------------------------------------------------------- use Tygh\Registry; $config = array('base_url' => fn_url('auth.process'), 'debug_mode' => false, 'debug_file' => Registry::get('config.dir.var') . 'oauth.log'); $providers_schema = fn_get_schema('hybrid_auth', 'providers'); $available_providers = fn_hybrid_auth_get_providers_list(); foreach ($available_providers as $provider_data) { $provider_name = $providers_schema[$provider_data['provider']]['provider']; $config['providers'][$provider_name] = array('enabled' => $provider_data['status'] == 'A' ? true : false); if (isset($providers_schema[$provider_data['provider']])) { $provider_keys = isset($providers_schema[$provider_data['provider']]['keys']) ? $providers_schema[$provider_data['provider']]['keys'] : array(); foreach ($provider_keys as $key => $key_data) { if (isset($key_data['db_field']) && isset($provider_data[$key_data['db_field']])) { $config['providers'][$provider_name]['keys'][$key] = $provider_data[$key_data['db_field']]; } } $provider_params = isset($providers_schema[$provider_data['provider']]['params']) ? $providers_schema[$provider_data['provider']]['params'] : array(); foreach ($provider_params as $param_id => $param_data) { if (isset($provider_data['params'][$param_id])) { $config['providers'][$provider_name][$param_id] = $provider_data['params'][$param_id]; } elseif ($param_data['type'] == 'hidden' && !empty($param_data['value'])) { $config['providers'][$provider_name][$param_id] = $param_data['value']; }
* * **************************************************************************** * PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE * * "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * ****************************************************************************/ use Tygh\Registry; if (!defined('BOOTSTRAP')) { die('Access denied'); } if ($mode == 'view') { fn_disable_translation_mode(); if (empty($_REQUEST['display'])) { die('Access denied'); } $types = array('pdf', 'xls'); $price_schema = fn_get_schema('price_list', 'schema'); $selected_fields = Registry::get('addons.price_list.price_list_fields'); $modes = fn_price_list_get_pdf_layouts(); // Check the available libs foreach ($types as $type) { if (!empty($modes[$type])) { foreach ($modes[$type] as $f_mode) { if ($_REQUEST['display'] == fn_basename($f_mode, '.php')) { include_once Registry::get('config.dir.addons') . '/price_list/templates/' . $type . '/' . $f_mode; $meta_redirect_url = urlencode(fn_url('price_list.view?display=' . fn_basename($f_mode, '.php'), 'C', 'http')); if (!empty($_REQUEST['return_url'])) { $base_url = $_REQUEST['return_url']; } else { $base_url = empty($_SERVER['HTTP_REFERER']) ? fn_url() . '?' : $_SERVER['HTTP_REFERER']; if (strpos('?', $base_url) === false) { $base_url .= '?';
/** * Update addon options * * @param string $addon addon to update options for * @param string $addon_data options data * @return bool always true */ function fn_update_addon($addon, $addon_data) { fn_get_schema('settings', 'actions', 'php', false, true); // Get old options $old_options = db_get_field("SELECT options FROM ?:addons WHERE addon = ?s", $addon); $old_options = fn_parse_addon_options($old_options); $ml_options = db_get_hash_single_array("SELECT object_id, description FROM ?:addon_descriptions WHERE addon = ?s AND object_id != '' AND object_type = 'L' AND lang_code = ?s", array('object_id', 'description'), $addon, CART_LANGUAGE); foreach ($old_options as $k => $v) { if (isset($addon_data['options'][$k]) && ($v != '%ML%' && $addon_data['options'][$k] != $v || $v == '%ML%' && isset($ml_options[$k]) && $addon_data['options'][$k] != $ml_options[$k]) || !isset($addon_data['options'][$k])) { $func = 'fn_settings_actions_addons_' . $addon . '_' . $k; if (function_exists($func)) { $func($addon_data['options'][$k], $v == '%ML%' ? $ml_options[$k] : $v); } } if ($v == '%ML%') { db_query("UPDATE ?:addon_descriptions SET ?u WHERE addon = ?s AND object_id = ?s AND object_type = 'L' AND lang_code = ?s", array('description' => $addon_data['options'][$k]), $addon, $k, CART_LANGUAGE); $addon_data['options'][$k] = '%ML%'; } } if (!empty($addon_data['options'])) { foreach ($addon_data['options'] as $k => $v) { if (is_array($v)) { $addon_data['options'][$k] = '#M#' . implode('=Y&', $v) . '=Y'; } } $addon_data['options'] = serialize($addon_data['options']); } else { $addon_data['options'] = ''; } db_query("UPDATE ?:addons SET ?u WHERE addon = ?s", $addon_data, $addon); return true; }
Registry::get('view')->assign('export_fields', $pattern['export_fields']); Registry::get('view')->assign('feature_fields', fn_data_feeds_get_features_fields()); // [Page sections] Registry::set('navigation.tabs', array('detailed' => array('title' => __('general'), 'js' => true), 'exported_items' => array('title' => __('exported_items'), 'js' => true), 'fields' => array('title' => __('map_fields'), 'js' => true))); // [/Page sections] } elseif ($mode == 'update') { $params['datafeed_id'] = $_REQUEST['datafeed_id']; $params['single'] = true; $datafeed_data = fn_data_feeds_get_data($params, DESCR_SL); Registry::get('view')->assign('datafeed_data', $datafeed_data); // Export languages foreach (fn_get_translation_languages() as $lang_code => $lang_data) { $datafeed_langs[$lang_code] = $lang_data['name']; } Registry::get('view')->assign('datafeed_langs', $datafeed_langs); $pattern = fn_get_schema('exim', 'products'); Registry::get('view')->assign('pattern', $pattern); if (empty($datafeed_data['datafeed_id'])) { return array(CONTROLLER_STATUS_NO_PAGE); } Registry::get('view')->assign('export_fields', $pattern['export_fields']); Registry::get('view')->assign('feature_fields', fn_data_feeds_get_features_fields()); // [Page sections] Registry::set('navigation.tabs', array('detailed' => array('title' => __('general'), 'js' => true), 'exported_items' => array('title' => __('exported_items'), 'js' => true), 'fields' => array('title' => __('map_fields'), 'js' => true))); // [/Page sections] } elseif ($mode == 'download') { $params['datafeed_id'] = $_REQUEST['datafeed_id']; $params['single'] = true; $datafeed_data = fn_data_feeds_get_data($params, DESCR_SL); $filename = fn_get_files_dir_path() . $datafeed_data['file_name']; if (file_exists($filename)) {
function fn_twg_get_cache_request($request) { $schema = fn_get_schema('twg_pre_cache', 'requests'); if (!isset($schema[$request['dispatch']])) { return ''; } $schema = $schema[$request['dispatch']]; $params = array(); foreach ($schema['params'] as $param_name => $param) { $params[$param_name] = $param; } if (isset($schema['param_values'])) { foreach ($schema['param_values'] as $param_name => $param) { $params[$param_name] = $request[$param]; } } return $params; }
<?php /*************************************************************************** * * * (c) 2004 Vladimir V. Kalynyak, Alexey V. Vinokurov, Ilya M. Shalnev * * * * This is commercial software, only users who have purchased a valid * * license and accept to the terms of the License Agreement can install * * and use this program. * * * **************************************************************************** * PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE * * "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * ****************************************************************************/ use Tygh\Registry; if (!defined('BOOTSTRAP')) { die('Access denied'); } Tygh::$app['view']->assign('yandex_metrika_goals_scheme', fn_get_schema('rus_yandex_metrika', 'goals'));
function fn_get_pattern_definition($pattern_id, $get_for = '') { // First, check basic patterns $schema = fn_get_schema('exim', $pattern_id); if (empty($schema)) { fn_set_notification('E', __('error'), __('error_exim_pattern_not_found')); return false; } if (!empty($schema['export_only']) && $get_for == 'import' || !empty($schema['import_only']) && $get_for == 'export') { return array(); } $has_alt_keys = false; foreach ($schema['export_fields'] as $field_id => $field_data) { if (!empty($field_data['table'])) { // Table exists in export fields, but doesn't exist in references definition if (empty($schema['references'][$field_data['table']])) { fn_set_notification('E', __('error'), __('error_exim_pattern_definition_references')); return false; } } // Check if schema has alternative keys to import basic data if (!empty($field_data['alt_key'])) { $has_alt_keys = true; } if (!empty($field_data['export_only']) && $get_for == 'import' || !empty($field_data['import_only']) && $get_for == 'export') { unset($schema['export_fields'][$field_id]); } } if ($has_alt_keys == false) { fn_set_notification('E', __('error'), __('error_exim_pattern_definition_alt_keys')); return false; } return $schema; }
/** * 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; }
} $processors = fn_sort_array_by_key($processors, 'position'); Tygh::$app['view']->assign('payment_processors', $processors); } } elseif ($mode == 'yandex_get_md5_password') { $md5 = md5(TIME . $_REQUEST['md5_shoppassword']); $md5 = substr($md5, 0, 20); Tygh::$app['view']->assign('ya_md5', $md5); Tygh::$app['view']->display('views/payments/components/cc_processors/yandex_money.tpl'); exit; } elseif ($mode == 'processor') { $payment_image = array(); if (!empty($_REQUEST['payment_id'])) { $processor_script = db_get_field("SELECT processor_script FROM ?:payments INNER JOIN ?:payment_processors USING (processor_id) WHERE payment_id = ?i", $_REQUEST['payment_id']); if ($processor_script == 'qiwi.php' && class_exists('SoapClient')) { Tygh::$app['view']->assign('soap_exist', true); } elseif ($processor_script == 'account.php') { $payment_image = $_REQUEST; $payment_image['path_stamp'] = fn_get_image_pairs($_REQUEST['payment_id'], 'stamp', 'M', true, true, DESCR_SL); Tygh::$app['view']->assign('payment_image', $payment_image); } } if (!empty($_REQUEST['processor_id'])) { $processor_script = db_get_field("SELECT processor_script FROM ?:payment_processors WHERE processor_id = ?i", $_REQUEST['processor_id']); } if (!empty($processor_script) && $processor_script == 'account.php') { $profile_fields = fn_get_profile_fields('ALL', array(), CART_LANGUAGE); Tygh::$app['view']->assign('profile_fields', $profile_fields); Tygh::$app['view']->assign('account_fields', fn_get_schema('rus_payments', 'account_fields')); } }