archive = "https://gitlab.telaaedifex.com/xevidos/codiad/-/archive/master/codiad-master.zip"; $this->commits = "https://gitlab.telaaedifex.com/api/v4/projects/3/repository/commits/"; $this->tags = "https://gitlab.telaaedifex.com/api/v4/projects/3/repository/tags/"; //$this->protocol = $this->CheckProtocol(); } ////////////////////////////////////////////////////////////////// // Set Initial Version ////////////////////////////////////////////////////////////////// public function Init() { $version = array(); } ////////////////////////////////////////////////////////////////// // Clear Version ////////////////////////////////////////////////////////////////// public function Clear() { $version[] = array("version"=>"","time"=>time(),"optout"=>"true","name"=>$_SESSION['user']); saveJSON('version.php', $version); } ////////////////////////////////////////////////////////////////// // Clear Version ////////////////////////////////////////////////////////////////// public function OptOut() { $current = getJSON('version.php'); $version[] = array("version"=>$current[0]['version'],"time"=>$current[0]['time'],"optout"=>"true","name"=>$current[0]['name']); saveJSON('version.php', $version); } ////////////////////////////////////////////////////////////////// // Check Version ////////////////////////////////////////////////////////////////// public function Check() { /* $local = $this->getLocalVersion(); $remote = $this->getRemoteVersion("check", $local[0]['version']); $nightly = true; $archive = Common::getConstant('ARCHIVEURL', $this->archive); $latest = ''; foreach ($remote as $tag) { if ($latest == '') { $latest = $tag["name"]; $archive = $tag["zipball_url"]; } if ($local[0]['version'] == $tag["commit"]["sha"]) { $local[0]['version'] = $tag["name"]; $nightly = false; break; } } $search = array("\r\n", "\n", "\r"); $replace = array(" ", " ", " "); $message = ''; $merge = ''; $commits = json_decode(file_get_contents(Common::getConstant('COMMITURL', $this->commits)), true); foreach ($commits as $commit) { if ($local[0]['version'] != $commit["sha"]) { if (strpos($commit["commit"]["message"], "Merge") === false) { $message .= '- '.str_replace($search, $replace, $commit["commit"]["message"]).'
'; } else { $merge .= '- '.str_replace($search, $replace, $commit["commit"]["message"]).'
'; } } else { break; } } if ($message == '') { $message = $merge; } */ $archive = $this->archive; $current_version = self::VERSION; $nightly = false; $response = $this->getRemoteVersion("check"); //return "[".formatJSEND("success", array("currentversion"=>$local[0]['version'],"remoteversion"=>$latest,"message"=>$message,"archive"=>$archive,"nightly"=>$nightly,"name"=>$local[0]['name']))."]"; return "[".formatJSEND("success", array("currentversion"=>$current_version,"remoteversion"=>$response["name"],"message"=>$response["message"],"archive"=>$archive,"nightly"=>$nightly,"name"=>$response["author_name"]))."]"; } ////////////////////////////////////////////////////////////////// // Get Local Version ////////////////////////////////////////////////////////////////// public function Download(){ } ////////////////////////////////////////////////////////////////// // Get Local Version ////////////////////////////////////////////////////////////////// public function getLocalVersion(){ return getJSON('version.php');; } ////////////////////////////////////////////////////////////////// // Get Remote Version ////////////////////////////////////////////////////////////////// public function getRemoteVersion($action="check", $localversion = "") { //$remoteurl = Common::getConstant('UPDATEURL', $this->remote); if ( $this->protocol === "none" ) { return; } switch( $this->protocol ) { case( "curl" ): $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $this->tags); //curl_setopt($curl, CURLOPT_POSTFIELDS, ""); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13'); $content = curl_exec($curl); curl_close($curl); $response = json_decode( $content, true ); //Return latest release return $response[0]; break; case( "fopen" ): break; } return json_decode(file_get_contents($remoteurl), true); } }