Merge branch 'development' into 'master'

Merge updater update.

See merge request xevidos/codiad!3
This commit is contained in:
Isaac Brown 2018-07-18 15:31:16 -04:00
commit f35a290570
14 changed files with 811 additions and 928 deletions

View File

@ -12,7 +12,7 @@
//////////////////////////////////////////////////////////////////
class Common {
//////////////////////////////////////////////////////////////////
// PROPERTIES
//////////////////////////////////////////////////////////////////

View File

@ -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"]).'<br/>';
} else {
$merge .= '- '.str_replace($search, $replace, $commit["commit"]["message"]).'<br/>';
}
} 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.7";
//////////////////////////////////////////////////////////////////
// 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"]).'<br/>';
} else {
$merge .= '- '.str_replace($search, $replace, $commit["commit"]["message"]).'<br/>';
}
} 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);
}
}

View File

@ -1,47 +1,62 @@
<?php
/*
* 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();
}
}
/*
* 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 "#";
}
}

View File

@ -1,65 +1,89 @@
<?php
/*
* 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.
*/
/*
* 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');
//////////////////////////////////////////////////////////////////
// Verify Session or Key
//////////////////////////////////////////////////////////////////
checkSession();
switch($_GET['action']){
//////////////////////////////////////////////////////////////////////
// Update
//////////////////////////////////////////////////////////////////////
case 'check':
if(!checkAccess()){
?>
<label><?php i18n("Restricted"); ?></label>
<pre><?php i18n("You can not check for updates"); ?></pre>
<button onclick="codiad.modal.unload();return false;"><?php i18n("Close"); ?></button>
<?php } else {
require_once('class.update.php');
$update = new Update();
$vars = json_decode($update->Check(), true);
?>
<form>
<input type="hidden" name="archive" value="<?php echo $vars[0]['data']['archive']; ?>">
<input type="hidden" name="remoteversion" value="<?php echo $vars[0]['data']['remoteversion']; ?>">
<label><?php i18n("Update Check"); ?></label>
<br><table>
<tr><td width="40%"><?php i18n("Your Version"); ?></td><td><?php echo $vars[0]['data']['currentversion']; ?></td></tr>
<tr><td width="40%"><?php i18n("Latest Version"); ?></td><td><?php echo $vars[0]['data']['remoteversion']; ?></td></tr>
</table>
<?php if($vars[0]['data']['currentversion'] != $vars[0]['data']['remoteversion']) { ?>
<br><label><?php i18n("Changes on Codiad"); ?></label>
<pre style="overflow: auto; max-height: 200px; max-width: 510px;"><?php echo $vars[0]['data']['message']; ?></pre>
<?php } else { ?>
<br><br><b><label><?php i18n("Congratulation, your system is up to date."); ?></label></b>
<?php if($vars[0]['data']['name'] != '') { ?>
<em><?php i18n("Last update was done by "); ?><?php echo $vars[0]['data']['name']; ?>.</em>
<?php } } ?>
<?php if($vars[0]['data']['nightly']) { ?>
<br><em class="note"><?php i18n("Note: Your installation is a nightly build. Codiad might be unstable."); ?></em><br>
<?php } ?>
<br><?php
if($vars[0]['data']['currentversion'] != $vars[0]['data']['remoteversion']) {
echo '<button class="btn-left" onclick="codiad.update.download();return false;">'.get_i18n("Download Codiad").'</button>&nbsp;';
}
?><button class="btn-right" onclick="codiad.modal.unload();return false;"><?php i18n("Cancel"); ?></button>
<form>
<?php }
break;
}
//////////////////////////////////////////////////////////////////
// Verify Session or Key
//////////////////////////////////////////////////////////////////
checkSession();
switch($_GET['action']){
//////////////////////////////////////////////////////////////////////
// Update
//////////////////////////////////////////////////////////////////////
case 'check':
if( ! checkAccess() ){
?>
<label><?php i18n("Restricted"); ?></label>
<pre><?php i18n("You can not check for updates"); ?></pre>
<button onclick="codiad.modal.unload();return false;"><?php i18n("Close"); ?></button>
<?php
} else {
require_once('class.update.php');
$update = new Update();
$vars = json_decode($update->Check(), true);
?>
<form>
<input type="hidden" name="archive" value="<?php echo $vars[0]['data']['archive']; ?>">
<a id="update" href="<?php echo Common::getConstant('BASE_URL') . "/components/update/update.php"; ?>" target="_blank" style="display: none;"></a>
<input type="hidden" name="remoteversion" value="<?php echo $vars[0]['data']['remoteversion']; ?>">
<label><?php i18n("Update Check"); ?></label>
<br><table>
<tr><td width="40%"><?php i18n("Your Version"); ?></td><td><?php echo $vars[0]['data']['currentversion']; ?></td></tr>
<tr><td width="40%"><?php i18n("Latest Version"); ?></td><td><?php echo $vars[0]['data']['remoteversion']; ?></td></tr>
</table>
<?php
if( $vars[0]['data']['currentversion'] < $vars[0]['data']['remoteversion'] ) {
?>
<br><label><?php i18n("Changes on Codiad"); ?></label>
<pre style="overflow: auto; max-height: 200px; max-width: 510px;"><?php echo $vars[0]['data']['message']; ?></pre>
<?php
} else {
?>
<br><br><b><label><?php echo htmlentities("Your current version of Codiad is up to date."); ?></label></b>
<?php
if( $vars[0]['data']['name'] != '' ) {
?>
<em><?php i18n("Last update was done by "); ?><?php echo $vars[0]['data']['name']; ?>.</em>
<?php
}
}
?>
<?php
if( $vars[0]['data']['nightly'] ) {
?>
<br><em class="note"><?php i18n("Note: Your installation is a nightly build. Codiad might be unstable."); ?></em><br>
<?php
}
?>
<br>
<?php
if( $vars[0]['data']['currentversion'] < $vars[0]['data']['remoteversion'] ) {
echo '<p>The update will open a new tab. Please allow popups from Codiad.</p>';
echo '<button class="btn-left" onclick="event.preventDefault();codiad.update.update();return false;">'.get_i18n("Update Codiad").'</button>&nbsp;';
echo '<button class="btn-left" onclick="codiad.update.download();return false;">'.get_i18n("Download Codiad").'</button>&nbsp;';
}
?>
<button class="btn-right" onclick="codiad.modal.unload();return false;"><?php i18n("Cancel"); ?></button>
<form>
<?php
}
break;
}
?>

View File

@ -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();
}
};

View File

@ -0,0 +1,465 @@
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once('../../common.php');
require_once('./class.update.php');
checkSession();
if ( ! checkAccess() ) {
echo "Error, you do not have access to update Codiad.";
exit;
}
/**
* Initiate the update class so we do not have to redefine their
* variables.
*/
class updater {
/**
* Telaaedifex Codiad updater
*
* This updater will extract an archive and then update each file
* with file put contents.
*/
/**
* Constants
*/
/**
* Properties
*/
public $archive = "";
public $path = "";
public $protocol = "";
function __construct() {
$update = new Update();
$this->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 "<script>document.getElementById('progress').innerHTML = '<p class=\"error_box\">Error, the php zip extension does not seem to be installed. Can not continue with update. Please install the <a href=\"http://php.net/manual/en/book.zip.php\" target=\"_blank\">php zip extension</a></p>'> ... </p>';</script>";
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 "<script>document.getElementById('progress').innerHTML = '<p class=\"status_box\">Downloading latest version ... </p>';</script>";
if ( ! $this->download() ) {
echo "<script>document.getElementById('progress').innerHTML += '<br><p class=\"error_box\">Error downloading latest version</p>';</script>";
return;
}
echo "<script>document.getElementById('progress').innerHTML = '<p class=\"status_box\">Extracting update ... </p>';</script>";
if ( ! $this->extract() ) {
echo "<script>document.getElementById('progress').innerHTML += '<br><p class=\"error_box\">Error extracting update</p>';</script>";
return;
}
echo "<script>document.getElementById('progress').innerHTML = '<p class=\"status_box\">Updating ... </p>';</script>";
$src = $this->path . "/codiad-master/";
$src_folder = $this->path . "/codiad-master";
$dest = $this->path . "/";
$this->copyr( $src, $dest );
echo "<script>document.getElementById('progress').innerHTML = '<p class=\"status_box\">Removing Update ... </p>';</script>";
$this->remove_directory( $src );
}
}
?>
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Codiad Update</title>
<style>
html {
}
body{
background-color: #1a1a1a;
color: #fff;
font: normal 13px 'Ubuntu', sans-serif;
height: 100%;
overflow: hidden;
width: 100%;
}
.title {
color: #666;
display: block;
//float: left;
//font-size: 15px;
font-weight: 500;
margin: 10px;
text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.6);
}
#progress {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
<script>
</script>
</head>
<body>
<h1 class="title" style="text-align: center;">
Telaaedifex Codiad Updater
</h1>
<div id="progress">
Starting Update ...
</div>
</body>
</html>
<?php
new updater();
?><?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once('../../common.php');
require_once('./class.update.php');
checkSession();
if ( ! checkAccess() ) {
echo "Error, you do not have access to update Codiad.";
exit;
}
/**
* Initiate the update class so we do not have to redefine their
* variables.
*/
class updater {
/**
* Telaaedifex Codiad updater
*
* This updater will extract an archive and then update each file
* with file put contents.
*/
/**
* Constants
*/
/**
* Properties
*/
public $archive = "";
public $path = "";
public $protocol = "";
function __construct() {
$update = new Update();
$this->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 "<script>document.getElementById('progress').innerHTML = '<p class=\"error_box\">Error, the php zip extension does not seem to be installed. Can not continue with update. Please install the <a href=\"http://php.net/manual/en/book.zip.php\" target=\"_blank\">php zip extension</a></p>'> ... </p>';</script>";
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 "<script>document.getElementById('progress').innerHTML = '<p class=\"status_box\">Downloading latest version ... </p>';</script>";
if ( ! $this->download() ) {
echo "<script>document.getElementById('progress').innerHTML += '<br><p class=\"error_box\">Error downloading latest version</p>';</script>";
}
echo "<script>document.getElementById('progress').innerHTML = '<p class=\"status_box\">Extracting update ... </p>';</script>";
if ( ! $this->extract() ) {
echo "<script>document.getElementById('progress').innerHTML += '<br><p class=\"error_box\">Error extracting update</p>';</script>";
}
echo "<script>document.getElementById('progress').innerHTML = '<p class=\"status_box\">Updating ... </p>';</script>";
try {
exec( "cp -a " );
} catch ( exception $e ) {
echo "<script>document.getElementById('progress').innerHTML = '<p class=\"error_box\">Update Failed ... </p>';</script>";
return;
}
echo "<script>document.getElementById('progress').innerHTML = '<p class=\"status_box\">Removing Update ... </p>';</script>";
exec( "rm -rf " . $this->path . "/update.zip;rm -rf " . $this->path . "/codiad-master" );
}
}
?>
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Codiad Update</title>
<style>
html {
}
body{
background-color: #1a1a1a;
color: #fff;
font: normal 13px 'Ubuntu', sans-serif;
height: 100%;
overflow: hidden;
width: 100%;
}
.title {
color: #666;
display: block;
//float: left;
//font-size: 15px;
font-weight: 500;
margin: 10px;
text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.6);
}
#progress {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
<script>
</script>
</head>
<body>
<h1 class="title" style="text-align: center;">
Telaaedifex Codiad Updater
</h1>
<div id="progress">
Starting Update ...
</div>
</body>
</html>
<?php
new updater();
?>

View File

@ -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/");
?>

View File

@ -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.

View File

@ -1,331 +0,0 @@
<?php
/*
* 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.
*/
require_once('../../common.php');
class AutoUpdate extends Common {
//////////////////////////////////////////////////////////////////
// PROPERTIES
//////////////////////////////////////////////////////////////////
public $remote = "";
public $commits = "";
public $archive = "";
public $type = "";
//////////////////////////////////////////////////////////////////
// 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";
$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"]).'<br/>';
} else {
$merge .= '- '.str_replace($search,$replace,$commit["commit"]["message"]).'<br/>';
}
} 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 = '<?php
$commit = "'.$this->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", "<?php/*|" . json_encode($version) . "|*/?>");
// 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);
}
}

View File

@ -1,70 +0,0 @@
<?php
/*
* 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.
*/
require_once('../../common.php');
require_once('class.autoupdate.php');
//////////////////////////////////////////////////////////////////
// Verify Session or Key
//////////////////////////////////////////////////////////////////
if($_GET['action']!='authenticate'){ checkSession(); }
$update = new AutoUpdate();
//////////////////////////////////////////////////////////////////
// Set Initial Version
//////////////////////////////////////////////////////////////////
if($_GET['action']=='init'){
$update->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();
}
}
?>

View File

@ -1,108 +0,0 @@
<?php
/*
* 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');
//////////////////////////////////////////////////////////////////
// Verify Session or Key
//////////////////////////////////////////////////////////////////
checkSession();
switch($_GET['action']){
//////////////////////////////////////////////////////////////////////
// Update
//////////////////////////////////////////////////////////////////////
case 'check':
if(!checkAccess()){
?>
<label><?php i18n("Restricted"); ?></label>
<pre><?php i18n("You can not check for updates"); ?></pre>
<button onclick="codiad.modal.unload();return false;"><?php i18n("Close"); ?></button>
<?php } else {
require_once('class.autoupdate.php');
$update = new AutoUpdate();
if(isset($_GET['type'])) {
$update->type = $_GET['type'];
}
$vars = json_decode($update->Check(), true);
?>
<form>
<input type="hidden" name="archive" value="<?php echo $vars[0]['data']['archive']; ?>">
<input type="hidden" name="remoteversion" value="<?php echo $vars[0]['data']['remoteversion']; ?>">
<input type="hidden" name="remotename" value="<?php echo $vars[0]['data']['remotename']; ?>">
<label><?php i18n("Auto Update Check"); ?></label>
<?php if($update->remote == Common::getConstant('UPDATEURL', $update->remote)) { ?>
<table>
<tr>
<td width="40%"><?php i18n("Update Channel"); ?></td>
<td><select id="type" name="type" onchange="codiad.autoupdate.check(this.value);">
<option value="stable" <?php if($update->type == 'stable') { echo "selected"; }?>>Stable Version</option>
<option value="latest" <?php if($update->type == 'latest') { echo "selected"; }?>>Latest Version</option>
</select>
</td>
</tr>
</table>
<?php } ?>
<br><table>
<tr><td width="40%"><?php i18n("Your Version"); ?></td><td><?php echo $vars[0]['data']['currentname']; ?></td></tr>
<tr><td width="40%"><?php i18n("Latest Version"); ?></td><td><?php echo $vars[0]['data']['remotename']; ?></td></tr>
</table>
<?php if($vars[0]['data']['currentversion'] != $vars[0]['data']['remoteversion']) { ?>
<br><label><?php i18n("Changes on Codiad"); ?></label>
<pre style="overflow: auto; max-height: 200px; max-width: 510px;"><?php echo $vars[0]['data']['message']; ?></pre>
<?php } else { ?>
<br><br><b><label><?php i18n("Congratulation, your system is up to date."); ?></label></b>
<?php if($vars[0]['data']['name'] != '') { ?>
<em class="note"><?php i18n("Last update was done by "); ?><?php echo $vars[0]['data']['name']; ?>.</em><br>
<?php }
if($vars[0]['data']['autoupdate'] == '1') {
echo '<div align="right"><a href="#" style="color:white; text-decoration: none;" onclick="codiad.autoupdate.update();return false;">Force Update Codiad</a></div>';
}
} ?>
<?php if($vars[0]['data']['nightly']) { ?>
<br><em class="note">Note: Your installation is a nightly build. Codiad might be unstable.</em><br>
<?php } ?>
<br><?php
if($vars[0]['data']['currentversion'] != $vars[0]['data']['remoteversion']) {
if($vars[0]['data']['autoupdate'] == '1') {
echo '<button class="btn-left" onclick="codiad.autoupdate.update();return false;">Update Codiad</button>&nbsp;<button class="btn-left" onclick="codiad.autoupdate.download();return false;">Download Codiad</button>&nbsp;';
} else {
if($vars[0]['data']['autoupdate'] == '-1') {
echo '<button class="btn-left" onclick="codiad.autoupdate.download();return false;">Download Codiad</button>&nbsp;';
} else {
echo '<button class="btn-left" onclick="codiad.autoupdate.check();return false;">Test Permission</button>&nbsp;<button class="btn-left" onclick="codiad.autoupdate.download();return false;">Download Codiad</button>&nbsp;';
}
}
}
?><button class="btn-right" onclick="codiad.modal.unload();return false;"><?php i18n("Cancel"); ?></button>
<form>
<?php }
break;
//////////////////////////////////////////////////////////////////
// Update
//////////////////////////////////////////////////////////////////
case 'update':
?>
<form>
<input type="hidden" name="remoteversion" value="<?php echo($_GET['remoteversion']); ?>">
<label><?php i18n("Confirm Update"); ?></label>
<pre><?php i18n("Update:"); ?> <?php echo($_GET['remotename']); ?></pre>
<button class="btn-left"><?php i18n("Confirm"); ?></button>&nbsp;<button class="btn-right" onclick="codiad.modal.unload(); return false;"><?php i18n("Cancel"); ?></button>
<form>
<?php
break;
}
?>

View File

@ -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('<div id="modal-loading"></div><div align="center">Checking...</div><br>');
},
//////////////////////////////////////////////////////////////////
// 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('<div id="modal-loading"></div><div align="center">Downloading & Installing...</div><br>');
$.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);

View File

@ -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"
} ]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB