Beispiel #1
0
 public function import($db_already_cloned)
 {
     Registry::set('runtime.simple_ultimate', true);
     Registry::del('runtime.forced_company_id');
     General::setProgressTitle(__CLASS__);
     if (!$db_already_cloned) {
         if (!General::cloneImportedDB($this->store_data)) {
             return false;
         }
     } else {
         General::setEmptyProgressBar(__('importing_data'));
         General::setEmptyProgressBar(__('importing_data'));
     }
     General::connectToOriginalDB(array('table_prefix' => General::formatPrefix()));
     $main_sql = Registry::get('config.dir.addons') . 'store_import/database/' . $this->main_sql_filename;
     if (is_file($main_sql)) {
         //Process main sql
         if (!db_import_sql_file($main_sql)) {
             return false;
         }
     }
     General::restoreSettings();
     db_query("\n            DELETE FROM ?:settings_objects\n            WHERE name IN (\n                'product_notify_vendor',\n                'order_notify_vendor',\n                'page_notify_vendor',\n                'company_discussion_type',\n                'company_only_buyers',\n                'company_posts_per_page',\n                'company_post_approval',\n                'company_post_ip_check',\n                'company_notification_email',\n                'company_notify_vendor',\n                'companies_setting',\n                'include_companies',\n                'companies_change',\n                'companies_priority',\n                'product_share_discussion',\n                'news_share_discussion',\n                'page_share_discussion',\n                'testimonials_from_all_stores'\n            )\n            AND section_id IN (\n                SELECT section_id FROM ?:settings_sections\n                WHERE name IN (\n                    'discussion',\n                    'google_sitemap'\n                )\n            )\n        ");
     General::setEmptyProgressBar(General::getUnavailableLangVar('updating_languages'));
     General::updateAltLanguages('language_values', 'name');
     General::updateAltLanguages('settings_descriptions', array('object_id', 'object_type'));
     General::updateAltLanguages('state_descriptions', 'state_id');
     db_query('DROP TABLE IF EXISTS ?:se_queue');
     General::setEmptyProgressBar();
     General::setEmptyProgressBar();
     return true;
 }
Beispiel #2
0
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */
function smarty_function_script($params, &$smarty)
{
    static $scripts = array();
    if (!isset($scripts[$params['src']])) {
        if (strpos($params['src'], '//') === false) {
            $src = Registry::get('config.current_location') . '/' . fn_link_attach($params['src'], 'ver=' . PRODUCT_VERSION);
        } else {
            $src = $params['src'];
        }
        $scripts[$params['src']] = '<script type="text/javascript"' . (!empty($params['class']) ? ' class="' . $params['class'] . '" ' : '') . ' src="' . $src . '" ' . (isset($params['charset']) ? 'charset="' . $params['charset'] . '"' : '') . (isset($params['escape']) ? '><\\/script>' : '></script>');
        if (defined('AJAX_REQUEST') || Registry::get('runtime.inside_scripts')) {
            return $scripts[$params['src']];
        } else {
            if (isset($params['no-defer']) && $params['no-defer']) {
                return $scripts[$params['src']];
            } else {
                $cache_name = $smarty->getTemplateVars('block_cache_name');
                if (!empty($cache_name)) {
                    $cached_content = Registry::get($cache_name);
                    if (!isset($cached_content['javascript'])) {
                        $cached_content['javascript'] = '';
                    }
                    $cached_content['javascript'] .= $scripts[$params['src']];
                    Registry::set($cache_name, $cached_content, true);
                }
                $repeat = false;
                $smarty->loadPlugin('smarty_block_inline_script');
                smarty_block_inline_script(array(), $scripts[$params['src']], $smarty, $repeat);
                return '<!-- Inline script moved to the bottom of the page -->';
            }
        }
    }
}
Beispiel #3
0
 public function import($db_already_cloned)
 {
     Registry::set('runtime.simple_ultimate', true);
     Registry::del('runtime.forced_company_id');
     General::setProgressTitle(__CLASS__);
     if (!$db_already_cloned) {
         if (!General::cloneImportedDB($this->store_data)) {
             return false;
         }
     } else {
         General::setEmptyProgressBar(__('importing_data'));
         General::setEmptyProgressBar(__('importing_data'));
     }
     General::connectToOriginalDB(array('table_prefix' => General::formatPrefix()));
     $main_sql = Registry::get('config.dir.addons') . 'store_import/database/' . $this->main_sql_filename;
     if (is_file($main_sql)) {
         //Process main sql
         if (!db_import_sql_file($main_sql)) {
             return false;
         }
     }
     General::setEmptyProgressBar(General::getUnavailableLangVar('updating_languages'));
     General::updateAltLanguages('language_values', 'name');
     General::updateAltLanguages('shipping_service_descriptions', 'service_id');
     General::setEmptyProgressBar();
     General::setEmptyProgressBar();
     return true;
 }
 protected static function SendRequest($requestString, $testMode)
 {
     if ($testMode) {
         $serverUrl = "https://testpayments.worldnettps.com/merchant/xmlpayment";
     } else {
         $serverUrl = "https://payments.worldnettps.com/merchant/xmlpayment";
     }
     Registry::set('log_cut_data', array('CARDTYPE', 'CARDNUMBER', 'CARDEXPIRY', 'CARDHOLDERNAME', 'CVV', 'ISSUENO'));
     return Http::post($serverUrl, $requestString);
 }
Beispiel #5
0
 /**
  * Return template object
  *
  * @param $id
  * @return Template
  */
 public static function getById($id)
 {
     $id = (int) $id;
     if (!isset(static::$templates[$id])) {
         Registry::set('runtime.skip_sharing_selection', true);
         $result = fn_get_ebay_template($id);
         Registry::set('runtime.skip_sharing_selection', false);
         static::$templates[$id] = new Template($result);
     }
     return static::$templates[$id];
 }
Beispiel #6
0
function smarty_helper_inline_scripts($params, $content, &$smarty, &$repeat)
{
    Registry::del('runtime.inside_scripts');
    // Get inline scripts
    $repeat = false;
    $smarty->loadPlugin('smarty_block_inline_script');
    $inline_scripts = "\n\n<!-- Inline scripts -->\n" . smarty_block_inline_script(array('output' => true), '', $smarty, $repeat);
    // FIXME: Backward compatibility. If {scripts} included at the TOP of the page, do not grab inline scripts.
    Registry::set('runtime.inside_scripts', 1);
    return $inline_scripts;
}
Beispiel #7
0
 /**
  * Installs addons
  *
  * @param  bool  $install_demo
  * @param  array $addons       List of addons to be installed, if empty will be installed addons according <auto_install> tag
  * @return bool  Always true
  */
 public function setup($install_demo = true, $addons = array())
 {
     $app = App::instance();
     Registry::set('customer_theme_path', Registry::get('config.dir.install_themes') . '/' . App::THEME_NAME);
     $addons = empty($addons) ? $this->_getAddons() : $addons;
     foreach ($addons as $addon_name) {
         if (fn_install_addon($addon_name, false, $install_demo)) {
             fn_set_progress('echo', $app->t('addon_installed', array('addon' => $addon_name)) . '<br/>', true);
         }
         Registry::set('runtime.database.errors', '');
     }
     return true;
 }
Beispiel #8
0
 public function import($db_already_cloned)
 {
     Registry::set('runtime.simple_ultimate', true);
     Registry::del('runtime.forced_company_id');
     General::setProgressTitle(__CLASS__);
     if (!$db_already_cloned) {
         if (!General::cloneImportedDB($this->store_data)) {
             return false;
         }
     } else {
         General::setEmptyProgressBar(__('importing_data'));
         General::setEmptyProgressBar(__('importing_data'));
     }
     General::connectToImportedDB($this->store_data);
     $supplier_settings = $this->getSupplierSettings();
     General::setSupplierSettings($supplier_settings);
     $default_language = db_get_field("SELECT value FROM ?:settings WHERE option_name = 'customer_default_language' AND section_id = 'Appearance'");
     $settings_to_be_saved = array('use_email_as_login', 'admin_default_language', 'customer_default_language', 'disable_shipping', 'fedex_enabled', 'ups_enabled', 'usps_enabled', 'dhl_enabled', 'aup_enabled', 'can_enabled', 'swisspost_enabled', 'seo_product_type', 'seo_category_type', 'single_url', 'seo_language');
     $settings_to_be_saved_values = General::get22xSettings($settings_to_be_saved);
     $addons = General::get22xAddons();
     General::connectToOriginalDB(array('table_prefix' => General::formatPrefix()));
     $main_sql = Registry::get('config.dir.addons') . 'store_import/database/' . $this->main_sql_filename;
     if (is_file($main_sql)) {
         //Process main sql
         if (!db_import_sql_file($main_sql)) {
             return false;
         }
     }
     General::processAddons($this->store_data, __CLASS__, array_keys($addons));
     if (!empty($addons)) {
         General::processAddonsSettings($addons);
     }
     General::enableInstalledAddons($addons);
     General::setEmptyProgressBar();
     $this->_importMenu();
     $this->_copyImages();
     $this->_copyFiles();
     $this->_patchProfileFields();
     $this->_normalizeProductViews();
     $this->_normalizeUserGroupIds();
     $this->_fixLanguagesMissedInImported($default_language);
     General::addStatusColors();
     General::copyProductsBlocks($this->store_data);
     General::restore22xSavedSetting($settings_to_be_saved_values);
     General::setEmptyProgressBar();
     return true;
 }
Beispiel #9
0
 public function create($params)
 {
     $status = Response::STATUS_BAD_REQUEST;
     $data = array();
     unset($params['company_id']);
     if (Registry::get('runtime.simple_ultimate')) {
         Registry::set('runtime.simple_ultimate', false);
     }
     list($valid_params, $data['message']) = $this->checkRequiredParams($params, 'add');
     if ($valid_params) {
         $company_id = fn_update_company($params);
         if ($company_id) {
             $status = Response::STATUS_OK;
             $data = array('store_id' => $company_id);
         }
     }
     return array('status' => $status, 'data' => $data);
 }
function fn_seo_settings_update($type, $option, $new_value, $redirect_only)
{
    $old_value = Registry::get('addons.seo.' . $option);
    fn_iterate_through_seo_names(function ($seo_name) use($option, $old_value, $new_value, $redirect_only) {
        // We shouldn't consider null value
        if (false === fn_check_seo_object_exists($seo_name['object_id'], $seo_name['type'], $seo_name['company_id'])) {
            fn_delete_seo_name($seo_name['object_id'], $seo_name['type'], '', $seo_name['company_id']);
            return;
        }
        Registry::set('addons.seo.' . $option, $old_value);
        $url = fn_generate_seo_url_from_schema(array('type' => $seo_name['type'], 'object_id' => $seo_name['object_id'], 'lang_code' => $seo_name['lang_code']), false);
        fn_seo_update_redirect(array('src' => $url, 'type' => $seo_name['type'], 'object_id' => $seo_name['object_id'], 'company_id' => $seo_name['company_id'], 'lang_code' => $seo_name['lang_code']), 0, false);
        if (!$redirect_only) {
            Registry::set('addons.seo.' . $option, $new_value);
            fn_create_seo_name($seo_name['object_id'], $seo_name['type'], $seo_name['name'], 0, '', $seo_name['company_id'], $seo_name['lang_code'], true);
        }
    }, db_quote("type = ?s ?p", $type, fn_get_seo_company_condition('?:seo_names.company_id', $type)));
}
 /**
  * Move settings from the database to the registry.
  * @param array $default_settings
  */
 public static function moveToRuntime($default_settings = array())
 {
     $in_runtime = self::get();
     if (!$in_runtime) {
         $in_runtime = array();
     }
     $settings = array_merge($default_settings, $in_runtime, self::_getFromDB());
     // Merge current company's settings to the root
     $company_id = fn_twg_get_current_company_id();
     if (!empty($settings['customer_connections'][$company_id])) {
         $settings = array_merge($settings, $settings['customer_connections'][$company_id]);
     }
     Registry::set(self::REGISTRY_PATH, $settings);
     // To avoid caching set for each store
     Registry::set(self::REGISTRY_PATH . '.customer_connections', $settings['customer_connections']);
     foreach ($settings['customer_connections'] as $company_id => $connection) {
         Registry::set(self::REGISTRY_PATH . ".customer_connections.{$company_id}", $connection);
     }
 }
function fn_seo_settings_update($type, $option, $new_value, $redirect_only)
{
    $i = 0;
    $items_per_pass = 100;
    $old_value = Registry::get('addons.seo.' . $option);
    $company_condition = fn_get_seo_company_condition('?:seo_names.company_id', $type);
    while ($update_data = db_get_array("SELECT * FROM ?:seo_names WHERE type = ?s ?p LIMIT {$i}, {$items_per_pass}", $type, $company_condition)) {
        foreach ($update_data as $data) {
            Registry::set('addons.seo.' . $option, $old_value);
            $url = fn_generate_seo_url_from_schema(array('type' => $data['type'], 'object_id' => $data['object_id'], 'lang_code' => $data['lang_code']), false);
            fn_seo_update_redirect(array('src' => $url, 'type' => $data['type'], 'object_id' => $data['object_id'], 'company_id' => $data['company_id'], 'lang_code' => $data['lang_code']), 0, false);
            if (!$redirect_only) {
                Registry::set('addons.seo.' . $option, $new_value);
                fn_create_seo_name($data['object_id'], $data['type'], $data['name'], 0, '', $data['company_id'], $data['lang_code'], true);
            }
        }
        $i += $items_per_pass;
    }
}
Beispiel #13
0
 public function import($db_already_cloned)
 {
     Registry::set('runtime.simple_ultimate', true);
     Registry::del('runtime.forced_company_id');
     General::setProgressTitle(__CLASS__);
     if (!$db_already_cloned) {
         if (!General::cloneImportedDB($this->store_data)) {
             return false;
         }
     } else {
         General::setEmptyProgressBar(__('importing_data'));
         General::setEmptyProgressBar(__('importing_data'));
     }
     General::connectToOriginalDB(array('table_prefix' => General::formatPrefix()));
     $default_company = General::getDefaultCompany();
     $supplier_settings = $this->getSupplierSettings();
     General::setSupplierSettings($supplier_settings);
     $enabledSuppliers = General::supplierSettings('enabled') ? true : false;
     $main_sql = Registry::get('config.dir.addons') . 'store_import/database/' . $this->main_sql_filename;
     if (is_file($main_sql)) {
         //Process main sql
         if (!db_import_sql_file($main_sql)) {
             return false;
         }
     }
     if ($enabledSuppliers) {
         $this->_importSuppliers();
     }
     General::processAddons($this->store_data, __CLASS__);
     General::setEmptyProgressBar();
     $this->_deleteAllCompanies();
     $default_company_id = (int) General::createDefaultCompany($default_company);
     $this->_fillSharingTable($default_company_id);
     $this->_updateCompanyId($default_company_id);
     $this->_setStorefromUrl($default_company_id, $this->store_data);
     General::setEmptyProgressBar();
     return true;
 }
Beispiel #14
0
 public static function outputScript($content, \Smarty_Internal_Template $template)
 {
     if (defined('AJAX_REQUEST')) {
         return $content;
     }
     $continue = $template->smarty->getTemplateVars('block_parse_js');
     if (!$continue) {
         return $content;
     }
     $pattern = '/\\<script([^>]*)\\>.*?\\<\\/script\\>/s';
     if (preg_match_all($pattern, $content, $matches)) {
         if (Registry::get('runtime.inside_scripts')) {
             return $content;
         }
         $cache_name = $template->smarty->getTemplateVars('block_cache_name');
         $m = $matches[0];
         $m_attrs = $matches[1];
         $javascript = '';
         foreach ($m as $index => $match) {
             if (strpos($m_attrs[$index], 'data-no-defer') === false) {
                 $repeat = false;
                 $template->smarty->loadPlugin('smarty_block_inline_script');
                 smarty_block_inline_script(array(), $match, $template->smarty, $repeat);
                 $content = str_replace($match, '<!-- Inline script moved to the bottom of the page -->', $content);
                 $javascript .= $match;
             }
         }
         if (!empty($cache_name)) {
             $cached_content = Registry::get($cache_name);
             if (!isset($cached_content['javascript'])) {
                 $cached_content['javascript'] = '';
             }
             $cached_content['javascript'] .= $javascript;
             Registry::set($cache_name, $cached_content, true);
         }
     }
     return $content;
 }
Beispiel #15
0
 public function import($db_already_cloned)
 {
     Registry::set('runtime.simple_ultimate', true);
     Registry::del('runtime.forced_company_id');
     General::setProgressTitle(__CLASS__);
     if (!$db_already_cloned) {
         if (!General::cloneImportedDB($this->store_data)) {
             return false;
         }
     } else {
         General::setEmptyProgressBar(__('importing_data'));
         General::setEmptyProgressBar(__('importing_data'));
     }
     General::connectToOriginalDB(array('table_prefix' => General::formatPrefix()));
     $main_sql = Registry::get('config.dir.addons') . 'store_import/database/' . $this->main_sql_filename;
     if (is_file($main_sql)) {
         //Process main sql
         if (!db_import_sql_file($main_sql)) {
             return false;
         }
     }
     General::setEmptyProgressBar(General::getUnavailableLangVar('updating_languages'));
     General::updateAltLanguages('language_values', 'name');
     General::updateAltLanguages('settings_descriptions', array('object_id', 'object_type'));
     General::updateAltLanguages('state_descriptions', 'state_id');
     General::updateAltLanguages('shipping_service_descriptions', 'service_id');
     General::updateAltLanguages('privilege_descriptions', 'privilege');
     General::updateAltLanguages('privilege_section_descriptions', 'section_id');
     General::updateAltLanguages('country_descriptions', 'code');
     db_query('DROP TABLE IF EXISTS ?:se_queue');
     General::setEmptyProgressBar();
     General::processBlocks();
     if (db_get_field("SHOW TABLES LIKE '?:mailing_lists'")) {
         db_query("ALTER TABLE ?:mailing_lists DROP `show_on_sidebar`");
     }
     General::setEmptyProgressBar();
     return true;
 }
 /**
  * @inheritDoc
  */
 public function register(Container $app)
 {
     // Database component
     $app['db'] = function ($app) {
         $database = new Connection($app['db.driver']);
         $connected = $database->connect(Registry::get('config.db_user'), Registry::get('config.db_password'), Registry::get('config.db_host'), Registry::get('config.db_name'), array('table_prefix' => Registry::get('config.table_prefix')));
         if ($connected) {
             Registry::set('runtime.database.skip_errors', false);
         } else {
             throw new DatabaseException('Cannot connect to the database server');
         }
         return $database;
     };
     // Database driver instance
     $app['db.driver'] = function ($app) {
         return new $app['db.driver.class']();
     };
     $app['db.driver.class'] = function ($app) {
         $driver_class = Registry::ifGet('config.database_backend', 'mysqli');
         $driver_class = '\\Tygh\\Backend\\Database\\' . ucfirst($driver_class);
         return $driver_class;
     };
 }
Beispiel #17
0
 /**
  * Loads received language variables into language cache
  *
  * @param array  $var_names Language variable that to be loaded
  * @param string $lang_code 2-letter language code
  *
  * @return boolean True if any of received language variables were added into cache; false otherwise
  */
 public static function preloadLangVars($var_names, $lang_code = CART_LANGUAGE)
 {
     Registry::registerCache('lang_cache', array('language_values', 'ult_language_values'), Registry::cacheLevel('dispatch'), true);
     $values = Registry::get('lang_cache.' . $lang_code);
     if (empty($values)) {
         $values = array();
     }
     $var_names = array_diff($var_names, array_keys($values));
     if ($var_names) {
         foreach ($var_names as $index => $var_name) {
             $var_names[$index] = strtolower($var_name);
             if (isset($values[$var_name])) {
                 unset($var_names[$index]);
             }
         }
         if (empty($var_names)) {
             return true;
         }
         $fields = array('lang.name' => true, 'lang.value' => true);
         $tables = array('?:language_values lang');
         $left_join = array();
         $condition = array(db_quote('lang.lang_code = ?s', $lang_code), db_quote('lang.name IN (?a)', $var_names));
         $params = array();
         fn_set_hook('get_lang_var', $fields, $tables, $left_join, $condition, $params);
         $joins = !empty($left_join) ? ' LEFT JOIN ' . implode(', ', $left_join) : '';
         $new_values = db_get_hash_single_array('SELECT ' . implode(', ', array_keys($fields)) . ' FROM ' . implode(', ', $tables) . $joins . ' WHERE ' . implode(' AND ', $condition), array('name', 'value'));
         foreach ($var_names as $var_name) {
             if (!isset($new_values[$var_name])) {
                 $new_values[$var_name] = '_' . $var_name;
             }
         }
         $values = fn_array_merge($values, $new_values);
         Registry::set('lang_cache.' . $lang_code, $values);
         return true;
     }
     return false;
 }
Beispiel #18
0
    if (!empty($_REQUEST['user_id'])) {
        $user_data = fn_get_user_info($_REQUEST['user_id']);
        $gift_cert_data = array('send_via' => 'E', 'recipient' => "{$user_data['firstname']} {$user_data['lastname']}", 'sender' => Registry::get('settings.Company.company_name'), 'email' => $user_data['email'], 'address' => $user_data['s_address'], 'address_2' => $user_data['s_address_2'], 'city' => $user_data['s_city'], 'country' => $user_data['s_country'], 'state' => $user_data['s_state'], 'zipcode' => $user_data['s_zipcode'], 'phone' => $user_data['phone']);
        Tygh::$app['view']->assign('gift_cert_data', $gift_cert_data);
    }
    Tygh::$app['view']->assign('templates', fn_get_gift_certificate_templates());
    Tygh::$app['view']->assign('states', fn_get_all_states());
    Tygh::$app['view']->assign('countries', fn_get_simple_countries(true, CART_LANGUAGE));
} elseif ($mode == 'update') {
    $gift_cert_id = intval($_REQUEST['gift_cert_id']);
    $gift_cert_data = fn_get_gift_certificate_info($gift_cert_id);
    if (empty($gift_cert_data) || !empty($gift_cert_id) && !fn_check_company_id('gift_certificates', 'gift_cert_id', $gift_cert_id)) {
        return array(CONTROLLER_STATUS_NO_PAGE);
    }
    // [Page sections]
    Registry::set('navigation.tabs', array('detailed' => array('title' => __('detailed_info'), 'js' => true), 'log' => array('title' => __('history'), 'js' => true)));
    // [/Page sections]
    list($log, $search) = fn_get_gift_certificate_log($_REQUEST, Registry::get('settings.Appearance.admin_elements_per_page'));
    Tygh::$app['view']->assign('log', $log);
    Tygh::$app['view']->assign('search', $search);
    if (false != ($last_item = reset($log))) {
        $gift_cert_data['amount'] = $last_item['debit'];
        $gift_cert_data['products'] = $last_item['debit_products'];
    }
    Tygh::$app['view']->assign('templates', fn_get_gift_certificate_templates());
    Tygh::$app['view']->assign('states', fn_get_all_states());
    Tygh::$app['view']->assign('countries', fn_get_simple_countries(true, CART_LANGUAGE));
    Tygh::$app['view']->assign('gift_cert_data', $gift_cert_data);
} elseif ($mode == 'manage') {
    list($gift_certificates, $search) = fn_get_gift_certificates($_REQUEST, Registry::get('addons.gift_certificates.cert_per_page'));
    Tygh::$app['view']->assign('gift_certificates', $gift_certificates);
Beispiel #19
0
/**
 * Gets data from storage
 * @param string $key key
 * @return mixed key value
 */
function fn_get_storage_data($key)
{
    if (!Registry::isExist('storage_data.' . $key)) {
        Registry::set('storage_data.' . $key, db_get_field('SELECT `data` FROM ?:storage_data WHERE `data_key` = ?s', $key));
    }
    return Registry::get('storage_data.' . $key);
}
Beispiel #20
0
/**
 * Fuctnions parses SQL file and import data from it
 *
 * @param string $file File for import
 * @param integer $buffer Buffer size for fread function
 * @param bool $show_status Show or do not show process by printing ' .'
 * @param integer $show_create_table 0 - Do not print the name of created table, 1 - Print name and get lang_var('create_table'), 2 - Print name without getting lang_var
 * @param bool $check_prefix Check table prefix and replace it with the installed in config.php
 * @param bool $track Use queries cache. Do not execute queries that already are executed.
 * @param bool $skip_errors Skip errors or not
 * @param bool $move_progress_bar Move COMET progress bar or not on show progress
 * @return bool false, if file is not accessible
 */
function db_import_sql_file($file, $buffer = 16384, $show_status = true, $show_create_table = 1, $check_prefix = false, $track = false, $skip_errors = false, $move_progress_bar = true)
{
    if (file_exists($file)) {
        $path = dirname($file);
        $file_name = fn_basename($file);
        $tmp_file = $path . "/{$file_name}.tmp";
        $executed_queries = array();
        if ($track && file_exists($tmp_file)) {
            $executed_queries = unserialize(fn_get_contents($tmp_file));
        }
        if ($skip_errors) {
            $_skip_errors = Registry::get('runtime.database.skip_errors');
            Registry::set('runtime.database.skip_errors', true);
        }
        $fd = fopen($file, 'r');
        if ($fd) {
            $ret = array();
            $rest = '';
            $fs = filesize($file);
            if ($show_status && $move_progress_bar) {
                fn_set_progress('step_scale', ceil($fs / $buffer));
            }
            while (!feof($fd)) {
                $str = $rest . fread($fd, $buffer);
                $rest = fn_parse_queries($ret, $str);
                if ($show_status) {
                    fn_set_progress('echo', '<br />' . __('importing_data'), $move_progress_bar);
                }
                if (!empty($ret)) {
                    foreach ($ret as $query) {
                        if (!in_array($query, $executed_queries)) {
                            if ($show_create_table && preg_match('/CREATE\\s+TABLE\\s+`?(\\w+)`?/i', $query, $matches)) {
                                if ($show_create_table == 1) {
                                    $_text = __('creating_table');
                                } elseif ($show_create_table == 2) {
                                    $_text = 'Creating table';
                                }
                                $table_name = $check_prefix ? fn_check_db_prefix($matches[1], Registry::get('config.table_prefix')) : $matches[1];
                                if ($show_status) {
                                    fn_set_progress('echo', '<br />' . $_text . ': <b>' . $table_name . '</b>', $move_progress_bar);
                                }
                            }
                            if ($check_prefix) {
                                $query = fn_check_db_prefix($query);
                            }
                            Database::query($query);
                            if ($track) {
                                $executed_queries[] = $query;
                                fn_put_contents($tmp_file, serialize($executed_queries));
                            }
                            if ($show_status) {
                                fn_echo(' .');
                            }
                        }
                    }
                    $ret = array();
                }
            }
            fclose($fd);
            return true;
        }
        if ($skip_errors) {
            Registry::set('runtime.database.skip_errors', $_skip_errors);
        }
    }
    return false;
}
Beispiel #21
0
        Tygh::$app['ajax']->assign('force_redirection', fn_url('upgrade_center.manage'));
        exit;
    }
    return array(CONTROLLER_STATUS_REDIRECT);
}
if ($mode == 'refresh') {
    $app->clearDownloadedPackages();
    $app->checkUpgrades(false);
    $upgrade_packages = $app->getPackagesList();
    if (empty($upgrade_packages)) {
        fn_set_notification('N', __('notice'), __('text_no_upgrades_available'));
    }
    return array(CONTROLLER_STATUS_OK, "upgrade_center.manage?skip_checking=true");
} elseif ($mode == 'manage') {
    $tabs = array('packages' => array('title' => __('packages'), 'js' => true), 'installed_upgrades' => array('title' => __('installed_upgrades'), 'js' => true));
    Registry::set('navigation.tabs', $tabs);
    if (empty($_REQUEST['skip_checking'])) {
        $app->checkUpgrades(false);
    }
    $upgrade_packages = $app->getPackagesList();
    $installed_packages = $app->getInstalledPackagesList();
    $timeout_check_failed = fn_get_storage_data('timeout_check_failed');
    fn_set_storage_data('timeout_check_failed', false);
    Tygh::$app['view']->assign('timeout_check_failed', $timeout_check_failed);
    Tygh::$app['view']->assign('show_pre_upgrade_notice', true);
    Tygh::$app['view']->assign('upgrade_packages', $upgrade_packages);
    Tygh::$app['view']->assign('installed_packages', $installed_packages);
} elseif ($mode == 'package_content' && !empty($_REQUEST['package_id'])) {
    $package_id = $_REQUEST['package_id'];
    $content = $app->getPackageContent($package_id);
    Tygh::$app['view']->assign('package_id', $package_id);
Beispiel #22
0
            if (!empty($new_invoice)) {
                Tygh::$app['view']->assign('spsr_new_invoice', 'Y');
                Tygh::$app['view']->assign('spsr_data_invoice', $new_invoice);
                $f_spsr = 1;
            }
            if (!empty($registers)) {
                Tygh::$app['view']->assign('registers', $registers);
                $f_spsr = 1;
            }
            Tygh::$app['view']->assign('addr_list', $addr_list);
            $url_invoice = RusSpsr::urlInvoice();
            Tygh::$app['view']->assign('url_invoice', $url_invoice);
            $info_barcode = array('width' => $spsr_settings['width'], 'height' => $spsr_settings['height'], 'type' => 'C128B');
            Tygh::$app['view']->assign('info_barcode', $info_barcode);
            if ($f_spsr) {
                Registry::set('navigation.tabs.rus_spsr_invoice', array('title' => __('shippings.spsr.tab_invoice'), 'js' => true));
            }
        }
        if (!$login) {
            fn_set_notification('E', __('notice'), __('shippings.spsr.login_error') . ' : ' . RusSpsr::$last_error);
        }
        $error_logout = RusSpsr::WALogout();
        if (!$error_logout) {
            fn_set_notification('E', __('notice'), __('shippings.spsr.logout_error') . ' : ' . RusSpsr::$last_error);
        }
    }
}
if ($mode == 'spsr_barcode') {
    require Registry::get('config.dir.addons') . 'barcode/lib/barcodegenerator/barcode.php';
    $style = BCS_ALIGN_CENTER;
    if (Registry::get('addons.barcode.text') == 'Y') {
Beispiel #23
0
/**
 * Connects to ftp server
 *
 * @param array $settings options
 * @param array $settings options
 * @return boolean true if connected successfully and working directory is correct, false - otherwise
 */
function fn_ftp_connect($settings, $show_notifications = false)
{
    $result = true;
    if (function_exists('ftp_connect')) {
        if (!empty($settings['ftp_hostname'])) {
            $ftp_port = !empty($settings['ftp_port']) ? $settings['ftp_port'] : '21';
            if (substr_count($settings['ftp_hostname'], ':') > 0) {
                $start_pos = strrpos($settings['ftp_hostname'], ':');
                $ftp_port = substr($settings['ftp_hostname'], $start_pos + 1);
                $settings['ftp_hostname'] = substr($settings['ftp_hostname'], 0, $start_pos);
            }
            $ftp = @ftp_connect($settings['ftp_hostname'], $ftp_port);
            if (!empty($ftp)) {
                if (@ftp_login($ftp, $settings['ftp_username'], $settings['ftp_password'])) {
                    ftp_pasv($ftp, true);
                    if (!empty($settings['ftp_directory'])) {
                        @ftp_chdir($ftp, $settings['ftp_directory']);
                    }
                    $files = ftp_nlist($ftp, '.');
                    if (!empty($files) && in_array('config.php', $files)) {
                        Registry::set('ftp_connection', $ftp);
                    } else {
                        if ($show_notifications) {
                            fn_set_notification('E', __('error'), __('text_uc_ftp_cart_directory_not_found'));
                        }
                        $result = false;
                    }
                } else {
                    if ($show_notifications) {
                        fn_set_notification('E', __('error'), __('text_uc_ftp_login_failed'));
                    }
                    $result = false;
                }
            } else {
                if ($show_notifications) {
                    fn_set_notification('E', __('error'), __('text_uc_ftp_connect_failed'));
                }
                $result = false;
            }
        }
    } else {
        if ($show_notifications) {
            fn_set_notification('E', __('error'), __('text_uc_no_ftp_module'));
        }
        $result = false;
    }
    return $result;
}
Beispiel #24
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');
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if ($mode == 'update') {
        if (!empty($_REQUEST['posts'])) {
            fn_update_discussion_posts($_REQUEST['posts']);
        }
    }
    return;
}
if ($mode == 'update') {
    if (!fn_allowed_for('ULTIMATE')) {
        $discussion = fn_get_discussion($_REQUEST['company_id'], 'M', true, $_REQUEST);
        if (!empty($discussion) && $discussion['type'] != 'D') {
            Registry::set('navigation.tabs.discussion', array('title' => __('discussion_title_company'), 'js' => true));
            Registry::get('view')->assign('discussion', $discussion);
        }
    }
}
Beispiel #25
0
function fn_rma_generate_sections($section)
{
    Registry::set('navigation.dynamic.sections', array('requests' => array('title' => __('return_requests'), 'href' => "rma.returns")));
    Registry::set('navigation.dynamic.active_section', $section);
    return true;
}
Beispiel #26
0
        unset($_REQUEST['redirect_url']);
        fn_clear_cache();
        return array(CONTROLLER_STATUS_REDIRECT, $redirect_url);
    }
    return array(CONTROLLER_STATUS_OK, 'settings' . $_suffix . '?section_id=' . Settings::instance()->getSectionTextId($section_id));
}
//
// OUPUT routines
//
if ($mode == 'manage') {
    $subsections = Settings::instance()->getSectionTabs($section_id, CART_LANGUAGE);
    $options = Settings::instance()->getList($section_id);
    fn_update_lang_objects('subsections', $subsections);
    // [Page sections]
    if (!empty($subsections)) {
        Registry::set('navigation.tabs.main', array('title' => __('main'), 'js' => true));
        foreach ($subsections as $k => $v) {
            Registry::set('navigation.tabs.' . $k, array('title' => $v['description'], 'js' => true));
        }
    }
    // [/Page sections]
    // Set navigation menu
    $sections = Registry::get('navigation.static.top.settings.items');
    fn_update_lang_objects('sections', $sections);
    Registry::set('navigation.dynamic.sections', $sections);
    Registry::set('navigation.dynamic.active_section', Settings::instance()->getSectionTextId($section_id));
    Tygh::$app['view']->assign('options', $options);
    Tygh::$app['view']->assign('subsections', $subsections);
    Tygh::$app['view']->assign('section_id', Settings::instance()->getSectionTextId($section_id));
    Tygh::$app['view']->assign('settings_title', Settings::instance()->getSectionName($section_id));
}
Beispiel #27
0
 public static function apiPlaceOrder($data, &$response, $lang_code = CART_LANGUAGE)
 {
     $cart =& $_SESSION['cart'];
     $auth =& $_SESSION['auth'];
     if (empty($cart)) {
         $response->addError('ERROR_ACCESS_DENIED', __('access_denied', $lang_code));
         $response->returnResponse();
     }
     if (!empty($data['user'])) {
         fn_twg_api_set_cart_user_data($data['user'], $response, $lang_code);
     }
     if (empty($auth['user_id']) && empty($cart['user_data'])) {
         $response->addError('ERROR_ACCESS_DENIED', __('access_denied', $lang_code));
         $response->returnResponse();
     }
     if (empty($data['payment_info']) && !empty($cart['extra_payment_info'])) {
         $data['payment_info'] = $cart['extra_payment_info'];
     }
     if (!empty($data['payment_info'])) {
         $cart['payment_id'] = (int) $data['payment_info']['payment_id'];
         unset($data['payment_info']['payment_id']);
         if (!empty($data['payment_info'])) {
             $cart['payment_info'] = $data['payment_info'];
         }
         unset($cart['payment_updated']);
         fn_update_payment_surcharge($cart, $auth);
         fn_save_cart_content($cart, $auth['user_id']);
     }
     unset($cart['payment_info']['secure_card_number']);
     // Remove previous failed order
     if (!empty($cart['failed_order_id']) || !empty($cart['processed_order_id'])) {
         $_order_ids = !empty($cart['failed_order_id']) ? $cart['failed_order_id'] : $cart['processed_order_id'];
         foreach ($_order_ids as $_order_id) {
             fn_delete_order($_order_id);
         }
         $cart['rewrite_order_id'] = $_order_ids;
         unset($cart['failed_order_id'], $cart['processed_order_id']);
     }
     if (!empty($data['shippings'])) {
         if (!fn_checkout_update_shipping($cart, $data['shippings'])) {
             unset($cart['shipping']);
         }
     }
     Registry::set('runtime.controller', 'checkout', true);
     list(, $_SESSION['shipping_rates']) = fn_calculate_cart_content($cart, $auth, 'E');
     Registry::set('runtime.controller', 'twigmo');
     if (empty($cart['shipping']) && $cart['shipping_failed']) {
         $response->addError('ERROR_WRONG_CHECKOUT_DATA', __('wrong_shipping_info', $lang_code));
         $response->returnResponse();
     }
     if (empty($cart['payment_info']) && !isset($cart['payment_id'])) {
         $response->addError('ERROR_WRONG_CHECKOUT_DATA', __('wrong_payment_info', $lang_code));
         $response->returnResponse();
     }
     if (!empty($data['notes'])) {
         $cart['notes'] = $data['notes'];
     }
     $cart['details'] = fn_twg_get_twigmo_order_note();
     Registry::set('runtime.controller', 'checkout', true);
     list($order_id, $process_payment) = fn_place_order($cart, $auth);
     Registry::set('runtime.controller', 'twigmo');
     if (empty($order_id)) {
         return false;
     }
     if ($process_payment == true) {
         $payment_info = !empty($cart['payment_info']) ? $cart['payment_info'] : array();
         Registry::set('runtime.mode', 'place_order');
         fn_start_payment($order_id, array(), $payment_info);
     }
     self::orderPlacementRoutines($order_id);
     return $order_id;
 }
Beispiel #28
0
Debugger::checkpoint('Before init');
// Callback: verifies if https works
if (isset($_REQUEST['check_https'])) {
    die(defined('HTTPS') ? 'OK' : '');
}
// Check if software is installed
if ($config['db_host'] == '%DB_HOST%') {
    die(PRODUCT_NAME . ' is <b>not installed</b>. Please click here to start the installation process: <a href="install/">[install]</a>');
}
// Load core functions
$fn_list = array('fn.database.php', 'fn.users.php', 'fn.catalog.php', 'fn.cms.php', 'fn.cart.php', 'fn.locations.php', 'fn.common.php', 'fn.fs.php', 'fn.images.php', 'fn.init.php', 'fn.control.php', 'fn.search.php', 'fn.promotions.php', 'fn.log.php', 'fn.companies.php', 'fn.addons.php');
$fn_list[] = 'fn.' . strtolower(PRODUCT_EDITION) . '.php';
foreach ($fn_list as $file) {
    require $config['dir']['functions'] . $file;
}
Registry::set('config', $config);
unset($config);
$application = Tygh\Tygh::createApplication();
$application['class_loader'] = $classLoader;
// Register service providers
$application->register(new Tygh\Providers\DatabaseProvider());
$application->register(new \Tygh\Providers\SessionProvider());
register_shutdown_function(array('\\Tygh\\Registry', 'save'));
fn_init_stack(array('fn_init_error_handler'), array('fn_init_unmanaged_addons'));
if (defined('API')) {
    fn_init_stack(array('fn_init_api'));
}
fn_init_stack(array('fn_init_crypt'), array('fn_init_imagine'), array('fn_init_archiver'), array('fn_init_storage'), array('fn_init_ua'));
if (fn_allowed_for('ULTIMATE')) {
    fn_init_stack(array('fn_init_store_params_by_host', &$_REQUEST));
}
Beispiel #29
0
}
if ($mode == 'manage') {
    $discussion_object_types = fn_get_discussion_objects();
    if (empty($_REQUEST['object_type'])) {
        reset($discussion_object_types);
        $_REQUEST['object_type'] = key($discussion_object_types);
        // FIXME: bad style
    }
    $_url = fn_query_remove(Registry::get('config.current_url'), 'object_type', 'page');
    foreach ($discussion_object_types as $obj_type => $obj) {
        if ($obj_type == 'E' && Registry::ifGet('addons.discussion.home_page_testimonials', 'D') == 'D') {
            continue;
        }
        $_name = $obj_type != 'E' ? __($obj) . ' ' . __('discussion_title_' . $obj) : __('discussion_title_' . $obj);
        // FIXME!!! Bad style
        Registry::set('navigation.tabs.' . $obj, array('title' => $_name, 'href' => $_url . '&object_type=' . $obj_type));
    }
    list($posts, $search) = fn_get_discussions($_REQUEST, Registry::get('settings.Appearance.admin_elements_per_page'));
    if (!empty($posts)) {
        foreach ($posts as $k => $v) {
            $posts[$k]['object_data'] = fn_get_discussion_object_data($v['object_id'], $v['object_type'], DESCR_SL);
        }
    }
    Tygh::$app['view']->assign('posts', $posts);
    Tygh::$app['view']->assign('search', $search);
    Tygh::$app['view']->assign('discussion_object_type', $_REQUEST['object_type']);
    Tygh::$app['view']->assign('discussion_object_types', $discussion_object_types);
}
function fn_get_discussions($params, $items_per_page)
{
    // Init filter
Beispiel #30
0
            fn_add_breadcrumb($category_data['category']);
        }
        // Get subcategories list for current category
        Tygh::$app['view']->assign('subcategories', fn_get_subcategories($category_id));
        Tygh::$app['view']->assign('category_data', $category_data);
        Tygh::$app['view']->assign('reset_url', fn_url('companies.products?category_id=' . $category_id . '&company_id=' . $company_id));
    } else {
        if (!empty($_REQUEST['q'])) {
            fn_add_breadcrumb($company_data['company'], 'companies.products?company_id=' . $company_id);
            fn_add_breadcrumb(__('search'));
        } else {
            fn_add_breadcrumb($company_data['company']);
        }
        Tygh::$app['view']->assign('reset_url', fn_url('companies.products?company_id=' . $company_id));
    }
    list($products, $search) = fn_get_products($params, Registry::get('settings.Appearance.products_per_page'));
    if (defined('AJAX_REQUEST') && (!empty($params['features_hash']) && !$products)) {
        fn_filters_not_found_notification();
        exit;
    }
    fn_gather_additional_products_data($products, array('get_icon' => true, 'get_detailed' => true, 'get_additional' => true, 'get_options' => true));
    if (!empty($products)) {
        $_SESSION['continue_url'] = Registry::get('config.current_url');
    }
    $selected_layout = fn_get_products_layout($params);
    Tygh::$app['view']->assign('products', $products);
    Tygh::$app['view']->assign('search', $search);
    Tygh::$app['view']->assign('selected_layout', $selected_layout);
    Tygh::$app['view']->assign('company_id', $company_data['company_id']);
    Registry::set('runtime.vendor_id', $company_id);
}