Advertisement
MrBrightside

Index Magento

Feb 13th, 2015
716
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.30 KB | None | 0 0
  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
  23.  * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
  24.  * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  25.  */
  26.  
  27. if (version_compare(phpversion(), '5.2.0', '<')===true) {
  28.     echo  '<div style="font:12px/1.35em arial, helvetica, sans-serif;">
  29. <div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;">
  30. <h3 style="margin:0; font-size:1.7em; font-weight:normal; text-transform:none; text-align:left; color:#2f2f2f;">
  31. Whoops, it looks like you have an invalid PHP version.</h3></div><p>Magento supports PHP 5.2.0 or newer.
  32. <a href="http://www.magentocommerce.com/install" target="">Find out</a> how to install</a>
  33. Magento using PHP-CGI as a work-around.</p></div>';
  34.     exit;
  35. }
  36.  
  37. /**
  38.  * Error reporting
  39.  */
  40. error_reporting(E_ALL | E_STRICT);
  41.  
  42. /**
  43.  * Compilation includes configuration file
  44.  */
  45. define('MAGENTO_ROOT', getcwd());
  46.  
  47. $compilerConfig = MAGENTO_ROOT . '/includes/config.php';
  48. if (file_exists($compilerConfig)) {
  49.     include $compilerConfig;
  50. }
  51.  
  52. $mageFilename = MAGENTO_ROOT . '/app/Mage.php';
  53. $maintenanceFile = 'maintenance.flag';
  54.  
  55. if (!file_exists($mageFilename)) {
  56.     if (is_dir('downloader')) {
  57.         header("Location: downloader");
  58.     } else {
  59.         echo $mageFilename." was not found";
  60.     }
  61.     exit;
  62. }
  63.  
  64. /*if (file_exists($maintenanceFile)) {
  65.     include_once dirname(__FILE__) . '/errors/503.php';
  66.     exit;
  67. }*/
  68. if (file_exists($maintenanceFile) && $_SERVER['REMOTE_ADDR'] != '80.28.189.81' ) {
  69.     include_once dirname(__FILE__) . '/errors/503.php';
  70.     exit;
  71. }
  72.  
  73. require_once $mageFilename;
  74.  
  75.  
  76. require_once 'app/Mage.php';
  77.  
  78. /* Determine correct language store based on browser */
  79. function getStoreForLanguage()
  80. {
  81.     if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
  82.         foreach (explode(",", strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE'])) as $accept) {
  83.             if (preg_match("!([a-z-]+)(;q=([0-9.]+))?!", trim($accept), $found)) {
  84.                 $langs[] = $found[1];
  85.                 $quality[] = (isset($found[3]) ? (float) $found[3] : 1.0);
  86.             }
  87.         }
  88.         // Order the codes by quality
  89.         array_multisort($quality, SORT_NUMERIC, SORT_DESC, $langs);
  90.         // get list of stores and use the store code for the key
  91.         $stores = Mage::app()->getStores(false, true);
  92.         // iterate through languages found in the accept-language header
  93.         foreach ($langs as $lang) {
  94.             $lang = substr($lang,0,2);
  95.             if (isset($stores[$lang]) && $stores[$lang]->getIsActive()) return $stores[$lang];
  96.         }
  97.     }
  98.     return Mage::app()->getStore();
  99. }
  100.  
  101. /* Auto redirect to language store view if request is for root */
  102. if ($_SERVER['REQUEST_URI'] === '/') {
  103.     header('Location: '.getStoreForLanguage()->getBaseUrl());
  104.     exit;
  105. }
  106.  
  107. if ($_SERVER['REQUEST_URI'] === '/') {
  108.    header('Location: '.checkStoreLanguage()->getBaseUrl());
  109.    exit;
  110. }
  111.  
  112.  
  113. #Varien_Profiler::enable();
  114.  
  115. if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
  116.     Mage::setIsDeveloperMode(true);
  117. }
  118.  
  119. #ini_set('display_errors', 1);
  120.  
  121. umask(0);
  122.  
  123. /* Store or website code */
  124. $mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
  125.  
  126. /* Run store or run website */
  127. $mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
  128.  
  129. switch($_SERVER['HTTP_HOST']) {
  130.     case 'www.vip.kanikas.com':
  131.     case 'vip.kanikas.com':
  132.         $mageRunCode = 'knksvip';
  133.         $mageRunType = 'website';
  134.     break;
  135. }
  136. Mage::run($mageRunCode, $mageRunType);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement