Merge branch 'development' into 'master'

Fixed install errors

See merge request xevidos/codiad!20
This commit is contained in:
Isaac Brown 2018-12-14 13:08:31 -05:00
commit 1370580918
3 changed files with 36 additions and 45 deletions

View File

@ -11,8 +11,8 @@ Features:
* 100+ Native programming languages supported. * 100+ Native programming languages supported.
* Auto Complete ( Trigger by CTRL + Space or Turn on Live Autocomplete ). * Auto Complete ( Trigger by CTRL + Space or Turn on Live Autocomplete ).
* Auto Save. * Auto Save.
* Built in updter. * Built in updater.
* Collaborative Editing ( [via plugin](https://gitlab.com/xevidos/codiad-collaborative) ). * Collaborative Editing ( [Via plugin](https://gitlab.com/xevidos/codiad-collaborative) ).
* Multi Cursor. * Multi Cursor.
* Overscroll ( Ability to center bottom of code ). * Overscroll ( Ability to center bottom of code ).
* PHP 7.2 Compatibility. * PHP 7.2 Compatibility.
@ -37,7 +37,6 @@ Task List:
* Add if file could not be saved 5 times close the open file. * Add if file could not be saved 5 times close the open file.
* Add multi level users. ( Projects for only certain groups, Permission levels ) * Add multi level users. ( Projects for only certain groups, Permission levels )
* Add mobile compatibility. * Add mobile compatibility.
* Clean up Collaborative compatibility.
* Clean up update script. * Clean up update script.

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,15 +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_prepare( $connection, $sql ) or die( $error ); $result = mysqli_multi_query( $connection, $sql ) or die( "Error creating tables." );
$result->bind_param( $bind, ...$bind_variables );
$result->execute();
if( $connection->error ) {
$return = formatJSEND( "error", $connection->error );
}
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
// Create Projects files // Create Projects files
@ -254,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 );
@ -277,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_variables ); $result->bind_param( $bind, ...$bind_vars );
$result->execute(); $result->execute();
if( $connection->error ) {
$return = formatJSEND( "error", $connection->error );
}
$bind_vars = array( $bind_vars = array(
"", "",
"", "",
@ -306,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_variables ); $result->bind_param( $bind, ...$bind_vars );
$result->execute(); $result->execute();
if( $connection->error ) {
$return = formatJSEND( "error", $connection->error );
}
/** /**
* Create sessions path. * Create sessions path.
@ -369,7 +359,7 @@ date_default_timezone_set("' . $_POST['timezone'] . '");
//define("AUTH_PATH", "/path/to/customauth.php"); //define("AUTH_PATH", "/path/to/customauth.php");
// Site Name // Site Name
define("SITE_NAME", "' . $_POST['sitename'] . '"); define("SITE_NAME", "' . $_POST['site_name'] . '");
// Database Information // Database Information
define( "DBHOST", "' . $_POST['dbhost'] . '" ); define( "DBHOST", "' . $_POST['dbhost'] . '" );

View File

@ -1,8 +1,8 @@
<?php <?php
ini_set('display_errors', 1); //ini_set('display_errors', 1);
ini_set('display_startup_errors', 1); //ini_set('display_startup_errors', 1);
error_reporting(E_ALL); //error_reporting(E_ALL);
require_once('../../common.php'); require_once('../../common.php');
require_once('./class.update.php'); require_once('./class.update.php');
@ -118,14 +118,6 @@ class updater {
"name" => "codiad.settings.autosave", "name" => "codiad.settings.autosave",
"value" => "true", "value" => "true",
), ),
array(
"name" => "codiad.settings.plugin.sync",
"value" => "true",
),
array(
"name" => "codiad.settings.plugin.sync",
"value" => "true",
),
); );
/** /**
@ -182,11 +174,21 @@ class updater {
mkdir($dest); mkdir($dest);
} }
$invalid_files = array(
'.',
'..',
'backup',
'codiad-master',
'update.zip',
'workspace',
);
// Loop through the folder // Loop through the folder
$dir = dir( $source ); $dir = dir( $source );
while (false !== $entry = $dir->read()) { while (false !== $entry = $dir->read()) {
// Skip pointers // Skip pointers
if ($entry == '.' || $entry == '..' || $entry == 'backup' || $entry == 'codiad-master' || $entry == 'workspace') { if( in_array( $entry, $invalid_files ) ) {
continue; continue;
} }