From 4186a609ef1813bee4c49370daa453c00a5d64e2 Mon Sep 17 00:00:00 2001
From: Fluffy-Bean [INFO] Found images table [INFO] Could not find images table, creating test table... [INFO] Table images made! [INFO] Found users table [INFO] Could not find users table, creating test table... [INFO] Table users made! [INFO] Found groups table [INFO] Could not find groups table, creating test table... [INFO] Table groups made! [INFO] Found logs table [INFO] Could not find logs table, creating test table... [INFO] Table logs made! [INFO] Found bans table [INFO] Could not find bans table, creating test table... [INFO] Table bans made! [INFO] Found tokens table [INFO] Could not find tokens table, creating test table... [INFO] Table tokens made! [INFO] Found test table [ERRO] Could not find test table, creating test table...
[ERRO] usr/ folder not found
"; - echo "[INFO] Creating usr/ folder...
"; - - mkdir("usr"); + try { + if (mkdir(__DIR__."/../../../usr")) { + $results[] = array( + 'type'=>'success', + 'message'=> 'Created usr/ folder!', + ); + } else { + $results[] = array( + 'type'=>'critical', + 'message'=> 'Error creating usr/ folder', + 'fix'=>'manual', + ); + } + } catch (Exception $e) { + $results[] = array( + 'type'=>'critical', + 'message'=> 'Error creating usr/ folder: '.$e, + 'fix'=>'manual', + ); + } } if (is_dir(__DIR__."/../../../usr/images")) { - echo "[INFO] Found usr/images/ folder!
"; + $results[] = array( + 'type'=>'success', + 'message'=> 'Found usr/images/ folder!', + ); } else { - echo "[ERRO] usr/images/ folder not found
"; - echo "[INFO] Creating usr/images/ folder...
"; - - mkdir("usr/images"); - } - if (!is_dir(__DIR__."/../../../usr/images/thumbnails")) { - echo "[ERRO] usr/images/thumbnails/ folder not found
"; - echo "[INFO] Creating usr/images/thumbnails/ folder...
"; - - mkdir("usr/images/thumbnails"); - } - if (!is_dir(__DIR__."/../../../usr/images/previews")) { - echo "[ERRO] usr/images/previews/ folder not found
"; - echo "[INFO] Creating usr/images/previews/ folder...
"; - - mkdir("usr/images/previews"); + try { + if (mkdir(__DIR__."/../../../usr/images")) { + $results[] = array( + 'type'=>'success', + 'message'=> 'Created usr/images/ folder!', + ); + } else { + $results[] = array( + 'type'=>'critical', + 'message'=> 'Error creating usr/images/ folder', + 'fix'=>'manual', + ); + } + } catch (Exception $e) { + $results[] = array( + 'type'=>'critical', + 'message'=> 'Error creating usr/images/ folder: '.$e, + 'fix'=>'manual', + ); + } } - if (!is_dir(__DIR__."/../../../usr/conf")) { - echo "[ERRO] usr/conf/ folder not found
"; - echo "[INFO] Creating usr/conf/ folder...
"; + if (is_dir(__DIR__."/../../../usr/images/thumbnails")) { + $results[] = array( + 'type'=>'success', + 'message'=> 'Found usr/images/thumbnails/ folder!', + ); + } else { + try { + if (mkdir(__DIR__."/../../../usr/images/thumbnails")) { + $results[] = array( + 'type'=>'success', + 'message'=> 'Created usr/images/thumbnails/ folder!', + ); + } else { + $results[] = array( + 'type'=>'critical', + 'message'=> 'Error creating usr/images/thumbnails/ folder', + 'fix'=>'manual', + ); + } + } catch (Exception $e) { + $results[] = array( + 'type'=>'critical', + 'message'=> 'Error creating usr/images/thumbnails/ folder: '.$e, + 'fix'=>'manual', + ); + } + } + if (is_dir(__DIR__."/../../../usr/images/previews")) { + $results[] = array( + 'type'=>'success', + 'message'=> 'Found usr/images/previews/ folder!', + ); + } else { + try { + if (mkdir(__DIR__."/../../../usr/images/previews")) { + $results[] = array( + 'type'=>'success', + 'message'=> 'Created usr/images/previews/ folder!', + ); + } else { + $results[] = array( + 'type'=>'critical', + 'message'=> 'Error creating usr/images/previews/ folder', + 'fix'=>'manual', + ); + } + } catch (Exception $e) { + $results[] = array( + 'type'=>'critical', + 'message'=> 'Error creating usr/images/previews/ folder: '.$e, + 'fix'=>'manual', + ); + } + } - mkdir("usr/conf"); + if (is_dir(__DIR__."/../../../usr/conf")) { + $results[] = array( + 'type'=>'success', + 'message'=> 'Found usr/conf/ folder!', + ); + } else { + try { + if (mkdir(__DIR__."/../../../usr/conf")) { + $results[] = array( + 'type'=>'success', + 'message'=> 'Created usr/conf/ folder!', + ); + } else { + $results[] = array( + 'type'=>'critical', + 'message'=> 'Error creating usr/conf/ folder', + 'fix'=>'manual', + ); + } + } catch (Exception $e) { + $results[] = array( + 'type'=>'critical', + 'message'=> 'Error creating usr/conf/ folder: '.$e, + 'fix'=>'manual', + ); + } } if (is_file(__DIR__."/../../../usr/conf/conf.json")) { - echo "[INFO] Found usr/conf/conf.json file!
"; + $results[] = array( + 'type'=>'success', + 'message'=> 'Found usr/conf/conf.json folder!', + ); } else { - echo "[ERRO] usr/conf/conf.json file not found
"; - echo "[INFO] Creating usr/conf/conf.json file...
"; - try { $conf = file_get_contents(__DIR__."/../../../usr/conf.default.json"); - $conf_new = fopen(__DIR__."/../../../usr/conf/conf.json", "w"); if ($conf_new) { fwrite($conf_new, $conf); fclose($conf_new); - echo "[INFO] usr/conf/conf.json file created!
"; + $results[] = array( + 'type'=>'success', + 'message'=> 'Created usr/conf/conf.json file!', + ); } else { - echo "[ERRO] Failed to create usr/conf/conf.json file
"; + $results[] = array( + 'type'=>'critical', + 'message'=> 'Error creating usr/conf/conf.json file!', + 'fix'=>'manual', + ); } } catch (Exception $e) { - echo "[ERRO] Could not read usr/conf.default.json file
"; + $results[] = array( + 'type'=>'critical', + 'message'=> 'Error creating usr/conf/conf.json file: '.$e, + 'fix'=>'manual', + ); } } } \ No newline at end of file diff --git a/app/sanity/sanity.php b/app/sanity/sanity.php index acd1036..b9f01c4 100644 --- a/app/sanity/sanity.php +++ b/app/sanity/sanity.php @@ -4,37 +4,60 @@ session_start(); require_once "../conn.php"; if (isset($_POST['fix'])) { - $timer_start = microtime(true); - - echo "[INFO] Starting autofix
"; - if (empty($_SESSION['id'])) { echo "You are not logged in
"; exit(); } elseif ($_SESSION['id'] != 1) { - echo "Autofix is currently not avaliable to You.
"; + echo "Autofix is currently not avaliable to You. Sowwy!
"; exit(); } - define('ROOT', true); // Only run scripts from this file - - echo "==== Databases ====
"; - require_once "fix/_database.php"; + $timer_start = microtime(true); - echo "==== Folders ====
"; + $results = array(); // Array to store results + define('ROOT', true); // Only run scripts from this file + + require_once "fix/_database.php"; require_once "fix/_folders.php"; + foreach ($results as $result) { + if (isset($result['type'])) { + if ($result['type'] == 'critical') { + echo "Critical "; + } elseif ($result['type'] == 'warning') { + echo "
Warning "; + } elseif ($result['type'] == 'success') { + echo "
Success "; + } + } + + if (isset($result['fix'])) { + if ($result['fix'] == 'auto') { + echo "Auto fix available "; + $autofix_enable = true; + } elseif ($result['fix'] == 'manual') { + echo "Manual fix required "; + } + } + + if (isset($result['link'])) { + echo "Recources "; + } + + echo $result['message']."
"; + } + $timer_end = microtime(true); $timer_diff = ($timer_end - $timer_start); $timer_diff = round($timer_diff, 6) * 1000; - echo "[INFO] Autofix complete in $timer_diff ms
"; + echo "Autofix complete in $timer_diff ms
"; } elseif (isset($_POST['check'])) { if (empty($_SESSION['id'])) { echo "You are not logged in
"; exit(); } elseif ($_SESSION['id'] != 1) { - echo "Autofix is currently not avaliable to You.
"; + echo "Scan is currently not avaliable to You. Sowwy!
"; exit(); } @@ -54,19 +77,23 @@ if (isset($_POST['fix'])) { echo "No errors! Lookin' good :3
"; } else { foreach ($results as $result) { - if ($result['type'] == 'critical') { - echo "Critical "; - } elseif ($result['type'] == 'warning') { - echo "
Warning "; - } elseif ($result['type'] == 'success') { - echo "
Success "; + if (isset($result['type'])) { + if ($result['type'] == 'critical') { + echo "
Critical "; + } elseif ($result['type'] == 'warning') { + echo "
Warning "; + } elseif ($result['type'] == 'success') { + echo "
Success "; + } } - if ($result['fix'] == 'auto') { - echo "Auto fix available "; - $autofix_enable = true; - } elseif ($result['fix'] == 'manual') { - echo "Manual fix required "; + if (isset($result['fix'])) { + if ($result['fix'] == 'auto') { + echo "Auto fix available "; + $autofix_enable = true; + } elseif ($result['fix'] == 'manual') { + echo "Manual fix required "; + } } if (isset($result['link'])) {