mirror of
https://github.com/Fluffy-Bean/image-gallery.git
synced 2025-06-06 10:23:12 +00:00
Update AutoFix style
This commit is contained in:
parent
9a7c042b52
commit
4186a609ef
3 changed files with 348 additions and 89 deletions
|
@ -15,10 +15,11 @@ if (defined('ROOT') && $_SESSION['id'] == 1) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check_database($conn, 'images')) {
|
if (check_database($conn, 'images')) {
|
||||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Found images table</p>";
|
$results[] = array(
|
||||||
|
'type'=>'success',
|
||||||
|
'message'=> 'Found images table',
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
echo "<p><span style='color: var(--warning);'>[INFO]</span> Could not find images table, creating test table...</p>";
|
|
||||||
|
|
||||||
$sql = "CREATE TABLE IF NOT EXISTS images (
|
$sql = "CREATE TABLE IF NOT EXISTS images (
|
||||||
id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
||||||
imagename VARCHAR(255) NOT NULL UNIQUE,
|
imagename VARCHAR(255) NOT NULL UNIQUE,
|
||||||
|
@ -28,16 +29,35 @@ if (defined('ROOT') && $_SESSION['id'] == 1) {
|
||||||
last_modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
last_modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
upload_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
upload_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
)";
|
)";
|
||||||
if ($conn->query($sql) === TRUE) {
|
|
||||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Table images made!</p>";
|
try {
|
||||||
|
if ($conn->query($sql) === TRUE) {
|
||||||
|
$results[] = array(
|
||||||
|
'type'=>'success',
|
||||||
|
'message'=> 'Table images created!',
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$results[] = array(
|
||||||
|
'type'=>'critical',
|
||||||
|
'message'=> 'Error creating table images: '.$conn->error,
|
||||||
|
'fix'=>'manual',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$results[] = array(
|
||||||
|
'type'=>'critical',
|
||||||
|
'message'=> 'Error creating table images: '.$e,
|
||||||
|
'fix'=>'manual',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check_database($conn, 'users')) {
|
if (check_database($conn, 'users')) {
|
||||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Found users table</p>";
|
$results[] = array(
|
||||||
|
'type'=>'success',
|
||||||
|
'message'=> 'Found users table',
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
echo "<p><span style='color: var(--warning);'>[INFO]</span> Could not find users table, creating test table...</p>";
|
|
||||||
|
|
||||||
$sql = "CREATE TABLE IF NOT EXISTS users (
|
$sql = "CREATE TABLE IF NOT EXISTS users (
|
||||||
id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
||||||
username VARCHAR(255) NOT NULL UNIQUE,
|
username VARCHAR(255) NOT NULL UNIQUE,
|
||||||
|
@ -47,16 +67,35 @@ if (defined('ROOT') && $_SESSION['id'] == 1) {
|
||||||
last_modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
last_modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
)";
|
)";
|
||||||
if ($conn->query($sql) === TRUE) {
|
|
||||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Table users made!</p>";
|
try {
|
||||||
|
if ($conn->query($sql) === TRUE) {
|
||||||
|
$results[] = array(
|
||||||
|
'type'=>'success',
|
||||||
|
'message'=> 'Table users created!',
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$results[] = array(
|
||||||
|
'type'=>'critical',
|
||||||
|
'message'=> 'Error creating table users: '.$conn->error,
|
||||||
|
'fix'=>'manual',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$results[] = array(
|
||||||
|
'type'=>'critical',
|
||||||
|
'message'=> 'Error creating table users: '.$e,
|
||||||
|
'fix'=>'manual',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check_database($conn, 'groups')) {
|
if (check_database($conn, 'groups')) {
|
||||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Found groups table</p>";
|
$results[] = array(
|
||||||
|
'type'=>'success',
|
||||||
|
'message'=> 'Found groups table',
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
echo "<p><span style='color: var(--warning);'>[INFO]</span> Could not find groups table, creating test table...</p>";
|
|
||||||
|
|
||||||
$sql = "CREATE TABLE IF NOT EXISTS groups (
|
$sql = "CREATE TABLE IF NOT EXISTS groups (
|
||||||
id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
||||||
group_name VARCHAR(255) NOT NULL,
|
group_name VARCHAR(255) NOT NULL,
|
||||||
|
@ -64,32 +103,70 @@ if (defined('ROOT') && $_SESSION['id'] == 1) {
|
||||||
last_modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
last_modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
)";
|
)";
|
||||||
if ($conn->query($sql) === TRUE) {
|
|
||||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Table groups made!</p>";
|
try {
|
||||||
|
if ($conn->query($sql) === TRUE) {
|
||||||
|
$results[] = array(
|
||||||
|
'type'=>'success',
|
||||||
|
'message'=> 'Table groups created!',
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$results[] = array(
|
||||||
|
'type'=>'critical',
|
||||||
|
'message'=> 'Error creating table groups: '.$conn->error,
|
||||||
|
'fix'=>'manual',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$results[] = array(
|
||||||
|
'type'=>'critical',
|
||||||
|
'message'=> 'Error creating table groups: '.$e,
|
||||||
|
'fix'=>'manual',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check_database($conn, 'logs')) {
|
if (check_database($conn, 'logs')) {
|
||||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Found logs table</p>";
|
$results[] = array(
|
||||||
|
'type'=>'success',
|
||||||
|
'message'=> 'Found logs table',
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
echo "<p><span style='color: var(--warning);'>[INFO]</span> Could not find logs table, creating test table...</p>";
|
|
||||||
|
|
||||||
$sql = "CREATE TABLE IF NOT EXISTS logs (
|
$sql = "CREATE TABLE IF NOT EXISTS logs (
|
||||||
id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
||||||
ipaddress VARCHAR(16) NOT NULL,
|
ipaddress VARCHAR(16) NOT NULL,
|
||||||
action VARCHAR(255) NOT NULL,
|
action VARCHAR(255) NOT NULL,
|
||||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
)";
|
)";
|
||||||
if ($conn->query($sql) === TRUE) {
|
|
||||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Table logs made!</p>";
|
try {
|
||||||
|
if ($conn->query($sql) === TRUE) {
|
||||||
|
$results[] = array(
|
||||||
|
'type'=>'success',
|
||||||
|
'message'=> 'Table logs created!',
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$results[] = array(
|
||||||
|
'type'=>'critical',
|
||||||
|
'message'=> 'Error creating table logs: '.$conn->error,
|
||||||
|
'fix'=>'manual',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$results[] = array(
|
||||||
|
'type'=>'critical',
|
||||||
|
'message'=> 'Error creating table logs: '.$e,
|
||||||
|
'fix'=>'manual',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check_database($conn, 'bans')) {
|
if (check_database($conn, 'bans')) {
|
||||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Found bans table</p>";
|
$results[] = array(
|
||||||
|
'type'=>'success',
|
||||||
|
'message'=> 'Found bans table',
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
echo "<p><span style='color: var(--warning);'>[INFO]</span> Could not find bans table, creating test table...</p>";
|
|
||||||
|
|
||||||
$sql = "CREATE TABLE IF NOT EXISTS bans (
|
$sql = "CREATE TABLE IF NOT EXISTS bans (
|
||||||
id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
||||||
ipaddress VARCHAR(16) NOT NULL,
|
ipaddress VARCHAR(16) NOT NULL,
|
||||||
|
@ -98,30 +175,73 @@ if (defined('ROOT') && $_SESSION['id'] == 1) {
|
||||||
length VARCHAR(255) NOT NULL,
|
length VARCHAR(255) NOT NULL,
|
||||||
permanent BOOLEAN NOT NULL DEFAULT FALSE
|
permanent BOOLEAN NOT NULL DEFAULT FALSE
|
||||||
)";
|
)";
|
||||||
if ($conn->query($sql) === TRUE) {
|
|
||||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Table bans made!</p>";
|
try {
|
||||||
|
if ($conn->query($sql) === TRUE) {
|
||||||
|
$results[] = array(
|
||||||
|
'type'=>'success',
|
||||||
|
'message'=> 'Table bans created!',
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$results[] = array(
|
||||||
|
'type'=>'critical',
|
||||||
|
'message'=> 'Error creating table bans: '.$conn->error,
|
||||||
|
'fix'=>'manual',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$results[] = array(
|
||||||
|
'type'=>'critical',
|
||||||
|
'message'=> 'Error creating table bans: '.$e,
|
||||||
|
'fix'=>'manual',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check_database($conn, 'tokens')) {
|
if (check_database($conn, 'tokens')) {
|
||||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Found tokens table</p>";
|
$results[] = array(
|
||||||
|
'type'=>'success',
|
||||||
|
'message'=> 'Found tokens table',
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
echo "<p><span style='color: var(--warning);'>[INFO]</span> Could not find tokens table, creating test table...</p>";
|
|
||||||
|
|
||||||
$sql = "CREATE TABLE IF NOT EXISTS tokens (
|
$sql = "CREATE TABLE IF NOT EXISTS tokens (
|
||||||
id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
||||||
code VARCHAR(59) NOT NULL,
|
code VARCHAR(59) NOT NULL,
|
||||||
used BOOLEAN NOT NULL DEFAULT FALSE,
|
used BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||||
)";
|
)";
|
||||||
if ($conn->query($sql) === TRUE) {
|
|
||||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Table tokens made!</p>";
|
try {
|
||||||
|
if ($conn->query($sql) === TRUE) {
|
||||||
|
$results[] = array(
|
||||||
|
'type'=>'success',
|
||||||
|
'message'=> 'Table tokens created!',
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$results[] = array(
|
||||||
|
'type'=>'critical',
|
||||||
|
'message'=> 'Error creating table tokens: '.$conn->error,
|
||||||
|
'fix'=>'manual',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$results[] = array(
|
||||||
|
'type'=>'critical',
|
||||||
|
'message'=> 'Error creating table tokens: '.$e,
|
||||||
|
'fix'=>'manual',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check_database($conn, 'test')) {
|
if (check_database($conn, 'test')) {
|
||||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Found test table</p>";
|
$results[] = array(
|
||||||
|
'type'=>'success',
|
||||||
|
'message'=> 'Found test table',
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
echo "<p><span style='color: var(--warning);'>[ERRO]</span> Could not find test table, creating test table...</p>";
|
$results[] = array(
|
||||||
|
'type'=>'critical',
|
||||||
|
'message'=> 'Error creating table tokens: This is a test, you do not need to act on this',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,63 +1,175 @@
|
||||||
<?php
|
<?php
|
||||||
if (defined('ROOT') && $_SESSION['id'] == 1) {
|
if (defined('ROOT') && $_SESSION['id'] == 1) {
|
||||||
if (is_dir(__DIR__."/../../../usr")) {
|
if (is_dir(__DIR__."/../../../usr")) {
|
||||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Found usr/ folder!</p>";
|
$results[] = array(
|
||||||
|
'type'=>'success',
|
||||||
|
'message'=> 'Found usr/ folder!',
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
echo "<p><span style='color: var(--warning);'>[ERRO]</span> usr/ folder not found</p>";
|
try {
|
||||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Creating usr/ folder...</p>";
|
if (mkdir(__DIR__."/../../../usr")) {
|
||||||
|
$results[] = array(
|
||||||
mkdir("usr");
|
'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")) {
|
if (is_dir(__DIR__."/../../../usr/images")) {
|
||||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Found usr/images/ folder!</p>";
|
$results[] = array(
|
||||||
|
'type'=>'success',
|
||||||
|
'message'=> 'Found usr/images/ folder!',
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
echo "<p><span style='color: var(--warning);'>[ERRO]</span> usr/images/ folder not found</p>";
|
try {
|
||||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Creating usr/images/ folder...</p>";
|
if (mkdir(__DIR__."/../../../usr/images")) {
|
||||||
|
$results[] = array(
|
||||||
mkdir("usr/images");
|
'type'=>'success',
|
||||||
}
|
'message'=> 'Created usr/images/ folder!',
|
||||||
if (!is_dir(__DIR__."/../../../usr/images/thumbnails")) {
|
);
|
||||||
echo "<p><span style='color: var(--warning);'>[ERRO]</span> usr/images/thumbnails/ folder not found</p>";
|
} else {
|
||||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Creating usr/images/thumbnails/ folder...</p>";
|
$results[] = array(
|
||||||
|
'type'=>'critical',
|
||||||
mkdir("usr/images/thumbnails");
|
'message'=> 'Error creating usr/images/ folder',
|
||||||
}
|
'fix'=>'manual',
|
||||||
if (!is_dir(__DIR__."/../../../usr/images/previews")) {
|
);
|
||||||
echo "<p><span style='color: var(--warning);'>[ERRO]</span> usr/images/previews/ folder not found</p>";
|
}
|
||||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Creating usr/images/previews/ folder...</p>";
|
} catch (Exception $e) {
|
||||||
|
$results[] = array(
|
||||||
mkdir("usr/images/previews");
|
'type'=>'critical',
|
||||||
|
'message'=> 'Error creating usr/images/ folder: '.$e,
|
||||||
|
'fix'=>'manual',
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_dir(__DIR__."/../../../usr/conf")) {
|
if (is_dir(__DIR__."/../../../usr/images/thumbnails")) {
|
||||||
echo "<p><span style='color: var(--warning);'>[ERRO]</span> usr/conf/ folder not found</p>";
|
$results[] = array(
|
||||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Creating usr/conf/ folder...</p>";
|
'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")) {
|
if (is_file(__DIR__."/../../../usr/conf/conf.json")) {
|
||||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Found usr/conf/conf.json file!</p>";
|
$results[] = array(
|
||||||
|
'type'=>'success',
|
||||||
|
'message'=> 'Found usr/conf/conf.json folder!',
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
echo "<p><span style='color: var(--warning);'>[ERRO]</span> usr/conf/conf.json file not found</p>";
|
|
||||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Creating usr/conf/conf.json file...</p>";
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$conf = file_get_contents(__DIR__."/../../../usr/conf.default.json");
|
$conf = file_get_contents(__DIR__."/../../../usr/conf.default.json");
|
||||||
|
|
||||||
$conf_new = fopen(__DIR__."/../../../usr/conf/conf.json", "w");
|
$conf_new = fopen(__DIR__."/../../../usr/conf/conf.json", "w");
|
||||||
|
|
||||||
if ($conf_new) {
|
if ($conf_new) {
|
||||||
fwrite($conf_new, $conf);
|
fwrite($conf_new, $conf);
|
||||||
fclose($conf_new);
|
fclose($conf_new);
|
||||||
|
|
||||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> usr/conf/conf.json file created!</p>";
|
$results[] = array(
|
||||||
|
'type'=>'success',
|
||||||
|
'message'=> 'Created usr/conf/conf.json file!',
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
echo "<p><span style='color: var(--warning);'>[ERRO]</span> Failed to create usr/conf/conf.json file</p>";
|
$results[] = array(
|
||||||
|
'type'=>'critical',
|
||||||
|
'message'=> 'Error creating usr/conf/conf.json file!',
|
||||||
|
'fix'=>'manual',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
echo "<p><span style='color: var(--warning);'>[ERRO]</span> Could not read usr/conf.default.json file</p>";
|
$results[] = array(
|
||||||
|
'type'=>'critical',
|
||||||
|
'message'=> 'Error creating usr/conf/conf.json file: '.$e,
|
||||||
|
'fix'=>'manual',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,37 +4,60 @@ session_start();
|
||||||
require_once "../conn.php";
|
require_once "../conn.php";
|
||||||
|
|
||||||
if (isset($_POST['fix'])) {
|
if (isset($_POST['fix'])) {
|
||||||
$timer_start = microtime(true);
|
|
||||||
|
|
||||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Starting autofix</p>";
|
|
||||||
|
|
||||||
if (empty($_SESSION['id'])) {
|
if (empty($_SESSION['id'])) {
|
||||||
echo "<p class='alert alert-bad'>You are not logged in</p>";
|
echo "<p class='alert alert-bad'>You are not logged in</p>";
|
||||||
exit();
|
exit();
|
||||||
} elseif ($_SESSION['id'] != 1) {
|
} elseif ($_SESSION['id'] != 1) {
|
||||||
echo "<p class='alert alert-warning'>Autofix is currently not avaliable to You.</p>";
|
echo "<p class='alert alert-warning'>Autofix is currently not avaliable to You. Sowwy!</p>";
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
define('ROOT', true); // Only run scripts from this file
|
$timer_start = microtime(true);
|
||||||
|
|
||||||
echo "<p>==== Databases ====</p>";
|
|
||||||
require_once "fix/_database.php";
|
|
||||||
|
|
||||||
echo "<p>==== Folders ====</p>";
|
$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";
|
require_once "fix/_folders.php";
|
||||||
|
|
||||||
|
foreach ($results as $result) {
|
||||||
|
if (isset($result['type'])) {
|
||||||
|
if ($result['type'] == 'critical') {
|
||||||
|
echo "<p class='alert alert-bad'><span class='badge badge-critical'>Critical</span> ";
|
||||||
|
} elseif ($result['type'] == 'warning') {
|
||||||
|
echo "<p class='alert alert-warning'><span class='badge badge-warning'>Warning</span> ";
|
||||||
|
} elseif ($result['type'] == 'success') {
|
||||||
|
echo "<p class='alert alert-good'><span class='badge badge-primary'>Success</span> ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($result['fix'])) {
|
||||||
|
if ($result['fix'] == 'auto') {
|
||||||
|
echo "<span class='badge badge-primary'>Auto fix available</span> ";
|
||||||
|
$autofix_enable = true;
|
||||||
|
} elseif ($result['fix'] == 'manual') {
|
||||||
|
echo "<span class='badge badge-critical'>Manual fix required</span> ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($result['link'])) {
|
||||||
|
echo "<a class='link badge badge-primary' href='".$result['link']."'>Recources</a> ";
|
||||||
|
}
|
||||||
|
|
||||||
|
echo $result['message']."</p>";
|
||||||
|
}
|
||||||
|
|
||||||
$timer_end = microtime(true);
|
$timer_end = microtime(true);
|
||||||
$timer_diff = ($timer_end - $timer_start);
|
$timer_diff = ($timer_end - $timer_start);
|
||||||
$timer_diff = round($timer_diff, 6) * 1000;
|
$timer_diff = round($timer_diff, 6) * 1000;
|
||||||
|
|
||||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Autofix complete in $timer_diff ms</p>";
|
echo "<p class='alert alert-good'> Autofix complete in $timer_diff ms</p>";
|
||||||
} elseif (isset($_POST['check'])) {
|
} elseif (isset($_POST['check'])) {
|
||||||
if (empty($_SESSION['id'])) {
|
if (empty($_SESSION['id'])) {
|
||||||
echo "<p class='alert alert-bad'>You are not logged in</p>";
|
echo "<p class='alert alert-bad'>You are not logged in</p>";
|
||||||
exit();
|
exit();
|
||||||
} elseif ($_SESSION['id'] != 1) {
|
} elseif ($_SESSION['id'] != 1) {
|
||||||
echo "<p class='alert alert-warning'>Autofix is currently not avaliable to You.</p>";
|
echo "<p class='alert alert-warning'>Scan is currently not avaliable to You. Sowwy!</p>";
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,19 +77,23 @@ if (isset($_POST['fix'])) {
|
||||||
echo "<p class='alert alert-good'>No errors! Lookin' good :3</p>";
|
echo "<p class='alert alert-good'>No errors! Lookin' good :3</p>";
|
||||||
} else {
|
} else {
|
||||||
foreach ($results as $result) {
|
foreach ($results as $result) {
|
||||||
if ($result['type'] == 'critical') {
|
if (isset($result['type'])) {
|
||||||
echo "<p class='alert alert-bad'><span class='badge badge-critical'>Critical</span> ";
|
if ($result['type'] == 'critical') {
|
||||||
} elseif ($result['type'] == 'warning') {
|
echo "<p class='alert alert-bad'><span class='badge badge-critical'>Critical</span> ";
|
||||||
echo "<p class='alert alert-warning'><span class='badge badge-warning'>Warning</span> ";
|
} elseif ($result['type'] == 'warning') {
|
||||||
} elseif ($result['type'] == 'success') {
|
echo "<p class='alert alert-warning'><span class='badge badge-warning'>Warning</span> ";
|
||||||
echo "<p class='alert alert-good'><span class='badge badge-primary'>Success</span> ";
|
} elseif ($result['type'] == 'success') {
|
||||||
|
echo "<p class='alert alert-good'><span class='badge badge-primary'>Success</span> ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result['fix'] == 'auto') {
|
if (isset($result['fix'])) {
|
||||||
echo "<span class='badge badge-primary'>Auto fix available</span> ";
|
if ($result['fix'] == 'auto') {
|
||||||
$autofix_enable = true;
|
echo "<span class='badge badge-primary'>Auto fix available</span> ";
|
||||||
} elseif ($result['fix'] == 'manual') {
|
$autofix_enable = true;
|
||||||
echo "<span class='badge badge-critical'>Manual fix required</span> ";
|
} elseif ($result['fix'] == 'manual') {
|
||||||
|
echo "<span class='badge badge-critical'>Manual fix required</span> ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($result['link'])) {
|
if (isset($result['link'])) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue