Example #1
0
 /**
  * Method download choosen page by url in argument and retrieves
  * its contents.
  * @param string $url
  * @return string contents of downloaded page
  */
 function downloadPage($url)
 {
     if ($this->isReady()) {
         /* remember Magento state and reset Magento */
         $prevURI = $_SERVER['REQUEST_URI'];
         $state = Mage::getStaticState();
         Mage::reset();
         /* start catching output */
         ob_start();
         /* run new Magento */
         $_SERVER['REQUEST_URI'] = preg_replace('/http(s){0,1}:\\/\\/[^\\/]*/', '', $url);
         Mage::run();
         /* get output */
         $html = ob_get_contents();
         /* end catching output */
         ob_end_clean();
         /* restore Magento state */
         Mage::restoreState($state);
         return $html;
     }
     return '';
 }
Example #2
0
 public static function getCachedPage()
 {
     $key = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
     if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
         $key = 'SECURE_' . $key;
     }
     //get params from config to exclude from url key
     $config = simplexml_load_file('app/etc/local.xml');
     $excludes = array();
     $excludeParams = $config->lightspeed->global->params;
     $excludeArr = explode(",", $excludeParams);
     foreach ($excludeArr as $param) {
         $excludes[] = $param;
     }
     //see if we even need to remove some params
     if (count($excludes)) {
         //if we do, blow it up and remake it
         $keyPart = explode("?", $key);
         if (isset($keyPart[1])) {
             $keyParse = parse_url($key);
             $newParams = explode("&", $keyParse['query']);
             $newString = '?';
             foreach ($newParams as $iteration => $newParam) {
                 $paramArr = explode("=", $newParam);
                 if (!in_array($paramArr[0], $excludes)) {
                     $newString .= $paramArr[0] . "=" . $paramArr[1] . "&";
                 }
                 $key = $keyPart[0] . $newString;
                 $key = rtrim($key, "&");
                 $key = preg_replace('/(\\?|&|&&)debug_front=1/s', '', $key);
             }
         }
     } else {
         $key = preg_replace('/(\\?|&|&&)debug_front=1/s', '', $key);
     }
     if (self::$multiCurrency) {
         self::report("configuration set to use multi_currency");
         $key .= '_' . self::getCurrencyCode();
     }
     self::report("attempting to fetch url: {$key}");
     if ($data = self::get($key)) {
         if (self::messageExists()) {
             self::report("a global message exists, we must not allow a cached page", true);
             return false;
         }
         if (isset($data[1]) && $data[1]) {
             $disqualified = false;
             if ($data[1] == '*') {
                 // auto disqualify when messages exist in the session
                 self::report("disqualified because the disqualifier is *");
                 $disqualified = true;
             } else {
                 self::initConditions();
                 $disqualifiers = explode(",", $data[1]);
                 if ($count = count($disqualifiers)) {
                     for ($i = 0; $i < $count; $i++) {
                         if (in_array($disqualifiers[$i], self::$conditions)) {
                             self::report("disqualified with {$disqualifiers[$i]}");
                             $disqualified = true;
                             break 1;
                         }
                     }
                 }
             }
             if ($disqualified) {
                 // handle dynamic content retrieval here
                 if (isset($data[2]) && $data[2]) {
                     self::report("attempting to retrieve hole punched content from {$data[2]}");
                     $_SERVER['REQUEST_URI'] = self::$request_path . "/" . $data[2];
                     require_once 'app/Mage.php';
                     ob_start();
                     //Single Site
                     if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
                         $_SERVER['HTTPS'] = 'on';
                         $_SERVER['SERVER_PORT'] = 443;
                     }
                     Mage::run();
                     //Multi-site test settings
                     // Add a "case" statement for each new site
                     // switch($_SERVER['HTTP_HOST']) {
                     //   case 'www.site1.com':
                     //     Mage::run('site1', 'website');
                     //     break;
                     //
                     //   case 'www.site2.com':
                     //     Mage::run('site2', 'website');
                     //     break;
                     //
                     //   default:
                     //     Mage::run();
                     //     break;
                     //End Multi-site Config
                     $content = ob_get_clean();
                     self::$holeContent = Zend_Json::decode($content);
                     return self::fillNoCacheHoles($data[0]);
                 } else {
                     self::report("valid disqualifiers without hole punch content... bummer", true);
                     return false;
                 }
             } else {
                 return $data[0];
             }
         } else {
             return $data[0];
         }
     } else {
         self::report("No match found in the cache store", true);
         return false;
     }
 }
Example #3
0
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;
}
/**
 * Error reporting
 */
error_reporting(E_ALL | E_STRICT);
/**
 * Compilation includes configuration file
 */
$compilerConfig = 'includes/config.php';
if (file_exists($compilerConfig)) {
    include $compilerConfig;
}
$mageFilename = 'app/Mage.php';
if (!file_exists($mageFilename)) {
    if (is_dir('downloader')) {
        header("Location: downloader");
    } else {
        echo $mageFilename . " was not found";
    }
    exit;
}
require_once $mageFilename;
#Varien_Profiler::enable();
#Mage::setIsDeveloperMode(true);
#ini_set('display_errors', 1);
umask(0);
Mage::run();
Example #4
0
    include $compilerConfig;
}
//$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
$mageFilename = '../app/Mage.php';
$maintenanceFile = 'maintenance.flag';
if (!file_exists($mageFilename)) {
    if (is_dir('downloader')) {
        header("Location: downloader");
    } else {
        echo $mageFilename . " was not found";
    }
    exit;
}
if (file_exists($maintenanceFile)) {
    include_once dirname(__FILE__) . '/errors/503.php';
    exit;
}
require_once $mageFilename;
#Varien_Profiler::enable();
if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
    Mage::setIsDeveloperMode(true);
}
#ini_set('display_errors', 1);
umask(0);
/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
//Mage::run($mageRunCode, $mageRunType);
Mage::run('inox_1', 'website');
Example #5
0
 /**
  * Run request
  *
  * @return void
  */
 public function dispatch($uri)
 {
     $this->getRequest()->setRequestUri($uri);
     Mage::run($this->_runCode, $this->_runScope, $this->_runOptions);
 }
Example #6
0
if (file_exists($compilerConfig)) {
    include $compilerConfig;
}
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
$maintenanceFile = 'maintenance.flag';
if (!file_exists($mageFilename)) {
    if (is_dir('downloader')) {
        header("Location: downloader");
    } else {
        echo $mageFilename . " was not found";
    }
    exit;
}
if (file_exists($maintenanceFile)) {
    include_once dirname(__FILE__) . '/errors/503.php';
    exit;
}
require MAGENTO_ROOT . '/app/bootstrap.php';
require_once $mageFilename;
#Varien_Profiler::enable();
if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
    Mage::setIsDeveloperMode(true);
}
ini_set('display_errors', 1);
umask(0);
/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : 'default';
/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
Mage::run("default");
Example #7
0
if (file_exists($compilerConfig)) {
    include $compilerConfig;
}
$mageFilename = $root . '/app/Mage.php';
$maintenanceFile = 'maintenance.flag';
if (!file_exists($mageFilename)) {
    if (is_dir('downloader')) {
        header("Location: downloader");
    } else {
        echo $mageFilename . " was not found";
    }
    exit;
}
if (file_exists($maintenanceFile)) {
    include_once dirname(__FILE__) . '/errors/503.php';
    exit;
}
require $root . '/app/bootstrap.php';
require_once $mageFilename;
#Varien_Profiler::enable();
if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
    Mage::setIsDeveloperMode(true);
}
#ini_set('display_errors', 1);
umask(0);
/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
Mage::run('jaipur', 'website');
Example #8
0
$compilerConfig = MAGENTO_ROOT . '/includes/config.php';
if (file_exists($compilerConfig)) {
    include $compilerConfig;
}
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
$maintenanceFile = 'maintenance.flag';
if (!file_exists($mageFilename)) {
    if (is_dir('downloader')) {
        header("Location: downloader");
    } else {
        echo $mageFilename . " was not found";
    }
    exit;
}
if (file_exists($maintenanceFile)) {
    include_once dirname(__FILE__) . '/errors/503.php';
    exit;
}
require_once $mageFilename;
#Varien_Profiler::enable();
if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
    Mage::setIsDeveloperMode(true);
}
#ini_set('display_errors', 1);
umask(0);
/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
Mage::run('en', 'website');
 /**
  * Runs the WebApplication
  *
  * @param \AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest The request instance
  *
  * @return string The web applications content
  */
 public function run(HttpServletRequestInterface $servletRequest)
 {
     try {
         // register the Magento autoloader as FIRST autoloader
         spl_autoload_register(array(new \Varien_Autoload(), 'autoload'), true, true);
         // Varien_Profiler::enable();
         if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
             \Mage::setIsDeveloperMode(true);
         }
         ini_set('display_errors', 1);
         umask(0);
         // store or website code
         $mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
         // run store or run website
         $mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
         // set headers sent to false and start output caching
         appserver_set_headers_sent(false);
         ob_start();
         // reset and run Magento
         \Mage::reset();
         \Mage::register('ServletRequest', $servletRequest);
         \Mage::run();
         // write the session back after the request
         session_write_close();
         // We need to init the session anew, so PHP session handling will work like it would in a clean environment
         appserver_session_init();
         // grab the contents generated by Magento
         $content = ob_get_clean();
     } catch (\Exception $e) {
         error_log($content = $e->__toString());
     }
     // return the content
     return $content;
 }
Example #10
0
$compilerConfig = MAGENTO_ROOT . '/includes/config.php';
if (file_exists($compilerConfig)) {
    include $compilerConfig;
}
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
$maintenanceFile = 'maintenance.flag';
if (!file_exists($mageFilename)) {
    if (is_dir('downloader')) {
        header("Location: downloader");
    } else {
        echo $mageFilename . " was not found";
    }
    exit;
}
if (file_exists($maintenanceFile)) {
    include_once dirname(__FILE__) . '/errors/503.php';
    exit;
}
require_once $mageFilename;
#Varien_Profiler::enable();
if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
    Mage::setIsDeveloperMode(true);
}
#ini_set('display_errors', 1);
umask(0);
/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
Mage::run('cn', 'website');
Example #11
0
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * 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
 * @copyright  Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
require_once 'app/bootstrap.php';
/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
/* Additional local.xml file from environment variable */
$options = array();
if (!empty($_SERVER['MAGE_LOCAL_CONFIG'])) {
    $options['local_config'] = $_SERVER['MAGE_LOCAL_CONFIG'];
}
Mage::run($mageRunCode, $mageRunType, $options);
Example #12
0
<?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());
Example #13
0
if (file_exists($compilerConfig)) {
    include $compilerConfig;
}
$mageFilename = $root . '/app/Mage.php';
$maintenanceFile = 'maintenance.flag';
if (!file_exists($mageFilename)) {
    if (is_dir('downloader')) {
        header("Location: downloader");
    } else {
        echo $mageFilename . " was not found";
    }
    exit;
}
if (file_exists($maintenanceFile)) {
    include_once dirname(__FILE__) . '/errors/503.php';
    exit;
}
require $root . '/app/bootstrap.php';
require_once $mageFilename;
#Varien_Profiler::enable();
if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
    Mage::setIsDeveloperMode(true);
}
#ini_set('display_errors', 1);
umask(0);
/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
Mage::run('delhi', 'website');
 /**
  * Runs the WebApplication
  *
  * @param \AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest The request instance
  *
  * @return string The web applications content
  */
 public function run(HttpServletRequestInterface $servletRequest)
 {
     try {
         // register the Magento autoloader as FIRST autoloader
         spl_autoload_register(array(new \Varien_Autoload(), 'autoload'), true, true);
         // Varien_Profiler::enable();
         if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
             \Mage::setIsDeveloperMode(true);
         }
         ini_set('display_errors', 1);
         umask(0);
         // store or website code
         $mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
         // run store or run website
         $mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
         // set headers sent to false and start output caching
         appserver_set_headers_sent(false);
         ob_start();
         // reset and run Magento
         \Mage::reset();
         \Mage::register(MageStandardSessionServlet::SERVLET_REQUEST, $servletRequest);
         \Mage::run();
         /*
         // load the session and persist the data from $_SESSION
         $session = $servletRequest->getSession();
         
         foreach ($_SESSION as $namespace => $data) {
             if ($namespace !== 'identifier') {
                 error_log("Now add data for session {$session->getId()} and namespace: ". PHP_EOL . var_export($dat));
                 $session->putData($namespace, $data);
             }
         }
         */
         // grab the contents generated by Magento
         $content = ob_get_clean();
     } catch (\Exception $e) {
         error_log($content = $e->__toString());
     }
     // return the content
     return $content;
 }
Example #15
0
    } else {
        echo $mageFilename." was not found";
    }
    exit;
}

if (file_exists($maintenanceFile)) {
    include_once MAGENTO_ROOT . '/errors/503.php';
    exit;
}

require_once $mageFilename;

#Varien_Profiler::enable();

if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
    Mage::setIsDeveloperMode(true);
}

#ini_set('display_errors', 1);

umask(0);

/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';

/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';

Mage::run('wholesale', 'website');
// Mage::run($mageRunCode, $mageRunType);
Example #16
0
/**
 * Application entry point
 *
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * 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
 * @copyright  Copyright (c) 2013 X.commerce, Inc. (http://www.magentocommerce.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
require_once __DIR__ . '/app/bootstrap.php';
$appOptions = new Mage_Core_Model_App_Options($_SERVER);
Mage::run($appOptions->getRunCode(), $appOptions->getRunType(), $appOptions->getRunOptions());
Example #17
0
    include $compilerConfig;
}
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
$maintenanceFile = 'maintenance.flag';
if (!file_exists($mageFilename)) {
    if (is_dir('downloader')) {
        header("Location: downloader");
    } else {
        echo $mageFilename . " was not found";
    }
    exit;
}
if (file_exists($maintenanceFile)) {
    include_once dirname(__FILE__) . '/errors/503.php';
    exit;
}
require MAGENTO_ROOT . '/app/bootstrap.php';
require_once $mageFilename;
#Varien_Profiler::enable();
if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
    Mage::setIsDeveloperMode(true);
}
#Mage::setIsDeveloperMode(true);
#ini_set('display_errors', 1);
umask(0);
/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
Mage::run($mageRunCode, $mageRunType);
Example #18
0
<?php

/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * 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.
 *
 * @category   Mage
 * @package    Mage
 * @copyright  Copyright (c) 2004-2007 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
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 'app/Mage.php';
umask(0);
Mage::run('default');