Started system object, added timezone to install, fixed issues with update script,

This commit is contained in:
xevidos 2019-04-12 12:11:27 -04:00
parent d298255e51
commit 3019999299
6 changed files with 107 additions and 8 deletions

View File

@ -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 .= '<option selected="selected" value="' . $key . '">' . $city . '</option>';
$timezones .= '<option value="' . $key . '" selected="selected">' . $city . '</option>';
} else {
$timezones .= '<option value="' . $key . '">' . $city . '</option>';
}
@ -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 ) {
$(".hide_field").click( function( e ) {
let input = e.target.parent.querySelector( 'input' );
let input = e.target.parentElement.querySelector( 'input' );
if( input.type == "password" ) {

View File

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

View File

@ -0,0 +1,33 @@
<?php
require_once('../../common.php');
if ( ! isset( $_POST['action'] ) ) {
die( formatJSEND( "error", "Missing parameter" ) );
}
//////////////////////////////////////////////////////////////////
// Verify Session or Key
//////////////////////////////////////////////////////////////////
checkSession();
if ( $_POST['action'] == 'create_default_tables' ) {
if( is_admin() ) {
global $sql;
$result = $sql->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." ) );
}
}

View File

@ -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 ) {

View File

@ -443,7 +443,6 @@ if( defined( "SITE_NAME" ) && ! ( SITE_NAME === "" || SITE_NAME === null ) ) {
<!-- Codiad System Variables -->
<script>
codiad.system = {};
codiad.system.site_id = `<?php echo $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];?>`;
codiad.system.session_id = `<?php echo SESSION_ID;?>`;
</script>

View File

@ -106,5 +106,51 @@
});
});
$(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);