mirror of
https://github.com/Fluffy-Bean/image-gallery.git
synced 2025-06-05 09:53:12 +00:00
Removing unessesary if statements and cleanup
This commit is contained in:
parent
fbbc953ba6
commit
6407669a5a
10 changed files with 489 additions and 593 deletions
158
account.php
158
account.php
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
require_once __DIR__."/app/required.php";
|
||||
require __DIR__."/app/required.php";
|
||||
|
||||
use App\Account;
|
||||
use App\Diff;
|
||||
use App\Sanity;
|
||||
|
||||
$user_info = new Account();
|
||||
$diff = new Diff();
|
||||
$sanity = new Sanity();
|
||||
$user_info = new Account();
|
||||
$diff = new Diff();
|
||||
$sanity = new Sanity();
|
||||
|
||||
$profile_info = $user_info->get_user_info($conn, $_SESSION['id']);
|
||||
?>
|
||||
|
@ -15,10 +15,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<?php require_once __DIR__."/assets/ui/header.php"; ?>
|
||||
<?php include __DIR__."/assets/ui/header.php"; ?>
|
||||
</head>
|
||||
<body>
|
||||
<?php require_once __DIR__."/assets/ui/nav.php"; ?>
|
||||
<?php include __DIR__."/assets/ui/nav.php"; ?>
|
||||
|
||||
<?php
|
||||
if ($user_info->is_loggedin()) {
|
||||
|
@ -43,35 +43,37 @@
|
|||
event.preventDefault();
|
||||
// Check if image avalible
|
||||
var file = $("#image").val();
|
||||
if (file != "") {
|
||||
// Make form
|
||||
var formData = new FormData();
|
||||
|
||||
// Get image
|
||||
var image_data = $("#image").prop("files")[0];
|
||||
formData.append("image", image_data);
|
||||
// Submit data
|
||||
var submit = $("#pfpSubmit").val();
|
||||
formData.append("pfp_submit", submit);
|
||||
|
||||
// Upload the information
|
||||
$.ajax({
|
||||
url: 'app/account/account.php',
|
||||
type: 'post',
|
||||
data: formData,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function(response) {
|
||||
$("#newSniff").html(response);
|
||||
}
|
||||
});
|
||||
|
||||
// Empty values
|
||||
$("#image").val("");
|
||||
$("#submit").val("");
|
||||
} else {
|
||||
if (file == "") {
|
||||
sniffleAdd('Gwha!', 'Pls provide image', 'var(--warning)', 'assets/icons/file-search.svg');
|
||||
return;
|
||||
}
|
||||
|
||||
// Make form
|
||||
var formData = new FormData();
|
||||
|
||||
// Get image
|
||||
var image_data = $("#image").prop("files")[0];
|
||||
formData.append("image", image_data);
|
||||
// Submit data
|
||||
var submit = $("#pfpSubmit").val();
|
||||
formData.append("pfp_submit", submit);
|
||||
|
||||
// Upload the information
|
||||
$.ajax({
|
||||
url: 'app/account/account.php',
|
||||
type: 'post',
|
||||
data: formData,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function(response) {
|
||||
$("#newSniff").html(response);
|
||||
}
|
||||
});
|
||||
|
||||
// Empty values
|
||||
$("#image").val("");
|
||||
$("#submit").val("");
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
@ -89,18 +91,18 @@
|
|||
</div>
|
||||
<script>
|
||||
function deleteAccount() {
|
||||
var header = "Are you very very sure?";
|
||||
var description = "This CANNOT be undone, be very carefull with your decition!!!";
|
||||
var actionBox = "<button class='btn btn-bad' onclick='deleteAccountConfirm()'><img class='svg' src='assets/icons/trash.svg'>Delete account (keep posts)</button>\
|
||||
var header = "Are you very very sure?";
|
||||
var description = "This CANNOT be undone, be very carefull with your decition!!!";
|
||||
var actionBox = "<button class='btn btn-bad' onclick='deleteAccountConfirm()'><img class='svg' src='assets/icons/trash.svg'>Delete account (keep posts)</button>\
|
||||
<button class='btn btn-bad' onclick='deleteAccountConfirmFull()'><img class='svg' src='assets/icons/trash.svg'>Delete account (delete posts)</button>";
|
||||
|
||||
flyoutShow(header, description, actionBox);
|
||||
}
|
||||
|
||||
function deleteAccountConfirm () {
|
||||
var header = "Deleting just your account!";
|
||||
var description = "This is your last warning, so enter your password now.";
|
||||
var actionBox = "<form id='accountDelete' method='POST'>\
|
||||
var header = "Deleting just your account!";
|
||||
var description = "This is your last warning, so enter your password now.";
|
||||
var actionBox = "<form id='accountDelete' method='POST'>\
|
||||
<input id='accountDeletePassword' class='btn btn-neutral' type='password' name='password' placeholder='Password'>\
|
||||
<button id='accountDeleteSubmit' class='btn btn-bad' type='submit'><img class='svg' src='assets/icons/trash.svg'>Delete account (keep posts)</button>\
|
||||
</form>";
|
||||
|
@ -109,8 +111,8 @@
|
|||
|
||||
$("#accountDelete").submit(function(event) {
|
||||
event.preventDefault();
|
||||
var accountDeletePassword = $("#accountDeletePassword").val();
|
||||
var accountDeleteSubmit = $("#accountDeleteSubmit").val();
|
||||
var accountDeletePassword = $("#accountDeletePassword").val();
|
||||
var accountDeleteSubmit = $("#accountDeleteSubmit").val();
|
||||
$("#newSniff").load("app/account/account.php", {
|
||||
delete_id: <?php echo $_SESSION['id']; ?>,
|
||||
full: 'false',
|
||||
|
@ -121,9 +123,9 @@
|
|||
}
|
||||
|
||||
function deleteAccountConfirmFull () {
|
||||
var header = "Deleting EVERYTHINGGGGG";
|
||||
var description = "This is your last warning, so enter your password now.";
|
||||
var actionBox = "<form id='accountDeleteFull' method='POST'>\
|
||||
var header = "Deleting EVERYTHINGGGGG";
|
||||
var description = "This is your last warning, so enter your password now.";
|
||||
var actionBox = "<form id='accountDeleteFull' method='POST'>\
|
||||
<input id='accountDeletePassword' class='btn btn-neutral' type='password' name='password' placeholder='Password'>\
|
||||
<button id='accountDeleteSubmit' class='btn btn-bad' type='submit'><img class='svg' src='assets/icons/trash.svg'>Delete account (delete posts)</button>\
|
||||
</form>";
|
||||
|
@ -132,8 +134,8 @@
|
|||
|
||||
$("#accountDeleteFull").submit(function(event) {
|
||||
event.preventDefault();
|
||||
var accountDeletePassword = $("#accountDeletePassword").val();
|
||||
var accountDeleteSubmit = $("#accountDeleteSubmit").val();
|
||||
var accountDeletePassword = $("#accountDeletePassword").val();
|
||||
var accountDeleteSubmit = $("#accountDeleteSubmit").val();
|
||||
$("#newSniff").load("app/account/account.php", {
|
||||
delete_id: <?php echo $_SESSION['id']; ?>,
|
||||
full: 'true',
|
||||
|
@ -175,10 +177,7 @@
|
|||
|
||||
<div id="logs" class="logs tabcontent">
|
||||
<div class="log">
|
||||
<p>ID</p>
|
||||
<p>User IP</p>
|
||||
<p>Action</p>
|
||||
<p>Time</p>
|
||||
<p>ID</p> <p>User IP</p> <p>Action</p> <p>Time</p>
|
||||
</div>
|
||||
<?php
|
||||
// Reading images from table
|
||||
|
@ -202,11 +201,7 @@
|
|||
|
||||
<div id="bans" class="bans tabcontent">
|
||||
<div class="ban">
|
||||
<p>ID</p>
|
||||
<p>User IP</p>
|
||||
<p>Reason</p>
|
||||
<p>Lenght</p>
|
||||
<p>Time</p>
|
||||
<p>ID</p> <p>User IP</p> <p>Reason</p> <p>Lenght</p> <p>Time</p>
|
||||
</div>
|
||||
<?php
|
||||
// Reading images from table
|
||||
|
@ -236,12 +231,7 @@
|
|||
<div id="users" class="user-settings tabcontent">
|
||||
|
||||
<div class="user">
|
||||
<p>ID</p>
|
||||
<p>Username</p>
|
||||
<p>Last Modified</p>
|
||||
<p>User Options</p>
|
||||
<p></p>
|
||||
<p></p>
|
||||
<p>ID</p> <p>Username</p> <p>Last Modified</p> <p>User Options</p> <p></p> <p></p>
|
||||
</div>
|
||||
<?php
|
||||
// Reading images from table
|
||||
|
@ -280,9 +270,9 @@
|
|||
?>
|
||||
<script>
|
||||
function userResetPassword(id, username) {
|
||||
var header = "UwU whats the new passywassy code?";
|
||||
var description = "Do this only if "+username+" has forgotten their password, DO NOT abuse this power";
|
||||
var actionBox = "<form id='userResetPasswordForm' method='POST' enctype='multipart/form-data'>\
|
||||
var header = "UwU whats the new passywassy code?";
|
||||
var description = "Do this only if "+username+" has forgotten their password, DO NOT abuse this power";
|
||||
var actionBox = "<form id='userResetPasswordForm' method='POST' enctype='multipart/form-data'>\
|
||||
<input id='userNewPassword' class='btn btn-neutral' type='password' name='new_password' placeholder='New Password'>\
|
||||
<input id='userConfirmPassword' class='btn btn-neutral' type='password' name='confirm_password' placeholder='Confirm Password'>\
|
||||
<br>\
|
||||
|
@ -293,10 +283,10 @@
|
|||
|
||||
$("#userResetPasswordForm").submit(function(event) {
|
||||
event.preventDefault();
|
||||
var new_password = $("#userNewPassword").val();
|
||||
var confirm_password = $("#userConfirmPassword").val();
|
||||
var submit = $("#userPasswordSubmit").val();
|
||||
var userId = $("#userPasswordSubmit").val();
|
||||
var new_password = $("#userNewPassword").val();
|
||||
var confirm_password = $("#userConfirmPassword").val();
|
||||
var submit = $("#userPasswordSubmit").val();
|
||||
var userId = $("#userPasswordSubmit").val();
|
||||
$("#newSniff").load("app/account/account.php", {
|
||||
new_password: new_password,
|
||||
confirm_password: confirm_password,
|
||||
|
@ -307,9 +297,9 @@
|
|||
}
|
||||
|
||||
function userDelete(id, username) {
|
||||
var header = "Are you very very sure?";
|
||||
var description = "This CANNOT be undone, be very carefull with your decition... There is no second warning!";
|
||||
var actionBox = "<form id='userDelete' method='POST'>\
|
||||
var header = "Are you very very sure?";
|
||||
var description = "This CANNOT be undone, be very carefull with your decition... There is no second warning!";
|
||||
var actionBox = "<form id='userDelete' method='POST'>\
|
||||
<button id='userDeleteSubmit' class='btn btn-bad' type='submit' value='"+id+"'><img class='svg' src='assets/icons/trash.svg'>Delete user "+username+" (keep posts)</button>\
|
||||
</form>\
|
||||
<form id='userDeleteFull' method='POST'>\
|
||||
|
@ -320,8 +310,8 @@
|
|||
|
||||
$("#userDelete").submit(function(event) {
|
||||
event.preventDefault();
|
||||
var id = $("#userDeleteSubmit").val();
|
||||
var userDeleteSubmit = $("#userDeleteSubmit").val();
|
||||
var id = $("#userDeleteSubmit").val();
|
||||
var userDeleteSubmit = $("#userDeleteSubmit").val();
|
||||
$("#newSniff").load("app/account/account.php", {
|
||||
delete_id: id,
|
||||
full: false,
|
||||
|
@ -341,9 +331,9 @@
|
|||
}
|
||||
|
||||
function userToggleAdmin(id, username) {
|
||||
var header = "With great power comes great responsibility...";
|
||||
var description = "Do you trust this user? With admin permitions they can cause a whole lot of damage to this place, so make sure you're very very sure";
|
||||
var actionBox = "<form id='toggleAdminConfirm' method='POST'>\
|
||||
var header = "With great power comes great responsibility...";
|
||||
var description = "Do you trust this user? With admin permitions they can cause a whole lot of damage to this place, so make sure you're very very sure";
|
||||
var actionBox = "<form id='toggleAdminConfirm' method='POST'>\
|
||||
<button id='toggleAdminSubmit' class='btn btn-bad' type='submit' value='"+id+"'>Toggle "+username+"'s admin status</button>\
|
||||
</form>";
|
||||
|
||||
|
@ -424,9 +414,9 @@
|
|||
<script>
|
||||
$("#loginForm").submit(function(event) {
|
||||
event.preventDefault();
|
||||
var username = $("#loginUsername").val();
|
||||
var password = $("#loginPassword").val();
|
||||
var submit = $("#loginSubmit").val();
|
||||
var username = $("#loginUsername").val();
|
||||
var password = $("#loginPassword").val();
|
||||
var submit = $("#loginSubmit").val();
|
||||
$("#newSniff").load("app/account/account.php", {
|
||||
username: username,
|
||||
password: password,
|
||||
|
@ -454,11 +444,11 @@
|
|||
<script>
|
||||
$("#signupForm").submit(function(event) {
|
||||
event.preventDefault();
|
||||
var username = $("#signupUsername").val();
|
||||
var password = $("#signupPassword").val();
|
||||
var confirm_password = $("#signupPasswordConfirm").val();
|
||||
var token = $("#signupToken").val();
|
||||
var submit = $("#signupSubmit").val();
|
||||
var username = $("#signupUsername").val();
|
||||
var password = $("#signupPassword").val();
|
||||
var confirm_password = $("#signupPasswordConfirm").val();
|
||||
var token = $("#signupToken").val();
|
||||
var submit = $("#signupSubmit").val();
|
||||
$("#newSniff").load("app/account/account.php", {
|
||||
username: username,
|
||||
password: password,
|
||||
|
@ -483,7 +473,7 @@
|
|||
}
|
||||
?>
|
||||
|
||||
<?php require_once __DIR__."/assets/ui/footer.php"; ?>
|
||||
<?php include __DIR__."/assets/ui/footer.php"; ?>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -7,8 +7,8 @@ use App\Account;
|
|||
use App\Make;
|
||||
|
||||
$make_stuff = new Make();
|
||||
$user_info = new Account();
|
||||
$user_ip = $user_info->get_ip();
|
||||
$user_info = new Account();
|
||||
$user_ip = $user_info->get_ip();
|
||||
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
|
|
51
app/app.php
51
app/app.php
|
@ -3,6 +3,7 @@ namespace App;
|
|||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
use Imagick;
|
||||
|
||||
class Make {
|
||||
/*
|
||||
|
@ -15,12 +16,12 @@ class Make {
|
|||
*/
|
||||
function thumbnail($image_path, $thumbnail_path, $resolution) {
|
||||
try {
|
||||
$thumbnail = new \Imagick($image_path);
|
||||
$thumbnail = new Imagick($image_path);
|
||||
$thumbnail->resizeImage($resolution,null,null,1,null);
|
||||
$thumbnail->writeImage($thumbnail_path);
|
||||
|
||||
return "success";
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
return $e;
|
||||
}
|
||||
}
|
||||
|
@ -31,15 +32,12 @@ class Make {
|
|||
Returns clean string of words with equal white space between it
|
||||
*/
|
||||
function tags($string) {
|
||||
$string = str_replace('-', '_', $string);
|
||||
$string = preg_replace('/[^A-Za-z0-9\_ ]/', '', $string);
|
||||
|
||||
$string = strtolower($string);
|
||||
|
||||
$string = preg_replace('/ +/', ' ', $string);
|
||||
|
||||
$string = explode(' ', $string);
|
||||
$string_list = array();
|
||||
$string = str_replace('-', '_', $string);
|
||||
$string = preg_replace('/[^A-Za-z0-9\_ ]/', '', $string);
|
||||
$string = strtolower($string);
|
||||
$string = preg_replace('/ +/', ' ', $string);
|
||||
$string = explode(' ', $string);
|
||||
$string_list = array();
|
||||
|
||||
foreach ($string as $i) {
|
||||
if (!in_array($i, $string_list)) {
|
||||
|
@ -287,9 +285,9 @@ class Group {
|
|||
|
||||
class Diff {
|
||||
function time($past_time, $full_date = false) {
|
||||
$now = new \DateTime;
|
||||
$ago = new \DateTime($past_time);
|
||||
$diff = $now->diff($ago);
|
||||
$now = new \DateTime;
|
||||
$ago = new \DateTime($past_time);
|
||||
$diff = $now->diff($ago);
|
||||
|
||||
$diff->w = floor($diff->d / 7);
|
||||
$diff->d -= $diff->w * 7;
|
||||
|
@ -332,8 +330,8 @@ class Sanity {
|
|||
if (!isset($manifest['upload']['rename_to']) || empty($manifest['upload']['rename_to'])) {
|
||||
$results[] = "Critical: manifest.json doesnt know what to rename your files to";
|
||||
} else {
|
||||
$rename_to = $manifest['upload']['rename_to'];
|
||||
$rename_rate = 0;
|
||||
$rename_to = $manifest['upload']['rename_to'];
|
||||
$rename_rate = 0;
|
||||
|
||||
if (str_contains($rename_to, '{{autoinc}}')) $rename_rate = 5;
|
||||
if (str_contains($rename_to, '{{time}}')) $rename_rate = 5;
|
||||
|
@ -381,7 +379,26 @@ class Sanity {
|
|||
function check_version() {
|
||||
$results = array();
|
||||
|
||||
if (PHP_VERSION_ID < 50102) {
|
||||
$url = "https://raw.githubusercontent.com/Fluffy-Bean/image-gallery/main/app/settings/manifest.json";
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
$manifest_repo = json_decode($result, true);
|
||||
$manifest_local = json_decode(file_get_contents(__DIR__."/settings/manifest.json"), true);
|
||||
|
||||
if ($manifest_local['version'] < $manifest_repo['version']) {
|
||||
$results[] = "Critical: You are not running the latest version of the app v".$manifest_repo['version']."";
|
||||
} else if ($manifest_local['version'] > $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) {
|
||||
$results[] = "Critical: Your current version of PHP is ".PHP_VERSION.". The reccomended version is 8.1.2";
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
"Eat hotchip and lie"
|
||||
],
|
||||
"license":"GPL 3.0",
|
||||
"version": "22.09.29",
|
||||
"version": "22.10.5",
|
||||
"user_name": "[your name]",
|
||||
"is_testing": true,
|
||||
"upload": {
|
||||
|
|
194
group.php
194
group.php
|
@ -1,24 +1,16 @@
|
|||
<?php
|
||||
require_once __DIR__."/app/required.php";
|
||||
require __DIR__."/app/required.php";
|
||||
|
||||
use App\Account;
|
||||
use App\Image;
|
||||
use App\Group;
|
||||
use App\Diff;
|
||||
|
||||
$user_info = new Account;
|
||||
$user_info = new Account;
|
||||
$image_info = new Image;
|
||||
$group_info = new Group;
|
||||
$diff = new Diff();
|
||||
$diff = new Diff();
|
||||
|
||||
if (isset($_GET['id'])) {
|
||||
$group = $group_info->get_group_info($conn, $_GET['id']);
|
||||
|
||||
if (!isset($group) || empty($group)) {
|
||||
header("Location: group.php");
|
||||
$_SESSION['err'] = "You followed a broken link";
|
||||
}
|
||||
}
|
||||
if (isset($_SESSION['err'])) {
|
||||
?>
|
||||
<script>
|
||||
|
@ -27,16 +19,27 @@
|
|||
<?php
|
||||
unset($_SESSION['err']);
|
||||
}
|
||||
|
||||
if (!empty($_GET['id']) && isset($_GET['id']) && $_GET['id'] != null) {
|
||||
$group = $group_info->get_group_info($conn, $_GET['id']);
|
||||
|
||||
if (empty($group) || !isset($group)) {
|
||||
$_SESSION['err'] = "You followed a broken link";
|
||||
header("Location: group.php");
|
||||
}
|
||||
|
||||
$group['created_at'] = new DateTime($group['created_at']);
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<?php require_once __DIR__."/assets/ui/header.php"; ?>
|
||||
<?php include __DIR__."/assets/ui/header.php"; ?>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
require_once __DIR__."/assets/ui/nav.php";
|
||||
include __DIR__."/assets/ui/nav.php";
|
||||
|
||||
if (isset($_SESSION['msg'])) {
|
||||
?>
|
||||
|
@ -49,7 +52,7 @@
|
|||
?>
|
||||
|
||||
<?php
|
||||
if (isset($_GET['id'])) {
|
||||
if (isset($_GET['id']) && !empty($_GET['id'])) {
|
||||
$image_list = array_reverse(explode(" ", $group['image_list']));
|
||||
|
||||
echo "<div class='group-banner defaultDecoration defaultSpacing defaultFonts'>
|
||||
|
@ -168,33 +171,19 @@
|
|||
}
|
||||
|
||||
echo "</div>";
|
||||
|
||||
$cover_image = $image_info->get_image_info($conn, $image_list[array_rand($image_list, 1)]);
|
||||
if (!empty($cover_image['imagename'])) {
|
||||
?>
|
||||
<div class='group-cover'>
|
||||
<span></span>
|
||||
<img <?php if(str_contains($cover_image['tags'], "nsfw")) echo "class='nsfw-blur'"; ?> src='images/<?php echo $cover_image['imagename']; ?>'/>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
$cover_image = $image_info->get_image_info($conn, $image_list[array_rand($image_list, 1)]);
|
||||
if (!empty($cover_image['imagename'])) {
|
||||
?>
|
||||
<div class='group-cover'>
|
||||
<span></span>
|
||||
<img <?php if(str_contains($cover_image['tags'], "nsfw")) echo "class='nsfw-blur'"; ?> src='images/<?php echo $cover_image['imagename']; ?>'/>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
echo "</div>";
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
if (empty($group['image_list']) && $_GET['mode'] != "edit" && !empty($_GET['id'])) {
|
||||
echo "<div class='info-text defaultFonts' style='text-align: center !important;'>
|
||||
<h1>Nothing here!</h1>
|
||||
<p>There are no images in the group, add some!</p>
|
||||
</div>";
|
||||
echo "<div id='gallery' class='gallery-root defaultDecoration' style='display: none;'>";
|
||||
} else {
|
||||
echo "<div id='gallery' class='gallery-root defaultDecoration' >";
|
||||
}
|
||||
if (isset($_GET['id']) && !empty($_GET['id'])) {
|
||||
if (isset($_GET['mode']) && $_GET['mode'] == "edit") {
|
||||
if ($_GET['mode'] == "edit") {
|
||||
echo "<div class='gallery-root defaultDecoration'>";
|
||||
$image_request = mysqli_query($conn, "SELECT * FROM images ORDER BY id DESC");
|
||||
|
||||
while ($image = mysqli_fetch_array($image_request)) {
|
||||
|
@ -262,7 +251,14 @@
|
|||
});
|
||||
</script>
|
||||
<?php
|
||||
} else {
|
||||
echo "</div>";
|
||||
} elseif (empty($image_list)) {
|
||||
echo "<div class='info-text defaultFonts' style='text-align: center !important;'>
|
||||
<h1>Nothing here!</h1>
|
||||
<p>There are no images in the group, add some!</p>
|
||||
</div>";
|
||||
} else {
|
||||
echo "<div class='gallery-root defaultDecoration'>";
|
||||
foreach ($image_list as $image) {
|
||||
// Reading images from table
|
||||
try {
|
||||
|
@ -292,74 +288,76 @@
|
|||
$e;
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif (!isset($_GET['id']) && empty($_GET['id'])) {
|
||||
if ($_SESSION["loggedin"]) {
|
||||
echo "<div class='group-make'>
|
||||
<button id='createGroup'><img class='svg' src='assets/icons/plus.svg'><span>Make new group</span></button>
|
||||
</div>";
|
||||
echo "</div>";
|
||||
}
|
||||
} else {
|
||||
echo "<div class='gallery-root defaultDecoration'>";
|
||||
if ($_SESSION["loggedin"]) {
|
||||
echo "<div class='group-make'>
|
||||
<button id='createGroup'><img class='svg' src='assets/icons/plus.svg'><span>Make new group</span></button>
|
||||
</div>";
|
||||
|
||||
?>
|
||||
<script>
|
||||
$('#createGroup').click(function() {
|
||||
$("#newSniff").load("app/image/group.php", {
|
||||
new_group_submit: "uwu"
|
||||
});
|
||||
?>
|
||||
<script>
|
||||
$('#createGroup').click(function() {
|
||||
$("#newSniff").load("app/image/group.php", {
|
||||
new_group_submit: "uwu"
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
$group_list = mysqli_query($conn, "SELECT * FROM groups ORDER BY id DESC");
|
||||
$group_list = mysqli_query($conn, "SELECT * FROM groups ORDER BY id DESC");
|
||||
|
||||
if (mysqli_num_rows($group_list) == 0 && !$_SESSION["loggedin"]) {
|
||||
?>
|
||||
<style>
|
||||
.gallery-root {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
$('body').append("<div class='info-text defaultFonts' style='text-align: center !important;'><h1>There are no groups yet</h1><p>Login to make a group!</p></div>");
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
if (mysqli_num_rows($group_list) == 0 && !$_SESSION["loggedin"]) {
|
||||
?>
|
||||
<style>
|
||||
.gallery-root {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
$('body').append("<div class='info-text defaultFonts' style='text-align: center !important;'><h1>There are no groups yet</h1><p>Login to make a group!</p></div>");
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
foreach ($group_list as $group) {
|
||||
$image_list = array_reverse(explode(" ", $group['image_list']));
|
||||
$image = $image_info->get_image_info($conn, $image_list[array_rand($image_list, 1)]);
|
||||
foreach ($group_list as $group) {
|
||||
$image_list = array_reverse(explode(" ", $group['image_list']));
|
||||
$image = $image_info->get_image_info($conn, $image_list[array_rand($image_list, 1)]);
|
||||
|
||||
// Getting thumbnail
|
||||
if (!empty($image['imagename'])) {
|
||||
if (file_exists("images/thumbnails/".$image['imagename'])) {
|
||||
$image_path = "images/thumbnails/".$image['imagename'];
|
||||
} else {
|
||||
$image_path = "images/".$image['imagename'];
|
||||
}
|
||||
// Getting thumbnail
|
||||
if (!empty($image['imagename'])) {
|
||||
if (file_exists("images/thumbnails/".$image['imagename'])) {
|
||||
$image_path = "images/thumbnails/".$image['imagename'];
|
||||
} else {
|
||||
$image_path = "assets/no_image.png";
|
||||
}
|
||||
|
||||
$image_path = "images/".$image['imagename'];
|
||||
}
|
||||
} else {
|
||||
$image_path = "assets/no_image.png";
|
||||
}
|
||||
|
||||
|
||||
// Check for NSFW tag
|
||||
if (str_contains($image['tags'], "nsfw")) {
|
||||
echo "<div class='gallery-item group-item'>
|
||||
<a href='group.php?id=".$group['id']."' class='nsfw-warning gallery-group'><img class='svg' src='assets/icons/warning_red.svg'><span>NSFW</span></a>
|
||||
<a href='group.php?id=".$group['id']."'><img class='gallery-image nsfw-blur' loading='lazy' src='".$image_path."' id='".$group['id']."'></a>
|
||||
<a href='group.php?id=".$group['id']."' class='group-name'>".$group['group_name']."</a>
|
||||
</div>";
|
||||
} else {
|
||||
echo "<div class='gallery-item group-item'>
|
||||
<a href='group.php?id=".$group['id']."' class='gallery-group'></a>
|
||||
<a href='group.php?id=".$group['id']."'><img class='gallery-image' loading='lazy' src='".$image_path."' id='".$group['id']."'></a>
|
||||
<a href='group.php?id=".$group['id']."' class='group-name'>".$group['group_name']."</a>
|
||||
</div>";
|
||||
}
|
||||
// Check for NSFW tag
|
||||
if (str_contains($image['tags'], "nsfw")) {
|
||||
echo "<div class='gallery-item group-item'>
|
||||
<a href='group.php?id=".$group['id']."' class='nsfw-warning gallery-group'><img class='svg' src='assets/icons/warning_red.svg'><span>NSFW</span></a>
|
||||
<a href='group.php?id=".$group['id']."'><img class='gallery-image nsfw-blur' loading='lazy' src='".$image_path."' id='".$group['id']."'></a>
|
||||
<a href='group.php?id=".$group['id']."' class='group-name'>".$group['group_name']."</a>
|
||||
</div>";
|
||||
} else {
|
||||
echo "<div class='gallery-item group-item'>
|
||||
<a href='group.php?id=".$group['id']."' class='gallery-group'></a>
|
||||
<a href='group.php?id=".$group['id']."'><img class='gallery-image' loading='lazy' src='".$image_path."' id='".$group['id']."'></a>
|
||||
<a href='group.php?id=".$group['id']."' class='group-name'>".$group['group_name']."</a>
|
||||
</div>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
echo "</div>";
|
||||
}
|
||||
?>
|
||||
|
||||
<?php require_once __DIR__."/assets/ui/footer.php"; ?>
|
||||
<?php include __DIR__."/assets/ui/footer.php"; ?>
|
||||
</body>
|
||||
</html>
|
502
image.php
502
image.php
|
@ -1,143 +1,53 @@
|
|||
<?php
|
||||
require_once __DIR__."/app/required.php";
|
||||
require __DIR__."/app/required.php";
|
||||
|
||||
use App\Make;
|
||||
use App\Account;
|
||||
use App\Image;
|
||||
use App\Diff;
|
||||
|
||||
$make_stuff = new Make();
|
||||
$image_info = new Image;
|
||||
$user_info = new Account;
|
||||
$diff = new Diff();
|
||||
$make_stuff = new Make();
|
||||
$image_info = new Image;
|
||||
$user_info = new Account;
|
||||
$diff = new Diff();
|
||||
|
||||
if (empty($_GET['id']) || !isset($_GET['id']) || $_GET['id'] == null) {
|
||||
$_SESSION['err'] = "You followed a broken link!!!";
|
||||
header("Location: index.php");
|
||||
}
|
||||
|
||||
$image = $image_info->get_image_info($conn, $_GET['id']);
|
||||
if (empty($image) || !isset($image)) {
|
||||
$_SESSION['err'] = "Image could not be found!";
|
||||
header("Location: index.php");
|
||||
}
|
||||
|
||||
$image_path = "images/".$image['imagename'];
|
||||
$image_alt = $image['alt'];
|
||||
$image_colour = $make_stuff->get_image_colour($image_path);
|
||||
|
||||
if (empty($image_colour)) $image_colour = "var(--bg)";
|
||||
?>
|
||||
<style>
|
||||
.image-container, .fullscreen-image {
|
||||
background-color: <?php echo $image_colour; ?>33 !important;
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
|
||||
$author = $user_info->get_user_info($conn, $image['author']);
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<?php require_once __DIR__."/assets/ui/header.php"; ?>
|
||||
<?php include __DIR__."/assets/ui/header.php"; ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
require_once __DIR__."/assets/ui/nav.php";
|
||||
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| Get image ID
|
||||
|-------------------------------------------------------------
|
||||
| Image ID should be written in the URL of the page as ?id=69
|
||||
| If ID cannot be obtained, give error. ID going here ^^
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
if (isset($_GET['id'])) {
|
||||
// Get all image info
|
||||
$image = $image_info->get_image_info($conn, $_GET['id']);
|
||||
|
||||
// Check if image is avalible
|
||||
if (!empty($image['imagename']) && isset($image['imagename'])) {
|
||||
$image_present = True;
|
||||
} else {
|
||||
?>
|
||||
<script>
|
||||
sniffleAdd('Woops', 'Something happened, either image with the ID <?php echo $_GET['id']; ?> was deleted or never existed, either way it could not be found!', 'var(--warning)', 'assets/icons/cross.svg');
|
||||
</script>
|
||||
<?php
|
||||
$image_present = False;
|
||||
}
|
||||
} else {
|
||||
?>
|
||||
<script>
|
||||
sniffleAdd('Where is da image?', 'The link you followed seems to be broken, or there was some other error, who knows!', 'var(--warning)', 'assets/icons/cross.svg');
|
||||
</script>
|
||||
<?php
|
||||
$image_present = False;
|
||||
}
|
||||
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| Image verification
|
||||
|-------------------------------------------------------------
|
||||
| Doublechecking if all information on images exists, if yes
|
||||
| display it, otherwise don't display at all or replace with
|
||||
| blank or filler info
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
if ($image_present) {
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| Check user details
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
if (isset($image['author'])) {
|
||||
// Get all information on the user
|
||||
$user = $user_info->get_user_info($conn, $image['author']);
|
||||
|
||||
if (isset($user['username'])) {
|
||||
$image_author = $user['username'];
|
||||
} else {
|
||||
$image_author = "Deleted User";
|
||||
}
|
||||
} else {
|
||||
$image_author = "No author";
|
||||
}
|
||||
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| Check if image path is good
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
if (isset($image['imagename'])) {
|
||||
$image_path = "images/".$image['imagename'];
|
||||
$image_alt = $image['alt'];
|
||||
|
||||
$image_colour = $make_stuff->get_image_colour($image_path);
|
||||
if (!empty($image_colour)) {
|
||||
$image_colour = $image_colour;
|
||||
} else {
|
||||
$image_colour = "var(--bg)";
|
||||
}
|
||||
?>
|
||||
<style>
|
||||
.image-container, .fullscreen-image {
|
||||
background-color: <?php echo $image_colour; ?>33 !important;
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
} else {
|
||||
$image_path = "assets/no_image.png";
|
||||
$image_alt = "No image could be found, sowwy";
|
||||
}
|
||||
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| If description not set or empty, replace with filler
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
if (!isset($image_alt) || empty($image_alt)) {
|
||||
$image_alt = "No description avalible";
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| Image was not present
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
$image_path = "assets/no_image.png";
|
||||
$image_alt = "No image could be found, sowwy";
|
||||
}
|
||||
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| Check user privilge
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
if ($image_info->image_privilage($image['author']) || $user_info->is_admin($conn, $_SESSION['id'])) {
|
||||
$privilaged = True;
|
||||
} else {
|
||||
$privilaged = False;
|
||||
}
|
||||
include __DIR__."/assets/ui/nav.php";
|
||||
|
||||
echo "<div class='fullscreen-image'>
|
||||
<button onclick='closeFullScreen()'><img src='assets/icons/cross.svg'></button>
|
||||
|
@ -146,13 +56,13 @@
|
|||
|
||||
if (is_file("images/previews/".$image['imagename'])) {
|
||||
echo "<div class='image-container'>
|
||||
<img class='image' id='".$image['id']."' src='images/previews/".$image['imagename']."' alt='".$image_alt."'>
|
||||
<button class='preview-button' onclick='fullScreen()'><img src='assets/icons/scan.svg'></button>
|
||||
<img class='image' id='".$image['id']."' src='images/previews/".$image['imagename']."' alt='".$image_alt."'>
|
||||
<button class='preview-button' onclick='fullScreen()'><img src='assets/icons/scan.svg'></button>
|
||||
</div>";
|
||||
} else {
|
||||
echo "<div class='image-container'>
|
||||
<img class='image' id='".$image['id']."' src='".$image_path."' alt='".$image_alt."'>
|
||||
<button class='preview-button' onclick='fullScreen()'><img src='assets/icons/scan.svg'></button>
|
||||
<img class='image' id='".$image['id']."' src='".$image_path."' alt='".$image_alt."'>
|
||||
<button class='preview-button' onclick='fullScreen()'><img src='assets/icons/scan.svg'></button>
|
||||
</div>";
|
||||
}
|
||||
|
||||
|
@ -180,22 +90,18 @@
|
|||
}, 500);
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| Start of displaying all info on image
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
if ($image_present) {
|
||||
?>
|
||||
|
||||
<div class="defaultDecoration defaultSpacing defaultFonts">
|
||||
<h2>Description</h2>
|
||||
<p><?php echo htmlentities($image_alt, ENT_QUOTES); ?></p>
|
||||
<?php
|
||||
if (empty($image['description'])) {
|
||||
echo "<p>No description provided.</p>";
|
||||
} else {
|
||||
echo "<p>".$image['description']."</p>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="image-detail defaultDecoration defaultSpacing defaultFonts">
|
||||
<h2>Details</h2>
|
||||
<div>
|
||||
|
@ -203,9 +109,13 @@
|
|||
<?php
|
||||
// User
|
||||
if (empty($image['author'])) {
|
||||
echo "<p>Author: ".$image_author."</p>";
|
||||
if (isset($author['username'])) {
|
||||
echo "<p>Author: ".$author['username']."</p>";
|
||||
} else {
|
||||
echo "<p>Author: Deleted user</p>";
|
||||
}
|
||||
} else {
|
||||
echo "<p>Author: <a href='profile.php?user=".$image['author']."' class='link'>".$image_author."</a></p>";
|
||||
echo "<p>Author: <a href='profile.php?user=".$image['author']."' class='link'>".$author['username']."</a></p>";
|
||||
}
|
||||
|
||||
// Image ID
|
||||
|
@ -220,13 +130,8 @@
|
|||
?>
|
||||
<script>
|
||||
// Updating time to Viewers local
|
||||
var updateDate = new Date('<?php echo $upload_time->format('m/d/Y H:i:s T'); ?>');
|
||||
var format = {year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
};
|
||||
var updateDate = new Date('<?php echo $upload_time->format('m/d/Y H:i:s T'); ?>');
|
||||
var format = {year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit'};
|
||||
|
||||
updateDate = updateDate.toLocaleDateString('en-GB', format);
|
||||
|
||||
|
@ -271,7 +176,6 @@
|
|||
<script>
|
||||
function copyLink() {
|
||||
navigator.clipboard.writeText(window.location.href);
|
||||
|
||||
sniffleAdd("Info", "Link has been copied!", "var(--success)", "assets/icons/clipboard-text.svg");
|
||||
}
|
||||
</script>
|
||||
|
@ -280,186 +184,180 @@
|
|||
<div class="defaultDecoration defaultSpacing defaultFonts">
|
||||
<h2>Tags</h2>
|
||||
<div class="tags">
|
||||
<?php
|
||||
// Get image tags
|
||||
if (isset($image['tags']) && !empty($image['tags'])) {
|
||||
$image_tags_array = explode(" ", $image['tags']);
|
||||
foreach ($image_tags_array as $tag) {
|
||||
if ($tag == "nsfw") {
|
||||
echo "<p id='tag' class='tag btn-bad'>".$tag."</p>";
|
||||
} else {
|
||||
echo "<p id='tag' class='tag btn-good'>".$tag."</p>";
|
||||
<?php
|
||||
// Get image tags
|
||||
if (isset($image['tags']) && !empty($image['tags'])) {
|
||||
$image_tags_array = explode(" ", $image['tags']);
|
||||
foreach ($image_tags_array as $tag) {
|
||||
if ($tag == "nsfw") {
|
||||
echo "<p id='tag' class='tag btn-bad'>".$tag."</p>";
|
||||
} else {
|
||||
echo "<p id='tag' class='tag btn-good'>".$tag."</p>";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo "<p>No tags present</p>";
|
||||
}
|
||||
} else {
|
||||
echo "<p>No tags present</p>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| Check if user is privilaged,
|
||||
|-------------------------------------------------------------
|
||||
| If yes, grant them access to the Danger zone, or "the place
|
||||
| that can fuck things up"
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
if ($privilaged) {
|
||||
?>
|
||||
<!-- Danger zone -->
|
||||
<div class='warningDecoration defaultSpacing defaultFonts'>
|
||||
<h2>Danger zone</h2>
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| Check if user is privilaged,
|
||||
|-------------------------------------------------------------
|
||||
| If yes, grant them access to the Danger zone, or "the place
|
||||
| that can fuck things up"
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
if ($image_info->image_privilage($image['author']) || $user_info->is_admin($conn, $_SESSION['id'])) {
|
||||
?>
|
||||
<!-- Danger zone -->
|
||||
<div class='warningDecoration defaultSpacing defaultFonts'>
|
||||
<h2>Danger zone</h2>
|
||||
|
||||
<!--
|
||||
|-------------------------------------------------------------
|
||||
| Delete
|
||||
|-------------------------------------------------------------
|
||||
| sus
|
||||
| I cannot describe the anxiety this gives me. pls help
|
||||
|-------------------------------------------------------------
|
||||
-->
|
||||
<button id='deleteButton' class='btn btn-bad'><img class='svg' src='assets/icons/trash.svg'>Delete image</button>
|
||||
<script>
|
||||
$('#deleteButton').click(function() {
|
||||
var header = "Are you sure?";
|
||||
var description = "Deleting this image is pernament, there is no going back after this!!!!!";
|
||||
var actionBox = "<form id='deleteConfirm' method='POST'>\
|
||||
<button id='deleteSubmit' class='btn btn-bad' type='submit'><img class='svg' src='assets/icons/trash.svg'>Delete image</button>\
|
||||
</form>";
|
||||
flyoutShow(header, description, actionBox);
|
||||
|
||||
$("#deleteConfirm").submit(function(event) {
|
||||
event.preventDefault();
|
||||
var deleteSubmit = $("#deleteSubmit").val();
|
||||
$("#newSniff").load("app/image/image.php", {
|
||||
id: <?php echo $_GET['id']; ?>,
|
||||
submit_delete: deleteSubmit
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<!--
|
||||
<!--
|
||||
|-------------------------------------------------------------
|
||||
| Edit Description
|
||||
| Delete
|
||||
|-------------------------------------------------------------
|
||||
| Most people reading through the code will probably say how
|
||||
| shit it is. YOU HAVE NO FUCKING CLUE HOW LONG THIS TOOK ME
|
||||
| TO FIGURE OUT. i hate js.
|
||||
| sus
|
||||
| I cannot describe the anxiety this gives me. pls help
|
||||
|-------------------------------------------------------------
|
||||
-->
|
||||
<button id='descriptionButton' class='btn btn-bad'><img class='svg' src='assets/icons/edit.svg'>Edit description</button>
|
||||
<script>
|
||||
$('#descriptionButton').click(function() {
|
||||
var header = "Enter new Description/Alt";
|
||||
var description = "Whatcha gonna put in there 👀";
|
||||
var actionBox = "<form id='descriptionConfirm' action='app/image/edit_description.php' method='POST'>\
|
||||
<input id='descriptionInput' class='btn btn-neutral space-bottom' type='text' placeholder='Description/Alt for image'>\
|
||||
<button id='descriptionSubmit' class='btn btn-bad' type='submit'><img class='svg' src='assets/icons/edit.svg'>Update information</button>\
|
||||
</form>";
|
||||
flyoutShow(header, description, actionBox);
|
||||
|
||||
$('#descriptionInput').val("<?php if ($image_alt != "No description avalible") echo str_replace('"', '\"', $image_alt); ?>");
|
||||
|
||||
$("#descriptionConfirm").submit(function(event) {
|
||||
event.preventDefault();
|
||||
var descriptionInput = $("#descriptionInput").val();
|
||||
var descriptionSubmit = $("#descriptionSubmit").val();
|
||||
$("#newSniff").load("app/image/image.php", {
|
||||
id: <?php echo $_GET['id']; ?>,
|
||||
input: descriptionInput,
|
||||
submit_description: descriptionSubmit
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<!--
|
||||
|-------------------------------------------------------------
|
||||
| Edit Tags
|
||||
|-------------------------------------------------------------
|
||||
| Literally no amount of work will get tags/lists to play well
|
||||
| with SQL so I gave up and made my own shitty system. It
|
||||
| works but once I re-add the search function this will make
|
||||
| anyone cry. I am so sorry.
|
||||
|-------------------------------------------------------------
|
||||
-->
|
||||
<button id='tagsButton' class='btn btn-bad'><img class='svg' src='assets/icons/tag.svg'>Add image tags</button>
|
||||
<script>
|
||||
$('#tagsButton').click(function() {
|
||||
var header = "Tags";
|
||||
var description = "Tags are seperated by spaces, only alowed characters are a-z and underscores, all hyphens are converted to underscores. There are also special tags such as nsfw that'll blur images in the overview";
|
||||
var actionBox = "<form id='tagsConfirm' action='app/image/edit_tags.php' method='POST'>\
|
||||
<input id='tagsInput' class='btn btn-neutral space-bottom' type='text' placeholder='Tags are seperated by spaces'>\
|
||||
<button id='tagsSubmit' class='btn btn-bad' type='submit'><img class='svg' src='assets/icons/edit.svg'>Edit tags</button>\
|
||||
</form>";
|
||||
flyoutShow(header, description, actionBox);
|
||||
|
||||
$('#tagsInput').val("<?php echo $image['tags']; ?>");
|
||||
|
||||
$("#tagsConfirm").submit(function(event) {
|
||||
event.preventDefault();
|
||||
var tagsInput = $("#tagsInput").val();
|
||||
var tagsSubmit = $("#tagsSubmit").val();
|
||||
$("#newSniff").load("app/image/image.php", {
|
||||
id: <?php echo $_GET['id']; ?>,
|
||||
input: tagsInput,
|
||||
submit_tags: tagsSubmit
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<!--
|
||||
|-------------------------------------------------------------
|
||||
| Edit Author
|
||||
|-------------------------------------------------------------
|
||||
| You must be a super cool person to see this section ;3
|
||||
|-------------------------------------------------------------
|
||||
-->
|
||||
<?php
|
||||
if ($user_info->is_admin($conn, $_SESSION['id'])) {
|
||||
?>
|
||||
<button id='authorButton' class='btn btn-bad'><img class='svg' src='assets/icons/edit.svg'>Edit author</button>
|
||||
-->
|
||||
<button id='deleteButton' class='btn btn-bad'><img class='svg' src='assets/icons/trash.svg'>Delete image</button>
|
||||
<script>
|
||||
$('#authorButton').click(function() {
|
||||
var header = "Who owns the image?????";
|
||||
var description = "Enter ID of image owner";
|
||||
var actionBox = "<form id='authorConfirm' action='app/image/edit_author.php' method='POST'>\
|
||||
<input id='authorInput' class='btn btn-neutral space-bottom' type='text' placeholder='le author'>\
|
||||
<button id='authorSubmit' class='btn btn-bad' type='submit'><img class='svg' src='assets/icons/edit.svg'>Edit author</button>\
|
||||
$('#deleteButton').click(function() {
|
||||
var header = "Are you sure?";
|
||||
var description = "Deleting this image is pernament, there is no going back after this!!!!!";
|
||||
var actionBox = "<form id='deleteConfirm' method='POST'>\
|
||||
<button id='deleteSubmit' class='btn btn-bad' type='submit'><img class='svg' src='assets/icons/trash.svg'>Delete image</button>\
|
||||
</form>";
|
||||
flyoutShow(header, description, actionBox);
|
||||
|
||||
$("#authorConfirm").submit(function(event) {
|
||||
$("#deleteConfirm").submit(function(event) {
|
||||
event.preventDefault();
|
||||
var authorInput = $("#authorInput").val();
|
||||
var authorSubmit = $("#authorSubmit").val();
|
||||
var deleteSubmit = $("#deleteSubmit").val();
|
||||
$("#newSniff").load("app/image/image.php", {
|
||||
id: <?php echo $_GET['id']; ?>,
|
||||
input: authorInput,
|
||||
submit_author: authorSubmit
|
||||
submit_delete: deleteSubmit
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
<!--
|
||||
|-------------------------------------------------------------
|
||||
| Edit Description
|
||||
|-------------------------------------------------------------
|
||||
| Most people reading through the code will probably say how
|
||||
| shit it is. YOU HAVE NO FUCKING CLUE HOW LONG THIS TOOK ME
|
||||
| TO FIGURE OUT. i hate js.
|
||||
|-------------------------------------------------------------
|
||||
-->
|
||||
<button id='descriptionButton' class='btn btn-bad'><img class='svg' src='assets/icons/edit.svg'>Edit description</button>
|
||||
<script>
|
||||
$('#descriptionButton').click(function() {
|
||||
var header = "Enter new Description/Alt";
|
||||
var description = "Whatcha gonna put in there 👀";
|
||||
var actionBox = "<form id='descriptionConfirm' action='app/image/edit_description.php' method='POST'>\
|
||||
<input id='descriptionInput' class='btn btn-neutral space-bottom' type='text' placeholder='Description/Alt for image'>\
|
||||
<button id='descriptionSubmit' class='btn btn-bad' type='submit'><img class='svg' src='assets/icons/edit.svg'>Update information</button>\
|
||||
</form>";
|
||||
flyoutShow(header, description, actionBox);
|
||||
|
||||
$('#descriptionInput').val("<?php if ($image_alt != "No description avalible") echo str_replace('"', '\"', $image_alt); ?>");
|
||||
|
||||
$("#descriptionConfirm").submit(function(event) {
|
||||
event.preventDefault();
|
||||
var descriptionInput = $("#descriptionInput").val();
|
||||
var descriptionSubmit = $("#descriptionSubmit").val();
|
||||
$("#newSniff").load("app/image/image.php", {
|
||||
id: <?php echo $_GET['id']; ?>,
|
||||
input: descriptionInput,
|
||||
submit_description: descriptionSubmit
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<!--
|
||||
|-------------------------------------------------------------
|
||||
| Edit Tags
|
||||
|-------------------------------------------------------------
|
||||
| Literally no amount of work will get tags/lists to play well
|
||||
| with SQL so I gave up and made my own shitty system. It
|
||||
| works but once I re-add the search function this will make
|
||||
| anyone cry. I am so sorry.
|
||||
|-------------------------------------------------------------
|
||||
-->
|
||||
<button id='tagsButton' class='btn btn-bad'><img class='svg' src='assets/icons/tag.svg'>Add image tags</button>
|
||||
<script>
|
||||
$('#tagsButton').click(function() {
|
||||
var header = "Tags";
|
||||
var description = "Tags are seperated by spaces, only alowed characters are a-z and underscores, all hyphens are converted to underscores. There are also special tags such as nsfw that'll blur images in the overview";
|
||||
var actionBox = "<form id='tagsConfirm' action='app/image/edit_tags.php' method='POST'>\
|
||||
<input id='tagsInput' class='btn btn-neutral space-bottom' type='text' placeholder='Tags are seperated by spaces'>\
|
||||
<button id='tagsSubmit' class='btn btn-bad' type='submit'><img class='svg' src='assets/icons/edit.svg'>Edit tags</button>\
|
||||
</form>";
|
||||
flyoutShow(header, description, actionBox);
|
||||
|
||||
$('#tagsInput').val("<?php echo $image['tags']; ?>");
|
||||
|
||||
$("#tagsConfirm").submit(function(event) {
|
||||
event.preventDefault();
|
||||
var tagsInput = $("#tagsInput").val();
|
||||
var tagsSubmit = $("#tagsSubmit").val();
|
||||
$("#newSniff").load("app/image/image.php", {
|
||||
id: <?php echo $_GET['id']; ?>,
|
||||
input: tagsInput,
|
||||
submit_tags: tagsSubmit
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<!--
|
||||
|-------------------------------------------------------------
|
||||
| Edit Author
|
||||
|-------------------------------------------------------------
|
||||
| You must be a super cool person to see this section ;3
|
||||
|-------------------------------------------------------------
|
||||
-->
|
||||
<?php
|
||||
if ($user_info->is_admin($conn, $_SESSION['id'])) {
|
||||
?>
|
||||
<button id='authorButton' class='btn btn-bad'><img class='svg' src='assets/icons/edit.svg'>Edit author</button>
|
||||
<script>
|
||||
$('#authorButton').click(function() {
|
||||
var header = "Who owns the image?????";
|
||||
var description = "Enter ID of image owner";
|
||||
var actionBox = "<form id='authorConfirm' action='app/image/edit_author.php' method='POST'>\
|
||||
<input id='authorInput' class='btn btn-neutral space-bottom' type='text' placeholder='le author'>\
|
||||
<button id='authorSubmit' class='btn btn-bad' type='submit'><img class='svg' src='assets/icons/edit.svg'>Edit author</button>\
|
||||
</form>";
|
||||
flyoutShow(header, description, actionBox);
|
||||
|
||||
$("#authorConfirm").submit(function(event) {
|
||||
event.preventDefault();
|
||||
var authorInput = $("#authorInput").val();
|
||||
var authorSubmit = $("#authorSubmit").val();
|
||||
$("#newSniff").load("app/image/image.php", {
|
||||
id: <?php echo $_GET['id']; ?>,
|
||||
input: authorInput,
|
||||
submit_author: authorSubmit
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| End of displaying all user info
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
}
|
||||
?>
|
||||
|
||||
<?php require_once __DIR__."/assets/ui/footer.php"; ?>
|
||||
<?php include __DIR__."/assets/ui/footer.php"; ?>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -44,6 +44,14 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
if (isset($_SESSION['err'])) {
|
||||
?>
|
||||
<script>
|
||||
sniffleAdd('Error', '<?php echo $_SESSION["err"]; ?>', 'var(--warning)', 'assets/icons/cross.svg');
|
||||
</script>
|
||||
<?php
|
||||
unset($_SESSION['err']);
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
|
|
@ -1,26 +1,25 @@
|
|||
<?php require_once __DIR__."/app/required.php"; ?>
|
||||
<?php
|
||||
require __DIR__."/app/required.php";
|
||||
|
||||
use App\Account;
|
||||
|
||||
$user_info = new Account();
|
||||
|
||||
// Check if the user is logged in, otherwise redirect to login page
|
||||
if ($user_info->is_loggedin() != true) {
|
||||
header("location: account.php");
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<?php require_once __DIR__."/assets/ui/header.php"; ?>
|
||||
<?php include __DIR__."/assets/ui/header.php"; ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
require_once __DIR__."/assets/ui/nav.php";
|
||||
|
||||
use App\Account;
|
||||
|
||||
$user_info = new Account();
|
||||
|
||||
// Check if the user is logged in, otherwise redirect to login page
|
||||
if ($user_info->is_loggedin() != true) {
|
||||
header("location: account.php");
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<?php include __DIR__."/assets/ui/nav.php"; ?>
|
||||
|
||||
<div class="warningDecoration defaultSpacing defaultFonts">
|
||||
<h2>Reset Password</h2>
|
||||
|
@ -39,9 +38,10 @@
|
|||
<script>
|
||||
$("#passwordForm").submit(function(event) {
|
||||
event.preventDefault();
|
||||
var new_password = $("#newPassword").val();
|
||||
var confirm_password = $("#confirmPassword").val();
|
||||
var submit = $("#passwordSubmit").val();
|
||||
var new_password = $("#newPassword").val();
|
||||
var confirm_password = $("#confirmPassword").val();
|
||||
var submit = $("#passwordSubmit").val();
|
||||
|
||||
$("#newSniff").load("app/account/account.php", {
|
||||
new_password: new_password,
|
||||
confirm_password: confirm_password,
|
||||
|
@ -50,7 +50,7 @@
|
|||
});
|
||||
</script>
|
||||
|
||||
<?php require_once __DIR__."/assets/ui/footer.php"; ?>
|
||||
<?php include __DIR__."/assets/ui/footer.php"; ?>
|
||||
</body>
|
||||
|
||||
</html>
|
91
profile.php
91
profile.php
|
@ -1,18 +1,21 @@
|
|||
<?php
|
||||
require_once __DIR__."/app/required.php";
|
||||
require __DIR__."/app/required.php";
|
||||
|
||||
use App\Make;
|
||||
use App\Account;
|
||||
use App\Diff;
|
||||
|
||||
$make_stuff = new Make();
|
||||
$user_info = new Account();
|
||||
$diff = new Diff();
|
||||
$user_info = new Account();
|
||||
$diff = new Diff();
|
||||
|
||||
if (!isset($_GET['user']) || empty($_GET['user'])) {
|
||||
header("Location: index.php");
|
||||
} else if (isset($_GET['user'])) {
|
||||
$user = $user_info->get_user_info($conn, $_GET['user']);
|
||||
if (!isset($_GET['user']) || empty($_GET['user'])) header("Location: index.php");
|
||||
|
||||
$user = $user_info->get_user_info($conn, $_GET['user']);
|
||||
if (empty($user) || !isset($user)) {
|
||||
$_SESSION['err'] = "You have followed a broken link to a profile that does not exist!";
|
||||
header("Location: index.php");
|
||||
}
|
||||
|
||||
$join_date = new DateTime($user['created_at']);
|
||||
?>
|
||||
|
@ -21,55 +24,45 @@
|
|||
<html>
|
||||
|
||||
<head>
|
||||
<?php require_once __DIR__."/assets/ui/header.php"; ?>
|
||||
<?php include __DIR__."/assets/ui/header.php"; ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php require_once __DIR__."/assets/ui/nav.php"; ?>
|
||||
<?php include __DIR__."/assets/ui/nav.php"; ?>
|
||||
|
||||
<div class="profile-root defaultDecoration defaultSpacing defaultFonts">
|
||||
<?php
|
||||
if (!empty($user)) {
|
||||
if (is_file("images/pfp/".$user['pfp_path'])) {
|
||||
echo "<img src='images/pfp/".$user['pfp_path']."'>";
|
||||
if (is_file("images/pfp/".$user['pfp_path'])) {
|
||||
echo "<img src='images/pfp/".$user['pfp_path']."'>";
|
||||
|
||||
$pfp_colour = $make_stuff->get_image_colour("images/pfp/".$user['pfp_path']);
|
||||
if (empty($pfp_colour)) $pfp_colour = "var(--bg-3)";
|
||||
?>
|
||||
<style>
|
||||
.profile-root {
|
||||
background-image: linear-gradient(to right, <?php echo $pfp_colour; ?>, var(--bg-3), var(--bg-3)) !important;
|
||||
}
|
||||
@media (max-width: 669px) {
|
||||
.profile-root {
|
||||
background-image: linear-gradient(to bottom, <?php echo $pfp_colour; ?>, var(--bg-3)) !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
} else {
|
||||
echo "<img src='assets/no_image.png'>";
|
||||
}
|
||||
$pfp_colour = $make_stuff->get_image_colour("images/pfp/".$user['pfp_path']);
|
||||
if (empty($pfp_colour)) $pfp_colour = "var(--bg-3)";
|
||||
?>
|
||||
<h2>
|
||||
<?php
|
||||
echo $user['username'];
|
||||
if ($user_info->is_admin($conn, $user['id'])) {
|
||||
echo "<span style='color: var(--accent); font-size: 16px; margin-left: 0.5rem;'>Admin</span>";
|
||||
<style>
|
||||
.profile-root {
|
||||
background-image: linear-gradient(to right, <?php echo $pfp_colour; ?>, var(--bg-3), var(--bg-3)) !important;
|
||||
}
|
||||
@media (max-width: 669px) {
|
||||
.profile-root {
|
||||
background-image: linear-gradient(to bottom, <?php echo $pfp_colour; ?>, var(--bg-3)) !important;
|
||||
}
|
||||
?>
|
||||
</h2>
|
||||
<div class="profile-info">
|
||||
<p id="joinDate">Member since: <?php echo $join_date->format('d/m/Y T'); ?></p>
|
||||
<p id="postCount"></p>
|
||||
</div>
|
||||
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
} else {
|
||||
echo "<img src='assets/no_image.png'>
|
||||
<h2>Failed to load user info</h2>";
|
||||
echo "<img src='assets/no_image.png'>";
|
||||
}
|
||||
?>
|
||||
<h2>
|
||||
<?php
|
||||
echo $user['username'];
|
||||
if ($user_info->is_admin($conn, $user['id'])) echo "<span style='color: var(--accent); font-size: 16px; margin-left: 0.5rem;'>Admin</span>";
|
||||
?>
|
||||
</h2>
|
||||
<div class="profile-info">
|
||||
<p id="joinDate">Member since: <?php echo $join_date->format('d/m/Y T'); ?></p>
|
||||
<p id="postCount"></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
@ -100,12 +93,12 @@
|
|||
// Check for NSFW tag
|
||||
if (str_contains($image['tags'], "nsfw")) {
|
||||
echo "<div class='gallery-item'>
|
||||
<a href='image.php?id=" . $image['id'] . "' class='nsfw-warning'><img class='svg' src='assets/icons/warning_red.svg'><span>NSFW</span></a>
|
||||
<a href='image.php?id=" . $image['id'] . "'><img class='gallery-image nsfw-blur' loading='lazy' src='" . $image_path . "' id='" . $image['id'] . "'></a>
|
||||
</div>";
|
||||
<a href='image.php?id=" . $image['id'] . "' class='nsfw-warning'><img class='svg' src='assets/icons/warning_red.svg'><span>NSFW</span></a>
|
||||
<a href='image.php?id=" . $image['id'] . "'><img class='gallery-image nsfw-blur' loading='lazy' src='" . $image_path . "' id='" . $image['id'] . "'></a>
|
||||
</div>";
|
||||
} else {
|
||||
echo "<div class='gallery-item'>
|
||||
<a href='image.php?id=" . $image['id'] . "'><img class='gallery-image' loading='lazy' src='" . $image_path . "' id='" . $image['id'] . "'></a>
|
||||
<a href='image.php?id=" . $image['id'] . "'><img class='gallery-image' loading='lazy' src='" . $image_path . "' id='" . $image['id'] . "'></a>
|
||||
</div>";
|
||||
}
|
||||
}
|
||||
|
@ -128,9 +121,7 @@
|
|||
</script>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
require_once __DIR__."/assets/ui/footer.php";
|
||||
include __DIR__."/assets/ui/footer.php";
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
|
|
34
upload.php
34
upload.php
|
@ -1,28 +1,24 @@
|
|||
<?php require_once __DIR__."/app/required.php"; ?>
|
||||
<?php
|
||||
require __DIR__."/app/required.php";
|
||||
|
||||
use App\Account;
|
||||
$user_info = new Account();
|
||||
|
||||
// Check if user is logged in
|
||||
if (!$user_info->is_loggedin()) {
|
||||
header("location: account.php");
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<?php require_once __DIR__."/assets/ui/header.php"; ?>
|
||||
<?php include __DIR__."/assets/ui/header.php"; ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
require_once __DIR__."/assets/ui/nav.php";
|
||||
|
||||
use App\Account;
|
||||
$user_info = new Account();
|
||||
|
||||
// Check if user is logged in
|
||||
if (!$user_info->is_loggedin()) {
|
||||
?>
|
||||
<script>
|
||||
sniffleAdd('Who are you!', 'You must be logged in to upload things, sowwy!', 'var(--alert)', 'assets/icons/cross.svg');
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?php include __DIR__."/assets/ui/nav.php"; ?>
|
||||
|
||||
<div class="upload-root defaultDecoration defaultSpacing defaultFonts">
|
||||
<h2>Upload image</h2>
|
||||
|
@ -42,8 +38,6 @@
|
|||
const [file] = image.files
|
||||
if (file) {
|
||||
imagePreview.src = URL.createObjectURL(file);
|
||||
} else {
|
||||
imagePreview.src = "assets/no_image.png";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -95,7 +89,7 @@
|
|||
});
|
||||
</script>
|
||||
|
||||
<?php require_once __DIR__."/assets/ui/footer.php"; ?>
|
||||
<?php include __DIR__."/assets/ui/footer.php"; ?>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue