installer: Better logging
installer: Better logging
This commit is contained in:
commit
fbd0191c45
2 changed files with 23 additions and 7 deletions
|
@ -29,6 +29,7 @@ if (isset($_POST['checkDB'])) {
|
||||||
|
|
||||||
$db = new mysqli($_POST["databasehost"], $_POST["databaseuser"], $_POST["databaseuserpass"], $_POST["database"], $_POST["databaseport"]);
|
$db = new mysqli($_POST["databasehost"], $_POST["databaseuser"], $_POST["databaseuserpass"], $_POST["database"], $_POST["databaseport"]);
|
||||||
if ($db->connect_error) {
|
if ($db->connect_error) {
|
||||||
|
wh_log($db->connect_error);
|
||||||
header("LOCATION: index.php?step=2&message=Could not connect to the Database");
|
header("LOCATION: index.php?step=2&message=Could not connect to the Database");
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
@ -78,14 +79,12 @@ if (isset($_POST['feedDB'])) {
|
||||||
}
|
}
|
||||||
$logs .= run_console('php artisan storage:link');
|
$logs .= run_console('php artisan storage:link');
|
||||||
|
|
||||||
$logsfile = fopen("logs.txt", "w") or die("Unable to open file!");
|
wh_log($logs);
|
||||||
fwrite($logsfile, $logs);
|
|
||||||
fclose($logsfile);
|
|
||||||
|
|
||||||
if (strpos(getEnvironmentValue("APP_KEY"), 'base64') !== false) {
|
if (strpos(getEnvironmentValue("APP_KEY"), 'base64') !== false) {
|
||||||
header("LOCATION: index.php?step=3");
|
header("LOCATION: index.php?step=3");
|
||||||
} else {
|
} else {
|
||||||
header("LOCATION: index.php?step=2.5&message=There was an error. Please check install/logs.txt !");
|
header("LOCATION: index.php?step=2.5&message=There was an error. Please check the .txt file in install/log !");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -123,7 +122,8 @@ if (isset($_POST['checkSMTP'])) {
|
||||||
|
|
||||||
$db = new mysqli(getEnvironmentValue("DB_HOST"), getEnvironmentValue("DB_USERNAME"), getEnvironmentValue("DB_PASSWORD"), getEnvironmentValue("DB_DATABASE"), getEnvironmentValue("DB_PORT"));
|
$db = new mysqli(getEnvironmentValue("DB_HOST"), getEnvironmentValue("DB_USERNAME"), getEnvironmentValue("DB_PASSWORD"), getEnvironmentValue("DB_DATABASE"), getEnvironmentValue("DB_PORT"));
|
||||||
if ($db->connect_error) {
|
if ($db->connect_error) {
|
||||||
header("LOCATION: index.php?step=4&message=Could not connect to the Database");
|
wh_log($db->connect_error);
|
||||||
|
header("LOCATION: index.php?step=4&message=Could not connect to the Database: ");
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
$values = [
|
$values = [
|
||||||
|
@ -181,6 +181,7 @@ if (isset($_POST['checkPtero'])) {
|
||||||
|
|
||||||
$db = new mysqli(getEnvironmentValue("DB_HOST"), getEnvironmentValue("DB_USERNAME"), getEnvironmentValue("DB_PASSWORD"), getEnvironmentValue("DB_DATABASE"), getEnvironmentValue("DB_PORT"));
|
$db = new mysqli(getEnvironmentValue("DB_HOST"), getEnvironmentValue("DB_USERNAME"), getEnvironmentValue("DB_PASSWORD"), getEnvironmentValue("DB_DATABASE"), getEnvironmentValue("DB_PORT"));
|
||||||
if ($db->connect_error) {
|
if ($db->connect_error) {
|
||||||
|
wh_log($db->connect_error);
|
||||||
header("LOCATION: index.php?step=5&message=Could not connect to the Database");
|
header("LOCATION: index.php?step=5&message=Could not connect to the Database");
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
@ -188,6 +189,7 @@ if (isset($_POST['checkPtero'])) {
|
||||||
if ($db->query($query1) && $db->query($query2)) {
|
if ($db->query($query1) && $db->query($query2)) {
|
||||||
header("LOCATION: index.php?step=6");
|
header("LOCATION: index.php?step=6");
|
||||||
} else {
|
} else {
|
||||||
|
wh_log($db->error);
|
||||||
header("LOCATION: index.php?step=5&message=Something went wrong when communicating with the Database!");
|
header("LOCATION: index.php?step=5&message=Something went wrong when communicating with the Database!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,6 +200,7 @@ if (isset($_POST['checkPtero'])) {
|
||||||
if (isset($_POST['createUser'])) {
|
if (isset($_POST['createUser'])) {
|
||||||
$db = new mysqli(getEnvironmentValue("DB_HOST"), getEnvironmentValue("DB_USERNAME"), getEnvironmentValue("DB_PASSWORD"), getEnvironmentValue("DB_DATABASE"), getEnvironmentValue("DB_PORT"));
|
$db = new mysqli(getEnvironmentValue("DB_HOST"), getEnvironmentValue("DB_USERNAME"), getEnvironmentValue("DB_PASSWORD"), getEnvironmentValue("DB_DATABASE"), getEnvironmentValue("DB_PORT"));
|
||||||
if ($db->connect_error) {
|
if ($db->connect_error) {
|
||||||
|
wh_log($db->connect_error);
|
||||||
header("LOCATION: index.php?step=6&message=Could not connect to the Database");
|
header("LOCATION: index.php?step=6&message=Could not connect to the Database");
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
@ -273,8 +276,8 @@ if (isset($_POST['createUser'])) {
|
||||||
if ($db->query($query1)) {
|
if ($db->query($query1)) {
|
||||||
header("LOCATION: index.php?step=7");
|
header("LOCATION: index.php?step=7");
|
||||||
} else {
|
} else {
|
||||||
|
wh_log($db->error);
|
||||||
header("LOCATION: index.php?step=6&message=Something went wrong when communicating with the Database!");
|
header("LOCATION: index.php?step=6&message=Something went wrong when communicating with the Database");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,4 +130,17 @@ function run_console($command)
|
||||||
return shell_exec($cmd);
|
return shell_exec($cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function wh_log($log_msg)
|
||||||
|
{
|
||||||
|
$log_filename = "log";
|
||||||
|
if (!file_exists($log_filename))
|
||||||
|
{
|
||||||
|
// create directory/folder uploads.
|
||||||
|
mkdir($log_filename, 0777, true);
|
||||||
|
}
|
||||||
|
$log_file_data = $log_filename.'/log_' . date('d-M-Y') . '.log';
|
||||||
|
// if you don't add `FILE_APPEND`, the file will be erased each time you add a log
|
||||||
|
file_put_contents($log_file_data, "[".date('h:i:s')."] " . $log_msg . "\n", FILE_APPEND);
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Add table
Reference in a new issue