diff --git a/admin-dev/tabs/AdminGenerator.php b/admin-dev/tabs/AdminGenerator.php
index e018e2c1b..12d8d083e 100644
--- a/admin-dev/tabs/AdminGenerator.php
+++ b/admin-dev/tabs/AdminGenerator.php
@@ -131,13 +131,13 @@ class AdminGenerator extends AdminTab
{
// PS Comments
fwrite($writeFd, "# robots.txt automaticaly generated by PrestaShop e-commerce open-source solution\n");
- fwrite($writeFd, "# http://www.prestashop.com - http://www.prestashop.com/forums\n\n");
+ fwrite($writeFd, "# http://www.prestashop.com - http://www.prestashop.com/forums\n");
fwrite($writeFd, "# This file is to prevent the crawling and indexing of certain parts\n");
fwrite($writeFd, "# of your site by web crawlers and spiders run by sites like Yahoo!\n");
fwrite($writeFd, "# and Google. By telling these \"robots\" where not to go on your site,\n");
- fwrite($writeFd, "# you save bandwidth and server resources.\n\n");
+ fwrite($writeFd, "# you save bandwidth and server resources.\n");
fwrite($writeFd, "# For more information about the robots.txt standard, see:\n");
- fwrite($writeFd, "# http://www.robotstxt.org/wc/robots.html\n\n");
+ fwrite($writeFd, "# http://www.robotstxt.org/wc/robots.html\n");
//GoogleBot specific
fwrite($writeFd, "# GoogleBot specific\n");
@@ -146,7 +146,7 @@ class AdminGenerator extends AdminTab
fwrite($writeFd, 'Disallow: '.__PS_BASE_URI__.$GB."\n");
// User-Agent
- fwrite($writeFd, "# All bots\n\n");
+ fwrite($writeFd, "# All bots\n");
fwrite($writeFd, "User-agent: *\n");
// Directories
@@ -193,4 +193,4 @@ class AdminGenerator extends AdminTab
return $tab;
}
-}
\ No newline at end of file
+}
diff --git a/admin-dev/tabs/AdminImages.php b/admin-dev/tabs/AdminImages.php
index 1ba072551..8fce7381e 100644
--- a/admin-dev/tabs/AdminImages.php
+++ b/admin-dev/tabs/AdminImages.php
@@ -443,8 +443,16 @@ class AdminImages extends AdminTab
'.$this->l('Move images').'
'.
$this->l('A new storage system for product images is now used by PrestaShop. It offers better performance if your shop has a very large number of products.').' '.
' ';
+ if (file_exists(_PS_PROD_IMG_DIR_.'duplicates/'))
+ {
+ echo '
';
+ $this->displayWarning($this->l('Duplicate images were found when moving the product images. It is probably caused by unused demonstration images. Please make sure that the folder ').
+ _PS_PROD_IMG_DIR_.'duplicates/'.
+ $this->l(' only contains demonstration images then delete this folder.'));
+ echo '
';
+ }
if($safe_mode)
- echo $this->displayWarning('PrestaShop has detected that your server configuration is not compatible with the new storage system (directive "safe_mode" is activated). You should continue to use the actual system.');
+ $this->displayWarning($this->l('PrestaShop has detected that your server configuration is not compatible with the new storage system (directive "safe_mode" is activated). You should continue to use the actual system.'));
else
echo '
';
+ }
echo '
';
if (!is_array($warn))
- $str_output .= ''.$warn;
+ {
+ if (file_exists(__PS_BASE_URI__.'img/admin/warn2.png'))
+ $str_output .= '';
+ else
+ $str_output .= '';
+
+
+ $str_output .= $warn;
+ }
else
{ $str_output .= ''.
(count($warn) > 1 ? $this->l('There are') : $this->l('There is')).' '.count($warn).' '.(count($warn) > 1 ? $this->l('warnings') : $this->l('warning'))
@@ -2141,5 +2152,112 @@ abstract class AdminSelfTab
'.
$this->l('Click here if you want to modify the main shop domain name').'');
}
+ /*
+ * from 1.4 AdminPreferences
+ */
+ protected function _postConfig($fields)
+ {
+ global $currentIndex, $smarty;
+
+ $languages = Language::getLanguages(false);
+ if (function_exists('Tools','clearCache'))
+ Tools::clearCache($smarty);
+
+ /* Check required fields */
+ foreach ($fields AS $field => $values)
+ if (isset($values['required']) AND $values['required'])
+ if (isset($values['type']) AND $values['type'] == 'textLang')
+ {
+ foreach ($languages as $language)
+ if (($value = Tools::getValue($field.'_'.$language['id_lang'])) == false AND (string)$value != '0')
+ $this->_errors[] = Tools::displayError('field').' '.$values['title'].' '.Tools::displayError('is required.');
+}
+ elseif (($value = Tools::getValue($field)) == false AND (string)$value != '0')
+ $this->_errors[] = Tools::displayError('field').' '.$values['title'].' '.Tools::displayError('is required.');
+
+ /* Check fields validity */
+ foreach ($fields AS $field => $values)
+ if (isset($values['type']) AND $values['type'] == 'textLang')
+ {
+ foreach ($languages as $language)
+ if (Tools::getValue($field.'_'.$language['id_lang']) AND isset($values['validation']))
+ if (!Validate::$values['validation'](Tools::getValue($field.'_'.$language['id_lang'])))
+ $this->_errors[] = Tools::displayError('field').' '.$values['title'].' '.Tools::displayError('is invalid.');
+ }
+ elseif (Tools::getValue($field) AND isset($values['validation']))
+ if (!Validate::$values['validation'](Tools::getValue($field)))
+ $this->_errors[] = Tools::displayError('field').' '.$values['title'].' '.Tools::displayError('is invalid.');
+
+ /* Default value if null */
+ foreach ($fields AS $field => $values)
+ if (!Tools::getValue($field) AND isset($values['default']))
+ $_POST[$field] = $values['default'];
+
+ /* Save process */
+ if (!sizeof($this->_errors))
+ {
+ if (Tools::isSubmit('submitAppearanceconfiguration'))
+ {
+ if (isset($_FILES['PS_LOGO']['tmp_name']) AND $_FILES['PS_LOGO']['tmp_name'])
+ {
+ if ($error = checkImage($_FILES['PS_LOGO'], 300000))
+ $this->_errors[] = $error;
+ if (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS') OR !move_uploaded_file($_FILES['PS_LOGO']['tmp_name'], $tmpName))
+ return false;
+ elseif (!@imageResize($tmpName, _PS_IMG_DIR_.'logo.jpg'))
+ $this->_errors[] = 'an error occurred during logo copy';
+ unlink($tmpName);
+ }
+ if (isset($_FILES['PS_LOGO_MAIL']['tmp_name']) AND $_FILES['PS_LOGO_MAIL']['tmp_name'])
+ {
+ if ($error = checkImage($_FILES['PS_LOGO_MAIL'], 300000))
+ $this->_errors[] = $error;
+ if (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS_MAIL') OR !move_uploaded_file($_FILES['PS_LOGO_MAIL']['tmp_name'], $tmpName))
+ return false;
+ elseif (!@imageResize($tmpName, _PS_IMG_DIR_.'logo_mail.jpg'))
+ $this->_errors[] = 'an error occurred during logo copy';
+ unlink($tmpName);
+ }
+ if (isset($_FILES['PS_LOGO_INVOICE']['tmp_name']) AND $_FILES['PS_LOGO_INVOICE']['tmp_name'])
+ {
+ if ($error = checkImage($_FILES['PS_LOGO_INVOICE'], 300000))
+ $this->_errors[] = $error;
+ if (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS_INVOICE') OR !move_uploaded_file($_FILES['PS_LOGO_INVOICE']['tmp_name'], $tmpName))
+ return false;
+ elseif (!@imageResize($tmpName, _PS_IMG_DIR_.'logo_invoice.jpg'))
+ $this->_errors[] = 'an error occurred during logo copy';
+ unlink($tmpName);
+ }
+ if (isset($_FILES['PS_STORES_ICON']['tmp_name']) AND $_FILES['PS_STORES_ICON']['tmp_name'])
+ {
+ if ($error = checkImage($_FILES['PS_STORES_ICON'], 300000))
+ $this->_errors[] = $error;
+ if (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS_STORES_ICON') OR !move_uploaded_file($_FILES['PS_STORES_ICON']['tmp_name'], $tmpName))
+ return false;
+ elseif (!@imageResize($tmpName, _PS_IMG_DIR_.'logo_stores.gif'))
+ $this->_errors[] = 'an error occurred during logo copy';
+ unlink($tmpName);
+ }
+ $this->uploadIco('PS_FAVICON', _PS_IMG_DIR_.'favicon.ico');
+ }
+
+ /* Update settings in database */
+ if (!sizeof($this->_errors))
+ {
+ foreach ($fields AS $field => $values)
+ {
+ unset($val);
+ if (isset($values['type']) AND $values['type'] == 'textLang')
+ foreach ($languages as $language)
+ $val[$language['id_lang']] = isset($values['cast']) ? $values['cast'](Tools::getValue($field.'_'.$language['id_lang'])) : Tools::getValue($field.'_'.$language['id_lang']);
+ else
+ $val = isset($values['cast']) ? $values['cast'](Tools::getValue($field)) : Tools::getValue($field);
+
+ Configuration::updateValue($field, $val);
+ }
+ Tools::redirectAdmin($currentIndex.'&conf=6'.'&token='.$this->token);
+ }
+ }
+ }
}
diff --git a/modules/autoupgrade/AdminSelfUpgrade.gif b/modules/autoupgrade/AdminSelfUpgrade.gif
new file mode 100644
index 0000000000000000000000000000000000000000..98135690867612ab16055ff813afeb7e16dafa20
GIT binary patch
literal 652
zcmZ?wbhEHb6krfwI9A3G7#J8F92^l55gi?^QqHMZ$t+jRtXj#gSj&)@n5bIMkdl(3
z-OQMsoo(9Ao}Zs@-7VnSC*jgBR#{o;HBlyTx>93fV^dR8_zaEa=H}?xn(giFNplT4
zJ3Hg%TP4poj9FllI^VFTrzd`)bNWK#j0ILni{1MB`?D9D=Pou+Tk4Uq)U9BNL;h0R
zlGXlm=FF*CAG%<{f`tngHg1k;*qpd{@#3bf=}VU`ZQYi(Y}vBbZCT5gFYnxu-M1@$
z&6+h6_LOYcuwmoIjhi-Yns%^Z`k|&7hnlx<-#+hX$HHS>yLRnbc)V-Ro;^!X^zPle
zci+B!D^E?>zkmOV(-T&mo_OHEfrAGR9y)Yr?b#`Z4RS@
zwP{OkX-=qLX1ar2La|#*WNvzP&f@H}gjnI0sPx1*Pkp1%=nyyArr5~ftR!#oCiU>p
zBqeFd$db&sWb+msMbGFw-hhI%=p@G$Rbz?ZG)_}>!<6VmT}>4kgCIRYCdMYasF0|D
zgpEq7r}$O1Wq3|Cx^d6o53Blc!11t~pa2((Zsla<<~DVo2{IQQU5++7iplBx2ySd*
h;gD;aq442Ff2*1kn}I~&f@KPf4F41i95e(NtO5C9LstL*
literal 0
HcmV?d00001
diff --git a/modules/autoupgrade/AdminSelfUpgrade.php b/modules/autoupgrade/AdminSelfUpgrade.php
index 448783608..fc32ef3ea 100644
--- a/modules/autoupgrade/AdminSelfUpgrade.php
+++ b/modules/autoupgrade/AdminSelfUpgrade.php
@@ -31,6 +31,9 @@ if(!defined('_PS_USE_SQL_SLAVE_'))
if(empty($_POST['action']) OR !in_array($_POST['action'],array('upgradeDb')))
{
+ if(!defined('_PS_CACHE_ENABLED_'))
+ define('_PS_CACHE_ENABLED_',false);
+
if(!defined('PS_ORDER_PROCESS_STANDARD'))
define('PS_ORDER_PROCESS_STANDARD',true);
if(!defined('PS_ORDER_PROCESS_OPC'))
@@ -40,24 +43,22 @@ if(empty($_POST['action']) OR !in_array($_POST['action'],array('upgradeDb')))
}
require_once(dirname(__FILE__).'/AdminSelfTab.php');
require_once(dirname(__FILE__).'/SelfModule.php');
- if(file_exists(_PS_ROOT_DIR_.'/classes/Upgrader.php'))
- {
+
+// Add Upgrader class
+ if(!version_compare(_PS_VERSION_,'1.4.5.0','<') AND file_exists(_PS_ROOT_DIR_.'/classes/Upgrader.php'))
require_once(_PS_ROOT_DIR_.'/classes/Upgrader.php');
- }
else
require_once(dirname(__FILE__).'/Upgrader.php');
if(!class_exists('Upgrader',false))
{
if(file_exists(_PS_ROOT_DIR_.'/override/classes/Upgrader.php'))
- {
require_once(_PS_ROOT_DIR_.'/override/classes/Upgrader.php');
- }
else
- {
eval('class Upgrader extends UpgraderCore{}');
}
- }
+
+
require_once(dirname(__FILE__).'/Tools14.php');
if(!class_exists('Tools',false))
@@ -68,6 +69,9 @@ class AdminSelfUpgrade extends AdminSelfTab
public $nextResponseType = 'json'; // json, xml
public $next = 'N/A';
+ public $upgrader = null;
+ public $standalone = true;
+
/**
* set to false if the current step is a loop
*
@@ -111,8 +115,8 @@ class AdminSelfUpgrade extends AdminSelfTab
public $rootWritable = false;
public $svnDir = 'svn';
public $destDownloadFilename = 'prestashop.zip';
- public $toUpgradeFileList = array();
- public $backupFileList = array();
+ public $toUpgradeFileList = 'filesToUpgrade.list';
+ public $toBackupFileList = 'filesToBackup.list';
public $sampleFileList = array();
private $backupIgnoreFiles = array();
private $backupIgnoreAbsoluteFiles = array();
@@ -165,7 +169,7 @@ class AdminSelfUpgrade extends AdminSelfTab
global $cookie;
$id_employee = $cookie->id_employee;
- $cookiePath = __PS_BASE_URI__.str_replace($this->prodRootDir,'',trim($this->adminDir,'/'));
+ $cookiePath = __PS_BASE_URI__.str_replace($this->prodRootDir,'',trim($this->adminDir,DIRECTORY_SEPARATOR));
setcookie('id_employee', $id_employee, time()+3600, $cookiePath);
setcookie('id_tab', $this->id, time()+3600, $cookiePath);
setcookie('autoupgrade', $this->encrypt($id_employee), time()+3600, $cookiePath);
@@ -221,7 +225,7 @@ class AdminSelfUpgrade extends AdminSelfTab
private function _setFields()
{
$this->_fieldsAutoUpgrade['PS_AUTOUP_DONT_SAVE_IMAGES'] = array(
- 'title' => $this->l('Don\'t save images'), 'cast' => 'intval', 'validation' => 'isBool',
+ 'title' => $this->l('Also save images'), 'cast' => 'intval', 'validation' => 'isBool',
'type' => 'bool', 'desc'=>$this->l('You can exclude the image directory from backup if you already saved it by another method (not recommended)'),
);
@@ -259,6 +263,7 @@ class AdminSelfUpgrade extends AdminSelfTab
{
$allowed = (ConfigurationTest::test_fopen() && $this->rootWritable);
$allowed &= !Configuration::get('PS_SHOP_ENABLE');
+ $allowed &= (Configuration::get('PS_AUTOUP_KEEP_TRAD') !== false);
return $allowed;
}
@@ -272,7 +277,7 @@ class AdminSelfUpgrade extends AdminSelfTab
$allowed = (ConfigurationTest::test_fopen() && $this->rootWritable);
if (!defined('_PS_MODE_DEV_') OR !_PS_MODE_DEV_)
- $allowed &= $this->upgrader->autoupgrade;
+ $allowed &= $this->upgrader->autoupgrade_module;
return $allowed;
}
@@ -289,8 +294,11 @@ class AdminSelfUpgrade extends AdminSelfTab
$this->prodRootDir = _PS_ROOT_DIR_;
$this->adminDir = _PS_ADMIN_DIR_;
+ // from $_POST or $_GET
+ $this->action = empty($_REQUEST['action'])?null:$_REQUEST['action'];
+ $this->currentParams = empty($_REQUEST['params'])?null:$_REQUEST['params'];
// test writable recursively
- if(version_compare(_PS_VERSION_,'1.4.4.0','<'))
+ if(version_compare(_PS_VERSION_,'1.4.5.0','<'))
{
require_once('ConfigurationTest.php');
if(!class_exists('ConfigurationTest', false) AND class_exists('ConfigurationTestCore'))
@@ -299,25 +307,28 @@ class AdminSelfUpgrade extends AdminSelfTab
if (ConfigurationTest::test_dir($this->prodRootDir,true))
$this->rootWritable = true;
+ if (!in_array($this->action,array('upgradeFile', 'upgradeDb', 'upgradeComplete','rollback','restoreFiles','restoreDb')))
+ {
// checkPSVersion will be not
- $this->upgrader = new Upgrader(true);
+ $this->upgrader = new Upgrader();
$this->upgrader->checkPSVersion();
- if (version_compare(_PS_VERSION_,'1.4.4.0','<') OR $this->upgrader->need_standalone)
+ $this->currentParams['install_version'] = $this->upgrader->version_num;
+
+ if ($this->upgrader->autoupgrade_module)
$this->standalone = true;
else
$this->standalone = false;
+$this->standalone = true;
+ }
// If you have defined this somewhere, you know what you do
if (defined('_PS_ALLOW_UPGRADE_UNSTABLE_') AND _PS_ALLOW_UPGRADE_UNSTABLE_ AND function_exists('svn_checkout'))
{
- if(version_compare(_PS_VERSION_,'1.4.4.0','<') OR class_exists('Configuration',false))
+ if(version_compare(_PS_VERSION_,'1.4.5.0','<') OR class_exists('Configuration',false))
$this->useSvn = Configuration::get('PS_AUTOUP_USE_SVN');
}
else
$this->useSvn = false;
- // from $_POST or $_GET
- $this->action = empty($_REQUEST['action'])?null:$_REQUEST['action'];
- $this->currentParams = empty($_REQUEST['params'])?null:$_REQUEST['params'];
// If not exists in this sessions, "create"
// session handling : from current to next params
@@ -327,6 +338,18 @@ class AdminSelfUpgrade extends AdminSelfTab
if (isset($this->currentParams['filesToUpgrade']))
$this->nextParams['filesToUpgrade'] = $this->currentParams['filesToUpgrade'];
+ // set autoupgradePath, to be used in backupFiles and backupDb config values
+ $this->autoupgradePath = $this->adminDir.DIRECTORY_SEPARATOR.$this->autoupgradeDir;
+
+ if (!file_exists($this->autoupgradePath))
+ if (!@mkdir($this->autoupgradePath,0777))
+ $this->_errors[] = Tools::displayError(sprintf($this->l('unable to create directory %s'),$this->autoupgradePath));
+
+ $latest = $this->autoupgradePath.DIRECTORY_SEPARATOR.'latest';
+ if (!file_exists($latest))
+ if (!@mkdir($latest,0777))
+ $this->_errors[] = Tools::displayError(sprintf($this->l('unable to create directory %s'),$latest));
+
if (class_exists('Configuration',false))
{
$time = time();
@@ -351,26 +374,16 @@ class AdminSelfUpgrade extends AdminSelfTab
// backupFilesFilename should never etc.
$this->backupFilesFilename = $this->currentParams['backupFilesFilename'];
}
- $this->autoupgradePath = $this->adminDir.DIRECTORY_SEPARATOR.$this->autoupgradeDir;
-
- if (!file_exists($this->autoupgradePath))
- if (!@mkdir($this->autoupgradePath,0777))
- $this->_errors[] = Tools::displayError(sprintf($this->l('unable to create directory %s'),$this->autoupgradePath));
-
- $latest = $this->autoupgradePath.DIRECTORY_SEPARATOR.'latest';
- if (!file_exists($latest))
- if (!@mkdir($latest,0777))
- $this->_errors[] = Tools::displayError(sprintf($this->l('unable to create directory %s'),$latest));
$this->latestRootDir = $latest.DIRECTORY_SEPARATOR.'prestashop';
$this->adminDir = str_replace($this->prodRootDir,'',$this->adminDir);
- // @TODO future option
+ // @TODO future option "install in test dir"
// $this->testRootDir = $this->autoupgradePath.DIRECTORY_SEPARATOR.'test';
/* option */
if (class_exists('Configuration',false))
{
- $this->dontBackupImages = Configuration::get('PS_AUTOUP_DONT_SAVE_IMAGES');
+ $this->dontBackupImages = !Configuration::get('PS_AUTOUP_DONT_SAVE_IMAGES');
$this->keepDefaultTheme = Configuration::get('PS_AUTOUP_KEEP_DEFAULT_THEME');
$this->keepTrad = Configuration::get('PS_AUTOUP_KEEP_TRAD');
$this->manualMode = Configuration::get('PS_AUTOUP_MANUAL_MODE');
@@ -382,7 +395,7 @@ class AdminSelfUpgrade extends AdminSelfTab
$this->keepDefaultTheme = $this->currentParams['keepDefaultTheme'];
$this->keepTrad = $this->currentParams['keepTrad'];
$this->manualMode = $this->currentParams['manualMode'];
- $this->desactivateCustomModule = $this->current['desactivateCustomModule'];
+ $this->desactivateCustomModule = $this->currentParams['desactivateCustomModule'];
}
// We can add any file or directory in the exclude dir : theses files will be not removed or overwritten
// @TODO cache should be ignored recursively, but we have to reconstruct it after upgrade
@@ -398,6 +411,7 @@ class AdminSelfUpgrade extends AdminSelfTab
$this->excludeFilesFromUpgrade[] = '.svn';
$this->excludeFilesFromUpgrade[] = 'install';
$this->excludeFilesFromUpgrade[] = 'settings.inc.php';
+ // this will exclude autoupgrade dir from admin, and autoupgrade from modules
$this->excludeFilesFromUpgrade[] = 'autoupgrade';
$this->backupIgnoreFiles[] = '.';
$this->backupIgnoreFiles[] = '..';
@@ -493,7 +507,7 @@ class AdminSelfUpgrade extends AdminSelfTab
}
public function ajaxProcessUnzip(){
- if(version_compare(_PS_VERSION_,'1.4.4.0','<')
+ if(version_compare(_PS_VERSION_,'1.4.5.0','<')
AND !class_exists('Tools',false)
)
require_once('Tools.php');
@@ -556,9 +570,12 @@ class AdminSelfUpgrade extends AdminSelfTab
public function _listBackupFiles($dir)
{
+ static $list = array();
$allFiles = scandir($dir);
foreach ($allFiles as $file)
{
+ if ($file[0] != '.')
+ {
$fullPath = $dir.DIRECTORY_SEPARATOR.$file;
if (!$this->_skipFile($file, $fullPath,'backup'))
@@ -566,16 +583,18 @@ class AdminSelfUpgrade extends AdminSelfTab
if (is_dir($fullPath))
$this->_listBackupFiles($fullPath);
else
- $this->backupFileList[] = $fullPath;
+ $list[] = $fullPath;
}
else
- $this->backupIgnoreFiles[] = $fullPath;
-
+ $list[] = $fullPath;
}
}
+ file_put_contents($this->autoupgradePath.DIRECTORY_SEPARATOR.$this->toBackupFileList,serialize($list));
+ }
public function _listFilesToUpgrade($dir)
{
+ static $list = array();
$allFiles = scandir($dir);
foreach ($allFiles as $file)
{
@@ -583,20 +602,15 @@ class AdminSelfUpgrade extends AdminSelfTab
if (!$this->_skipFile($file, $fullPath, "upgrade"))
{
+ $list[] = $fullPath;
+ // if is_dir, we will create it :)
if (is_dir($fullPath))
- {
- // if is_dir, we will create it :)e it :)
- $this->toUpgradeFileList[] = $fullPath;
if (strpos($dir.DIRECTORY_SEPARATOR.$file, 'install') === false)
- {
$this->_listFilesToUpgrade($fullPath);
}
}
- else
- $this->toUpgradeFileList[] = $fullPath;
- }
- }
+ file_put_contents($this->autoupgradePath.DIRECTORY_SEPARATOR.$this->toUpgradeFileList,serialize($list));
$this->nextParams['filesToUpgrade'] = $this->toUpgradeFileList;
}
@@ -615,9 +629,9 @@ class AdminSelfUpgrade extends AdminSelfTab
// @TODO :
// foreach files in latest, copy
$this->next = 'upgradeFiles';
- if (!is_array($this->nextParams['filesToUpgrade']))
+ $filesToUpgrade = @unserialize(file_get_contents($this->nextParams['filesToUpgrade']));
+ if (!is_array($filesToUpgrade))
{
- error($this->nextParams);
$this->next = 'error';
$this->nextDesc = $this->l('filesToUpgrade is not an array');
$this->nextQuickInfo[] = $this->l('filesToUpgrade is not an array');
@@ -627,29 +641,31 @@ class AdminSelfUpgrade extends AdminSelfTab
// @TODO : does not upgrade files in modules, translations if they have not a correct md5 (or crc32, or whatever) from previous version
for ($i=0;$inextParams['filesToUpgrade'])<=0)
+ if (sizeof($filesToUpgrade)<=0)
{
$this->next = 'upgradeDb';
+ unlink($this->nextParams['filesToUpgrade']);
$this->nextDesc = $this->l('All files upgraded. Now upgrading database');
$this->nextResponseType = 'xml';
break;
}
- //$file = array_shift($this->nextParams['filesToUpgrade']);
- $file = array_shift($this->nextParams['filesToUpgrade']);
+ $file = array_shift($filesToUpgrade);
if (!$this->upgradeThisFile($file))
{
// put the file back to the begin of the list
- $totalFiles = array_unshift($this->nextParams['filesToUpgrade'],$file);
+ $totalFiles = array_unshift($filesToUpgrade,$file);
$this->next = 'error';
$this->nextQuickInfo[] = sprintf($this->l('error when trying to upgrade %s'),$file);
break;
}
else{
+ $this->nextQuickInfo[] = sprintf($this->l('copied %1$s. %2$s files left to upgrade.'),$file, sizeof($filesToUpgrade));
// @TODO : maybe put several files at the same times ?
- $this->nextDesc = sprintf($this->l('%2$s files left to upgrade.'),$file,sizeof($this->nextParams['filesToUpgrade']));
+ $this->nextDesc = sprintf($this->l('%2$s files left to upgrade.'),$file,sizeof($filesToUpgrade));
}
}
+ file_put_contents($this->nextParams['filesToUpgrade'],serialize($filesToUpgrade));
}
/**
@@ -692,10 +708,14 @@ class AdminSelfUpgrade extends AdminSelfTab
///////////////////////
// Copy from model.php
///////////////////////
+ if (!is_object($this->upgrader))
+ $this->upgrader = new Upgrader();
+
$upgrader = $this->upgrader;
+
$upgrader->checkPSVersion();
- define('INSTALL_VERSION', $upgrader->version_num);
+ define('INSTALL_VERSION', $this->currentParams['install_version']);
// now the install dir to use is in a subdirectory of the admin dir
define('INSTALL_PATH', realpath($this->latestRootDir.DIRECTORY_SEPARATOR.'install'));
@@ -733,14 +753,12 @@ class AdminSelfUpgrade extends AdminSelfTab
// 2) confirm config is correct (r/w rights)
// install/model.php?method=checkConfig&firsttime=0
// later
-
// 3) save current activated modules in nextParams, or don't desactivate them ?
// @TODO
// 4) upgrade
// install/model.php?_=1309193641470&method=doUpgrade&customModule=desactivate
if (!empty($this->currentParams['desactivateCustomModule']))
$_GET['customModule'] = 'desactivate';
-
if (!$this->_modelDoUpgrade())
{
$this->next = 'error';
@@ -775,13 +793,14 @@ class AdminSelfUpgrade extends AdminSelfTab
if (is_dir($file))
{
+ // if $dest is not a directory (that can happen), just remove that file
+ if (!is_dir($dest) AND file_exists($dest))
+ unlink($dest);
+
if (!file_exists($dest))
{
if (@mkdir($dest))
- {
- $this->nextQuickInfo[] = sprintf($this->l('created dir %2$s. %3$s files left to upgrade.'),$file, $dest, sizeof($this->nextParams['filesToUpgrade']));
return true;
- }
else
{
$this->next = 'error';
@@ -791,18 +810,13 @@ class AdminSelfUpgrade extends AdminSelfTab
}
}
else
- {
// directory already exists
return true;
}
- }
else
{
if (copy($file,$dest))
- {
- $this->nextQuickInfo[] = sprintf($this->l('copied %1$s in %2$s. %3$s files left to upgrade.'),$file, $dest, sizeof($this->nextParams['filesToUpgrade']));
return true;
- }
else
{
$this->next = 'error';
@@ -824,7 +838,7 @@ class AdminSelfUpgrade extends AdminSelfTab
{
$this->next = 'restoreFiles';
$this->status = 'ok';
- $this->nextDesc = $this->l('Files restored, now restoring database.');
+ $this->nextDesc = $this->l('Restoring files...');
}
else
{
@@ -832,7 +846,7 @@ class AdminSelfUpgrade extends AdminSelfTab
{
$this->next = 'restoreDb';
$this->status = 'ok';
- $this->nextDesc = $this->l('Database restored');
+ $this->nextDesc = $this->l('restoring Database ...');
}
else
{
@@ -841,6 +855,9 @@ class AdminSelfUpgrade extends AdminSelfTab
// all theses cases are handled by the method ajaxRequestRollback()
$this->next = ''; // next is empty : nothing next :)
$this->status = 'ok';
+ if (isset($this->currentParams['firstTime']))
+ $this->nextDesc = $this->l('Nothing has to be restored');
+ else
$this->nextDesc = $this->l('All your site is restored... ');
}
}
@@ -866,19 +883,18 @@ class AdminSelfUpgrade extends AdminSelfTab
$filepath = $this->backupFilesFilename;
$destExtract = $this->prodRootDir;
+
if (self::ZipExtract($filepath, $destExtract))
{
- // once it's restored, delete the file !
- unlink($this->backupFilesFilename);
- Configuration::updateValue('UPGRADER_BACKUPFILES_FILENAME', '');
- if (!empty($this->backupDbFilename))
+ // once it's restored, do not delete the archive file. This has to be done manually
+ if (!empty($this->backupDbFilename) AND file_exists($this->backupDbFilename) )
{
$this->nextDesc = $this->l('Files restored. No database backup found. Restoration done.');
- $this->next = '';
+ $this->next = 'rollback';
}
else
{
- $this->nextDesc = $this->l('Files restored.');
+ $this->nextDesc = $this->l('Files restored. No database backup found. Restoration done.');
$this->next = 'rollback';
}
return true;
@@ -906,6 +922,8 @@ class AdminSelfUpgrade extends AdminSelfTab
*/
public function ajaxProcessRestoreDb()
{
+ $this->_loadDbRelatedClasses();
+
$exts = explode('.', $this->backupDbFilename);
$fileext = $exts[count($exts)-1];
$requests = array();
@@ -947,12 +965,12 @@ class AdminSelfUpgrade extends AdminSelfTab
// This way we avoid extra blank lines
// option s (PCRE_DOTALL) added
// @TODO need to check if a ";" in description could block that (I suppose it can at the end of a line)
- preg_match_all('/.*;[\n]\+/s', $content, $requests);
+ preg_match_all('/(.*;)[\n\r]+/Usm', $content, $requests);
/* @TODO maybe improve regex pattern ... */
$db = Db::getInstance();
- if (count($requests)>0)
+ if (count($requests[0])>0)
{
- foreach ($requests as $request)
+ foreach ($requests[1] as $request)
if (!empty($request))
if (!$db->Execute($request))
$this->nextQuickInfo[] = $db->getMsgError();
@@ -968,8 +986,9 @@ class AdminSelfUpgrade extends AdminSelfTab
$this->nextDesc = 'Database restore done.';
}
- public function ajaxProcessBackupDb()
+ private function _loadDbRelatedClasses()
{
+ // Manual inclusion of all classes used
if(!class_exists('ObjectModel',false))
{
require_once(_PS_ROOT_DIR_.'/classes/ObjectModel.php');
@@ -983,12 +1002,6 @@ class AdminSelfUpgrade extends AdminSelfTab
if(!class_exists('Language',false))
eval('Class Language extends LanguageCore{}');
}
- if(!class_exists('Validate',false))
- {
- require_once(_PS_ROOT_DIR_.'/classes/Validate.php');
- if(!class_exists('Validate',false))
- eval('Class Validate extends ValidateCore{}');
- }
if(!class_exists('Db',false))
{
require_once(_PS_ROOT_DIR_.'/classes/Db.php');
@@ -1001,6 +1014,13 @@ class AdminSelfUpgrade extends AdminSelfTab
if(!class_exists('MySQL',false))
eval('Class MySQL extends MySQLCore{}');
}
+
+ if(!class_exists('Validate',false))
+ {
+ require_once(_PS_ROOT_DIR_.'/classes/Validate.php');
+ if(!class_exists('Validate',false))
+ eval('Class Validate extends ValidateCore{}');
+ }
if(!class_exists('Configuration',false))
{
require_once(_PS_ROOT_DIR_.'/classes/Configuration.php');
@@ -1021,6 +1041,11 @@ class AdminSelfUpgrade extends AdminSelfTab
define('_PS_MAGIC_QUOTES_GPC_', get_magic_quotes_gpc());
if(!defined('_PS_MYSQL_REAL_ESCAPE_STRING_'))
define('_PS_MYSQL_REAL_ESCAPE_STRING_', function_exists('mysql_real_escape_string'));
+ Configuration::loadConfiguration();
+ }
+ public function ajaxProcessBackupDb()
+ {
+ $this->_loadDbRelatedClasses();
$backup = new Backup();
// for backup db, use autoupgrade directory
@@ -1050,8 +1075,8 @@ class AdminSelfUpgrade extends AdminSelfTab
if (!isset($this->nextParams['filesForBackup']))
{
$list = $this->_listBackupFiles($this->prodRootDir);
- $this->nextQuickInfo[] = sprintf($this->l('%s Files to backup.'), sizeof($this->backupFileList));
- $this->nextParams['filesForBackup'] = $this->backupFileList;
+ $this->nextQuickInfo[] = sprintf($this->l('%s Files to backup.'), sizeof($this->toBackupFileList));
+ $this->nextParams['filesForBackup'] = $this->toBackupFileList;
// delete old backup, create new
if (file_exists($this->backupFilesFilename))
@@ -1059,12 +1084,13 @@ class AdminSelfUpgrade extends AdminSelfTab
$this->nextQuickInfo[] = sprintf($this->l('backup files initialized in %s'), $this->backupFilesFilename);
}
+ $filesToBackup = unserialize(file_get_contents($this->toBackupFileList));
/////////////////////
$this->next = 'backupFiles';
// @TODO : display % instead of this
- $this->nextDesc = sprintf($this->l('Backup files in progress. %s files left'), sizeof($this->nextParams['filesForBackup']));
- if (is_array($this->nextParams['filesForBackup']))
+ $this->nextDesc = sprintf($this->l('Backup files in progress. %s files left'), sizeof($filesToBackup));
+ if (is_array($filesToBackup))
{
// @TODO later
// 1) calculate crc32 of next file
@@ -1089,7 +1115,7 @@ class AdminSelfUpgrade extends AdminSelfTab
// @TODO min(self::$loopBackupFiles, sizeof())
for($i=0;$inextParams['filesForBackup'])<=0)
+ if (sizeof($filesToBackup)<=0)
{
$this->stepok = true;
$this->status = 'ok';
@@ -1099,11 +1125,11 @@ class AdminSelfUpgrade extends AdminSelfTab
break;
}
// filesForBackup already contains all the correct files
- $file = array_shift($this->nextParams['filesForBackup']);
- $archiveFilename = str_replace($this->prodRootDir,'',$file);
+ $file = array_shift($filesToBackup);
+ $archiveFilename = ltrim(str_replace($this->prodRootDir,'',$file),DIRECTORY_SEPARATOR);
// @TODO : maybe put several files at the same times ?
if ($zip->addFile($file,$archiveFilename))
- $this->nextQuickInfo[] = sprintf($this->l('%1$s added to archive. %2$s left.'),$file, sizeof($this->nextParams['filesForBackup']));
+ $this->nextQuickInfo[] = sprintf($this->l('%1$s added to archive. %2$s left.'),$file, sizeof($filesToBackup));
else
{
// if an error occur, it's more safe to delete the corrupted backup
@@ -1115,6 +1141,7 @@ class AdminSelfUpgrade extends AdminSelfTab
}
}
$zip->close();
+ file_put_contents($this->autoupgradePath.DIRECTORY_SEPARATOR.$this->toBackupFileList,serialize($filesToBackup));
return true;
}
else{
@@ -1157,7 +1184,6 @@ class AdminSelfUpgrade extends AdminSelfTab
public function ajaxProcessRemoveSamples(){
$this->stepDone = false;
- // @TODO : list exaustive list of files to remove :
// all images from img dir exept admin ?
// all images like logo, favicon, ?.
// all custom image from modules ?
@@ -1306,8 +1332,8 @@ class AdminSelfUpgrade extends AdminSelfTab
{
if(!$this->standalone)
{
- if (version_compare(_PS_VERSION_,'1.4.4.0','<') AND false)
- $this->_errors[] = Tools::displayError('This class depends of several files modified in 1.4.4.0 version and should not be used in an older version');
+ if (version_compare(_PS_VERSION_,'1.4.5.0','<') AND false)
+ $this->_errors[] = Tools::displayError('This class depends of several files modified in 1.4.5.0 version and should not be used in an older version');
}
parent::displayConf();
@@ -1336,7 +1362,7 @@ class AdminSelfUpgrade extends AdminSelfTab
}
}
- if ($this->apacheModExists('mod_evasive'))
+ if ($this->apacheModExists('evasive'))
sleep(1);
}
/**
@@ -1357,9 +1383,11 @@ class AdminSelfUpgrade extends AdminSelfTab
// we need strpos (example can be evasive20
foreach($apacheModuleList as $module)
- if (strpos($name, $module)!==false)
+ {
+ if (strpos($module, $name)!==false)
return true;
}
+ }
else{
// If apache_get_modules does not exists,
// one solution should be parsing httpd.conf,
@@ -1377,7 +1405,7 @@ class AdminSelfUpgrade extends AdminSelfTab
private function _getJsErrorMsgs()
{
- $INSTALL_VERSION = $this->upgrader->version_num;
+ $INSTALL_VERSION = $this->currentParams['install_version'];
$ret = '
var txtError = new Array();
txtError[0] = "'.$this->l('Required field').'";
@@ -1501,11 +1529,11 @@ txtError[37] = "'.$this->l('The config/defines.inc.php file was not found. Where
$srcExecTime = '../img/admin/warning.gif';
echo ''.$this->l('PHP time limit').' : '.''.($max_exec_time == 0?$this->l('disabled'):$max_exec_time.' '.$this->l('seconds')).'
';
echo ''.$this->l('Modify your options').'';
echo '';
@@ -1556,7 +1584,7 @@ txtError[37] = "'.$this->l('The config/defines.inc.php file was not found. Where
- if (defined('_PS_MODE_DEV_') AND _PS_MODE_DEV_)
+ if (defined('_PS_MODE_DEV_') AND _PS_MODE_DEV_ AND $this->manualMode)
{
echo ' ';
echo '