// Merge -> revision 8624

This commit is contained in:
rMalie
2011-09-16 15:02:29 +00:00
parent 72e890b65c
commit c0224d4958
7 changed files with 281 additions and 87 deletions
+64 -2
View File
@@ -457,7 +457,19 @@ $this->standalone = true;
$this->nextDesc = $this->l('Upgrade process done. Congratulations ! You can now reactive your shop.');
$this->next = '';
}
public function ajaxProcessCheckFilesVersion()
{
if ($testOrigCore = $this->upgrader->isAuthenticPrestashopVersion() !== false)
$this->nextParams['status'] = 'ok';
else
$this->nextParams['status'] = 'nok';
$changedFileList = $this->upgrader->getChangedFilesList();
// echo '<img src="'.$originalCore.'" /> '.
$this->nextParams['msg'] = ($testOrigCore?$this->l('Core files are ok'):sprintf($this->l('%s core files have been modified'), sizeof($changedFileList)));
$this->nextParams['result'] = $changedFileList;
}
public function ajaxProcessUpgradeNow()
{
$this->nextDesc = $this->l('Starting upgrade ...');
@@ -1570,7 +1582,11 @@ txtError[37] = "'.$this->l('The config/defines.inc.php file was not found. Where
$configurationDone = '../img/admin/disabled.gif';
echo '<b>'.$this->l('Options chosen').' : </b>'.'<img src="'.$configurationDone.'" /> '.($testConfigDone?$this->l('autoupgrade configuration ok'):$this->l('Please configure autoupgrade options')).'<br/><br/>';
echo '<a class="button" id="scrollToOptions" href="#options">'.$this->l('Modify your options').'</a>';
echo '<b>'.$this->l('PrestaShop Original version').' : </b>'.'<span id="checkPrestaShopFilesVersion">
<img id="pleaseWait" src="'.__PS_BASE_URI__.'img/loader.gif"/>
</span>';
echo '<p> <a class="button" id="scrollToOptions" href="#options">'.$this->l('Modify your options').'</a></p>';
echo '</fieldset>';
echo '<br/>';
@@ -1687,6 +1703,8 @@ echo '</script>';
.button-autoupgrade {-moz-border-bottom-colors: none;-moz-border-image: none;-moz-border-left-colors: none;-moz-border-right-colors: none;-moz-border-top-colors: none;border-color: #FFF6D3 #DFD5AF #DFD5AF #FFF6D3;border-right: 1px solid #DFD5AF;border-style: solid;border-width: 1px;color: #268CCD;font-size: medium;padding: 5px;}
.processing {border:2px outset grey;margin-top:1px;overflow: auto;}
#dbResultCheck{ padding-left:20px;}
#checkPrestaShopFilesVersion{margin-bottom:20px;}
#changedList ul{list-style-type:circle}
</style>';
$this->displayWarning($this->l('This function is experimental. It\'s highly recommended to make a backup of your files and database before starting the upgrade process.'));
@@ -1882,8 +1900,8 @@ function afterUpgradeDb()
{
// console.info("inside afterUpgradeDb");
// console.log(resGlobal);
}
function afterUpgradeComplete()
{
$("#pleaseWait").hide();
@@ -2093,6 +2111,50 @@ function handleError(res)
}
}
';
// ajax to check md5 files
$js.= '$(document).ready(function(){
$.ajax({
type:"POST",
url : "'.($this->standalone? __PS_BASE_URI__ . trim($this->adminDir,DIRECTORY_SEPARATOR).'/autoupgrade/ajax-upgradetab.php' : str_replace('index','ajax-tab',$currentIndex)).'",
async: true,
data : {
dir:"'.trim($this->adminDir,DIRECTORY_SEPARATOR).'",
token : "'.$this->token.'",
tab : "'.get_class($this).'",
action : "checkFilesVersion",
params : {}
},
success : function(res,textStatus,jqXHR)
{
res = $.parseJSON(res);
answer = res.nextParams;
$("#checkPrestaShopFilesVersion").html("<span>"+answer.msg+"</span> ");
$("#checkPrestaShopFilesVersion").append("<a id=\"toggleChangedList\" class=\"button\" href=\"\">'.$this->l('See or hide the list').'</a><br/>");
$("#checkPrestaShopFilesVersion").append("<div id=\"changedList\" style=\"display:none \">");
$("#changedList").html("<ul>");
$(answer.result).each(function(k,v){
$("#changedList ul").append("<li>"+v+"</li>");
});
$("#toggleChangedList").bind("click",function(e){e.preventDefault();$("#changedList").toggle();});
}
,
error: function(res,textStatus,jqXHR)
{
if (textStatus == "timeout" && action == "download")
{
updateInfoStep("'.$this->l('Your server can\'t download the file. Please upload it first by ftp in your admin/autoupgrade directory').'");
}
else
{
updateInfoStep("[Server Error] Status message : " + textStatus);
}
}
})
});';
return $js;
}
private function _cleanUp($path)
+64
View File
@@ -28,6 +28,7 @@
class UpgraderCore{
const DEFAULT_CHECK_VERSION_DELAY_HOURS = 24;
public $rss_version_link = 'http://www.prestashop.com/xml/version.xml';
public $rss_md5file_link_dir = 'http://www.prestashop.com/xml/md5/';
/**
* link contains hte url where to download the file
*
@@ -35,6 +36,8 @@ class UpgraderCore{
*/
private $needUpgrade = false;
private $noRefresh = false;
private $changedFiles = array();
private $missingFiles = array();
public $version_name;
public $version_num;
@@ -158,4 +161,65 @@ class UpgraderCore{
return false;
}
public function getChangedFilesList()
{
$checksum = simplexml_load_file($this->rss_md5file_link_dir._PS_VERSION_.'.xml');
if ($checksum === false)
throw new Exception('No checksum xml file for your Prestashop version');
$this->browseXmlAndCompare($checksum);
return $this->changedFiles;
}
protected function addChangedFile($path)
{
$this->versionIsModified = true;
$this->changedFiles[] = $path;
//array_unique($this->changedFiles);
}
protected function addMissingFile($path)
{
$this->versionIsModified = true;
$this->missingFiles[] = $path;
//array_unique($this->missingFile);
}
protected function browseXmlAndCompare($node, &$currentPath = array(), $level = 0)
{
foreach ($node as $key => $child)
{
if (is_object($child) && $child->getName() != 'md5file')
{
$level += 1;
$currentPath[$level] = $child->getName();
$this->browseXmlAndCompare($child, $currentPath, $level);
$level -= 1;
}
else
{
$path = '';
for ($i=1;$i<=$level;$i++)
$path .= $currentPath[$i].'/';
$path .= (string)$child->attributes()->name;
$path = str_replace('ps_root_dir',_PS_ROOT_DIR_,$path);
if(!file_exists($path))
$this->addMissingFile($path);
else if (!$this->compareChecksum($path, (string)$child->attributes()->sum))
$this->addChangedFile($path);
}
}
}
protected function compareChecksum($path, $originalSum)
{
if (md5_file($path) == $originalSum)
return true;
return false;
}
public function isAuthenticPrestashopVersion()
{
return !$this->versionIsModified;
}
}
+1
View File
@@ -0,0 +1 @@
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';5(10.M)(w($){$.N({11:w(j,k){5(!j)t{};w B(d,e){5(!d)t y;6 f=\'\',2=y,E=y;6 g=d.x,12=l(d.O||d.P);6 h=d.v||d.F||\'\';5(d.G){5(d.G.7>0){$.Q(d.G,w(n,a){6 b=a.x,u=l(a.O||a.P);6 c=a.v||a.F||\'\';5(b==8){t}z 5(b==3||b==4||!u){5(c.13(/^\\s+$/)){t};f+=c.H(/^\\s+/,\'\').H(/\\s+$/,\'\')}z{2=2||{};5(2[u]){5(!2[u].7)2[u]=p(2[u]);2[u][2[u].7]=B(a,R);2[u].7=2[u].7}z{2[u]=B(a)}}})}};5(d.I){5(d.I.7>0){E={};2=2||{};$.Q(d.I,w(a,b){6 c=l(b.14),C=b.15;E[c]=C;5(2[c]){5(!2[c].7)2[c]=p(2[c]);2[c][2[c].7]=C;2[c].7=2[c].7}z{2[c]=C}})}};5(2){2=$.N((f!=\'\'?A J(f):{}),2||{});f=(2.v)?(D(2.v)==\'16\'?2.v:[2.v||\'\']).17([f]):f;5(f)2.v=f;f=\'\'};6 i=2||f;5(k){5(f)i={};f=i.v||f||\'\';5(f)i.v=f;5(!e)i=p(i)};t i};6 l=w(s){t J(s||\'\').H(/-/g,"18")};6 m=w(s){t(D s=="19")||J((s&&D s=="K")?s:\'\').1a(/^((-)?([0-9]*)((\\.{0,1})([0-9]+))?$)/)};6 p=w(o){5(!o.7)o=[o];o.7=o.7;t o};5(D j==\'K\')j=$.S(j);5(!j.x)t;5(j.x==3||j.x==4)t j.F;6 q=(j.x==9)?j.1b:j;6 r=B(q,R);j=y;q=y;t r},S:w(a){6 b;T{6 c=($.U.V)?A 1c("1d.1e"):A 1f();c.1g=W}X(e){Y A L("Z 1h 1i 1j 1k 1l")};T{5($.U.V)b=(c.1m(a))?c:W;z b=c.1n(a,"v/1o")}X(e){Y A L("L 1p Z K")};t b}})})(M);',62,88,'||obj|||if|var|length||||||||||||||||||||||return|cnn|text|function|nodeType|null|else|new|parseXML|atv|typeof|att|nodeValue|childNodes|replace|attributes|String|string|Error|jQuery|extend|localName|nodeName|each|true|text2xml|try|browser|msie|false|catch|throw|XML|window|xml2json|nn|match|name|value|object|concat|_|number|test|documentElement|ActiveXObject|Microsoft|XMLDOM|DOMParser|async|Parser|could|not|be|instantiated|loadXML|parseFromString|xml|parsing'.split('|'),0,{}))