/**
  * Initialize object of class
  *
  * @return Maged_Controller
  */
 public static function singleton()
 {
     if (!self::$_instance) {
         self::$_instance = new self();
         if (self::$_instance->isDownloaded() && self::$_instance->isInstalled()) {
             Mage::app('', 'store', array('global_ban_use_cache' => true));
             Mage::getSingleton('adminhtml/url')->turnOffSecretKey();
         }
     }
     return self::$_instance;
 }
Example #2
0
 /**
  * Initialize object of class
  *
  * @return Maged_Controller
  */
 public static function singleton()
 {
     if (!self::$_instance) {
         self::$_instance = new self();
         if (self::$_instance->isDownloaded() && self::$_instance->isInstalled()) {
             Mage::app();
             Mage::getSingleton('adminhtml/url')->turnOffSecretKey();
         }
     }
     return self::$_instance;
 }
Example #3
0
 /**
  * Retrieve Controller as singleton
  *
  * @return Maged_Controller
  */
 public function controller()
 {
     return Maged_Controller::singleton();
 }
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Magento Enterprise Edition License
 * that is bundled with this package in the file LICENSE_EE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.magentocommerce.com/license/enterprise-edition
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    Mage
 * @package     Mage_Connect
 * @copyright   Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://www.magentocommerce.com/license/enterprise-edition
 */
if (version_compare(phpversion(), '5.2.0', '<') === true) {
    echo '<div style="font:12px/1.35em arial, helvetica, sans-serif;"><div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;"><h3 style="margin:0; font-size:1.7em; font-weight:normal; text-transform:none; text-align:left; color:#2f2f2f;">Whoops, it looks like you have an invalid PHP version.</h3></div><p>Magento supports PHP 5.2.0 or newer. <a href="http://www.magentocommerce.com/install" target="">Find out</a> how to install</a> Magento using PHP-CGI as a work-around.</p></div>';
    exit;
}
require_once "lib/Mage/Autoload/Simple.php";
Mage_Autoload_Simple::register();
umask(0);
Maged_Controller::run();
Example #5
0
 /**
  * Wrapper to System::mkDir(), creates a directory as well as
  * any necessary parent directories.
  *
  * @param string  $dir  directory name
  *
  * @return bool TRUE on success, or a PEAR error
  *
  * @access public
  */
 function mkDirHier($dir)
 {
     $this->log(2, "+ create dir {$dir}");
     if (!class_exists('System')) {
         require_once 'System.php';
     }
     /*
      * Magento fix for custom set permissions in config.ini
      */
     if (class_exists('Maged_Controller', false)) {
         $magedConfig = Maged_Controller::model('Config', true)->load();
         if ($magedConfig->get('use_custom_permissions_mode') == '1' && ($mode = $magedConfig->get('mkdir_mode'))) {
             return System::mkDir(array('-m' . $mode, $dir));
         }
     }
     /*
      * End fix
      */
     return System::mkDir(array('-p', $dir));
 }
Example #6
0
 /**
  * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
  * @param string filename
  * @param array attributes from <file> tag in package.xml
  * @param string path to install the file in
  * @param array options from command-line
  * @access private
  */
 function _installFile2(&$pkg, $file, $atts, $tmp_path, $options)
 {
     if (!isset($this->_registry)) {
         $this->_registry =& $this->config->getRegistry();
     }
     $channel = $pkg->getChannel();
     // {{{ assemble the destination paths
     if (!in_array($atts['attribs']['role'], PEAR_Installer_Role::getValidRoles($pkg->getPackageType()))) {
         return $this->raiseError('Invalid role `' . $atts['attribs']['role'] . "' for file {$file}");
     }
     $role =& PEAR_Installer_Role::factory($pkg, $atts['attribs']['role'], $this->config);
     $err = $role->setup($this, $pkg, $atts['attribs'], $file);
     if (PEAR::isError($err)) {
         return $err;
     }
     if (!$role->isInstallable()) {
         return;
     }
     $info = $role->processInstallation($pkg, $atts['attribs'], $file, $tmp_path);
     if (PEAR::isError($info)) {
         return $info;
     } else {
         list($save_destdir, $dest_dir, $dest_file, $orig_file) = $info;
     }
     if (preg_match('~/\\.\\.(/|\\z)|^\\.\\./~', str_replace('\\', '/', $dest_file))) {
         return $this->raiseError("SECURITY ERROR: file {$file} (installed to {$dest_file}) contains parent directory reference ..", PEAR_INSTALLER_FAILED);
     }
     $final_dest_file = $installed_as = $dest_file;
     if (isset($this->_options['packagingroot'])) {
         $final_dest_file = $this->_prependPath($final_dest_file, $this->_options['packagingroot']);
     }
     $dest_dir = dirname($final_dest_file);
     $dest_file = $dest_dir . DIRECTORY_SEPARATOR . '.tmp' . basename($final_dest_file);
     // }}}
     if (empty($this->_options['register-only'])) {
         if (!file_exists($dest_dir) || !is_dir($dest_dir)) {
             if (!$this->mkDirHier($dest_dir)) {
                 return $this->raiseError("failed to mkdir {$dest_dir}", PEAR_INSTALLER_FAILED);
             }
             $this->log(3, "+ mkdir {$dest_dir}");
         }
     }
     $attribs = $atts['attribs'];
     unset($atts['attribs']);
     // pretty much nothing happens if we are only registering the install
     if (empty($this->_options['register-only'])) {
         if (!count($atts)) {
             // no tasks
             if (!file_exists($orig_file)) {
                 return $this->raiseError("file {$orig_file} does not exist", PEAR_INSTALLER_FAILED);
             }
             if (!@copy($orig_file, $dest_file)) {
                 return $this->raiseError("failed to write {$dest_file}: {$php_errormsg}", PEAR_INSTALLER_FAILED);
             }
             $this->log(3, "+ cp {$orig_file} {$dest_file}");
             if (isset($attribs['md5sum'])) {
                 $md5sum = md5_file($dest_file);
             }
         } else {
             // file with tasks
             if (!file_exists($orig_file)) {
                 return $this->raiseError("file {$orig_file} does not exist", PEAR_INSTALLER_FAILED);
             }
             $contents = file_get_contents($orig_file);
             if ($contents === false) {
                 $contents = '';
             }
             if (isset($attribs['md5sum'])) {
                 $md5sum = md5($contents);
             }
             foreach ($atts as $tag => $raw) {
                 $tag = str_replace(array($pkg->getTasksNs() . ':', '-'), array('', '_'), $tag);
                 $task = "PEAR_Task_{$tag}";
                 $task =& new $task($this->config, $this, PEAR_TASK_INSTALL);
                 if (!$task->isScript()) {
                     // scripts are only handled after installation
                     $task->init($raw, $attribs, $pkg->getLastInstalledVersion());
                     $res = $task->startSession($pkg, $contents, $final_dest_file);
                     if ($res === false) {
                         continue;
                         // skip this file
                     }
                     if (PEAR::isError($res)) {
                         return $res;
                     }
                     $contents = $res;
                     // save changes
                 }
                 $wp = @fopen($dest_file, "wb");
                 if (!is_resource($wp)) {
                     return $this->raiseError("failed to create {$dest_file}: {$php_errormsg}", PEAR_INSTALLER_FAILED);
                 }
                 if (fwrite($wp, $contents) === false) {
                     return $this->raiseError("failed writing to {$dest_file}: {$php_errormsg}", PEAR_INSTALLER_FAILED);
                 }
                 fclose($wp);
             }
         }
         // {{{ check the md5
         if (isset($md5sum)) {
             if (strtolower($md5sum) === strtolower($attribs['md5sum'])) {
                 $this->log(2, "md5sum ok: {$final_dest_file}");
             } else {
                 if (empty($options['force'])) {
                     // delete the file
                     if (file_exists($dest_file)) {
                         unlink($dest_file);
                     }
                     if (!isset($options['ignore-errors'])) {
                         return $this->raiseError("bad md5sum for file {$final_dest_file}", PEAR_INSTALLER_FAILED);
                     } else {
                         if (!isset($options['soft'])) {
                             $this->log(0, "warning : bad md5sum for file {$final_dest_file}");
                         }
                     }
                 } else {
                     if (!isset($options['soft'])) {
                         $this->log(0, "warning : bad md5sum for file {$final_dest_file}");
                     }
                 }
             }
         }
         // }}}
         // {{{ set file permissions
         if (!OS_WINDOWS) {
             if ($role->isExecutable()) {
                 $mode = 0777 & ~(int) octdec($this->config->get('umask'));
                 $this->log(3, "+ chmod +x {$dest_file}");
             } else {
                 $mode = 0666 & ~(int) octdec($this->config->get('umask'));
             }
             /*
              * Magento fix for custom set permissions in config.ini
              */
             if (class_exists('Maged_Controller', false)) {
                 $magedConfig = Maged_Controller::model('Config', true)->load();
                 if ($magedConfig->get('use_custom_permissions_mode') == '1') {
                     if ($role->isExecutable() && ($configMode = $magedConfig->get('chmod_file_mode_executable'))) {
                         $mode = $magedConfig;
                     }
                     if (!$role->isExecutable() && ($configMode = $magedConfig->get('chmod_file_mode'))) {
                         $mode = $magedConfig;
                     }
                 }
             }
             /*
              * End fix
              */
             if ($attribs['role'] != 'src') {
                 $this->addFileOperation("chmod", array($mode, $dest_file));
                 if (!@chmod($dest_file, $mode)) {
                     if (!isset($options['soft'])) {
                         $this->log(0, "failed to change mode of {$dest_file}: {$php_errormsg}");
                     }
                 }
             }
         }
         // }}}
         if ($attribs['role'] == 'src') {
             rename($dest_file, $final_dest_file);
             $this->log(2, "renamed source file {$dest_file} to {$final_dest_file}");
         } else {
             $this->addFileOperation("rename", array($dest_file, $final_dest_file, $role->isExtension()));
         }
     }
     // Store the full path where the file was installed for easy uninstall
     if ($attribs['role'] != 'src') {
         $loc = $this->config->get($role->getLocationConfig(), null, $channel);
         $this->addFileOperation("installed_as", array($file, $installed_as, $loc, dirname(substr($installed_as, strlen($loc)))));
     }
     //$this->log(2, "installed: $dest_file");
     return PEAR_INSTALLER_OK;
 }
Example #7
0
 /**
  * Get the path of the temporal directory set in the system
  * by looking in its environments variables.
  * Note: php.ini-recommended removes the "E" from the variables_order setting,
  * making unavaible the $_ENV array, that s why we do tests with _ENV
  *
  * @static 
  * @return string The temporary directory on the system
  */
 function tmpdir()
 {
     /*
      * Magento fix for set tmp dir in config.ini
      */
     if (class_exists('Maged_Controller', false)) {
         $magedConfig = Maged_Controller::model('Config', true)->load();
         if (!is_null($tmpDir = $magedConfig->get('tmp_dir'))) {
             return $tmpDir;
         }
     }
     /*
      * End fix
      */
     if (OS_WINDOWS) {
         if ($var = isset($_ENV['TMP']) ? $_ENV['TMP'] : getenv('TMP')) {
             return $var;
         }
         if ($var = isset($_ENV['TEMP']) ? $_ENV['TEMP'] : getenv('TEMP')) {
             return $var;
         }
         if ($var = isset($_ENV['USERPROFILE']) ? $_ENV['USERPROFILE'] : getenv('USERPROFILE')) {
             return $var;
         }
         if ($var = isset($_ENV['windir']) ? $_ENV['windir'] : getenv('windir')) {
             return $var;
         }
         return getenv('SystemRoot') . '\\temp';
     }
     if ($var = isset($_ENV['TMPDIR']) ? $_ENV['TMPDIR'] : getenv('TMPDIR')) {
         return $var;
     }
     return realpath('/tmp');
 }
Example #8
0
 public static function singleton()
 {
     if (!self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }