<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* 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.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* 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@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
set_time_limit(0);
define('_PS_INSTALL_MINIMUM_PHP_VERSION_ID_', 70103);
define('_PS_INSTALL_MINIMUM_PHP_VERSION_', '7.1.3');
define('_PS_VERSION_', '1.7.7.3');
define('ZIP_NAME', 'prestashop.zip');
define('TARGET_FOLDER', __DIR__ . '/');
define('BATCH_SIZE', 500);
// bust cache, or else it won't load the installer after the extraction is done
header('Cache-Control: no-cache, no-store, must-revalidate');
if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < _PS_INSTALL_MINIMUM_PHP_VERSION_ID_) {
die('You need at least PHP ' . _PS_INSTALL_MINIMUM_PHP_VERSION_ . ' to install PrestaShop. Your current PHP version is ' . PHP_VERSION);
}
// --------------------------------------------------------------------------------
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* 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.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* 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@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
/**
* Very basic file cache.
*/
class BasicFileCache
{
/**
* @param string $filename
*
* @return string
*/
public function get($filename)
{
if (false === $this->isCached($filename)) {
throw new \Exception(sprintf('No cache entry for %s', $filename));
}
$filepath = $this->computeCacheFilepath($filename);
return file_get_contents($filepath);
}
/**
* @param string $filename
*
* @return bool
*/
public function isCached($filename)
{
$filepath = $this->computeCacheFilepath($filename);
return is_file($filepath) && is_readable($filepath);
}
/**
* @param string $data
* @param string $filename
*
* @return bool
*
* @throws Exception
*/
public function save($data, $filename)
{
$filepath = $this->computeCacheFilepath($filename);
if (is_file($filepath)) {
throw new \Exception(sprintf('Could not cache file %s', $filepath));
}
return (bool) file_put_contents($filepath, $data);
}
/**
* @param string $filename
*
* @return bool
*/
public function delete($filename)
{
$filepath = $this->computeCacheFilepath($filename);
return unlink($filepath);
}
/**
* @param string $filename
*
* @return string
*/
private function computeCacheFilepath($filename)
{
return __DIR__ . DIRECTORY_SEPARATOR . $filename . '.cache';
}
}
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* 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.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* 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@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/
/**
* In charge of downloading the latest Prestashop Version.
*
* Most methods are copied from https://github.com/PrestaShop/autoupgrade/blob/master/classes/TaskRunner/Upgrade/Download.php
* and https://github.com/PrestaShop/autoupgrade/blob/master/classes/Tools14.php
*/
class Download
{
const PRESTASHOP_API_RELEASES_XML_FEED = 'https://api.prestashop.com/xml/channel.xml';
const CACHED_FEED_FILENAME = 'XMLFeed';
/**
* @var BasicFileCache
*/
private $cachingSystem;
/**
* @param BasicFileCache $cachingSystem optional FileCache
*/
public function __construct(BasicFileCache $cachingSystem = null)
{
if (null === $cachingSystem) {
$cachingSystem = new BasicFileCache();
}
$this->cachingSystem = $cachingSystem;
}
/**
* @param string $source
* @param string $destination
*
* @return bool|int
*/
public static function copy($source, $destination)
{
return @file_put_contents($destination, self::fileGetContents($source));
}
/**
* @param string $url
*
* @return bool|mixed|string
*/
public static function fileGetContents($url)
{
$curl_timeout = 60;
if (!extension_loaded('openssl') && strpos($url, 'https://') === true) {
$url = str_replace('https', 'http', $url);
}
$stream_context = null;
if (preg_match('/^https?:\/\//', $url)) {
$stream_context = @stream_context_create([
'http' => ['timeout' => $curl_timeout, 'header' => "User-Agent:MyAgent/1.0\r\n"],
]);
}
if (in_array(ini_get('allow_url_fopen'), ['On', 'on', '1']) || !preg_match('/^https?:\/\//', $url)) {
$var = @file_get_contents($url, false, $stream_context);
if ($var) {
return $var;
}
} elseif (function_exists('curl_init')) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($curl, CURLOPT_TIMEOUT, $curl_timeout);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
$opts = stream_context_get_options($stream_context);
if (isset($opts['http']['method']) && strtolower($opts['http']['method']) == 'post') {
curl_setopt($curl, CURLOPT_POST, true);