diff --git a/common.php b/common.php
index aead3d2..3e73c65 100755
--- a/common.php
+++ b/common.php
@@ -12,7 +12,7 @@
//////////////////////////////////////////////////////////////////
class Common {
-
+
//////////////////////////////////////////////////////////////////
// PROPERTIES
//////////////////////////////////////////////////////////////////
diff --git a/components/update/class.update.php b/components/update/class.update.php
index bfd433e..a240748 100755
--- a/components/update/class.update.php
+++ b/components/update/class.update.php
@@ -6,186 +6,187 @@
* [root]/license.txt for more. This information must remain intact.
*/
-class Update
-{
-
- //////////////////////////////////////////////////////////////////
- // PROPERTIES
- //////////////////////////////////////////////////////////////////
-
- public $remote = "";
- public $commits = "";
- public $archive = "";
-
- //////////////////////////////////////////////////////////////////
- // METHODS
- //////////////////////////////////////////////////////////////////
-
- // -----------------------------||----------------------------- //
-
- //////////////////////////////////////////////////////////////////
- // Construct
- //////////////////////////////////////////////////////////////////
-
- public function __construct()
- {
- ini_set("user_agent", "Codiad");
- $this->remote = "https://codiad.telaaedifex.com/update/?v={VER}&o={OS}&p={PHP}&w={WEB}&a={ACT}";
- $this->commits = "https://gitlab.telaaedifex.com/api/v4/projects/3/repository/commits/";
- $this->archive = "https://gitlab.telaaedifex.com/xevidos/codiad/-/archive/master/codiad-master.zip";
- }
-
- //////////////////////////////////////////////////////////////////
- // Set Initial Version
- //////////////////////////////////////////////////////////////////
-
- public function Init()
- {
- $version = array();
- if (!file_exists(DATA ."/version.php")) {
- if (file_exists(BASE_PATH."/.git/HEAD")) {
- $remote = $this->getRemoteVersion("install_git");
- $local = $this->getLocalVersion();
- $version[] = array("version"=>$local[0]['version'],"time"=>time(),"optout"=>"true","name"=>"");
- saveJSON('version.php', $version);
- } else {
- $remote = $this->getRemoteVersion("install_man");
- $version[] = array("version"=>$remote[0]["commit"]["sha"],"time"=>time(),"optout"=>"true","name"=>"");
- saveJSON('version.php', $version);
- }
- } else {
- $local = $this->getLocalVersion();
-
- if (file_exists(BASE_PATH."/.git/HEAD")) {
- $current = getJSON('version.php');
- if ($local[0]['version'] != $current[0]['version']) {
- $remote = $this->getRemoteVersion("update_git", $local[0]['version']);
- $version[] = array("version"=>$local[0]['version'],"time"=>time(),"optout"=>"true","name"=>"");
- saveJSON('version.php', $version);
- }
- } else {
- if ($local[0]['version'] == '' && $local[0]['name'] == $_SESSION['user']) {
- $remote = $this->getRemoteVersion("update_man", $local[0]['version']);
- $version[] = array("version"=>$remote[0]["commit"]["sha"],"time"=>time(),"optout"=>"true","name"=>$_SESSION['user']);
- saveJSON('version.php', $version);
- }
- }
-
- $local = $this->getLocalVersion();
- if (!isset($local[0]['optout'])) {
- $remote = $this->getRemoteVersion("optout", $local[0]['version']);
- $this->OptOut();
- }
- }
- }
-
- //////////////////////////////////////////////////////////////////
- // 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;
- }
-
- return "[".formatJSEND("success", array("currentversion"=>$local[0]['version'],"remoteversion"=>$latest,"message"=>$message,"archive"=>$archive,"nightly"=>$nightly,"name"=>$local[0]['name']))."]";
- }
-
- //////////////////////////////////////////////////////////////////
- // Get Local Version
- //////////////////////////////////////////////////////////////////
-
- public function getLocalVersion()
- {
- if (file_exists(BASE_PATH."/.git/HEAD")) {
- $tmp = file_get_contents(BASE_PATH."/.git/HEAD");
- if (strpos($tmp, "ref:") === false) {
- $data[0]['version'] = trim($tmp);
- } else {
- $data[0]['version'] = trim(file_get_contents(BASE_PATH."/.git/".trim(str_replace('ref: ', '', $tmp))));
- }
- $data[0]['name'] = "";
- if (file_exists(DATA ."/version.php")) {
- $data[0]['optout'] = "true";
- }
- } else {
- $data = getJSON('version.php');
- }
- return $data;
- }
-
- //////////////////////////////////////////////////////////////////
- // Get Remote Version
- //////////////////////////////////////////////////////////////////
-
- public function getRemoteVersion($action, $localversion = "")
- {
- $remoteurl = Common::getConstant('UPDATEURL', $this->remote);
- $remoteurl = str_replace("{OS}", PHP_OS, $remoteurl);
- $remoteurl = str_replace("{PHP}", phpversion(), $remoteurl);
- $remoteurl = str_replace("{VER}", $localversion, $remoteurl);
- $remoteurl = str_replace("{WEB}", urlencode($_SERVER['SERVER_SOFTWARE']), $remoteurl);
- $remoteurl = str_replace("{ACT}", $action, $remoteurl);
-
- return json_decode(file_get_contents($remoteurl), true);
- }
+class Update {
+
+ //////////////////////////////////////////////////////////////////
+ // CONSTANTS
+ //////////////////////////////////////////////////////////////////
+
+ CONST VERSION = "v.2.8.5";
+
+ //////////////////////////////////////////////////////////////////
+ // PROPERTIES
+ //////////////////////////////////////////////////////////////////
+
+ public $remote = "";
+ public $commits = "";
+ public $tags = "";
+ public $archive = "";
+ public $version = "";
+ public $protocol = "";
+
+ //////////////////////////////////////////////////////////////////
+ // METHODS
+ //////////////////////////////////////////////////////////////////
+
+ // -----------------------------||----------------------------- //
+
+ //////////////////////////////////////////////////////////////////
+ // Construct
+ //////////////////////////////////////////////////////////////////
+
+ public function __construct() {
+ ini_set("user_agent", "Codiad");
+
+ $this->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);
+ }
}
diff --git a/components/update/controller.php b/components/update/controller.php
index 2bbec7a..d2223d2 100755
--- a/components/update/controller.php
+++ b/components/update/controller.php
@@ -1,47 +1,62 @@
Init();
-}
-
- //////////////////////////////////////////////////////////////////
- // Clear Version
- //////////////////////////////////////////////////////////////////
-
-if ($_GET['action']=='clear') {
- if (checkAccess()) {
- $update->Clear();
- }
-}
-
- //////////////////////////////////////////////////////////////////
- // OptOut
- //////////////////////////////////////////////////////////////////
-
-if ($_GET['action']=='optout') {
- if (checkAccess()) {
- $update->OptOut();
- }
-}
+ /*
+ * Copyright (c) Codiad & daeks (codiad.com), distributed
+ * as-is and without warranty under the MIT License. See
+ * [root]/license.txt for more. This information must remain intact.
+ */
+
+
+ require_once('../../common.php');
+ require_once('class.update.php');
+
+ //////////////////////////////////////////////////////////////////
+ // Verify Session or Key
+ //////////////////////////////////////////////////////////////////
+
+ checkSession();
+
+ $update = new Update();
+
+ //////////////////////////////////////////////////////////////////
+ // Set Initial Version
+ //////////////////////////////////////////////////////////////////
+
+ if ($_GET['action']=='init') {
+ $update->Init();
+ }
+
+ //////////////////////////////////////////////////////////////////
+ // Clear Version
+ //////////////////////////////////////////////////////////////////
+
+ if ($_GET['action']=='clear') {
+ if (checkAccess()) {
+ $update->Clear();
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////
+ // OptOut
+ //////////////////////////////////////////////////////////////////
+
+ if ($_GET['action']=='optout') {
+ if (checkAccess()) {
+ $update->OptOut();
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////
+ // Update Codiad
+ //////////////////////////////////////////////////////////////////
+
+ if ($_GET['action']=='update') {
+ if (checkAccess()) {
+ $update->Download();
+ echo Common::getConstant('BASE_URL') . "/components/update/update.php";
+ } else {
+
+ echo "#";
+ }
+ }
+
diff --git a/components/update/dialog.php b/components/update/dialog.php
index 3ef6fd5..9520933 100755
--- a/components/update/dialog.php
+++ b/components/update/dialog.php
@@ -1,65 +1,89 @@
-
-