public static function makeUpdate($params) { //@tosee: //https://site.ru/local/dev/lp_b24_hosting/lp_b24_hosting.php?className=ShefAutoUpdate&functionName=makeUpdate&token=dekqkddeiorsojdoaixuiqcafwnhwudi&projectId=2 $result = array(); $update = new AutoUpdate(true); $update->currentVersion = iLPB24HOSTINGVER; $update->updateUrl = DEFAULT_UPDATE_SERVER; //Check for a new update $latest = $update->checkUpdate(); if ($latest !== false) { if ($latest > $update->currentVersion) { //Install new update if ($update->update()) { $result = array('response' => array('status' => 'ok', 'message' => 'Update_successful'), 'values' => array($update->latestVersionName)); } else { $result = array('response' => array('status' => 'error', 'message' => 'Update_failed'), 'values' => array()); } } else { $result = array('response' => array('status' => 'ok', 'message' => 'Current_Version_is_up_to_date'), 'values' => array()); } } else { $result = array('response' => array('status' => 'error', 'message' => $update->getLastError()), 'values' => array()); } return $result; }
/** * Function making the update if a new version is available * * @return json */ public function makeUpdate() { $r = array(); $r['install'] = false; $update = new AutoUpdate(); $update->setCurrentVersion($this->getCurrentVersion()); $result = $update->update(); //fait une simulation d'abord, si ok ça install if ($result === true) { //echo 'Update successful<br>'; $r['install'] = true; } else { // si echec de la simulation d'install //echo 'Update failed: ' . $result . '!<br>'; if ($result = AutoUpdate::ERROR_SIMULATE) { $r['information'] = '<pre>' . var_dump($update->getSimulationResults()) . '</pre>'; } } return $this->sendResponse($r); }
require $path . '/libs/Update.class.php'; $update = new AutoUpdate(true); $update->currentVersion = 2; //Must be an integer - you can't compare strings $update->updateUrl = 'http://localhost/libs'; //Replace with your server update directory //Check for a new update $latest = $update->checkUpdate(); if ($latest !== false) { // var_dump($update->currentVersion); if ($latest > $update->currentVersion) { //Install new update $rUpdate = ""; $rUpdate .= "New Version: " . $update->latestVersionName . "<br />"; $rUpdate .= "Installing Update...<br />"; if ($update->update()) { $rUpdate .= "Update successful!"; } else { $rUpdate .= "Update failed!"; } } else { $rUpdate .= "Current Version is up to date"; } } else { echo $update->getLastError(); } $smarty->assign('returnUpdate', $rUpdate); } else { $version = $db->get_row("SELECT value FROM `settings` WHERE `key` LIKE 'version'"); $currentVObj = unserialize($version->value); $smarty->assign('currentV', $currentVObj['version']);