### 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')."
  • "; $error=true; } @@ -168,33 +167,33 @@ setGlobalSetting('updatekey',sanitize_paranoid_string($_POST['updatekey'])); } $error=false; - $output='
    '.$clang->gT('Welcome to the ComfortUpdate').'

    '; - $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('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('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.="
    '; - $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 "
    '; + echo '
    '; } else { - $output.="

    '.$clang->gT('Change log').'

    '; require_once($homedir."/classes/http/http.php"); $updatekey=getGlobalSetting('updatekey'); @@ -218,7 +217,7 @@ $full_body .= $body; } $changelog=json_decode($full_body,true); - $output.=''; + echo ''; } else { @@ -229,19 +228,18 @@ if ($error) { - $output.='

    '.$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.='
    '; - return $output; + echo '
    '; } @@ -254,7 +252,7 @@ require_once($homedir."/classes/http/http.php"); $updatekey=getGlobalSetting('updatekey'); - $output='
    '.sprintf($clang->gT('ComfortUpdate step %s'),'2').'

    '; + echo '
    '.sprintf($clang->gT('ComfortUpdate step %s'),'2').'

    '; $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.')."

    @@ -349,63 +347,62 @@ } } - $output.='

    '.$clang->gT('Checking existing LimeSurvey files...').'

    '; + echo '

    '.$clang->gT('Checking existing LimeSurvey files...').'

    '; 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='
    '.sprintf($clang->gT('ComfortUpdate step %s'),'3').'
    '; - $output.='

    '.$clang->gT('Creating DB & file backup').'

    '; + echo '
    '.sprintf($clang->gT('ComfortUpdate step %s'),'3').'
    '; + echo '

    '.$clang->gT('Creating DB & file backup').'

    '; 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').'

    '; + echo "".$clang->gT('File backup created:').' '.htmlspecialchars($tempdir.DIRECTORY_SEPARATOR.'files-'.$basefilename.'.zip').'

    '; } @@ -472,23 +469,22 @@ if ($databasetype=='mysql' || $databasetype=='mysqli') { - $output.=$clang->gT('Creating database backup... ').'
    '; + echo $clang->gT('Creating database backup... ').'
    '; $byteswritten=file_put_contents($tempdir.DIRECTORY_SEPARATOR.'db-'.$basefilename.'.sql',completedump()); if ($byteswritten>5000) { - $output.="".$clang->gT('DB backup created:')." ".htmlspecialchars($tempdir.DIRECTORY_SEPARATOR.'db-'.$basefilename.'.sql').'

    '; + echo "".$clang->gT('DB backup created:')." ".htmlspecialchars($tempdir.DIRECTORY_SEPARATOR.'db-'.$basefilename.'.sql').'

    '; } } 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 '
    '; } @@ -496,18 +492,18 @@ { global $clang, $scriptname, $homedir, $buildnumber, $updatebuild, $debug, $rootdir, $publicdir, $tempdir, $database_exists, $databasetype, $action, $demoModeOnly; - $output='
    '.sprintf($clang->gT('ComfortUpdate step %s'),'4').'

    '; + echo '
    '.sprintf($clang->gT('ComfortUpdate step %s'),'4').'

    '; 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:').'

      '; - $output.="
    • " .$clang->gT('Database type') . ": " . $databasetype . "
    • "; - $output.="
    • " .$clang->gT('Database name') . ": " . $databasename . "
    • "; - $output.="
    • " .$clang->gT('Table prefix') . ": " . $dbprefix . "
    • "; - $output.="
    • " .$clang->gT('Site name') . ": " . $sitename . "
    • "; - $output.="
    • " .$clang->gT('Root URL') . ": " . $rooturl . "
    • "; - $output.='
    '; - $output.="
    "; - $output.="" . $clang->gT('Click here to continue') . ""; - $output.="
    "; - return $output; + echo "
    ".$clang->gT('Database upgrade').'

    '; + echo $clang->gT('Please verify the following information before continuing with the database upgrade:').'

      '; + echo "
    • " .$clang->gT('Database type') . ": " . $databasetype . "
    • "; + echo "
    • " .$clang->gT('Database name') . ": " . $databasename . "
    • "; + echo "
    • " .$clang->gT('Table prefix') . ": " . $dbprefix . "
    • "; + echo "
    • " .$clang->gT('Site name') . ": " . $sitename . "
    • "; + echo "
    • " .$clang->gT('Root URL') . ": " . $rooturl . "
    • "; + echo '
    '; + echo "
    "; + echo "" . $clang->gT('Click here to continue') . ""; + echo "
    "; } ?>