v.2.9.5 Bug fixes

This commit is contained in:
xevidos 2019-06-27 12:43:19 +00:00
parent bad1a09302
commit 8feda8460b
14 changed files with 4012 additions and 3828 deletions

View file

@ -22,22 +22,28 @@ Stick to the conventions defined in other components as closely as possible.
In order to maintain a consistant code structure to the code across the application please follow the wordpress standard, or run any changes through [JSBeautifier] (http://jsbeautifier.org/) with the settings below.
{
"indent_size": "1",
"brace_style": "collapse",
"break_chained_methods": false,
"comma_first": false,
"e4x": false,
"end_with_newline": true,
"indent_char": "\t",
"indent_empty_lines": true,
"indent_inner_html": true,
"indent_scripts": "normal",
"indent_size": "1",
"jslint_happy": false,
"keep_array_indentation": true,
"max_preserve_newlines": "5",
"preserve_newlines": true,
"keep_array_indentation": true,
"break_chained_methods": false,
"indent_scripts": "normal",
"brace_style": "collapse",
"space_after_anon_function": false,
"space_after_named_function": false,
"space_before_conditional": false,
"space_in_empty_paren": false,
"space_in_paren": true,
"unescape_strings": false,
"jslint_happy": false,
"end_with_newline": true,
"wrap_line_length": "0",
"indent_inner_html": true,
"comma_first": false,
"e4x": false
"unindent_chained_methods": true,
"wrap_line_length": "0"
}
If you have questions, please ask. Submit an issue or [contact us directly](mailto:support@telaaedifex.com).

View file

@ -9,11 +9,13 @@ Distributed under the MIT-Style License. See LICENSE.txt file for more informati
Repositories:
[GitLab](https://gitlab.com/xevidos/codiad)
[GitHub](https://github.com/xevidos/codiad)
Issues:
[GitLab](https://gitlab.com/xevidos/codiad/issues)
[GitHub](https://github.com/xevidos/codiad/issues)
Features:
@ -37,16 +39,19 @@ Task List:
* Add ability to login with LDAP
* Add custom market
* Add in new admin interface ( Check admin-portal branch for progress )
* \- Add in new admin interface ( Check admin-portal branch for progress )
- Group Management
- Permissions Management
- Plugin Management
- Project Management
- System Settings
- User Management
* Add Drag and Drop natively to filemanager
* Add folder / filestructure upload ability
* Add if file could not be saved 5 times close the open file
* Add multi level users. ( Projects for only certain groups, Permission levels )
* Add mobile compatibility
* Add permissions module ( more in depth permissions such as read/write, delete, etc )
* Add support for more database systems ( MSSQL, Oracle, SQLite, Filesystem storage, etc )
* Add in auto save timer that saves after the user stops typing instead of after every change
* Clean up update script
@ -70,7 +75,9 @@ Completed:
* Updated for PHP 7.2
Bugs:
Known Bugs:
* Auto save does not save the most recent changes every once in a while requiring more information to be typed ( E.G. A couple spaces ) in order to show up in saved file.
* Cursor is set to the wrong position if in split view.
* Auto save does not save the most recent changes every once in a while requiring more information to be typed ( E.G. A couple spaces ) in order to show up in saved file
* Cursor is set to the wrong position if in split view
* In certain enviroments the update script pulls the old version of the sql class causing the update to fail
* The Server has new version of file alert causes auto save to stop when the user presses okay

View file

@ -4,7 +4,6 @@
* warranty under the MIT License. See [root]/license.txt for more.
* This information must remain intact.
*/
( function( global, $ ) {
var EditSession = ace.require( 'ace/edit_session' )
@ -59,7 +58,10 @@
//}
/* Notify listeners. */
amplify.publish('active.onFileWillOpen', {path: path, content: content});
amplify.publish( 'active.onFileWillOpen', {
path: path,
content: content
});
if( focus === undefined ) {
focus = true;
@ -403,7 +405,10 @@
let _this = this;
codiad.editor.setSession( this.sessions[path] );
this.history.push( path );
$.get(this.controller, {'action':'focused', 'path':path}, function() {
$.get( this.controller, {
'action': 'focused',
'path': path
}, function() {
if( !( _this.positions[`${path}`] === undefined ) ) {
@ -448,8 +453,7 @@
/* Show the dropdown menu if needed */
this.showTabDropdownMenu();
}
}
else if(this.history.length > 0) {
} else if( this.history.length > 0 ) {
var prevPath = this.history[this.history.length - 1];
var prevSession = this.sessions[prevPath];
if( $( '#dropdown-list-active-files' ).has( prevSession.tabThumb ).length > 0 ) {
@ -611,7 +615,9 @@
/* Animate only if the tabThumb if a tab, not a dropdown item. */
if( session.tabThumb.hasClass( 'tab-item' ) ) {
session.tabThumb.css({'z-index': 1});
session.tabThumb.css( {
'z-index': 1
});
session.tabThumb.animate( {
top: $( '#editor-top-bar' ).height() + 'px'
}, 300, function() {
@ -714,7 +720,10 @@
}
$.get( this.controller + '?action=rename&old_path=' + encodeURIComponent( oldPath ) + '&new_path=' + encodeURIComponent( newPath ), function() {
/* Notify listeners. */
amplify.publish('active.onRename', {"oldPath": oldPath, "newPath": newPath});
amplify.publish( 'active.onRename', {
"oldPath": oldPath,
"newPath": newPath
});
});
},
@ -1010,8 +1019,7 @@
data: {
positions: ( JSON.stringify( codiad.active.positions ) )
},
success: function( data ) {
},
success: function( data ) {},
});
},
@ -1097,16 +1105,16 @@
createTabThumb: function( path ) {
split = this.splitDirectoryAndFileName( path );
return $('<li class="tab-item" data-path="' + path + '"><a class="label" title="' + path + '">'
+ split.directory + '<span class="file-name">' + split.fileName + '</span>'
+ '</a><a class="close">x</a></li>');
return $( '<li class="tab-item" data-path="' + path + '"><a class="label" title="' + path + '">' +
split.directory + '<span class="file-name">' + split.fileName + '</span>' +
'</a><a class="close">x</a></li>' );
},
createMenuItemThumb: function( path ) {
split = this.splitDirectoryAndFileName( path );
return $('<li data-path="' + path + '"><a title="' + path + '"><span class="label"></span><div class="label">'
+ split.directory + '<span class="file-name">' + split.fileName + '</span>'
+ '</div></a></li>');
return $( '<li data-path="' + path + '"><a title="' + path + '"><span class="label"></span><div class="label">' +
split.directory + '<span class="file-name">' + split.fileName + '</span>' +
'</div></a></li>' );
},
};

View file

@ -38,12 +38,13 @@
editor: null,
invalid_states: [ "", " ", null, undefined ],
path: curpath,
save_interval: null,
saving: false,
settings: {
autosave: true,
toggle: true,
},
verbose: false,
verbose: true,
init: async function() {
@ -109,6 +110,10 @@
* try to close it, the program will throw an exception and
* stop you from closing the file
*/
if( codiad.auto_save.verbose ) {
console.log( "Error removing event listener", e );
}
}
});
@ -128,6 +133,30 @@
});
},
auto_save: function() {
/**
* When saving after every change, we encounter an issue where every
* once in a while the last change or last few changes will not get
* saved. Due to this, I decided to instead only save after the user
* has finished typing their changes.
*
* On every change to the editor, we set a timeout of half a second
* to see if the user is still typing. If they are, we clear the
* timeout and set it again. If they have stopped typing then the
* timout is triggered after 500 miliseconds and the file is saved.
*/
let _this = codiad.auto_save;
if( _this.save_interval !== null ) {
clearTimeout( _this.save_interval );
_this.save_interval = null;
}
_this.save_interval = setTimeout( _this.save, 500 );
},
/**
*
* This is where the core functionality goes, any call, references,
@ -135,9 +164,15 @@
*
*/
auto_save: function() {
save: function() {
let _this = codiad.auto_save;
if( _this.saving ) {
return;
}
_this.saving = true;
let tabs = document.getElementsByClassName( "tab-item" );
let path = codiad.active.getPath();
@ -157,9 +192,9 @@
if( _this.verbose ) {
console.log( content, _this.content );
//console.log( content, _this.content );
}
/*
if( content == _this.content ) {
let session = codiad.active.sessions[path];
@ -180,7 +215,7 @@
return;
}
/*
this code caused issues even though it is the proper way to save something.
Whenever in collaboration, the server constantly gave a wrong file version error.
@ -210,13 +245,6 @@
}
}
_this.saving = false;
setTimeout(function() {
//Call the function again after one second so that if we missed the last change we resave the file.
let _this = codiad.auto_save;
_this.auto_save();
}, 1000);
},
reload_interval: async function() {
@ -226,7 +254,13 @@
window.clearInterval( codiad.autosave.auto_save_trigger );
window.clearInterval( this.auto_save_trigger );
} catch( error ) {}
} catch( error ) {
if( codiad.auto_save.verbose ) {
console.log( "Error clearing interval", error );
}
}
if( codiad.auto_save.settings.autosave == true || codiad.auto_save.settings.autosave == "true" ) {

View file

@ -3,7 +3,6 @@
* as-is and without warranty under the MIT License. See
* [root]/license.txt for more. This information must remain intact.
*/
( function( global, $ ) {
// Classes from Ace
@ -46,8 +45,7 @@
if( _this.splitType === 'horizontal' ) {
var w1, w2;
w1 = ui.position.left - separatorWidth / 2;
w2 = _this.root.width() - ui.position.left
- separatorWidth/2;
w2 = _this.root.width() - ui.position.left - separatorWidth / 2;
_this.splitProp = w1 / _this.root.width();
_this.childElements[0]
.width( w1 )
@ -60,8 +58,8 @@
} else {
var h1, h2;
h1 = ui.position.top - separatorWidth / 2;
h2 = _this.root.width() - ui.position.top
- separatorWidth/2;
h2 = _this.root.width() - ui.position.top -
separatorWidth / 2;
_this.splitProp = h1 / _this.root.height();
_this.childElements[0]
.height( h1 )
@ -90,10 +88,10 @@
e.stopPropagation();
if( _this.splitType === 'horizontal' ) {
var w1, w2;
w1 = _this.root.width() * _this.splitProp
- separatorWidth / 2;
w2 = _this.root.width() * (1 - _this.splitProp)
- separatorWidth / 2;
w1 = _this.root.width() * _this.splitProp -
separatorWidth / 2;
w2 = _this.root.width() * ( 1 - _this.splitProp ) -
separatorWidth / 2;
_this.childElements[0]
.width( w1 );
_this.childElements[1]
@ -132,10 +130,10 @@
.height( h );
_this.splitter.height( h );
} else if( _this.splitType === 'vertical' ) {
var h1 = _this.root.height() * _this.splitProp
- separatorWidth / 2;
var h2 = _this.root.height() * (1 - _this.splitProp)
- separatorWidth / 2;
var h1 = _this.root.height() * _this.splitProp -
separatorWidth / 2;
var h2 = _this.root.height() * ( 1 - _this.splitProp ) -
separatorWidth / 2;
_this.childElements[0]
.height( h1 );
_this.childElements[1]
@ -410,7 +408,9 @@
addInstance: function( session, where ) {
var el = $( '<div class="editor">' );
var chType, chArr = [], sc = null, chIdx = null;
var chType, chArr = [],
sc = null,
chIdx = null;
var _this = this;
if( this.instances.length == 0 ) {
@ -1282,10 +1282,10 @@
*/
$( '#cursor-position' )
.html(i18n('Ln') + ': '
+ (i.getCursorPosition().row + 1)
+ ' &middot; ' + i18n('Col') + ': '
+ i.getCursorPosition().column
.html( i18n( 'Ln' ) + ': ' +
( i.getCursorPosition().row + 1 ) +
' &middot; ' + i18n( 'Col' ) + ': ' +
i.getCursorPosition().column
);
//Register the changecursor function so updates continue
@ -1293,10 +1293,10 @@
codiad.active.savePosition();
$( '#cursor-position' )
.html(i18n('Ln') + ': '
+ (i.getCursorPosition().row + 1)
+ ' &middot; ' + i18n('Col') + ': '
+ i.getCursorPosition().column
.html( i18n( 'Ln' ) + ': ' +
( i.getCursorPosition().row + 1 ) +
' &middot; ' + i18n( 'Col' ) + ': ' +
i.getCursorPosition().column
);
});
},
@ -1549,7 +1549,9 @@
paste: function() {
navigator.clipboard.readText().then(text => {codiad.editor.getActive().insert( text )});
navigator.clipboard.readText().then( text => {
codiad.editor.getActive().insert( text )
});
},
openSort: function() {

View file

@ -3,17 +3,15 @@
* 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;
$(window)
.load(function() {
$( window ).load( function() {
codiad.filemanager.init();
});
codiad.filemanager = {
auto_reload: false,
@ -22,6 +20,7 @@
dialog: 'components/filemanager/dialog.php',
dialogUpload: 'components/filemanager/dialog_upload.php',
preview: null,
refresh_interval: null,
init: async function() {
@ -33,7 +32,7 @@
'mp4',
'wav',
'ogg',
],
];
this.noFiles = [
//Files
'exe',
@ -41,7 +40,7 @@
'zip',
'tar',
'tar.gz',
],
];
this.noImages = [
//Images
'ico',
@ -51,7 +50,7 @@
'png',
'gif',
'bmp',
],
];
this.noOpen = this.noAudio.concat( this.noFiles, this.noImages ),
@ -96,7 +95,8 @@
//////////////////////////////////////////////////////////////////
nodeListener: function() {
var _this = this;
let _this = this;
$( '#file-manager' ).on( 'selectstart', false );
@ -178,7 +178,7 @@
//////////////////////////////////////////////////////////////////
contextMenuShow: function( e, path, type, name ) {
var _this = this;
let _this = this;
$( '#context-menu a, #context-menu hr' ).hide();
// Selective options
@ -240,7 +240,11 @@
$( '#context-menu, #editor-region' ).on( 'paste', codiad.editor.paste );
/* Notify listeners. */
amplify.publish('context-menu.onShow', {e: e, path: path, type: type});
amplify.publish( 'context-menu.onShow', {
e: e,
path: path,
type: type
});
// Hide on click
$( '#context-menu a' )
.click( function() {
@ -346,7 +350,7 @@
indexFiles: [],
index: function( path, rescan ) {
var _this = this;
let _this = this;
if( rescan === undefined ) {
rescan = false;
}
@ -360,41 +364,54 @@
node.removeClass( 'open' );
});
} else {
node.addClass( 'loading' );
$.get( this.controller + '?action=index&path=' + encodeURIComponent( path ), function( data ) {
node.addClass( 'open' );
var objectsResponse = codiad.jsend.parse( data );
if( objectsResponse != 'error' ) {
/* Notify listener */
_this.indexFiles = objectsResponse.index;
amplify.publish("filemanager.onIndex", {path: path, files: _this.indexFiles});
amplify.publish( "filemanager.onIndex", {
path: path,
files: _this.indexFiles
});
var files = _this.indexFiles;
if( files.length > 0 ) {
if( node.parent().children( 'span' ).hasClass( 'plus' ) ) {
node.parent().children( 'span' ).removeClass( 'plus' ).addClass( 'minus' );
}
var display = 'display:none;';
if( rescan ) {
display = '';
}
var appendage = '<ul style="' + display + '">';
$.each( files, function( index ) {
var ext = '';
var name = files[index].name.replace( path, '' );
var nodeClass = 'none';
name = name.split( '/' )
.join( ' ' );
if( files[index].type == 'file' ) {
var ext = ' ext-' + name.split( '.' )
.pop();
}
if( files[index].type == 'directory' && files[index].size > 0 ) {
nodeClass = 'plus';
}
appendage += '<li><span class="' + nodeClass + '"></span><a class="' + files[index].type + ext + '" data-type="' + files[index].type + '" data-path="' + files[index].name + '">' + name + '</a></li>';
});
appendage += '</ul>';
if( rescan ) {
node.parent( 'li' )
.children( 'ul' )
.remove();
@ -402,6 +419,7 @@
$( appendage )
.insertAfter( node );
if( !rescan ) {
node.siblings( 'ul' )
.slideDown( 300 );
}
@ -409,8 +427,10 @@
}
node.removeClass( 'loading' );
if( rescan && _this.rescanChildren.length > _this.rescanCounter ) {
_this.rescan( _this.rescanChildren[_this.rescanCounter++] );
} else {
_this.rescanChildren = [];
_this.rescanCounter = 0;
}
@ -423,7 +443,7 @@
rescanCounter: 0,
rescan: function( path ) {
var _this = this;
let _this = this;
if( this.rescanCounter === 0 ) {
// Create array of open directories
node = $( '#file-manager a[data-path="' + path + '"]' );
@ -442,7 +462,9 @@
openFile: function( path, focus ) {
/* Notify listeners. */
amplify.publish('filemanager.onFileWillOpen', {path: path});
amplify.publish( 'filemanager.onFileWillOpen', {
path: path
});
if( focus === undefined ) {
focus = true;
@ -503,7 +525,21 @@
refreshPreview: function( event ) {
_this = codiad.filemanager;
let _this = codiad.filemanager;
/**
* When reloading after every change, we encounter performance issues
* in the editor. Therefore, we implement the same logic as the
* auto_save module where we only reload after the user has finished
* changing their document.
*/
if( _this.refresh_interval !== null ) {
clearTimeout( _this.refresh_interval );
_this.refresh_interval = null;
}
_this.refresh_interval = setTimeout( function() {
if( _this.preview == null ) {
@ -526,6 +562,7 @@
_this.preview = null;
codiad.editor.getActive().removeEventListener( "change", _this.refreshPreview );
}
}, 500 );
},
openInModal: function( path ) {
@ -547,8 +584,9 @@
});
},
saveModifications: function( path, data, callbacks, save = true ) {
callbacks = callbacks || {};
var _this = this, action, data;
let _this = this, action;
var notifySaveErr = function() {
codiad.message.error( i18n( 'File could not be saved' ) );
if( typeof callbacks.error === 'function' ) {
@ -596,12 +634,17 @@
//////////////////////////////////////////////////////////////////
saveFile: function( path, content, callbacks, save = true ) {
this.saveModifications(path, {content: content}, callbacks, save);
this.saveModifications( path, {
content: content
}, callbacks, save );
},
savePatch: function( path, patch, mtime, callbacks, alerts ) {
if( patch.length > 0 )
this.saveModifications(path, {patch: patch, mtime: mtime}, callbacks, alerts);
this.saveModifications( path, {
patch: patch,
mtime: mtime
}, callbacks, alerts );
else if( typeof callbacks.success === 'function' ) {
var context = callbacks.context || this;
callbacks.success.call( context, mtime );
@ -620,7 +663,6 @@
});
$( '#modal-content form' )
.live( 'submit', function( e ) {
let project = codiad.project.getCurrent();
e.preventDefault();
var shortName = $( '#modal-content form input[name="object_name"]' )
.val();
@ -641,10 +683,15 @@
codiad.filemanager.openFile( createPath, true );
}
codiad.filemanager.rescan( project );
codiad.filemanager.rescan( path );
/* Notify listeners. */
amplify.publish('filemanager.onCreate', {createPath: createPath, path: path, shortName: shortName, type: type});
amplify.publish( 'filemanager.onCreate', {
createPath: createPath,
path: path,
shortName: shortName,
type: type
});
}
});
});
@ -664,7 +711,7 @@
//////////////////////////////////////////////////////////////////
pasteNode: function( path ) {
var _this = this;
let _this = this;
if( this.clipboard == '' ) {
codiad.message.error( i18n( 'Nothing in Your Clipboard' ) );
} else if( path == this.clipboard ) {
@ -683,7 +730,8 @@
e.preventDefault();
var duplicate = false;
if( $( '#modal-content form select[name="or_action"]' ).val() == 1 ) {
duplicate=true; console.log('Dup!');
duplicate = true;
console.log( 'Dup!' );
}
_this.processPasteNode( path, duplicate );
});
@ -696,19 +744,24 @@
},
processPasteNode: function( path, duplicate ) {
var _this = this;
let _this = this;
var shortName = this.getShortName( this.clipboard );
var type = this.getType( this.clipboard );
$.get( this.controller + '?action=duplicate&path=' +
encodeURIComponent( this.clipboard ) + '&destination=' +
encodeURIComponent(path + '/' + shortName) + '&duplicate=' + encodeURIComponent( duplicate ), function(data) {
encodeURIComponent( path + '/' + shortName ) + '&duplicate=' + encodeURIComponent( duplicate ),
function( data ) {
var pasteResponse = codiad.jsend.parse( data );
if( pasteResponse != 'error' ) {
_this.createObject( path, path + '/' + shortName, type );
codiad.modal.unload();
/* Notify listeners. */
amplify.publish('filemanager.onPaste', {path: path, shortName: shortName, duplicate: duplicate});
amplify.publish( 'filemanager.onPaste', {
path: path,
shortName: shortName,
duplicate: duplicate
});
}
});
},
@ -720,8 +773,13 @@
renameNode: function( path ) {
var shortName = this.getShortName( path );
var type = this.getType( path );
var _this = this;
codiad.modal.load(250, this.dialog, { action: 'rename', path: path, short_name: shortName, type: type});
let _this = this;
codiad.modal.load( 250, this.dialog, {
action: 'rename',
path: path,
short_name: shortName,
type: type
});
$( '#modal-content form' )
.live( 'submit', function( e ) {
let project = codiad.project.getCurrent();
@ -735,7 +793,11 @@
temp.push( arr[i] )
}
var newPath = temp.join( '/' ) + '/' + newName;
$.get(_this.controller, { action: 'modify', path: path, new_name: newName} , function(data) {
$.get( _this.controller, {
action: 'modify',
path: path,
new_name: newName
}, function( data ) {
var renameResponse = codiad.jsend.parse( data );
let renamedMessage = "";
if( renameResponse != 'error' ) {
@ -765,9 +827,16 @@
// Change any active files
codiad.active.rename( path, newPath );
codiad.modal.unload();
codiad.filemanager.rescan( project );
let parent = path.split( '/' );
parent.pop();
codiad.filemanager.rescan( parent.join( '/' ) );
/* Notify listeners. */
amplify.publish('filemanager.onRename', {path: path, newPath: newPath, project: project });
amplify.publish( 'filemanager.onRename', {
path: path,
newPath: newPath,
project: project
});
}
});
});
@ -792,7 +861,7 @@
//////////////////////////////////////////////////////////////////
deleteNode: function( path ) {
var _this = this;
let _this = this;
codiad.modal.load( 400, this.dialog, {
action: 'delete',
path: path
@ -816,7 +885,10 @@
}
});
/* Notify listeners. */
amplify.publish('filemanager.onDelete', {deletePath: path, path: parent_path });
amplify.publish( 'filemanager.onDelete', {
deletePath: path,
path: parent_path
});
}
codiad.modal.unload();
});
@ -824,7 +896,7 @@
},
deleteInnerNode: function( path ) {
var _this = this;
let _this = this;
codiad.modal.load( 400, this.dialog, {
action: 'delete',
path: path
@ -856,7 +928,10 @@
});
/* Notify listeners. */
amplify.publish('filemanager.onDelete', {deletePath: path + "/*", path: path });
amplify.publish( 'filemanager.onDelete', {
deletePath: path + "/*",
path: path
});
}
codiad.modal.unload();
});
@ -883,7 +958,7 @@
}
});
codiad.modal.hideOverlay();
var _this = this;
let _this = this;
$( '#modal-content form' )
.live( 'submit', function( e ) {
$( '#filemanager-search-processing' )
@ -947,7 +1022,9 @@
//////////////////////////////////////////////////////////////////
uploadToNode: function( path ) {
codiad.modal.load(500, this.dialogUpload, {path: path});
codiad.modal.load( 500, this.dialogUpload, {
path: path
});
},
//////////////////////////////////////////////////////////////////

View file

@ -1,9 +1,5 @@
<?php
//ini_set('display_errors', 1);
//ini_set('display_startup_errors', 1);
//error_reporting(E_ALL);
require_once( __DIR__ . "/../sql/class.sql.php" );
require_once( __DIR__ . "/../settings/class.settings.php" );
@ -129,11 +125,11 @@ date_default_timezone_set("' . $_POST['timezone'] . '");
define("SITE_NAME", "' . $_POST['site_name'] . '");
// Database Information
define( "DBHOST", "' . $_POST['dbhost'] . '" );
define( "DBNAME", "' . $_POST['dbname'] . '" );
define( "DBUSER", "' . $_POST['dbuser'] . '" );
define( "DBPASS", "' . $_POST['dbpass'] . '" );
define( "DBTYPE", "' . $_POST['dbtype'] . '" );
define( "DBHOST", \'' . addslashes( urldecode( $_POST['dbhost'] ) ) . '\' );
define( "DBNAME", \'' . addslashes( urldecode( $_POST['dbname'] ) ) . '\' );
define( "DBUSER", \'' . addslashes( urldecode( $_POST['dbuser'] ) ) . '\' );
define( "DBPASS", \'' . addslashes( urldecode( $_POST['dbpass'] ) ) . '\' );
define( "DBTYPE", \'' . addslashes( urldecode( $_POST['dbtype'] ) ) . '\' );
//////////////////////////////////////////////////////////////////
// ** DO NOT EDIT CONFIG BELOW **

View file

@ -170,7 +170,7 @@ if ( ! empty( $query ) ) {
"MBString"=>"required",
"MySQL"=>"",
"PGSQL"=>"",
"SQLite3"=>""
//"SQLite3"=>""
] as $dep=>$status) {
if (extension_loaded(strtolower($dep))) { ?>
<div class="success"><span class="icon-check"></span> <?=$dep?></div>

View file

@ -107,6 +107,11 @@ switch( $_GET['action'] ) {
?>
<td width="70"><a onclick="codiad.message.error(i18n('Active Project Cannot Be Removed'));" class="icon-block bigger-icon"></a></td>
<?php
} elseif( $owner !== $_SESSION["user"] ) {
?>
<td width="70"><a onclick="codiad.message.error(i18n('Projects owned by others can not be deleted'));" class="icon-block bigger-icon"></a></td>
<?php
} else {
?>

View file

@ -1,60 +1,14 @@
<?php
require_once('../../common.php');
?>
<label><span class="icon-home big-icon"></span><?php i18n("Editor Settings");?></label>
<hr>
<table class="settings">
<tr>
<td width="50%"><?php i18n("Theme"); ?></td>
<td>
<select class="setting" data-setting="codiad.editor.theme">
<option value="ambiance">Ambiance</option>
<option value="chaos">Chaos</option>
<option value="chrome">Chrome</option>
<option value="clouds">Clouds</option>
<option value="clouds_midnight">Clouds - Midnight</option>
<option value="cobalt">Cobalt</option>
<option value="crimson_editor">Crimson Editor</option>
<option value="dawn">Dawn</option>
<option value="dreamweaver">Dreamweaver</option>
<option value="eclipse">Eclipse</option>
<option value="github">GitHub</option>
<option value="idle_fingers">Idle Fingers</option>
<option value="iplastic">IPlastic</option>
<option value="katzenmilch">Katzenmilch</option>
<option value="kuroir">Kuroir</option>
<option value="kr_theme">krTheme</option>
<option value="merbivore">Merbivore</option>
<option value="merbivore_soft">Merbivore Soft</option>
<option value="mono_industrial">Mono Industrial</option>
<option value="monokai">Monokai</option>
<option value="pastel_on_dark">Pastel On Dark</option>
<option value="solarized_dark">Solarized Dark</option>
<option value="solarized_light">Solarized Light</option>
<option value="sqlserver">SQL Server</option>
<option value="terminal">Terminal</option>
<option value="textmate">Textmate</option>
<option value="tomorrow">Tomorrow</option>
<option value="tomorrow_night">Tomorrow Night</option>
<option value="tomorrow_night_blue">Tomorrow Night Blue</option>
<option value="tomorrow_night_bright">Tomorrow Night Bright</option>
<option value="tomorrow_night_eighties">Tomorrow Night Eighties</option>
<option value="twilight" selected>Twilight</option>
<option value="vibrant_ink">Vibrant Ink</option>
<option value="xcode">XCode</option>
</select>
</td>
</tr>
<tr>
<td><?php i18n("Font Size");?></td>
<td>
<select class="setting" data-setting="codiad.editor.fontSize">
<option value="10px">10px</option>
<option value="11px">11px</option>
@ -66,54 +20,57 @@
<option value="17px">17px</option>
<option value="18px">18px</option>
</select>
</td>
</tr>
<tr>
<td><?php i18n("Highlight Active Line");?></td>
<td>
<select class="setting" data-setting="codiad.editor.highlightLine">
<option value="true" selected><?php i18n("Yes");?></option>
<option value="false"><?php i18n("No");?></option>
</select>
</td>
</tr>
<tr>
<td><?php i18n("Indent Guides");?></td>
<td>
<select class="setting" data-setting="codiad.editor.indentGuides">
<option value="true" selected><?php i18n("On");?></option>
<option value="false"><?php i18n("Off");?></option>
</select>
</td>
</tr>
<tr>
<td><?php i18n("Live Autocomplete"); ?></td>
<td>
<select class="setting" data-setting="codiad.editor.autocomplete">
<option value="false" selected><?php i18n("Off");?></option>
<option value="true"><?php i18n("On"); ?></option>
</select>
</td>
</tr>
<tr>
<td><?php i18n("Over Scroll"); ?></td>
<td>
<select class="setting" data-setting="codiad.editor.overScroll">
<option value="0" selected><?php i18n("None");?></option>
<option value="0.5"><?php i18n("Half");?></option>
<option value="1"><?php i18n("Full");?></option>
</select>
</td>
</tr>
<tr>
<td><?php i18n("Print Margin"); ?></td>
<td>
<select class="setting" data-setting="codiad.editor.printMargin">
<option value="true"><?php i18n("Show");?></option>
<option value="false" selected><?php i18n("Hide");?></option>
</select>
</td>
</tr>
<tr>
<td><?php i18n("Print Margin Column");?></td>
<td>
<select class="setting" data-setting="codiad.editor.printMarginColumn">
<option value="80" selected>80</option>
<option value="85">85</option>
@ -125,28 +82,20 @@
<option value="115">115</option>
<option value="120">120</option>
</select>
</td>
</tr>
<tr>
<td><?php i18n("Wrap Lines"); ?></td>
<td><?php i18n("Soft Tabs");?></td>
<td>
<select class="setting" data-setting="codiad.editor.wrapMode">
<option value="false" selected><?php i18n("No wrap"); ?></option>
<option value="true"><?php i18n("Wrap Lines"); ?></option>
<select class="setting" data-setting="codiad.editor.softTabs">
<option value="false" selected><?php i18n("No");?></option>
<option value="true"><?php i18n("Yes");?></option>
</select>
</td>
</tr>
<tr>
<td><?php i18n("Tab Size");?></td>
<td>
<select class="setting" data-setting="codiad.editor.tabSize">
<option value="2">2</option>
<option value="3">3</option>
@ -156,46 +105,36 @@
<option value="7">7</option>
<option value="8">8</option>
</select>
</td>
</tr>
<tr>
<td><?php i18n("Soft Tabs"); ?></td>
<td>
<select class="setting" data-setting="codiad.editor.softTabs">
<option value="false" selected><?php i18n("No"); ?></option>
<option value="true"><?php i18n("Yes"); ?></option>
</select>
</td>
</tr>
<tr>
<td><?php i18n("Over Scroll"); ?></td>
<td>
<select class="setting" data-setting="codiad.editor.overScroll">
<option value="0" selected><?php i18n("None"); ?></option>
<option value="0.5"><?php i18n("Half"); ?></option>
<option value="1"><?php i18n("Full"); ?></option>
</select>
</td>
</tr>
<tr>
<td><?php i18n("Live Autocomplete"); ?></td>
<td width="50%"><?php i18n("Theme");?></td>
<td>
<select class="setting" data-setting="codiad.editor.theme">
<?php
<select class="setting" data-setting="codiad.editor.autocomplete">
<option value="false" selected><?php i18n("Off"); ?></option>
<option value="true"><?php i18n("On"); ?></option>
$files = glob( COMPONENTS . "/editor/ace-editor/*.js" );
foreach( $files as $file ) {
$name = pathinfo( $file, PATHINFO_FILENAME );
if( strpos( strtolower( $name ), strtolower( "theme-" ) ) !== false ) {
$value = str_replace( "theme-", "", str_replace( ".js", "", $name ) );
$name = ucwords( str_replace( "_", " ", $value ) );
?><option value="<?php echo $value;?>"><?php echo $name;?></option><?php
}
}
?>
</select>
</td>
</tr>
<tr>
<td><?php i18n("Wrap Lines"); ?></td>
<td>
<select class="setting" data-setting="codiad.editor.wrapMode">
<option value="false" selected><?php i18n("No wrap");?></option>
<option value="true"><?php i18n("Wrap Lines");?></option>
</select>
</td>
</tr>
</table>

View file

@ -7,8 +7,8 @@ class sql {
const DB_TYPES = array(
"MySQL" => "mysql",
"PostgresSQL" => "pgsql",
"SQLite" => "sqlite",
"PostgreSQL" => "pgsql",
//"SQLite" => "sqlite",
);
public $connection = null;

View file

@ -12,7 +12,7 @@ class Update {
// CONSTANTS
//////////////////////////////////////////////////////////////////
CONST VERSION = "v.2.9.4.1";
CONST VERSION = "v.2.9.5";
//////////////////////////////////////////////////////////////////
// PROPERTIES

View file

@ -5,11 +5,14 @@
//error_reporting(E_ALL);
require_once('../../common.php');
require_once('../settings/class.settings.php');
require_once('./class.update.php');
$user_settings_file = DATA . "/settings.php";
$projects_file = DATA . "/projects.php";
$users_file = DATA . "/users.php";
$user_settings_file = BASE_PATH . "/data/settings.php";
$projects_file = BASE_PATH . "/data/projects.php";
$users_file = BASE_PATH . "/data/users.php";
//checkSession();
if ( ! checkAccess() ) {
echo "Error, you do not have access to update Codiad.";
@ -102,8 +105,6 @@ class updater {
mkdir( $backup, 00755 );
}
function copy_backup( $source, $dest ) {
// Check for symlinks
@ -173,8 +174,6 @@ class updater {
function check_sql() {
require_once('../../common.php');
require_once('../sql/class.sql.php');
$sql = new sql();
$connection = $sql->connect();
$result = $sql->create_default_tables();
@ -211,9 +210,6 @@ class updater {
function convert() {
require_once('../sql/class.sql.php');
require_once('../settings/class.settings.php');
$user_settings_file = DATA . "/settings.php";
$projects_file = DATA . "/projects.php";
$users_file = DATA . "/users.php";
@ -235,6 +231,9 @@ class updater {
if( file_exists( $projects_file ) ) {
$projects = getJSON( 'projects.php' );
if( is_array( $projects ) ) {
foreach( $projects as $project => $data ) {
$owner = 'nobody';
@ -249,12 +248,16 @@ class updater {
exit( formatJSEND( "error", "There was an error adding projects to database." ) );
}
}
}
unlink( $projects_file );
}
if( file_exists( $users_file ) ) {
$users = getJSON( 'users.php' );
if( is_array( $users ) ) {
foreach( $users as $user ) {
if( $user["username"] === $_SESSION["user"] ) {
@ -279,6 +282,7 @@ class updater {
exit(formatJSEND( "error", "The Username is Already Taken" ));
}
}
}
unlink( $users_file );
}
}
@ -415,7 +419,7 @@ class updater {
function remove_directory( $path ) {
$files = glob($path . '/*');
$files = glob( $path . '{,.}[!.,!..]*', GLOB_MARK|GLOB_BRACE );
foreach( $files as $file ) {
is_dir( $file ) ? $this->remove_directory( $file ) : unlink( $file );
@ -524,8 +528,6 @@ class updater {
$this->copyr( $src, $dest );
$this->remove_directory( $src );
$this->convert();
$this->check_sql();
return( "true" );
} catch( Exception $e ) {
@ -534,6 +536,21 @@ class updater {
}
}
public function update_database() {
try {
$this->convert();
} catch( Exception $e ) {
$this->restore();
return( $e );
}
$this->check_sql();
return( "true" );
}
public function update_option( $option, $value, $user_setting = null ) {
$sql = new sql();
@ -619,6 +636,11 @@ if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) {
echo $updater->update();
break;
case( "update_database" ):
echo $updater->update_database();
break;
}
exit();
@ -674,6 +696,7 @@ if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) {
const codiad = {};
codiad.update = {
base_url: `<?php echo BASE_URL;?>`,
progress: null,
init: function() {
@ -711,6 +734,35 @@ if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) {
});
},
apply_database: function() {
return jQuery.ajax({
url: "update.php",
type: "GET",
dataType: 'html',
data: {
action: 'update_database',
},
success: function( result ) {
return result;
},
error: function( jqXHR, textStatus, errorThrown ) {
console.log( 'jqXHR:' );
console.log( jqXHR );
console.log( 'textStatus:' );
console.log( textStatus);
console.log( 'errorThrown:' );
console.log( errorThrown );
return null;
}
});
},
check_update: function() {
this.progress.innerText = "Checking for update ... ";
@ -809,6 +861,33 @@ if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) {
update: async function() {
let GET = {};
let parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function( m, key, value) {
GET[key] = value;
});
if( Object.keys( GET ).includes( "step" ) && GET.step === "database_update" ) {
progress.innerText = "Applying database update.";
let apply = await this.apply_database();
if( apply !== "true" ) {
console.log( apply );
progress.innerText = "Error applying update.";
return;
}
progress.innerText = "Successfully completed update. Returning you to Codiad ...";
setTimeout( function() {
window.location.href = `${location.protocol}//${codiad.update.base_url}`;
}, 5000);
return;
}
let result = await this.check_update();
console.log( result );
@ -834,7 +913,7 @@ if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) {
return;
}
progress.innerText = "Applying update.";
progress.innerText = "Applying filesystem update.";
let apply = await this.apply();
if( apply !== "true" ) {
@ -844,7 +923,12 @@ if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) {
return;
}
progress.innerText = "Update Finished.";
progress.innerText = "Filesystem update finished. Please wait, your browser will now reload and start the datbase update.";
setTimeout( function() {
window.location.href = window.location.href + "?step=database_update"
}, 5000);
} else if( result === "false" ) {
progress.innerText = "No update was found ...";
@ -856,6 +940,28 @@ if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) {
update_development: async function() {
let GET = {};
let parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function( m, key, value) {
GET[key] = value;
});
if( Object.keys( GET ).includes( "step" ) && GET.step === "database_update" ) {
progress.innerText = "Applying database update.";
let apply = await this.apply_database();
if( apply !== "true" ) {
console.log( apply );
progress.innerText = "Error applying update.";
return;
}
progress.innerText = "Successfully completed update. You may now return to Codiad.";
return;
}
progress.innerText = "An update was found. Downloading update.";
let download = await this.download( true );
@ -876,7 +982,7 @@ if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) {
return;
}
progress.innerText = "Applying update.";
progress.innerText = "Applying filesystem update.";
let apply = await this.apply();
if( apply !== "true" ) {
@ -886,7 +992,12 @@ if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) {
return;
}
progress.innerText = "Update Finished.";
progress.innerText = "Filesystem update finished. Please wait, your browser will now reload and start the datbase update.";
setTimeout( function() {
window.location.href = window.location.href + "?step=database_update"
}, 5000);
},
};
</script>

View file

@ -41,7 +41,6 @@ class User {
public function __construct() {
$this->actives = getJSON( 'active.php' );
}
public function add_user() {