### Eclipse Workspace Patch 1.0
#P Limesurvey 1.x trunk stable
Index: admin/update/updater.php
===================================================================
--- admin/update/updater.php (revision 10155)
+++ admin/update/updater.php (working copy)
@@ -12,31 +12,30 @@
*
* $Id: updater.php 8987 2010-07-27 12:59:34Z c_schmitz $
*/
-$updaterversion=explode(' ','$Rev$'); // this is updated by subversion so don't change this string
-$updaterversion=$updaterversion[1];
+list(,$updaterversion)=explode(' ','$Rev$'); // this is updated by subversion so don't change this string
if (isset($_REQUEST['update'])) die();
-if ($action=='update'){
- if ($subaction=='step4')
- {
- $adminoutput=UpdateStep4();
- }
- elseif ($subaction=='step3')
- {
- $adminoutput=UpdateStep3();
- }
- elseif ($subaction=='step2')
- {
- $adminoutput=UpdateStep2();
- }
- else
- {
- $adminoutput=RunUpdaterUpdate();
- $adminoutput=UpdateStep1();
-}
+if ($action!=='update') return;
+
+ob_start();
+switch ($subaction)
+{
+ case 'step2':
+ case 'step3':
+ case 'step4':
+ $updatefunction = 'Update'.ucfirst($subaction);
+ break;
+ default:
+ $updatefunction = 'UpdateStep1';
+ RunUpdaterUpdate();
}
+$buffer = $updatefunction();
+if ($buffer) echo $buffer;
+$adminoutput = ob_get_clean();
+
+return;
function RunUpdaterUpdate()
{
@@ -86,12 +85,12 @@
if (!is_writable($tempdir))
{
- $output.= "
".sprintf($clang->gT("Tempdir %s is not writable"),$tempdir)."
";
+ echo "
".sprintf($clang->gT("Tempdir %s is not writable"),$tempdir)."
";
$error=true;
}
if (!is_writable($homedir.DIRECTORY_SEPARATOR.'update'.DIRECTORY_SEPARATOR.'updater.php'))
{
- $output.= "
".sprintf($clang->gT("Updater file is not writable (%s). Please set according file permissions."),$homedir.DIRECTORY_SEPARATOR.'update'.DIRECTORY_SEPARATOR.'updater.php')."
";
+ echo "
".sprintf($clang->gT("Updater file is not writable (%s). Please set according file permissions."),$homedir.DIRECTORY_SEPARATOR.'update'.DIRECTORY_SEPARATOR.'updater.php')."
';
- $output.=$clang->gT('The LimeSurvey ComfortUpdate is an easy procedure to quickly update to the latest version of LimeSurvey.').' ';
- $output.=$clang->gT('The following steps will be done by this update:').'
';
- $output.='
'.$clang->gT('Your LimeSurvey installation is checked if the update can be run successfully.').'
';
- $output.='
'.$clang->gT('Your DB and any changed files will be backed up.').'
';
- $output.='
'.$clang->gT('New files will be downloaded and installed.').'
';
- $output.='
'.$clang->gT('If necessary the database will be updated.').'
';
- $output.='
'.$clang->gT('Checking basic requirements...').'
';
+ echo '
'.$clang->gT('Welcome to the ComfortUpdate').'
';
+ echo $clang->gT('The LimeSurvey ComfortUpdate is an easy procedure to quickly update to the latest version of LimeSurvey.').' ';
+ echo $clang->gT('The following steps will be done by this update:').'
';
+ echo '
'.$clang->gT('Your LimeSurvey installation is checked if the update can be run successfully.').'
';
+ echo '
'.$clang->gT('Your DB and any changed files will be backed up.').'
';
+ echo '
'.$clang->gT('New files will be downloaded and installed.').'
';
+ echo '
'.$clang->gT('If necessary the database will be updated.').'
';
+ echo '
'.$clang->gT('Checking basic requirements...').'
';
if ($updatekey==''){
- $output.=$clang->gT('You need an update key to run the comfort update. During the beta test of this update feature the key "LIMESURVEYUPDATE" can be used.');
- $output.=" ';
+ echo $clang->gT('You need an update key to run the comfort update. During the beta test of this update feature the key "LIMESURVEYUPDATE" can be used.');
+ echo " ';
}
else {
- $output.="
".$clang->gT('Update key: Valid')."
";
+ echo "
".$clang->gT('Update key: Valid')."
";
if (!is_writable($tempdir))
{
- $output.= "
".sprintf($clang->gT("Tempdir %s is not writable"),$tempdir)."
";
+ echo "
".sprintf($clang->gT("Tempdir %s is not writable"),$tempdir)."
";
$error=true;
}
if (!is_writable($rootdir.DIRECTORY_SEPARATOR.'version.php'))
{
- $output.= "
".sprintf($clang->gT("Version file is not writable (%s). Please set according file permissions."),$rootdir.DIRECTORY_SEPARATOR.'version.php')."
";
+ echo "
".sprintf($clang->gT("Version file is not writable (%s). Please set according file permissions."),$rootdir.DIRECTORY_SEPARATOR.'version.php')."
'.$clang->gT('When checking your installation we found one or more problems. Please check for any error messages above and fix these before you can proceed.');
- $output.="";
+ echo '
'.$clang->gT('When checking your installation we found one or more problems. Please check for any error messages above and fix these before you can proceed.');
+ echo "";
}
else
{
- $output.='
'.$clang->gT('Everything looks alright. Please proceed to the next step.');
- $output.="";
+ echo '
'.$clang->gT('Everything looks alright. Please proceed to the next step.');
+ echo "";
}
- $output.='
';
$http=new http_class;
/* Connection timeout */
@@ -285,15 +283,15 @@
if (isset($updateinfo['error']))
{
- $output.=$clang->gT('On requesting the update information from limesurvey.org there has been an error:').' ';
+ echo $clang->gT('On requesting the update information from limesurvey.org there has been an error:').' ';
if ($updateinfo['error']==1)
{
setGlobalSetting('updatekey','');
- $output.=$clang->gT('Your update key is invalid and was removed. ').' ';
+ echo $clang->gT('Your update key is invalid and was removed. ').' ';
}
else
- $output.=$clang->gT('On requesting the update information from limesurvey.org there has been an error:').' ';
+ echo $clang->gT('On requesting the update information from limesurvey.org there has been an error:').' ';
}
// okay, updateinfo now contains all necessary updateinformation
// Now check if the existing files have the mentioned checksum
@@ -302,7 +300,7 @@
$readonlyfiles=array();
if (!isset($updateinfo['files']))
{
- $output.="
+ echo "
".$clang->gT('Update server busy')."
".$clang->gT('The update server is currently busy. This usually happens when the update files for a new version are being prepared.')."
".$clang->gT('Please be patient and try again in about 10 minutes.')."
';
if (count($readonlyfiles)>0)
{
- $output.=''.$clang->gT('Warning: The following files/directories need to be updated but their permissions are set to read-only.').' ';
- $output.=$clang->gT('You must set according write permissions on these filese before you can proceed. If you are unsure what to do please contact your system administrator for advice.').' ';
- $output.='
';
+ echo ''.$clang->gT('Warning: The following files/directories need to be updated but their permissions are set to read-only.').' ';
+ echo $clang->gT('You must set according write permissions on these filese before you can proceed. If you are unsure what to do please contact your system administrator for advice.').' ';
+ echo '
';
$readonlyfiles=array_unique($readonlyfiles);
sort($readonlyfiles);
foreach ($readonlyfiles as $readonlyfile)
{
- $output.='
'.htmlspecialchars($readonlyfile).'
';
+ echo '
'.htmlspecialchars($readonlyfile).'
';
}
- $output.='
';
+ echo '
';
}
if (count($existingfiles)>0)
{
- $output.=$clang->gT('The following files would be added by the update but already exist. This is very unusual and may be co-incidental.').' ';
- $output.=$clang->gT('We recommend that these files should be replaced by the update procedure.').' ';
- $output.='
';
+ echo $clang->gT('The following files would be added by the update but already exist. This is very unusual and may be co-incidental.').' ';
+ echo $clang->gT('We recommend that these files should be replaced by the update procedure.').' ';
+ echo '
';
sort($existingfiles);
foreach ($existingfiles as $existingfile)
{
- $output.='
'.htmlspecialchars($existingfile['file']).'
';
+ echo '
'.htmlspecialchars($existingfile['file']).'
';
}
- $output.='
';
+ echo '
';
}
if (count($modifiedfiles)>0)
{
- $output.=$clang->gT('The following files will be modified or deleted but were already modified by someone else.').' ';
- $output.=$clang->gT('We recommend that these files should be replaced by the update procedure.').' ';
- $output.='
';
+ echo $clang->gT('The following files will be modified or deleted but were already modified by someone else.').' ';
+ echo $clang->gT('We recommend that these files should be replaced by the update procedure.').' ';
+ echo '
';
sort($modifiedfiles);
foreach ($modifiedfiles as $modifiedfile)
{
- $output.='
'.htmlspecialchars($modifiedfile['file']).'
';
+ echo '
'.htmlspecialchars($modifiedfile['file']).'
';
}
- $output.='
';
+ echo '
';
}
if (count($readonlyfiles)>0)
{
- $output.=' '.$clang->gT('When checking your file permissions we found one or more problems. Please check for any error messages above and fix these before you can proceed.');
- $output.="";
+ echo ' '.$clang->gT('When checking your file permissions we found one or more problems. Please check for any error messages above and fix these before you can proceed.');
+ echo "";
}
else
{
- $output.=$clang->gT('Please check any problems above and then proceed to the next step.').' ';
- $output.="";
+ echo $clang->gT('Please check any problems above and then proceed to the next step.').' ';
+ echo "";
}
}
$_SESSION['updateinfo']=$updateinfo;
$_SESSION['updatesession']=$site_cookies;
- return $output;
}
@@ -413,19 +410,19 @@
{
global $clang, $scriptname, $homedir, $buildnumber, $updatebuild, $debug, $rootdir, $publicdir, $tempdir, $database_exists, $databasetype, $action, $demoModeOnly;
- $output='
';
if (!isset( $_SESSION['updateinfo']))
{
- $output.=$clang->gT('On requesting the update information from limesurvey.org there has been an error:').' ';
+ echo $clang->gT('On requesting the update information from limesurvey.org there has been an error:').' ';
if ($updateinfo['error']==1)
{
setGlobalSetting('updatekey','');
- $output.=$clang->gT('Your update key is invalid and was removed. ').' ';
+ echo $clang->gT('Your update key is invalid and was removed. ').' ';
}
else
- $output.=$clang->gT('On requesting the update information from limesurvey.org there has been an error:').' ';
+ echo $clang->gT('On requesting the update information from limesurvey.org there has been an error:').' ';
}
else
{
@@ -457,14 +454,14 @@
$v_list = $archive->add($filestozip, PCLZIP_OPT_REMOVE_PATH, $publicdir);
- $output.=$clang->gT('Creating file backup... ').' ';
+ echo $clang->gT('Creating file backup... ').' ';
if ($v_list == 0) {
die("Error : ".$archive->errorInfo(true));
}
else
{
- $output.="".$clang->gT('File backup created:').' '.htmlspecialchars($tempdir.DIRECTORY_SEPARATOR.'files-'.$basefilename.'.zip').'
';
}
}
else
{
- $output.="".$clang->gT('No DB backup created:').' '.$clang->gT('Database backup functionality is currently not available for your database type. Before proceeding please backup your database using a backup tool!').'
';
+ echo "".$clang->gT('No DB backup created:').' '.$clang->gT('Database backup functionality is currently not available for your database type. Before proceeding please backup your database using a backup tool!').'
';
}
- $output.=$clang->gT('Please check any problems above and then proceed to the final step.');
- $output.="";
- $output.='
';
- return $output;
+ echo $clang->gT('Please check any problems above and then proceed to the final step.');
+ echo "";
+ echo '
';
if (!isset( $_SESSION['updateinfo']))
{
- $output.=$clang->gT('On requesting the update information from limesurvey.org there has been an error:').' ';
+ echo $clang->gT('On requesting the update information from limesurvey.org there has been an error:').' ';
if ($updateinfo['error']==1)
{
setGlobalSetting('updatekey','');
- $output.=$clang->gT('Your update key is invalid and was removed. ').' ';
+ echo $clang->gT('Your update key is invalid and was removed. ').' ';
}
else
- $output.=$clang->gT('On requesting the update information from limesurvey.org there has been an error:').' ';
+ echo $clang->gT('On requesting the update information from limesurvey.org there has been an error:').' ';
}
else
{
@@ -569,7 +565,7 @@
else{
rmdirr($rootdir.$afile['file']);
}
- $output.=sprintf($clang->gT('File deleted: %s'),$afile['file']).' ';
+ echo sprintf($clang->gT('File deleted: %s'),$afile['file']).' ';
}
}
@@ -581,13 +577,13 @@
}
else
{
- $output.=$clang->gT('New files were successfully installed.').' ';
+ echo $clang->gT('New files were successfully installed.').' ';
unlink($tempdir.'/update.zip');
}
}
else
{
- $output.=$clang->gT('There was a problem downloading the update file. Please try to restart the update process.').' ';
+ echo $clang->gT('There was a problem downloading the update file. Please try to restart the update process.').' ';
$downloaderror=true;
}
// PclTraceDisplay();
@@ -607,16 +603,15 @@
fwrite($handle,$line);
}
fclose($handle);
- $output.=sprintf($clang->gT('Buildnumber was successfully updated to %s.'),$_SESSION['updateinfo']['toversion']).' ';
- $output.=$clang->gT('Please check any problems above - update was done.').' ';
+ echo sprintf($clang->gT('Buildnumber was successfully updated to %s.'),$_SESSION['updateinfo']['toversion']).' ';
+ echo $clang->gT('Please check any problems above - update was done.').' ';
}
- $output.="";
- $output.='
';
+ echo "";
+ echo '
';
setGlobalSetting('updatelastcheck','1980-01-01 00:00');
setGlobalSetting('updateavailable','0');
- return $output;
}
/**
@@ -644,7 +639,7 @@
echo " ".sprintf($clang->gT("Database has been successfully upgraded to version %s"),$dbversionnumber);
}
else {
- return ShowDBUpgradeNotice();
+ ShowDBUpgradeNotice();
}
}
}
@@ -652,18 +647,17 @@
function ShowDBUpgradeNotice() {
global $databasetype, $dbprefix, $databasename, $sitename, $rooturl,$clang;
$error=false;
- $output="
".$clang->gT('Database upgrade').'
';
- $output.=$clang->gT('Please verify the following information before continuing with the database upgrade:').'