mirror of
https://github.com/Fluffy-Bean/image-gallery.git
synced 2025-06-05 09:53:12 +00:00
Fixing conf file writing and upload settings errors
This commit is contained in:
parent
86bba69f81
commit
45b79c9c33
6 changed files with 50 additions and 32 deletions
54
app/app.php
54
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;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"license": "GPL 3.0",
|
||||
"version": "22.11.03",
|
||||
"version": "22.11.05",
|
||||
"branch": "main"
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
if (defined('ROOT')) {
|
||||
if (defined('ROOT') && $_SESSION['id'] == 1) {
|
||||
function check_database($conn, $database) {
|
||||
try {
|
||||
$check = $conn->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 "<p><span style='color: var(--accent);'>[INFO]</span> Found images table</p>";
|
||||
} else {
|
||||
echo "<p><span style='color: var(--warning);'>[INFO]</span> Could not find images table</p>";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
if (defined('ROOT')) {
|
||||
if (defined('ROOT') && $_SESSION['id'] == 1) {
|
||||
if (is_dir(__DIR__."/../../usr")) {
|
||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Found usr/ folder!</p>";
|
||||
} 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 "<p><span style='color: var(--accent);'>[INFO]</span> Found usr/conf/conf.json file!</p>";
|
||||
} else {
|
||||
echo "<p><span style='color: var(--warning);'>[ERRO]</span> usr/conf/conf.json file not found</p>";
|
||||
|
@ -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 "<p><span style='color: var(--accent);'>[INFO]</span> usr/conf/conf.json file created!</p>";
|
||||
} else {
|
||||
echo "<p><span style='color: var(--warning);'>[ERRO]</span> Failed to create usr/conf/conf.json file</p>";
|
||||
|
|
|
@ -13,7 +13,10 @@ if (isset($_POST['autofix'])) {
|
|||
|
||||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Starting autofix</p>";
|
||||
|
||||
if ($_SESSION['id'] != 1) {
|
||||
if (empty($_SESSION['id'])) {
|
||||
echo "<p><span style='color: var(--warning);'>[ERROR]</span> You are not logged in</p>";
|
||||
exit();
|
||||
} elseif ($_SESSION['id'] != 1) {
|
||||
echo "<p><span style='color: var(--warning);'>[ERRO]</span> You cannot use Autofix as an Admin currently.</p>";
|
||||
exit();
|
||||
}
|
||||
|
@ -23,7 +26,7 @@ if (isset($_POST['autofix'])) {
|
|||
echo "<p><span style='color: var(--accent);'>[INFO]</span> Sanity check passed. No errors found.</p>";
|
||||
exit();
|
||||
} else {
|
||||
//echo "<p><span style='color: var(--alert);'>[WARN]</span> Sanity check failed</p>";
|
||||
echo "<p><span style='color: var(--alert);'>[WARN]</span> Sanity check failed, continuing...</p>";
|
||||
}
|
||||
|
||||
define('ROOT', true); // Only run scripts from this file
|
||||
|
|
|
@ -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);
|
||||
$web_info = json_decode(file_get_contents(__DIR__."/gallery.json"), true);
|
||||
$upload_conf = $user_settings['upload'];
|
Loading…
Add table
Add a link
Reference in a new issue