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 @@ - -
- - Check(), true); - ?> -
- - - -
- - -
- -
-
- -

- - . - - -

- -
'.get_i18n("Download Codiad").' '; - } - ?> - - + +
+ + Check(), true); + + ?> + + + " target="_blank" style="display: none;"> + + +
+ + +
+ +
+
+ +

+ + . + + +

+ +
+ The update will open a new tab. Please allow popups from Codiad.

'; + echo ' '; + echo ' '; + } + ?> + + + diff --git a/components/update/init.js b/components/update/init.js index 01ccdfe..3924f7c 100755 --- a/components/update/init.js +++ b/components/update/init.js @@ -51,6 +51,21 @@ .attr('src', archive); $.get(_this.controller + '?action=clear'); codiad.modal.unload(); + }, + + ////////////////////////////////////////////////////////////////// + // Update Codiad + ////////////////////////////////////////////////////////////////// + + update: function () { + var _this = this; + console.log( $.get(_this.controller + '?action=update', function( response ){ + + if( ! ( response === "" || response === null || response === "#" ) ) { + window.open( window.location.protocol + "//" + response, "_self" ) + } + })) + //codiad.modal.unload(); } }; diff --git a/components/update/update.php b/components/update/update.php new file mode 100644 index 0000000..43e8642 --- /dev/null +++ b/components/update/update.php @@ -0,0 +1,465 @@ +archive = $update->archive; + $this->path = Common::getConstant('BASE_PATH'); + $this->protocol = $this->check_protocol(); + + //Trigger update + $this->update(); + } + + function check_protocol() { + + if( extension_loaded( 'curl' ) ) { + + //Curl is loaded + return "curl"; + } elseif( ini_get('allow_url_fopen') ) { + + //Remote get file is enabled + return "fopen"; + } else { + + //None are enabled exit. + return "none"; + } + } + + function copyr( $source, $dest ) { + // Check for symlinks + if (is_link($source)) { + return symlink(readlink($source), $dest); + } + + // Simple copy for a file + if (is_file($source)) { + return copy($source, $dest); + } + + // Make destination directory + if (!is_dir($dest)) { + mkdir($dest); + } + + // Loop through the folder + $dir = dir( $source ); + while (false !== $entry = $dir->read()) { + // Skip pointers + if ($entry == '.' || $entry == '..') { + continue; + } + + // Deep copy directories + $this->copyr("$source/$entry", "$dest/$entry"); + } + + // Clean up + $dir->close(); + return true; + } + + ////////////////////////////////////////////////////////////////// + // Download latest archive + ////////////////////////////////////////////////////////////////// + + function download() { + + switch( $this->protocol ) { + + case( "curl" ): + + $filepath = $this->path . "/update.zip"; + if( file_exists( $filepath ) ) { + unlink( $filepath ); + } + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $this->archive); + //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'); + $raw_file_data = curl_exec($curl); + curl_close($curl); + + file_put_contents( $filepath, $raw_file_data ); + return ( filesize( $filepath ) > 0 ) ? true : false; + break; + + case( "fopen" ): + + break; + } + } + + function extract() { + + if ( ! extension_loaded( 'zip' ) ) { + + echo ""; + return false; + } + + $zip = new ZipArchive; + if ( $zip->open( $this->path . "/update.zip" ) === TRUE ) { + + $zip->extractTo( $this->path ); + $zip->close(); + + return true; + } else { + + return false; + } + } + + function remove_directory( $path ) { + + $files = glob($path . '/*'); + foreach ($files as $file) { + + is_dir($file) ? $this->remove_directory($file) : unlink($file); + } + rmdir($path); + return; + } + + function update() { + + echo ""; + if ( ! $this->download() ) { + + echo ""; + return; + } + + echo ""; + if ( ! $this->extract() ) { + + echo ""; + return; + } + + echo ""; + + $src = $this->path . "/codiad-master/"; + $src_folder = $this->path . "/codiad-master"; + $dest = $this->path . "/"; + + $this->copyr( $src, $dest ); + + + echo ""; + $this->remove_directory( $src ); + } +} + +?> + + + + + Codiad Update + + + + +

+ Telaaedifex Codiad Updater +

+
+ Starting Update ... +
+ + +archive = $update->archive; + $this->path = Common::getConstant('BASE_PATH'); + $this->protocol = $this->check_protocol(); + + //Trigger update + $this->update(); + } + + function check_protocol() { + + if( extension_loaded( 'curl' ) ) { + + //Curl is loaded + return "curl"; + } elseif( ini_get('allow_url_fopen') ) { + + //Remote get file is enabled + return "fopen"; + } else { + + //None are enabled exit. + return "none"; + } + } + + ////////////////////////////////////////////////////////////////// + // Download latest archive + ////////////////////////////////////////////////////////////////// + + function download() { + + switch( $this->protocol ) { + + case( "curl" ): + + $filepath = $this->path . "/update.zip"; + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $this->archive); + //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'); + $raw_file_data = curl_exec($curl); + curl_close($curl); + + file_put_contents( $filepath, $raw_file_data ); + return ( filesize( $filepath ) > 0 ) ? true : false; + break; + + case( "fopen" ): + + break; + } + } + + function extract() { + + if ( ! extension_loaded( 'zip' ) ) { + + echo ""; + return false; + } + + $zip = new ZipArchive; + if ( $zip->open( $this->path . "/update.zip", ZipArchive::OVERWRITE ) === TRUE ) { + + $zip->extractTo( $this->path ); + $zip->close(); + + return true; + } else { + + return false; + } + } + + function update() { + + echo ""; + if ( ! $this->download() ) { + + echo ""; + } + + echo ""; + if ( ! $this->extract() ) { + + echo ""; + } + + echo ""; + try { + + exec( "cp -a " ); + } catch ( exception $e ) { + + echo ""; + return; + } + + echo ""; + exec( "rm -rf " . $this->path . "/update.zip;rm -rf " . $this->path . "/codiad-master" ); + } +} + +?> + + + + + Codiad Update + + + + +

+ Telaaedifex Codiad Updater +

+
+ Starting Update ... +
+ + + \ No newline at end of file diff --git a/config.example.php b/config.example.php index d33939c..1b3664c 100755 --- a/config.example.php +++ b/config.example.php @@ -52,8 +52,8 @@ define("WSURL", BASE_URL . "/workspace"); //define("MARKETURL", "http://market.codiad.com/json"); // Update Check -define("UPDATEURL", "https://codiad.telaaedifex.com/update/?v={VER}&o={OS}&p={PHP}&w={WEB}&a={ACT}"); -define("ARCHIVEURL", "https://gitlab.telaaedifex.com/xevidos/codiad/-/archive/master/codiad-master.zip"); -define("COMMITURL", "https://gitlab.telaaedifex.com/api/v4/projects/3/repository/commits/"); +//define("UPDATEURL", "https://codiad.telaaedifex.com/update/?v={VER}&o={OS}&p={PHP}&w={WEB}&a={ACT}"); +//define("ARCHIVEURL", "https://gitlab.telaaedifex.com/xevidos/codiad/-/archive/master/codiad-master.zip"); +//define("COMMITURL", "https://gitlab.telaaedifex.com/api/v4/projects/3/repository/commits/"); ?> diff --git a/plugins/Codiad-AutoUpdate-master/README.md b/plugins/Codiad-AutoUpdate-master/README.md deleted file mode 100755 index e00eaa0..0000000 --- a/plugins/Codiad-AutoUpdate-master/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# WARNING - -It is tested on Ubuntu 12.04 and Windows 2008R2 with Apache 2.x but may mess up your system. -All files during the upgrade are stored at /backup if there is some failure. - -# Auto Update - -This plugin hooks into the current update check and provides the possibility to automatically update your system. - -# Requirements - -- Write Permission for webserver user for whole codiad directory -- Installed ZIP Extension for PHP -- Installed OPENSSL Extension for PHP -- Environment variable ```allow_url_fopen``` has been set to ```On``` - -# Installation - -- Download the zip file and extract it to your plugins folder -- Enable this plugin in the plugins manager in Codiad - -# Change Update URL - -- Define UPDATEURL in your config.php -- UPDATEURL needs syntax like https://api.github.com/repos/Codiad/Codiad/tags -- Update Channel is only available if update.codiad.com is used - -# WARNING - -It is tested on Ubuntu 12.04 and Windows 2008R2 with Apache 2.x but may mess up your system. -All files during the upgrade are stored at /backup if there is some failure. diff --git a/plugins/Codiad-AutoUpdate-master/class.autoupdate.php b/plugins/Codiad-AutoUpdate-master/class.autoupdate.php deleted file mode 100755 index 7853db0..0000000 --- a/plugins/Codiad-AutoUpdate-master/class.autoupdate.php +++ /dev/null @@ -1,331 +0,0 @@ -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"; - $this->type = ""; - } - - ////////////////////////////////////////////////////////////////// - // 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", $this->type); - $local = $this->getLocalVersion(); - $version[] = array("version"=>$local[0]['version'],"time"=>time(),"optout"=>"true","name"=>""); - saveJSON('version.php',$version); - } else { - $remote = $this->getRemoteVersion("install_man", $this->type); - $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", $this->type, $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", $this->type, $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", $this->type, $local[0]['version']); - $this->OptOut(); - } - } - - if(!file_exists(DATA."/config/".get_called_class().".php")) { - mkdir(DATA."/config"); - $settings = array("type"=>"stable"); - saveJSON("/config/".get_called_class().".php",$settings); - } - } - - ////////////////////////////////////////////////////////////////// - // 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() { - - if($this->type == 'undefined' || $this->type == '') { - $data = getJSON("/config/".get_called_class().".php"); - $this->type = $data['type']; - } - - $local = $this->getLocalVersion(); - $remote = $this->getRemoteVersion("check", $this->type, $local[0]['version']); - - $settings = array("type"=>$this->type); - saveJSON("/config/".get_called_class().".php",$settings); - - $nightly = true; - $archive = Common::getConstant('ARCHIVEURL', $this->archive); - $latestversion = ''; - $latestname = ''; - - if(file_exists(BASE_PATH."/.git/FETCH_HEAD")) { - $autoupdate = '-1'; - } else { - if(is_writeable(BASE_PATH) && is_writeable(COMPONENTS) && is_writeable(THEMES)) { - if(extension_loaded('zip') && extension_loaded('openssl') && ini_get('allow_url_fopen') == 1) { - $autoupdate = '1'; - } else { - $autoupdate = '-1'; - } - } else { - $autoupdate = '0'; - } - } - - $local[0]['tag'] = $local[0]['version']; - - foreach($remote as $tag) { - if($latestversion == '') { - if($tag['name'] != 'latest') { - $latestname = $tag["name"]; - } else { - $latestname = 'Latest Commit from Repository'; - } - $latestversion = $tag["commit"]["sha"]; - $archive = $tag["zipball_url"]; - } - if($local[0]['version'] == $tag["commit"]["sha"]) { - if($tag['name'] != 'latest') { - $local[0]['tag'] = $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("currentname"=>$local[0]['tag'], "currentversion"=>$local[0]['version'],"remoteversion"=>$latestversion,"remotename"=>$latestname,"message"=>$message,"archive"=>$archive,"nightly"=>$nightly,"autoupdate"=>$autoupdate,"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'] = ""; - } else { - $data = getJSON('version.php'); - } - return $data; - } - - ////////////////////////////////////////////////////////////////// - // Get Remote Version - ////////////////////////////////////////////////////////////////// - - public function getRemoteVersion($action, $type, $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); - - if($type == 'latest') { - $remoteurl = $remoteurl.'&l'; - } - - return json_decode(file_get_contents($remoteurl),true); - } - - ////////////////////////////////////////////////////////////////// - // Download Version - ////////////////////////////////////////////////////////////////// - - public function Download() { - if(file_exists('../../'.$this->commit.'.zip')) { - unlink('../../'.$this->commit.'.zip'); - } - file_put_contents('../../'.$this->commit.'.zip', fopen(str_replace('master', $this->commit, $this->archive), 'r')); - - $data = 'commit.'"; - -function delTree($dir) { - $files = array_diff(scandir($dir), array(".","..")); - foreach ($files as $file) { - (is_dir("$dir/$file")) ? delTree("$dir/$file") : unlink("$dir/$file"); - } - return rmdir($dir); -} - -function cpy($source, $dest, $ign, $frc){ - if(is_dir($source)) { - $dir_handle=opendir($source); - while($file=readdir($dir_handle)){ - if(!in_array($file, array(".",".."))) { - if(!in_array($file, $ign) || in_array($file, $frc)){ - if(is_dir($source."/".$file)){ - if(!file_exists($dest."/".$file)) { @mkdir($dest."/".$file); } - cpy($source."/".$file, $dest."/".$file, $ign, $frc); - rmdir($source."/".$file); - } else { - copy($source."/".$file, $dest."/".$file); - unlink($source."/".$file); - } - } else { - if(array_key_exists($file, $frc)) { - if(is_dir($source."/".$file)){ - if(!file_exists($dest."/".$file)) { @mkdir($dest."/".$file); } - cpy($source."/".$file."/".$frc[$file], $dest."/".$file."/".$frc[$file], $ign, $frc); - } else { - copy($source."/".$file, $dest."/".$file); - unlink($source."/".$file); - } - } - } - } - } - closedir($dir_handle); - } else { - copy($source, $dest); - unlink($source); - } -} - -// Getting current codiad path -$path = rtrim(str_replace($commit.".php", "", $_SERVER["SCRIPT_FILENAME"]),"/"); -$ignore = array(".git", "config.json", "data", "workspace", "plugins", "themes", "backup", "config.php", $commit.".php",$commit.".zip", "Codiad-".$commit); -$force = array("themes" => "default", "themes" => "README.md"); - -$zip = new ZipArchive; -$res = $zip->open($path."/".$commit.".zip"); -// open downloaded archive -if ($res === TRUE) { - // extract archive - if($zip->extractTo($path) === true) { - // delete old files except some directories and files - if(!file_exists($path."/backup")) { mkdir($path."/backup"); } - cpy($path, $path."/backup", $ignore, $force); - - // move extracted files to path - cpy($path."/Codiad-".$commit, $path, array(), array()); - - // store current commit to version.json - $version = array(); - $version[] = array("version"=>$commit,"optout"=>"true","name"=>"'.$_SESSION['user'].'","time"=>"'.time().'"); - file_put_contents($path."/data/version.php", ""); - - // cleanup and restart codiad - @$zip->close(); - delTree($path."/backup"); - rmdir($path."/Codiad-".$commit); - unlink($path."/".$commit.".zip"); - unlink($path."/".$commit.".php"); - header("Location: ".str_replace($commit.".php","",$_SERVER["SCRIPT_NAME"])); - } else { - echo "Unable to extract ".$path."/".$commit.".zip to path ".$path; - } - $zip->close(); -} else { - echo "Unable to open ".$path."/".$commit.".zip"; -} - -?>'; - $write = fopen('../../'.$this->commit.'.php', 'w') or die("can't open file"); - fwrite($write, $data); - fclose($write); - - @session_unset(); @session_destroy(); session_start(); - echo formatJSEND("success",null); - } - -} diff --git a/plugins/Codiad-AutoUpdate-master/controller.php b/plugins/Codiad-AutoUpdate-master/controller.php deleted file mode 100755 index 050ff0d..0000000 --- a/plugins/Codiad-AutoUpdate-master/controller.php +++ /dev/null @@ -1,70 +0,0 @@ -Init(); - } - - ////////////////////////////////////////////////////////////////// - // Clear Version - ////////////////////////////////////////////////////////////////// - - if($_GET['action']=='clear'){ - if(checkAccess()) { - $update->Clear(); - } - } - - ////////////////////////////////////////////////////////////////// - // Test Write Access - ////////////////////////////////////////////////////////////////// - - if($_GET['action']=='test'){ - if(checkAccess()) { - $update->Test(); - } - } - - ////////////////////////////////////////////////////////////////// - // Download Version - ////////////////////////////////////////////////////////////////// - - if($_GET['action']=='download'){ - if(checkAccess()) { - $update->commit = $_GET['remoteversion']; - $update->Download(); - } - } - - ////////////////////////////////////////////////////////////////// - // OptOut - ////////////////////////////////////////////////////////////////// - - if($_GET['action']=='optout'){ - if(checkAccess()) { - $update->OptOut(); - } - } - -?> diff --git a/plugins/Codiad-AutoUpdate-master/dialog.php b/plugins/Codiad-AutoUpdate-master/dialog.php deleted file mode 100755 index f3af1f2..0000000 --- a/plugins/Codiad-AutoUpdate-master/dialog.php +++ /dev/null @@ -1,108 +0,0 @@ - - -
- - type = $_GET['type']; - } - $vars = json_decode($update->Check(), true); - ?> - - - - - - remote == Common::getConstant('UPDATEURL', $update->remote)) { ?> - - - - - -
-
- -
- - -
- -
-
- -

- - .
- Force Update Codiad'; - } - } ?> - -
Note: Your installation is a nightly build. Codiad might be unstable.
- -
Update Codiad  '; - } else { - if($vars[0]['data']['autoupdate'] == '-1') { - echo ' '; - } else { - echo '  '; - } - } - } - ?> - - - - - -
 
-   - - diff --git a/plugins/Codiad-AutoUpdate-master/init.js b/plugins/Codiad-AutoUpdate-master/init.js deleted file mode 100755 index 6348595..0000000 --- a/plugins/Codiad-AutoUpdate-master/init.js +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) Codiad & daeks, distributed - * as-is and without warranty under the MIT License. See - * [root]/license.txt for more. This information must remain intact. - */ - - (function (global, $) { - - var codiad = global.codiad, - scripts= document.getElementsByTagName('script'), - path = scripts[scripts.length-1].src.split('?')[0], - curpath = path.split('/').slice(0, -1).join('/')+'/'; - - $(window) - .load(function() { - codiad.autoupdate.init(); - }); - - codiad.autoupdate = { - - controller: curpath + 'controller.php', - dialog: curpath + 'dialog.php', - - ////////////////////////////////////////////////////////////////// - // Initilization - ////////////////////////////////////////////////////////////////// - - init: function () { - var _this = this; - $.get(_this.controller + '?action=init'); - $('#sb-right a[onclick="codiad.update.check();"]').attr("onclick", "codiad.autoupdate.check();"); - }, - - ////////////////////////////////////////////////////////////////// - // Update Check - ////////////////////////////////////////////////////////////////// - - check: function (type) { - var _this = this; - $('#modal-content form') - .die('submit'); // Prevent form bubbling - codiad.modal.load(500, this.dialog + '?action=check&type='+type); - $('#modal-content').html('
Checking...

'); - }, - - ////////////////////////////////////////////////////////////////// - // Update System - ////////////////////////////////////////////////////////////////// - - update: function () { - var _this = this; - var remoteversion = $('#modal-content form input[name="remoteversion"]') - .val(); - var remotename = $('#modal-content form input[name="remotename"]') - .val(); - codiad.modal.load(350, this.dialog + '?action=update&remoteversion=' + remoteversion + '&remotename=' + remotename); - $('#modal-content form') - .live('submit', function (e) { - e.preventDefault(); - var remoteversion = $('#modal-content form input[name="remoteversion"]') - .val(); - $('#modal-content').html('
Downloading & Installing...

'); - $.get(_this.controller + '?action=download&remoteversion=' + remoteversion, function(data) { - var response = codiad.jsend.parse(data); - codiad.modal.unload(); - if (response != 'error') { - window.open('./' + remoteversion + '.php','_self'); - } else { - codiad.message.error('Update failed'); - } - }); - }); - }, - - ////////////////////////////////////////////////////////////////// - // Download Archive - ////////////////////////////////////////////////////////////////// - - download: function () { - var _this = this; - var archive = $('#modal-content form input[name="archive"]') - .val(); - $('#download') - .attr('src', archive); - $.get(_this.controller + '?action=clear'); - codiad.modal.unload(); - } - - }; - -})(this, jQuery); \ No newline at end of file diff --git a/plugins/Codiad-AutoUpdate-master/plugin.json b/plugins/Codiad-AutoUpdate-master/plugin.json deleted file mode 100755 index a547edc..0000000 --- a/plugins/Codiad-AutoUpdate-master/plugin.json +++ /dev/null @@ -1,6 +0,0 @@ -[ { "author" : "daeks", - "version": "1.2", - "name" : "Codiad AutoUpdate", - "image" : "https://raw.github.com/daeks/Codiad-AutoUpdate/master/screen.png", - "url" : "https://github.com/daeks/Codiad-AutoUpdate" - } ] diff --git a/plugins/Codiad-AutoUpdate-master/screen.png b/plugins/Codiad-AutoUpdate-master/screen.png deleted file mode 100755 index 5ba0d18..0000000 Binary files a/plugins/Codiad-AutoUpdate-master/screen.png and /dev/null differ