diff --git a/app/app.php b/app/app.php index 8abe9e2..f2b17d7 100644 --- a/app/app.php +++ b/app/app.php @@ -492,33 +492,41 @@ class Sanity { { $results = array(); - if (!is_writable("usr/images")) { + if (!fileperms("usr")) { $results[] = array( 'type'=>'critical', - 'message'=>'You need to make the images folder writable', - 'fix'=>'manual' - ); - } - if (!is_writable("usr/images/pfp")) { - $results[] = array( - 'type'=>'critical', - 'message'=>'You need to make the pfp folder writable', - 'fix'=>'manual' - ); - } - if (!is_writable("usr/images/previews")) { - $results[] = array( - 'type'=>'critical', - 'message'=>'You need to make the previews folder writable', - 'fix'=>'manual' - ); - } - if (!is_writable("usr/images/thumbnails")) { - $results[] = array( - 'type'=>'critical', - 'message'=>'You need to make the thumbnails folder writable', + 'message'=>'You need to give PHP usr folder permissions', 'fix'=>'manual' ); + } else { + if (!fileperms("usr/images")) { + $results[] = array( + 'type'=>'critical', + 'message'=>'You need to give PHP images folder permissions', + 'fix'=>'manual' + ); + } + if (!fileperms("usr/images/pfp")) { + $results[] = array( + 'type'=>'critical', + 'message'=>'You need to give PHP pfp folder permissions', + 'fix'=>'manual' + ); + } + if (!fileperms("usr/images/previews")) { + $results[] = array( + 'type'=>'critical', + 'message'=>'You need to give PHP previews folder permissions', + 'fix'=>'manual' + ); + } + if (!fileperms("usr/images/thumbnails")) { + $results[] = array( + 'type'=>'critical', + 'message'=>'You need to give PHP thumbnails folder permissions', + 'fix'=>'manual' + ); + } } return $results; diff --git a/app/gallery.json b/app/gallery.json index 7c33a8f..1752fcf 100644 --- a/app/gallery.json +++ b/app/gallery.json @@ -1,5 +1,5 @@ { "license": "GPL 3.0", - "version": "22.11.03", + "version": "22.11.05", "branch": "main" } \ No newline at end of file diff --git a/app/sanity/database.php b/app/sanity/database.php index 33a5326..e33cc9e 100644 --- a/app/sanity/database.php +++ b/app/sanity/database.php @@ -1,5 +1,5 @@ query("SELECT 1 FROM $database LIMIT 1"); @@ -14,7 +14,8 @@ if (defined('ROOT')) { } } - /*if (check_database($conn, 'images')) { + /* + if (check_database($conn, 'images')) { echo "

[INFO] Found images table

"; } else { echo "

[INFO] Could not find images table

"; diff --git a/app/sanity/folders.php b/app/sanity/folders.php index 6ffa94b..4da82fa 100644 --- a/app/sanity/folders.php +++ b/app/sanity/folders.php @@ -1,5 +1,5 @@ [INFO] Found usr/ folder!

"; } else { @@ -37,7 +37,7 @@ if (defined('ROOT')) { mkdir("usr/conf"); } - if (is_file(__DIR__."/../../usr/conf/conf.json")) { + if (is_file("../../usr/conf/conf.json")) { echo "

[INFO] Found usr/conf/conf.json file!

"; } else { echo "

[ERRO] usr/conf/conf.json file not found

"; @@ -45,8 +45,13 @@ if (defined('ROOT')) { try { $conf = file_get_contents(__DIR__."/../../usr/conf.default.json"); + + $conf_new = fopen(__DIR__."/../../usr/conf/conf.json", "w"); - if (file_put_contents(__DIR__."/../../usr/conf/conf.json", $conf)) { + if ($conf_new) { + fwrite($conf_new, $conf); + fclose($conf_new); + echo "

[INFO] usr/conf/conf.json file created!

"; } else { echo "

[ERRO] Failed to create usr/conf/conf.json file

"; diff --git a/app/sanity/sanity.php b/app/sanity/sanity.php index 77abf97..7ac752e 100644 --- a/app/sanity/sanity.php +++ b/app/sanity/sanity.php @@ -13,7 +13,10 @@ if (isset($_POST['autofix'])) { echo "

[INFO] Starting autofix

"; - if ($_SESSION['id'] != 1) { + if (empty($_SESSION['id'])) { + echo "

[ERROR] You are not logged in

"; + exit(); + } elseif ($_SESSION['id'] != 1) { echo "

[ERRO] You cannot use Autofix as an Admin currently.

"; exit(); } @@ -23,7 +26,7 @@ if (isset($_POST['autofix'])) { echo "

[INFO] Sanity check passed. No errors found.

"; exit(); } else { - //echo "

[WARN] Sanity check failed

"; + echo "

[WARN] Sanity check failed, continuing...

"; } define('ROOT', true); // Only run scripts from this file diff --git a/app/settings.php b/app/settings.php index 7514380..1ea6eea 100644 --- a/app/settings.php +++ b/app/settings.php @@ -19,4 +19,5 @@ if (is_file(__DIR__."/../usr/conf/msg.json")) { $user_welcome = $user_welcome['welcome']; } -$web_info = json_decode(file_get_contents(__DIR__."/gallery.json"), true); \ No newline at end of file +$web_info = json_decode(file_get_contents(__DIR__."/gallery.json"), true); +$upload_conf = $user_settings['upload']; \ No newline at end of file