Moving to conf.json from manifest.json

This commit is contained in:
Michał Gdula 2022-11-01 12:36:37 +00:00
parent 3b24876900
commit b3dbc2cb65
11 changed files with 113 additions and 119 deletions

View file

@ -159,8 +159,9 @@
if ($user_info->is_admin($conn, $_SESSION['id'])) {
$sql_start = microtime(true);
?>
<div class="defaultDecoration defaultSpacing defaultFonts">
<h2>Admin</h2>
<div class="sanity-check defaultDecoration defaultSpacing defaultFonts">
<h2>Website</h2>
<h3>Invite Codes</h3>
<?php
$token_request = mysqli_query($conn, "SELECT * FROM tokens WHERE used = 0");
@ -177,8 +178,7 @@
}
?>
<br>
<br><h3>Admin</h3>
<div class="tabs">
<button class="btn btn-neutral tablinks" onclick="openTab(event, 'logs')">Logs</button>
<button class="btn btn-neutral tablinks" onclick="openTab(event, 'bans')">Bans</button>
@ -378,48 +378,46 @@
evt.currentTarget.className += " active-tab";
}
</script>
</div>
<div class="sanity-check defaultDecoration defaultSpacing defaultFonts">
<h2>Sanity check</h2>
<?php
$check_sanity = $sanity->get_results();
<br><h3>Sanity check</h3>
<?php
$check_sanity = $sanity->get_results();
if (empty($check_sanity)) {
echo "<p class='alert alert-good'>No errors! Lookin' good :3</p>";
} else {
?>
<style>
.sanity-check {
border-color: var(--warning);
}
</style>
<?php
foreach ($check_sanity as $result) {
if ($result['type'] == 'critical') {
echo "<p class='alert alert-bad'>
<img class='svg' src='assets/icons/warning.svg'>
".$result['message']."
</p>";
} elseif ($result['type'] == 'warning') {
echo "<p class='alert alert-warning'>
<img class='svg' src='assets/icons/warning.svg'>
".$result['message']."
</p>";
} else {
echo "<p class='alert alert-warning'>
<img class='svg' src='assets/icons/warning.svg'>
".$result['message']."
</p>";
if (empty($check_sanity)) {
echo "<p class='alert alert-good'>No errors! Lookin' good :3</p>";
} else {
?>
<style>
.sanity-check {
border-color: var(--warning);
}
</style>
<?php
foreach ($check_sanity as $result) {
if ($result['type'] == 'critical') {
echo "<p class='alert alert-bad'>
<img class='svg' src='assets/icons/warning.svg'>
".$result['message']."
</p>";
} elseif ($result['type'] == 'warning') {
echo "<p class='alert alert-warning'>
<img class='svg' src='assets/icons/warning.svg'>
".$result['message']."
</p>";
} else {
echo "<p class='alert alert-warning'>
<img class='svg' src='assets/icons/warning.svg'>
".$result['message']."
</p>";
}
echo "<br> <button class='btn btn-bad' disabled>
<img class='svg' src='assets/icons/wrench.svg'>
Attemp Autofix
</button>";
}
?>
echo "<button class='btn btn-bad' disabled>
<img class='svg' src='assets/icons/wrench.svg'>
Attempt Autofix
</button>";
}
?>
</div>
<?php
$sql_end = microtime(true);

View file

@ -1,5 +1,5 @@
{
"license": "GPL 3.0",
"version": "22.10.20",
"version": "22.11.01",
"branch": "main"
}

View file

@ -378,7 +378,7 @@ class Setup {
mkdir("usr/conf");
}
if (!is_file(__DIR__."/../usr/conf/manifest.json")) {
if (!is_file(__DIR__."/../usr/conf/conf.json")) {
$manifest = array(
"website_name" => "Only Legs",
"website_description" => "A simple PHP gallery with multiple users in mind",
@ -392,7 +392,7 @@ class Setup {
"allowed_extensions" => array("jpg", "jpeg", "png", "webp")
)
);
file_put_contents(__DIR__."/../usr/conf/manifest.json", json_encode($manifest));
file_put_contents(__DIR__."/../usr/conf/conf.json", json_encode($manifest));
}
}
}
@ -402,17 +402,25 @@ class Sanity {
{
$results = array();
if (!is_file(__DIR__."/../usr/conf/manifest.json")) {
$results[] = array('type'=>'critical', 'message'=>'manifest.json is missing');
if (!is_file(__DIR__."/../usr/conf/msg.json")) {
$results[] = array('type'=>'warning', 'message'=>'msg.json is missing');
}
if (!is_file(__DIR__."/../usr/conf/conf.json")) {
if (is_file(__DIR__."/../usr/conf/manifest.json")) {
$results[] = array('type'=>'critical', 'message'=>'manifest.json is deprecated, please rename it to conf.json');
} else {
$results[] = array('type'=>'critical', 'message'=>'conf.json is missing, using conf.default.json instead');
}
} else {
$manifest = json_decode(file_get_contents(__DIR__."/../usr/conf/manifest.json"), true);
$manifest = json_decode(file_get_contents(__DIR__."/../usr/conf/conf.json"), true);
if (empty($manifest['user_name']) || $manifest['user_name'] == "[your name]") {
$results[] = array('type'=>'warning', 'message'=>'manifest.json is missing your name');
$results[] = array('type'=>'warning', 'message'=>'conf.json is missing your name');
}
if ($manifest['upload']['rename_on_upload']) {
if (empty($manifest['upload']['rename_to'])) {
$results[] = array('type'=>'critical', 'message'=>'manifest.json doesnt know what to rename your files to');
$results[] = array('type'=>'critical', 'message'=>'conf.json doesnt know what to rename your files to');
} else {
$rename_to = $manifest['upload']['rename_to'];
$rename_rate = 0;
@ -426,9 +434,9 @@ class Sanity {
if (str_contains($rename_to, '{{username}}') || str_contains($rename_to, '{{userid}}')) $rename_rate += 1;
if ($rename_rate < 2) {
$results[] = array('type'=>'critical', 'message'=>'You will encounter errors when uploading images due to filenames, update your manifest.json');
$results[] = array('type'=>'critical', 'message'=>'You will encounter errors when uploading images due to filenames, update your conf.json');
} elseif ($rename_rate < 5 && $rename_rate > 2) {
$results[] = array('type'=>'warning', 'message'=>'You may encounter errors when uploading images due to filenames, concider modifying your manifest.json');
$results[] = array('type'=>'warning', 'message'=>'You may encounter errors when uploading images due to filenames, concider modifying your conf.json');
}
}
}

View file

@ -5,8 +5,8 @@ require_once dirname(__DIR__)."/app/conn.php";
require_once dirname(__DIR__)."/app/app.php";
require_once dirname(__DIR__)."/app/settings.php";
ini_set('post_max_size', $upload_conf['max_filesize']."M");
ini_set('upload_max_filesize', ($upload_conf['upload_max'] + 1)."M");
ini_set('post_max_size', $upload_conf['max_filesize']);
ini_set('upload_max_filesize', $upload_conf['max_filesize']);
if ($user_settings['is_testing']) {
ini_set('display_errors', 1);

View file

@ -8,7 +8,22 @@
| the default background and accent colour
|-------------------------------------------------------------
*/
$user_settings = json_decode(file_get_contents(__DIR__."/../usr/conf/manifest.json"), true);
$user_settings = json_decode(file_get_contents(__DIR__."/../usr/conf/conf.json"), true);
if (!is_file(__DIR__."/../usr/conf/conf.json")) {
$settings = json_decode(file_get_contents(__DIR__."/../usr/conf/conf.json"), true);
} else {
$settings = json_decode(file_get_contents(__DIR__."/../usr/conf.default.json"), true);
}
if (!is_file(__DIR__."/../usr/conf/msg.json")) {
$user_welcome = json_decode(file_get_contents(__DIR__."/../usr/conf/msg.json"), true);
$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);
$upload_conf = $user_settings["upload"];

View file

@ -114,8 +114,6 @@ nav .btn {
@media (max-width: 550px) {
nav {
margin: 0;
width: calc(100% - 1rem);
height: 2.5rem;
position: fixed;
top: auto;
bottom: 0;
@ -542,6 +540,7 @@ nav .btn {
.group-name {
margin: 0;
max-width: 90%;
position: absolute;
top: 50%;
left: 50%;
@ -553,6 +552,8 @@ nav .btn {
font-family: "Secular One", sans-serif;
text-decoration: none;
text-align: center;
text-overflow: ellipsis;
overflow-x: hidden;
}
.gallery-group {
@ -585,6 +586,7 @@ nav .btn {
position: relative;
overflow: hidden;
flex: 1 0 150px;
text-overflow: ellipsis;
transition: outline 0.1s cubic-bezier(0.19, 1, 0.22, 1);
}
.group-make:hover {
@ -620,7 +622,9 @@ nav .btn {
cursor: pointer;
}
.group-make button span {
max-width: 90%;
text-align: center;
text-overflow: ellipsis;
}
.group-make button img {
margin: 0.25rem;
@ -628,16 +632,9 @@ nav .btn {
height: 2.5rem;
}
@media (max-width: 800px) {
.group-make {
max-width: calc(25% - 0.5rem);
min-width: calc(25% - 0.5rem);
}
}
@media (max-width: 550px) {
.group-make {
max-width: calc(33.33% - 0.5rem);
min-width: calc(33.33% - 0.5rem);
.group-make > button > span {
display: none;
}
}
/*

View file

@ -481,6 +481,8 @@
.group-name {
margin: 0;
max-width: 90%;
position: absolute;
top: 50%;
left: 50%;
@ -495,6 +497,9 @@
font-family: $font-body;
text-decoration: none;
text-align: center;
text-overflow: ellipsis;
overflow-x: hidden;
}
.gallery-group {
@ -540,6 +545,8 @@
flex: 1 0 150px;
text-overflow: ellipsis;
transition: outline 0.1s cubic-bezier(.19, 1, .22, 1);
&:hover {
@ -587,7 +594,9 @@
}
span {
max-width: 90%;
text-align: center;
text-overflow: ellipsis;
}
img {
@ -598,16 +607,9 @@
}
}
}
@media (max-width: 800px) {
.group-make {
max-width: calc(25% - 0.5rem);
min-width: calc(25% - 0.5rem);
}
}
@media (max-width: 550px) {
.group-make {
max-width: calc(33.33% - 0.5rem);
min-width: calc(33.33% - 0.5rem);
.group-make > button > span {
display: none;
}
}
/*

View file

@ -85,9 +85,6 @@ nav {
nav {
margin: 0;
width: calc(100% - 1rem);
height: 2.5rem;
position: fixed;
top: auto;
bottom: 0;

View file

@ -95,9 +95,8 @@
echo "<h1>".$time_welc."!</h1>";
}
// Random welcome message
$welcome_message = $user_settings['welcome_msg'];
echo "<p>".$welcome_message[array_rand($welcome_message, 1)]."</p>";
// Random welcome message
echo "<p>".$user_welcome[array_rand($user_welcome, 1)]."</p>";
?>
</div>
<?php

17
usr/conf.default.json Normal file
View file

@ -0,0 +1,17 @@
{
"website_name": "Only Legs",
"website_description": "A simple PHP gallery with multiple users in mind",
"user_name": "[your name]",
"is_testing": true,
"upload": {
"max_filesize": "32M",
"rename_on_upload": true,
"rename_to": "IMG_{{username}}_{{time}}",
"allowed_extentions": [
"jpg",
"jpeg",
"png",
"webp"
]
}
}

View file

@ -1,39 +0,0 @@
{
"website_name": "Only Legs",
"website_description": "A simple PHP gallery with multiple users in mind",
"welcome_msg": [
"*internal screaming*",
"Don't forget to drink water!",
"Bruh",
"Fluffy made this!",
"maybe",
"I'm gay",
"I wish we were better strangers.",
"<span style='color:#ffff00;'>Just like Minecraft!</span>",
"If I were you, I'd run now",
"This is the part where I kill you",
"SILICA GEL \"DO NOT EAT\".",
"This was supposed to be a simple project",
"AAAAAAAAAAAAAAAAAAAA",
"Let me out",
"nice",
"I'm glad you're here",
"The weather is dry",
"Need me a man 👀",
"Gods die too.",
"Eat hotchip and lie"
],
"user_name": "[your name]",
"is_testing": true,
"upload": {
"max_filesize": "32",
"rename_on_upload": true,
"rename_to": "IMG_{{username}}_{{time}}",
"allowed_extentions": [
"jpg",
"jpeg",
"png",
"webp"
]
}
}