diff --git a/components/install/process.php b/components/install/process.php index d931770..bbb3e5b 100755 --- a/components/install/process.php +++ b/components/install/process.php @@ -1,5 +1,4 @@ getMessage() ) ) .'"}' ); } $bind_vars = array(); $bind = ""; $database_sql_fullpath = $path . '/components/install/sql/' . $dbtype . '.sql'; 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 ); - try { @@ -131,13 +128,13 @@ if ( ! ( defined( 'DBHOST' ) && defined( 'DBNAME' ) && defined( 'DBUSER' ) && de $result = $connection->exec( $sql ); } catch( PDOException $e ) { - die($e->getMessage()); + die( '{"message":"Could not create initial tables in database.","error":"' . addslashes( json_encode( $e->getMessage() ) ) .'"}' ); } $error = $connection->errorInfo(); 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 ) ) { - die( "Unable to create Absolute Path" ); + die( '{"message": "Unable to create Absolute Path"}' ); } } else { 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" ) { - die( $error[2] ); + die( '{"message":"Could not create project in database.","error":"' . addslashes(json_encode( $error )) .'"}' ); } $bind_variables = array( @@ -208,7 +205,7 @@ if ( ! ( defined( 'DBHOST' ) && defined( 'DBNAME' ) && defined( 'DBUSER' ) && de if( ! $error[0] == "00000" ) { - die( $error[2] ); + die( '{"message":"Could not create user in database.","error":"' . addslashes(json_encode( $error )) .'"}' ); } diff --git a/components/install/view.php b/components/install/view.php index 5c1127d..6df38fd 100755 --- a/components/install/view.php +++ b/components/install/view.php @@ -344,11 +344,14 @@ if ($newrelic) { if(!password_match){ alert('The passwords entered do not match'); } if(!empty_fields && password_match && check_path){ - $.post('components/install/process.php',$('#install').serialize(),function(data){ - if(data=='success'){ + $.post('components/install/process.php',$('#install').serialize(),function( data ) { + + if( data == 'success' ){ window.location.reload(); - }else{ - alert("An Error Occoured\n"+data); + } else { + data = JSON.parse( data ); + console.log( data.error ); + alert( "An Error Occurred\n" + data.message ); } }); } diff --git a/js/localstorage.js b/js/localstorage.js index 3eeaebb..56fb8d3 100755 --- a/js/localstorage.js +++ b/js/localstorage.js @@ -44,7 +44,7 @@ Dual licensed under the MIT or GPL licenses. setItem: async function( key, value ) { - let value = await codiad.settings.update_option( key, value ); + let return_value = await codiad.settings.update_option( key, value ); }, }