diff --git a/components/install/view.php b/components/install/view.php index ad0022e..6fc1e26 100755 --- a/components/install/view.php +++ b/components/install/view.php @@ -21,6 +21,10 @@ $conf = $path . '/config.php'; $config = is_writable(file_exists($conf) ? $conf : $path); +$date = new DateTime(); +$timeZone = $date->getTimezone()->getName(); + + if (ini_get('register_globals') == 1) { $register = true; } else { @@ -41,7 +45,7 @@ $autocomplete = array( 'password_confirm' => '', 'project_name' => '', 'project_path' => '', - 'timezone' => '', + 'timezone' => $timeZone, 'site_name' => '', 'dbhost' => '', @@ -302,7 +306,7 @@ if ($newrelic) { $timezones = ""; foreach ($location as $key => $city) { if ($autocomplete['timezone'] == $key) { - $timezones .= ''; + $timezones .= ''; } else { $timezones .= ''; } @@ -344,9 +348,9 @@ if ($newrelic) { if($(this).text().indexOf(timezone) > -1) $("[name=timezone]").val($(this).val()); }) - document.querySelectorAll( ".hide_field" ).addEventListener( "click", function( e ) { - - let input = e.target.parent.querySelector( 'input' ); + $(".hide_field").click( function( e ) { + + let input = e.target.parentElement.querySelector( 'input' ); if( input.type == "password" ) { diff --git a/components/sql/class.sql.php b/components/sql/class.sql.php index b2b7524..c421039 100755 --- a/components/sql/class.sql.php +++ b/components/sql/class.sql.php @@ -50,7 +50,7 @@ class sql { public function create_default_tables() { - $this->sql->create_tables( + $result = $this->create_tables( array( "active" => array( "fields" => array( @@ -130,6 +130,8 @@ class sql { ), ) ); + + return $result; } public function create_tables( $table ) { @@ -176,6 +178,9 @@ class sql { if ( $result === false || ! $error[0] == "00000" ) { return false; + } else { + + return true; } } diff --git a/components/system/controller.php b/components/system/controller.php new file mode 100644 index 0000000..c1ffdac --- /dev/null +++ b/components/system/controller.php @@ -0,0 +1,33 @@ +create_default_tables(); + + if( $result === true ) { + + exit( formatJSEND( "success", "Created tables." ) ); + } else { + + exit( formatJSEND( "error", "Could not create tables." ) ); + } + } else { + + exit( formatJSEND( "error", "Only admins can use this method." ) ); + } +} \ No newline at end of file diff --git a/components/update/update.php b/components/update/update.php index e957932..26d4847 100755 --- a/components/update/update.php +++ b/components/update/update.php @@ -95,6 +95,8 @@ class updater { mkdir( $backup, 00755 ); } + + function copy_backup( $source, $dest ) { // Check for symlinks @@ -161,6 +163,15 @@ 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(); + } + function check_update() { $response = $this->update->getRemoteVersion(); @@ -199,7 +210,7 @@ class updater { $user_settings_file = DATA . "/settings.php"; $projects_file = DATA . "/projects.php"; $users_file = DATA . "/users.php"; - global $sql; + $sql = new sql(); $connection = $sql->connect(); $result = $sql->create_default_tables(); @@ -457,6 +468,7 @@ class updater { $this->copyr( $src, $dest ); $this->remove_directory( $src ); $this->convert(); + $this->check_sql(); return( "true" ); } catch( Exception $e ) { diff --git a/index.php b/index.php index 7ed9e2f..d9579bc 100755 --- a/index.php +++ b/index.php @@ -443,7 +443,6 @@ if( defined( "SITE_NAME" ) && ! ( SITE_NAME === "" || SITE_NAME === null ) ) { diff --git a/js/system.js b/js/system.js index f552f33..ee61afb 100755 --- a/js/system.js +++ b/js/system.js @@ -105,6 +105,52 @@ codiad.settings.show(); }); }); + + $(function() { + + codiad.system.init(); + }); + + codiad.system = { + + controller: 'components/system/controller.php', + session_id: '', + site_id: '', + + init: function() { + + let _this = this; + + }, + + create_default_tables: function() { + + jQuery.ajax({ + + url: this.controller, + type: "POST", + dataType: 'html', + data: { + action: 'create_default_tables' + }, + success: function( data ) { + + let response = codiad.jsend.parse( data ); + + console.log( data ); + }, + error: function(jqXHR, textStatus, errorThrown) { + + console.log('jqXHR:'); + console.log(jqXHR); + console.log('textStatus:'); + console.log(textStatus); + console.log('errorThrown:'); + console.log(errorThrown); + }, + }); + }, + }; })(this, jQuery);