Merge pull request #2 from int2001/installer_new

Added Logic for First-User
This commit is contained in:
HB9HIL
2024-01-28 20:14:37 +01:00
committed by GitHub
2 changed files with 13 additions and 2 deletions

View File

@@ -437,7 +437,7 @@ CREATE TABLE `users` (
-- ----------------------------
-- Records of users
-- ----------------------------
INSERT INTO `users` VALUES ('4', '4w7est', '$2y$10$WFGFdNK.I4X0z1qXxjqrEeMvy65M2OyxJiNcNCY0gQ4KzeCCKms02', 'demo@demo.com', '99', '4W7EST', 'HH44aa', 'Demo', 'Account', '0', null, null, null, null, null);
INSERT INTO `users` VALUES ('4', '%%FIRSTUSER_NAME%%', '%%FIRSTUSER_PASS%%', '%%FIRSTUSER_MAIL%%', '99', '%%FIRSTUSER_CALL%%', '%%FIRSTUSER_LOCATOR%%', '%%FIRSTUSER_FIRSTNAME%%', '%%FIRSTUSER_LASTNAME%%', '%%FIRSTUSER_TIMEZONE%%', null, null, null, null, null);

View File

@@ -34,10 +34,21 @@ class Database {
// Open the default SQL file
$query = file_get_contents('assets/install.sql');
$newpw=password_hash($data['password'], PASSWORD_DEFAULT);
$newquery = str_replace("%%FIRSTUSER_NAME%%",$data['username'],$query);
$newquery = str_replace("%%FIRSTUSER_PASS%%",$newpw,$newquery);
$newquery = str_replace("%%FIRSTUSER_MAIL%%",$data['user_email'],$newquery);
$newquery = str_replace("%%FIRSTUSER_CALL%%",$data['callsign'],$newquery);
$newquery = str_replace("%%FIRSTUSER_LOCATOR%%",$data['userlocator'],$newquery);
$newquery = str_replace("%%FIRSTUSER_FIRSTNAME%%",$data['firstname'],$newquery);
$newquery = str_replace("%%FIRSTUSER_LASTNAME%%",$data['lastname'],$newquery);
$newquery = str_replace("%%FIRSTUSER_TIMEZONE%%",$data['timezone'],$newquery);
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
// Execute a multi query
$mysqli->multi_query($query);
$mysqli->multi_query($newquery);
// MultiQuery is NON-Blocking,so wait until everything is done
do { null; } while($mysqli->next_result());