From cc8482a952e52cc5baa8033257013ce7d1ad0c8d Mon Sep 17 00:00:00 2001 From: louis Date: Thu, 30 Jul 2015 12:40:13 +0200 Subject: [PATCH] - Fixed Issue : tab/space mix - Dev : find . -name '*.php' ! -type d -exec bash -c 'expand -t 4 "$0" > /tmp/e && mv /tmp/e "$0"' {} \; --- .../controllers/admin/globalsettings.php | 2 +- application/controllers/admin/update.php | 768 +++---- application/core/Survey_Common_Action.php | 1 + application/models/UpdateForm.php | 1758 ++++++++--------- .../views/admin/globalSettings_view.php | 2 +- .../views/admin/update/_ajaxVariables.php | 16 +- .../views/admin/update/_updateContainer.php | 24 +- .../admin/update/_update_notification.php | 6 +- .../update/check_updates/_checkButtons.php | 114 +- .../update_buttons/_updatesavailable.php | 64 +- .../_updatesavailable_error.php | 92 +- .../views/admin/update/updater/_error.php | 272 +-- .../views/admin/update/updater/_progress.php | 52 +- .../admin/update/updater/_right_container.php | 20 +- .../views/admin/update/updater/_updater.php | 16 +- .../admin/update/updater/steps/_backup.php | 124 +- .../update/updater/steps/_change_log.php | 60 +- .../updater/steps/_check_local_errors.php | 182 +- .../update/updater/steps/_fileSystem.php | 102 +- .../admin/update/updater/steps/_final.php | 12 +- .../update/updater/steps/_updater_updated.php | 18 +- .../steps/textaeras/_existingfiles.php | 16 +- .../steps/textaeras/_modifiedfiles.php | 14 +- .../steps/textaeras/_readonlyfiles.php | 18 +- .../admin/update/updater/welcome/_error.php | 114 +- .../welcome/_error_files_update_updater.php | 26 +- .../update/updater/welcome/_key_updated.php | 12 +- .../update/updater/welcome/_subscribe.php | 40 +- .../updater/welcome/_updater_update.php | 26 +- .../admin/update/updater/welcome/_welcome.php | 80 +- 30 files changed, 2026 insertions(+), 2025 deletions(-) mode change 100755 => 100644 application/views/admin/update/check_updates/update_buttons/_updatesavailable.php mode change 100755 => 100644 application/views/admin/update/check_updates/update_buttons/_updatesavailable_error.php mode change 100755 => 100644 application/views/admin/update/updater/steps/_backup.php mode change 100755 => 100644 application/views/admin/update/updater/steps/_change_log.php mode change 100755 => 100644 application/views/admin/update/updater/steps/_fileSystem.php mode change 100755 => 100644 application/views/admin/update/updater/steps/_final.php diff --git a/application/controllers/admin/globalsettings.php b/application/controllers/admin/globalsettings.php index bdf35c80d8a..83cb85b2c66 100755 --- a/application/controllers/admin/globalsettings.php +++ b/application/controllers/admin/globalsettings.php @@ -40,7 +40,7 @@ function __construct($controller, $id) public function index() { if (!empty($_POST['action'])) { - $this->_saveSettings(); + $this->_saveSettings(); } $this->_displaySettings(); } diff --git a/application/controllers/admin/update.php b/application/controllers/admin/update.php index b193cbb6929..5e42c441861 100755 --- a/application/controllers/admin/update.php +++ b/application/controllers/admin/update.php @@ -17,8 +17,8 @@ /** * Update Controller * -* @package LimeSurvey -* @subpackage Backend +* @package LimeSurvey +* @subpackage Backend * * This controller performs updates, it is highly ajax oriented * Methods are only called from JavaScript controller (wich is called from the global_setting view). comfortupdater.js is the first registred script. @@ -26,9 +26,9 @@ * * * Public methods are written in a chronological way : -* - First, when the user click on the "check for updates" button, the plugin buildComfortButtons.js call for getstablebutton() or getbothbuttons() method and inject the HTML inside the li#udapteButtonsContainer in the _checkButtons view +* - First, when the user click on the "check for updates" button, the plugin buildComfortButtons.js call for getstablebutton() or getbothbuttons() method and inject the HTML inside the li#udapteButtonsContainer in the _checkButtons view * - Then, when the user click on one of those buttons, the comfortUpdateNextStep.js plugin will call for the getWelcome() method and inject the HTML inside div#updaterContainer in the _right_container view (all steps will be then injected here) -* - Then, when the user click on the continue button, the comfortUpdateNextStep.js plugin will call for the step1() method and inject the the HTML inside div#updaterContainer in the _right_container view +* - Then, when the user click on the continue button, the comfortUpdateNextStep.js plugin will call for the step1() method and inject the the HTML inside div#updaterContainer in the _right_container view * - etc. etc. * * @@ -59,336 +59,336 @@ */ class update extends Survey_Common_Action { - - /** - * This function return the update buttons for stable branch - * @return html the button code - */ - public function getstablebutton() - { - echo $this->_getButtons("0"); - } - - /** - * This function return the update buttons for all versions - * @return html the buttons code - */ - public function getbothbuttons() - { - echo $this->_getButtons("1"); - } + + /** + * This function return the update buttons for stable branch + * @return html the button code + */ + public function getstablebutton() + { + echo $this->_getButtons("0"); + } + + /** + * This function return the update buttons for all versions + * @return html the buttons code + */ + public function getbothbuttons() + { + echo $this->_getButtons("1"); + } - /** - * This function has a special rendering, because the ComfortUpdate server can choose what it's going to show : - * the welcome message or the subscribe message or the updater update, etc. - * The same system is used for the static views (update key, etc.) - * - * @return html the welcome message - */ - public function getwelcome() - { - // We get the update key in the database. If it's empty, getWelcomeMessage will return subscription - $updateKey = getGlobalSetting("update_key"); - //$updateKey = SettingGlobal::model()->findByPk('update_key')->stg_value; - $updateModel = new UpdateForm(); - $destinationBuild = $_REQUEST['destinationBuild']; - $welcome = (array) $updateModel->getWelcomeMessage($updateKey, $destinationBuild); - $welcome['destinationBuild'] = $destinationBuild; - $welcome = (object)$welcome; - - return $this->_renderWelcome($welcome); - } + /** + * This function has a special rendering, because the ComfortUpdate server can choose what it's going to show : + * the welcome message or the subscribe message or the updater update, etc. + * The same system is used for the static views (update key, etc.) + * + * @return html the welcome message + */ + public function getwelcome() + { + // We get the update key in the database. If it's empty, getWelcomeMessage will return subscription + $updateKey = getGlobalSetting("update_key"); + //$updateKey = SettingGlobal::model()->findByPk('update_key')->stg_value; + $updateModel = new UpdateForm(); + $destinationBuild = $_REQUEST['destinationBuild']; + $welcome = (array) $updateModel->getWelcomeMessage($updateKey, $destinationBuild); + $welcome['destinationBuild'] = $destinationBuild; + $welcome = (object)$welcome; + + return $this->_renderWelcome($welcome); + } - /** - * returns the "Checking basic requirements" step - * @return html the welcome message - */ - public function checkLocalErrors() - { - // We use request rather than post, because this step can be called by url by displayComfortStep.js - if( isset($_REQUEST['destinationBuild']) ) - { - $destinationBuild = $_REQUEST['destinationBuild']; - $access_token = $_REQUEST['access_token']; - - $updateModel = new UpdateForm(); - $localChecks = $updateModel->getLocalChecks($destinationBuild); - $aData['localChecks'] = $localChecks; - $aData['changelog'] = NULL; - $aData['destinationBuild'] = $destinationBuild; - $aData['access_token'] = $access_token; - - return $this->controller->renderPartial('update/updater/steps/_check_local_errors', $aData, false, true); - } - return $this->_renderErrorString("unkown_destination_build"); - } + /** + * returns the "Checking basic requirements" step + * @return html the welcome message + */ + public function checkLocalErrors() + { + // We use request rather than post, because this step can be called by url by displayComfortStep.js + if( isset($_REQUEST['destinationBuild']) ) + { + $destinationBuild = $_REQUEST['destinationBuild']; + $access_token = $_REQUEST['access_token']; + + $updateModel = new UpdateForm(); + $localChecks = $updateModel->getLocalChecks($destinationBuild); + $aData['localChecks'] = $localChecks; + $aData['changelog'] = NULL; + $aData['destinationBuild'] = $destinationBuild; + $aData['access_token'] = $access_token; + + return $this->controller->renderPartial('update/updater/steps/_check_local_errors', $aData, false, true); + } + return $this->_renderErrorString("unkown_destination_build"); + } /** * Display change log - * @return HTML - */ - public function changeLog() - { - // We use request rather than post, because this step can be called by url by displayComfortStep.js - if( isset($_REQUEST['destinationBuild']) ) - { - - $destinationBuild = $_REQUEST['destinationBuild']; - $access_token = $_REQUEST['access_token']; - - // We get the change log from the ComfortUpdater server - $updateModel = new UpdateForm(); - $changelog = $updateModel->getChangeLog( $destinationBuild ); - - if( $changelog->result ) - { - $aData['errors'] = FALSE; - $aData['changelogs'] = $changelog; - $aData['html_from_server'] = $changelog->html; - $aData['destinationBuild'] = $destinationBuild; - $aData['access_token'] = $access_token; - } - else - { - return $this->_renderError($changelog); - } - return $this->controller->renderPartial('update/updater/steps/_change_log', $aData, false, true); - } - return $this->_renderErrorString("unkown_destination_build"); - } - - /** - * diaplay the result of the changed files check - * - * @return html HTML - */ + * @return HTML + */ + public function changeLog() + { + // We use request rather than post, because this step can be called by url by displayComfortStep.js + if( isset($_REQUEST['destinationBuild']) ) + { + + $destinationBuild = $_REQUEST['destinationBuild']; + $access_token = $_REQUEST['access_token']; + + // We get the change log from the ComfortUpdater server + $updateModel = new UpdateForm(); + $changelog = $updateModel->getChangeLog( $destinationBuild ); + + if( $changelog->result ) + { + $aData['errors'] = FALSE; + $aData['changelogs'] = $changelog; + $aData['html_from_server'] = $changelog->html; + $aData['destinationBuild'] = $destinationBuild; + $aData['access_token'] = $access_token; + } + else + { + return $this->_renderError($changelog); + } + return $this->controller->renderPartial('update/updater/steps/_change_log', $aData, false, true); + } + return $this->_renderErrorString("unkown_destination_build"); + } + + /** + * diaplay the result of the changed files check + * + * @return html HTML + */ public function fileSystem() { - if( isset($_REQUEST['destinationBuild'])) - { - $tobuild = $_REQUEST['destinationBuild']; - $access_token = $_REQUEST['access_token']; - $frombuild = Yii::app()->getConfig("buildnumber"); + if( isset($_REQUEST['destinationBuild'])) + { + $tobuild = $_REQUEST['destinationBuild']; + $access_token = $_REQUEST['access_token']; + $frombuild = Yii::app()->getConfig("buildnumber"); - $updateModel = new UpdateForm(); - $changedFiles = $updateModel->getChangedFiles($tobuild); - - if( $changedFiles->result ) - { - //TODO : clean that - $aData = $updateModel->getFileStatus($changedFiles->files); - - $aData['html_from_server'] = ( isset($changedFiles->html) )?$changedFiles->html:''; - $aData['datasupdateinfo'] = $this->_parseToView($changedFiles->files); - $aData['destinationBuild']=$tobuild; - $aData['updateinfo'] = $changedFiles->files; - $aData['access_token'] = $access_token; - - return $this->controller->renderPartial('update/updater/steps/_fileSystem', $aData, false, true); - } - var_dump($changedFiles); - return $this->_renderError($changedFiles); - } - return $this->_renderErrorString("unkown_destination_build"); + $updateModel = new UpdateForm(); + $changedFiles = $updateModel->getChangedFiles($tobuild); + + if( $changedFiles->result ) + { + //TODO : clean that + $aData = $updateModel->getFileStatus($changedFiles->files); + + $aData['html_from_server'] = ( isset($changedFiles->html) )?$changedFiles->html:''; + $aData['datasupdateinfo'] = $this->_parseToView($changedFiles->files); + $aData['destinationBuild']=$tobuild; + $aData['updateinfo'] = $changedFiles->files; + $aData['access_token'] = $access_token; + + return $this->controller->renderPartial('update/updater/steps/_fileSystem', $aData, false, true); + } + var_dump($changedFiles); + return $this->_renderError($changedFiles); + } + return $this->_renderErrorString("unkown_destination_build"); } - /** - * backup files - * @return html - */ + /** + * backup files + * @return html + */ public function backup() { - if(Yii::app()->request->getPost('destinationBuild')) - { - $destinationBuild = Yii::app()->request->getPost('destinationBuild'); - $access_token = $_REQUEST['access_token']; - - if(Yii::app()->request->getPost('datasupdateinfo')) - { - $updateinfos= unserialize ( base64_decode( ( Yii::app()->request->getPost('datasupdateinfo') ))); + if(Yii::app()->request->getPost('destinationBuild')) + { + $destinationBuild = Yii::app()->request->getPost('destinationBuild'); + $access_token = $_REQUEST['access_token']; + + if(Yii::app()->request->getPost('datasupdateinfo')) + { + $updateinfos= unserialize ( base64_decode( ( Yii::app()->request->getPost('datasupdateinfo') ))); - $updateModel = new UpdateForm(); - $backupInfos = $updateModel->backupFiles($updateinfos); + $updateModel = new UpdateForm(); + $backupInfos = $updateModel->backupFiles($updateinfos); - if( $backupInfos->result ) - { - $dbBackupInfos = $updateModel->backupDb($destinationBuild); - // If dbBackup fails, it will just provide a warning message : backup manually - - $aData['dbBackupInfos'] = $dbBackupInfos; - $aData['basefilename']=$backupInfos->basefilename; - $aData['tempdir'] = $backupInfos->tempdir; - $aData['datasupdateinfo'] = $this->_parseToView($updateinfos); - $aData['destinationBuild'] = $destinationBuild; - $aData['access_token'] = $access_token; - return $this->controller->renderPartial('update/updater/steps/_backup', $aData, false, true); - - } - else - { - $error = $backup->error; - } - } - else - { - $error = "no_updates_infos"; - } - } - else - { - $error = "unkown_destination_build"; - } - return $this->_renderErrorString($error); + if( $backupInfos->result ) + { + $dbBackupInfos = $updateModel->backupDb($destinationBuild); + // If dbBackup fails, it will just provide a warning message : backup manually + + $aData['dbBackupInfos'] = $dbBackupInfos; + $aData['basefilename']=$backupInfos->basefilename; + $aData['tempdir'] = $backupInfos->tempdir; + $aData['datasupdateinfo'] = $this->_parseToView($updateinfos); + $aData['destinationBuild'] = $destinationBuild; + $aData['access_token'] = $access_token; + return $this->controller->renderPartial('update/updater/steps/_backup', $aData, false, true); + + } + else + { + $error = $backup->error; + } + } + else + { + $error = "no_updates_infos"; + } + } + else + { + $error = "unkown_destination_build"; + } + return $this->_renderErrorString($error); } - /** - * Display step4 - * @return html - */ + /** + * Display step4 + * @return html + */ function step4() { - if( Yii::app()->request->getPost('destinationBuild') ) - { - $destinationBuild = Yii::app()->request->getPost('destinationBuild'); - $access_token = $_REQUEST['access_token']; - - if( Yii::app()->request->getPost('datasupdateinfo') ) - { - $updateinfos = unserialize ( base64_decode( ( Yii::app()->request->getPost('datasupdateinfo') ))); + if( Yii::app()->request->getPost('destinationBuild') ) + { + $destinationBuild = Yii::app()->request->getPost('destinationBuild'); + $access_token = $_REQUEST['access_token']; + + if( Yii::app()->request->getPost('datasupdateinfo') ) + { + $updateinfos = unserialize ( base64_decode( ( Yii::app()->request->getPost('datasupdateinfo') ))); - // this is the last step - Download the zip file, unpack it and replace files accordingly - $updateModel = new UpdateForm(); - $file = $updateModel->downloadUpdateFile($access_token, $destinationBuild); - - if( $file->result ) - { - $unzip = $updateModel->unzipUpdateFile(); - if( $unzip->result ) - { - $remove = $updateModel->removeDeletedFiles($updateinfos); - if( $remove->result ) - { - // Should never bug (version.php is checked before)) - $updateModel->updateVersion($destinationBuild); - $updateModel->destroyGlobalSettings(); - // TODO : aData should contains information about each step - return $this->controller->renderPartial('update/updater/steps/_final', array(), false, true); - } - else - { - $error = $remove->error; - } - } - else - { - $error = $unzip->error; - } - } - else - { - $error = $file->error; - } - } - else - { - $error = "no_updates_infos"; - } - } - else - { - $error = "unkown_destination_build"; - } - return $this->_renderErrorString($error); + // this is the last step - Download the zip file, unpack it and replace files accordingly + $updateModel = new UpdateForm(); + $file = $updateModel->downloadUpdateFile($access_token, $destinationBuild); + + if( $file->result ) + { + $unzip = $updateModel->unzipUpdateFile(); + if( $unzip->result ) + { + $remove = $updateModel->removeDeletedFiles($updateinfos); + if( $remove->result ) + { + // Should never bug (version.php is checked before)) + $updateModel->updateVersion($destinationBuild); + $updateModel->destroyGlobalSettings(); + // TODO : aData should contains information about each step + return $this->controller->renderPartial('update/updater/steps/_final', array(), false, true); + } + else + { + $error = $remove->error; + } + } + else + { + $error = $unzip->error; + } + } + else + { + $error = $file->error; + } + } + else + { + $error = "no_updates_infos"; + } + } + else + { + $error = "unkown_destination_build"; + } + return $this->_renderErrorString($error); } - /** - * This function update the updater - * It is called from the view _updater_update. - * The view _updater_update is called by the ComfortUpdater server during the getWelcome step if the updater version is not the minimal required one. - * @return html the welcome message - */ - public function updateUpdater() - { - if( Yii::app()->request->getPost('destinationBuild') ) - { - $destinationBuild = Yii::app()->request->getPost('destinationBuild'); - $updateModel = new UpdateForm(); - - $localChecks = $updateModel->getLocalChecksForUpdater(); - - if( $localChecks->result ) - { - $file = $updateModel->downloadUpdateUpdaterFile($destinationBuild); - - if( $file->result ) - { - $unzip = $updateModel->unzipUpdateUpdaterFile(); - if( $unzip->result ) - { - return $this->controller->renderPartial('update/updater/steps/_updater_updated', array('destinationBuild'=>$destinationBuild), false, true); - } - else - { - $error = $unzip->error; - } - } - else - { - $error = $file->error; - } - } - else - { - return $this->controller->renderPartial('update/updater/welcome/_error_files_update_updater', array('localChecks'=>$localChecks), false, true); - } - - } - return $this->_renderErrorString($error); - } + /** + * This function update the updater + * It is called from the view _updater_update. + * The view _updater_update is called by the ComfortUpdater server during the getWelcome step if the updater version is not the minimal required one. + * @return html the welcome message + */ + public function updateUpdater() + { + if( Yii::app()->request->getPost('destinationBuild') ) + { + $destinationBuild = Yii::app()->request->getPost('destinationBuild'); + $updateModel = new UpdateForm(); + + $localChecks = $updateModel->getLocalChecksForUpdater(); + + if( $localChecks->result ) + { + $file = $updateModel->downloadUpdateUpdaterFile($destinationBuild); + + if( $file->result ) + { + $unzip = $updateModel->unzipUpdateUpdaterFile(); + if( $unzip->result ) + { + return $this->controller->renderPartial('update/updater/steps/_updater_updated', array('destinationBuild'=>$destinationBuild), false, true); + } + else + { + $error = $unzip->error; + } + } + else + { + $error = $file->error; + } + } + else + { + return $this->controller->renderPartial('update/updater/welcome/_error_files_update_updater', array('localChecks'=>$localChecks), false, true); + } + + } + return $this->_renderErrorString($error); + } - /** - * This return the subscribe message - * @return html the welcome message - */ - public function getnewkey() - { - // We try to get the update key in the database. If it's empty, getWelcomeMessage will return subscription - $updateKey = NULL; - $updateModel = new UpdateForm(); - $destinationBuild = $_REQUEST['destinationBuild']; - $welcome = $updateModel->getWelcomeMessage($updateKey, $destinationBuild); //$updateKey - echo $this->_renderWelcome($welcome); - } + /** + * This return the subscribe message + * @return html the welcome message + */ + public function getnewkey() + { + // We try to get the update key in the database. If it's empty, getWelcomeMessage will return subscription + $updateKey = NULL; + $updateModel = new UpdateForm(); + $destinationBuild = $_REQUEST['destinationBuild']; + $welcome = $updateModel->getWelcomeMessage($updateKey, $destinationBuild); //$updateKey + echo $this->_renderWelcome($welcome); + } - /** - * This function create or update the LS update key - * @return html - */ - public function submitkey() - { - if( Yii::app()->request->getPost('keyid') ) - { - // We trim it, just in case user added a space... - $submittedUpdateKey = trim(Yii::app()->request->getPost('keyid')); - - $updateModel = new UpdateForm(); - $check = $updateModel->checkUpdateKeyonServer($submittedUpdateKey); - if( $check->result ) - { - // If the key is validated by server, we update the local database with this key - $updateKey = $updateModel->setUpdateKey($submittedUpdateKey); - $check = new stdClass(); - $check->result = TRUE; - $check->view = "key_updated"; - } - // then, we render the what returned the server (views and key infos or error ) - echo $this->_renderWelcome($check); - } - else - { - return $this->_renderErrorString("key_null"); - } - } + /** + * This function create or update the LS update key + * @return html + */ + public function submitkey() + { + if( Yii::app()->request->getPost('keyid') ) + { + // We trim it, just in case user added a space... + $submittedUpdateKey = trim(Yii::app()->request->getPost('keyid')); + + $updateModel = new UpdateForm(); + $check = $updateModel->checkUpdateKeyonServer($submittedUpdateKey); + if( $check->result ) + { + // If the key is validated by server, we update the local database with this key + $updateKey = $updateModel->setUpdateKey($submittedUpdateKey); + $check = new stdClass(); + $check->result = TRUE; + $check->view = "key_updated"; + } + // then, we render the what returned the server (views and key infos or error ) + echo $this->_renderWelcome($check); + } + else + { + return $this->_renderErrorString("key_null"); + } + } @@ -410,88 +410,88 @@ function db($continue = null) $aViewUrls['output'] = CheckForDBUpgrades(); } - $aData['updatedbaction'] = true; + $aData['updatedbaction'] = true; $this->_renderWrappedTemplate('update', $aViewUrls, $aData); } - /** - * this function render the update buttons - * @param object $serverAnswer the update server answer (getInfo) - */ - private function _getButtons($crosscheck) - { - $updateModel = new UpdateForm(); - $serverAnswer = $updateModel->getUpdateInfo($crosscheck); - - if( $serverAnswer->result ) - { - unset($serverAnswer->result); - return $this->controller->renderPartial('//admin/update/check_updates/update_buttons/_updatesavailable', array('updateInfos' => $serverAnswer)); - } - // Error : we build the error title and messages - return $this->controller->renderPartial('//admin/update/check_updates/update_buttons/_updatesavailable_error', array('serverAnswer' => $serverAnswer)); - } + /** + * this function render the update buttons + * @param object $serverAnswer the update server answer (getInfo) + */ + private function _getButtons($crosscheck) + { + $updateModel = new UpdateForm(); + $serverAnswer = $updateModel->getUpdateInfo($crosscheck); + + if( $serverAnswer->result ) + { + unset($serverAnswer->result); + return $this->controller->renderPartial('//admin/update/check_updates/update_buttons/_updatesavailable', array('updateInfos' => $serverAnswer)); + } + // Error : we build the error title and messages + return $this->controller->renderPartial('//admin/update/check_updates/update_buttons/_updatesavailable_error', array('serverAnswer' => $serverAnswer)); + } - /** - * This method render the welcome/subscribe/key_updated message - * @param obj $serverAnswer the answer return by the server - */ - private function _renderWelcome($serverAnswer) - { - if( $serverAnswer->result ) - { - // Available views (in /admin/update/welcome/ ) - $views = array('welcome', 'subscribe', 'key_updated', 'updater_update'); - if( in_array($serverAnswer->view, $views) ) - { - return $this->controller->renderPartial('//admin/update/updater/welcome/_'.$serverAnswer->view, array('serverAnswer' => $serverAnswer), false, true); - } - else - { - $serverAnswer->result = FALSE; - $serverAnswer->error = "unknown_view"; - } - } - echo $this->_renderError($serverAnswer); - - } + /** + * This method render the welcome/subscribe/key_updated message + * @param obj $serverAnswer the answer return by the server + */ + private function _renderWelcome($serverAnswer) + { + if( $serverAnswer->result ) + { + // Available views (in /admin/update/welcome/ ) + $views = array('welcome', 'subscribe', 'key_updated', 'updater_update'); + if( in_array($serverAnswer->view, $views) ) + { + return $this->controller->renderPartial('//admin/update/updater/welcome/_'.$serverAnswer->view, array('serverAnswer' => $serverAnswer), false, true); + } + else + { + $serverAnswer->result = FALSE; + $serverAnswer->error = "unknown_view"; + } + } + echo $this->_renderError($serverAnswer); + + } - /** - * This method renders the error view - * @param object $errorObject - * @return html - */ - private function _renderError($errorObject) - { - echo $this->controller->renderPartial('//admin/update/updater/_error', array('errorObject' => $errorObject), false, true); - } + /** + * This method renders the error view + * @param object $errorObject + * @return html + */ + private function _renderError($errorObject) + { + echo $this->controller->renderPartial('//admin/update/updater/_error', array('errorObject' => $errorObject), false, true); + } - /** - * This method convert a string to an error object, and then render the error view - * @param string $error the error message - * @return html - */ - private function _renderErrorString($error) - { - $errorObject = new stdClass(); - $errorObject->result = FALSE; - $errorObject->error = $error; - return $this->_renderError($errorObject); - } + /** + * This method convert a string to an error object, and then render the error view + * @param string $error the error message + * @return html + */ + private function _renderErrorString($error) + { + $errorObject = new stdClass(); + $errorObject->result = FALSE; + $errorObject->error = $error; + return $this->_renderError($errorObject); + } - /** - * This function convert the huge updateinfos array to a base64 string, so it can be parsed to the view to be inserted in an hidden input element. - * - * @param array $udpateinfos the udpadte infos array returned by the update server - * @return $string - */ - private function _parseToView($updateinfos) - { - $data=serialize($updateinfos); - return base64_encode($data); - } + /** + * This function convert the huge updateinfos array to a base64 string, so it can be parsed to the view to be inserted in an hidden input element. + * + * @param array $udpateinfos the udpadte infos array returned by the update server + * @return $string + */ + private function _parseToView($updateinfos) + { + $data=serialize($updateinfos); + return base64_encode($data); + } } \ No newline at end of file diff --git a/application/core/Survey_Common_Action.php b/application/core/Survey_Common_Action.php index 4d4563ecb8e..5f2591d1cbd 100644 --- a/application/core/Survey_Common_Action.php +++ b/application/core/Survey_Common_Action.php @@ -1041,6 +1041,7 @@ protected function _filterImportedResources($extractdir, $destdir) return array($aImportedFilesInfo, $aErrorFilesInfo); } + /** * Creates a temporary directory * diff --git a/application/models/UpdateForm.php b/application/models/UpdateForm.php index 7f04d9d4d8d..eb6e0d594cf 100644 --- a/application/models/UpdateForm.php +++ b/application/models/UpdateForm.php @@ -17,497 +17,497 @@ * * This model retrieves all the data Comfort Updates needs. Most of them come from request to the Update Server. * -* @package LimeSurvey -* @subpackage Backend +* @package LimeSurvey +* @subpackage Backend */ class UpdateForm extends CFormModel { - // The build id - public $build; - - // The view to display : used only for welcome type views to let the server choose wich view will be displayed - public $view; - - // Proxy infos - private $proxy_host_name; - private $proxy_host_port; - - // File system infos - private $tempdir; - private $rootdir; - private $publicdir; - - // Session - private $path_cookie; - - public function init() - { - $this->build=Yii::app()->getConfig("buildnumber"); - $this->proxy_host_name = Yii::app()->getConfig("proxy_host_name",""); - $this->proxy_host_port = Yii::app()->getConfig("proxy_host_port",80); - $this->tempdir = Yii::app()->getConfig("tempdir"); - $this->rootdir = Yii::app()->getConfig("rootdir"); - $this->publicdir = Yii::app()->getConfig("publicdir"); - $this->path_cookie = $this->tempdir.DIRECTORY_SEPARATOR.'comfort_updater_cookie.txt'; - } - - /** - * First call to the server : This function requests the latest update informations from the update server necessary to build the update buttons. - * If any error occure (server not answering, no curl, servor returns error, etc.), the view check_updates/update_buttons/_updatesavailable_error will be rendered by the controller. - * - * @param boolean $crosscheck if it checks for info for both stable and unstable branches - * @return array Contains update information or error object - */ - public function getUpdateInfo($crosscheck="1") - { - if( $this->build != '' ) - { - $crosscheck = (int) $crosscheck; - $getters = '/index.php?r=updates/updateinfo¤tbuild='.$this->build.'&id='.md5(getGlobalSetting('SessionName')).'&crosscheck='.$crosscheck; - $content = $this->_performRequest($getters); - } - else - { - $content = new stdClass(); - $content->result = FALSE; - $content->error = "no_build"; - } - return $content; - } - - /** - * The server will do some checks and will ask for the correct view to be diplayed. - * - * @param string $updateKey the update key - */ - public function getWelcomeMessage($updateKey=NULL, $destinationBuild) - { - // First, we destroy any previous cookie : - if ( file_exists(realpath($this->path_cookie)) ) - unlink( $this->path_cookie ); - - $updater_version = Yii::app()->getConfig("updaterversion"); - touch($this->path_cookie); - $getters = '/index.php?r=updates/getwelcome¤tbuild='.$this->build.'&keyid='.$updateKey.'&destinationbuild='.$destinationBuild.'&updater_version='.$updater_version; - $content = $this->_performRequest($getters, TRUE); - return $content; - } - - /** - * check if a submitted update key exist on the update server and if it's valid - * @param string $submittedUpdateKey the submitted update key - * @return boolean true if it exists, false if it doesn't - */ - public function checkUpdateKeyonServer($submittedUpdateKey) - { - $getters = '/index.php?r=updates/checkupdatekey&keyid='.$submittedUpdateKey; - $content = $this->_performRequest($getters); - return $content; - } - - /** - * create or update the updatekey to the submited value - * @param string $submittedUpdateKey the new key id - * @return SettingGlobal the new update key if success, CActiveRecord result if error - * - * TODO : should return same status than server to use the same view render - */ - public function setUpdateKey($submittedUpdateKey) - { - // The update keys never contains special characters, so, it should not affect the key - // If it affects the key : then the key was wrong... and the database is safe - $submittedUpdateKey = trim(htmlspecialchars(addslashes($submittedUpdateKey))); - - $updateKey = SettingGlobal::model()->findByPk('update_key'); - if(!$updateKey) - { - // Create - $updateKey = new SettingGlobal(); - $updateKey->stg_name = 'update_key'; - $updateKey->stg_value = $submittedUpdateKey; - $result = $updateKey->save(); - } - else - { - //Update - $result = SettingGlobal::model()->updateByPk( 'update_key', array('stg_value'=>$submittedUpdateKey)); - } - - if($result) - { - // If success we return the updatekey row - $updateKey = SettingGlobal::model()->findByPk('update_key'); - return $updateKey; - } - else - { - // Else we return the errors - return array('result'=>FALSE, 'error'=>'db_error'); - } - } - - - /** - * This function check for local errors such as readonly files, available space, php ini config etc. - * It calls the server to get the list of files/directories to check - * - * @param int $destinationBuild : the id of the destination build - * @return object $checks ; an object indexing local checks - */ - public function getLocalChecks($destinationBuild) - { - $checks = new stdClass(); - - $checks->files = $this->_getFileSystemCheckList(); - $checks->php = $this->_phpVerCheck($destinationBuild); - $checks->php_modules = $this->_getModuleChecks($destinationBuild); - - return $checks; - } - - /** - * This function check for local arrors such as readonly files/directory to update the updater itself - * - * @return object $checks - */ - public function getLocalChecksForUpdater() - { - $toCheck = array( - 'config'.DIRECTORY_SEPARATOR.'updater_version.php', - 'controllers'.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.'update.php', - 'models'.DIRECTORY_SEPARATOR.'UpdateForm.php', - '..'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'ajax-loader.gif',); - - $toCheckRecurive = array( - 'views'.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.'update'.DIRECTORY_SEPARATOR.'', - '..'.DIRECTORY_SEPARATOR.'scripts'.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.'comfortupdater'.DIRECTORY_SEPARATOR ); - - $readOnly = array(); - - // We check the write permission of files - foreach( $toCheck as $check ) - { - if( !is_writable( APPPATH . $check ) ) - { - $readOnly[] = APPPATH . $check ; - } - } - - // We check the write permission of directories and their content - // TODO : a beautifull recursive function - foreach( $toCheckRecurive as $check ) - { - $start_directory = APPPATH . $check; - $readOnly = $this->_checkDirectoryAndItsFiles( $start_directory , $readOnly); - - $check_all_subdirectories = $this->_getAllSubDirectories( $start_directory, DIRECTORY_SEPARATOR ); - foreach ($check_all_subdirectories as $directory) - { - $readOnly = $this->_checkDirectoryAndItsFiles( $directory , $readOnly); - } - } - - if( count($readOnly) <= 0 ) - return (object) array('result'=>TRUE); - - return (object) array('result'=>FALSE, 'readOnly'=>$readOnly); - } - - - /** - * This function requests the change log between the curent build and the destination build - * - * @param int $destinationBuild - * @return TODO : check return - */ + // The build id + public $build; + + // The view to display : used only for welcome type views to let the server choose wich view will be displayed + public $view; + + // Proxy infos + private $proxy_host_name; + private $proxy_host_port; + + // File system infos + private $tempdir; + private $rootdir; + private $publicdir; + + // Session + private $path_cookie; + + public function init() + { + $this->build=Yii::app()->getConfig("buildnumber"); + $this->proxy_host_name = Yii::app()->getConfig("proxy_host_name",""); + $this->proxy_host_port = Yii::app()->getConfig("proxy_host_port",80); + $this->tempdir = Yii::app()->getConfig("tempdir"); + $this->rootdir = Yii::app()->getConfig("rootdir"); + $this->publicdir = Yii::app()->getConfig("publicdir"); + $this->path_cookie = $this->tempdir.DIRECTORY_SEPARATOR.'comfort_updater_cookie.txt'; + } + + /** + * First call to the server : This function requests the latest update informations from the update server necessary to build the update buttons. + * If any error occure (server not answering, no curl, servor returns error, etc.), the view check_updates/update_buttons/_updatesavailable_error will be rendered by the controller. + * + * @param boolean $crosscheck if it checks for info for both stable and unstable branches + * @return array Contains update information or error object + */ + public function getUpdateInfo($crosscheck="1") + { + if( $this->build != '' ) + { + $crosscheck = (int) $crosscheck; + $getters = '/index.php?r=updates/updateinfo¤tbuild='.$this->build.'&id='.md5(getGlobalSetting('SessionName')).'&crosscheck='.$crosscheck; + $content = $this->_performRequest($getters); + } + else + { + $content = new stdClass(); + $content->result = FALSE; + $content->error = "no_build"; + } + return $content; + } + + /** + * The server will do some checks and will ask for the correct view to be diplayed. + * + * @param string $updateKey the update key + */ + public function getWelcomeMessage($updateKey=NULL, $destinationBuild) + { + // First, we destroy any previous cookie : + if ( file_exists(realpath($this->path_cookie)) ) + unlink( $this->path_cookie ); + + $updater_version = Yii::app()->getConfig("updaterversion"); + touch($this->path_cookie); + $getters = '/index.php?r=updates/getwelcome¤tbuild='.$this->build.'&keyid='.$updateKey.'&destinationbuild='.$destinationBuild.'&updater_version='.$updater_version; + $content = $this->_performRequest($getters, TRUE); + return $content; + } + + /** + * check if a submitted update key exist on the update server and if it's valid + * @param string $submittedUpdateKey the submitted update key + * @return boolean true if it exists, false if it doesn't + */ + public function checkUpdateKeyonServer($submittedUpdateKey) + { + $getters = '/index.php?r=updates/checkupdatekey&keyid='.$submittedUpdateKey; + $content = $this->_performRequest($getters); + return $content; + } + + /** + * create or update the updatekey to the submited value + * @param string $submittedUpdateKey the new key id + * @return SettingGlobal the new update key if success, CActiveRecord result if error + * + * TODO : should return same status than server to use the same view render + */ + public function setUpdateKey($submittedUpdateKey) + { + // The update keys never contains special characters, so, it should not affect the key + // If it affects the key : then the key was wrong... and the database is safe + $submittedUpdateKey = trim(htmlspecialchars(addslashes($submittedUpdateKey))); + + $updateKey = SettingGlobal::model()->findByPk('update_key'); + if(!$updateKey) + { + // Create + $updateKey = new SettingGlobal(); + $updateKey->stg_name = 'update_key'; + $updateKey->stg_value = $submittedUpdateKey; + $result = $updateKey->save(); + } + else + { + //Update + $result = SettingGlobal::model()->updateByPk( 'update_key', array('stg_value'=>$submittedUpdateKey)); + } + + if($result) + { + // If success we return the updatekey row + $updateKey = SettingGlobal::model()->findByPk('update_key'); + return $updateKey; + } + else + { + // Else we return the errors + return array('result'=>FALSE, 'error'=>'db_error'); + } + } + + + /** + * This function check for local errors such as readonly files, available space, php ini config etc. + * It calls the server to get the list of files/directories to check + * + * @param int $destinationBuild : the id of the destination build + * @return object $checks ; an object indexing local checks + */ + public function getLocalChecks($destinationBuild) + { + $checks = new stdClass(); + + $checks->files = $this->_getFileSystemCheckList(); + $checks->php = $this->_phpVerCheck($destinationBuild); + $checks->php_modules = $this->_getModuleChecks($destinationBuild); + + return $checks; + } + + /** + * This function check for local arrors such as readonly files/directory to update the updater itself + * + * @return object $checks + */ + public function getLocalChecksForUpdater() + { + $toCheck = array( + 'config'.DIRECTORY_SEPARATOR.'updater_version.php', + 'controllers'.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.'update.php', + 'models'.DIRECTORY_SEPARATOR.'UpdateForm.php', + '..'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'ajax-loader.gif',); + + $toCheckRecurive = array( + 'views'.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.'update'.DIRECTORY_SEPARATOR.'', + '..'.DIRECTORY_SEPARATOR.'scripts'.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.'comfortupdater'.DIRECTORY_SEPARATOR ); + + $readOnly = array(); + + // We check the write permission of files + foreach( $toCheck as $check ) + { + if( !is_writable( APPPATH . $check ) ) + { + $readOnly[] = APPPATH . $check ; + } + } + + // We check the write permission of directories and their content + // TODO : a beautifull recursive function + foreach( $toCheckRecurive as $check ) + { + $start_directory = APPPATH . $check; + $readOnly = $this->_checkDirectoryAndItsFiles( $start_directory , $readOnly); + + $check_all_subdirectories = $this->_getAllSubDirectories( $start_directory, DIRECTORY_SEPARATOR ); + foreach ($check_all_subdirectories as $directory) + { + $readOnly = $this->_checkDirectoryAndItsFiles( $directory , $readOnly); + } + } + + if( count($readOnly) <= 0 ) + return (object) array('result'=>TRUE); + + return (object) array('result'=>FALSE, 'readOnly'=>$readOnly); + } + + + /** + * This function requests the change log between the curent build and the destination build + * + * @param int $destinationBuild + * @return TODO : check return + */ public function getChangelog($destinationBuild) { - $getters = '/index.php?r=updates/changelog&frombuild=' . $this->build . '&tobuild=' . $destinationBuild ; - $content = $this->_performRequest($getters); - return $content; + $getters = '/index.php?r=updates/changelog&frombuild=' . $this->build . '&tobuild=' . $destinationBuild ; + $content = $this->_performRequest($getters); + return $content; } - /** - * This function requests the list of changed file between two build - * @param int $destinationBuild - * @return TODO : check return - */ + /** + * This function requests the list of changed file between two build + * @param int $destinationBuild + * @return TODO : check return + */ public function getChangedFiles($destinationBuild) { - $getters = '/index.php?r=updates/changed-files&frombuild=' . $this->build . '&tobuild=' . $destinationBuild ; - $content = $this->_performRequest($getters); - return $content; + $getters = '/index.php?r=updates/changed-files&frombuild=' . $this->build . '&tobuild=' . $destinationBuild ; + $content = $this->_performRequest($getters); + return $content; + } + + /** + * This function requests a download to the server + * @param int $downloadid the id of the download on the server + * @return object + */ + public function downloadUpdateFile($downloadid, $tobuild) + { + $getters = '/index.php?r=updates/download&frombuild='.$this->build.'&tobuild='.$tobuild; + $getters .= "&access_token=".$_REQUEST['access_token']; + $file = $this->_performDownload($getters); + return $file; } - /** - * This function requests a download to the server - * @param int $downloadid the id of the download on the server - * @return object - */ - public function downloadUpdateFile($downloadid, $tobuild) - { - $getters = '/index.php?r=updates/download&frombuild='.$this->build.'&tobuild='.$tobuild; - $getters .= "&access_token=".$_REQUEST['access_token']; - $file = $this->_performDownload($getters); - return $file; - } - - /** - * This function download the file to update the updater to the last version - * @param int $downloadid the id of the download on the server - * @return object - */ - public function downloadUpdateUpdaterFile( $tobuild ) - { - $getters = '/index.php?r=updates/download-updater&tobuild='.$tobuild; - $file = $this->_performDownload($getters, 'update_updater'); - return $file; - } - - - /** - * Unzip the update file. - * @return NULL if sucess or message error void (TODO : return status) - */ - public function unzipUpdateFile($file_to_unzip = 'update.zip') - { - if (file_exists($this->tempdir.DIRECTORY_SEPARATOR.$file_to_unzip)) - { - // To debug pcl_zip, uncomment the following line : require_once('/var/www/limesurvey/LimeSurvey/application/libraries/admin/pclzip/pcltrace.lib.php'); require_once('/var/www/limesurvey/LimeSurvey/application/libraries/admin/pclzip/pclzip-trace.lib.php'); PclTraceOn(2); - // To debug pcl_zip, comment the following line: - Yii::app()->loadLibrary("admin/pclzip"); - - $archive = new PclZip($this->tempdir.DIRECTORY_SEPARATOR.$file_to_unzip); - - // TODO : RESTORE REPLACE NEWER !! - //if ($archive->extract(PCLZIP_OPT_PATH, $this->rootdir.'/', PCLZIP_OPT_REPLACE_NEWER)== 0) - if ($archive->extract(PCLZIP_OPT_PATH, $this->rootdir.DIRECTORY_SEPARATOR, PCLZIP_OPT_REPLACE_NEWER)== 0) - { - //PclTraceDisplay(); die(); - $return = array('result'=>FALSE, 'error'=>'unzip_error', 'message'=>$archive->errorInfo(true)); - return (object) $return; - } - $return = array('result'=>TRUE); - return (object) $return; - } - else - { - $return = array('result'=>FALSE, 'error'=>'zip_update_not_found'); - return (object) $return; - } - } - - /** - * Unzip the update file. - * @return NULL if sucess or message error void (TODO : return status) - */ - public function unzipUpdateUpdaterFile() - { - $file_to_unzip = 'update_updater.zip'; - return $this->unzipUpdateFile($file_to_unzip); - } - - /** - * Delete the files tagged as deleted in the update - * @return object - */ - public function removeDeletedFiles($updateinfos) - { - foreach ( $updateinfos as $file ) - { - if ( $file->type =='D' && file_exists($this->rootdir.$file->file) ) - { - if( is_file($this->rootdir.$file->file ) ) - { - if( ! @unlink($this->rootdir.$file->file) ) - { - $return = array('result'=>FALSE, 'error'=>'cant_remove_deleted_files', 'message'=>'file : '.$file->file); - return (object) $return; - } - } - else - { - if( ! rmdir($this->rootdir.$file->file) ) - { - $return = array('result'=>FALSE, 'error'=>'cant_remove_deleted_directory', 'message'=>'dir : '.$afile->file); - return (object) $return; - } - } - } - } - $return = array('result' => TRUE); - return (object) $return; - } - - /** - * Update the version file to the destination build version - * @param INT $destinationBuild the id of the new version - * @return NULL : will never fail (file access tested before), or only if user changed it manually - */ - public function updateVersion($destinationBuild) - { - // Now we have to update version.php - @ini_set('auto_detect_line_endings', true); - $versionlines=file($this->rootdir.DIRECTORY_SEPARATOR.'application'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'version.php'); - $handle = fopen($this->rootdir.DIRECTORY_SEPARATOR.'application'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'version.php', "w"); - foreach ($versionlines as $line) - { - if(strpos($line,'buildnumber')!==false) - { - $line='$config[\'buildnumber\'] = '.$destinationBuild.';'."\r\n"; - } - fwrite($handle,$line); - } - fclose($handle); - } - - /** - * Destroy the global settings stored in the settings (they sould not be used anymore...) - * @return NULL (TODO : return status) - */ - public function destroyGlobalSettings() - { - setGlobalSetting('updateavailable','0'); - setGlobalSetting('updatebuild',''); - setGlobalSetting('updateversions',''); - } - - /** - * This function provide status information about files presents on the system that will be afected by the update : do they exist ? are they writable ? modified ? - * @param int $updateinfo array of updated files - * @return array - */ + /** + * This function download the file to update the updater to the last version + * @param int $downloadid the id of the download on the server + * @return object + */ + public function downloadUpdateUpdaterFile( $tobuild ) + { + $getters = '/index.php?r=updates/download-updater&tobuild='.$tobuild; + $file = $this->_performDownload($getters, 'update_updater'); + return $file; + } + + + /** + * Unzip the update file. + * @return NULL if sucess or message error void (TODO : return status) + */ + public function unzipUpdateFile($file_to_unzip = 'update.zip') + { + if (file_exists($this->tempdir.DIRECTORY_SEPARATOR.$file_to_unzip)) + { + // To debug pcl_zip, uncomment the following line : require_once('/var/www/limesurvey/LimeSurvey/application/libraries/admin/pclzip/pcltrace.lib.php'); require_once('/var/www/limesurvey/LimeSurvey/application/libraries/admin/pclzip/pclzip-trace.lib.php'); PclTraceOn(2); + // To debug pcl_zip, comment the following line: + Yii::app()->loadLibrary("admin/pclzip"); + + $archive = new PclZip($this->tempdir.DIRECTORY_SEPARATOR.$file_to_unzip); + + // TODO : RESTORE REPLACE NEWER !! + //if ($archive->extract(PCLZIP_OPT_PATH, $this->rootdir.'/', PCLZIP_OPT_REPLACE_NEWER)== 0) + if ($archive->extract(PCLZIP_OPT_PATH, $this->rootdir.DIRECTORY_SEPARATOR, PCLZIP_OPT_REPLACE_NEWER)== 0) + { + //PclTraceDisplay(); die(); + $return = array('result'=>FALSE, 'error'=>'unzip_error', 'message'=>$archive->errorInfo(true)); + return (object) $return; + } + $return = array('result'=>TRUE); + return (object) $return; + } + else + { + $return = array('result'=>FALSE, 'error'=>'zip_update_not_found'); + return (object) $return; + } + } + + /** + * Unzip the update file. + * @return NULL if sucess or message error void (TODO : return status) + */ + public function unzipUpdateUpdaterFile() + { + $file_to_unzip = 'update_updater.zip'; + return $this->unzipUpdateFile($file_to_unzip); + } + + /** + * Delete the files tagged as deleted in the update + * @return object + */ + public function removeDeletedFiles($updateinfos) + { + foreach ( $updateinfos as $file ) + { + if ( $file->type =='D' && file_exists($this->rootdir.$file->file) ) + { + if( is_file($this->rootdir.$file->file ) ) + { + if( ! @unlink($this->rootdir.$file->file) ) + { + $return = array('result'=>FALSE, 'error'=>'cant_remove_deleted_files', 'message'=>'file : '.$file->file); + return (object) $return; + } + } + else + { + if( ! rmdir($this->rootdir.$file->file) ) + { + $return = array('result'=>FALSE, 'error'=>'cant_remove_deleted_directory', 'message'=>'dir : '.$afile->file); + return (object) $return; + } + } + } + } + $return = array('result' => TRUE); + return (object) $return; + } + + /** + * Update the version file to the destination build version + * @param INT $destinationBuild the id of the new version + * @return NULL : will never fail (file access tested before), or only if user changed it manually + */ + public function updateVersion($destinationBuild) + { + // Now we have to update version.php + @ini_set('auto_detect_line_endings', true); + $versionlines=file($this->rootdir.DIRECTORY_SEPARATOR.'application'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'version.php'); + $handle = fopen($this->rootdir.DIRECTORY_SEPARATOR.'application'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'version.php', "w"); + foreach ($versionlines as $line) + { + if(strpos($line,'buildnumber')!==false) + { + $line='$config[\'buildnumber\'] = '.$destinationBuild.';'."\r\n"; + } + fwrite($handle,$line); + } + fclose($handle); + } + + /** + * Destroy the global settings stored in the settings (they sould not be used anymore...) + * @return NULL (TODO : return status) + */ + public function destroyGlobalSettings() + { + setGlobalSetting('updateavailable','0'); + setGlobalSetting('updatebuild',''); + setGlobalSetting('updateversions',''); + } + + /** + * This function provide status information about files presents on the system that will be afected by the update : do they exist ? are they writable ? modified ? + * @param int $updateinfo array of updated files + * @return array + */ public function getFileStatus($updateinfo) { - $existingfiles = array(); $modifiedfiles = array(); $readonlyfiles = array(); - - foreach ( $updateinfo as $file ) - { - $file = (array) $file; - $readonly_checked_file = $this->_getReadOnlyCheckedFile($file); - - if($readonly_checked_file->type == 'readonlyfile') - { - $readonlyfiles[] = $readonly_checked_file->file; - } - - $checkedfile = $this->_getCheckedFile($file); - switch ($checkedfile->type) { - case 'modifiedfile': - $modifiedfiles[] = $checkedfile->file; - break; - - case 'existingfile': - $existingfiles[] = $checkedfile->file; - } - } - - // Format the array for presentation in the view - if(count($readonlyfiles)) - { - foreach (array_unique($readonlyfiles) as $aFile) - { - $aReadOnlyFiles[]=substr($aFile,strlen(Yii::app()->getConfig("rootdir"))); - } - sort($aReadOnlyFiles); - $readonlyfiles=$aReadOnlyFiles; - } - - return array( - 'readonlyfiles'=>$readonlyfiles, - 'modifiedfiles'=>$modifiedfiles, - 'existingfiles'=>$existingfiles - ); - } - - /** - * Create a backup of the files that will be updated - * @param $updateinfos array of files to updated (needs file field) - * @return object error/success and text message - */ - public function backupFiles($updateinfos) - { - $filestozip=array(); - - foreach ($updateinfos as $file) - { - // Sort out directories - if (is_file($this->publicdir.$file->file)===true) - { - $filestozip[]=$this->publicdir.$file->file; - } - } - - Yii::app()->loadLibrary("admin/pclzip"); - $basefilename = dateShift(date("Y-m-d H:i:s"), "Y-m-d", Yii::app()->getConfig('timeadjust')).'_'.md5(uniqid(rand(), true)); - $archive = new PclZip($this->tempdir.DIRECTORY_SEPARATOR.'LimeSurvey_files_backup_'.$basefilename.'.zip'); - $v_list = $archive->add($filestozip, PCLZIP_OPT_REMOVE_PATH, $this->publicdir); - $backup = new stdClass(); - - if ( ! $v_list == 0) - { - $backup->result = TRUE; - $backup->basefilename = $basefilename; - $backup->tempdir = $this->tempdir; - } - else - { - $backup->result = FALSE; - $backup->error = 'cant_zip_backup'; - $backup->message = $archive->errorInfo(true); - } - return $backup; - } - - /** - * Create a backup of the DataBase - * @param $updateinfos array of files to updated (needs file field) - * @return object error/success and text message - */ - public function backupDb($destionationBuild) - { - $backupDb = new stdClass(); - $dbType = Yii::app()->db->getDriverName(); - - // We backup only mysql/mysqli database - // TODO : add postgresql - if( in_array($dbType, array('mysql', 'mysqli')) && Yii::app()->getConfig('demoMode') != true ) - { - // This function will call the server to get the requirement about DB, such as max size - $dbChecks = $this->_getDbChecks($destionationBuild); - - if( $dbChecks->result ) - { - $currentDbVersion = Yii::app()->getConfig("dbversionnumber"); - if( $currentDbVersion < $dbChecks->dbVersion ) - { - $dbSize = $this->_getDbTotalSize(); - if( $dbSize <= $dbChecks->dbSize ) - { - return $this->_createDbBackup(); - } - else - { - $backupDb->result = FALSE; - $backupDb->message = 'db_too_big'; - } - } - else - { - $backupDb->result = FALSE; - $backupDb->message = 'no_db_changes'; - } - } - } - else - { - $backupDb->result = TRUE; - $backupDb->message = 'not_mysql'; - } - - return $backupDb; - - } + $existingfiles = array(); $modifiedfiles = array(); $readonlyfiles = array(); + + foreach ( $updateinfo as $file ) + { + $file = (array) $file; + $readonly_checked_file = $this->_getReadOnlyCheckedFile($file); + + if($readonly_checked_file->type == 'readonlyfile') + { + $readonlyfiles[] = $readonly_checked_file->file; + } + + $checkedfile = $this->_getCheckedFile($file); + switch ($checkedfile->type) { + case 'modifiedfile': + $modifiedfiles[] = $checkedfile->file; + break; + + case 'existingfile': + $existingfiles[] = $checkedfile->file; + } + } + + // Format the array for presentation in the view + if(count($readonlyfiles)) + { + foreach (array_unique($readonlyfiles) as $aFile) + { + $aReadOnlyFiles[]=substr($aFile,strlen(Yii::app()->getConfig("rootdir"))); + } + sort($aReadOnlyFiles); + $readonlyfiles=$aReadOnlyFiles; + } + + return array( + 'readonlyfiles'=>$readonlyfiles, + 'modifiedfiles'=>$modifiedfiles, + 'existingfiles'=>$existingfiles + ); + } + + /** + * Create a backup of the files that will be updated + * @param $updateinfos array of files to updated (needs file field) + * @return object error/success and text message + */ + public function backupFiles($updateinfos) + { + $filestozip=array(); + + foreach ($updateinfos as $file) + { + // Sort out directories + if (is_file($this->publicdir.$file->file)===true) + { + $filestozip[]=$this->publicdir.$file->file; + } + } + + Yii::app()->loadLibrary("admin/pclzip"); + $basefilename = dateShift(date("Y-m-d H:i:s"), "Y-m-d", Yii::app()->getConfig('timeadjust')).'_'.md5(uniqid(rand(), true)); + $archive = new PclZip($this->tempdir.DIRECTORY_SEPARATOR.'LimeSurvey_files_backup_'.$basefilename.'.zip'); + $v_list = $archive->add($filestozip, PCLZIP_OPT_REMOVE_PATH, $this->publicdir); + $backup = new stdClass(); + + if ( ! $v_list == 0) + { + $backup->result = TRUE; + $backup->basefilename = $basefilename; + $backup->tempdir = $this->tempdir; + } + else + { + $backup->result = FALSE; + $backup->error = 'cant_zip_backup'; + $backup->message = $archive->errorInfo(true); + } + return $backup; + } + + /** + * Create a backup of the DataBase + * @param $updateinfos array of files to updated (needs file field) + * @return object error/success and text message + */ + public function backupDb($destionationBuild) + { + $backupDb = new stdClass(); + $dbType = Yii::app()->db->getDriverName(); + + // We backup only mysql/mysqli database + // TODO : add postgresql + if( in_array($dbType, array('mysql', 'mysqli')) && Yii::app()->getConfig('demoMode') != true ) + { + // This function will call the server to get the requirement about DB, such as max size + $dbChecks = $this->_getDbChecks($destionationBuild); + + if( $dbChecks->result ) + { + $currentDbVersion = Yii::app()->getConfig("dbversionnumber"); + if( $currentDbVersion < $dbChecks->dbVersion ) + { + $dbSize = $this->_getDbTotalSize(); + if( $dbSize <= $dbChecks->dbSize ) + { + return $this->_createDbBackup(); + } + else + { + $backupDb->result = FALSE; + $backupDb->message = 'db_too_big'; + } + } + else + { + $backupDb->result = FALSE; + $backupDb->message = 'no_db_changes'; + } + } + } + else + { + $backupDb->result = TRUE; + $backupDb->message = 'not_mysql'; + } + + return $backupDb; + + } /** @@ -516,126 +516,126 @@ public function backupDb($destionationBuild) * @access protected * @return mixed */ - public function getUpdateNotification() - { - $crosscheck = (getGlobalSetting('updatenotification')=="both")?1:0; - $updates = $this->getUpdateInfo($crosscheck="1"); - - $update_available = FALSE; - if($updates->result) - { - unset($updates->result); - - if( count($updates) > 0) - { - $update_available = TRUE; - $security_update_available = FALSE; - foreach( $updates as $update ) - { - if($update->security_update) - $security_update_available = TRUE; - } - } - $updates = array('result'=>$update_available , 'security_update'=>$security_update_available); - } - - - return (object) $updates; - - } - - - //// END OF INTERFACE //// - - - /** - * Call the server to get the necessary datas to check the database - */ - private function _getDbChecks($destinationBuild) - { - $getters = '/index.php?r=updates/get-db-checks&build=' . $destinationBuild ; - $content = $this->_performRequest($getters); - return $content; - } - - - /** - * Return the total size of the current database in MB - * @return int - */ - private function _getDbTotalSize() - { - $command = Yii::app()->db->createCommand("SHOW TABLE STATUS"); - $results = $command->query(); - - $size = 0; - foreach($results as $row) - { - $size += $row["Data_length"] + $row["Index_length"]; - } - - $dbSize = number_format($size/(1024*1024),2); - - return $dbSize; - } - - /** - * Create a backup of the DataBase - * @return array result of backup - */ - private function _createDbBackup() - { - Yii::app()->loadHelper("admin/backupdb"); - $backupDb = new stdClass(); - $basefilename = dateShift(date("Y-m-d H:i:s"), "Y-m-d", Yii::app()->getConfig('timeadjust')).'_'.md5(uniqid(rand(), true)); - $sfilename = $this->tempdir.DIRECTORY_SEPARATOR."backup_db_".randomChars(20)."_".dateShift(date("Y-m-d H:i:s"), "Y-m-d", Yii::app()->getConfig('timeadjust')).".sql"; - $dfilename = $this->tempdir.DIRECTORY_SEPARATOR."LimeSurvey_database_backup_".$basefilename.".zip"; - outputDatabase('',false,$sfilename); - - if( is_file($sfilename) && filesize($sfilename)) - { - $archive = new PclZip($dfilename); - $v_list = $archive->add(array($sfilename), PCLZIP_OPT_REMOVE_PATH, $this->tempdir,PCLZIP_OPT_ADD_TEMP_FILE_ON); - unlink($sfilename); - if ($v_list == 0) - { - $backupDb->result = FALSE; - $backupDb->message = 'db_backup_zip_failed'; - } - else - { - $backupDb->result = TRUE; - $backupDb->message = htmlspecialchars($dfilename); - } - } - else - { - $backupDb->result = FALSE; - $backupDb->message = htmlspecialchars(db_backup_failed); - } - return $backupDb; - - } - - - /** - * Check if a file (added/deleted/modified) from the update exists yet on the server and if it is readonly - * @param array $file a file to update (must contain file and type indexes) - * @return array containing a list of read only files - */ - private function _getReadOnlyCheckedFile($file) - { - $checkedfile = new stdClass(); - $checkedfile->type = ''; + public function getUpdateNotification() + { + $crosscheck = (getGlobalSetting('updatenotification')=="both")?1:0; + $updates = $this->getUpdateInfo($crosscheck="1"); + + $update_available = FALSE; + if($updates->result) + { + unset($updates->result); + + if( count($updates) > 0) + { + $update_available = TRUE; + $security_update_available = FALSE; + foreach( $updates as $update ) + { + if($update->security_update) + $security_update_available = TRUE; + } + } + $updates = array('result'=>$update_available , 'security_update'=>$security_update_available); + } + + + return (object) $updates; + + } + + + //// END OF INTERFACE //// + + + /** + * Call the server to get the necessary datas to check the database + */ + private function _getDbChecks($destinationBuild) + { + $getters = '/index.php?r=updates/get-db-checks&build=' . $destinationBuild ; + $content = $this->_performRequest($getters); + return $content; + } + + + /** + * Return the total size of the current database in MB + * @return int + */ + private function _getDbTotalSize() + { + $command = Yii::app()->db->createCommand("SHOW TABLE STATUS"); + $results = $command->query(); + + $size = 0; + foreach($results as $row) + { + $size += $row["Data_length"] + $row["Index_length"]; + } + + $dbSize = number_format($size/(1024*1024),2); + + return $dbSize; + } + + /** + * Create a backup of the DataBase + * @return array result of backup + */ + private function _createDbBackup() + { + Yii::app()->loadHelper("admin/backupdb"); + $backupDb = new stdClass(); + $basefilename = dateShift(date("Y-m-d H:i:s"), "Y-m-d", Yii::app()->getConfig('timeadjust')).'_'.md5(uniqid(rand(), true)); + $sfilename = $this->tempdir.DIRECTORY_SEPARATOR."backup_db_".randomChars(20)."_".dateShift(date("Y-m-d H:i:s"), "Y-m-d", Yii::app()->getConfig('timeadjust')).".sql"; + $dfilename = $this->tempdir.DIRECTORY_SEPARATOR."LimeSurvey_database_backup_".$basefilename.".zip"; + outputDatabase('',false,$sfilename); + + if( is_file($sfilename) && filesize($sfilename)) + { + $archive = new PclZip($dfilename); + $v_list = $archive->add(array($sfilename), PCLZIP_OPT_REMOVE_PATH, $this->tempdir,PCLZIP_OPT_ADD_TEMP_FILE_ON); + unlink($sfilename); + if ($v_list == 0) + { + $backupDb->result = FALSE; + $backupDb->message = 'db_backup_zip_failed'; + } + else + { + $backupDb->result = TRUE; + $backupDb->message = htmlspecialchars($dfilename); + } + } + else + { + $backupDb->result = FALSE; + $backupDb->message = htmlspecialchars(db_backup_failed); + } + return $backupDb; + + } + + + /** + * Check if a file (added/deleted/modified) from the update exists yet on the server and if it is readonly + * @param array $file a file to update (must contain file and type indexes) + * @return array containing a list of read only files + */ + private function _getReadOnlyCheckedFile($file) + { + $checkedfile = new stdClass(); + $checkedfile->type = ''; $checkedfile->file = ''; - - // We check if the file read only + + // We check if the file read only if ($file['type'] == 'A' && !file_exists($this->rootdir . $file['file']) || ($file['type'] == 'D' && file_exists($this->rootdir . $file['file']))) { $searchpath = $this->rootdir . $file['file']; $is_writable = is_writable(dirname($searchpath)); - - // LOUIS : snippet from the original code. It supposed to go up in the file sytem : if one directory need to be deleted... TODO : check if it works, if it's needed... + + // LOUIS : snippet from the original code. It supposed to go up in the file sytem : if one directory need to be deleted... TODO : check if it works, if it's needed... while ( !$is_writable && strlen($searchpath) > strlen($this->rootdir) ) { $searchpath = dirname($searchpath); @@ -647,308 +647,308 @@ private function _getReadOnlyCheckedFile($file) if ( !$is_writable ) { - $checkedfile->type = 'readonlyfile'; + $checkedfile->type = 'readonlyfile'; $checkedfile->file = $searchpath; } } elseif ( file_exists($this->rootdir . $file['file']) && !is_writable($this->rootdir . $file['file']) ) { - $checkedfile->type = 'readonlyfile'; + $checkedfile->type = 'readonlyfile'; $checkedfile->file = $this->rootdir . $file['file']; } - - return $checkedfile; - } - - /** - * Check if a given directory and its files are writable - * Used by the Updater of the Updater - */ - private function _checkDirectoryAndItsFiles($start_directory , $readOnly) - { - if(! is_writable( realpath ( $start_directory )) ) - $readOnly[] = realpath ( $start_directory ) ; - - $pattern = '*.*'; - $files = glob ( $start_directory.$pattern ); - - foreach( $files as $file ) - { - if(! is_writable( $file )) - $readOnly[] = $file ; - } - return $readOnly; - } - - /** - * Return a list of all the subdirectories (and their own subdirectories) of a given directory - * Used by the Updater of the Updater - */ - private function _getAllSubDirectories( $directory, $directory_seperator ) - { - $dirs = array_map( function($item)use($directory_seperator){ return $item . $directory_seperator;}, array_filter( glob( $directory . '*' ), 'is_dir') ); - - foreach( $dirs AS $dir ) - { - $dirs = array_merge( $dirs, $this->_getAllSubDirectories( $dir, $directory_seperator ) ); - } - - return $dirs; - } - - - /** - * Check if a file (added/deleted/) on the update yet exists on the server, or has been modified - * - * @param array $file array of files to update (must contain file, type and chekcsum indexes) - * @return array containing a list of read only files - */ - private function _getCheckedFile($file) - { - $checkedfile = new stdClass(); - $checkedfile->type = ''; + + return $checkedfile; + } + + /** + * Check if a given directory and its files are writable + * Used by the Updater of the Updater + */ + private function _checkDirectoryAndItsFiles($start_directory , $readOnly) + { + if(! is_writable( realpath ( $start_directory )) ) + $readOnly[] = realpath ( $start_directory ) ; + + $pattern = '*.*'; + $files = glob ( $start_directory.$pattern ); + + foreach( $files as $file ) + { + if(! is_writable( $file )) + $readOnly[] = $file ; + } + return $readOnly; + } + + /** + * Return a list of all the subdirectories (and their own subdirectories) of a given directory + * Used by the Updater of the Updater + */ + private function _getAllSubDirectories( $directory, $directory_seperator ) + { + $dirs = array_map( function($item)use($directory_seperator){ return $item . $directory_seperator;}, array_filter( glob( $directory . '*' ), 'is_dir') ); + + foreach( $dirs AS $dir ) + { + $dirs = array_merge( $dirs, $this->_getAllSubDirectories( $dir, $directory_seperator ) ); + } + + return $dirs; + } + + + /** + * Check if a file (added/deleted/) on the update yet exists on the server, or has been modified + * + * @param array $file array of files to update (must contain file, type and chekcsum indexes) + * @return array containing a list of read only files + */ + private function _getCheckedFile($file) + { + $checkedfile = new stdClass(); + $checkedfile->type = ''; $checkedfile->file = ''; - // We check if the file exist - if ( $file['type'] == 'A' && file_exists($this->rootdir . $file['file']) ) - { + // We check if the file exist + if ( $file['type'] == 'A' && file_exists($this->rootdir . $file['file']) ) + { //A new file, check if this already exists - $checkedfile->type = 'existingfile'; - $checkedfile->file = $file; + $checkedfile->type = 'existingfile'; + $checkedfile->file = $file; + } + + // We check if the file has been modified + elseif(($file['type'] == 'D' || $file['type'] == 'M') && is_file($this->rootdir . $file['file']) && sha1_file($this->rootdir . $file['file']) != $file['checksum']) + { + $checkedfile->type = 'modifiedfile'; + $checkedfile->file = $file; + } + + return $checkedfile; + } + + + /** + * Call the server to get the list of files and directory to check (and check type : writable / free space) + * @return object containing the list + */ + private function _getFileSystemCheckList() + { + $getters = '/index.php?r=updates/filesystemchecklist'; + $content = $this->_performRequest($getters); + $fileSystemCheck = $content->list; + + $checks = new stdClass(); + + // Strategy Pattern : different way to buil the path of the file + // Right now, calling _fileSystemCheckAppath() or _fileSystemCheckConfig() + // Could also use params in the futur : YAGNI !!!!! + $files = array(); + foreach($fileSystemCheck as $key => $obj) + { + $method = '_fileSystemCheck'.$obj->type; + $files[$key] = $this->$method($obj); + } + + return $files; + } + + /** + * Check if a file / dir is writable AND/OR if it has enough freespace + * @param object $obj an object containing the name of the file/directory to check, and what must be checked + * @return object the result of the test + */ + private function _fileSystemCheck($obj) + { + $check = new stdClass(); + $check->name = $obj->name; + + if($obj->writableCheck) + $check->writable = is_writable( $obj->name ); + else + $check->writable = 'pass'; + + if($obj->freespaceCheck) + $check->freespace = (disk_free_space( $obj->name ) > $obj->minfreespace ); + else + $check->freespace = 'pass'; + + return $check; + + } + + /** + * build the file / Directory path using APPATH, and then call the check method + * @param object $obj an object containing the name of the file/directory to check, and what must be checked + * @return object the result of the test + */ + private function _fileSystemCheckAppath($obj) + { + $obj->name = APPPATH . $obj->name; + $check = $this->_fileSystemCheck($obj); + + return $check; + } + + + /** + * build the file / Directory path using getConfig(), and then call the check method + * @param object $obj an object containing the name of the file/directory to check, and what must be checked + * @return object the result of the test + */ + private function _fileSystemCheckConfig($obj) + { + $obj->name = Yii::app()->getConfig($obj->name); + $check = $this->_fileSystemCheck($obj); + + return $check; + } + + /** + * Get the required minimal php version for destination build from server, and compare it to local php version. + * + * @param int $build the buildid to test + * @return object the success/error result + */ + private function _phpVerCheck($build) + { + $getters = '/index.php?r=updates/get-php-ver&build='.$build; + $php_ver = $this->_performRequest($getters); + + $return = new stdClass(); + $return->php_ver = $php_ver->php_version; + + if(version_compare(PHP_VERSION, $return->php_ver) >= 0) + { + $return->result = TRUE; + } + else + { + $return->result = FALSE; + $return->local_php_ver = PHP_VERSION; + } + return ( $return ); + } + + /** + * Get the list of required PHP modules for this update + * + * @param int $build the buildid to tes + * @return object the success/error message + */ + private function _getModuleChecks($build) + { + $getters = '/index.php?r=updates/get-php-modules&build='.$build; + $php_module_list = $this->_performRequest($getters); + + $return = new stdClass(); + if($php_module_list->result) + { + foreach( $php_module_list->php_modules as $module => $state ) + { + $return->$module = new stdClass(); + // Required or Optional + $return->$module->$state = TRUE; + // Installed or not + $return->$module->installed = ( extension_loaded ($module) ) ? TRUE : FALSE; + } } - - // We check if the file has been modified - elseif(($file['type'] == 'D' || $file['type'] == 'M') && is_file($this->rootdir . $file['file']) && sha1_file($this->rootdir . $file['file']) != $file['checksum']) - { - $checkedfile->type = 'modifiedfile'; - $checkedfile->file = $file; - } - - return $checkedfile; - } - - - /** - * Call the server to get the list of files and directory to check (and check type : writable / free space) - * @return object containing the list - */ - private function _getFileSystemCheckList() - { - $getters = '/index.php?r=updates/filesystemchecklist'; - $content = $this->_performRequest($getters); - $fileSystemCheck = $content->list; - - $checks = new stdClass(); - - // Strategy Pattern : different way to buil the path of the file - // Right now, calling _fileSystemCheckAppath() or _fileSystemCheckConfig() - // Could also use params in the futur : YAGNI !!!!! - $files = array(); - foreach($fileSystemCheck as $key => $obj) - { - $method = '_fileSystemCheck'.$obj->type; - $files[$key] = $this->$method($obj); - } - - return $files; - } - - /** - * Check if a file / dir is writable AND/OR if it has enough freespace - * @param object $obj an object containing the name of the file/directory to check, and what must be checked - * @return object the result of the test - */ - private function _fileSystemCheck($obj) - { - $check = new stdClass(); - $check->name = $obj->name; - - if($obj->writableCheck) - $check->writable = is_writable( $obj->name ); - else - $check->writable = 'pass'; - - if($obj->freespaceCheck) - $check->freespace = (disk_free_space( $obj->name ) > $obj->minfreespace ); - else - $check->freespace = 'pass'; - - return $check; - - } - - /** - * build the file / Directory path using APPATH, and then call the check method - * @param object $obj an object containing the name of the file/directory to check, and what must be checked - * @return object the result of the test - */ - private function _fileSystemCheckAppath($obj) - { - $obj->name = APPPATH . $obj->name; - $check = $this->_fileSystemCheck($obj); - - return $check; - } - - - /** - * build the file / Directory path using getConfig(), and then call the check method - * @param object $obj an object containing the name of the file/directory to check, and what must be checked - * @return object the result of the test - */ - private function _fileSystemCheckConfig($obj) - { - $obj->name = Yii::app()->getConfig($obj->name); - $check = $this->_fileSystemCheck($obj); - - return $check; - } - - /** - * Get the required minimal php version for destination build from server, and compare it to local php version. - * - * @param int $build the buildid to test - * @return object the success/error result - */ - private function _phpVerCheck($build) - { - $getters = '/index.php?r=updates/get-php-ver&build='.$build; - $php_ver = $this->_performRequest($getters); - - $return = new stdClass(); - $return->php_ver = $php_ver->php_version; - - if(version_compare(PHP_VERSION, $return->php_ver) >= 0) - { - $return->result = TRUE; - } - else - { - $return->result = FALSE; - $return->local_php_ver = PHP_VERSION; - } - return ( $return ); - } - - /** - * Get the list of required PHP modules for this update - * - * @param int $build the buildid to tes - * @return object the success/error message - */ - private function _getModuleChecks($build) - { - $getters = '/index.php?r=updates/get-php-modules&build='.$build; - $php_module_list = $this->_performRequest($getters); - - $return = new stdClass(); - if($php_module_list->result) - { - foreach( $php_module_list->php_modules as $module => $state ) - { - $return->$module = new stdClass(); - // Required or Optional - $return->$module->$state = TRUE; - // Installed or not - $return->$module->installed = ( extension_loaded ($module) ) ? TRUE : FALSE; - } - } - - //var_dump($return); die(); - return($return); - } - + + //var_dump($return); die(); + return($return); + } + /** * Returns the supported protocol extension (https/http) - * + * * @return string */ private function _getProtocol() { - $server_ssl = Yii::app()->getConfig("comfort_update_server_ssl"); - if( $server_ssl === 1 ) - { - if( extension_loaded("openssl") ) - { - return 'https://'; - } - } - return 'http://'; + $server_ssl = Yii::app()->getConfig("comfort_update_server_ssl"); + if( $server_ssl === 1 ) + { + if( extension_loaded("openssl") ) + { + return 'https://'; + } + } + return 'http://'; + } + + + + /** + * This function download a file from the ComfortUpdater and accept redirection + * @param string $getters request parameters + * @return object containing success = TRUE or error message + */ + private function _performDownload($getters, $fileName='update') + { + // TODO : Could test if curl is loaded, and if not, use httprequest2 + + $ch = curl_init(); + $pFile = fopen($this->tempdir.DIRECTORY_SEPARATOR.$fileName.'.zip', 'w'); + curl_setopt($ch, CURLOPT_URL, $this->_getProtocol().Yii::app()->getConfig("comfort_update_server_url").$getters); + curl_setopt($ch, CURLOPT_COOKIEFILE, $this->path_cookie ); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_HEADER, false); // We don't want the header to be written in the zip file ! + curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_FILE, $pFile); + $content = curl_exec($ch); + $content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); // But we want the header to be returned to the controller so we can check if a file has been returned + curl_close($ch); + + if($content_type == "application/zip") + $result = array("result"=>TRUE); + else + $result = array('result'=>FALSE, 'error'=>'error_while_processing_download'); + + return (object) $result; } - - - - /** - * This function download a file from the ComfortUpdater and accept redirection - * @param string $getters request parameters - * @return object containing success = TRUE or error message - */ - private function _performDownload($getters, $fileName='update') - { - // TODO : Could test if curl is loaded, and if not, use httprequest2 - - $ch = curl_init(); - $pFile = fopen($this->tempdir.DIRECTORY_SEPARATOR.$fileName.'.zip', 'w'); - curl_setopt($ch, CURLOPT_URL, $this->_getProtocol().Yii::app()->getConfig("comfort_update_server_url").$getters); - curl_setopt($ch, CURLOPT_COOKIEFILE, $this->path_cookie ); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_HEADER, false); // We don't want the header to be written in the zip file ! - curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); - curl_setopt($ch, CURLOPT_FILE, $pFile); - $content = curl_exec($ch); - $content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); // But we want the header to be returned to the controller so we can check if a file has been returned - curl_close($ch); - - if($content_type == "application/zip") - $result = array("result"=>TRUE); - else - $result = array('result'=>FALSE, 'error'=>'error_while_processing_download'); - - return (object) $result; - } - - - /** - * This function perform the request - * @param string $getters request parameters - * @return html the server page answer (json most of the time) - */ - private function _performRequest($getters, $CREATE_NEW_COOKIE_FILE=FALSE) - { - - if(( extension_loaded ("curl") )) - { - if( isset($_REQUEST['access_token']) ) - $getters .= "&access_token=".$_REQUEST['access_token']; - - $ch = curl_init($this->_getProtocol().Yii::app()->getConfig("comfort_update_server_url").$getters); - - if($CREATE_NEW_COOKIE_FILE) - curl_setopt($ch, CURLOPT_COOKIEJAR, $this->path_cookie ); - else - curl_setopt($ch, CURLOPT_COOKIEFILE, $this->path_cookie ); - - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - - $content = curl_exec($ch); - curl_close($ch); - - $content_decoded = json_decode ( base64_decode ( $content )); - if( ! is_object( $content_decoded )) - { - $content_decoded = new stdClass(); - $content_decoded->result = FALSE; - $content_decoded->error = "no_server_answer"; - $content_decoded->message = $content; - } - return $content_decoded; - } - else - { - // Should happen only on first step (get buttons), diplayed in check_updates/update_buttons/_updatesavailable_error.php - // Could rather define a call to httprequest2 functions. - return (object) array('result' => FALSE, 'error'=>"php_curl_not_loaded" ); - } - } + + + /** + * This function perform the request + * @param string $getters request parameters + * @return html the server page answer (json most of the time) + */ + private function _performRequest($getters, $CREATE_NEW_COOKIE_FILE=FALSE) + { + + if(( extension_loaded ("curl") )) + { + if( isset($_REQUEST['access_token']) ) + $getters .= "&access_token=".$_REQUEST['access_token']; + + $ch = curl_init($this->_getProtocol().Yii::app()->getConfig("comfort_update_server_url").$getters); + + if($CREATE_NEW_COOKIE_FILE) + curl_setopt($ch, CURLOPT_COOKIEJAR, $this->path_cookie ); + else + curl_setopt($ch, CURLOPT_COOKIEFILE, $this->path_cookie ); + + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + + $content = curl_exec($ch); + curl_close($ch); + + $content_decoded = json_decode ( base64_decode ( $content )); + if( ! is_object( $content_decoded )) + { + $content_decoded = new stdClass(); + $content_decoded->result = FALSE; + $content_decoded->error = "no_server_answer"; + $content_decoded->message = $content; + } + return $content_decoded; + } + else + { + // Should happen only on first step (get buttons), diplayed in check_updates/update_buttons/_updatesavailable_error.php + // Could rather define a call to httprequest2 functions. + return (object) array('result' => FALSE, 'error'=>"php_curl_not_loaded" ); + } + } } \ No newline at end of file diff --git a/application/views/admin/globalSettings_view.php b/application/views/admin/globalSettings_view.php index 3a4efc80c93..5f58b194f15 100755 --- a/application/views/admin/globalSettings_view.php +++ b/application/views/admin/globalSettings_view.php @@ -20,7 +20,7 @@
  • -
  • + 'form30','id'=>'frmglobalsettings','name'=>'frmglobalsettings'));?> diff --git a/application/views/admin/update/_ajaxVariables.php b/application/views/admin/update/_ajaxVariables.php index d1a7596441e..a7a714c5362 100644 --- a/application/views/admin/update/_ajaxVariables.php +++ b/application/views/admin/update/_ajaxVariables.php @@ -15,29 +15,29 @@ ?> - - + + - + - + - + "/> "/> - "/> + "/> "/> "/> "/> diff --git a/application/views/admin/update/_updateContainer.php b/application/views/admin/update/_updateContainer.php index 51ad7324437..b121c77270f 100644 --- a/application/views/admin/update/_updateContainer.php +++ b/application/views/admin/update/_updateContainer.php @@ -14,10 +14,10 @@ renderPartial("./update/_ajaxVariables"); ?>
    - - renderPartial("./update/check_updates/_checkButtons", array( "thisupdatecheckperiod"=>$thisupdatecheckperiod, "updatelastcheck"=>$updatelastcheck,"UpdateNotificationForBranch"=>$UpdateNotificationForBranch )); ?> - - renderPartial("./update/updater/_updater"); ?> + + renderPartial("./update/check_updates/_checkButtons", array( "thisupdatecheckperiod"=>$thisupdatecheckperiod, "updatelastcheck"=>$updatelastcheck,"UpdateNotificationForBranch"=>$UpdateNotificationForBranch )); ?> + + renderPartial("./update/updater/_updater"); ?>
    \ No newline at end of file diff --git a/application/views/admin/update/_update_notification.php b/application/views/admin/update/_update_notification.php index 2be833e9535..0678598d62c 100644 --- a/application/views/admin/update/_update_notification.php +++ b/application/views/admin/update/_update_notification.php @@ -11,11 +11,11 @@ diff --git a/application/views/admin/update/check_updates/_checkButtons.php b/application/views/admin/update/check_updates/_checkButtons.php index a538e3272c9..2ff0af3301d 100644 --- a/application/views/admin/update/check_updates/_checkButtons.php +++ b/application/views/admin/update/check_updates/_checkButtons.php @@ -12,64 +12,64 @@ */ ?>
    - -

    - + +

    +
    \ No newline at end of file diff --git a/application/views/admin/update/check_updates/update_buttons/_updatesavailable.php b/application/views/admin/update/check_updates/update_buttons/_updatesavailable.php old mode 100755 new mode 100644 index 698138f0a12..cdf4e301251 --- a/application/views/admin/update/check_updates/update_buttons/_updatesavailable.php +++ b/application/views/admin/update/check_updates/update_buttons/_updatesavailable.php @@ -15,48 +15,48 @@ // First we check if the server provided a specific HTML message if(isset($updateInfos->html)) { - if($updateInfos->html != "") - echo ''.$updateInfos->html.''; - - // And we unset this html message for the loop on update versions don't crush on it - unset($updateInfos->html); + if($updateInfos->html != "") + echo ''.$updateInfos->html.''; + + // And we unset this html message for the loop on update versions don't crush on it + unset($updateInfos->html); } ?> - + - - () - - - createUrl("admin/update/sa/getwelcome"); ?> - - 'launchUpdateForm')); ?> - - - - "ajax_button launch_update ui-button ui-widget ui-state-default ui-corner-all",)); ?> - - - - - - - - - - + + () + + + createUrl("admin/update/sa/getwelcome"); ?> + + 'launchUpdateForm')); ?> + + + + "ajax_button launch_update ui-button ui-widget ui-state-default ui-corner-all",)); ?> + + + + + + + + + + - + diff --git a/application/views/admin/update/check_updates/update_buttons/_updatesavailable_error.php b/application/views/admin/update/check_updates/update_buttons/_updatesavailable_error.php old mode 100755 new mode 100644 index 6b06d100f53..05dbb572133 --- a/application/views/admin/update/check_updates/update_buttons/_updatesavailable_error.php +++ b/application/views/admin/update/check_updates/update_buttons/_updatesavailable_error.php @@ -6,50 +6,50 @@ */ ?> html)) - if($serverAnswer->html != "") - echo $serverAnswer->html.'
    '; - - switch ($serverAnswer->error) - { - case 'php_curl_not_loaded': - $sTile = 'Error'; - $sHeader = 'PHP_CURL library not loaded !'; - $sMessage = "it seems that your server doesn't support PHP CURL Library. Please install it before proceeding to ComfortUpdate"; - break; - - case 'no_server_answer': - $sTile = 'Error'; - $sHeader = 'No server answer'; - $sMessage = "it seems that the Comfort Updater is not responding for now. Please, try again in few minutes, or contact LimeSurvey team"; - break; - - case 'no_update_available_for_your_version': - $sTile = 'Up to date !'; - $sHeader = 'No update available for your version'; - $sMessage = 'Your version is up to date !'; - break; + // First we check if the server provided a specific HTML message + if(isset($serverAnswer->html)) + if($serverAnswer->html != "") + echo $serverAnswer->html.'
    '; + + switch ($serverAnswer->error) + { + case 'php_curl_not_loaded': + $sTile = 'Error'; + $sHeader = 'PHP_CURL library not loaded !'; + $sMessage = "it seems that your server doesn't support PHP CURL Library. Please install it before proceeding to ComfortUpdate"; + break; + + case 'no_server_answer': + $sTile = 'Error'; + $sHeader = 'No server answer'; + $sMessage = "it seems that the Comfort Updater is not responding for now. Please, try again in few minutes, or contact LimeSurvey team"; + break; + + case 'no_update_available_for_your_version': + $sTile = 'Up to date !'; + $sHeader = 'No update available for your version'; + $sMessage = 'Your version is up to date !'; + break; - case 'not_updatable': - $sTile = 'Error'; - $sHeader = 'Not updatable !'; - $sMessage = 'Your version is not updatable via ComfortUpdate. Please, update manually.'; - break; - - case 'no_build': - $sTile = 'Error'; - $sHeader = 'No build version found !'; - $sMessage = "It seems you're using a version coming from the LimeSurvey GitHub repository. You can't use ComfortUpdate."; - break; - - default : - $sTile = 'Error'; - $sHeader = 'Unknown Error !'; - $sMessage = 'An unknown error occured. Please, contact LimeSurvey team.'; - $sErrorCode = 'error code : '.$serverAnswer->error; - break; - } + case 'not_updatable': + $sTile = 'Error'; + $sHeader = 'Not updatable !'; + $sMessage = 'Your version is not updatable via ComfortUpdate. Please, update manually.'; + break; + + case 'no_build': + $sTile = 'Error'; + $sHeader = 'No build version found !'; + $sMessage = "It seems you're using a version coming from the LimeSurvey GitHub repository. You can't use ComfortUpdate."; + break; + + default : + $sTile = 'Error'; + $sHeader = 'Unknown Error !'; + $sMessage = 'An unknown error occured. Please, contact LimeSurvey team.'; + $sErrorCode = 'error code : '.$serverAnswer->error; + break; + } ?> @@ -58,9 +58,9 @@

    -
    +
    " role="button" aria-disabled="false"> - - + + \ No newline at end of file diff --git a/application/views/admin/update/updater/_error.php b/application/views/admin/update/updater/_error.php index 1b885a54a08..4e85105221f 100644 --- a/application/views/admin/update/updater/_error.php +++ b/application/views/admin/update/updater/_error.php @@ -11,154 +11,154 @@ $buttons = 0; switch ($errorObject->error) { - case 'no_server_answer': - $title = gT('No server answer !'); - $message = gt("We couldn't reach the server, or the server didn't provide any answer. Please, try again in few minutes."); - break; - - case 'db_error': - $title = gT('Database error !'); - $message = gt("Comfort Update encounter an error while trying to get datas from your database."); - break; - - case 'unzip_error': - $title = gT('Unzip error'); - $message = gt("ComfortUpdate could not unzip the update file (or the updater update file)"); - break; - - case 'zip_update_not_found': - $title = gT('Zip file not found !'); - $message = gt("ComfortUpdate could not find the update file on your local system (or the updater update file)"); - break; - - case 'cant_zip_backup': - $title = gT('Zip error !'); - $message = gt("ComfortUpdate could not zip the files for your backup"); - break; - - case 'error_while_processing_download': - $title = gT('Download error !'); - $message = gt("ComfortUpdate could not download the update !"); - break; - - case 'out_of_updates': - $title = gt("Your update key is out of update !"); - $message = gt("you should first renew this key before using it, or try to enter a new one !"); - $buttons = 1; - break; - - case 'expired': - $title = gt("Your update key is expired !"); - $message = gt("you should first renew this key before using it, or try to enter a new one !"); - $buttons = 1; - break; + case 'no_server_answer': + $title = gT('No server answer !'); + $message = gt("We couldn't reach the server, or the server didn't provide any answer. Please, try again in few minutes."); + break; + + case 'db_error': + $title = gT('Database error !'); + $message = gt("Comfort Update encounter an error while trying to get datas from your database."); + break; + + case 'unzip_error': + $title = gT('Unzip error'); + $message = gt("ComfortUpdate could not unzip the update file (or the updater update file)"); + break; + + case 'zip_update_not_found': + $title = gT('Zip file not found !'); + $message = gt("ComfortUpdate could not find the update file on your local system (or the updater update file)"); + break; + + case 'cant_zip_backup': + $title = gT('Zip error !'); + $message = gt("ComfortUpdate could not zip the files for your backup"); + break; + + case 'error_while_processing_download': + $title = gT('Download error !'); + $message = gt("ComfortUpdate could not download the update !"); + break; + + case 'out_of_updates': + $title = gt("Your update key is out of update !"); + $message = gt("you should first renew this key before using it, or try to enter a new one !"); + $buttons = 1; + break; + + case 'expired': + $title = gt("Your update key is expired !"); + $message = gt("you should first renew this key before using it, or try to enter a new one !"); + $buttons = 1; + break; - case 'not_found': - $title = gt("Unknown update key !"); - $message = gt("Your key is unkown by the update server."); - $buttons = 3; - break; - - case 'key_null': - $title = gt("key can't be null !"); - $message = ""; - $buttons = 3; - break; - - case 'unknown_view': - $title = gt("The server try to call an unkown view !"); - $message = gt("Is your ComfortUpdater up to date ? Please, contact LimeSurvey team."); - $buttons = 3; - break; - - case 'unkown_destination_build': - $title = gt("Unkown destination build !"); - $message = gt("It seems that the ComfortUpdater don't know to which version you're trying to update. Please, restart the process."); - $buttons = 0; - break; - - case 'file_locked': - $title = gT('Update server busy'); - $message = gT('The update server is currently busy. This usually happens when the update files for a new version are being prepared.').'
    '.gT('Please be patient and try again in about 10 minutes.'); - $buttons = 0; - break; - - case 'server_error_creating_zip_update': - $title = gT('Server error !'); - $message = gT('An error occure while creating your update zip. Please, contact LimeSurvey team.'); - $buttons = 0; - break; - - case 'server_error_getting_checksums': - $title = gT('Server error !'); - $message = gT('An error occure while getting checksums. Please, contact LimeSurvey team.'); - $buttons = 0; - break; - - case 'cant_get_changeset': - $title = gT('Server error !'); - $message = gT('An error occure while getting the changeset. Please, contact LimeSurvey team.'); - $buttons = 0; - break; - - case 'wrong_token': - $title = gT('Unkown sessions'); - $message = gT('Your session with the ComfortUpdate server is not valid. Please, restart the process.'); - $buttons = 0; - break; - - case 'zip_error': - $title = gT('Error while creating zip file'); - $message = gt("An error occured while creating the backup of your files. Check your local system (permission, available space, etc.)"); - break; - - - case 'no_updates_infos': - $title = gT("Could not retrieve update infos datas"); - $message = gt("ComfortUpdate could not find the update infos datas."); - break; - - case 'cant_remove_deleted_files': - $title = gT("Could not remove the deleted files"); - $message = gT("ComfortUpdate could not delete from your system the removed file in the update."); - break; - - case 'cant_remove_deleted_directory': - $title = gT("Could not remove the deleted directories"); - $message = gT("ComfortUpdate could not delete from your system the removed directories in the update."); - break; - - - default: - $title = $errorObject->error; - $message = gt("Unknown error. Please, contact LimeSurvey team."); - $buttons = 0; - break; + case 'not_found': + $title = gt("Unknown update key !"); + $message = gt("Your key is unkown by the update server."); + $buttons = 3; + break; + + case 'key_null': + $title = gt("key can't be null !"); + $message = ""; + $buttons = 3; + break; + + case 'unknown_view': + $title = gt("The server try to call an unkown view !"); + $message = gt("Is your ComfortUpdater up to date ? Please, contact LimeSurvey team."); + $buttons = 3; + break; + + case 'unkown_destination_build': + $title = gt("Unkown destination build !"); + $message = gt("It seems that the ComfortUpdater don't know to which version you're trying to update. Please, restart the process."); + $buttons = 0; + break; + + case 'file_locked': + $title = gT('Update server busy'); + $message = gT('The update server is currently busy. This usually happens when the update files for a new version are being prepared.').'
    '.gT('Please be patient and try again in about 10 minutes.'); + $buttons = 0; + break; + + case 'server_error_creating_zip_update': + $title = gT('Server error !'); + $message = gT('An error occure while creating your update zip. Please, contact LimeSurvey team.'); + $buttons = 0; + break; + + case 'server_error_getting_checksums': + $title = gT('Server error !'); + $message = gT('An error occure while getting checksums. Please, contact LimeSurvey team.'); + $buttons = 0; + break; + + case 'cant_get_changeset': + $title = gT('Server error !'); + $message = gT('An error occure while getting the changeset. Please, contact LimeSurvey team.'); + $buttons = 0; + break; + + case 'wrong_token': + $title = gT('Unkown sessions'); + $message = gT('Your session with the ComfortUpdate server is not valid. Please, restart the process.'); + $buttons = 0; + break; + + case 'zip_error': + $title = gT('Error while creating zip file'); + $message = gt("An error occured while creating the backup of your files. Check your local system (permission, available space, etc.)"); + break; + + + case 'no_updates_infos': + $title = gT("Could not retrieve update infos datas"); + $message = gt("ComfortUpdate could not find the update infos datas."); + break; + + case 'cant_remove_deleted_files': + $title = gT("Could not remove the deleted files"); + $message = gT("ComfortUpdate could not delete from your system the removed file in the update."); + break; + + case 'cant_remove_deleted_directory': + $title = gT("Could not remove the deleted directories"); + $message = gT("ComfortUpdate could not delete from your system the removed directories in the update."); + break; + + + default: + $title = $errorObject->error; + $message = gt("Unknown error. Please, contact LimeSurvey team."); + $buttons = 0; + break; } ?>

    - +
    - - - - - - - - - - - - + + + + + + + + + + + + " role="button" aria-disabled="false"> - +
    diff --git a/application/views/admin/update/updater/_progress.php b/application/views/admin/update/updater/_progress.php index e87772ed1c4..f9fc5ba29ef 100644 --- a/application/views/admin/update/updater/_progress.php +++ b/application/views/admin/update/updater/_progress.php @@ -6,29 +6,29 @@ ?>

    -
      -
    1. - - -
    2. - -
    3. - -
    4. -
    5. - -
    6. -
    7. - -
    8. -
    9. - -
    10. -
    11. - -
    12. -
    13. - -
    14. -
    -
    \ No newline at end of file +
      +
    1. + + +
    2. + +
    3. + +
    4. +
    5. + +
    6. +
    7. + +
    8. +
    9. + +
    10. +
    11. + +
    12. +
    13. + +
    14. +
    + \ No newline at end of file diff --git a/application/views/admin/update/updater/_right_container.php b/application/views/admin/update/updater/_right_container.php index 5c85e609b2f..42d323e7aa6 100644 --- a/application/views/admin/update/updater/_right_container.php +++ b/application/views/admin/update/updater/_right_container.php @@ -6,14 +6,14 @@ ?>
    - - - - -
    - -
    + + + + +
    + +
    \ No newline at end of file diff --git a/application/views/admin/update/updater/_updater.php b/application/views/admin/update/updater/_updater.php index 5506665ec9d..d31e905cb21 100644 --- a/application/views/admin/update/updater/_updater.php +++ b/application/views/admin/update/updater/_updater.php @@ -2,13 +2,13 @@ /** * This view build the updater layout. Content is injected inside #updaterContainer by the ajax process */ -?> +?> \ No newline at end of file diff --git a/application/views/admin/update/updater/steps/_backup.php b/application/views/admin/update/updater/steps/_backup.php old mode 100755 new mode 100644 index 86c2cebdd4b..b4912605f5d --- a/application/views/admin/update/updater/steps/_backup.php +++ b/application/views/admin/update/updater/steps/_backup.php @@ -12,77 +12,77 @@

    html)) - echo $dbBackupInfos->html; + if(isset($dbBackupInfos->html)) + echo $dbBackupInfos->html; ?>
    -

    - -
    - -

    +

    + +
    + +

    - - result):?> -

    - -
    - message); ?> -

    - - message) { - - case 'db_too_big': - $db_message = 'Your DataBase is too big to be saved ! Before proceeding please backup your database using a backup tool!'; - break; - - case 'no_db_changes': - $db_message = 'This update will not change the database. No database backup required.'; - break; - - case 'not_mysql': - $db_message = 'Your DataBase is not using MySql ! Before proceeding please backup your database using a backup tool!'; - break; - - case 'db_backup_zip_failed': - $db_message = 'We could not zip your database ! Before proceeding please backup your database using a backup tool! '; - break; - - - - default : - $db_message = 'Unable to backup your database for unknow reason. Before proceeding please backup your database using a backup tool!'; - break; - } - ?> + + result):?> +

    + +
    + message); ?> +

    + + message) { + + case 'db_too_big': + $db_message = 'Your DataBase is too big to be saved ! Before proceeding please backup your database using a backup tool!'; + break; + + case 'no_db_changes': + $db_message = 'This update will not change the database. No database backup required.'; + break; + + case 'not_mysql': + $db_message = 'Your DataBase is not using MySql ! Before proceeding please backup your database using a backup tool!'; + break; + + case 'db_backup_zip_failed': + $db_message = 'We could not zip your database ! Before proceeding please backup your database using a backup tool! '; + break; + + + + default : + $db_message = 'Unable to backup your database for unknow reason. Before proceeding please backup your database using a backup tool!'; + break; + } + ?> -

    - -

    - - - -

    +

    + +

    + + + +

    - - getController()->createUrl("admin/update/sa/step4/");?> - 'launchStep4Form')); ?> - - - - + + getController()->createUrl("admin/update/sa/step4/");?> + 'launchStep4Form')); ?> + + + + - " role="button" aria-disabled="false"> - - - - "ui-button ui-widget ui-state-default ui-corner-all")); ?> - + " role="button" aria-disabled="false"> + + + + "ui-button ui-widget ui-state-default ui-corner-all")); ?> +

    \ No newline at end of file diff --git a/application/views/admin/update/updater/steps/_change_log.php b/application/views/admin/update/updater/steps/_change_log.php old mode 100755 new mode 100644 index ed3ad2e53ec..d05decbe0a2 --- a/application/views/admin/update/updater/steps/_change_log.php +++ b/application/views/admin/update/updater/steps/_change_log.php @@ -14,57 +14,57 @@

    -
    - -
    +
    + +
    changingBranch) { - $changelog.= gt("Note: Because you are updating from a stable to an unstable version or vice versa \n a change log might not be available or not complete.\n\n"); + $changelog.= gt("Note: Because you are updating from a stable to an unstable version or vice versa \n a change log might not be available or not complete.\n\n"); } foreach ($changelogs->changelogentries as $changelogentry) { - if (trim($changelogentry->changelog !='')) - { - - $tempfromversion=$changelogentry->versionnumber; - $tempfrombuild=$changelogentry->build; - - $changelog.="Changes from $tempfromversion Build $tempfrombuild to {$changelogentry->versionnumber} Build {$changelogentry->build} --- Legend: + New feature, # Updated feature, - Bug fix\n"; - $changelog.=$changelogentry->changelog; - } + if (trim($changelogentry->changelog !='')) + { + + $tempfromversion=$changelogentry->versionnumber; + $tempfrombuild=$changelogentry->build; + + $changelog.="Changes from $tempfromversion Build $tempfrombuild to {$changelogentry->versionnumber} Build {$changelogentry->build} --- Legend: + New feature, # Updated feature, - Bug fix\n"; + $changelog.=$changelogentry->changelog; + } } ?> - + - getController()->createUrl("admin/update/sa/fileSystem/"); - echo CHtml::beginForm($formUrl, 'post', array("id"=>"launchFileSystemForm")); - echo CHtml::hiddenField('destinationBuild' , $destinationBuild); - echo CHtml::hiddenField('access_token' , $access_token); - ?> - " role="button" aria-disabled="false"> - - - - 'step2launch', "class"=>"ui-button ui-widget ui-state-default ui-corner-all")); - echo CHtml::endForm(); - ?> + getController()->createUrl("admin/update/sa/fileSystem/"); + echo CHtml::beginForm($formUrl, 'post', array("id"=>"launchFileSystemForm")); + echo CHtml::hiddenField('destinationBuild' , $destinationBuild); + echo CHtml::hiddenField('access_token' , $access_token); + ?> + " role="button" aria-disabled="false"> + + + + 'step2launch', "class"=>"ui-button ui-widget ui-state-default ui-corner-all")); + echo CHtml::endForm(); + ?> - + \ No newline at end of file diff --git a/application/views/admin/update/updater/steps/_check_local_errors.php b/application/views/admin/update/updater/steps/_check_local_errors.php index 7c36cb61c28..ff258fbe063 100644 --- a/application/views/admin/update/updater/steps/_check_local_errors.php +++ b/application/views/admin/update/updater/steps/_check_local_errors.php @@ -9,88 +9,88 @@ ?> createUrl("admin/globalsettings", array("update"=>'checkLocalErrors', 'destinationBuild' => $destinationBuild, 'access_token' => $access_token)); - $errors = FALSE; - //var_dump($localChecks); die(); + $urlNew = Yii::app()->createUrl("admin/globalsettings", array("update"=>'checkLocalErrors', 'destinationBuild' => $destinationBuild, 'access_token' => $access_token)); + $errors = FALSE; + //var_dump($localChecks); die(); ?>

    html) ) - echo $localChecks->html; + if( isset($localChecks->html) ) + echo $localChecks->html; ?> @@ -98,38 +98,38 @@

    - - + +

    - " role="button" aria-disabled="false"> - - - - - + " role="button" aria-disabled="false"> + + + + +

    - - - getController()->createUrl("admin/update/sa/changeLog/"); - echo CHtml::beginForm($formUrl, 'post', array("id"=>"launchChangeLogForm")); - echo CHtml::hiddenField('destinationBuild' , $destinationBuild); - echo CHtml::hiddenField('access_token' , $access_token); - ?> - " role="button" aria-disabled="false"> - - - - 'step1launch', "class"=>"ui-button ui-widget ui-state-default ui-corner-all")); - echo CHtml::endForm(); - ?> + + + getController()->createUrl("admin/update/sa/changeLog/"); + echo CHtml::beginForm($formUrl, 'post', array("id"=>"launchChangeLogForm")); + echo CHtml::hiddenField('destinationBuild' , $destinationBuild); + echo CHtml::hiddenField('access_token' , $access_token); + ?> + " role="button" aria-disabled="false"> + + + + 'step1launch', "class"=>"ui-button ui-widget ui-state-default ui-corner-all")); + echo CHtml::endForm(); + ?>

    @@ -137,5 +137,5 @@ \ No newline at end of file diff --git a/application/views/admin/update/updater/steps/_fileSystem.php b/application/views/admin/update/updater/steps/_fileSystem.php old mode 100755 new mode 100644 index 291dc6cecfb..a0babb1f2ce --- a/application/views/admin/update/updater/steps/_fileSystem.php +++ b/application/views/admin/update/updater/steps/_fileSystem.php @@ -13,63 +13,63 @@

    -
    - -
    +
    + +
    - - renderPartial("./update/updater/steps/textaeras/_readonlyfiles", array("readonlyfiles"=>$readonlyfiles) );?> - renderPartial("./update/updater/steps/textaeras/_existingfiles", array("existingfiles"=>$existingfiles) );?> - renderPartial("./update/updater/steps/textaeras/_modifiedfiles", array("modifiedfiles"=>$modifiedfiles) );?> + + renderPartial("./update/updater/steps/textaeras/_readonlyfiles", array("readonlyfiles"=>$readonlyfiles) );?> + renderPartial("./update/updater/steps/textaeras/_existingfiles", array("existingfiles"=>$existingfiles) );?> + renderPartial("./update/updater/steps/textaeras/_modifiedfiles", array("modifiedfiles"=>$modifiedfiles) );?> - - - 0):?> -
    - -

    - - createUrl('/admin/globalsettings'); - echo CHtml::beginForm($url, 'post'); - echo CHtml::hiddenField('destinationBuild' , $destinationBuild); - echo CHtml::hiddenField('access_token' , $access_token); - echo CHtml::hiddenField('update' , 'checkFiles'); - //echo CHtml::hiddenField('datasupdateinfo' , $datasupdateinfo); - echo ' - '.gT("Cancel").' - '; - echo CHtml::submitButton(gT('Check again'), array("class"=>"ui-button ui-widget ui-state-default ui-corner-all")); - echo CHtml::endForm(); - ?> -

    - -

    - '; ?> - - createUrl('/admin/update/sa/backup'); - echo CHtml::beginForm($url, 'post', array("id"=>"launchBackupForm")); - echo CHtml::hiddenField('destinationBuild' , $destinationBuild); - echo CHtml::hiddenField('access_token' , $access_token); - echo CHtml::hiddenField('datasupdateinfo' , $datasupdateinfo); - echo ' - '.gT("Cancel").' - '; - echo CHtml::submitButton(sprintf(gT('Continue')), array("class"=>"ui-button ui-widget ui-state-default ui-corner-all")); - echo CHtml::endForm(); - ?> -

    - + + + 0):?> +
    + +

    + + createUrl('/admin/globalsettings'); + echo CHtml::beginForm($url, 'post'); + echo CHtml::hiddenField('destinationBuild' , $destinationBuild); + echo CHtml::hiddenField('access_token' , $access_token); + echo CHtml::hiddenField('update' , 'checkFiles'); + //echo CHtml::hiddenField('datasupdateinfo' , $datasupdateinfo); + echo ' + '.gT("Cancel").' + '; + echo CHtml::submitButton(gT('Check again'), array("class"=>"ui-button ui-widget ui-state-default ui-corner-all")); + echo CHtml::endForm(); + ?> +

    + +

    + '; ?> + + createUrl('/admin/update/sa/backup'); + echo CHtml::beginForm($url, 'post', array("id"=>"launchBackupForm")); + echo CHtml::hiddenField('destinationBuild' , $destinationBuild); + echo CHtml::hiddenField('access_token' , $access_token); + echo CHtml::hiddenField('datasupdateinfo' , $datasupdateinfo); + echo ' + '.gT("Cancel").' + '; + echo CHtml::submitButton(sprintf(gT('Continue')), array("class"=>"ui-button ui-widget ui-state-default ui-corner-all")); + echo CHtml::endForm(); + ?> +

    +
    \ No newline at end of file diff --git a/application/views/admin/update/updater/steps/_final.php b/application/views/admin/update/updater/steps/_final.php old mode 100755 new mode 100644 index 674dd188d36..cb16637cc9f --- a/application/views/admin/update/updater/steps/_final.php +++ b/application/views/admin/update/updater/steps/_final.php @@ -8,17 +8,17 @@

    session['updateinfo']['toversion']).'
    '; + echo sprintf(gT('Buildnumber was successfully updated to %s.'),Yii::app()->session['updateinfo']['toversion']).'
    '; eT('The update is now complete!'); ?>

    - " role="button" aria-disabled="false"> - - - + " role="button" aria-disabled="false"> + + +
    - + diff --git a/application/views/admin/update/updater/steps/_updater_updated.php b/application/views/admin/update/updater/steps/_updater_updated.php index 64c72a880f3..1c17eeb0bdc 100644 --- a/application/views/admin/update/updater/steps/_updater_updated.php +++ b/application/views/admin/update/updater/steps/_updater_updated.php @@ -4,19 +4,19 @@ */ ?> createUrl("admin/globalsettings", array("update"=>'welcome', 'destinationBuild'=>$destinationBuild)); + $urlContinue = Yii::app()->createUrl("admin/globalsettings", array("update"=>'welcome', 'destinationBuild'=>$destinationBuild)); ?>

    -

    - -

    -

    - -

    - +

    + +

    +

    + +

    +
    - + diff --git a/application/views/admin/update/updater/steps/textaeras/_existingfiles.php b/application/views/admin/update/updater/steps/textaeras/_existingfiles.php index 92c58f26eba..85fa9db8df9 100644 --- a/application/views/admin/update/updater/steps/textaeras/_existingfiles.php +++ b/application/views/admin/update/updater/steps/textaeras/_existingfiles.php @@ -9,11 +9,11 @@ ?> 0): ?> - -
    - -
    - -

    - -

    +

    + +

    \ No newline at end of file diff --git a/application/views/admin/update/updater/steps/textaeras/_modifiedfiles.php b/application/views/admin/update/updater/steps/textaeras/_modifiedfiles.php index 7d4048142cc..3b9c188dedb 100644 --- a/application/views/admin/update/updater/steps/textaeras/_modifiedfiles.php +++ b/application/views/admin/update/updater/steps/textaeras/_modifiedfiles.php @@ -8,10 +8,10 @@ */ ?> 0): ?> - -
    - -
    + +
    + +
    -

    - -

    +

    + +

    diff --git a/application/views/admin/update/updater/steps/textaeras/_readonlyfiles.php b/application/views/admin/update/updater/steps/textaeras/_readonlyfiles.php index d6351b4d8a3..2f011c571a2 100644 --- a/application/views/admin/update/updater/steps/textaeras/_readonlyfiles.php +++ b/application/views/admin/update/updater/steps/textaeras/_readonlyfiles.php @@ -8,20 +8,20 @@ */ ?> 0):?> - - -
    -
    -
    + + +
    +
    +
    - + -

    - -

    +

    + +

    \ No newline at end of file diff --git a/application/views/admin/update/updater/welcome/_error.php b/application/views/admin/update/updater/welcome/_error.php index ef10de83f32..220b7ac02e9 100644 --- a/application/views/admin/update/updater/welcome/_error.php +++ b/application/views/admin/update/updater/welcome/_error.php @@ -11,79 +11,79 @@ // View is right place to do this, so it's easy for further integrators to change messages. switch ($serverAnswer->error) { - case 'out_of_updates': - $title = "Your update key is out of update !"; - $message = "you should first renew this key before using it, or try to enter a new one !"; - $buttons = 1; - break; - - case 'expired': - $title = "Your update key is expired !"; - $message = "you should first renew this key before using it, or try to enter a new one !"; - $buttons = 1; - break; + case 'out_of_updates': + $title = "Your update key is out of update !"; + $message = "you should first renew this key before using it, or try to enter a new one !"; + $buttons = 1; + break; + + case 'expired': + $title = "Your update key is expired !"; + $message = "you should first renew this key before using it, or try to enter a new one !"; + $buttons = 1; + break; - case 'not_found': - $title = "Unknown update key !"; - $message = "Your key is unkown by the update server."; - $buttons = 3; - break; - - case 'key_null': - $title = "key can't be null !"; - $message = ""; - $buttons = 3; - break; - - case 'unkown_destination_build': - $title = "Unkown destination build !"; - $message = "It seems that the ComfortUpdater don't know to which version you're trying to update. Please, restart the process."; - break; - - case 'file_locked': - $title = 'Update server busy'; - $message = 'The update server is currently busy. This usually happens when the update files for a new version are being prepared
    Please be patient and try again in about 10 minutes.'; - break; + case 'not_found': + $title = "Unknown update key !"; + $message = "Your key is unkown by the update server."; + $buttons = 3; + break; + + case 'key_null': + $title = "key can't be null !"; + $message = ""; + $buttons = 3; + break; + + case 'unkown_destination_build': + $title = "Unkown destination build !"; + $message = "It seems that the ComfortUpdater don't know to which version you're trying to update. Please, restart the process."; + break; + + case 'file_locked': + $title = 'Update server busy'; + $message = 'The update server is currently busy. This usually happens when the update files for a new version are being prepared
    Please be patient and try again in about 10 minutes.'; + break; - case 'zip_error': - $title = gT('Error while creating zip file'); - $message = "An error occured while creating the backup of your files. Check your local system (permission, available space, etc.)"; - break; - - default: - $title = $serverAnswer->error; - $message = "Unknown error. Please, contact LimeSurvey team."; - break; + case 'zip_error': + $title = gT('Error while creating zip file'); + $message = "An error occured while creating the backup of your files. Check your local system (permission, available space, etc.)"; + break; + + default: + $title = $serverAnswer->error; + $message = "Unknown error. Please, contact LimeSurvey team."; + break; } ?>

    html) ) - echo $serverAnswer->html; + if( isset($serverAnswer->html) ) + echo $serverAnswer->html; ?>
    - +
    - - - - - - - - - - - - + + + + + + + + + + + + " role="button" aria-disabled="false"> - +
    diff --git a/application/views/admin/update/updater/welcome/_error_files_update_updater.php b/application/views/admin/update/updater/welcome/_error_files_update_updater.php index 8f8772062f3..52de11274cc 100644 --- a/application/views/admin/update/updater/welcome/_error_files_update_updater.php +++ b/application/views/admin/update/updater/welcome/_error_files_update_updater.php @@ -10,20 +10,20 @@

    html) ) - echo $serverAnswer->html; + if( isset($serverAnswer->html) ) + echo $serverAnswer->html; ?>

    - -
    - readOnly as $readonly ):?> - ";?> - -
    - - - " role="button" aria-disabled="false"> - - + +
    + readOnly as $readonly ):?> + ";?> + +
    + + + " role="button" aria-disabled="false"> + +

    diff --git a/application/views/admin/update/updater/welcome/_key_updated.php b/application/views/admin/update/updater/welcome/_key_updated.php index 1cf33bd4ea6..82cdae8820d 100644 --- a/application/views/admin/update/updater/welcome/_key_updated.php +++ b/application/views/admin/update/updater/welcome/_key_updated.php @@ -1,19 +1,19 @@ createUrl("admin/globalsettings", array("update"=>'welcome', 'destinationBuild'=>$_POST["destinationBuild"])); + // TODO : move to the controler + $urlContinue = Yii::app()->createUrl("admin/globalsettings", array("update"=>'welcome', 'destinationBuild'=>$_POST["destinationBuild"])); ?>

    html) ) - echo $serverAnswer->html; + if( isset($serverAnswer->html) ) + echo $serverAnswer->html; ?>
    - +
    - + diff --git a/application/views/admin/update/updater/welcome/_subscribe.php b/application/views/admin/update/updater/welcome/_subscribe.php index 964a77d026c..b588650efa8 100644 --- a/application/views/admin/update/updater/welcome/_subscribe.php +++ b/application/views/admin/update/updater/welcome/_subscribe.php @@ -7,32 +7,32 @@

    title);?>

    html) ) - echo $serverAnswer->html; + if( isset($serverAnswer->html) ) + echo $serverAnswer->html; ?>
    -
    - message); ?> - - createUrl('/admin/update/sa/submitkey'); - echo CHtml::beginForm($url, 'post', array("id"=>"submitKeyForm")); - echo CHtml::hiddenField('destinationBuild', $_REQUEST['destinationBuild']); - echo CHtml::textField('keyid', '', array("id"=>"inputKey")); - echo CHtml::submitButton('submit', array("class"=>"ui-button ui-widget ui-state-default ui-corner-all", "id"=>"submitKeyButton")); - ?> - - " role="button" aria-disabled="false"> - - - - - +
    + message); ?> + + createUrl('/admin/update/sa/submitkey'); + echo CHtml::beginForm($url, 'post', array("id"=>"submitKeyForm")); + echo CHtml::hiddenField('destinationBuild', $_REQUEST['destinationBuild']); + echo CHtml::textField('keyid', '', array("id"=>"inputKey")); + echo CHtml::submitButton('submit', array("class"=>"ui-button ui-widget ui-state-default ui-corner-all", "id"=>"submitKeyButton")); + ?> + + " role="button" aria-disabled="false"> + + + + +
    \ No newline at end of file diff --git a/application/views/admin/update/updater/welcome/_updater_update.php b/application/views/admin/update/updater/welcome/_updater_update.php index e9e5405e76c..fa246818dba 100644 --- a/application/views/admin/update/updater/welcome/_updater_update.php +++ b/application/views/admin/update/updater/welcome/_updater_update.php @@ -6,16 +6,16 @@

    html) ) - echo $serverAnswer->html; + if( isset($serverAnswer->html) ) + echo $serverAnswer->html; ?>
    - -
    - -
    - + +
    + +
    +
    @@ -23,15 +23,15 @@ createUrl("admin/update/sa/updateUpdater"); ?> 'launchUpdateUpdaterForm')); ?> - destinationBuild); ?> - " role="button" aria-disabled="false"> - - - "ajax_button ui-button ui-widget ui-state-default ui-corner-all",)); ?> + destinationBuild); ?> + " role="button" aria-disabled="false"> + + + "ajax_button ui-button ui-widget ui-state-default ui-corner-all",)); ?> \ No newline at end of file diff --git a/application/views/admin/update/updater/welcome/_welcome.php b/application/views/admin/update/updater/welcome/_welcome.php index d954d83114f..d2953bbc22b 100644 --- a/application/views/admin/update/updater/welcome/_welcome.php +++ b/application/views/admin/update/updater/welcome/_welcome.php @@ -12,57 +12,57 @@

    title);?>

    html) ) - echo $serverAnswer->html; + if( isset($serverAnswer->html) ) + echo $serverAnswer->html; ?>
    -
    '; - echo ''; - ?> - -
    - - createUrl("admin/update/sa/checkLocalErrors"); ?> - 'launchCheckLocalErrorsForm')); ?> - destinationBuild); ?> - access_token); ?> - " role="button" aria-disabled="false"> - - - "ajax_button ui-button ui-widget ui-state-default ui-corner-all",)); ?> - -
    +
    '; + echo ''; + ?> + +
    + + createUrl("admin/update/sa/checkLocalErrors"); ?> + 'launchCheckLocalErrorsForm')); ?> + destinationBuild); ?> + access_token); ?> + " role="button" aria-disabled="false"> + + + "ajax_button ui-button ui-widget ui-state-default ui-corner-all",)); ?> + +
    -

    -
    -

    - : key_infos->keyid; ?>
    - : key_infos->validuntil; ?>
    - key_infos->remaining_updates; ?> updatekey_infos->remaining_updates > 1 ){echo 's';}?>
    -
    -
    - - - - - - - -
    +

    +
    +

    + : key_infos->keyid; ?>
    + : key_infos->validuntil; ?>
    + key_infos->remaining_updates; ?> updatekey_infos->remaining_updates > 1 ){echo 's';}?>
    +
    +
    + + + + + + + +
    \ No newline at end of file