From 88d4c01866fc12dc4c85421c67dcd47d440e8a83 Mon Sep 17 00:00:00 2001 From: David Windell Date: Wed, 17 Jun 2015 11:30:19 +0100 Subject: [PATCH] Delete get.php.orig --- get.php.orig | 207 --------------------------------------------------- 1 file changed, 207 deletions(-) delete mode 100644 get.php.orig diff --git a/get.php.orig b/get.php.orig deleted file mode 100644 index 285df1993a7..00000000000 --- a/get.php.orig +++ /dev/null @@ -1,207 +0,0 @@ -

Whoops, it looks like you have an invalid PHP version.' - . '

Magento supports PHP 5.2.0 or newer. Find out how to install Magento using PHP-CGI as a work-around.

'; - exit; -} -$start = microtime(true); -/** - * Error reporting - */ -error_reporting(E_ALL | E_STRICT); -ini_set('display_errors', 1); - -$ds = DIRECTORY_SEPARATOR; -$ps = PATH_SEPARATOR; -$bp = dirname(__FILE__); - -/** - * Set include path - */ - -$paths[] = $bp . $ds . 'app' . $ds . 'code' . $ds . 'local'; -$paths[] = $bp . $ds . 'app' . $ds . 'code' . $ds . 'community'; -$paths[] = $bp . $ds . 'app' . $ds . 'code' . $ds . 'core'; -$paths[] = $bp . $ds . 'lib'; - -$appPath = implode($ps, $paths); -set_include_path($appPath . $ps . get_include_path()); - -include_once 'Mage/Core/functions.php'; -include_once 'Varien/Autoload.php'; - -Varien_Autoload::register(); - -$varDirectory = $bp . $ds . Mage_Core_Model_Config_Options::VAR_DIRECTORY; - -$configCacheFile = $varDirectory . $ds . 'resource_config.json'; - -$mediaDirectory = null; -$allowedResources = array(); - -if (file_exists($configCacheFile) && is_readable($configCacheFile)) { - $config = json_decode(file_get_contents($configCacheFile), true); - - //checking update time - if (filemtime($configCacheFile) + $config['update_time'] > time()) { - $mediaDirectory = trim(str_replace($bp . $ds, '', $config['media_directory']), $ds); - $allowedResources = array_merge($allowedResources, $config['allowed_resources']); - } -} - -$request = new Zend_Controller_Request_Http(); - -$pathInfo = str_replace('..', '', ltrim($request->getPathInfo(), '/')); - -$filePath = str_replace('/', $ds, rtrim($bp, $ds) . $ds . $pathInfo); - -if ($mediaDirectory) { - if (0 !== stripos($pathInfo, $mediaDirectory . '/') || is_dir($filePath)) { - sendNotFoundPage(); - } - - $relativeFilename = str_replace($mediaDirectory . '/', '', $pathInfo); - checkResource($relativeFilename, $allowedResources); - sendFile($filePath); -} - -$mageFilename = 'app/Mage.php'; - -if (!file_exists($mageFilename)) { - echo $mageFilename . ' was not found'; -} - -require_once $mageFilename; - -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'; - -if (empty($mediaDirectory)) { - Mage::init($mageRunCode, $mageRunType); -} else { - Mage::init( - $mageRunCode, - $mageRunType, - array('cache' => array('disallow_save' => true)), - array('Mage_Core') - ); -} - -if (!$mediaDirectory) { - $config = Mage_Core_Model_File_Storage::getScriptConfig(); - $mediaDirectory = str_replace($bp . $ds, '', $config['media_directory']); - $allowedResources = array_merge($allowedResources, $config['allowed_resources']); - - $relativeFilename = str_replace($mediaDirectory . '/', '', $pathInfo); - - $fp = fopen($configCacheFile, 'w'); - if (flock($fp, LOCK_EX | LOCK_NB)) { - ftruncate($fp, 0); - fwrite($fp, json_encode($config)); - } - flock($fp, LOCK_UN); - fclose($fp); - - checkResource($relativeFilename, $allowedResources); -} - -if (0 !== stripos($pathInfo, $mediaDirectory . '/')) { - sendNotFoundPage(); -} - -try { - $databaseFileSotrage = Mage::getModel('core/file_storage_database'); - $databaseFileSotrage->loadByFilename($relativeFilename); -} catch (Exception $e) { -} -if ($databaseFileSotrage->getId()) { - $directory = dirname($filePath); - if (!is_dir($directory)) { - mkdir($directory, 0777, true); - } - - $fp = fopen($filePath, 'w'); - if (flock($fp, LOCK_EX | LOCK_NB)) { - ftruncate($fp, 0); - fwrite($fp, $databaseFileSotrage->getContent()); - } - flock($fp, LOCK_UN); - fclose($fp); -} - -sendFile($filePath); -sendNotFoundPage(); - -/** - * Send 404 - */ -function sendNotFoundPage() -{ - header('HTTP/1.0 404 Not Found'); - exit; -} - -/** - * Check resource by whitelist - * - * @param string $resource - * @param array $allowedResources - */ -function checkResource($resource, array $allowedResources) -{ - $isResourceAllowed = false; - foreach ($allowedResources as $allowedResource) { - if (0 === stripos($resource, $allowedResource)) { - $isResourceAllowed = true; - } - } - - if (!$isResourceAllowed) { - sendNotFoundPage(); - } -} -/** - * Send file to browser - * - * @param string $file - */ -function sendFile($file) -{ - if (file_exists($file) || is_readable($file)) { - $transfer = new Varien_File_Transfer_Adapter_Http(); - $transfer->send($file); - exit; - } -}