コード例 #1
0
 /**
  * Outputs exception information
  * @return type
  */
 public function output()
 {
     $message = $this->message;
     fn_set_notification('E', self::ERROR_HEADER, $message);
     if ($this->getTrace()) {
         $params = array('db_host', 'db_name', 'db_user', 'db_password', 'crypt_key');
         $pattern = '/(\\s*\\[.*?(' . implode('|', $params) . ')[^\\[\\]]*\\] => )[^\\s]*/iS';
         $message .= preg_replace($pattern, '$1*****', print_r($this->getTrace(), true));
     }
     Logger::instance()->write($message);
     $filename = Registry::get('config.dir.database') . 'export.sql';
     if (file_exists($filename)) {
         $new_filename = $filename . '.' . date('Y-m-d_H-i') . '.sql';
         fn_rename($filename, $new_filename);
     }
     exit;
 }
コード例 #2
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;
 }
コード例 #3
0
ファイル: func.php プロジェクト: heg-arc-ne/cscart
function fn_store_import_after_set_progress($prop, $value, $extra)
{
    \Tygh\Logger::instance()->write($value);
}
コード例 #4
0
ファイル: General.php プロジェクト: heg-arc-ne/cscart
 public static function import($store_data, $actualize_data = false)
 {
     set_time_limit(0);
     ini_set('memory_limit', '1024M');
     fn_define('STORE_IMPORT', true);
     fn_define('DISABLE_HOOK_CACHE', 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);
     $store_data['skin_name'] = self::setDefaultSkinName($store_data);
     $theme_to_be_installed = db_get_field("SELECT value FROM ?:settings_vendor_values WHERE object_id = (SELECT object_id FROM ?:settings_objects WHERE name = 'theme_name')");
     if (empty($theme_to_be_installed)) {
         $theme_to_be_installed = db_get_field("SELECT value FROM ?:settings_objects WHERE name = 'theme_name'");
     }
     $style_id_to_be_installed = db_get_field("SELECT style_id FROM ?:bm_layouts WHERE is_default = '1'");
     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) {
         if (fn_allowed_for('ULTIMATE')) {
             General::setForcedCompanyId();
         }
         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();
         if (fn_allowed_for('ULTIMATE')) {
             General::ultProcessImages($store_data);
         } else {
             General::mveProcessImages($store_data);
         }
         General::processFiles($store_data, 'downloads');
         General::processFiles($store_data, 'attachments');
         General::processFiles($store_data, 'custom_files');
         fn_clear_cache();
         if (!$actualize_data) {
             self::_removeRussianServices($store_data);
             General::uninstallAddons(array('twigmo', 'searchanise', 'live_help', 'exim_store', 'webmail'));
             /*
                             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();
                             }
             */
             db_query("UPDATE ?:settings_objects SET value = '{$theme_to_be_installed}' WHERE name = 'theme_name'");
             db_query("UPDATE ?:settings_vendor_values SET value = '{$theme_to_be_installed}' WHERE object_id = (SELECT object_id FROM ?:settings_objects WHERE name = 'theme_name')");
             db_query("UPDATE ?:bm_layouts SET style_id = '{$style_id_to_be_installed}'");
             db_query("UPDATE ?:bm_layouts SET theme_name  = '{$theme_to_be_installed}'");
         }
         self::replaceOriginalDB($store_data, $actualize_data);
         fn_install_addon('store_import', false);
         fn_uninstall_addon('twigmo', 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;
 }
コード例 #5
0
function fn_uc_run_continuous_job($fn_name, $args)
{
    // make sure no another upgrade processes are still active
    $lock_file_path = Registry::get('config.dir.upgrade') . '.upgrade_lock';
    if (is_file($lock_file_path)) {
        fn_set_notification('E', __('error'), __('text_uc_another_update_process_running', array('[filename]' => $lock_file_path, '[url]' => fn_url('upgrade_center.unlock'))));
        exit;
    } else {
        $h = fopen($lock_file_path, 'w');
        if (!$h) {
            fn_set_notification('E', __('error'), __('text_uc_cannot_lock_upgrade_process'));
            exit;
        }
        fclose($h);
    }
    // adjust PHP to handle the long-running process
    set_time_limit(0);
    // set up the logger
    try {
        $log = Logger::instance();
        $log->logfile = Registry::get('config.dir.upgrade') . 'upgrade.log';
    } catch (Exception $e) {
        fn_set_notification('W', __('warning'), __('text_uc_upgrade_log_file_not_writable'));
    }
    $args[] = $log;
    // run the job
    $result = call_user_func_array($fn_name, $args);
    // remove the lock after the job is done
    @unlink($lock_file_path);
    if (is_file($lock_file_path)) {
        fn_set_notification('W', __('warning'), __('text_uc_unable_to_remove_upgrade_lock', array('[file]' => $lock_file_path)));
    }
    return $result;
}