Adding Json config

This commit is contained in:
Michał Gdula 2022-09-08 13:29:45 +00:00
parent 8713a6321a
commit b261368a9b
18 changed files with 285 additions and 519 deletions

View file

@ -28,14 +28,14 @@ if (isset($_POST['submit'])) {
if (mysqli_stmt_execute($stmt)) {
?>
<script>
sniffleAdd('Success!!!', 'The Author has been updated successfully! You may need to refresh the page to see the new information.', 'var(--green)', '<?php echo $root_dir; ?>assets/icons/check.svg');
sniffleAdd('Success!!!', 'The Author has been updated successfully! You may need to refresh the page to see the new information.', 'var(--green)', 'assets/icons/check.svg');
flyoutClose();
</script>
<?php
} else {
?>
<script>
sniffleAdd('Oopsie....', 'An error occured on the servers', 'var(--red)', '<?php echo $root_dir; ?>assets/icons/cross.svg');
sniffleAdd('Oopsie....', 'An error occured on the servers', 'var(--red)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
@ -44,7 +44,7 @@ if (isset($_POST['submit'])) {
} else {
?>
<script>
sniffleAdd('Denied', 'Sussy wussy.', 'var(--red)', '<?php echo $root_dir; ?>assets/icons/cross.svg');
sniffleAdd('Denied', 'Sussy wussy.', 'var(--red)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php

View file

@ -40,14 +40,14 @@ if (isset($_POST['submit'])) {
if (mysqli_stmt_execute($stmt)) {
?>
<script>
sniffleAdd('Success!!!', 'Description has been updated successfully! You may need to refresh the page to see the new information.', 'var(--green)', '<?php echo $root_dir; ?>assets/icons/check.svg');
sniffleAdd('Success!!!', 'Description has been updated successfully! You may need to refresh the page to see the new information.', 'var(--green)', 'assets/icons/check.svg');
flyoutClose();
</script>
<?php
} else {
?>
<script>
sniffleAdd('Error :c', 'An error occured on the servers', 'var(--red)', '<?php echo $root_dir; ?>assets/icons/cross.svg');
sniffleAdd('Error :c', 'An error occured on the servers', 'var(--red)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
@ -55,7 +55,7 @@ if (isset($_POST['submit'])) {
} else {
?>
<script>
sniffleAdd('Error :c', 'An error occured on the servers', 'var(--red)', '<?php echo $root_dir; ?>assets/icons/cross.svg');
sniffleAdd('Error :c', 'An error occured on the servers', 'var(--red)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
@ -63,7 +63,7 @@ if (isset($_POST['submit'])) {
} else {
?>
<script>
sniffleAdd('Denied', 'It seems that you do not have the right permitions to edit this image.', 'var(--red)', '<?php echo $root_dir; ?>assets/icons/cross.svg');
sniffleAdd('Denied', 'It seems that you do not have the right permitions to edit this image.', 'var(--red)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php

View file

@ -45,14 +45,14 @@ if (isset($_POST['submit'])) {
if (mysqli_stmt_execute($stmt)) {
?>
<script>
sniffleAdd('Success!!!', 'Tags have been modified successfully! You may need to refresh the page to see the new information.', 'var(--green)', '<?php echo $root_dir; ?>assets/icons/check.svg');
sniffleAdd('Success!!!', 'Tags have been modified successfully! You may need to refresh the page to see the new information.', 'var(--green)', 'assets/icons/check.svg');
flyoutClose();
</script>
<?php
} else {
?>
<script>
sniffleAdd('Error :c', 'An error occured on the servers', 'var(--red)', '<?php echo $root_dir; ?>assets/icons/cross.svg');
sniffleAdd('Error :c', 'An error occured on the servers', 'var(--red)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
@ -60,7 +60,7 @@ if (isset($_POST['submit'])) {
} else {
?>
<script>
sniffleAdd('Error :c', 'An error occured on the servers', 'var(--red)', '<?php echo $root_dir; ?>assets/icons/cross.svg');
sniffleAdd('Error :c', 'An error occured on the servers', 'var(--red)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
@ -68,7 +68,7 @@ if (isset($_POST['submit'])) {
} else {
?>
<script>
sniffleAdd('Denied', 'It seems that you do not have the right permitions to modify tags here.', 'var(--red)', '<?php echo $root_dir; ?>assets/icons/cross.svg');
sniffleAdd('Denied', 'It seems that you do not have the right permitions to modify tags here.', 'var(--red)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php

View file

@ -5,13 +5,33 @@
In the future I want this section to be configurable, but that'll require some work to be done.
For now it's hard-coded, shouldn't be an issue as most people wont be changing this often anyway
*/
// Setting up connection variables
$conn_ip = "192.168.0.79:3306";
$conn_username = "uwu";
$conn_password = "fennec621";
$conn_database = "gallery";
/*
$conn_ip = $database['ip'].":".$database['port'];
$conn_username = $database['username'];
$conn_password = $database['password'];
$conn_database = $database['database'];
echo $_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['SCRIPT_NAME']);
echo $_SERVER['PHP_SELF'];
*/
$conn = mysqli_connect($conn_ip, $conn_username, $conn_password , $conn_database);
if ($conn->connect_error) {
echo "<script>sniffleAdd('Error','Could not make a connection to the server, please try again later','var(--red)','".$root_dir."../../assets/icons/warning.svg')</script>";
?>
<script>
sniffleAdd('Error','Could not make a connection to the server, please try again later','var(--red)','assets/icons/warning.svg');
</script>
<?php
}
/*
Start session
This is important as most pages use the PHP session and will complain if its not possible to access.
*/
session_start();

29
app/settings/settings.php Normal file
View file

@ -0,0 +1,29 @@
<?php
/*
|-------------------------------------------------------------
| Settings (decode)
|-------------------------------------------------------------
| This is for decoding the settings Json, used throughout
| most of the website. Used for settings things such as
| the default background and accent colour
|-------------------------------------------------------------
*/
$user_import = file_get_contents("app/settings/user_settings.json");
$user_settings = json_decode($user_import, true);
foreach ($user_settings->data as $settings_list) {
foreach ($settings_list->website as $website) {
foreach ($website->database as $database) {
}
foreach ($website->debug as $debug) {
}
foreach ($website->plugins as $plugins) {
}
}
}
$database = $user_settings["website"]["database"];
$debug = $user_settings["website"]["debug"];
$plugins = $user_settings["website"]["plugins"];

View file

@ -0,0 +1,50 @@
{
"website": {
"name": "Only Legs",
"description": "A simple 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"
],
"license":"GPL 3.0",
"database": {
"ip": "192.168.0.79",
"port": "3306",
"username": "uwu",
"password": "fennec621",
"database": "gallery"
},
"debug": {
"testing": true,
"version": "22.09.08"
}
},
"plugins": {
"sniffle": {
"location": "Sniffle/sniffle.js",
"using": true
},
"flyout": {
"location": "Flyout/flyout.js",
"using": true
}
}
}