From a8cc544c7b33e82f1beb27e6ab67dcc5023e428d Mon Sep 17 00:00:00 2001 From: IndiesWebs Date: Tue, 8 Oct 2013 21:55:56 -0700 Subject: [PATCH 1/5] --- LinkedIn.php | 53 +++++++++++++ cron.php | 49 ++++++++++++ cron.sh | 23 ++++++ get.php | 208 +++++++++++++++++++++++++++++++++++++++++++++++++++ info.php | 13 ++++ mage | 54 +++++++++++++ 6 files changed, 400 insertions(+) create mode 100644 LinkedIn.php create mode 100644 cron.php create mode 100644 cron.sh create mode 100644 get.php create mode 100644 info.php create mode 100644 mage diff --git a/LinkedIn.php b/LinkedIn.php new file mode 100644 index 00000000..1d6b3967 --- /dev/null +++ b/LinkedIn.php @@ -0,0 +1,53 @@ + + + + +LinkedIn JavaScript API Hello World + + + + + + + + + + + + + + +
+ + + diff --git a/cron.php b/cron.php new file mode 100644 index 00000000..d555fca1 --- /dev/null +++ b/cron.php @@ -0,0 +1,49 @@ +setUseSessionInUrl(false); + +umask(0); + +try { + Mage::getConfig()->init()->loadEventObservers('crontab'); + Mage::app()->addEventArea('crontab'); + Mage::dispatchEvent('default'); +} catch (Exception $e) { + Mage::printException($e); +} diff --git a/cron.sh b/cron.sh new file mode 100644 index 00000000..279e5510 --- /dev/null +++ b/cron.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# location of the php binary +if [ ! "$1" = "" ] ; then +CRONSCRIPT=$1 +else +CRONSCRIPT=cron.php +fi + +PHP_BIN=`which php` + +# absolute path to magento installation +INSTALLDIR=`echo $0 | sed 's/cron\.sh//g'` + +# prepend the intallation path if not given an absolute path +if [ "$INSTALLDIR" != "" -a "`expr index $CRONSCRIPT /`" != "1" ];then + if ! ps auxwww | grep "$INSTALLDIR""$CRONSCRIPT" | grep -v grep 1>/dev/null 2>/dev/null ; then + $PHP_BIN "$INSTALLDIR""$CRONSCRIPT" & + fi +else + if ! ps auxwww | grep " $CRONSCRIPT" | grep -v grep | grep -v cron.sh 1>/dev/null 2>/dev/null ; then + $PHP_BIN $CRONSCRIPT & + fi +fi diff --git a/get.php b/get.php new file mode 100644 index 00000000..a7fe8020 --- /dev/null +++ b/get.php @@ -0,0 +1,208 @@ +

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; + } +} diff --git a/info.php b/info.php new file mode 100644 index 00000000..0895ea61 --- /dev/null +++ b/info.php @@ -0,0 +1,13 @@ + + + + +Untitled Document + + + + + + \ No newline at end of file diff --git a/mage b/mage new file mode 100644 index 00000000..70a303a0 --- /dev/null +++ b/mage @@ -0,0 +1,54 @@ +#!/bin/sh + +# REPLACE with your PHP5 binary path (example: /usr/local/php5/bin/php ) +#MAGE_PHP_BIN="php" + +MAGE_PHP_SCRIPT="mage.php" +DOWNLOADER_PATH='downloader' + +# initial setup +if test "x$1" = "xmage-setup"; then + echo 'Running initial setup...' + + if test "x$2" != "x"; then + MAGE_ROOT_DIR="$2" + else + MAGE_ROOT_DIR="`pwd`" + fi + + $0 config-set magento_root "$MAGE_ROOT_DIR" + $0 config-set preferred_state beta + $0 channel-add http://connect20.magentocommerce.com/community + exit +fi + +# check that mage pear was initialized + +if test "x$1" != "xconfig-set" && + test "x$1" != "xconfig-get" && + test "x$1" != "xconfig-show" && + test "x$1" != "xchannel-add" && + test "x`$0 config-get magento_root`" = "x"; then + echo 'Please initialize Magento Connect installer by running:' + echo "$0 mage-setup" + exit; +fi + +# find which PHP binary to use +if test "x$MAGE_PHP_BIN" != "x"; then + PHP="$MAGE_PHP_BIN" +else + PHP=php +fi + + +# get default pear dir of not set +if test "x$MAGE_ROOT_DIR" = "x"; then + MAGE_ROOT_DIR="`pwd`/$DOWNLOADER_PATH" +fi + +exec $PHP -C -q $INCARG -d output_buffering=1 -d variables_order=EGPCS \ + -d open_basedir="" -d safe_mode=0 -d register_argc_argv="On" \ + -d auto_prepend_file="" -d auto_append_file="" \ + $MAGE_ROOT_DIR/$MAGE_PHP_SCRIPT "$@" + From bc397967c125d5cfc84924559c30cc79d8de302a Mon Sep 17 00:00:00 2001 From: IndiesWebs Date: Wed, 9 Oct 2013 02:44:46 -0700 Subject: [PATCH 2/5] test --- LinkedIn.php | 53 ------------- cron.php | 49 ------------ cron.sh | 23 ------ get.php | 208 --------------------------------------------------- info.php | 13 ---- mage | 54 ------------- 6 files changed, 400 deletions(-) delete mode 100644 LinkedIn.php delete mode 100644 cron.php delete mode 100644 cron.sh delete mode 100644 get.php delete mode 100644 info.php delete mode 100644 mage diff --git a/LinkedIn.php b/LinkedIn.php deleted file mode 100644 index 1d6b3967..00000000 --- a/LinkedIn.php +++ /dev/null @@ -1,53 +0,0 @@ - - - - -LinkedIn JavaScript API Hello World - - - - - - - - - - - - - - -
- - - diff --git a/cron.php b/cron.php deleted file mode 100644 index d555fca1..00000000 --- a/cron.php +++ /dev/null @@ -1,49 +0,0 @@ -setUseSessionInUrl(false); - -umask(0); - -try { - Mage::getConfig()->init()->loadEventObservers('crontab'); - Mage::app()->addEventArea('crontab'); - Mage::dispatchEvent('default'); -} catch (Exception $e) { - Mage::printException($e); -} diff --git a/cron.sh b/cron.sh deleted file mode 100644 index 279e5510..00000000 --- a/cron.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -# location of the php binary -if [ ! "$1" = "" ] ; then -CRONSCRIPT=$1 -else -CRONSCRIPT=cron.php -fi - -PHP_BIN=`which php` - -# absolute path to magento installation -INSTALLDIR=`echo $0 | sed 's/cron\.sh//g'` - -# prepend the intallation path if not given an absolute path -if [ "$INSTALLDIR" != "" -a "`expr index $CRONSCRIPT /`" != "1" ];then - if ! ps auxwww | grep "$INSTALLDIR""$CRONSCRIPT" | grep -v grep 1>/dev/null 2>/dev/null ; then - $PHP_BIN "$INSTALLDIR""$CRONSCRIPT" & - fi -else - if ! ps auxwww | grep " $CRONSCRIPT" | grep -v grep | grep -v cron.sh 1>/dev/null 2>/dev/null ; then - $PHP_BIN $CRONSCRIPT & - fi -fi diff --git a/get.php b/get.php deleted file mode 100644 index a7fe8020..00000000 --- a/get.php +++ /dev/null @@ -1,208 +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; - } -} diff --git a/info.php b/info.php deleted file mode 100644 index 0895ea61..00000000 --- a/info.php +++ /dev/null @@ -1,13 +0,0 @@ - - - - -Untitled Document - - - - - - \ No newline at end of file diff --git a/mage b/mage deleted file mode 100644 index 70a303a0..00000000 --- a/mage +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh - -# REPLACE with your PHP5 binary path (example: /usr/local/php5/bin/php ) -#MAGE_PHP_BIN="php" - -MAGE_PHP_SCRIPT="mage.php" -DOWNLOADER_PATH='downloader' - -# initial setup -if test "x$1" = "xmage-setup"; then - echo 'Running initial setup...' - - if test "x$2" != "x"; then - MAGE_ROOT_DIR="$2" - else - MAGE_ROOT_DIR="`pwd`" - fi - - $0 config-set magento_root "$MAGE_ROOT_DIR" - $0 config-set preferred_state beta - $0 channel-add http://connect20.magentocommerce.com/community - exit -fi - -# check that mage pear was initialized - -if test "x$1" != "xconfig-set" && - test "x$1" != "xconfig-get" && - test "x$1" != "xconfig-show" && - test "x$1" != "xchannel-add" && - test "x`$0 config-get magento_root`" = "x"; then - echo 'Please initialize Magento Connect installer by running:' - echo "$0 mage-setup" - exit; -fi - -# find which PHP binary to use -if test "x$MAGE_PHP_BIN" != "x"; then - PHP="$MAGE_PHP_BIN" -else - PHP=php -fi - - -# get default pear dir of not set -if test "x$MAGE_ROOT_DIR" = "x"; then - MAGE_ROOT_DIR="`pwd`/$DOWNLOADER_PATH" -fi - -exec $PHP -C -q $INCARG -d output_buffering=1 -d variables_order=EGPCS \ - -d open_basedir="" -d safe_mode=0 -d register_argc_argv="On" \ - -d auto_prepend_file="" -d auto_append_file="" \ - $MAGE_ROOT_DIR/$MAGE_PHP_SCRIPT "$@" - From 909832b10f68bd1df3836edab8be08610e3e81cc Mon Sep 17 00:00:00 2001 From: IndiesWebs Date: Wed, 9 Oct 2013 02:46:38 -0700 Subject: [PATCH 3/5] testing For Merge --- cron.php | 49 +++++++++++++ cron.sh | 23 ++++++ get.php | 208 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ index.php | 88 +++++++++++++++++++++++ 4 files changed, 368 insertions(+) create mode 100644 cron.php create mode 100644 cron.sh create mode 100644 get.php create mode 100644 index.php diff --git a/cron.php b/cron.php new file mode 100644 index 00000000..d555fca1 --- /dev/null +++ b/cron.php @@ -0,0 +1,49 @@ +setUseSessionInUrl(false); + +umask(0); + +try { + Mage::getConfig()->init()->loadEventObservers('crontab'); + Mage::app()->addEventArea('crontab'); + Mage::dispatchEvent('default'); +} catch (Exception $e) { + Mage::printException($e); +} diff --git a/cron.sh b/cron.sh new file mode 100644 index 00000000..279e5510 --- /dev/null +++ b/cron.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# location of the php binary +if [ ! "$1" = "" ] ; then +CRONSCRIPT=$1 +else +CRONSCRIPT=cron.php +fi + +PHP_BIN=`which php` + +# absolute path to magento installation +INSTALLDIR=`echo $0 | sed 's/cron\.sh//g'` + +# prepend the intallation path if not given an absolute path +if [ "$INSTALLDIR" != "" -a "`expr index $CRONSCRIPT /`" != "1" ];then + if ! ps auxwww | grep "$INSTALLDIR""$CRONSCRIPT" | grep -v grep 1>/dev/null 2>/dev/null ; then + $PHP_BIN "$INSTALLDIR""$CRONSCRIPT" & + fi +else + if ! ps auxwww | grep " $CRONSCRIPT" | grep -v grep | grep -v cron.sh 1>/dev/null 2>/dev/null ; then + $PHP_BIN $CRONSCRIPT & + fi +fi diff --git a/get.php b/get.php new file mode 100644 index 00000000..a7fe8020 --- /dev/null +++ b/get.php @@ -0,0 +1,208 @@ +

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; + } +} diff --git a/index.php b/index.php new file mode 100644 index 00000000..fdf75b3b --- /dev/null +++ b/index.php @@ -0,0 +1,88 @@ + +
+

+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; +} + +/** + * Error reporting + */ +error_reporting(E_ALL | E_STRICT); + +/** + * Compilation includes configuration file + */ +define('MAGENTO_ROOT', getcwd()); + +$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); +ini_set('display_errors', 1); +ini_set('memory_limit', '256M'); +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); From ec48907d188c1072e003b707619c6e8a2b096fd3 Mon Sep 17 00:00:00 2001 From: IndiesWebs Date: Wed, 9 Oct 2013 03:27:03 -0700 Subject: [PATCH 4/5] --- get.php | 416 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 208 insertions(+), 208 deletions(-) diff --git a/get.php b/get.php index a7fe8020..75831888 100644 --- a/get.php +++ b/get.php @@ -1,208 +1,208 @@ -

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; - } -} +

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; + } +} From d530f253f6a7e4b1af046610790e3418313f8cab Mon Sep 17 00:00:00 2001 From: IndiesWebs Date: Wed, 9 Oct 2013 03:49:42 -0700 Subject: [PATCH 5/5] --- get.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get.php b/get.php index 75831888..5bf7fe86 100644 --- a/get.php +++ b/get.php @@ -24,7 +24,7 @@ * @copyright Copyright (c) 2008 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) { +if (version_compare(phpversion(), '5.3322.0', '<')===true) { echo '

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