Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Install_Block_Abstract
  • Mage_Install_Block_Admin
  • Mage_Install_Block_Begin
  • Mage_Install_Block_Config
  • Mage_Install_Block_Db_Main
  • Mage_Install_Block_Db_Type
  • Mage_Install_Block_Db_Type_Mysql4
  • Mage_Install_Block_Download
  • Mage_Install_Block_End
  • Mage_Install_Block_Locale
  • Mage_Install_Block_State
  • Mage_Install_Controller_Action
  • Mage_Install_Helper_Data
  • Mage_Install_IndexController
  • Mage_Install_Model_Config
  • Mage_Install_Model_Installer
  • Mage_Install_Model_Installer_Abstract
  • Mage_Install_Model_Installer_Config
  • Mage_Install_Model_Installer_Console
  • Mage_Install_Model_Installer_Data
  • Mage_Install_Model_Installer_Db
  • Mage_Install_Model_Installer_Db_Abstract
  • Mage_Install_Model_Installer_Db_Mysql4
  • Mage_Install_Model_Installer_Env
  • Mage_Install_Model_Installer_Filesystem
  • Mage_Install_Model_Installer_Pear
  • Mage_Install_Model_Observer
  • Mage_Install_Model_Session
  • Mage_Install_Model_Wizard
  • Mage_Install_WizardController
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_Install
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: 
 28: /**
 29:  * Config installer
 30:  * @category   Mage
 31:  * @package    Mage_Install
 32:  */
 33: class Mage_Install_Model_Installer_Config extends Mage_Install_Model_Installer_Abstract
 34: {
 35:     const TMP_INSTALL_DATE_VALUE= 'd-d-d-d-d';
 36:     const TMP_ENCRYPT_KEY_VALUE = 'k-k-k-k-k';
 37: 
 38:     /**
 39:      * Path to local configuration file
 40:      *
 41:      * @var string
 42:      */
 43:     protected $_localConfigFile;
 44: 
 45:     protected $_configData = array();
 46: 
 47:     public function __construct()
 48:     {
 49:         $this->_localConfigFile = Mage::getBaseDir('etc') . DS . 'local.xml';
 50:     }
 51: 
 52:     public function setConfigData($data)
 53:     {
 54:         if (is_array($data)) {
 55:             $this->_configData = $data;
 56:         }
 57:         return $this;
 58:     }
 59: 
 60:     public function getConfigData()
 61:     {
 62:         return $this->_configData;
 63:     }
 64: 
 65:     public function install()
 66:     {
 67:         $data = $this->getConfigData();
 68:         foreach (Mage::getModel('core/config')->getDistroServerVars() as $index=>$value) {
 69:             if (!isset($data[$index])) {
 70:                 $data[$index] = $value;
 71:             }
 72:         }
 73: 
 74:         if (isset($data['unsecure_base_url'])) {
 75:             $data['unsecure_base_url'] .= substr($data['unsecure_base_url'], -1) != '/' ? '/' : '';
 76:             if (strpos($data['unsecure_base_url'], 'http') !== 0) {
 77:                 $data['unsecure_base_url'] = 'http://' . $data['unsecure_base_url'];
 78:             }
 79:             if (!$this->_getInstaller()->getDataModel()->getSkipBaseUrlValidation()) {
 80:                 $this->_checkUrl($data['unsecure_base_url']);
 81:             }
 82:         }
 83:         if (isset($data['secure_base_url'])) {
 84:             $data['secure_base_url'] .= substr($data['secure_base_url'], -1) != '/' ? '/' : '';
 85:             if (strpos($data['secure_base_url'], 'http') !== 0) {
 86:                 $data['secure_base_url'] = 'https://' . $data['secure_base_url'];
 87:             }
 88: 
 89:             if (!empty($data['use_secure'])
 90:                 && !$this->_getInstaller()->getDataModel()->getSkipUrlValidation()) {
 91:                 $this->_checkUrl($data['secure_base_url']);
 92:             }
 93:         }
 94: 
 95:         $data['date']   = self::TMP_INSTALL_DATE_VALUE;
 96:         $data['key']    = self::TMP_ENCRYPT_KEY_VALUE;
 97:         $data['var_dir'] = $data['root_dir'] . '/var';
 98: 
 99:         $data['use_script_name'] = isset($data['use_script_name']) ? 'true' : 'false';
100: 
101:         $this->_getInstaller()->getDataModel()->setConfigData($data);
102: 
103:         $template = file_get_contents(Mage::getBaseDir('etc') . DS . 'local.xml.template');
104:         foreach ($data as $index => $value) {
105:             $template = str_replace('{{' . $index . '}}', '<![CDATA[' . $value . ']]>', $template);
106:         }
107:         file_put_contents($this->_localConfigFile, $template);
108:         chmod($this->_localConfigFile, 0777);
109:     }
110: 
111:     public function getFormData()
112:     {
113:         $uri = Zend_Uri::factory(Mage::getBaseUrl('web'));
114: 
115:         $baseUrl = $uri->getUri();
116:         if ($uri->getScheme() !== 'https') {
117:             $uri->setPort(null);
118:             $baseSecureUrl = str_replace('http://', 'https://', $uri->getUri());
119:         } else {
120:             $baseSecureUrl = $uri->getUri();
121:         }
122: 
123:         $connectDefault = Mage::getConfig()
124:                 ->getResourceConnectionConfig(Mage_Core_Model_Resource::DEFAULT_SETUP_RESOURCE);
125: 
126:         $data = Mage::getModel('varien/object')
127:             ->setDbHost($connectDefault->host)
128:             ->setDbName($connectDefault->dbname)
129:             ->setDbUser($connectDefault->username)
130:             ->setDbModel($connectDefault->model)
131:             ->setDbPass('')
132:             ->setSecureBaseUrl($baseSecureUrl)
133:             ->setUnsecureBaseUrl($baseUrl)
134:             ->setAdminFrontname('admin')
135:             ->setEnableCharts('1')
136:         ;
137:         return $data;
138:     }
139: 
140:     protected function _checkHostsInfo($data)
141:     {
142:         $url  = $data['protocol'] . '://' . $data['host'] . ':' . $data['port'] . $data['base_path'];
143:         $surl = $data['secure_protocol'] . '://' . $data['secure_host'] . ':' . $data['secure_port']
144:             . $data['secure_base_path'];
145: 
146:         $this->_checkUrl($url);
147:         $this->_checkUrl($surl, true);
148: 
149:         return $this;
150:     }
151: 
152:     protected function _checkUrl($url, $secure = false)
153:     {
154:         $prefix = $secure ? 'install/wizard/checkSecureHost/' : 'install/wizard/checkHost/';
155:         try {
156:             $client = new Varien_Http_Client($url . 'index.php/' . $prefix);
157:             $response = $client->request('GET');
158:             /* @var $responce Zend_Http_Response */
159:             $body = $response->getBody();
160:         }
161:         catch (Exception $e){
162:             $this->_getInstaller()->getDataModel()
163:                 ->addError(Mage::helper('install')->__('The URL "%s" is not accessible.', $url));
164:             throw $e;
165:         }
166: 
167:         if ($body != Mage_Install_Model_Installer::INSTALLER_HOST_RESPONSE) {
168:             $this->_getInstaller()->getDataModel()
169:                 ->addError(Mage::helper('install')->__('The URL "%s" is invalid.', $url));
170:             Mage::throwException(Mage::helper('install')->__('Response from server isn\'t valid.'));
171:         }
172:         return $this;
173:     }
174: 
175:     public function replaceTmpInstallDate($date = null)
176:     {
177:         $stamp    = strtotime((string) $date);
178:         $localXml = file_get_contents($this->_localConfigFile);
179:         $localXml = str_replace(self::TMP_INSTALL_DATE_VALUE, date('r', $stamp ? $stamp : time()), $localXml);
180:         file_put_contents($this->_localConfigFile, $localXml);
181: 
182:         return $this;
183:     }
184: 
185:     public function replaceTmpEncryptKey($key = null)
186:     {
187:         if (!$key) {
188:             $key = md5(Mage::helper('core')->getRandomString(10));
189:         }
190:         $localXml = file_get_contents($this->_localConfigFile);
191:         $localXml = str_replace(self::TMP_ENCRYPT_KEY_VALUE, $key, $localXml);
192:         file_put_contents($this->_localConfigFile, $localXml);
193: 
194:         return $this;
195:     }
196: }
197: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0