public function update_system_version() { $url = $this->nascop_url . "sync/gitlog"; $facility_code = $this->session->userdata("facility"); $hash = Git_Log::getLatestHash(); $results = array("facility_code" => $facility_code, "hash_value" => $hash); $json_data = json_encode($results, JSON_PRETTY_PRINT); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, array('json_data' => $json_data)); $json_data = curl_exec($ch); if (empty($json_data)) { $message = "cURL Error: " . curl_error($ch) . "<br/>"; } else { $messages = json_decode($json_data, TRUE); $message = $messages[0] . "<br/>"; } curl_close($ch); return $message; }
public function update_notification() { ini_set("max_execution_time", "1000000"); $this->load->library('Curl'); $main_link = base_url() . "github/"; $main_link = str_replace("ADT", "UPDATE", $main_link); $url = $main_link . "checkJsonUpdate"; $curl = new Curl(); $curl->get($url); $temp = ""; $order_link = $main_link; $changelog_link = base_url() . 'changelog.txt'; //check if update is needed if ($curl->error) { //shows when error $curl->error_code; $temp .= "Error: " . $curl->error_code; } else { //shows if request successful $main_array = json_decode($curl->response, TRUE); if ($main_array == true) { //check if update session is present if ($this->session->userdata("update_session") == "") { //update needed $main_link = base_url() . "github/"; $main_link = str_replace("ADT", "UPDATE", $main_link); $url = $main_link . "runGithubUpdater"; //create update session $this->session->set_userdata("update_session", true); //get update $curl->get($url); if ($curl->error) { //error when getting update $curl->error_code; $temp = "Error: " . $curl->error_code; } else { $temp = "<li><a href='{$changelog_link}' target='_blank'><i class='icon-th'></i>System Up to Date</a></li>"; //delete update file $hash = Git_Log::getLatestHash(); $file = $_SERVER['DOCUMENT_ROOT'] . "/UPDATE/" . $hash . ".zip"; if (is_file($file)) { unlink($file); } } //on completion unset update session $this->session->set_userdata("update_session", ""); } else { //update in progress $temp = "<li><a href='#' target='_blank'><i class='icon-th'></i>Update in Progress...</a></li>"; } } else { //system up to date $temp = "<li><a href='{$changelog_link}' target='_blank'><i class='icon-th'></i>System Up to Date</a></li>"; //delete update file $hash = Git_Log::getLatestHash(); $file = $_SERVER['DOCUMENT_ROOT'] . "/UPDATE/" . $hash . ".zip"; if (is_file($file)) { unlink($file); } } } echo $temp; }