mirror of
https://github.com/Fluffy-Bean/image-gallery.git
synced 2025-06-07 02:43:12 +00:00
Fixing problems caused with conf.json
Adding to upcoming autofix feature
This commit is contained in:
parent
37e1db5b7b
commit
05533395eb
4 changed files with 66 additions and 39 deletions
|
@ -47,7 +47,9 @@ if (isset($_POST['submit_login'])) {
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$error += 1;
|
$error += 1;
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if ($error <= 0) {
|
||||||
$attemps = 0;
|
$attemps = 0;
|
||||||
$log_query = mysqli_query($conn, "SELECT * FROM logs WHERE ipaddress = '$user_ip' ORDER BY id DESC LIMIT 5");
|
$log_query = mysqli_query($conn, "SELECT * FROM logs WHERE ipaddress = '$user_ip' ORDER BY id DESC LIMIT 5");
|
||||||
|
|
||||||
|
|
84
app/app.php
84
app/app.php
|
@ -6,15 +6,7 @@ use Throwable;
|
||||||
use Imagick;
|
use Imagick;
|
||||||
|
|
||||||
class Make {
|
class Make {
|
||||||
/*
|
function thumbnail($image_path, $thumbnail_path, $resolution = 300): Exception|string
|
||||||
|-------------------------------------------------------------
|
|
||||||
| Create Thumbnails
|
|
||||||
|-------------------------------------------------------------
|
|
||||||
| Default resolution for a preview image is 300px (max-width)
|
|
||||||
| ** Not yet implemented **
|
|
||||||
|-------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
function thumbnail($image_path, $thumbnail_path, $resolution): Exception|string
|
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$thumbnail = new Imagick($image_path);
|
$thumbnail = new Imagick($image_path);
|
||||||
|
@ -336,26 +328,76 @@ class Setup {
|
||||||
function create_tables($conn, $sql): bool
|
function create_tables($conn, $sql): bool
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
$sql = "CREATE TABLE IF NOT EXISTS users ()";
|
$sql = "CREATE TABLE IF NOT EXISTS users (
|
||||||
|
id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
username VARCHAR(255) NOT NULL UNIQUE,
|
||||||
|
password VARCHAR(255) NOT NULL,
|
||||||
|
pfp_path VARCHAR(255) NOT NULL,
|
||||||
|
admin BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
last_modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
)";
|
||||||
if ($conn->query($sql) === TRUE) {
|
if ($conn->query($sql) === TRUE) {
|
||||||
echo "Table users created successfully";
|
echo "Table users created successfully";
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "CREATE TABLE IF NOT EXISTS images ()";
|
$sql = "CREATE TABLE IF NOT EXISTS images (
|
||||||
|
id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
imagename VARCHAR(255) NOT NULL,
|
||||||
|
alt VARCHAR(text) NOT NULL,
|
||||||
|
tags VARCHAR(text) NOT NULL,
|
||||||
|
author INT(11) NOT NULL,
|
||||||
|
last_modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
|
upload_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
)";
|
||||||
if ($conn->query($sql) === TRUE) {
|
if ($conn->query($sql) === TRUE) {
|
||||||
echo "Table images created successfully";
|
echo "Table images created successfully";
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "CREATE TABLE IF NOT EXISTS groups ()";
|
$sql = "CREATE TABLE IF NOT EXISTS groups (
|
||||||
|
id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
group_name VARCHAR(255) NOT NULL,
|
||||||
|
image_list VARCHAR(text) NOT NULL,
|
||||||
|
last_modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
)";
|
||||||
if ($conn->query($sql) === TRUE) {
|
if ($conn->query($sql) === TRUE) {
|
||||||
echo "Table groups created successfully";
|
echo "Table groups created successfully";
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "CREATE TABLE IF NOT EXISTS logs ()";
|
$sql = "CREATE TABLE IF NOT EXISTS logs (
|
||||||
|
id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
ipaddress VARCHAR(16) NOT NULL,
|
||||||
|
action VARCHAR(255) NOT NULL,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
)";
|
||||||
if ($conn->query($sql) === TRUE) {
|
if ($conn->query($sql) === TRUE) {
|
||||||
echo "Table logs created successfully";
|
echo "Table logs created successfully";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$sql = "CREATE TABLE IF NOT EXISTS bans (
|
||||||
|
id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
ipaddress VARCHAR(16) NOT NULL,
|
||||||
|
reason VARCHAR(255) NOT NULL,
|
||||||
|
time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
length VARCHAR(255) NOT NULL,
|
||||||
|
permanent BOOLEAN NOT NULL DEFAULT FALSE
|
||||||
|
)";
|
||||||
|
if ($conn->query($sql) === TRUE) {
|
||||||
|
echo "Table bans created successfully";
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "CREATE TABLE IF NOT EXISTS tokens (
|
||||||
|
id INT(11) AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
code VARCHAR(59) NOT NULL,
|
||||||
|
used BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||||
|
)";
|
||||||
|
if ($conn->query($sql) === TRUE) {
|
||||||
|
echo "Table tokens created successfully";
|
||||||
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,20 +421,8 @@ class Setup {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_file(__DIR__."/../usr/conf/conf.json")) {
|
if (!is_file(__DIR__."/../usr/conf/conf.json")) {
|
||||||
$manifest = array(
|
$manifest = file_get_contents(__DIR__."/../usr/conf.default.json");
|
||||||
"website_name" => "Only Legs",
|
file_put_contents(__DIR__."/../usr/conf/conf.json", $manifest);
|
||||||
"website_description" => "A simple PHP gallery with multiple users in mind",
|
|
||||||
"welcome_message" => array("*internal screaming*", "Welcome to Only Legs!"),
|
|
||||||
"user_name" => "[your name]",
|
|
||||||
"is_test" => true,
|
|
||||||
"upload" => array(
|
|
||||||
"max_filesize" => 35,
|
|
||||||
"rename_on_upload" => true,
|
|
||||||
"rename_to" => "IMG_{{username}}_{{time}}",
|
|
||||||
"allowed_extensions" => array("jpg", "jpeg", "png", "webp")
|
|
||||||
)
|
|
||||||
);
|
|
||||||
file_put_contents(__DIR__."/../usr/conf/conf.json", json_encode($manifest));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,22 +8,15 @@
|
||||||
| the default background and accent colour
|
| the default background and accent colour
|
||||||
|-------------------------------------------------------------
|
|-------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
$user_settings = json_decode(file_get_contents(__DIR__."/../usr/conf/conf.json"), true);
|
|
||||||
|
|
||||||
if (is_file(__DIR__."/../usr/conf/conf.json")) {
|
if (is_file(__DIR__."/../usr/conf/conf.json")) {
|
||||||
$settings = json_decode(file_get_contents(__DIR__."/../usr/conf/conf.json"), true);
|
$user_settings = json_decode(file_get_contents(__DIR__."/../usr/conf/conf.json"), true);
|
||||||
} else {
|
} else {
|
||||||
$settings = json_decode(file_get_contents(__DIR__."/../usr/conf.default.json"), true);
|
$user_settings = json_decode(file_get_contents(__DIR__."/../usr/conf.default.json"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_file(__DIR__."/../usr/conf/msg.json")) {
|
if (is_file(__DIR__."/../usr/conf/msg.json")) {
|
||||||
$user_welcome = json_decode(file_get_contents(__DIR__."/../usr/conf/msg.json"), true);
|
$user_welcome = json_decode(file_get_contents(__DIR__."/../usr/conf/msg.json"), true);
|
||||||
$user_welcome = $user_welcome['welcome'];
|
$user_welcome = $user_welcome['welcome'];
|
||||||
} else {
|
|
||||||
$user_welcome = array('Welcome to your new Only Legs installation! You can change this message in the settings page.');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$web_info = json_decode(file_get_contents(__DIR__."/app.json"), true);
|
$web_info = json_decode(file_get_contents(__DIR__."/app.json"), true);
|
||||||
|
|
||||||
$upload_conf = $user_settings["upload"];
|
|
|
@ -96,7 +96,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Random welcome message
|
// Random welcome message
|
||||||
|
if (isset($user_welcome)) {
|
||||||
echo "<p>".$user_welcome[array_rand($user_welcome, 1)]."</p>";
|
echo "<p>".$user_welcome[array_rand($user_welcome, 1)]."</p>";
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue