Fixed localstorage redifinition, Added more description to error messages on install process to console.

This commit is contained in:
xevidos 2019-04-01 16:20:57 -04:00
parent 707b61ea6e
commit d045c696ed
3 changed files with 19 additions and 19 deletions

View File

@ -1,5 +1,4 @@
<?php <?php
/* /*
* Copyright (c) Codiad & Kent Safranski (codiad.com), Isaac Brown (telaaedifex.com), * Copyright (c) Codiad & Kent Safranski (codiad.com), Isaac Brown (telaaedifex.com),
* distributed as-is and without warranty under the MIT License. See * distributed as-is and without warranty under the MIT License. See
@ -27,7 +26,7 @@ $config = $path . "/config.php";
function saveFile( $file, $data ) { function saveFile( $file, $data ) {
$write = fopen( $file, 'w' ) or die( "can't open file" ); $write = fopen( $file, 'w' ) or die( '{"message": "can\'t open file"}' );
fwrite( $write, $data ); fwrite( $write, $data );
fclose( $write ); fclose( $write );
} }
@ -104,26 +103,24 @@ if ( ! ( defined( 'DBHOST' ) && defined( 'DBNAME' ) && defined( 'DBUSER' ) && de
//Is selected database type valid? //Is selected database type valid?
if( ! in_array( $dbtype, $db_types ) ) { if( ! in_array( $dbtype, $db_types ) ) {
die( "Invalid database. Please select one of " . implode( ", ", $db_types ) . "." ); die( '{"message": "Invalid database. Please select one of the following: ' . implode( ", ", $db_types ) . '.", "error": "' . addslashes(json_encode( array( $dbtype, $db_types ) ) ) . '"}' );
} }
try { try {
$connection = new PDO( "{$dbtype}:host={$dbhost};dbname={$dbname}", $dbuser, $dbpass ); $connection = new PDO( "{$dbtype}:host={$dbhost};dbname={$dbname}", $dbuser, $dbpass );
} catch( exception $e ) { } catch( PDOException $e ) {
die( "Could not connect to database." ); die( '{"message":"Could not connect to database.","error":"' . addslashes( json_encode( $e->getMessage() ) ) .'"}' );
die();
} }
$bind_vars = array(); $bind_vars = array();
$bind = ""; $bind = "";
$database_sql_fullpath = $path . '/components/install/sql/' . $dbtype . '.sql'; $database_sql_fullpath = $path . '/components/install/sql/' . $dbtype . '.sql';
if( ! is_file( $database_sql_fullpath ) ) { if( ! is_file( $database_sql_fullpath ) ) {
die("Could not find the sql of the database ".$dbtype." to execute"); die( '{"message":"Could not find the sql script for the database type: ' . $dbtype . '","error":"' . addslashes( json_encode( array( "path" => $database_sql_fullpath, "dbtype" => $dbtype ) ) ) .'"}' );
} }
$sql = file_get_contents( $database_sql_fullpath ); $sql = file_get_contents( $database_sql_fullpath );
try { try {
@ -131,13 +128,13 @@ if ( ! ( defined( 'DBHOST' ) && defined( 'DBNAME' ) && defined( 'DBUSER' ) && de
$result = $connection->exec( $sql ); $result = $connection->exec( $sql );
} catch( PDOException $e ) { } catch( PDOException $e ) {
die($e->getMessage()); die( '{"message":"Could not create initial tables in database.","error":"' . addslashes( json_encode( $e->getMessage() ) ) .'"}' );
} }
$error = $connection->errorInfo(); $error = $connection->errorInfo();
if( ! $error[0] == "00000" ) { if( ! $error[0] == "00000" ) {
die( $error[2] ); die( '{"message":"Could not create initial tables in database.","error":"' . addslashes( json_encode( $error ) ) .'"}' );
} }
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
@ -164,13 +161,13 @@ if ( ! ( defined( 'DBHOST' ) && defined( 'DBNAME' ) && defined( 'DBUSER' ) && de
if ( ! mkdir( $project_path . '/', 0755, true ) ) { if ( ! mkdir( $project_path . '/', 0755, true ) ) {
die( "Unable to create Absolute Path" ); die( '{"message": "Unable to create Absolute Path"}' );
} }
} else { } else {
if ( ! is_writable( $project_path ) || ! is_readable( $project_path ) ) { if ( ! is_writable( $project_path ) || ! is_readable( $project_path ) ) {
die( "No Read/Write Permission" ); die( '{"message": "No Read/Write Permission"}' );
} }
} }
} }
@ -187,7 +184,7 @@ if ( ! ( defined( 'DBHOST' ) && defined( 'DBNAME' ) && defined( 'DBUSER' ) && de
if( ! $error[0] == "00000" ) { if( ! $error[0] == "00000" ) {
die( $error[2] ); die( '{"message":"Could not create project in database.","error":"' . addslashes(json_encode( $error )) .'"}' );
} }
$bind_variables = array( $bind_variables = array(
@ -208,7 +205,7 @@ if ( ! ( defined( 'DBHOST' ) && defined( 'DBNAME' ) && defined( 'DBUSER' ) && de
if( ! $error[0] == "00000" ) { if( ! $error[0] == "00000" ) {
die( $error[2] ); die( '{"message":"Could not create user in database.","error":"' . addslashes(json_encode( $error )) .'"}' );
} }

View File

@ -344,11 +344,14 @@ if ($newrelic) {
if(!password_match){ alert('The passwords entered do not match'); } if(!password_match){ alert('The passwords entered do not match'); }
if(!empty_fields && password_match && check_path){ if(!empty_fields && password_match && check_path){
$.post('components/install/process.php',$('#install').serialize(),function(data){ $.post('components/install/process.php',$('#install').serialize(),function( data ) {
if(data=='success'){
if( data == 'success' ){
window.location.reload(); window.location.reload();
}else{ } else {
alert("An Error Occoured\n"+data); data = JSON.parse( data );
console.log( data.error );
alert( "An Error Occurred\n" + data.message );
} }
}); });
} }

View File

@ -44,7 +44,7 @@ Dual licensed under the MIT or GPL licenses.
setItem: async function( key, value ) { setItem: async function( key, value ) {
let value = await codiad.settings.update_option( key, value ); let return_value = await codiad.settings.update_option( key, value );
}, },
} }