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. 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_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", "max_preserve_newlines": "5",
"preserve_newlines": true, "preserve_newlines": true,
"keep_array_indentation": true, "space_after_anon_function": false,
"break_chained_methods": false, "space_after_named_function": false,
"indent_scripts": "normal",
"brace_style": "collapse",
"space_before_conditional": false, "space_before_conditional": false,
"space_in_empty_paren": false,
"space_in_paren": true,
"unescape_strings": false, "unescape_strings": false,
"jslint_happy": false, "unindent_chained_methods": true,
"end_with_newline": true, "wrap_line_length": "0"
"wrap_line_length": "0",
"indent_inner_html": true,
"comma_first": false,
"e4x": false
} }
If you have questions, please ask. Submit an issue or [contact us directly](mailto:support@telaaedifex.com). 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: Repositories:
[GitLab](https://gitlab.com/xevidos/codiad) [GitLab](https://gitlab.com/xevidos/codiad)
[GitHub](https://github.com/xevidos/codiad) [GitHub](https://github.com/xevidos/codiad)
Issues: Issues:
[GitLab](https://gitlab.com/xevidos/codiad/issues) [GitLab](https://gitlab.com/xevidos/codiad/issues)
[GitHub](https://github.com/xevidos/codiad/issues) [GitHub](https://github.com/xevidos/codiad/issues)
Features: Features:
@ -37,16 +39,19 @@ Task List:
* Add ability to login with LDAP * Add ability to login with LDAP
* Add custom market * 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 - Group Management
- Permissions Management - Permissions Management
- Plugin Management - Plugin Management
- Project Management - Project Management
- System Settings - System Settings
- User Management - 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 if file could not be saved 5 times close the open file
* Add multi level users. ( Projects for only certain groups, Permission levels ) * Add multi level users. ( Projects for only certain groups, Permission levels )
* Add mobile compatibility * 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 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 * Add in auto save timer that saves after the user stops typing instead of after every change
* Clean up update script * Clean up update script
@ -70,7 +75,9 @@ Completed:
* Updated for PHP 7.2 * 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. * 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. * 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

File diff suppressed because it is too large Load diff

View file

@ -38,12 +38,13 @@
editor: null, editor: null,
invalid_states: [ "", " ", null, undefined ], invalid_states: [ "", " ", null, undefined ],
path: curpath, path: curpath,
save_interval: null,
saving: false, saving: false,
settings: { settings: {
autosave: true, autosave: true,
toggle: true, toggle: true,
}, },
verbose: false, verbose: true,
init: async function() { init: async function() {
@ -109,6 +110,10 @@
* try to close it, the program will throw an exception and * try to close it, the program will throw an exception and
* stop you from closing the file * 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, * This is where the core functionality goes, any call, references,
@ -135,9 +164,15 @@
* *
*/ */
auto_save: function() { save: function() {
let _this = codiad.auto_save; let _this = codiad.auto_save;
if( _this.saving ) {
return;
}
_this.saving = true; _this.saving = true;
let tabs = document.getElementsByClassName( "tab-item" ); let tabs = document.getElementsByClassName( "tab-item" );
let path = codiad.active.getPath(); let path = codiad.active.getPath();
@ -157,9 +192,9 @@
if( _this.verbose ) { if( _this.verbose ) {
console.log( content, _this.content ); //console.log( content, _this.content );
} }
/*
if( content == _this.content ) { if( content == _this.content ) {
let session = codiad.active.sessions[path]; let session = codiad.active.sessions[path];
@ -180,7 +215,7 @@
return; return;
} }
/*
this code caused issues even though it is the proper way to save something. 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. Whenever in collaboration, the server constantly gave a wrong file version error.
@ -210,13 +245,6 @@
} }
} }
_this.saving = false; _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() { reload_interval: async function() {
@ -226,7 +254,13 @@
window.clearInterval( codiad.autosave.auto_save_trigger ); window.clearInterval( codiad.autosave.auto_save_trigger );
window.clearInterval( this.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" ) { if( codiad.auto_save.settings.autosave == true || codiad.auto_save.settings.autosave == "true" ) {

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

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

View file

@ -170,7 +170,7 @@ if ( ! empty( $query ) ) {
"MBString"=>"required", "MBString"=>"required",
"MySQL"=>"", "MySQL"=>"",
"PGSQL"=>"", "PGSQL"=>"",
"SQLite3"=>"" //"SQLite3"=>""
] as $dep=>$status) { ] as $dep=>$status) {
if (extension_loaded(strtolower($dep))) { ?> if (extension_loaded(strtolower($dep))) { ?>
<div class="success"><span class="icon-check"></span> <?=$dep?></div> <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> <td width="70"><a onclick="codiad.message.error(i18n('Active Project Cannot Be Removed'));" class="icon-block bigger-icon"></a></td>
<?php <?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 { } else {
?> ?>

View file

@ -1,60 +1,14 @@
<?php <?php
require_once('../../common.php');
require_once('../../common.php');
?> ?>
<label><span class="icon-home big-icon"></span><?php i18n("Editor Settings"); ?></label> <label><span class="icon-home big-icon"></span><?php i18n("Editor Settings");?></label>
<hr> <hr>
<table class="settings"> <table class="settings">
<tr> <tr>
<td><?php i18n("Font Size");?></td>
<td width="50%"><?php i18n("Theme"); ?></td>
<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"> <select class="setting" data-setting="codiad.editor.fontSize">
<option value="10px">10px</option> <option value="10px">10px</option>
<option value="11px">11px</option> <option value="11px">11px</option>
@ -66,54 +20,57 @@
<option value="17px">17px</option> <option value="17px">17px</option>
<option value="18px">18px</option> <option value="18px">18px</option>
</select> </select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td><?php i18n("Highlight Active Line");?></td>
<td><?php i18n("Highlight Active Line"); ?></td>
<td> <td>
<select class="setting" data-setting="codiad.editor.highlightLine"> <select class="setting" data-setting="codiad.editor.highlightLine">
<option value="true" selected><?php i18n("Yes"); ?></option> <option value="true" selected><?php i18n("Yes");?></option>
<option value="false"><?php i18n("No"); ?></option> <option value="false"><?php i18n("No");?></option>
</select> </select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td><?php i18n("Indent Guides");?></td>
<td><?php i18n("Indent Guides"); ?></td>
<td> <td>
<select class="setting" data-setting="codiad.editor.indentGuides"> <select class="setting" data-setting="codiad.editor.indentGuides">
<option value="true" selected><?php i18n("On"); ?></option> <option value="true" selected><?php i18n("On");?></option>
<option value="false"><?php i18n("Off"); ?></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> </select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td><?php i18n("Print Margin"); ?></td> <td><?php i18n("Print Margin"); ?></td>
<td> <td>
<select class="setting" data-setting="codiad.editor.printMargin"> <select class="setting" data-setting="codiad.editor.printMargin">
<option value="true"><?php i18n("Show"); ?></option> <option value="true"><?php i18n("Show");?></option>
<option value="false" selected><?php i18n("Hide"); ?></option> <option value="false" selected><?php i18n("Hide");?></option>
</select> </select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td><?php i18n("Print Margin Column");?></td>
<td><?php i18n("Print Margin Column"); ?></td>
<td> <td>
<select class="setting" data-setting="codiad.editor.printMarginColumn"> <select class="setting" data-setting="codiad.editor.printMarginColumn">
<option value="80" selected>80</option> <option value="80" selected>80</option>
<option value="85">85</option> <option value="85">85</option>
@ -125,28 +82,20 @@
<option value="115">115</option> <option value="115">115</option>
<option value="120">120</option> <option value="120">120</option>
</select> </select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td><?php i18n("Soft Tabs");?></td>
<td><?php i18n("Wrap Lines"); ?></td>
<td> <td>
<select class="setting" data-setting="codiad.editor.softTabs">
<select class="setting" data-setting="codiad.editor.wrapMode"> <option value="false" selected><?php i18n("No");?></option>
<option value="false" selected><?php i18n("No wrap"); ?></option> <option value="true"><?php i18n("Yes");?></option>
<option value="true"><?php i18n("Wrap Lines"); ?></option>
</select> </select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td><?php i18n("Tab Size");?></td>
<td><?php i18n("Tab Size"); ?></td>
<td> <td>
<select class="setting" data-setting="codiad.editor.tabSize"> <select class="setting" data-setting="codiad.editor.tabSize">
<option value="2">2</option> <option value="2">2</option>
<option value="3">3</option> <option value="3">3</option>
@ -156,46 +105,36 @@
<option value="7">7</option> <option value="7">7</option>
<option value="8">8</option> <option value="8">8</option>
</select> </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> </td>
</tr> </tr>
<tr> <tr>
<td width="50%"><?php i18n("Theme");?></td>
<td><?php i18n("Live Autocomplete"); ?></td>
<td> <td>
<select class="setting" data-setting="codiad.editor.theme">
<?php
<select class="setting" data-setting="codiad.editor.autocomplete"> $files = glob( COMPONENTS . "/editor/ace-editor/*.js" );
<option value="false" selected><?php i18n("Off"); ?></option> foreach( $files as $file ) {
<option value="true"><?php i18n("On"); ?></option>
$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> </select>
</td> </td>
</tr> </tr>
</table> </table>

View file

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

View file

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

View file

@ -5,11 +5,14 @@
//error_reporting(E_ALL); //error_reporting(E_ALL);
require_once('../../common.php'); require_once('../../common.php');
require_once('../settings/class.settings.php');
require_once('./class.update.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(); //checkSession();
if ( ! checkAccess() ) { if ( ! checkAccess() ) {
echo "Error, you do not have access to update Codiad."; echo "Error, you do not have access to update Codiad.";
@ -102,8 +105,6 @@ class updater {
mkdir( $backup, 00755 ); mkdir( $backup, 00755 );
} }
function copy_backup( $source, $dest ) { function copy_backup( $source, $dest ) {
// Check for symlinks // Check for symlinks
@ -173,8 +174,6 @@ class updater {
function check_sql() { function check_sql() {
require_once('../../common.php');
require_once('../sql/class.sql.php');
$sql = new sql(); $sql = new sql();
$connection = $sql->connect(); $connection = $sql->connect();
$result = $sql->create_default_tables(); $result = $sql->create_default_tables();
@ -211,9 +210,6 @@ class updater {
function convert() { function convert() {
require_once('../sql/class.sql.php');
require_once('../settings/class.settings.php');
$user_settings_file = DATA . "/settings.php"; $user_settings_file = DATA . "/settings.php";
$projects_file = DATA . "/projects.php"; $projects_file = DATA . "/projects.php";
$users_file = DATA . "/users.php"; $users_file = DATA . "/users.php";
@ -235,6 +231,9 @@ class updater {
if( file_exists( $projects_file ) ) { if( file_exists( $projects_file ) ) {
$projects = getJSON( 'projects.php' ); $projects = getJSON( 'projects.php' );
if( is_array( $projects ) ) {
foreach( $projects as $project => $data ) { foreach( $projects as $project => $data ) {
$owner = 'nobody'; $owner = 'nobody';
@ -246,7 +245,8 @@ class updater {
} else { } else {
$this->restore(); $this->restore();
exit(formatJSEND( "error", "There was an error adding projects to database." )); exit( formatJSEND( "error", "There was an error adding projects to database." ) );
}
} }
} }
unlink( $projects_file ); unlink( $projects_file );
@ -255,6 +255,9 @@ class updater {
if( file_exists( $users_file ) ) { if( file_exists( $users_file ) ) {
$users = getJSON( 'users.php' ); $users = getJSON( 'users.php' );
if( is_array( $users ) ) {
foreach( $users as $user ) { foreach( $users as $user ) {
if( $user["username"] === $_SESSION["user"] ) { if( $user["username"] === $_SESSION["user"] ) {
@ -279,6 +282,7 @@ class updater {
exit(formatJSEND( "error", "The Username is Already Taken" )); exit(formatJSEND( "error", "The Username is Already Taken" ));
} }
} }
}
unlink( $users_file ); unlink( $users_file );
} }
} }
@ -415,10 +419,10 @@ class updater {
function remove_directory( $path ) { function remove_directory( $path ) {
$files = glob($path . '/*'); $files = glob( $path . '{,.}[!.,!..]*', GLOB_MARK|GLOB_BRACE );
foreach ($files as $file) { foreach( $files as $file ) {
is_dir($file) ? $this->remove_directory($file) : unlink($file); is_dir( $file ) ? $this->remove_directory( $file ) : unlink( $file );
} }
if( is_dir( $path ) ) { if( is_dir( $path ) ) {
@ -524,8 +528,6 @@ class updater {
$this->copyr( $src, $dest ); $this->copyr( $src, $dest );
$this->remove_directory( $src ); $this->remove_directory( $src );
$this->convert();
$this->check_sql();
return( "true" ); return( "true" );
} catch( Exception $e ) { } 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 ) { public function update_option( $option, $value, $user_setting = null ) {
$sql = new sql(); $sql = new sql();
@ -619,6 +636,11 @@ if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) {
echo $updater->update(); echo $updater->update();
break; break;
case( "update_database" ):
echo $updater->update_database();
break;
} }
exit(); exit();
@ -674,6 +696,7 @@ if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) {
const codiad = {}; const codiad = {};
codiad.update = { codiad.update = {
base_url: `<?php echo BASE_URL;?>`,
progress: null, progress: null,
init: function() { 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() { check_update: function() {
this.progress.innerText = "Checking for update ... "; this.progress.innerText = "Checking for update ... ";
@ -809,6 +861,33 @@ if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) {
update: async function() { 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(); let result = await this.check_update();
console.log( result ); console.log( result );
@ -834,7 +913,7 @@ if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) {
return; return;
} }
progress.innerText = "Applying update."; progress.innerText = "Applying filesystem update.";
let apply = await this.apply(); let apply = await this.apply();
if( apply !== "true" ) { if( apply !== "true" ) {
@ -844,7 +923,12 @@ if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) {
return; 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" ) { } else if( result === "false" ) {
progress.innerText = "No update was found ..."; progress.innerText = "No update was found ...";
@ -856,6 +940,28 @@ if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) {
update_development: async function() { 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."; progress.innerText = "An update was found. Downloading update.";
let download = await this.download( true ); let download = await this.download( true );
@ -876,7 +982,7 @@ if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) {
return; return;
} }
progress.innerText = "Applying update."; progress.innerText = "Applying filesystem update.";
let apply = await this.apply(); let apply = await this.apply();
if( apply !== "true" ) { if( apply !== "true" ) {
@ -886,7 +992,12 @@ if( isset( $_GET["action"] ) && $_GET["action"] !== '' ) {
return; 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> </script>

View file

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