Fixed install process errors after upgrade.

This commit is contained in:
xevidos 2018-12-14 13:08:07 -05:00
parent 8faec8dbe8
commit 4991c0c76c
1 changed files with 18 additions and 25 deletions

View File

@ -70,7 +70,7 @@ function cleanPath( $path ) {
// Verify no overwrites // Verify no overwrites
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
if ( ( file_exists( $user_settings_file ) || file_exists( $projects_file ) || file_exists( $users_file ) ) || ! ( defined( "DBHOST" ) && defined( "DBNAME" ) && defined( "DBUSER" ) && defined( "DBPASS" ) && defined( "DBTYPE" ) ) ) { if ( ! ( defined( "DBHOST" ) && defined( "DBNAME" ) && defined( "DBUSER" ) && defined( "DBPASS" ) && defined( "DBTYPE" ) ) ) {
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
// Get POST responses // Get POST responses
@ -88,12 +88,12 @@ if ( ( file_exists( $user_settings_file ) || file_exists( $projects_file ) || fi
} }
$timezone = $_POST['timezone']; $timezone = $_POST['timezone'];
$dbhost = $_POST['DBHOST']; $dbhost = $_POST['dbhost'];
$dbname = $_POST['DBNAME']; $dbname = $_POST['dbname'];
$dbuser = $_POST['DBUSER']; $dbuser = $_POST['dbuser'];
$dbpass = $_POST['DBPASS']; $dbpass = $_POST['dbpass'];
$connection = mysqli_connect( $dbhost, $dbuser, $dbpass, $dbname ) or die ( formatJSEND( "error", 'Error connecting to mysql database. Please contact the website administrator.' ) ); $connection = mysqli_connect( $dbhost, $dbuser, $dbpass, $dbname ) or die ( 'Error connecting to mysql database. Please contact the website administrator.' );
$bind_vars = array(); $bind_vars = array();
$bind = ""; $bind = "";
$sql = " $sql = "
@ -235,12 +235,9 @@ ALTER TABLE `user_options`
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
"; ";
$result = mysqli_multi_query( $connection, $sql ) or die( $error ); $result = mysqli_multi_query( $connection, $sql ) or die( "Error creating tables." );
if( $connection->error ) {
$return = formatJSEND( "error", $connection->error );
}
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
// Create Projects files // Create Projects files
@ -251,7 +248,10 @@ ALTER TABLE `user_options`
if ( ! isAbsPath( $project_path ) ) { if ( ! isAbsPath( $project_path ) ) {
$project_path = str_replace( " ", "_", preg_replace( '/[^\w-\.]/', '', $project_path ) ); $project_path = str_replace( " ", "_", preg_replace( '/[^\w-\.]/', '', $project_path ) );
mkdir( $workspace . "/" . $project_path ); if( ! is_dir( $workspace . "/" . $project_path ) ) {
mkdir( $workspace . "/" . $project_path );
}
} else { } else {
$project_path = cleanPath( $project_path ); $project_path = cleanPath( $project_path );
@ -274,22 +274,18 @@ ALTER TABLE `user_options`
} }
} }
$connection = mysqli_connect( $dbhost, $dbuser, $dbpass, $dbname ) or die ( 'Error connecting to mysql database. Please contact the website administrator.' );
$bind_vars = array( $bind_vars = array(
$project_name, $project_name,
$project_path, $project_path,
$username $username
); );
$bind = "sss"; $bind = "sss";
$sql = "INSERT INTO `projects`(`name`, `path`, `owner`) VALUES (?,?,?)"; $sql = "INSERT INTO `projects`(`name`, `path`, `owner`) VALUES (?,?,?);";
$result = mysqli_prepare( $connection, $sql ) or die( $error ); $result = mysqli_prepare( $connection, $sql ) or die( "Error inserting into projects." );
$result->bind_param( $bind, ...$bind_vars ); $result->bind_param( $bind, ...$bind_vars );
$result->execute(); $result->execute();
if( $connection->error ) {
$return = formatJSEND( "error", $connection->error );
}
$bind_vars = array( $bind_vars = array(
"", "",
"", "",
@ -303,14 +299,11 @@ ALTER TABLE `user_options`
); );
$bind = "sssssssss"; $bind = "sssssssss";
$sql = "INSERT INTO `users`(`first_name`, `last_name`, `username`, `password`, `email`, `project`, `access`, `groups`, `token`) VALUES (?,?,?,PASSWORD(?),?,?,?,?,?)"; $sql = "INSERT INTO `users`(`first_name`, `last_name`, `username`, `password`, `email`, `project`, `access`, `groups`, `token`) VALUES (?,?,?,PASSWORD(?),?,?,?,?,?)";
$result = mysqli_prepare( $connection, $sql ) or die( $error ); $result = mysqli_prepare( $connection, $sql ) or die( "Error inserting into users." );
$result->bind_param( $bind, ...$bind_vars ); $result->bind_param( $bind, ...$bind_vars );
$result->execute(); $result->execute();
if( $connection->error ) {
$return = formatJSEND( "error", $connection->error );
}
/** /**
* Create sessions path. * Create sessions path.
@ -395,4 +388,4 @@ define("WSURL", BASE_URL . "/workspace");
saveFile( $config, $config_data ); saveFile( $config, $config_data );
echo( "success" ); echo( "success" );
} }