/** * Initialize application and parse input parameters */ public function __construct() { if ($this->_includeMage) { require_once $this->_getRootPath() . 'app' . DIRECTORY_SEPARATOR . 'Mage.php'; require_once $this->_getRootPath() . 'app' . DIRECTORY_SEPARATOR . 'MultiClient.php'; $file = $_SERVER['PWD'] . DS . $_SERVER['PHP_SELF']; $bits = explode('/', $file); Mage::app($this->_appCode, $this->_appType, MultiClient::getRunOptions($bits[count($bits) - 2])); $this->initLog(); } $this->_factory = new Mage_Core_Model_Factory(); $this->_applyPhpVariables(); $this->_parseArgs(); $this->_construct(); $this->_validate(); $this->_showHelp(); }
/** * Retrive Declared Module file list * * @return array */ protected function _getDeclaredModuleFiles() { $etcDir = $this->getOptions()->getEtcDir(); $moduleFiles = glob($etcDir . DS . 'modules' . DS . '*.xml'); $moduleFiles = array_merge($moduleFiles, glob(MultiClient::getEtcDir() . DS . 'modules' . DS . '*.xml')); if (!$moduleFiles) { return false; } $collectModuleFiles = array('base' => array(), 'mage' => array(), 'custom' => array()); foreach ($moduleFiles as $v) { $name = explode(DIRECTORY_SEPARATOR, $v); $name = substr($name[count($name) - 1], 0, -4); if ($name == 'Mage_All') { $collectModuleFiles['base'][] = $v; } elseif (substr($name, 0, 5) == 'Mage_') { $collectModuleFiles['mage'][] = $v; } else { $collectModuleFiles['custom'][] = $v; } } return array_merge($collectModuleFiles['base'], $collectModuleFiles['mage'], $collectModuleFiles['custom']); }
/** * Get the "local.xml" for this CLIENT_CODE * * @return string */ public static function getLocalXmlFile() { if (self::$_localXmlFile === null) { self::$_localXmlFile = self::getEtcDir() . DS . 'local.xml'; } return self::$_localXmlFile; }
<?php error_reporting(E_ALL | E_STRICT); define('MAGENTO_ROOT', __DIR__ . DIRECTORY_SEPARATOR . '..'); if (file_exists('maintenance.flag')) { include_once dirname(__FILE__) . '/errors/503.php'; exit; } require_once MAGENTO_ROOT . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'Mage.php'; require_once MAGENTO_ROOT . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'MultiClient.php'; umask(0); // aws load balancers are dumb if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') { $_SERVER['HTTPS'] = 'on'; $_SERVER['SERVER_PORT'] = 443; } Mage::run(MultiClient::getRunCode(), MultiClient::getRunType(), MultiClient::getRunOptions());
chdir(dirname(__FILE__)); require 'app/Mage.php'; require 'app/MultiClient.php'; if (!isset($argv[1])) { Mage::throwException('Error: CLIENT_CODE not specified'); } $code = $argv[1]; if (!Mage::isInstalled()) { echo "Application is not installed yet, please complete install wizard first."; exit; } // Only for urls // Don't remove this $_SERVER['SCRIPT_NAME'] = str_replace(basename(__FILE__), 'index.php', $_SERVER['SCRIPT_NAME']); $_SERVER['SCRIPT_FILENAME'] = str_replace(basename(__FILE__), 'index.php', $_SERVER['SCRIPT_FILENAME']); Mage::app('admin', 'store', MultiClient::getRunOptions($code))->setUseSessionInUrl(false); umask(0); $disabledFuncs = explode(',', ini_get('disable_functions')); $isShellDisabled = is_array($disabledFuncs) ? in_array('shell_exec', $disabledFuncs) : true; $isShellDisabled = stripos(PHP_OS, 'win') === false ? $isShellDisabled : true; try { if (stripos(PHP_OS, 'win') === false) { if (isset($argv[2])) { switch ($argv[2]) { case 'always': case 'default': $cronMode = $argv[2]; break; default: Mage::throwException('Unrecognized cron mode was defined'); }