mirror of
https://github.com/Fluffy-Bean/image-gallery.git
synced 2025-06-06 10:23: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
36
account.php
36
account.php
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
require_once __DIR__."/app/required.php";
|
||||
require __DIR__."/app/required.php";
|
||||
|
||||
use App\Account;
|
||||
use App\Diff;
|
||||
|
@ -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,7 +43,12 @@
|
|||
event.preventDefault();
|
||||
// Check if image avalible
|
||||
var file = $("#image").val();
|
||||
if (file != "") {
|
||||
|
||||
if (file == "") {
|
||||
sniffleAdd('Gwha!', 'Pls provide image', 'var(--warning)', 'assets/icons/file-search.svg');
|
||||
return;
|
||||
}
|
||||
|
||||
// Make form
|
||||
var formData = new FormData();
|
||||
|
||||
|
@ -69,9 +74,6 @@
|
|||
// Empty values
|
||||
$("#image").val("");
|
||||
$("#submit").val("");
|
||||
} else {
|
||||
sniffleAdd('Gwha!', 'Pls provide image', 'var(--warning)', 'assets/icons/file-search.svg');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
@ -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
|
||||
|
@ -483,7 +473,7 @@
|
|||
}
|
||||
?>
|
||||
|
||||
<?php require_once __DIR__."/assets/ui/footer.php"; ?>
|
||||
<?php include __DIR__."/assets/ui/footer.php"; ?>
|
||||
</body>
|
||||
|
||||
</html>
|
29
app/app.php
29
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;
|
||||
}
|
||||
}
|
||||
|
@ -33,11 +34,8 @@ class Make {
|
|||
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();
|
||||
|
||||
|
@ -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": {
|
||||
|
|
60
group.php
60
group.php
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
require_once __DIR__."/app/required.php";
|
||||
require __DIR__."/app/required.php";
|
||||
|
||||
use App\Account;
|
||||
use App\Image;
|
||||
|
@ -11,14 +11,6 @@
|
|||
$group_info = new Group;
|
||||
$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,7 +171,6 @@
|
|||
}
|
||||
|
||||
echo "</div>";
|
||||
|
||||
$cover_image = $image_info->get_image_info($conn, $image_list[array_rand($image_list, 1)]);
|
||||
if (!empty($cover_image['imagename'])) {
|
||||
?>
|
||||
|
@ -178,23 +180,10 @@
|
|||
</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
|
||||
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,8 +288,10 @@
|
|||
$e;
|
||||
}
|
||||
}
|
||||
echo "</div>";
|
||||
}
|
||||
} elseif (!isset($_GET['id']) && empty($_GET['id'])) {
|
||||
} 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>
|
||||
|
@ -356,10 +354,10 @@
|
|||
</div>";
|
||||
}
|
||||
}
|
||||
echo "</div>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php require_once __DIR__."/assets/ui/footer.php"; ?>
|
||||
<?php include __DIR__."/assets/ui/footer.php"; ?>
|
||||
</body>
|
||||
</html>
|
180
image.php
180
image.php
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
require_once __DIR__."/app/required.php";
|
||||
require __DIR__."/app/required.php";
|
||||
|
||||
use App\Make;
|
||||
use App\Account;
|
||||
|
@ -10,94 +10,23 @@
|
|||
$image_info = new Image;
|
||||
$user_info = new Account;
|
||||
$diff = new Diff();
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
if (empty($_GET['id']) || !isset($_GET['id']) || $_GET['id'] == null) {
|
||||
$_SESSION['err'] = "You followed a broken link!!!";
|
||||
header("Location: index.php");
|
||||
}
|
||||
|
||||
<head>
|
||||
<?php require_once __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;
|
||||
if (empty($image) || !isset($image)) {
|
||||
$_SESSION['err'] = "Image could not be found!";
|
||||
header("Location: index.php");
|
||||
}
|
||||
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| 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)";
|
||||
}
|
||||
|
||||
if (empty($image_colour)) $image_colour = "var(--bg)";
|
||||
?>
|
||||
<style>
|
||||
.image-container, .fullscreen-image {
|
||||
|
@ -105,39 +34,20 @@
|
|||
}
|
||||
</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";
|
||||
}
|
||||
$author = $user_info->get_user_info($conn, $image['author']);
|
||||
?>
|
||||
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| Check user privilge
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
if ($image_info->image_privilage($image['author']) || $user_info->is_admin($conn, $_SESSION['id'])) {
|
||||
$privilaged = True;
|
||||
} else {
|
||||
$privilaged = False;
|
||||
}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<?php include __DIR__."/assets/ui/header.php"; ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
include __DIR__."/assets/ui/nav.php";
|
||||
|
||||
echo "<div class='fullscreen-image'>
|
||||
<button onclick='closeFullScreen()'><img src='assets/icons/cross.svg'></button>
|
||||
|
@ -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: <a href='profile.php?user=".$image['author']."' class='link'>".$image_author."</a></p>";
|
||||
echo "<p>Author: Deleted user</p>";
|
||||
}
|
||||
} else {
|
||||
echo "<p>Author: <a href='profile.php?user=".$image['author']."' class='link'>".$author['username']."</a></p>";
|
||||
}
|
||||
|
||||
// Image ID
|
||||
|
@ -221,12 +131,7 @@
|
|||
<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 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>
|
||||
|
@ -307,7 +211,7 @@
|
|||
| that can fuck things up"
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
if ($privilaged) {
|
||||
if ($image_info->image_privilage($image['author']) || $user_info->is_admin($conn, $_SESSION['id'])) {
|
||||
?>
|
||||
<!-- Danger zone -->
|
||||
<div class='warningDecoration defaultSpacing defaultFonts'>
|
||||
|
@ -448,18 +352,12 @@
|
|||
</script>
|
||||
<?php
|
||||
}
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| End of displaying all user info
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
echo "</div>";
|
||||
}
|
||||
?>
|
||||
|
||||
<?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,15 +1,5 @@
|
|||
<?php require_once __DIR__."/app/required.php"; ?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<?php require_once __DIR__."/assets/ui/header.php"; ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
require_once __DIR__."/assets/ui/nav.php";
|
||||
require __DIR__."/app/required.php";
|
||||
|
||||
use App\Account;
|
||||
|
||||
|
@ -18,10 +8,19 @@
|
|||
// Check if the user is logged in, otherwise redirect to login page
|
||||
if ($user_info->is_loggedin() != true) {
|
||||
header("location: account.php");
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<?php include __DIR__."/assets/ui/header.php"; ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php include __DIR__."/assets/ui/nav.php"; ?>
|
||||
|
||||
<div class="warningDecoration defaultSpacing defaultFonts">
|
||||
<h2>Reset Password</h2>
|
||||
<p>After reset, you will be kicked out to login again</p>
|
||||
|
@ -42,6 +41,7 @@
|
|||
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>
|
31
profile.php
31
profile.php
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
require_once __DIR__."/app/required.php";
|
||||
require __DIR__."/app/required.php";
|
||||
|
||||
use App\Make;
|
||||
use App\Account;
|
||||
|
@ -9,10 +9,13 @@
|
|||
$user_info = new Account();
|
||||
$diff = new Diff();
|
||||
|
||||
if (!isset($_GET['user']) || empty($_GET['user'])) {
|
||||
header("Location: index.php");
|
||||
} else if (isset($_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,15 +24,14 @@
|
|||
<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']."'>";
|
||||
|
||||
|
@ -54,22 +56,13 @@
|
|||
<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>";
|
||||
}
|
||||
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>
|
||||
|
||||
<?php
|
||||
} else {
|
||||
echo "<img src='assets/no_image.png'>
|
||||
<h2>Failed to load user info</h2>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
@ -128,9 +121,7 @@
|
|||
</script>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
require_once __DIR__."/assets/ui/footer.php";
|
||||
include __DIR__."/assets/ui/footer.php";
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
|
|
32
upload.php
32
upload.php
|
@ -1,29 +1,25 @@
|
|||
<?php require_once __DIR__."/app/required.php"; ?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<?php require_once __DIR__."/assets/ui/header.php"; ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
require_once __DIR__."/assets/ui/nav.php";
|
||||
require __DIR__."/app/required.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
|
||||
header("location: account.php");
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<?php include __DIR__."/assets/ui/header.php"; ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php include __DIR__."/assets/ui/nav.php"; ?>
|
||||
|
||||
<div class="upload-root defaultDecoration defaultSpacing defaultFonts">
|
||||
<h2>Upload image</h2>
|
||||
<p>In this world you have 2 choices, to upload a really cute picture of an animal or fursuit, or something other than those 2 things.</p>
|
||||
|
@ -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