Remaking file structure for easier updating

This commit is contained in:
Michał Gdula 2022-10-13 12:04:25 +00:00
parent e7a2284809
commit d897215023
17 changed files with 119 additions and 103 deletions

View file

@ -41,8 +41,8 @@
<button id="pfpSubmit" class="btn btn-good" type="submit"><img class="svg" src="assets/icons/upload.svg">Upload Image</button> <button id="pfpSubmit" class="btn btn-good" type="submit"><img class="svg" src="assets/icons/upload.svg">Upload Image</button>
</form> </form>
<?php <?php
if (is_file("images/pfp/".$profile_info['pfp_path'])) { if (is_file("usr/images/pfp/".$profile_info['pfp_path'])) {
echo "<img src='images/pfp/".$profile_info['pfp_path']."'>"; echo "<img src='usr/images/pfp/".$profile_info['pfp_path']."'>";
} else { } else {
echo "<img src='assets/no_image.png'>"; echo "<img src='assets/no_image.png'>";
} }
@ -251,8 +251,8 @@
if ($user['admin'] || $user['id'] == 1) { if ($user['admin'] || $user['id'] == 1) {
echo "<div class='user is-admin'>"; echo "<div class='user is-admin'>";
} else { } else {
echo "<div class='user'>"; echo "<div class='user'>";
} }
?> ?>
<p><?php echo $user['id']; ?></p> <p><?php echo $user['id']; ?></p>
<p><?php echo $user['username']; ?></p> <p><?php echo $user['username']; ?></p>

View file

@ -1,6 +1,6 @@
<?php <?php
// Include server connection // Include server connection
include dirname(__DIR__)."/server/conn.php"; include dirname(__DIR__)."/conn.php";
include dirname(__DIR__)."/app.php"; include dirname(__DIR__)."/app.php";
use App\Account; use App\Account;
@ -131,11 +131,6 @@ if (isset($_POST['submit_login'])) {
$_SESSION['welc'] = true; $_SESSION['welc'] = true;
mysqli_query($conn,"INSERT INTO logs (ipaddress, action) VALUES('$user_ip','New loggin to ".$_SESSION['username']."')"); mysqli_query($conn,"INSERT INTO logs (ipaddress, action) VALUES('$user_ip','New loggin to ".$_SESSION['username']."')");
// This is a terrible way of doing this, but is has to be done
if ($id == 1 && $user_info->is_admin($conn, $id) == false) {
mysqli_query($conn,"UPDATE users SET admin = 1 WHERE id = 1");
}
} else { } else {
?> ?>
<script> <script>
@ -379,6 +374,11 @@ if (isset($_POST['submit_signup'])) {
// Attempt to execute the prepared statement // Attempt to execute the prepared statement
if (mysqli_stmt_execute($stmt)) { if (mysqli_stmt_execute($stmt)) {
// If first user, set as admin
if (mysqli_insert_id($conn) == 1) {
mysqli_query($conn,"UPDATE users SET admin = 1 WHERE id = 1");
}
// Prepare sql // Prepare sql
$sql = "UPDATE tokens SET used = True WHERE code = ?"; $sql = "UPDATE tokens SET used = True WHERE code = ?";
$stmt = mysqli_prepare($conn, $sql); $stmt = mysqli_prepare($conn, $sql);
@ -438,7 +438,7 @@ if (isset($_POST['toggle_admin'])) {
if ($admin_status) { if ($admin_status) {
$param_admin_status = 0; $param_admin_status = 0;
$admin_update_message = "removed from the admins list"; $admin_update_message = "removed from the admins list";
} elseif (!$admin_status) { } else {
$param_admin_status = 1; $param_admin_status = 1;
$admin_update_message = "added to the admins list"; $admin_update_message = "added to the admins list";
} }

View file

@ -14,7 +14,8 @@ class Make {
| ** Not yet implemented ** | ** Not yet implemented **
|------------------------------------------------------------- |-------------------------------------------------------------
*/ */
function thumbnail($image_path, $thumbnail_path, $resolution) { function thumbnail($image_path, $thumbnail_path, $resolution): Exception|string
{
try { try {
$thumbnail = new Imagick($image_path); $thumbnail = new Imagick($image_path);
$thumbnail->resizeImage($resolution,null,null,1,null); $thumbnail->resizeImage($resolution,null,null,1,null);
@ -31,7 +32,8 @@ class Make {
Returns clean string of words with equal white space between it Returns clean string of words with equal white space between it
*/ */
function tags($string) { function tags($string): string
{
$string = str_replace('-', '_', $string); $string = str_replace('-', '_', $string);
$string = preg_replace('/[^A-Za-z0-9\_ ]/', '', $string); $string = preg_replace('/[^A-Za-z0-9\_ ]/', '', $string);
$string = strtolower($string); $string = strtolower($string);
@ -50,7 +52,8 @@ class Make {
return trim($string); return trim($string);
} }
function get_image_colour($img) { function get_image_colour($img): ?string
{
$img_type = pathinfo($img, PATHINFO_EXTENSION); $img_type = pathinfo($img, PATHINFO_EXTENSION);
if ($img_type == "png") { if ($img_type == "png") {
@ -106,10 +109,11 @@ class Account {
Returns True if user is Returns True if user is
Returns False if user is NOT Returns False if user is NOT
*/ */
function is_loggedin($conn) { function is_loggedin($conn): bool
{
$error = 0; $error = 0;
if (!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] == false) $error += 1; if (!isset($_SESSION["loggedin"]) || !$_SESSION["loggedin"]) $error += 1;
if (empty($this->get_user_info($conn, $_SESSION["id"])) || $this->get_user_info($conn, $_SESSION["id"]) == null) $error += 1; if (empty($this->get_user_info($conn, $_SESSION["id"])) || $this->get_user_info($conn, $_SESSION["id"]) == null) $error += 1;
@ -124,7 +128,8 @@ class Account {
Returns array with user info Returns array with user info
*/ */
function get_user_info($conn, $id) { function get_user_info($conn, $id): bool|array|null
{
$sql = "SELECT id, username, created_at, pfp_path FROM users WHERE id = ?"; $sql = "SELECT id, username, created_at, pfp_path FROM users WHERE id = ?";
if ($stmt = mysqli_prepare($conn, $sql)) { if ($stmt = mysqli_prepare($conn, $sql)) {
@ -148,7 +153,8 @@ class Account {
Returns True if user is privilaged Returns True if user is privilaged
Returns False if user is NOT privilaged Returns False if user is NOT privilaged
*/ */
function is_admin($conn, $id) { function is_admin($conn, $id): bool
{
if (isset($id) && !empty($id)) { if (isset($id) && !empty($id)) {
// Setting SQL query // Setting SQL query
$sql = "SELECT admin FROM users WHERE id = ?"; $sql = "SELECT admin FROM users WHERE id = ?";
@ -179,7 +185,8 @@ class Account {
/* /*
Get target IP, used for logging Get target IP, used for logging
*/ */
function get_ip() { function get_ip(): mixed
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) { if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$target_ip = $_SERVER['HTTP_CLIENT_IP']; $target_ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
@ -198,7 +205,8 @@ class Image {
Returns array with image info Returns array with image info
*/ */
function get_image_info($conn, $id) { function get_image_info($conn, $id): bool|array|null
{
$sql = "SELECT * FROM images WHERE id = ?"; $sql = "SELECT * FROM images WHERE id = ?";
if ($stmt = mysqli_prepare($conn, $sql)) { if ($stmt = mysqli_prepare($conn, $sql)) {
@ -220,7 +228,8 @@ class Image {
Returns True if user is privilaged Returns True if user is privilaged
Returns False if user is NOT privilaged Returns False if user is NOT privilaged
*/ */
function image_privilage($id) { function image_privilage($id): bool
{
$session_id = $_SESSION['id']; $session_id = $_SESSION['id'];
if (isset($session_id) || !empty($session_id)) { if (isset($session_id) || !empty($session_id)) {
if ($session_id == $id) { if ($session_id == $id) {
@ -235,7 +244,8 @@ class Image {
} }
class Group { class Group {
function get_group_info($conn, $id) { function get_group_info($conn, $id): bool|array|null
{
// Setting SQL query // Setting SQL query
$sql = "SELECT * FROM groups WHERE id = ?"; $sql = "SELECT * FROM groups WHERE id = ?";
@ -253,7 +263,8 @@ class Group {
return($group_array); return($group_array);
} }
function get_group_members($conn, $id){ function get_group_members($conn, $id): array
{
$user_array = array(); $user_array = array();
$sql = "SELECT * FROM groups WHERE id = ?"; $sql = "SELECT * FROM groups WHERE id = ?";
@ -290,7 +301,8 @@ class Group {
} }
class Diff { class Diff {
function time($past_time, $full_date = false) { function time($past_time, $full_date = false): string
{
$now = new \DateTime; $now = new \DateTime;
$ago = new \DateTime($past_time); $ago = new \DateTime($past_time);
$diff = $now->diff($ago); $diff = $now->diff($ago);
@ -321,19 +333,20 @@ class Diff {
} }
class Sanity { class Sanity {
function check_json() { function check_json(): array
{
$results = array(); $results = array();
if (!is_file(__DIR__."/settings/manifest.json")) { if (!is_file(__DIR__."/../usr/conf/manifest.json")) {
$results[] = "Critical: manifest.json is missing"; $results[] = "Critical: manifest.json is missing";
} else { } else {
$manifest = json_decode(file_get_contents(__DIR__."/settings/manifest.json"), true); $manifest = json_decode(file_get_contents(__DIR__."/../usr/conf/manifest.json"), true);
if (!isset($manifest['user_name']) || empty($manifest['user_name']) || $manifest['user_name'] == "[your name]") { if (empty($manifest['user_name']) || $manifest['user_name'] == "[your name]") {
$results[] = "Warning: manifest.json is missing your name"; $results[] = "Warning: manifest.json is missing your name";
} }
if ($manifest['upload']['rename_on_upload'] == true ) { if ($manifest['upload']['rename_on_upload']) {
if (!isset($manifest['upload']['rename_to']) || empty($manifest['upload']['rename_to'])) { if (empty($manifest['upload']['rename_to'])) {
$results[] = "Critical: manifest.json doesnt know what to rename your files to"; $results[] = "Critical: manifest.json doesnt know what to rename your files to";
} else { } else {
$rename_to = $manifest['upload']['rename_to']; $rename_to = $manifest['upload']['rename_to'];
@ -347,7 +360,7 @@ class Sanity {
if (str_contains($rename_to, '{{username}}') || str_contains($rename_to, '{{userid}}')) $rename_rate += 1; if (str_contains($rename_to, '{{username}}') || str_contains($rename_to, '{{userid}}')) $rename_rate += 1;
if ($rename_rate == 0 || $rename_rate < 2) { if ($rename_rate < 2) {
$results[] = "Critical: You will encounter errors when uploading images due to filenames, update your manifest.json"; $results[] = "Critical: You will encounter errors when uploading images due to filenames, update your manifest.json";
} elseif ($rename_rate < 5 && $rename_rate > 2) { } elseif ($rename_rate < 5 && $rename_rate > 2) {
$results[] = "Warning: You may encounter errors when uploading images due to filenames, concider update your manifest.json"; $results[] = "Warning: You may encounter errors when uploading images due to filenames, concider update your manifest.json";
@ -363,26 +376,28 @@ class Sanity {
return $results; return $results;
} }
function check_files() { function check_files(): array
{
$results = array(); $results = array();
if (!is_dir("images")) { if (!is_dir("usr/images")) {
$results[] = "Critical: You need to setup an images folder, follow the guide on the GitHub repo"; $results[] = "Critical: You need to setup an images folder, follow the guide on the GitHub repo";
} }
if (!is_dir("images/pfp")) { if (!is_dir("usr/images/pfp")) {
$results[] = "Critical: You need to setup an pfp folder, follow the guide on the GitHub repo"; $results[] = "Critical: You need to setup an pfp folder, follow the guide on the GitHub repo";
} }
if (!is_dir("images/previews")) { if (!is_dir("usr/images/previews")) {
$results[] = "Critical: You need to setup an previews folder, follow the guide on the GitHub repo"; $results[] = "Critical: You need to setup an previews folder, follow the guide on the GitHub repo";
} }
if (!is_dir("images/thumbnails")) { if (!is_dir("usr/images/thumbnails")) {
$results[] = "Critical: You need to setup an thumbnails folder, follow the guide on the GitHub repo"; $results[] = "Critical: You need to setup an thumbnails folder, follow the guide on the GitHub repo";
} }
return $results; return $results;
} }
function check_version() { function check_version(): array
{
$results = array(); $results = array();
$url = "https://raw.githubusercontent.com/Fluffy-Bean/image-gallery/main/app/settings/manifest.json"; $url = "https://raw.githubusercontent.com/Fluffy-Bean/image-gallery/main/app/settings/manifest.json";
@ -396,7 +411,7 @@ class Sanity {
curl_close($ch); curl_close($ch);
$manifest_repo = json_decode($result, true); $manifest_repo = json_decode($result, true);
$manifest_local = json_decode(file_get_contents(__DIR__."/settings/manifest.json"), true); $manifest_local = json_decode(file_get_contents(__DIR__."/../usr/conf/manifest.json"), true);
if ($manifest_local['version'] < $manifest_repo['version']) { if ($manifest_local['version'] < $manifest_repo['version']) {
$results[] = "Critical: You are not running the latest version of the app v".$manifest_repo['version'].""; $results[] = "Critical: You are not running the latest version of the app v".$manifest_repo['version']."";
@ -404,14 +419,15 @@ class Sanity {
$results[] = "Warning: You are running a version of the app that is newer than the latest release v".$manifest_repo['version'].""; $results[] = "Warning: You are running a version of the app that is newer than the latest release v".$manifest_repo['version']."";
} }
if (PHP_VERSION_ID < 80100) { if (PHP_VERSION_ID < 80000) {
$results[] = "Critical: Your current version of PHP is ".PHP_VERSION.". The reccomended version is 8.1.2"; $results[] = "Critical: Your current version of PHP is ".PHP_VERSION.". The reccomended version is 8.0.0 or higher";
} }
return $results; return $results;
} }
function get_results() { function get_results(): array
{
$results = array(); $results = array();
foreach ($this->check_json() as $result) { foreach ($this->check_json() as $result) {

View file

@ -1,7 +1,7 @@
<?php <?php
session_start(); session_start();
// Include server connection // Include server connection
include dirname(__DIR__) . "/server/conn.php"; include dirname(__DIR__) . "/conn.php";
include dirname(__DIR__) . "/app.php"; include dirname(__DIR__) . "/app.php";
use App\Account; use App\Account;

View file

@ -1,7 +1,7 @@
<?php <?php
session_start(); session_start();
// Include server connection // Include server connection
include dirname(__DIR__)."/server/conn.php"; include dirname(__DIR__)."/conn.php";
include dirname(__DIR__)."/app.php"; include dirname(__DIR__)."/app.php";
use App\Account; use App\Account;
@ -36,16 +36,16 @@ if (isset($_POST['submit_delete'])) {
// Attempt to execute the prepared statement // Attempt to execute the prepared statement
if (mysqli_stmt_execute($stmt)) { if (mysqli_stmt_execute($stmt)) {
// See if image is in the directory // See if image is in the directory
if (is_file(dirname(__DIR__)."/images/".$image_array['imagename'])) { if (is_file(dirname(__DIR__)."/usr/images/".$image_array['imagename'])) {
unlink(dirname(__DIR__)."/images/".$image_array['imagename']); unlink(dirname(__DIR__)."/usr/images/".$image_array['imagename']);
} }
// Delete thumbnail if exitsts // Delete thumbnail if exitsts
if (is_file(dirname(__DIR__)."/images/thumbnails/".$image_array['imagename'])) { if (is_file(dirname(__DIR__)."/usr/images/thumbnails/".$image_array['imagename'])) {
unlink(dirname(__DIR__)."/images/thumbnails/".$image_array['imagename']); unlink(dirname(__DIR__)."/usr/images/thumbnails/".$image_array['imagename']);
} }
// Delete preview if exitsts // Delete preview if exitsts
if (is_file(dirname(__DIR__)."/images/previews/".$image_array['imagename'])) { if (is_file(dirname(__DIR__)."/usr/images/previews/".$image_array['imagename'])) {
unlink(dirname(__DIR__)."/images/previews/".$image_array['imagename']); unlink(dirname(__DIR__)."/usr/images/previews/".$image_array['imagename']);
} }
// TP user to the homepage with a success message // TP user to the homepage with a success message
mysqli_query($conn, "INSERT INTO logs (ipaddress, action) VALUES('$user_ip','Deleted image " . $_POST['id'] . "')"); mysqli_query($conn, "INSERT INTO logs (ipaddress, action) VALUES('$user_ip','Deleted image " . $_POST['id'] . "')");

View file

@ -8,9 +8,9 @@
*/ */
session_start(); session_start();
// Include server connection // Include server connection
include dirname(__DIR__)."/server/conn.php"; include dirname(__DIR__)."/conn.php";
include dirname(__DIR__)."/app.php"; include dirname(__DIR__)."/app.php";
include dirname(__DIR__)."/settings/settings.php"; include dirname(__DIR__)."/settings.php";
use App\Make; use App\Make;
@ -21,7 +21,7 @@ if (isset($_POST['submit'])) {
$error = 0; $error = 0;
// Root paths // Root paths
$dir = "../../images/"; $dir = "../../usr/images/";
$thumb_dir = $dir."thumbnails/"; $thumb_dir = $dir."thumbnails/";
$preview_dir = $dir."previews/"; $preview_dir = $dir."previews/";

View file

@ -1,14 +1,14 @@
<?php <?php
$exec_start = microtime(true); $exec_start = microtime(true);
require_once dirname(__DIR__)."/app/server/conn.php"; require_once dirname(__DIR__)."/app/conn.php";
require_once dirname(__DIR__)."/app/app.php"; require_once dirname(__DIR__)."/app/app.php";
require_once dirname(__DIR__)."/app/settings/settings.php"; require_once dirname(__DIR__)."/app/settings.php";
ini_set('post_max_size', $upload_conf['max_filesize']."M"); ini_set('post_max_size', $upload_conf['max_filesize']."M");
ini_set('upload_max_filesize', ($upload_conf['upload_max'] + 1)."M"); ini_set('upload_max_filesize', ($upload_conf['upload_max'] + 1)."M");
if ($user_settings['is_testing'] == true) { if ($user_settings['is_testing']) {
ini_set('display_errors', 1); ini_set('display_errors', 1);
ini_set('display_startup_errors', 1); ini_set('display_startup_errors', 1);
error_reporting(E_ERROR | E_PARSE | E_NOTICE); error_reporting(E_ERROR | E_PARSE | E_NOTICE);

View file

@ -8,6 +8,6 @@
| the default background and accent colour | the default background and accent colour
|------------------------------------------------------------- |-------------------------------------------------------------
*/ */
$user_import = file_get_contents(__DIR__."/manifest.json"); $user_import = file_get_contents(__DIR__."/../usr/conf/manifest.json");
$user_settings = json_decode($user_import, true); $user_settings = json_decode($user_import, true);
$upload_conf = $user_settings["upload"]; $upload_conf = $user_settings["upload"];

View file

@ -1015,7 +1015,7 @@ html {
body { body {
margin: 0 auto; margin: 0 auto;
padding: 1rem; padding: 1rem;
max-width: 1200px; max-width: 1100px;
min-height: calc(100vh - 2rem); min-height: calc(100vh - 2rem);
display: flex; display: flex;
flex-direction: column; flex-direction: column;

View file

@ -45,7 +45,7 @@ body {
margin: 0 auto; margin: 0 auto;
padding: 1rem; padding: 1rem;
max-width: 1200px; max-width: 1100px;
min-height: calc(100vh - 2rem); min-height: calc(100vh - 2rem);

View file

@ -11,10 +11,10 @@
$group_info = new Group; $group_info = new Group;
$diff = new Diff(); $diff = new Diff();
if (!empty($_GET['id']) && isset($_GET['id']) && $_GET['id'] != null) { if (isset($_GET['id'])) {
$group = $group_info->get_group_info($conn, $_GET['id']); $group = $group_info->get_group_info($conn, $_GET['id']);
if (empty($group) || !isset($group)) { if (!isset($group)) {
$_SESSION['err'] = "You followed a broken link"; $_SESSION['err'] = "You followed a broken link";
header("Location: group.php"); header("Location: group.php");
} }
@ -77,10 +77,10 @@
if (!empty($group['image_list'])) echo "<p>Images: ".count(explode(" ", $group['image_list']))."</p>"; if (!empty($group['image_list'])) echo "<p>Images: ".count(explode(" ", $group['image_list']))."</p>";
$upload_time = new DateTime($group['created_on']); $upload_time = new DateTime($group['created_on']);
echo "<p id='updateTime'>Created at: ".$upload_time->format('d/m/Y H:i:s T')."</p>"; echo "<p id='updateTime'>Created at: ".$upload_time->format(format: 'd/m/Y H:i:s T')."</p>";
?> ?>
<script> <script>
var updateDate = new Date('<?php echo $upload_time->format('m/d/Y H:i:s T'); ?>'); var updateDate = new Date('<?php echo $upload_time->format(format: 'm/d/Y H:i:s T'); ?>');
updateDate = updateDate.toLocaleDateString('en-GB', {year: 'numeric', month: 'short', day: 'numeric'}); updateDate = updateDate.toLocaleDateString('en-GB', {year: 'numeric', month: 'short', day: 'numeric'});
$("#updateTime").html("Created at: "+updateDate); $("#updateTime").html("Created at: "+updateDate);
</script> </script>
@ -178,7 +178,7 @@
?> ?>
<div class='group-cover'> <div class='group-cover'>
<span></span> <span></span>
<img <?php if(str_contains($cover_image['tags'], "nsfw")) echo "class='nsfw-blur'"; ?> src='images/<?php echo $cover_image['imagename']; ?>'/> <img <?php if(str_contains($cover_image['tags'], "nsfw")) echo "class='nsfw-blur'"; ?> src='usr/images/<?php echo $cover_image['imagename']; ?>'/>
</div> </div>
<?php <?php
} }
@ -190,10 +190,10 @@
while ($image = mysqli_fetch_array($image_request)) { while ($image = mysqli_fetch_array($image_request)) {
// Getting thumbnail // Getting thumbnail
if (file_exists("images/thumbnails/".$image['imagename'])) { if (file_exists("usr/images/thumbnails/".$image['imagename'])) {
$image_path = "images/thumbnails/".$image['imagename']; $image_path = "usr/images/thumbnails/".$image['imagename'];
} else { } else {
$image_path = "images/".$image['imagename']; $image_path = "usr/images/".$image['imagename'];
} }
if (in_array($image['id'], $image_list)) { if (in_array($image['id'], $image_list)) {
@ -268,10 +268,10 @@
while ($image = mysqli_fetch_array($image_request)) { while ($image = mysqli_fetch_array($image_request)) {
// Getting thumbnail // Getting thumbnail
if (file_exists("images/thumbnails/".$image['imagename'])) { if (file_exists("usr/images/thumbnails/".$image['imagename'])) {
$image_path = "images/thumbnails/".$image['imagename']; $image_path = "usr/images/thumbnails/".$image['imagename'];
} else { } else {
$image_path = "images/".$image['imagename']; $image_path = "usr/images/".$image['imagename'];
} }
// Check for NSFW tag // Check for NSFW tag
@ -331,10 +331,10 @@
// Getting thumbnail // Getting thumbnail
if (!empty($image['imagename'])) { if (!empty($image['imagename'])) {
if (file_exists("images/thumbnails/".$image['imagename'])) { if (file_exists("usr/images/thumbnails/".$image['imagename'])) {
$image_path = "images/thumbnails/".$image['imagename']; $image_path = "usr/images/thumbnails/".$image['imagename'];
} else { } else {
$image_path = "images/".$image['imagename']; $image_path = "usr/images/".$image['imagename'];
} }
} else { } else {
$image_path = "assets/no_image.png"; $image_path = "assets/no_image.png";

View file

@ -22,7 +22,7 @@
header("Location: index.php"); header("Location: index.php");
} }
$image_path = "images/".$image['imagename']; $image_path = "usr/images/".$image['imagename'];
$image_alt = $image['alt']; $image_alt = $image['alt'];
$image_colour = $make_stuff->get_image_colour($image_path); $image_colour = $make_stuff->get_image_colour($image_path);
@ -54,9 +54,9 @@
<img> <img>
</div>"; </div>";
if (is_file("images/previews/".$image['imagename'])) { if (is_file("usr/images/previews/".$image['imagename'])) {
echo "<div class='image-container'> echo "<div class='image-container'>
<img class='image' id='".$image['id']."' src='images/previews/".$image['imagename']."' alt='".$image_alt."'> <img class='image' id='".$image['id']."' src='usr/images/previews/".$image['imagename']."' alt='".$image_alt."'>
<button class='preview-button' onclick='fullScreen()'><img src='assets/icons/scan.svg'></button> <button class='preview-button' onclick='fullScreen()'><img src='assets/icons/scan.svg'></button>
</div>"; </div>";
} else { } else {
@ -164,7 +164,7 @@
</div> </div>
</div> </div>
<!-- Download Image --> <!-- Download Image -->
<a id='download' class='btn btn-good' href='<?php echo "images/".$image['imagename']; ?>' download='<?php echo $image['imagename']; ?>'><img class='svg' src='assets/icons/download.svg'>Download image</a> <a id='download' class='btn btn-good' href='<?php echo "usr/images/".$image['imagename']; ?>' download='<?php echo $image['imagename']; ?>'><img class='svg' src='assets/icons/download.svg'>Download image</a>
<script> <script>
$("#download").click(function() { $("#download").click(function() {
sniffleAdd("Info", "Image download started!", "var(--success)", "assets/icons/download.svg"); sniffleAdd("Info", "Image download started!", "var(--success)", "assets/icons/download.svg");

View file

@ -31,7 +31,7 @@
if (isset($user['pfp_path'])) { if (isset($user['pfp_path'])) {
?> ?>
<script> <script>
sniffleAdd('O hi <?php echo $_SESSION["username"]; ?>', 'You are now logged in, enjoy your stay!', 'var(--success)', 'images/pfp/<?php echo $user["pfp_path"]; ?>'); sniffleAdd('O hi <?php echo $_SESSION["username"]; ?>', 'You are now logged in, enjoy your stay!', 'var(--success)', 'usr/images/pfp/<?php echo $user["pfp_path"]; ?>');
</script> </script>
<?php <?php
} else { } else {
@ -106,10 +106,10 @@
while ($image = mysqli_fetch_array($image_request)) { while ($image = mysqli_fetch_array($image_request)) {
// Getting thumbnail // Getting thumbnail
if (file_exists("images/thumbnails/".$image['imagename'])) { if (file_exists("usr/images/thumbnails/".$image['imagename'])) {
$image_path = "images/thumbnails/".$image['imagename']; $image_path = "usr/images/thumbnails/".$image['imagename'];
} else { } else {
$image_path = "images/".$image['imagename']; $image_path = "usr/images/".$image['imagename'];
} }
// Check for NSFW tag // Check for NSFW tag

View file

@ -32,10 +32,10 @@
<div class="profile-root defaultDecoration defaultSpacing defaultFonts"> <div class="profile-root defaultDecoration defaultSpacing defaultFonts">
<?php <?php
if (is_file("images/pfp/".$user['pfp_path'])) { if (is_file("usr/images/pfp/".$user['pfp_path'])) {
echo "<img src='images/pfp/".$user['pfp_path']."'>"; echo "<img src='usr/images/pfp/".$user['pfp_path']."'>";
$pfp_colour = $make_stuff->get_image_colour("images/pfp/".$user['pfp_path']); $pfp_colour = $make_stuff->get_image_colour("usr/images/pfp/".$user['pfp_path']);
if (empty($pfp_colour)) $pfp_colour = "var(--bg-3)"; if (empty($pfp_colour)) $pfp_colour = "var(--bg-3)";
?> ?>
<style> <style>
@ -86,10 +86,10 @@
while ($image = mysqli_fetch_array($query)) { while ($image = mysqli_fetch_array($query)) {
// Getting thumbnail // Getting thumbnail
if (file_exists("images/thumbnails/".$image['imagename'])) { if (file_exists("usr/images/thumbnails/".$image['imagename'])) {
$image_path = "images/thumbnails/" . $image['imagename']; $image_path = "usr/images/thumbnails/" . $image['imagename'];
} else { } else {
$image_path = "images/" . $image['imagename']; $image_path = "usr/images/" . $image['imagename'];
} }
// Check for NSFW tag // Check for NSFW tag

View file

@ -12,7 +12,7 @@
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="">
<head> <head>
<?php include __DIR__."/assets/ui/header.php"; ?> <?php include __DIR__."/assets/ui/header.php"; ?>
@ -29,8 +29,8 @@
<form id="uploadSubmit" class="flex-down between" method="POST" enctype="multipart/form-data"> <form id="uploadSubmit" class="flex-down between" method="POST" enctype="multipart/form-data">
<input id="image" class="btn btn-neutral" type="file" placeholder="select image UwU"> <input id="image" class="btn btn-neutral" type="file" placeholder="select image UwU">
<br> <br>
<input id="alt" class="btn btn-neutral" placeholder="Description/Alt for image" type='text'> <input id="alt" class="btn btn-neutral" placeholder="Description/Alt for image" type='text'>
<input id="tags" class="btn btn-neutral" placeholder="Tags, seperated by spaces" type='text'> <input id="tags" class="btn btn-neutral" placeholder="Tags, seperated by spaces" type='text'>
<br> <br>
<button id="submit" class="btn btn-good" type="submit"><img class="svg" src="assets/icons/upload.svg">Upload Image</button> <button id="submit" class="btn btn-good" type="submit"><img class="svg" src="assets/icons/upload.svg">Upload Image</button>
</form> </form>

View file

@ -24,7 +24,7 @@
"Eat hotchip and lie" "Eat hotchip and lie"
], ],
"license":"GPL 3.0", "license":"GPL 3.0",
"version": "22.10.12", "version": "22.10.13",
"user_name": "[your name]", "user_name": "[your name]",
"is_testing": true, "is_testing": true,
"upload": { "upload": {