[+] Install: new installer reworked from scratch

This commit is contained in:
rMalie committed 2011-11-10 17:32:47 +00:00
1 parent a2c3001445
commit 122b163553
867 files changed
+39069

No files matched your search

+89
View File
@@ -0,0 +1,89 @@
<?php
/*
* 2007-2011 PrestaShop
*
* 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@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 http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date dans le passé
if (!class_exists('ConfigurationTest',false))
require_once(INSTALL_PATH.'/../classes/ConfigurationTest.php');
// Functions list to test with 'test_system'
$funcs = array('fopen', 'fclose', 'fread', 'fwrite', 'rename', 'file_exists', 'unlink', 'rmdir', 'mkdir', 'getcwd', 'chdir', 'chmod');
// Test list to execute (function/args)
$tests = array(
'phpversion' => false,
'upload' => false,
'system' => $funcs,
'gd' => false,
'mysql_support' => false,
'config_dir' => 'config',
'cache_dir' => 'cache',
'sitemap' => 'sitemap.xml',
'log_dir' => 'log',
'img_dir' => 'img',
'mails_dir' => 'mails/',
'module_dir' => 'modules/',
'theme_lang_dir' => 'themes/prestashop/lang',
'theme_cache_dir' => 'themes/prestashop/cache',
'translations_dir' => 'translations',
'customizable_products_dir' => 'upload',
'virtual_products_dir' => 'download',
);
$tests_op = array(
'fopen' => false,
'register_globals' => false,
'gz' => false,
'mcrypt' => false,
'magicquotes' => false,
'dom' => false,
);
// Execute tests
$res = ConfigurationTest::check($tests);
$res_op = ConfigurationTest::check($tests_op);
$has_error = false;
// Building XML Tree...
echo '<config>'."\n";
echo '<firsttime value="'.((isset($_GET['firsttime']) AND $_GET['firsttime'] == 1) ? 1 : 0).'" />'."\n";
echo '<testList id="required">'."\n";
foreach ($res AS $key => $line)
{
if ($line == 'fail') $has_error = true;
echo '<test id="'.$key.'" result="'.$line.'"/>'."\n";
}
echo '</testList>'."\n";
echo '<testList id="optional">'."\n";
foreach ($res_op AS $key => $line)
{
if ($line == 'fail') $has_error = true;
echo '<test id="'.$key.'" result="'.$line.'"/>'."\n";
}
echo '</testList>'."\n";
echo '</config>';
+29
View File
@@ -0,0 +1,29 @@
<?php
/*
* 2007-2011 PrestaShop
*
* 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@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 http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include_once(INSTALL_PATH.'/classes/ToolsInstall.php');
$resultDB = ToolsInstall::checkDB($_GET['server'], $_GET['login'], $_GET['password'], $_GET['name'], true, $_GET['engine']);
die("<action result='".($resultDB === true ? "ok" : "fail")."' error='".($resultDB === true ? "" : $resultDB)."'/>\n");
+44
View File
@@ -0,0 +1,44 @@
<?php
/*
* 2007-2011 PrestaShop
*
* 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@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 http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include_once(INSTALL_PATH.'/classes/ToolsInstall.php');
$smtpChecked = (trim($_GET['mailMethod']) == 'smtp');
$smtpServer = $_GET['smtpSrv'];
$content = $_GET['testMsg'];
$subject = $_GET['testSubject'];
$type = 'text/html';
$to = $_GET['testEmail'];
$from = 'no-reply@'.ToolsInstall::getHttpHost(false, true, true);
$smtpLogin = $_GET['smtpLogin'];
$smtpPassword = $_GET['smtpPassword'];
$smtpPort = $_GET['smtpPort'];
$smtpEncryption = $_GET['smtpEnc'];
$result = ToolsInstall::sendMail($smtpChecked, $smtpServer, $content, $subject, $type, $to, $from, $smtpLogin, $smtpPassword, $smtpPort, $smtpEncryption);
die($result ? '<action result="ok"/>' : '<action result="fail"/>');
+294
View File
@@ -0,0 +1,294 @@
<?php
/*
* 2007-2011 PrestaShop
*
* 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@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 http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
if (function_exists('date_default_timezone_set'))
date_default_timezone_set('Europe/Paris');
define('_PS_MAGIC_QUOTES_GPC_', get_magic_quotes_gpc());
require_once(INSTALL_PATH.'/classes/AddConfToFile.php');
require_once(INSTALL_PATH.'/../classes/Validate.php');
require_once(INSTALL_PATH.'/../classes/db/Db.php');
require_once(INSTALL_PATH.'/../classes/Tools.php');
require_once(INSTALL_PATH.'/../config/settings.inc.php');
Context::getContext()->shop = Shop::initialize();
define('_THEME_NAME_', Context::getContext()->shop->getTheme());
define('__PS_BASE_URI__', Context::getContext()->shop->getBaseURI());
function isFormValid()
{
global $error;
foreach ($error as $anError)
if ($anError != '')
return false;
return true;
}
$error = array();
foreach ($_GET AS &$var)
{
if (is_string($var))
$var = html_entity_decode($var, ENT_COMPAT, 'UTF-8');
elseif (is_array($var))
foreach ($var AS &$row)
$row = html_entity_decode($row, ENT_COMPAT, 'UTF-8');
}
if(!isset($_GET['infosShop']) OR empty($_GET['infosShop']))
$error['infosShop'] = '0';
else
$error['infosShop'] = '';
if(!isset($_GET['infosFirstname']) OR empty($_GET['infosFirstname']))
$error['infosFirstname'] = '0';
else
$error['infosFirstname'] = '';
if(!isset($_GET['infosName']) OR empty($_GET['infosName']))
$error['infosName'] = '0';
else
$error['infosName'] = '';
if(isset($_GET['infosEmail']) AND !Validate::isEmail($_GET['infosEmail']))
$error['infosEmail'] = '3';
else
$error['infosEmail'] = '';
if (isset($_GET['infosShop']) AND !Validate::isGenericName($_GET['infosShop']))
$error['validateShop'] = '46';
else
$error['validateShop'] = '';
if (!isset($_GET['infosCountry']) OR empty($_GET['infosCountry']))
$error['infosCountry'] = '0';
else
$error['infosCountry'] = '';
if (!isset($_GET['infosTimezone']) OR empty($_GET['infosTimezone']))
$error['infosTimezone'] = '0';
else
$error['infosTimezone'] = '';
if (isset($_GET['infosFirstname']) AND !Validate::isName($_GET['infosFirstname']))
$error['validateFirstname'] = '47';
else
$error['validateFirstname'] = '';
if (isset($_GET['infosName']) AND !Validate::isName($_GET['infosName']))
$error['validateName'] = '48';
else
$error['validateName'] = '';
if (isset($_GET['catalogMode']) AND !Validate::isInt($_GET['catalogMode']))
$error['validateCatalogMode'] = '52';
else
$error['validateCatalogMode'] = '';
if(!isset($_GET['infosEmail']) OR empty($_GET['infosEmail']))
$error['infosEmail'] = '0';
if (!isset($_GET['infosPassword']) OR empty($_GET['infosPassword']))
$error['infosPassword'] = '0';
else
$error['infosPassword'] = '';
if (!isset($_GET['infosPasswordRepeat']) OR empty($_GET['infosPasswordRepeat']))
$error['infosPasswordRepeat'] = '0';
else
$error['infosPasswordRepeat'] = '';
if($error['infosPassword'] == '' AND $_GET['infosPassword'] != $_GET['infosPasswordRepeat'])
$error['infosPassword'] = '2';
if($error['infosPassword'] == '' AND (Tools::strlen($_GET['infosPassword']) < 8 OR !Validate::isPasswdAdmin($_GET['infosPassword'])))
$error['infosPassword'] = '12';
/////////////////////////////
// IF ALL IS OK DO THE NEXT//
/////////////////////////////
include_once(INSTALL_PATH.'/classes/ToolsInstall.php');
$dbInstance = Db::getInstance();
// set Languages
$error['infosLanguages'] = '';
if(isFormValid())
{
/*$idDefault = array_search($_GET['infosDL'][0], $_GET['infosWL']) + 1;
//prepare the requests
$sqlLanguages = array();
$sqlLanguages[] = "UPDATE `"._DB_PREFIX_."configuration` SET `value` = '".$idDefault."' WHERE `"._DB_PREFIX_."configuration`.`id_configuration` =1";
$sqlLanguages[] = "TRUNCATE TABLE `"._DB_PREFIX_."lang`";
foreach ($_GET['infosWL'] AS $wl)
$sqlLanguages[] = "INSERT INTO `"._DB_PREFIX_."lang` (`id_lang` ,`name` ,`active` ,`iso_code`)VALUES (NULL , '".ToolsInstall::getLangString($wl)."', '1', '".pSQL($wl)."')";
foreach($sqlLanguages AS $query)
if(!Db::getInstance()->execute($query))
$error['infosLanguages'] = '11';
// Flags copy
if(!$languagesId = Db::getInstance()->executeS('SELECT `id_lang`, `iso_code` FROM `'._DB_PREFIX_.'lang`'))
$error['infosLanguages'] = '11';
unset($dbInstance);*/
}
// Mail Notification
$error['infosNotification'] = '';
if (isFormValid())
{
if (isset($_GET['infosNotification']) AND $_GET['infosNotification'] == 'on') {
include_once(INSTALL_PATH.'/classes/ToolsInstall.php');
$smtpChecked = (trim($_GET['infosMailMethod']) == 'smtp');
$smtpServer = $_GET['smtpSrv'];
$subject = $_GET['infosShop']." - " . $_GET['mailSubject'];
$type = 'text/html';
$to = $_GET['infosEmail'];
$from = "no-reply@".ToolsInstall::getHttpHost(false, true, true);
$smtpLogin = $_GET['smtpLogin'];
$smtpPassword = $_GET['smtpPassword'];
$smtpPort = $_GET['smtpPort'];//'default','secure'
$smtpEncryption = $_GET['smtpEnc'];//"tls","ssl","off"
$content = ToolsInstall::getNotificationMail($_GET['infosShop'], INSTALLER__PS_BASE_URI_ABSOLUTE, INSTALLER__PS_BASE_URI_ABSOLUTE."img/logo.jpg", ToolsInstall::strtoupper($_GET['infosFirstname']), $_GET['infosName'], $_GET['infosPassword'], $_GET['infosEmail']);
$result = @ToolsInstall::sendMail($smtpChecked, $smtpServer, $content, $subject, $type, $to, $from, $smtpLogin, $smtpPassword, $smtpPort, $smtpEncryption);
}
}
//Insert configuration parameters into the database
$error['infosInsertSQL'] = '';
if (isFormValid())
{
$sqlParams = array();
$sqlParams[] = "INSERT IGNORE INTO "._DB_PREFIX_."configuration (name, value, date_add, date_upd) VALUES ('PS_SHOP_DOMAIN', '".Tools::getHttpHost()."', NOW(), NOW())";
$sqlParams[] = "INSERT IGNORE INTO "._DB_PREFIX_."configuration (name, value, date_add, date_upd) VALUES ('PS_SHOP_DOMAIN_SSL', '".Tools::getHttpHost()."', NOW(), NOW())";
$sqlParams[] = "INSERT IGNORE INTO "._DB_PREFIX_."configuration (name, value, date_add, date_upd) VALUES ('PS_INSTALL_VERSION', '".pSQL(INSTALL_VERSION)."', NOW(), NOW())";
$sqlParams[] = "INSERT IGNORE INTO "._DB_PREFIX_."configuration (name, value, date_add, date_upd) VALUES ('PS_SHOP_NAME', '".pSQL($_GET['infosShop'])."', NOW(), NOW())";
$sqlParams[] = "INSERT IGNORE INTO "._DB_PREFIX_."configuration (name, value, date_add, date_upd) VALUES ('PS_SHOP_EMAIL', '".pSQL($_GET['infosEmail'])."', NOW(), NOW())";
$sqlParams[] = "INSERT IGNORE INTO "._DB_PREFIX_."configuration (name, value, date_add, date_upd) VALUES ('PS_MAIL_METHOD', '".pSQL($_GET['infosMailMethod'] == "smtp" ? "2": "1")."', NOW(), NOW())";
$sqlParams[] = 'UPDATE '._DB_PREFIX_.'configuration SET value = \''.pSQL($_GET['isoCode']).'\' WHERE name = \'PS_LOCALE_LANGUAGE\'';
$sqlParams[] = 'UPDATE '._DB_PREFIX_.'configuration SET value = \''.(int)$_GET['catalogMode'].'\' WHERE name = \'PS_CATALOG_MODE\'';
$sqlParams[] = "INSERT IGNORE INTO "._DB_PREFIX_."configuration (name, value, date_add, date_upd) VALUES ('PS_SHOP_ACTIVITY', '".(int)($_GET['infosActivity'])."', NOW(), NOW())";
if ((int)($_GET['infosCountry']) != 0)
{
$sqlParams[] = 'UPDATE '._DB_PREFIX_.'configuration SET value = '.(int)($_GET['infosCountry']).' WHERE name = \'PS_COUNTRY_DEFAULT\'';
$sqlParams[] = 'UPDATE '._DB_PREFIX_.'configuration SET value = "'.pSQL($_GET['infosTimezone']).'" WHERE name = \'PS_TIMEZONE\'';
$sql_isocode = Db::getInstance()->getValue('SELECT `iso_code` FROM `'._DB_PREFIX_.'country` WHERE `id_country` = '.(int)($_GET['infosCountry']));
$sqlParams[] = 'UPDATE '._DB_PREFIX_.'configuration SET value = \''.pSQL($sql_isocode).'\' WHERE name = \'PS_LOCALE_COUNTRY\'';
}
Language::loadLanguages();
Configuration::loadConfiguration();
require_once(DEFINES_FILE);
require_once(INSTALL_PATH.'/../classes/LocalizationPack.php');
$stream_context = @stream_context_create(array('http' => array('timeout' => 5)));
$localization_file = @Tools::file_get_contents('http://www.prestashop.com/download/localization_pack.php?country='.$_GET['countryName'], false, $stream_context);
if (!$localization_file AND file_exists(dirname(__FILE__).'/../../localization/'.strtolower($_GET['countryName']).'.xml'))
$localization_file = @file_get_contents(dirname(__FILE__).'/../../localization/'.strtolower($_GET['countryName']).'.xml');
if ($localization_file)
{
$localizationPack = new LocalizationPackCore();
$localizationPack->loadLocalisationPack($localization_file, '', true);
if (Configuration::get('PS_LANG_DEFAULT') == 1)
{
$sqlParams[] = 'UPDATE `'._DB_PREFIX_.'configuration` SET `value` = (SELECT id_lang FROM '._DB_PREFIX_.'lang WHERE iso_code = \''.pSQL($_GET['isoCode']).'\') WHERE name = \'PS_LANG_DEFAULT\'';
// This request is used when _PS_MODE_DEV_ is set to true
$sqlParams[] = 'UPDATE `'._DB_PREFIX_.'lang` SET `active` = 0 WHERE `iso_code` != \''.pSQL($_GET['isoCode']).'\'';
}
else
$sqlParams[] = 'UPDATE `'._DB_PREFIX_.'lang` SET `active` = 0 WHERE `id_lang` != '.Configuration::get('PS_LANG_DEFAULT');
}
if (isset($_GET['infosMailMethod']) AND $_GET['infosMailMethod'] == "smtp")
{
$sqlParams[] = "INSERT INTO "._DB_PREFIX_."configuration (name, value, date_add, date_upd) VALUES ('PS_MAIL_SERVER', '".pSQL($_GET['smtpSrv'])."', NOW(), NOW())";
$sqlParams[] = "INSERT INTO "._DB_PREFIX_."configuration (name, value, date_add, date_upd) VALUES ('PS_MAIL_USER', '".pSQL($_GET['smtpLogin'])."', NOW(), NOW())";
$sqlParams[] = "INSERT INTO "._DB_PREFIX_."configuration (name, value, date_add, date_upd) VALUES ('PS_MAIL_PASSWD', '".pSQL($_GET['smtpPassword'])."', NOW(), NOW())";
$sqlParams[] = "INSERT INTO "._DB_PREFIX_."configuration (name, value, date_add, date_upd) VALUES ('PS_MAIL_SMTP_ENCRYPTION', '".pSQL($_GET['smtpEnc'])."', NOW(), NOW())";
$sqlParams[] = "INSERT INTO "._DB_PREFIX_."configuration (name, value, date_add, date_upd) VALUES ('PS_MAIL_SMTP_PORT', '".pSQL($_GET['smtpPort'])."', NOW(), NOW())";
}
$sqlParams[] = 'INSERT INTO '._DB_PREFIX_.'employee (id_employee, lastname, firstname, email, passwd, last_passwd_gen, bo_theme, active, id_profile, id_lang, bo_show_screencast) VALUES (NULL, \''.pSQL(ToolsInstall::ucfirst($_GET['infosName'])).'\', \''.pSQL(ToolsInstall::ucfirst($_GET['infosFirstname'])).'\', \''.pSQL($_GET['infosEmail']).'\', \''.md5(pSQL(_COOKIE_KEY_.$_GET['infosPassword'])).'\', \''.date('Y-m-d h:i:s', strtotime('-360 minutes')).'\', \'oldschool\', 1, 1, (SELECT `value` FROM `'._DB_PREFIX_.'configuration` WHERE `name` = \'PS_LANG_DEFAULT\' LIMIT 1), 1)';
$sqlParams[] = 'INSERT INTO '._DB_PREFIX_.'employee_shop (id_employee, id_shop) VALUES (1 ,1)';
$sqlParams[] = 'INSERT INTO '._DB_PREFIX_.'contact (id_contact, email, customer_service) VALUES (NULL, \''.pSQL($_GET['infosEmail']).'\', 1), (NULL, \''.pSQL($_GET['infosEmail']).'\', 1)';
if (function_exists('mcrypt_encrypt'))
{
$settings = file_get_contents(dirname(__FILE__).'/../../config/settings.inc.php');
if (!strstr($settings, '_RIJNDAEL_KEY_'))
{
$key_size = mcrypt_get_key_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB);
$key = Tools::passwdGen($key_size);
$settings = preg_replace('/define\(\'_COOKIE_KEY_\', \'([a-z0-9=\/+-_]+)\'\);/i', 'define(\'_COOKIE_KEY_\', \'\1\');'."\n".'define(\'_RIJNDAEL_KEY_\', \''.$key.'\');', $settings);
}
if (!strstr($settings, '_RIJNDAEL_IV_'))
{
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB);
$iv = base64_encode(mcrypt_create_iv($iv_size, MCRYPT_RAND));
$settings = preg_replace('/define\(\'_COOKIE_IV_\', \'([a-z0-9=\/+-_]+)\'\);/i', 'define(\'_COOKIE_IV_\', \'\1\');'."\n".'define(\'_RIJNDAEL_IV_\', \''.$iv.'\');', $settings);
}
if (file_put_contents(dirname(__FILE__).'/../../config/settings.inc.php', $settings))
$sqlParams[] = 'UPDATE '._DB_PREFIX_.'configuration SET value = 1 WHERE name = \'PS_CIPHER_ALGORITHM\'';
}
if (file_exists(realpath(INSTALL_PATH.'/../img').'/logo.jpg'))
{
list($width, $height, $type, $attr) = getimagesize(realpath(INSTALL_PATH.'/../img').'/logo.jpg');
$sqlParams[] = 'UPDATE '._DB_PREFIX_.'configuration SET value = '.(int)round($width).' WHERE name = \'SHOP_LOGO_WIDTH\'';
$sqlParams[] = 'UPDATE '._DB_PREFIX_.'configuration SET value = '.(int)round($height).' WHERE name = \'SHOP_LOGO_HEIGHT\'';
}
if ((int)$_GET['catalogMode'] == 1)
{
$sqlParams[] = 'DELETE c, cl FROM `'._DB_PREFIX_.'cms` AS c LEFT JOIN `'._DB_PREFIX_.'cms_lang` AS cl ON c.id_cms = cl.id_cms WHERE 1 AND c.`id_cms` IN (1, 5)';
}
$dbInstance = Db::getInstance();
foreach($sqlParams as $query)
if(!$dbInstance->Execute($query))
$error['infosInsertSQL'] = '11';
unset($dbInstance);
}
//////////////////////////
// Building XML Response//
//////////////////////////
global $logger;
echo '<shopConfig>'."\n";
foreach ($error AS $key => $line)
{
if ($line != '')
$logger->logError($key.' => '.$line);
echo '<field id="'.$key.'" result="'.( $line != "" ? 'fail' : 'ok').'" error="'.$line.'" />'."\n";
}
echo '</shopConfig>';
+242
View File
@@ -0,0 +1,242 @@
<?php
/*
* 2007-2011 PrestaShop
*
* 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@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 http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
if (!defined('_PS_MAGIC_QUOTES_GPC_'))
define('_PS_MAGIC_QUOTES_GPC_', get_magic_quotes_gpc());
if (function_exists('date_default_timezone_set'))
date_default_timezone_set('Europe/Paris');
//delete settings file if it exist
if (file_exists(SETTINGS_FILE))
if (!unlink(SETTINGS_FILE))
die('<action result="fail" error="17" />'."\n");
require_once(INSTALL_PATH.'/classes/AddConfToFile.php');
require_once(INSTALL_PATH.'/../classes/Validate.php');
require_once(INSTALL_PATH.'/../classes/db/Db.php');
require_once(INSTALL_PATH.'/../classes/Tools.php');
global $logger;
//check db access
include_once(INSTALL_PATH.'/classes/ToolsInstall.php');
$resultDB = ToolsInstall::checkDB($_GET['server'], $_GET['login'], $_GET['password'], $_GET['name'], true);
if ($resultDB !== true)
{
$logger->logError('Invalid database configuration');
die("<action result='fail' error='".$resultDB."'/>\n");
}
if (!isset($_GET['mode']) OR ($_GET['mode'] != "full" AND $_GET['mode'] != "lite"))
die('<action result="fail" error="8"/>'."\n");
// Writing data in settings file
$oldLevel = error_reporting(E_ALL);
$_PS_DIRECTORY_ = trim(str_replace(' ', '%20', INSTALLER__PS_BASE_URI), '/');
$_PS_DIRECTORY_ = ($_PS_DIRECTORY_) ? '/'.$_PS_DIRECTORY_.'/' : '/';
$datas = array(
array('_DB_SERVER_', trim($_GET['server'])),
array('_DB_TYPE_', 'MySQL'),
array('_DB_NAME_', trim($_GET['name'])),
array('_DB_USER_', trim($_GET['login'])),
array('_DB_PASSWD_', trim($_GET['password'])),
array('_DB_PREFIX_', trim($_GET['tablePrefix'])),
array('_MYSQL_ENGINE_', trim($_GET['engine'])),
array('_PS_CACHING_SYSTEM_', 'CacheMemcache'),
array('_PS_CACHE_ENABLED_', '0'),
array('_MEDIA_SERVER_1_', ''),
array('_MEDIA_SERVER_2_', ''),
array('_MEDIA_SERVER_3_', ''),
array('_COOKIE_KEY_', Tools::passwdGen(56)),
array('_COOKIE_IV_', Tools::passwdGen(8)),
array('_PS_CREATION_DATE_', date('Y-m-d')),
array('_PS_VERSION_', INSTALL_VERSION)
);
error_reporting($oldLevel);
$confFile = new AddConfToFile(SETTINGS_FILE, 'w');
if ($confFile->error)
die('<action result="fail" error="'.$confFile->error.'" />'."\n");
foreach ($datas AS $data){
$confFile->writeInFile($data[0], $data[1]);
}
$confFile->writeEndTagPhp();
// Settings updated, compile and cache directories must be emptied
foreach (array(INSTALL_PATH.'/../tools/smarty/cache/', INSTALL_PATH.'/../tools/smarty/compile/', INSTALL_PATH.'/../tools/smarty_v2/cache/', INSTALL_PATH.'/../tools/smarty_v2/compile/') as $dir)
if (file_exists($dir))
foreach (scandir($dir) as $file)
if ($file[0] != '.' AND $file != 'index.php')
unlink($dir.$file);
if ($confFile->error != false)
die('<action result="fail" error="'.$confFile->error.'" />'."\n");
//load new settings, and fatal error if you can't
require_once(SETTINGS_FILE);
//-----------
//import SQL data
//-----------
switch (_DB_TYPE_)
{
case 'MySQL':
$filePrefix = 'PREFIX_';
$engineType = 'ENGINE_TYPE';
//send the SQL structure file requests
$structureFile = dirname(__FILE__).'/../sql/db.sql';
if(!file_exists($structureFile))
{
$logger->logError('Impossible to access to a MySQL content file. ('.$structureFile.')');
die('<action result="fail" error="10" />'."\n");
}
$db_structure_settings = '';
if ( !$db_structure_settings .= file_get_contents($structureFile) )
{
$logger->logError('Impossible to read the content of a MySQL content file. ('.$structureFile.')');
die('<action result="fail" error="9" />'."\n");
}
$db_structure_settings = str_replace(array($filePrefix, $engineType), array($_GET['tablePrefix'], $_GET['engine']), $db_structure_settings);
$db_structure_settings = preg_split("/;\s*[\r\n]+/",$db_structure_settings);
if (isset($_GET['dropAndCreate']) && $_GET['dropAndCreate'] == 'true')
{
array_unshift($db_structure_settings, 'USE `'.trim($_GET['name']).'`;');
array_unshift($db_structure_settings, 'CREATE DATABASE `'.trim($_GET['name']).'`;');
array_unshift($db_structure_settings, 'DROP DATABASE `'.trim($_GET['name']).'`;');
}
foreach ($db_structure_settings as $query)
{
$query = trim($query);
if (!empty($query))
{
if (!Db::getInstance()->Execute($query))
{
if (Db::getInstance()->getNumberError() == 1050)
{
$logger->logError('A Prestashop database already exists, please drop it or change the prefix.');
die('<action result="fail" error="14" />'."\n");
}
else
{
$logger->logError('SQL query: '."\r\n".$query);
$logger->logError('SQL error: '."\r\n".Db::getInstance()->getMsgError());
die(
'<action
result="fail"
error="11"
sqlMsgError="'.addslashes(htmlentities(Db::getInstance()->getMsgError())).'"
sqlNumberError="'.htmlentities(Db::getInstance()->getNumberError()).'"
sqlQuery="'.addslashes(htmlentities($query)).'"
/>'
);
}
}
}
}
//send the SQL data file requests
$db_data_settings = '';
$liteFile = dirname(__FILE__).'/../sql/db_settings_lite.sql';
if(!file_exists($liteFile))
die('<action result="fail" error="10" />'."\n");
if ( !$db_data_settings .= file_get_contents( $liteFile ) )
die('<action result="fail" error="9" />'."\n");
if ($_GET['mode'] == 'full')
{
$fullFile = dirname(__FILE__).'/../sql/db_settings_extends.sql';
if(!file_exists($fullFile))
{
$logger->logError('Impossible to access to a MySQL content file. ('.$fullFile.')');
die('<action result="fail" error="10" />'."\n");
}
if (!$db_data_settings .= file_get_contents($fullFile))
{
$logger->logError('Impossible to read the content of a MySQL content file. ('.$fullFile.')');
die('<action result="fail" error="9" />'."\n");
}
}
$db_data_settings .= "\n".'INSERT INTO `PREFIX_shop_url` (`id_shop`, `domain`, `domain_ssl`, `physical_uri`, `virtual_uri`, `main`, `active`) VALUES(1, \''.pSQL(Tools::getHttpHost()).'\', \''.pSQL(Tools::getHttpHost()).'\', \''.pSQL($_PS_DIRECTORY_).'\', \'\', 1, 1);';
$db_data_settings .= "\n".'UPDATE `PREFIX_customer` SET `passwd` = \''.md5(_COOKIE_KEY_.'123456789').'\' WHERE `id_customer` =1;';
$db_data_settings .= "\n".'INSERT INTO `PREFIX_configuration` (name, value, date_add, date_upd) VALUES (\'PS_VERSION_DB\', \'' . INSTALL_VERSION . '\', NOW(), NOW());';
$db_data_settings = str_replace(array($filePrefix, $engineType), array($_GET['tablePrefix'], $_GET['engine']), $db_data_settings);
$db_data_settings = preg_split("/;\s*[\r\n]+/",$db_data_settings);
/* UTF-8 support */
array_unshift($db_data_settings, 'SET NAMES \'utf8\';');
foreach ($db_data_settings as $query)
{
$query = trim($query);
if (!empty($query))
{
if (!Db::getInstance()->Execute($query))
{
if (Db::getInstance()->getNumberError() == 1050)
die('<action result="fail" error="14" />'."\n");
else
{
$logger->logError('SQL query: '."\r\n".$query);
$logger->logError('SQL error: '."\r\n".Db::getInstance()->getMsgError());
die(
'<action
result="fail"
error="11"
sqlMsgError="'.addslashes(htmlentities(Db::getInstance()->getMsgError())).'"
sqlNumberError="'.htmlentities(Db::getInstance()->getNumberError()).'"
sqlQuery="'.addslashes(htmlentities($query)).'"
/>'
);
}
}
}
}
break;
}
$xml = '<result><action result="ok" error="" />'."\n";
$countries = Db::getInstance()->executeS('
SELECT c.`id_country`, cl.`name`, c.`iso_code` FROM `'.$_GET['tablePrefix'].'country` c
INNER JOIN `'.$_GET['tablePrefix'].'country_lang` cl ON (c.`id_country` = cl.`id_country`)
WHERE cl.`id_lang` = '.(int)($_GET['language'] + 1).'
ORDER BY cl.`name`');
$timezones = Db::getInstance()->executeS('
SELECT * FROM `'.$_GET['tablePrefix'].'timezone`
ORDER BY `name`');
$xml .= '<countries>'."\n";
foreach ($countries as $country)
$xml .= "\t".'<country iso="'.$country['iso_code'].'" value="'.$country['id_country'].'" name="'.$country['name'].'" />'."\n";
$xml .= '</countries>'."\n".'<timezones>'."\n";
foreach ($timezones as $timezone)
$xml .= "\t".'<timezone value="'.$timezone['name'].'" name="'.$timezone['name'].'" />'."\n";
$xml .= '</timezones></result>'."\n";
die($xml);
+329
View File
@@ -0,0 +1,329 @@
<?php
/*
* 2007-2011 PrestaShop
*
* 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@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 http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
define('UPGRADE_PATH', INSTALL_PATH.'/upgrade/');
$filePrefix = 'PREFIX_';
$engineType = 'ENGINE_TYPE';
if (function_exists('date_default_timezone_set'))
date_default_timezone_set('Europe/Paris');
// if _PS_ROOT_DIR_ is defined, use it instead of "guessing" the module dir.
if (defined('_PS_ROOT_DIR_') AND !defined('_PS_MODULE_DIR_'))
define('_PS_MODULE_DIR_', _PS_ROOT_DIR_.'/modules/');
else if (!defined('_PS_MODULE_DIR_'))
define('_PS_MODULE_DIR_', INSTALL_PATH.'/../modules/');
if(!defined('_PS_INSTALLER_PHP_UPGRADE_DIR_'))
define('_PS_INSTALLER_PHP_UPGRADE_DIR_', UPGRADE_PATH.'functions/');
// No more infinite require_once on functions !
foreach (scandir(_PS_INSTALLER_PHP_UPGRADE_DIR_) as $file)
if ($file[0] != '.' && $file != 'index.php' && preg_match('#\.php$#i', $file))
require_once _PS_INSTALLER_PHP_UPGRADE_DIR_.$file;
//old version detection
global $oldversion, $logger;
$oldversion = false;
if (file_exists(SETTINGS_FILE) AND file_exists(DEFINES_FILE))
{
include_once(SETTINGS_FILE);
include_once(DEFINES_FILE);
$oldversion = _PS_VERSION_;
}
else
{
$logger->logError('The config/settings.inc.php file was not found.');
die('<action result="fail" error="30" />'."\n");
}
if (!file_exists(DEFINES_FILE))
{
$logger->logError('The config/settings.inc.php file was not found.');
die('<action result="fail" error="37" />'."\n");
}
include_once(SETTINGS_FILE);
if (!defined('_THEMES_DIR_'))
define('_THEMES_DIR_', __PS_BASE_URI__.'themes/');
if (!defined('_PS_IMG_'))
define('_PS_IMG_', __PS_BASE_URI__.'img/');
if (!defined('_PS_JS_DIR_'))
define('_PS_JS_DIR_', __PS_BASE_URI__.'js/');
if (!defined('_PS_CSS_DIR_'))
define('_PS_CSS_DIR_', __PS_BASE_URI__.'css/');
include_once(DEFINES_FILE);
$oldversion = _PS_VERSION_;
$versionCompare = version_compare(INSTALL_VERSION, $oldversion);
if ($versionCompare == '-1')
{
$logger->logError('This installer is too old.');
die('<action result="fail" error="27" />'."\n");
}
elseif ($versionCompare == 0)
{
$logger->logError(sprintf('You already have the %s version.',INSTALL_VERSION));
die('<action result="fail" error="28" />'."\n");
}
elseif ($versionCompare === false)
{
$logger->logError('There is no older version. Did you delete or rename the config/settings.inc.php file?');
die('<action result="fail" error="29" />'."\n");
}
//check DB access
include_once(UPGRADE_PATH.'classes/ToolsInstall.php');
$resultDB = ToolsInstall::checkDB(_DB_SERVER_, _DB_USER_, _DB_PASSWD_, _DB_NAME_, false);
if ($resultDB !== true)
{
$logger->logError('Invalid database configuration.');
die("<action result='fail' error='".$resultDB."'/>\n");
}
//custom sql file creation
$upgradeFiles = array();
if ($handle = opendir(UPGRADE_PATH.'sql'))
{
while (false !== ($file = readdir($handle)))
if ($file != '.' AND $file != '..')
$upgradeFiles[] = str_replace(".sql", "", $file);
closedir($handle);
}
if (empty($upgradeFiles))
{
$logger->logError('Can\'t find the sql upgrade files. Please verify that the /install/sql/upgrade folder is not empty)');
die('<action result="fail" error="31" />'."\n");
}
natcasesort($upgradeFiles);
$neededUpgradeFiles = array();
// fix : complete version number if there is not all 4 numbers
// for example replace 1.4.3 by 1.4.3.0
// consequences : file 1.4.3.0.sql will be skipped if oldversion = 1.4.3
// @since 1.4.4.0
$arrayVersion = preg_split('#\.#', $oldversion);
$versionNumbers = sizeof($arrayVersion);
if ($versionNumbers != 4)
$arrayVersion = array_pad($arrayVersion, 4, '0');
$oldversion = implode('.', $arrayVersion);
// end of fix
foreach ($upgradeFiles AS $version)
{
if (version_compare($version, $oldversion) == 1 AND version_compare(INSTALL_VERSION, $version) != -1)
$neededUpgradeFiles[] = $version;
}
if (empty($neededUpgradeFiles))
{
$logger->logError('No upgrade is possible.');
die('<action result="fail" error="32" />'."\n");
}
//refresh conf file
require_once(UPGRADE_PATH.'classes/AddConfToFile.php');
$oldLevel = error_reporting(E_ALL);
$mysqlEngine = (defined('_MYSQL_ENGINE_') ? _MYSQL_ENGINE_ : 'MyISAM');
$datas = array(
array('_DB_SERVER_', _DB_SERVER_),
array('_DB_TYPE_', _DB_TYPE_),
array('_DB_NAME_', _DB_NAME_),
array('_DB_USER_', _DB_USER_),
array('_DB_PASSWD_', _DB_PASSWD_),
array('_DB_PREFIX_', _DB_PREFIX_),
array('_MYSQL_ENGINE_', $mysqlEngine),
array('_PS_CACHING_SYSTEM_', (defined('_PS_CACHING_SYSTEM_') AND _PS_CACHING_SYSTEM_ != 'CacheMemcache') ? _PS_CACHING_SYSTEM_ : 'CacheMemcache'),
array('_PS_CACHE_ENABLED_', defined('_PS_CACHE_ENABLED_') ? _PS_CACHE_ENABLED_ : '0'),
array('_MEDIA_SERVER_1_', defined('_MEDIA_SERVER_1_') ? _MEDIA_SERVER_1_ : ''),
array('_MEDIA_SERVER_2_', defined('_MEDIA_SERVER_2_') ? _MEDIA_SERVER_2_ : ''),
array('_MEDIA_SERVER_3_', defined('_MEDIA_SERVER_3_') ? _MEDIA_SERVER_3_ : ''),
array('_PS_DIRECTORY_', __PS_BASE_URI__),
array('_COOKIE_KEY_', _COOKIE_KEY_),
array('_COOKIE_IV_', _COOKIE_IV_),
array('_PS_CREATION_DATE_', defined("_PS_CREATION_DATE_") ? _PS_CREATION_DATE_ : date('Y-m-d')),
array('_PS_VERSION_', INSTALL_VERSION)
);
if (defined('_RIJNDAEL_KEY_'))
$datas[] = array('_RIJNDAEL_KEY_', _RIJNDAEL_KEY_);
if (defined('_RIJNDAEL_IV_'))
$datas[] = array('_RIJNDAEL_IV_', _RIJNDAEL_IV_);
if(!defined('_PS_CACHE_ENABLED_'))
define('_PS_CACHE_ENABLED_', '0');
if(!defined('_MYSQL_ENGINE_'))
define('_MYSQL_ENGINE_', 'MyISAM');
$sqlContent = '';
if(isset($_GET['customModule']) AND $_GET['customModule'] == 'desactivate')
desactivate_custom_modules();
foreach($neededUpgradeFiles AS $version)
{
$file = UPGRADE_PATH.'sql/'.$version.'.sql';
if (!file_exists($file))
{
$logger->logError('Error while loading sql upgrade file.');
die('<action result="fail" error="33" />'."\n");
}
if (!$sqlContent .= file_get_contents($file))
{
$logger->logError('Error while loading sql upgrade file.');
die('<action result="fail" error="33" />'."\n");
}
$sqlContent .= "\n";
}
$sqlContent = str_replace(array($filePrefix, $engineType), array(_DB_PREFIX_, $mysqlEngine), $sqlContent);
$sqlContent = preg_split("/;\s*[\r\n]+/",$sqlContent);
error_reporting($oldLevel);
$confFile = new AddConfToFile(SETTINGS_FILE, 'w');
if ($confFile->error)
{
$logger->logError($confFile->error);
die('<action result="fail" error="'.$confFile->error.'" />'."\n");
}
foreach ($datas AS $data){
$confFile->writeInFile($data[0], $data[1]);
}
if ($confFile->error != false)
{
$logger->logError($confFile->error);
die('<action result="fail" error="'.$confFile->error.'" />'."\n");
}
// Settings updated, compile and cache directories must be emptied
$arrayToClean = array(
_PS_CACHE_DIR_.'smarty/cache/',
_PS_CACHE_DIR_.'smarty/compile/',
);
foreach ($arrayToClean as $dir)
if (!file_exists($dir))
$logger->logError('directory '.$dir." doesn't exist and can't be emptied.\r\n");
else
foreach (scandir($dir) as $file)
if ($file[0] != '.' AND $file != 'index.php' AND $file != '.htaccess')
unlink($dir.$file);
// delete cache filesystem if activated
$depth = Configuration::get('PS_CACHEFS_DIRECTORY_DEPTH');
if($depth)
{
CacheFs::deleteCacheDirectory();
CacheFs::createCacheDirectories((int)$depth);
}
//sql file execution
global $requests, $warningExist;
$requests = '';
$warningExist = false;
Configuration::loadConfiguration();
foreach($sqlContent as $query)
{
$query = trim($query);
if(!empty($query))
{
/* If php code have to be executed */
if (strpos($query, '/* PHP:') !== false)
{
/* Parsing php code */
$pos = strpos($query, '/* PHP:') + strlen('/* PHP:');
$phpString = substr($query, $pos, strlen($query) - $pos - strlen(' */;'));
$php = explode('::', $phpString);
preg_match('/\((.*)\)/', $phpString, $pattern);
$paramsString = trim($pattern[0], '()');
preg_match_all('/([^,]+),? ?/', $paramsString, $parameters);
if (isset($parameters[1]))
$parameters = $parameters[1];
else
$parameters = array();
if (is_array($parameters))
foreach ($parameters AS &$parameter)
$parameter = str_replace('\'', '', $parameter);
/* Call a simple function */
if (strpos($phpString, '::') === false)
$phpRes = call_user_func_array(str_replace($pattern[0], '', $php[0]), $parameters);
/* Or an object method */
else
$phpRes = call_user_func_array(array($php[0], str_replace($pattern[0], '', $php[1])), $parameters);
if ((is_array($phpRes) AND !empty($phpRes['error'])) OR $phpRes === false )
{
$logger->logError('PHP error: '.$query."\r\n".(empty($phpRes['msg'])?'':' - '.$phpRes['msg']));
$logger->logError(empty($phpRes['error'])?'':$phpRes['error']);
if (!isset($request))
$request = '';
$request .=
' <request result="fail">
<sqlQuery><![CDATA['.htmlentities($query).']]></sqlQuery>
<phpMsgError><![CDATA['.(empty($phpRes['msg'])?'':$phpRes['msg']).']]></sqlMsgError>
<phpNumberError><![CDATA['.(empty($phpRes['error'])?'':$phpRes['error']).']]></sqlNumberError>
</request>'."\n";
}
else
$requests .=
' <request result="ok">
<sqlQuery><![CDATA['.htmlentities($query).']]></sqlQuery>
</request>'."\n";
}
elseif(!Db::getInstance()->execute($query))
{
$logger->logError('SQL query: '."\r\n".$query);
$logger->logError('SQL error: '."\r\n".Db::getInstance()->getMsgError());
$warningExist = true;
$requests .=
' <request result="fail">
<sqlQuery><![CDATA['.htmlentities($query).']]></sqlQuery>
<sqlMsgError><![CDATA['.htmlentities(Db::getInstance()->getMsgError()).']]></sqlMsgError>
<sqlNumberError><![CDATA['.htmlentities(Db::getInstance()->getNumberError()).']]></sqlNumberError>
</request>'."\n";
}
else
$requests .=
' <request result="ok">
<sqlQuery><![CDATA['.htmlentities($query).']]></sqlQuery>
</request>'."\n";
}
}
Configuration::updateValue('PS_HIDE_OPTIMIZATION_TIPS', 0);
Configuration::updateValue('PS_NEED_REBUILD_INDEX', 1);
Configuration::updateValue('PS_VERSION_DB', INSTALL_VERSION);
$result = $warningExist ? '<action result="fail" error="34">'."\n" : '<action result="ok" error="">'."\n";
$result .= $requests;
die($result.'</action>'."\n");
@@ -0,0 +1,85 @@
<?php
/*
* 2007-2011 PrestaShop
*
* 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@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 http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
require_once(SETTINGS_FILE);
require_once(INSTALL_PATH.'/classes/GetVersionFromDb.php');
require_once(INSTALL_PATH.'/classes/LanguagesManager.php');
$lm = new LanguageManager(INSTALL_PATH.'/langs/list.xml');
$_LANG = array();
$_LIST_WORDS = array();
function lang($txt) {
global $_LANG , $_LIST_WORDS;
return (isset($_LANG[$txt]) ? $_LANG[$txt] : $txt);
}
if ($lm->getIncludeTradFilename())
include_once($lm->getIncludeTradFilename());
$dbVersion = new GetVersionFromDb();
$versions = $dbVersion->getVersions();
$psVersionDb = Configuration::get('PS_VERSION_DB');
// Usefull debug
/* echo '<xmp>';
print_r($versions);
print_r($dbVersion->getErrors());
exit;*/
if (!$versions)
{
// Desactivate this case temporary
die('<action result="ok" />');
$message = lang('Warning, the installer was unable to detect what is your current PrestaShop version from a database structure analysis. This means some fields or tables are missing, and upgrade is under your own risk.');
if ($psVersionDb)
{
$message .= '<br /><br />' . sprintf(lang('However the installer has detected that the version stored in your configuration table is %1$s'), '<span class="versionInfo">' . $psVersionDb . '</span>');
}
die('<action result="ko" lang="' . htmlspecialchars($message) . '" />');
}
foreach ($versions as $version)
{
if (version_compare(_PS_VERSION_, $version) == 0)
{
die('<action result="ok" />');
}
}
if (count($versions) == 1)
{
die('<action result="ko" lang="' . htmlspecialchars(sprintf(lang('Warning, we detected that the version specified in your config/settings.inc.php does not match your SQL database structure.<br />File config/settings.inc.php indicates: %1$s<br />Our automatic detection tool has detected version: %2$s<br /><br />You should edit your config/settings.inc.php file to replace %1$s by %2$s.<br />Failure to fix this issue before upgrading may result in severe complications.<br />Do not forget to relaunch the installer after this modification by pressing F5 on your web browser.'), '<span class="versionInfo">' . _PS_VERSION_ . '</span>', '<span class="versionInfo">' . $versions[0] . '</span>')) . '" />');
}
if ($psVersionDb && in_array($psVersionDb, $versions))
{
die('<action result="ko" lang="' . htmlspecialchars(sprintf(lang('Warning, we detected that the version specified in your config/settings.inc.php does not match your SQL database structure.<br />File config/settings.inc.php indicates: %1$s<br />Our automatic detection tool has detected version: %2$s<br /><br />You should edit your config/settings.inc.php file to replace %1$s by %2$s.<br />Failure to fix this issue before upgrading may result in severe complications.<br />Do not forget to relaunch the installer after this modification by pressing F5 on your web browser.'), '<span class="versionInfo">' . _PS_VERSION_ . '</span>', '<span class="versionInfo">' . $psVersionDb . '</span>')) . '" />');
}
else
{
die('<action result="ko" lang="' . htmlspecialchars(sprintf(lang('Warning, we detected that the version specified in your config/settings.inc.php does not match your SQL database structure.<br />File config/settings.inc.php indicates: %1$s<br />Our automatic detection tool has detected a version between %2$s and %3$s<br /><br />You should edit your config/settings.inc.php file to replace %1$s by your real shop version.<br />Failure to fix this issue before upgrading may result in severe complications.<br />Do not forget to relaunch the installer after this modification by pressing F5 on your web browser.'), '<span class="versionInfo">' . _PS_VERSION_ . '</span>', '<span class="versionInfo">' . $versions[count($versions) - 1] . '</span>', '<span class="versionInfo">' . $versions[0] . '</span>')) . '" />');
}
+36
View File
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2011 PrestaShop
*
* 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@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 http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;