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; }
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']); $smarty->assign('currentC', $currentVObj['commit']); $lasteV = $startUp->get_web_page('https://raw.githubusercontent.com/atmoner/Bittytorrent/master/version?access_token=00d6ca368c3f725bb1ba63663debd5dc212da0c2'); $jsonObj = json_decode($lasteV['content']); $smarty->assign('lasteV', $jsonObj->version); $smarty->assign('lasteC', $jsonObj->commit); $smarty->assign('updateValue', $jsonObj->updateValue); $smarty->assign('updateMessage', $jsonObj->updateMessage); }