コード例 #1
0
ファイル: AddonsSetup.php プロジェクト: heg-arc-ne/cscart
 /**
  * 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;
 }
コード例 #2
0
ファイル: SetupController.php プロジェクト: heg-arc-ne/cscart
 /**
  * Setup console action
  *
  * @param  array $cart_settings     Cart settings
  * @param  array $database_settings Database settings
  * @param  array $server_settings   Server settings
  * @param  array $addons            List of addons to be installed
  * @return bool  Result of setup
  */
 public function actionConsole($cart_settings, $database_settings, $server_settings, $addons = array())
 {
     $app = App::instance();
     $setup_result = 1;
     // return code for cli
     $validator = new Validator();
     if ($validator->validateAll(array_merge($cart_settings, $server_settings, $database_settings, $addons))) {
         if ($app->connectToDB($database_settings['host'], $database_settings['name'], $database_settings['user'], $database_settings['password'], $database_settings['table_prefix'], $database_settings['database_backend'])) {
             define('CART_LANGUAGE', $cart_settings['main_language']);
             define('DESCR_SL', $cart_settings['main_language']);
             define('CART_SECONDARY_CURRENCY', 'NULL');
             // Need for cache_level
             set_time_limit(0);
             $sCart = new Setup($cart_settings, $server_settings, $database_settings, $this->isDemoInstall($cart_settings));
             $sAddons = new AddonsSetup();
             $sCart->setupScheme();
             $sCart->setupData();
             $sCart->setSimpleMode();
             if ($this->isDemoInstall($cart_settings)) {
                 $sCart->setupDemo();
             } else {
                 $sCart->clean();
             }
             $sCart->setupUsers();
             $sCart->setupCompanies();
             $sCart->setupLanguages($this->isDemoInstall($cart_settings));
             $sCart->setupThemes();
             $sAddons->setup($this->isDemoInstall($cart_settings), $addons);
             $license_number = !empty($cart_settings['license_number']) ? $cart_settings['license_number'] : '';
             $sCart->setupLicense($license_number);
             $sCart->writeConfig();
             $app->setNotification('N', '', $app->t('successfully_finished'), true);
             $setup_result = 0;
         }
     }
     return $setup_result;
 }
コード例 #3
0
ファイル: run.php プロジェクト: heg-arc-ne/cscart
<?php

/***************************************************************************
*                                                                          *
*   (c) 2004 Vladimir V. Kalynyak, Alexey V. Vinokurov, Ilya M. Shalnev    *
*                                                                          *
* This  is  commercial  software,  only  users  who have purchased a valid *
* license  and  accept  to the terms of the  License Agreement can install *
* and use this program.                                                    *
*                                                                          *
****************************************************************************
* PLEASE READ THE FULL TEXT  OF THE SOFTWARE  LICENSE   AGREEMENT  IN  THE *
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE.            *
****************************************************************************/
use Installer\App;
include 'app/Installer/App.php';
App::instance()->init($_REQUEST);
if (defined('CONSOLE') && file_exists('config.php')) {
    if (!defined('DEVELOPMENT')) {
        define('DEVELOPMENT', true);
    }
    $params = (include 'config.php');
    $result = App::instance()->dispatch('setup.console', $params, true);
    $status_code = array_pop($result);
    exit($status_code);
} else {
    App::instance()->run($_REQUEST);
}
コード例 #4
0
ファイル: Validator.php プロジェクト: heg-arc-ne/cscart
 /**
  * Runs some validate method from $this class
  * Automaticly generates notification if methods accept params that missing in $params
  *
  * @param  string $validator_name
  * @param  array  $params
  * @return bool   Validator result
  */
 public function validate($validator_name, $params)
 {
     $validate_result = false;
     $app = App::instance();
     if (method_exists($this, $validator_name)) {
         $can_call = true;
         $reflection_method = new \ReflectionMethod($this, $validator_name);
         $accepted_params = $reflection_method->getParameters();
         $call_params = array();
         foreach ($accepted_params as $param) {
             if (isset($params[$param->name])) {
                 $call_params[] = $params[$param->name];
             } else {
                 $can_call = false;
                 $app->setNotification('E', $app->t('error'), $app->t('empty_params', array('param' => $app->t($param->name))), true);
             }
         }
         if ($can_call) {
             $validate_result = $reflection_method->invokeArgs($this, $call_params);
         }
     }
     return $validate_result;
 }
コード例 #5
0
ファイル: Setup.php プロジェクト: askzap/ask-zap
 /**
  * Parse and import sql file
  *
  * @param  string $filename path to SQL file
  * @param  string $title    Language value that will be showed on import
  * @param  array  $extra    Extra param
  * @return bool   True on success, false otherwise
  */
 private function _parseSql($filename, $title, $extra = array())
 {
     $app = App::instance();
     $title_shown = false;
     $fd = fopen($filename, 'r');
     if ($fd) {
         $_sess_name = md5($filename);
         if (!empty($_SESSION['parse_sql'][$_sess_name])) {
             if ($_SESSION['parse_sql'][$_sess_name] == 'COMPLETED') {
                 fclose($fd);
                 return true;
             }
             fseek($fd, $_SESSION['parse_sql'][$_sess_name]);
         }
         $rest = '';
         $ret = array();
         $counter = 0;
         while (!feof($fd)) {
             $str = $rest . fread($fd, 16384);
             $rest = fn_parse_queries($ret, $str);
             if (!empty($ret)) {
                 if ($title_shown == false) {
                     $app->setNotification('N', '', $app->t($title, $extra), true);
                     $title_shown = true;
                 }
                 foreach ($ret as $query) {
                     $counter++;
                     if (strpos($query, 'CREATE TABLE') !== false) {
                         preg_match("/CREATE\\s+TABLE\\s+`(\\w*)`/i", $query, $matches);
                         $table_name = str_replace(App::DEFAULT_PREFIX, '', $matches[1]);
                         fn_set_progress('echo', $app->t('creating_table', array('table' => $table_name)));
                     } else {
                         if ($counter > 30 && !App::instance()->isConsole()) {
                             fn_set_progress('echo', '');
                             $counter = 0;
                         }
                     }
                     $query = str_replace(App::DEFAULT_PREFIX, $this->_database_settings['table_prefix'], $query);
                     db_query($query);
                 }
                 $ret = array();
             }
             // Break the connection and re-request
             if (time() - TIME > INSTALL_DB_EXECUTION && !App::instance()->isConsole()) {
                 $pos = ftell($fd);
                 $pos = $pos - strlen($rest);
                 fclose($fd);
                 $_SESSION['parse_sql'][$_sess_name] = $pos;
                 $location = $_SERVER['REQUEST_URI'] . '&no_checking=1';
                 fn_echo("<meta http-equiv=\"Refresh\" content=\"0;URL={$location}\" />");
                 die;
             }
         }
         fclose($fd);
         $_SESSION['parse_sql'][$_sess_name] = 'COMPLETED';
         return true;
     }
     return false;
 }