Merge branch 'development' into 'master'

Update

See merge request xevidos/codiad!6
This commit is contained in:
Isaac Brown 2018-07-24 08:37:21 -04:00
commit 10d6dbc84e
9 changed files with 149 additions and 83 deletions

View file

@ -57,6 +57,10 @@
define('DATA', BASE_PATH . '/data');
}
if(!defined('SESSIONS_PATH')) {
define('SESSIONS_PATH', BASE_PATH . '/data/sessions');
}
if(!defined('THEMES')){
define("THEMES", BASE_PATH . "/themes");
}
@ -84,7 +88,7 @@
//Set a Session Name
session_name(md5(BASE_PATH));
session_save_path( SESSIONS_PATH );
session_start();
//Check for external authentification
@ -164,7 +168,9 @@
$key = "";
if(isset($_GET['key'])){ $key = $_GET['key']; }
if(!isset($_SESSION['user']) && !in_array($key,$api_keys)){
exit('{"status":"error","message":"Authentication Error"}');
//exit('{"status":"error","message":"Authentication Error"}');
exit('{"status":"error","message":"Authentication Error<script>window.location.href = window.location.protocol + `' . "//" . Common::getConstant('BASE_URL') . '`</script>"}');
}
}

View file

@ -18,72 +18,44 @@
clipboard: '',
noFiles: [
//Files
'exe',
'zip',
'tar',
'tar.gz',
],
noImages: [
//Images
'jpg',
'jpeg',
'png',
'gif',
'bmp',
],
noMusic: [
//Music
'aac',
'aif',
'mp3',
'mp4',
'wav',
'ogg',
],
noOpen: [
//Files
'exe',
'zip',
'tar',
'tar.gz',
//Images
'jpg',
'jpeg',
'png',
'gif',
'bmp',
//Music
'aac',
'aif',
'mp3',
'mp4',
'wav',
'ogg',
],
noBrowser: [
//Images
'jpg',
'jpeg',
'png',
'gif',
'bmp',
//Music
'aac',
'aif',
'mp3',
'mp4',
'wav',
'ogg',
],
controller: 'components/filemanager/controller.php',
dialog: 'components/filemanager/dialog.php',
dialogUpload: 'components/filemanager/dialog_upload.php',
init: function() {
this.noAudio = [
//Audio
'aac',
'aif',
'mp3',
'mp4',
'wav',
'ogg',
],
this.noFiles = [
//Files
'exe',
'pdf',
'zip',
'tar',
'tar.gz',
],
this.noImages = [
//Images
'ico',
'icon',
'jpg',
'jpeg',
'png',
'gif',
'bmp',
],
this.noOpen = this.noAudio.concat( this.noFiles, this.noImages ),
this.noBrowser = this.noAudio.concat( this.noImages ),
// Initialize node listener
this.nodeListener();
// Load uploader
@ -471,7 +443,7 @@
let type = "";
var ext = this.getExtension(path).toLowerCase();
if ( this.noMusic.includes(ext) ) {
if ( this.noAudio.includes(ext) ) {
type = 'music_preview';
} else if ( this.noImages.includes(ext) ) {

View file

@ -12,7 +12,7 @@ class Update {
// CONSTANTS
//////////////////////////////////////////////////////////////////
CONST VERSION = "v.2.8.8";
CONST VERSION = "v.2.8.7";
//////////////////////////////////////////////////////////////////
// PROPERTIES
@ -24,6 +24,7 @@ class Update {
public $archive = "";
public $version = "";
public $protocol = "";
public $update_fiile = "";
//////////////////////////////////////////////////////////////////
// METHODS
@ -41,7 +42,9 @@ class Update {
$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->update_file = "https://gitlab.telaaedifex.com/xevidos/codiad/raw/master/components/update/update.php";
$this->protocol = $this->CheckProtocol();
}
//////////////////////////////////////////////////////////////////
@ -125,6 +128,22 @@ class Update {
$nightly = false;
$response = $this->getRemoteVersion("check");
if ( $response["name"] > $current_version ) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $this->update_file);
//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);
unlink( "./update.php" );
file_put_contents( "./update.php", $content );
}
//echo var_dump( $response );

View file

@ -54,6 +54,11 @@ switch($_GET['action']){
<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
} elseif( $vars[0]['data']['remoteversion'] === "" || $vars[0]['data']['remoteversion'] === null ) {
?>
<br><br><b><label><?php echo htmlentities("Error, could not check for updates. Please try again later. If this problem persists, then please contact the web administrator."); ?></label></b>
<?php
} else {
?>
<br><br><b><label><?php echo htmlentities("Your current version of Codiad is up to date."); ?></label></b>

3
components/update/update.php Normal file → Executable file
View file

@ -305,6 +305,9 @@ class updater {
//Trigger update
$this->update();
//Delete File
unlink( __FILE__ );
}
function check_protocol() {

View file

@ -50,6 +50,9 @@ class User
$users = getJSON('users.php');
foreach ($users as $user) {
if ($user['username']==$this->username && $user['password']==$this->password) {
$this->checkDuplicateSessions();
$pass = true;
$_SESSION['user'] = $this->username;
$_SESSION['lang'] = $this->lang;
@ -67,6 +70,64 @@ class User
}
}
/**
* Check duplicate sessions
*
* This function checks to see if the user is currently logged in
* on any other machine and if they are then log them off. This
* will fix the issue with the new auto save attempting to save both
* users at the same time.
*/
public function checkDuplicateSessions() {
$all_sessions = array();
session_save_path( SESSIONS_PATH );
session_start();
$sessions = glob( SESSIONS_PATH . "/*" );
$this_session = session_id();
$username = "xevidos";
foreach($sessions as $session) {
//echo var_dump( $session ) . "\n\n";
if ( strpos( $session, "sess_") == false ) {
continue;
}
$session = str_replace( "sess_", "", $session );
$session = str_replace( SESSIONS_PATH . "/", "", $session );
//This skips temp files that aren't sessions
if( strpos( $session, "." ) == false ) {
if ( $session == $this_session ) {
continue;
}
session_save_path( SESSIONS_PATH );
session_id( $session );
session_start();
//echo var_dump( $_SESSION ) . "\n\n";
if ( ( isset( $_SESSION["user"] ) && $_SESSION["user"] == $username ) || empty( $_SESSION ) ) {
session_unset();
session_destroy();
} else {
session_abort();
}
}
}
session_id( $this_session );
session_start();
}
//////////////////////////////////////////////////////////////////
// Create Account
//////////////////////////////////////////////////////////////////

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -92,8 +92,13 @@
});
// Run resize command to fix render issues
// Add a check to see if it is not undefined due to an
// error being generated on the login page.
if ( typeof( codiad.editor.resize() ) !== "undefined" ) {
codiad.editor.resize();
codiad.active.updateTabDropdownVisibility();
}
});
$('#settings').click(function(){

View file

@ -1,5 +0,0 @@
# Tests
tests/
shell/
config.log