Example #1
0
 /**
  * Setup complete action
  *
  * @param array $params Request variables
  *
  * @return bool Always true
  */
 public function actionComplete($params = array())
 {
     $validator = new Validator();
     $app = App::instance();
     fn_define('CART_LANGUAGE', $app->getCurrentLangCode());
     fn_define('DESCR_SL', $app->getCurrentLangCode());
     $database = $app->getFromStorage('database_settings');
     if (!empty($database)) {
         $result = $validator->isMysqlSettingsValid($database['host'], $database['name'], $database['user'], $database['password'], $database['table_prefix'], $database['database_backend'], false);
         if ($result) {
             // Delete installer after store was installed.
             fn_rm(Registry::get('config.dir.root') . '/install');
             session_destroy();
             $this->_prepareHttpData();
             Session::init($params);
             $user_data = array('user_id' => 1, 'user_type' => 'A', 'area' => 'A', 'login' => 'admin', 'is_root' => 'Y', 'company_id' => 0);
             $_SESSION['auth'] = fn_fill_auth($user_data, array(), false, 'A');
             if (is_file(Registry::get('config.dir.root') . '/install/index.php')) {
                 $_SESSION['notifications']['installer'] = array('type' => 'W', 'title' => 'warning', 'message' => 'delete_install_folder', 'message_state' => 'S', 'new' => true, 'extra' => '', 'init_message' => true);
             }
             $redirect_url = Registry::get('config.http_location') . '/' . Registry::get('config.admin_index') . '?welcome';
             fn_redirect($redirect_url);
         }
     }
     fn_redirect('install/index.php');
     return true;
 }
Example #2
0
function fn_watermarks_init_company_data(&$params, &$company_id, &$company_data)
{
    if (fn_allowed_for('ULTIMATE')) {
        if ($company_id) {
            fn_define('WATERMARK_IMAGE_ID', $company_id);
            fn_define('WATERMARKS_DIR_NAME', 'watermarked/' . $company_id . '/');
        } else {
            fn_define('WATERMARK_IMAGE_ID', 0);
            fn_define('WATERMARKS_DIR_NAME', 'watermarked/');
        }
    } else {
        fn_define('WATERMARK_IMAGE_ID', 1);
        fn_define('WATERMARKS_DIR_NAME', 'watermarked/');
    }
}
Example #3
0
 public function update($id, $params)
 {
     fn_define('NEW_FEATURE_GROUP_ID', 'OG');
     $status = Response::STATUS_BAD_REQUEST;
     $data = array();
     unset($params['feature_id']);
     if (!empty($params['variants'])) {
         list($variants) = fn_get_product_feature_variants(array('feature_id' => $id));
         $params['original_var_ids'] = implode(',', array_keys($variants));
     }
     $lang_code = $this->safeGet($params, 'lang_code', DEFAULT_LANGUAGE);
     $feature_id = fn_update_product_feature($params, $id, $lang_code);
     if ($feature_id) {
         $status = Response::STATUS_OK;
         $data = array('feature_id' => $feature_id);
     }
     return array('status' => $status, 'data' => $data);
 }
Example #4
0
/**
 * Detect the cyrillic encoding of string
 *
 * @param string $str
 * @return string cyrillic encoding
 */
function fn_detect_cyrillic_charset($str)
{
    fn_define('LOWERCASE', 3);
    fn_define('UPPERCASE', 1);
    $charsets = array('KOI8-R' => 0, 'CP1251' => 0, 'CP866' => 0, 'ISO-8859-5' => 0, 'MAC-CYRILLIC' => 0);
    for ($i = 0, $length = strlen($str); $i < $length; $i++) {
        $char = ord($str[$i]);
        //non-russian characters
        if ($char < 128 || $char > 256) {
            continue;
        }
        //CP866
        if ($char > 159 && $char < 176 || $char > 223 && $char < 242) {
            $charsets['CP866'] += LOWERCASE;
        }
        if ($char > 127 && $char < 160) {
            $charsets['CP866'] += UPPERCASE;
        }
        //KOI8-R
        if ($char > 191 && $char < 223) {
            $charsets['KOI8-R'] += LOWERCASE;
        }
        if ($char > 222 && $char < 256) {
            $charsets['KOI8-R'] += UPPERCASE;
        }
        //CP1251
        if ($char > 223 && $char < 256) {
            $charsets['CP1251'] += LOWERCASE;
        }
        if ($char > 191 && $char < 224) {
            $charsets['CP1251'] += UPPERCASE;
        }
        //MAC-CYRILLIC
        if ($char > 221 && $char < 255) {
            $charsets['MAC-CYRILLIC'] += LOWERCASE;
        }
        if ($char > 127 && $char < 160) {
            $charsets['MAC-CYRILLIC'] += UPPERCASE;
        }
        //ISO-8859-5
        if ($char > 207 && $char < 240) {
            $charsets['ISO-8859-5'] += LOWERCASE;
        }
        if ($char > 175 && $char < 208) {
            $charsets['ISO-8859-5'] += UPPERCASE;
        }
    }
    arsort($charsets);
    return current($charsets) > 0 ? key($charsets) : '';
}
Example #5
0
    if (defined('AJAX_REQUEST')) {
        Tygh::$app['view']->display('addons/ebay/views/ebay/components/category_features.tpl');
        exit;
    } else {
        fn_print_die($features, $_REQUEST);
    }
} elseif ($mode == 'get_shippings') {
    $template_data = fn_get_ebay_template($_REQUEST['template_id']);
    Tygh::$app['view']->assign('shipping_type', $_REQUEST['shipping_type']);
    Tygh::$app['view']->assign('template_data', $template_data);
    if (defined('AJAX_REQUEST')) {
        Tygh::$app['view']->display('addons/ebay/views/ebay/update.tpl');
        exit;
    }
} elseif ($mode == 'get_orders') {
    fn_define('ORDER_MANAGEMENT', true);
    if (fn_allowed_for('ULTIMATE')) {
        if (Registry::get('runtime.company_id')) {
            list($success_orders, $failed_orders) = fn_get_ebay_orders($cart, $customer_auth);
            if (!empty($success_orders)) {
                fn_set_notification('N', __('successful'), __('ebay_success_orders_notice', array('[SUCCESS_IDS]' => implode(', ', $success_orders))));
            } elseif (!empty($failed_orders)) {
                fn_set_notification('W', __('warning'), __('ebay_failed_orders_notice', array('[FAILED_EBAY_IDS]' => implode(', ', $failed_orders))));
            } else {
                fn_set_notification('W', __('warning'), 'no orders found');
            }
        } else {
            fn_set_notification('W', __('warning'), __('store_object_denied', array('[object_type]' => '', '[object_name]' => '')), '', 'store_object_denied');
        }
    } else {
        list($success_orders, $failed_orders) = fn_get_ebay_orders($cart, $customer_auth);
Example #6
0
/**
 * Generates list of (pre/post)controllers from active addons
 *
 * @param string $controller controller name
 * @param string $type controller type (pre/post)
 * @return array controllers list and active addons
 */
function fn_init_addon_controllers($controller, $type = GET_CONTROLLERS, $area = AREA)
{
    $controllers = array();
    static $addons = array();
    $prefix = '';
    $area_name = fn_get_area_name($area);
    if ($type == GET_POST_CONTROLLERS) {
        $prefix = '.post';
    } elseif ($type == GET_PRE_CONTROLLERS) {
        $prefix = '.pre';
    }
    foreach ((array) Registry::get('addons') as $addon_name => $data) {
        if ($data['status'] == 'A') {
            // try to find area-specific controller
            $dir = Registry::get('config.dir.addons') . $addon_name . '/controllers/' . $area_name . '/';
            if (is_readable($dir . $controller . $prefix . '.php')) {
                $controllers[] = $dir . $controller . $prefix . '.php';
                $addons[$addon_name] = true;
                if (empty($prefix)) {
                    fn_define('LOADED_ADDON_PATH', $addon_name);
                }
            }
            // try to find common controller
            $dir = Registry::get('config.dir.addons') . $addon_name . '/controllers/common/';
            if (is_readable($dir . $controller . $prefix . '.php')) {
                $controllers[] = $dir . $controller . $prefix . '.php';
                $addons[$addon_name] = true;
                if (empty($prefix)) {
                    fn_define('LOADED_ADDON_PATH', $addon_name);
                }
            }
        }
    }
    return array($controllers, $addons);
}
Example #7
0
<?php

/***************************************************************************
*                                                                          *
*    Copyright (c) 2004 Simbirsk Technologies Ltd. All rights reserved.    *
*                                                                          *
* 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.            *
****************************************************************************/
//
// $Id: init.php 10229 2010-07-27 14:21:39Z 2tl $
//
if (!defined('AREA')) {
    die('Access denied');
}
fn_define('SEO_FILENAME_EXTENSION', '.html');
fn_register_hooks('url', 'get_route', 'before_dispatch', 'update_category', 'get_category_data', 'get_category_data_post', 'get_categories', 'get_categories_post', 'delete_category', 'update_product', 'get_products', 'get_products_post', 'get_product_data', 'delete_product', 'update_page', 'get_page_data', 'delete_page', 'get_product_feature_variants', 'update_product_feature', 'get_news', 'get_news_post', 'get_news_data', 'update_news', 'delete_news');
Example #8
0
*                                                                          *
****************************************************************************
* PLEASE READ THE FULL TEXT  OF THE SOFTWARE  LICENSE   AGREEMENT  IN  THE *
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE.            *
****************************************************************************/
use Tygh\Bootstrap;
use Tygh\Registry;
use Tygh\Storage;
use Tygh\Tools\Url;
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
// Set line endings autodetection
ini_set('auto_detect_line_endings', true);
set_time_limit(0);
fn_define('DB_LIMIT_SELECT_ROW', 30);
if (empty($_SESSION['export_ranges'])) {
    $_SESSION['export_ranges'] = array();
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $suffix = '';
    $layout_data = !empty($_REQUEST['layout_data']) ? $_REQUEST['layout_data'] : array();
    //
    // Select layout
    //
    if ($mode == 'set_layout') {
        db_query("UPDATE ?:exim_layouts SET active = 'N' WHERE pattern_id = ?s", $layout_data['pattern_id']);
        db_query("UPDATE ?:exim_layouts SET active = 'Y' WHERE layout_id = ?i", $layout_data['layout_id']);
        return array(CONTROLLER_STATUS_OK, 'exim.export?section=' . $_REQUEST['section'] . '&pattern_id=' . $layout_data['pattern_id']);
    }
    //
Example #9
0
<?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.            *
****************************************************************************/
// rus_build_kupivkredit dbazhenov
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
fn_define('KVK_API_URL', 'api.kupivkredit.ru');
fn_define('KVK_API_TEST_URL', 'kupivkredit-test-api.tcsbank.ru');
fn_define('KVK_WIDGET_URL', 'www.kupivkredit.ru');
fn_define('KVK_WIDGET_TEST_URL', 'kupivkredit-test-fe.tcsbank.ru');
Example #10
0
if (!defined('AREA')) {
    die('Access denied');
}
use Tygh\Registry;
use Twigmo\Core\TwigmoSettings;
use Twigmo\Core\TwigmoConnector;
// addon version
fn_define('TWIGMO_VERSION', '3.8');
fn_define('TWIGMO_UPGRADE_DIR', Registry::get('config.dir.var') . 'twigmo/');
fn_define('TWIGMO_UA_RULES_FILE', TWIGMO_UPGRADE_DIR . 'ua_rules.txt');
fn_define('TWIGMO_UPGRADE_VERSION_FILE', 'version_info.txt');
fn_define('TWG_UA_RULES_STAT', 'http://twigmo.com/svc2/ua_meta/stat.php');
fn_define('TWG_DEFAULT_DATA_FORMAT', 'json');
fn_define('TWG_DEFAULT_API_VERSION', '2.0');
fn_define('TWG_RESPONSE_ITEMS_LIMIT', 10);
fn_define('TWG_MAX_DESCRIPTION_LEN', 200);
if (Registry::get('addons.twigmo.status') == 'A' && TwigmoSettings::dbIsInited()) {
    $settings = array();
    $settings['unsupported_payment_methods'] = array('FRIbetaling', 'PayPal Advanced', 'FuturePay');
    $settings['unsupported_shipping_methods'] = array();
    $settings['block_types'] = array('products', 'categories', 'pages', 'html_block');
    if (Registry::get('addons.banners.status') == 'A') {
        $settings['block_types'][] = 'banners';
    }
    $settings['images'] = array('cart' => array('width' => 96, 'height' => 96), 'catalog' => array('width' => 200, 'height' => 200), 'prewiew' => array('width' => 130, 'height' => 120), 'big' => array('width' => 800, 'height' => 800, 'keep_proportions' => true));
    fn_set_hook('twg_config', $settings);
    // Init twigmo settings
    TwigmoSettings::moveToRuntime($settings);
}
if (file_exists(Registry::get('config.dir.addons') . 'twigmo/local_conf.php')) {
    include Registry::get('config.dir.addons') . 'twigmo/local_conf.php';
Example #11
0
<?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.            *
****************************************************************************/
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
fn_define('PAGE_TYPE_PROJECTS', 'P');
fn_define('PROJECTS_CUT', '<!--CUT-->');
Example #12
0
function fn_calculate_tax_rates($taxes, $price, $amount, $auth, &$cart)
{
    static $destination_id;
    static $tax_description;
    static $user_data;
    $taxed_price = $price;
    if (!empty($cart['user_data']) && !fn_is_empty($cart['user_data'])) {
        $profile_fields = fn_get_profile_fields('O', $auth);
        $billing_population = fn_check_profile_fields_population($cart['user_data'], 'B', $profile_fields);
        $shipping_population = fn_check_profile_fields_population($cart['user_data'], 'S', $profile_fields);
        if (empty($auth['user_id']) && (!$shipping_population || !$billing_population)) {
            fn_define('ESTIMATION', true);
        }
    }
    if (empty($auth['user_id']) && (empty($cart['user_data']) || fn_is_empty($cart['user_data']) || $billing_population != true || $shipping_population != true) && Registry::get('runtime.checkout') && Registry::get('settings.Appearance.taxes_using_default_address') !== 'Y' && !defined('ESTIMATION')) {
        return false;
    }
    if (empty($destination_id) || $user_data != @$cart['user_data']) {
        // Get billing location
        $location = fn_get_customer_location($auth, $cart, true);
        $destination_id['B'] = fn_get_available_destination($location);
        // Get shipping location
        $location = fn_get_customer_location($auth, $cart);
        $destination_id['S'] = fn_get_available_destination($location);
    }
    if (!empty($cart['user_data'])) {
        $user_data = $cart['user_data'];
    }
    $_tax = 0;
    $previous_priority = -1;
    $previous_price = '';
    foreach ($taxes as $key => $tax) {
        if (empty($tax['tax_id'])) {
            $tax['tax_id'] = $key;
        }
        if (empty($tax['priority'])) {
            $tax['priority'] = 0;
        }
        $_is_zero = floatval($taxed_price);
        if (empty($_is_zero)) {
            continue;
        }
        if (!empty($cart['stored_taxes']) && $cart['stored_taxes'] == 'Y' && (!empty($tax['rate_type']) || isset($cart['taxes'][$tax['tax_id']]['rate_value']))) {
            $rate = array('rate_value' => isset($cart['taxes'][$tax['tax_id']]['rate_value']) ? $cart['taxes'][$tax['tax_id']]['rate_value'] : $tax['rate_value'], 'rate_type' => isset($cart['taxes'][$tax['tax_id']]['rate_type']) ? $cart['taxes'][$tax['tax_id']]['rate_type'] : $tax['rate_type']);
        } else {
            if (!isset($destination_id[$tax['address_type']])) {
                continue;
            }
            $rate = db_get_row("SELECT destination_id, rate_value, rate_type FROM ?:tax_rates WHERE tax_id = ?i AND destination_id = ?i", $tax['tax_id'], $destination_id[$tax['address_type']]);
            if (!@floatval($rate['rate_value'])) {
                continue;
            }
        }
        $base_price = $tax['priority'] == $previous_priority ? $previous_price : $taxed_price;
        if ($rate['rate_type'] == 'P') {
            // Percent dependence
            // If tax is included into the price
            if ($tax['price_includes_tax'] == 'Y') {
                $_tax = fn_format_price($base_price - $base_price / (1 + $rate['rate_value'] / 100));
                // If tax is NOT included into the price
            } else {
                $_tax = fn_format_price($base_price * ($rate['rate_value'] / 100));
                $taxed_price += $_tax;
            }
        } else {
            $_tax = fn_format_price($rate['rate_value']);
            // If tax is NOT included into the price
            if ($tax['price_includes_tax'] != 'Y') {
                $taxed_price += $_tax;
            }
        }
        $previous_priority = $tax['priority'];
        $previous_price = $base_price;
        if (empty($tax_description[$tax['tax_id']])) {
            $tax_description[$tax['tax_id']] = db_get_field("SELECT tax FROM ?:tax_descriptions WHERE tax_id = ?i AND lang_code = ?s", $tax['tax_id'], CART_LANGUAGE);
        }
        $taxes_data[$tax['tax_id']] = array('rate_type' => $rate['rate_type'], 'rate_value' => $rate['rate_value'], 'price_includes_tax' => $tax['price_includes_tax'], 'regnumber' => @$tax['regnumber'], 'priority' => @$tax['priority'], 'tax_subtotal' => fn_format_price($_tax * $amount), 'description' => $tax_description[$tax['tax_id']]);
    }
    return empty($taxes_data) ? false : $taxes_data;
}
Example #13
0
/**
 * Get promotion dynamic properties
 *
 * @param array $promotion_id promotion ID
 * @param array $promotion promotion condition
 * @param array $condition condition
 * @param array $cart cart
 * @param array $auth auth information
 * @return mixed
 */
function fn_promotion_get_dynamic($promotion_id, $promotion, $condition, &$cart, &$auth = NULL)
{
    if ($condition == 'number_of_usages') {
        $usages = db_get_field("SELECT number_of_usages FROM ?:promotions WHERE promotion_id = ?i", $promotion_id);
        return intval($usages) + 1;
    } elseif ($condition == 'once_per_customer') {
        fn_define('PROMOTION_MIN_MATCHES', 5);
        $order_statuses = fn_get_statuses(STATUSES_ORDER, false, true);
        $_statuses = array();
        foreach ($order_statuses as $v) {
            if ($v['inventory'] == 'D') {
                // decreasing (positive) status
                $_statuses[] = $v['status'];
            }
        }
        if (empty($cart['user_data'])) {
            return 'Y';
        }
        $udata = $cart['user_data'];
        fn_fill_user_fields($udata);
        $exists = db_get_field("SELECT ((firstname = ?s) + (lastname = ?s) + (b_city = ?s) + (b_state = ?s) + (b_country = ?s) + (b_zipcode = ?s) + (email = ?s) * 6) as r FROM ?:orders WHERE FIND_IN_SET(promotion_ids, ?i) AND status IN (?a) HAVING r >= ?i LIMIT 1", $udata['firstname'], $udata['lastname'], $udata['b_city'], $udata['b_state'], $udata['b_country'], $udata['b_zipcode'], $udata['email'], $promotion_id, $_statuses, PROMOTION_MIN_MATCHES);
        $promotion_data = fn_get_promotion_data($promotion_id);
        $coupon_exist = false;
        if (!empty($promotion_data['conditions']['conditions'])) {
            foreach ($promotion_data['conditions']['conditions'] as $val) {
                if ($val['condition'] == 'coupon_code') {
                    $coupon_exist = fn_promotion_validate_coupon($val, $cart);
                    if (!empty($coupon_exist) && !empty($exists)) {
                        fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('text_can_be_used_once'), false, 'error_coupon_already_used');
                    }
                    break;
                }
            }
        }
        if (!empty($exists)) {
            return 'N';
        }
        return 'Y';
        // this is checkbox with values (Y/N), so we need to return appropriate values
    }
}
require DIR_CORE . 'fn.init.php';
require DIR_CORE . 'fn.control.php';
require DIR_CORE . 'fn.search.php';
require DIR_CORE . 'fn.promotions.php';
require DIR_CORE . 'fn.log.php';
require DIR_CORE . 'fn.companies.php';
if (in_array(PRODUCT_TYPE, array('PROFESSIONAL', 'MULTIVENDOR', 'MULTISHOP'))) {
    require DIR_CORE . 'editions/fn.pro_functions.php';
}
if (in_array(PRODUCT_TYPE, array('MULTIVENDOR', 'MULTISHOP'))) {
    require DIR_CORE . 'editions/fn.mve_functions.php';
}
if (PRODUCT_TYPE == 'MULTISHOP') {
    require DIR_CORE . 'editions/fn.mse_functions.php';
}
fn_define('ACCOUNT_TYPE', 'customer');
if (file_exists(DIR_CORE . 'classes/profiler.php')) {
    require DIR_CORE . 'classes/profiler.php';
    require DIR_CORE . 'classes/registry.php';
    require DIR_CORE . 'classes/session.php';
} else {
    require DIR_CORE . 'class.profiler.php';
    require DIR_CORE . 'class.registry.php';
    require DIR_CORE . 'class.session.php';
}
// Used for the javascript to be able to hide the Loading box when a downloadable file (pdf, etc.) is ready
//setcookie('page_unload', 'N', '0', !empty($config['current_path'])? $config['current_path'] : '/');
if (isset($_GET['ct']) && (AREA == 'A' || defined('DEVELOPMENT'))) {
    fn_rm(DIR_THUMBNAILS, false);
}
// Set configuration options from config.php to registry
Example #15
0
// API request timeout
fn_define('SE_PRODUCTS_PER_PASS', 100);
// Number of products submitted in a single API request during a full catalog synchronization
fn_define('SE_USE_RELEVANCE_AS_DEFAULT_SORTING', 'Y');
// Y or N  (Set Sorting by relevance as the default sorting on product search in the storefront)
//
// Not configurable constants
//
fn_define('SE_VERSION', '1.3');
fn_define('SE_IMAGE_SIZE', 100);
fn_define('SE_MEMORY_LIMIT', 512);
fn_define('SE_MAX_ERROR_COUNT', 15);
fn_define('SE_MAX_PROCESSING_TIME', 720);
fn_define('SE_MAX_SEARCH_REQUEST_LENGTH', '8000');
fn_define('SE_SERVICE_URL', 'http://www.searchanise.com');
fn_define('SE_PLATFORM', 'cs-cart4');
function fn_searchanise_init_secure_controllers(&$controllers)
{
    $controllers['searchanise'] = 'passive';
}
function fn_searchanise_dispatch_assign_template($controller, $mode, $area)
{
    if (AREA != 'C') {
        return;
    }
    if (!fn_allowed_for('ULTIMATE') && fn_se_get_import_status(fn_se_get_company_id(), CART_LANGUAGE) == 'done') {
        $se_active_companies = db_get_fields("SELECT company_id FROM ?:companies WHERE status = 'A'");
        $se_active_companies = join('|', $se_active_companies);
        $se_active_companies = '0' . (empty($se_active_companies) ? '' : '|') . $se_active_companies;
        Registry::set('se_active_companies', $se_active_companies);
        Tygh::$app['view']->assign('se_active_companies', $se_active_companies);
Example #16
0
<?php

if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
fn_define('DISABLE_HOOK_CACHE', true);
fn_register_hooks('get_products_post');
Example #17
0
/**
 * Detect user agent
 *
 * @return boolean true always
 */
function fn_init_ua()
{
    static $crawlers = array('google', 'bot', 'yahoo', 'spider', 'archiver', 'curl', 'python', 'nambu', 'twitt', 'perl', 'sphere', 'PEAR', 'java', 'wordpress', 'radian', 'crawl', 'yandex', 'eventbox', 'monitor', 'mechanize', 'facebookexternal');
    $http_ua = isset($_SERVER['HTTP_USER_AGENT']) ? strtolower($_SERVER['HTTP_USER_AGENT']) : '';
    if (strpos($http_ua, 'shiretoko') !== false || strpos($http_ua, 'firefox') !== false) {
        $ua = 'firefox';
    } elseif (strpos($http_ua, 'chrome') !== false) {
        $ua = 'chrome';
    } elseif (strpos($http_ua, 'safari') !== false) {
        $ua = 'safari';
    } elseif (strpos($http_ua, 'opera') !== false) {
        $ua = 'opera';
    } elseif (strpos($http_ua, 'msie') !== false) {
        $ua = 'ie';
    } elseif (empty($http_ua) || preg_match('/(' . implode('|', $crawlers) . ')/', $http_ua, $m)) {
        $ua = 'crawler';
        if (!empty($m)) {
            fn_define('CRAWLER', $m[1]);
        }
        if (!defined('SKIP_SESSION_VALIDATION')) {
            fn_define('NO_SESSION', true);
            // do not start session for crawler
        }
    } else {
        $ua = 'unknown';
    }
    fn_define('USER_AGENT', $ua);
    return true;
}
Example #18
0
*                                                                          *
* 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;
use Tygh\Enum\ProductFeatures;
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
fn_define('KEEP_UPLOADED_FILES', true);
fn_define('NEW_FEATURE_GROUP_ID', 'OG');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    fn_trusted_vars('feature_data');
    // Update features
    if ($mode == 'update') {
        $feature_id = fn_update_product_feature($_REQUEST['feature_data'], $_REQUEST['feature_id'], DESCR_SL);
        if ($_REQUEST['feature_data']['feature_type'] == ProductFeatures::EXTENDED) {
            return array(CONTROLLER_STATUS_OK, 'product_features.update?feature_id=' . $feature_id);
        }
    }
    if ($mode == 'update_status') {
        fn_tools_update_status($_REQUEST);
        if (!empty($_REQUEST['status']) && $_REQUEST['status'] == 'D') {
            $filter_ids = db_get_fields("SELECT filter_id FROM ?:product_filters WHERE feature_id = ?i AND status = 'A'", $_REQUEST['id']);
            if (!empty($filter_ids)) {
                db_query("UPDATE ?:product_filters SET status = 'D' WHERE filter_id IN (?n)", $filter_ids);
Example #19
0
*                                                                          *
* 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;
use Tygh\Settings;
use Tygh\Navigation\LastView;
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
fn_define('LOG_MAX_DATA_LENGTH', 10000);
function fn_log_event($type, $action, $data = array())
{
    $object_primary_keys = array('users' => 'user_id', 'orders' => 'order_id', 'products' => 'product_id', 'categories' => 'category_id');
    $update = false;
    $content = array();
    $actions = Registry::get('settings.Logging.log_type_' . $type);
    $cut_log = Registry::ifGet('log_cut', false);
    Registry::del('log_cut');
    $cut_data = Registry::ifGet('log_cut_data', false);
    Registry::del('log_cut_data');
    if (empty($actions) || $action && !empty($actions) && empty($actions[$action]) || !empty($cut_log)) {
        return false;
    }
    if (!empty($_SESSION['auth']['user_id'])) {
        $user_id = $_SESSION['auth']['user_id'];
Example #20
0
 list($products, $search) = fn_get_products($params, Registry::get('settings.Appearance.products_per_page'));
 if (!empty($products)) {
     foreach ($products as $k => $v) {
         fn_gather_additional_product_data($products[$k], true, true, true, true, true);
     }
 }
 $selected_layout = fn_get_products_layout($_REQUEST);
 $view->assign('products', $products);
 $view->assign('search', $search);
 $view->assign('selected_layout', $selected_layout);
 $view->assign('category_data', $category_data);
 // If page title for this category is exist than assign it to template
 if (!empty($category_data['page_title'])) {
     $view->assign('page_title', $category_data['page_title']);
 }
 fn_define('FILTER_CUSTOM_ADVANCED', true);
 // this constant means that extended filtering should be stayed on the same page
 if (!empty($_REQUEST['advanced_filter']) && $_REQUEST['advanced_filter'] == 'Y') {
     list($filters) = fn_get_filters_products_count($_REQUEST);
     $view->assign('filter_features', $filters);
 }
 // [Breadcrumbs]
 $parent_ids = explode('/', $category_data['id_path']);
 array_pop($parent_ids);
 if (!empty($parent_ids)) {
     $cats = fn_get_category_name($parent_ids);
     foreach ($parent_ids as $c_id) {
         fn_add_breadcrumb($cats[$c_id], "categories.view?category_id={$c_id}");
     }
 }
 fn_add_breadcrumb($category_data['category'], empty($_REQUEST['features_hash']) && empty($_REQUEST['advanced_filter']) ? '' : "categories.view?category_id={$_REQUEST['category_id']}");
Example #21
0
 public function update($id, $params)
 {
     fn_define('ORDER_MANAGEMENT', true);
     $data = array();
     $valid_params = true;
     $status = Response::STATUS_BAD_REQUEST;
     if ($valid_params) {
         fn_clear_cart($cart, true);
         $customer_auth = fn_fill_auth(array(), array(), false, 'C');
         $cart_status = md5(serialize($cart));
         // Order info was not found or customer does not have enought permissions
         if (fn_form_cart($id, $cart, $customer_auth) && $cart_status != md5(serialize($cart))) {
             unset($params['product_groups']);
             if (empty($params['shipping_id'])) {
                 $shipping = reset($cart['shipping']);
                 if (!empty($shipping['shipping_id'])) {
                     $params['shipping_id'] = $shipping['shipping_id'];
                 }
             }
             $cart['order_id'] = $id;
             fn_calculate_cart_content($cart, $customer_auth);
             if (!empty($params['user_id'])) {
                 $cart['user_data'] = fn_get_user_info($params['user_id']);
             } elseif (!empty($params)) {
                 $cart['user_data'] = array_merge($cart['user_data'], $params);
             }
             if (!empty($cart['product_groups']) && !empty($params['shipping_id'])) {
                 foreach ($cart['product_groups'] as $key => $group) {
                     foreach ($group['shippings'] as $shipping_id => $shipping) {
                         if ($params['shipping_id'] == $shipping['shipping_id']) {
                             $cart['chosen_shipping'][$key] = $shipping_id;
                             break;
                         }
                     }
                 }
             }
             if (!empty($params['payment_id'])) {
                 if (!empty($params['payment_info'])) {
                     $cart['payment_info'] = $params['payment_info'];
                 } elseif ($params['payment_id'] != $cart['payment_id']) {
                     $cart['payment_info'] = array();
                 }
                 $cart['payment_id'] = $params['payment_id'];
             }
             if (!empty($params['products'])) {
                 $cart['products'] = $params['products'];
             }
             fn_calculate_cart_content($cart, $customer_auth);
             if (!empty($cart) && empty($cart['shipping_failed'])) {
                 $cart['parent_order_id'] = 0;
                 fn_update_payment_surcharge($cart, $customer_auth);
                 list($order_id, $order_status) = fn_update_order($cart, $id);
                 if ($order_id) {
                     if (!empty($params['status']) && fn_check_permissions('orders', 'update_status', 'admin')) {
                         fn_change_order_status($order_id, $params['status'], '', fn_get_notification_rules($params, false));
                     } elseif (!empty($order_status)) {
                         fn_change_order_status($order_id, $order_status, '', fn_get_notification_rules($params, false));
                     }
                     $status = Response::STATUS_OK;
                     $data = array('order_id' => $order_id);
                 }
             }
         }
     }
     return array('status' => $status, 'data' => $data);
 }
Example #22
0
*                                                                          *
*   (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');
}
fn_define('KEEP_UPLOADED_FILES', true);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $suffix = '';
    if (!fn_allowed_for('ULTIMATE:FREE')) {
        if ($mode == 'add_exceptions') {
            foreach ($_REQUEST['add_options_combination'] as $k => $v) {
                $_data = array('product_id' => $_REQUEST['product_id'], 'combination' => $v);
                fn_update_exception($_data);
            }
            fn_recalculate_exceptions($_REQUEST['product_id']);
            $suffix = ".exceptions?product_id={$_REQUEST['product_id']}";
        }
        if ($mode == 'm_delete_exceptions') {
            foreach ($_REQUEST['exception_ids'] as $id) {
                fn_delete_exception($id);
            }
Example #23
0
function fn_update_localization($data, $localization_id = 0, $lang_code = DESCR_SL)
{
    fn_define('POSITIONS_STEP', 10);
    if (!empty($localization_id)) {
        db_query('UPDATE ?:localizations SET ?u WHERE localization_id = ?i', $data, $localization_id);
        db_query('UPDATE ?:localization_descriptions SET ?u WHERE localization_id = ?i AND lang_code = ?s', $data, $localization_id, $lang_code);
        db_query("DELETE FROM ?:localization_elements WHERE localization_id = ?i", $localization_id);
    } else {
        $exist = db_get_field("SELECT COUNT(*) FROM ?:localizations");
        if (empty($exist)) {
            $data['is_default'] = 'Y';
        }
        $localization_id = $data['localization_id'] = db_query("REPLACE INTO ?:localizations ?e", $data);
        foreach (fn_get_translation_languages() as $data['lang_code'] => $_v) {
            db_query("REPLACE INTO ?:localization_descriptions ?e", $data);
        }
    }
    $_data = array('localization_id' => $localization_id);
    if (!empty($data['countries'])) {
        $_data['element_type'] = 'C';
        foreach ($data['countries'] as $key => $value) {
            $_data['element'] = $value;
            $_data['position'] = POSITIONS_STEP * $key;
            db_query('INSERT INTO ?:localization_elements ?e', $_data);
        }
    }
    if (!empty($data['currencies'])) {
        $_data['element_type'] = 'M';
        foreach ($data['currencies'] as $key => $value) {
            $_data['element'] = $value;
            $_data['position'] = POSITIONS_STEP * $key;
            db_query('INSERT INTO ?:localization_elements ?e', $_data);
        }
    }
    if (!empty($data['languages'])) {
        $_data['element_type'] = 'L';
        foreach ($data['languages'] as $key => $value) {
            $_data['element'] = $value;
            $_data['position'] = POSITIONS_STEP * $key;
            db_query('INSERT INTO ?:localization_elements ?e', $_data);
        }
    }
    return $localization_id;
}
Example #24
0
 * 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.            *
 ****************************************************************************/
//
// $Id: checkout.php 10349 2010-08-04 12:56:49Z alexions $
//
if (!defined('AREA')) {
    die('Access denied');
}
fn_define('CHECKOUT', true);
fn_define('ORDERS_TIMEOUT', 60);
// Cart is empty, create it
if (empty($_SESSION['cart'])) {
    fn_clear_cart($_SESSION['cart']);
}
$cart =& $_SESSION['cart'];
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $_suffix = '';
    //
    // Add product to cart
    //
    if ($mode == 'add') {
        if (empty($auth['user_id']) && Registry::get('settings.General.allow_anonymous_shopping') != 'Y') {
            return array(CONTROLLER_STATUS_REDIRECT, "auth.login_form?return_url=" . urlencode($_SERVER['HTTP_REFERER']));
        }
        // Add to cart button was pressed for single product on advanced list
Example #25
0
*                                                                          *
****************************************************************************
* PLEASE READ THE FULL TEXT  OF THE SOFTWARE  LICENSE   AGREEMENT  IN  THE *
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE.            *
****************************************************************************/
use Tygh\Enum\ProductFeatures;
use Tygh\Database;
use Tygh\Exceptions\DeveloperException;
use Tygh\Mailer;
use Tygh\Navigation\LastView;
use Tygh\Registry;
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
fn_define('COUPON_CODE_LENGTH', 8);
fn_define('PROMOTION_MIN_MATCHES', 5);
/**
 * Get promotions
 *
 * @param array $params array with search params
 * @param int $items_per_page
 * @param string $lang_code
 * @return array list of promotions in first element, filtered parameters in second
 */
function fn_get_promotions($params, $items_per_page = 0, $lang_code = CART_LANGUAGE)
{
    // Init filter
    $params = LastView::instance()->update('promotions', $params);
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page, 'get_hidden' => true);
    $params = array_merge($default_params, $params);
Example #26
0
*                                                                          *
* 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\Pdf;
use Tygh\Registry;
use Tygh\Storage;
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
fn_define('ITEMS_PER_PAGE', 30);
define('GENERAL_FONT_FAMILY', 'freeserif');
define('GENERAL_FONT_SIZE', 10);
define('GENERAL_MARGIN_TOP', 10);
define('GENERAL_MARGIN_LEFT', 10);
define('GENERAL_MARGIN_RIGHT', 10);
define('FIELDS_HEADER_FONT_SIZE', 11);
define('FIELDS_ODD_BG_COLOR', '#EEEEEE');
define('IMAGE_HEIGHT', 50);
define('CATEGORY_HEADER_FONT_SIZE', 12);
define('CATEGORY_HEADER_FONT_COLOR', '#FFFFFF');
define('CATEGORY_HEADER_BG_COLOR', '#888888');
define('TABLE_CELLPADDING', 4);
define('TABLE_CELLSPACING', 0);
// Min column width in percent
$min_width = array('product' => 50, 'product_code' => 13, 'image' => 10);
Example #27
0
        if (!empty($order_info)) {
            Tygh::$app['view']->assign('order_info', $order_info);
        }
    }
    fn_add_breadcrumb(__('landing_header'));
} elseif ($mode == 'process_payment') {
    if (fn_allow_place_order($cart, $auth) == true) {
        $order_info = $cart;
        $order_info['products'] = $cart['products'];
        $order_info = fn_array_merge($order_info, $cart['user_data']);
        $order_info['order_id'] = $order_id = TIME . "_" . (!empty($auth['user_id']) ? $auth['user_id'] : 0);
        unset($order_info['user_data']);
        list($is_processor_script, $processor_data) = fn_check_processor_script($order_info['payment_id']);
        if ($is_processor_script) {
            set_time_limit(300);
            fn_define('IFRAME_MODE', true);
            include Registry::get('config.dir.payments') . $processor_data['processor_script'];
            fn_finish_payment($order_id, $pp_response, array());
            fn_order_placement_routines('route', $order_id);
        }
    }
}
if (fn_cart_is_empty($cart) && !isset($force_redirection) && !in_array($mode, array('clear', 'delete', 'cart', 'update', 'apply_coupon', 'shipping_estimation', 'update_shipping', 'complete'))) {
    fn_set_notification('W', __('cart_is_empty'), __('cannot_proccess_checkout', 'K', 'cannot_proccess_checkout'));
    return array(CONTROLLER_STATUS_REDIRECT, 'checkout.cart');
}
if (!empty($profile_fields)) {
    Tygh::$app['view']->assign('profile_fields', $profile_fields);
}
Tygh::$app['view']->assign('cart', $cart);
Tygh::$app['view']->assign('continue_url', empty($_SESSION['continue_url']) ? '' : $_SESSION['continue_url']);
Example #28
0
*                                                                          *
****************************************************************************
* PLEASE READ THE FULL TEXT  OF THE SOFTWARE  LICENSE   AGREEMENT  IN  THE *
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE.            *
****************************************************************************/
/* WARNING: DO NOT MODIFY THIS FILE TO AVOID PROBLEMS WITH THE CART FUNCTIONALITY */
use Tygh\Registry;
use Tygh\Settings;
use Tygh\Mailer;
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
include_once Registry::get('config.dir.schemas') . 'literal_converter/utf8.functions.php';
fn_define('LIC_STAT_FR', 0x1a4);
fn_define('LIC_STAT_TR', 0xf17);
fn_define('LIC_STAT_FL', 0xbb1);
$schema = array();
$prefix = fn_simple_decode_str('mbtu');
$description = fn_simple_decode_str('tubuvt');
if (!empty($_SESSION[fn_simple_decode_str('npef`sfdifdl')])) {
    unset($_SESSION[fn_simple_decode_str('npef`sfdifdl')]);
    $mode = fn_get_storage_data(fn_simple_decode_str('tupsf`npef'));
    switch ($mode) {
        case fn_simple_decode_str('usjbm'):
            $_SESSION[$prefix . '_' . $description] = fn_simple_decode_str('MJDFOTF`JT`JOWBMJE');
            $_SESSION[$description] = LIC_STAT_TR;
            break;
        case fn_simple_decode_str('gsff'):
        case fn_simple_decode_str('gvmm'):
            $_SESSION[$prefix . '_' . $description] = fn_simple_decode_str('BDUJWF');
            if ($mode == fn_simple_decode_str('gvmm')) {
Example #29
0
*   (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');
}
include_once Registry::get('config.dir.payments') . 'amazon/amazon_func.php';
fn_define('AMAZON_ORDER_DATA', 'Z');
if (!empty($_POST['order-calculations-request'])) {
    $xml_response = $_POST['order-calculations-request'];
} elseif (!empty($_POST['NotificationData'])) {
    $xml_response = $_POST['NotificationData'];
}
if (!empty($_POST['order-calculations-error'])) {
    // Process the Amazon callback error
    $xml_error = $_POST['order-calculations-error'];
    $xml = @simplexml_load_string($xml_error);
    if (empty($xml)) {
        $xml = @simplexml_load_string(stripslashes($xml_error));
    }
    // Get error message
    $code = (string) $xml->OrderCalculationsErrorCode;
    $message = (string) $xml->OrderCalculationsErrorMessage;
Example #30
0
 public static function import($store_data, $actualize_data = false)
 {
     set_time_limit(0);
     ini_set('memory_limit', '1024M');
     fn_define('STORE_IMPORT', true);
     $log_dir = Registry::get('config.dir.store_import');
     fn_mkdir($log_dir);
     $logger = \Tygh\Logger::instance();
     $logger->logfile = $log_dir . date('Y-m-d_H-i') . '.log';
     if ($actualize_data) {
         $logos = self::_backupLogos();
     }
     $import_classes_cascade = self::getImportClassesCascade($store_data);
     $db_already_cloned = false;
     Registry::set('runtime.skip_sharing_selection', true);
     self::_removeTempTables();
     self::_setUnavailableLangVars();
     if (!$actualize_data) {
         self::_uninstallAllAddons();
     }
     fn_set_progress('parts', count($import_classes_cascade) * 6 + 2);
     $result = !empty($import_classes_cascade) ? true : false;
     self::setDefaultLanguage($store_data);
     foreach ($import_classes_cascade as $class_name) {
         if ($result) {
             if (class_exists($class_name)) {
                 $obj = new $class_name($store_data);
                 $result = $db_already_cloned = $obj->import($db_already_cloned);
                 Settings::instance()->reloadSections();
             } else {
                 $result = false;
                 fn_set_notification('E', __('error'), __('store_import.class_not_found'));
                 break;
             }
         } else {
             fn_set_notification('E', __('error'), __('store_import.import_failed'));
             break;
         }
     }
     Registry::set('runtime.skip_sharing_selection', false);
     if ($result) {
         General::setLicenseData();
         //First, we should install all addons from old version in the new version that all templates, etc were installed in the new version
         self::installAddons();
         //Next, we should install all tabs in the upgraded database (mostly for the old version, 2.2.x)
         self::installAddonsTabs();
         fn_clear_cache();
         if (!$actualize_data) {
             self::_removeRussianServices($store_data);
             if (fn_allowed_for('ULTIMATE')) {
                 $company_ids = db_get_fields("SELECT company_id FROM ?:companies");
                 foreach ($company_ids as $company_id) {
                     self::_installTheme($company_id);
                 }
             } else {
                 self::_installTheme();
             }
         }
         self::replaceOriginalDB($store_data, $actualize_data);
         fn_install_addon('store_import', false);
         self::_removeTempTables();
         if (defined('AJAX_REQUEST')) {
             Registry::get('ajax')->assign('non_ajax_notifications', true);
             Registry::get('ajax')->assign('force_redirection', fn_url('index.index'));
         }
         if ($actualize_data) {
             self::_restoreLogos($logos);
         }
         fn_set_progress('step_scale', '1');
         fn_set_progress('echo', __('store_import.done'), true);
         return true;
     }
     return false;
 }