Merge pull request #8 from Fluffy-Bean/beta

Beta
This commit is contained in:
Michal 2022-09-29 15:13:49 +01:00 committed by GitHub
commit 55335113db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 3138 additions and 1562 deletions

122
README.md
View file

@ -1,115 +1,19 @@
# OnlyLegs!
The only gallery made by a maned wolf.
<div align="center">
<img src="onlylegs.jpg" width="621px" align="center">
<p></p>
</div>
## How to setup
### Downloading & installing
#### Path
Download this project and move it into your website(s) folder. Usually under ```/var/www/html/``` on Linux.
# Only legs!
The only gallery made by a maned wolf
#### Imagik
You will need to install the image-magik PHP plugin for thumbnail creation, on Ubuntu its as easy as ```apt install php-imagick```.
## Special thanks
* Carty: Kickstarting and helping with the SQL/PHP development
* Jeetix: Helping patch holes in some features
* mrHDash, Verg, Fennec, Carty, Jeetix and everyone else for helping with early bug testing
* <a class='link' href="https://phosphoricons.com/">Phosphor</a> for providing nice SVG icons
#### PHP
This project also requires PHP 8.1 and was made with Ubuntu 22.04 LTS and Nginx in mind, so I reccommend running this gallery on such.
With Nginx, you may need to configure the ```/etc/nginx/sites-available/default.conf``` for the new version on PHP. You must find the allowed index list and add index.php as such:
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
Then you have to find the ```fastcgi-php``` configuration, you will need to uncomment the lines and update the php version to 8.1 and now the config should look like the following:
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
}
### Database setup
If you made it this far, congrats! We're not even close to done. Next you will need to setup your database. If you're running a seperate server for databases, that'll also work.
#### Note:
If you run into errors with connecting to the database, you may need to install php-mysqli, on Ubuntu that command will be ```apt install php-mysqli```.
You first need to head over to ```app/server/conn.php``` and set the correct information, if you're using localhost, this should be the following details:
- localhost
- (username)
- (password)
- Gallery
I recommend using a database name such as Gallery, but others should work just as well.
I also recommend not using root for this and setting up a user specifically for this, but I will not go through the process of making a such user here.
You will next need to setup the following 5 tables:
#### Images
CREATE TABLE images (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
imagename VARCHAR(50) UNIQUE, alt VARCHAR(255),
tags VARCHAR(255),
author VARCHAR(50),
last_modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
upload_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
#### Users
CREATE TABLE users (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(50) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL, admin bool,
last_modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
#### Tokens
CREATE TABLE tokens (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
code VARCHAR(50) NOT NULL,
used BOOL,
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
#### Logs
CREATE TABLE logs (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
ipaddress VARCHAR(16) NOT NULL,
action VARCHAR(255),
time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
#### Bans
CREATE TABLE bans (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
ipaddress VARCHAR(16) NOT NULL,
reason VARCHAR(255),
time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
length VARCHAR(255) NOT NULL,
permanent BOOL NOT NULL
);
### Manifest
In the ```app/settings/manifest.json``` you have a list of infomation about your website. You must change ```user_name``` to your prefered name, ```is_testing``` to false (or anything else) as that is used for development and ```upload_max``` to your prefered file size max in MBs.
### Images Folder
Since there is currently no automated install script for this gallery, you'll have to make your own folders to hold images in. To do that, go into the root directory of the gallery and type the following commands:
mkdir images
mkdir images/thumbnails
mkdir images/previews
This'll make 3 new folders. That is where all the uploaded images will be held in. But before you go anywhere, you will need to ```chown``` them so Nginx can access them, a simple way of doing this is ```chown www-data:www-data -R images``` this will give Nginx access to the folder and all of its content.
### Creating an account
For now, there is no automated way of doing this, so you will have to go into your database on a terminal and type the following command ```INSERT INTO tokens (code, used) VALUES('UserToken', False)```. You have now made a token that you can use to make an account with.
Head over to the Login section off the app and click the Need an account button, from there you can enter your own details. Once you get to the token section enter ```UserToken```. And with that, you have now set up your own image gallery!
## Usage
### Admin
As an admin, you can do things such as modifying other people's posts, reseting users passwords and checking logs for sussy behaviour. With that, use these tools with respect to others and don't abuse them.
If you trust someone enough, you can set them to a moderator through the settings > users > toggle admin. You can tell who is an admin by the green highlight to the left of their name.
### Images
Uploading images is as simple as choosing the image you want to upload, then clicking upload! Keep in mind that not all formats play well as this gallery uses Imagik to generate thumbnails and preview images, so images such as GIFs do not work as of now. Supported file formats include JPG, JPEG, PNG and WEBP.
You should also keep in mind the file size, by default images of 20MBs should be able to get uploaded. But if you run into issues, either raise the file size in the ```manifest.json``` or locate your ```php.ini``` on your webserver and raise the ```upload_max_filesize``` and ```post_max_size``` to a same or greater value.
## How to install/setup
Check out the wiki tab!
## License
This project is under the GNU v3 License

View file

@ -66,7 +66,7 @@
z-index: 1;
transform: scale(1);
opacity: 1;
transition: transform 1s cubic-bezier(.19,1,.22,1), opacity 0.25s cubic-bezier(.19,1,.22,1);
transition: transform 1s cubic-bezier(.08,.82,.16,1.01), opacity 0.25s cubic-bezier(.08,.82,.16,1.01);
}
.sniffle-notification:nth-of-type(2) {
z-index: -1;

View file

@ -1,44 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<?php require_once __DIR__."/ui/header.php"; ?>
</head>
<body>
<?php
require_once __DIR__."/ui/required.php";
require_once __DIR__."/ui/nav.php";
?>
<div class="about-root">
<h1><?php echo $user_settings['website_name']; ?></h1>
<p><?php echo $user_settings['website_description']; ?></p>
<p>Version <?php echo $user_settings['version']; ?></p>
<br>
<h2>TOS</h2>
<p><?php echo $user_settings['tos']; ?></p>
<p>This project is protected under the <?php echo $user_settings['license']; ?> license by <?php echo $user_settings['user_name']; ?></p>
<br>
<h2>Credits to development</h2>
<p>Carty: Kickstarting development and SQL/PHP development</p>
<p>Jeetix: Helping patch holes in some features</p>
<p>mrHDash, Verg, Fennec, Carty, Jeetix and everyone else for helping with early bug testing</p>
<p><a class='link' href="https://phosphoricons.com/">Phosphor</a> for providing nice SVG icons</p>
<br>
<h2>Development</h2>
<a href="https://github.com/Fluffy-Bean/image-gallery" class="link">Project Github</a>
<a href="https://twitter.com/fluffybeanUwU" class="link">Creators Twitter</a>
</div>
<?php require_once __DIR__."/ui/footer.php"; ?>
</body>
</html>

View file

@ -1,32 +1,91 @@
<!DOCTYPE html>
<html>
<head>
<?php require_once __DIR__."/ui/header.php"; ?>
</head>
<body>
<?php
require_once __DIR__."/ui/required.php";
require_once __DIR__."/ui/nav.php";
<?php
require_once __DIR__."/app/required.php";
use App\Account;
use App\Diff;
use App\Sanity;
$user_info = new Account();
$diff = new Diff();
?>
$sanity = new Sanity();
$profile_info = $user_info->get_user_info($conn, $_SESSION['id']);
?>
<!DOCTYPE html>
<html>
<head>
<?php require_once __DIR__."/assets/ui/header.php"; ?>
</head>
<body>
<?php require_once __DIR__."/assets/ui/nav.php"; ?>
<?php
if ($user_info->is_loggedin()) {
?>
<div class="account-root">
<h2>Settings</h2>
<a class='btn btn-bad' href='password-reset.php'><img class='svg' src='assets/icons/password.svg'>Reset Password</a>
<button class="btn btn-bad" onclick="deleteAccount()"><img class='svg' src='assets/icons/trash.svg'>Delete account</button>
<div class="defaultDecoration defaultSpacing defaultFonts">
<h2>Profile</h2>
<div class="pfp-upload">
<form id="pfpForm" method="POST" enctype="multipart/form-data">
<h3>Profile Picture</h3>
<input id="image" class="btn btn-neutral" type="file" placeholder="select image UwU">
<button id="pfpSubmit" class="btn btn-good" type="submit"><img class="svg" src="assets/icons/upload.svg">Upload Image</button>
</form>
<?php
if (is_file("images/pfp/".$profile_info['pfp_path'])) {
echo "<img src='images/pfp/".$profile_info['pfp_path']."'>";
} else {
echo "<img src='assets/no_image.png'>";
}
?>
<script>
$("#pfpForm").submit(function(event) {
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 {
sniffleAdd('Gwha!', 'Pls provide image', 'var(--warning)', 'assets/icons/file-search.svg');
}
});
</script>
</div>
<br>
<a href="profile.php?user=<?php echo $_SESSION['id']; ?>" class="btn btn-neutral">Go to profile</a>
</div>
<div class="warningDecoration defaultSpacing defaultFonts">
<h2>Account</h2>
<p>Don't leave! I'm with the science team!</p>
<a class='btn btn-bad' href='app/account/logout.php'><img class='svg' src='assets/icons/sign-out.svg'>Logout</a>
<a class='btn btn-bad' href='app/account/logout.php'><img class='svg' src='assets/icons/sign-out.svg'>Forget Me</a>
<br>
<a class='btn btn-bad' href='password-reset.php'><img class='svg' src='assets/icons/password.svg'>Reset Password</a>
<button class="btn btn-bad" onclick="deleteAccount()"><img class='svg' src='assets/icons/trash.svg'>Forget me forever</button>
</div>
<script>
function deleteAccount() {
@ -52,7 +111,7 @@
event.preventDefault();
var accountDeletePassword = $("#accountDeletePassword").val();
var accountDeleteSubmit = $("#accountDeleteSubmit").val();
$("#sniffle").load("app/account/account.php", {
$("#newSniff").load("app/account/account.php", {
delete_id: <?php echo $_SESSION['id']; ?>,
full: 'false',
account_password: accountDeletePassword,
@ -75,7 +134,7 @@
event.preventDefault();
var accountDeletePassword = $("#accountDeletePassword").val();
var accountDeleteSubmit = $("#accountDeleteSubmit").val();
$("#sniffle").load("app/account/account.php", {
$("#newSniff").load("app/account/account.php", {
delete_id: <?php echo $_SESSION['id']; ?>,
full: 'true',
account_password: accountDeletePassword,
@ -88,8 +147,8 @@
<?php
if ($user_info->is_admin($conn, $_SESSION['id'])) {
?>
<div class="admin-root">
<h2>Admin controlls</h2>
<div class="defaultDecoration defaultSpacing defaultFonts">
<h2>Admin</h2>
<h3>Invite Codes</h3>
<?php
$token_request = mysqli_query($conn, "SELECT * FROM tokens WHERE used = 0");
@ -133,7 +192,7 @@
<p><?php echo $log['action']; ?></p>
<?php
$log_time = new DateTime($log['time']);
echo "<p>" . $log_time->format('Y-m-d H:i:s T') . " | " . $diff->time($log['time']) . "</p>";
echo "<p>".$log_time->format('Y-m-d H:i:s T')." (".$diff->time($log['time']).")</p>";
?>
</div>
<?php
@ -166,7 +225,7 @@
<p><?php echo $ban['length']; ?> mins</p>
<?php
$log_time = new DateTime($ban['time']);
echo "<p>" . $log_time->format('Y-m-d H:i:s T') . " | " . $diff->time($ban['time']) . "</p>";
echo "<p>".$log_time->format('Y-m-d H:i:s T')." (".$diff->time($ban['time']).")</p>";
?>
</div>
<?php
@ -199,7 +258,7 @@
<p><?php echo $user['username']; ?></p>
<?php
$user_time = new DateTime($user['created_at']);
echo "<p>" . $user_time->format('Y-m-d H:i:s T') . " | " . $diff->time($user['last_modified']) . "</p>";
echo "<p>".$user_time->format('Y-m-d H:i:s T')." (".$diff->time($user['last_modified']).")</p>";
if ($user['id'] == 1) {
?>
@ -238,7 +297,7 @@
var confirm_password = $("#userConfirmPassword").val();
var submit = $("#userPasswordSubmit").val();
var userId = $("#userPasswordSubmit").val();
$("#sniffle").load("app/account/account.php", {
$("#newSniff").load("app/account/account.php", {
new_password: new_password,
confirm_password: confirm_password,
id: userId,
@ -263,7 +322,7 @@
event.preventDefault();
var id = $("#userDeleteSubmit").val();
var userDeleteSubmit = $("#userDeleteSubmit").val();
$("#sniffle").load("app/account/account.php", {
$("#newSniff").load("app/account/account.php", {
delete_id: id,
full: false,
account_delete_submit: userDeleteSubmit
@ -273,7 +332,7 @@
event.preventDefault();
var id = $("#userDeleteSubmit").val();
var userDeleteSubmit = $("#userDeleteSubmit").val();
$("#sniffle").load("app/account/account.php", {
$("#newSniff").load("app/account/account.php", {
delete_id: id,
full: true,
account_delete_submit: userDeleteSubmit
@ -285,7 +344,7 @@
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+"'>Make "+username+" powerfull!</button>\
<button id='toggleAdminSubmit' class='btn btn-bad' type='submit' value='"+id+"'>Toggle "+username+"'s admin status</button>\
</form>";
flyoutShow(header, description, actionBox);
@ -293,7 +352,7 @@
$("#toggleAdminConfirm").submit(function(event) {
event.preventDefault();
var toggleAdminSubmit = $("#toggleAdminSubmit").val();
$("#sniffle").load("app/account/account.php", {
$("#newSniff").load("app/account/account.php", {
id: toggleAdminSubmit,
toggle_admin: toggleAdminSubmit
});
@ -320,11 +379,44 @@
}
</script>
</div>
<?php // UwU
<div class="sanity-check defaultDecoration defaultSpacing defaultFonts">
<h2>Sanity check</h2>
<?php
$check_sanity = $sanity->get_results();
if (empty($check_sanity) || !isset($check_sanity)) {
echo "<p class='btn btn-good' style='outline: none;'>No errors! Lookin' good</p>";
?>
<style>
.sanity-check {
border-color: var(--page-accent);
}
</style>
<?php
} else {
?>
<style>
.sanity-check {
border-color: var(--warning);
}
</style>
<?php
foreach ($check_sanity as $result) {
if (str_contains($result, "Critical")) {
echo "<p class='btn btn-bad' style='outline: none; cursor: default;'>".$result."</p>";
} elseif (str_contains($result, "Warning")) {
echo "<p class='btn btn-warning' style='outline: none; cursor: default;'>".$result."</p>";
}
}
}
?>
</div>
<?php
}
} else {
?>
<div class="login-root">
<div class="login-root defaultDecoration defaultSpacing defaultFonts">
<h2>Login</h2>
<p>Passwords are important to keep safe. Don't tell anyone your password, not even Fluffy!</p>
<br>
@ -342,7 +434,7 @@
var username = $("#loginUsername").val();
var password = $("#loginPassword").val();
var submit = $("#loginSubmit").val();
$("#sniffle").load("app/account/account.php", {
$("#newSniff").load("app/account/account.php", {
username: username,
password: password,
submit_login: submit
@ -350,7 +442,7 @@
});
</script>
<div class="signup-root">
<div class="signup-root defaultDecoration defaultSpacing defaultFonts" style="display: none;">
<h2>Make account</h2>
<p>And amazing things happened here...</p>
<br>
@ -374,7 +466,7 @@
var confirm_password = $("#signupPasswordConfirm").val();
var token = $("#signupToken").val();
var submit = $("#signupSubmit").val();
$("#sniffle").load("app/account/account.php", {
$("#newSniff").load("app/account/account.php", {
username: username,
password: password,
confirm_password: confirm_password,
@ -398,7 +490,7 @@
}
?>
<?php require_once __DIR__."/ui/footer.php"; ?>
<?php require_once __DIR__."/assets/ui/footer.php"; ?>
</body>
</html>

View file

@ -4,7 +4,9 @@ include dirname(__DIR__)."/server/conn.php";
include dirname(__DIR__)."/app.php";
use App\Account;
use App\Make;
$make_stuff = new Make();
$user_info = new Account();
$user_ip = $user_info->get_ip();
@ -32,7 +34,7 @@ if (isset($_POST['submit_login'])) {
if ($ban_perm) {
?>
<script>
sniffleAdd('Bye bye!', 'You have been banned, contact the owner if you feel that this was a mistake', 'var(--red)', 'assets/icons/warning.svg');
sniffleAdd('Bye bye!', 'You have been banned, contact the owner if you feel that this was a mistake', 'var(--warning)', 'assets/icons/warning.svg');
</script>
<?php
@ -40,7 +42,7 @@ if (isset($_POST['submit_login'])) {
} elseif (($ban_diff / 60) <= 60) {
?>
<script>
sniffleAdd('Slow down!', 'You have attempted to login/signup too many times in 10 minutes. Come back in <?php echo round(60-($ban_diff/60)); ?> minutes', 'var(--red)', 'assets/icons/warning.svg');
sniffleAdd('Slow down!', 'You have attempted to login/signup too many times in 10 minutes. Come back in <?php echo round(60-($ban_diff/60)); ?> minutes', 'var(--warning)', 'assets/icons/warning.svg');
</script>
<?php
@ -69,7 +71,7 @@ if (isset($_POST['submit_login'])) {
if (empty(trim($_POST["username"]))) {
?>
<script>
sniffleAdd('Who dis?', 'You must enter a username to login!', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Who dis?', 'You must enter a username to login!', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
$error += 1;
@ -81,7 +83,7 @@ if (isset($_POST['submit_login'])) {
if (empty(trim($_POST["password"]))) {
?>
<script>
sniffleAdd('Whats the magic word?', 'Pls enter the super duper secrete word(s) to login!', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Whats the magic word?', 'Pls enter the super duper secrete word(s) to login!', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
$error += 1;
@ -123,10 +125,10 @@ if (isset($_POST['submit_login'])) {
// let the user know
?>
<script>
sniffleAdd('O hi <?php echo $_SESSION["username"]; ?>', 'You are now logged in! You will be redirected in a few seconds', 'var(--green)', 'assets/icons/hand-waving.svg');
setTimeout(function(){window.location.href = "index.php";}, 2000);
window.location.href = "index.php";
</script>
<?php
$_SESSION['welc'] = true;
mysqli_query($conn,"INSERT INTO logs (ipaddress, action) VALUES('$user_ip','New loggin to ".$_SESSION['username']."')");
@ -137,7 +139,7 @@ if (isset($_POST['submit_login'])) {
} else {
?>
<script>
sniffleAdd('Sus', 'Username or Password WRONG, please try again :3', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Sus', 'Username or Password WRONG, please try again :3', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
mysqli_query($conn,"INSERT INTO logs (ipaddress, action) VALUES('$user_ip','Failed to enter correct Password')");
@ -146,7 +148,7 @@ if (isset($_POST['submit_login'])) {
} else {
?>
<script>
sniffleAdd('Sus', 'Username or Password WRONG, please try again :3', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Sus', 'Username or Password WRONG, please try again :3', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
mysqli_query($conn,"INSERT INTO logs (ipaddress, action) VALUES('$user_ip','Failed to enter correct Username')");
@ -154,7 +156,7 @@ if (isset($_POST['submit_login'])) {
} else {
?>
<script>
sniffleAdd('woops...', 'Sowwy, something went wrong on our end :c', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('woops...', 'Sowwy, something went wrong on our end :c', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
}
@ -186,7 +188,7 @@ if (isset($_POST['submit_signup'])) {
if ($ban_perm) {
?>
<script>
sniffleAdd('Bye bye!', 'You have been banned, contact the owner if you feel that this was a mistake', 'var(--red)', 'assets/icons/warning.svg');
sniffleAdd('Bye bye!', 'You have been banned, contact the owner if you feel that this was a mistake', 'var(--warning)', 'assets/icons/warning.svg');
</script>
<?php
@ -194,7 +196,7 @@ if (isset($_POST['submit_signup'])) {
} elseif (($ban_diff / 60) <= 60) {
?>
<script>
sniffleAdd('Slow down!', 'You have attempted to login/signup too many times in 10 minutes. Come back in <?php echo round(60-($ban_diff/60)); ?> minutes', 'var(--red)', 'assets/icons/warning.svg');
sniffleAdd('Slow down!', 'You have attempted to login/signup too many times in 10 minutes. Come back in <?php echo round(60-($ban_diff/60)); ?> minutes', 'var(--warning)', 'assets/icons/warning.svg');
</script>
<?php
@ -223,7 +225,7 @@ if (isset($_POST['submit_signup'])) {
// Username not entered
?>
<script>
sniffleAdd('Hmmm', 'You must enter a username!', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Hmmm', 'You must enter a username!', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
$error = $error + 1;
@ -231,7 +233,7 @@ if (isset($_POST['submit_signup'])) {
// Username entered contains illegal characters
?>
<script>
sniffleAdd('Sussy Wussy', 'Very sus. Username can only contain letters, numbers, and underscores', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Sussy Wussy', 'Very sus. Username can only contain letters, numbers, and underscores', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
$error = $error + 1;
@ -252,7 +254,7 @@ if (isset($_POST['submit_signup'])) {
// Username taken
?>
<script>
sniffleAdd('A clone?', 'Sorry, but username was already taken by someone else', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('A clone?', 'Sorry, but username was already taken by someone else', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
$error = $error + 1;
@ -262,7 +264,7 @@ if (isset($_POST['submit_signup'])) {
} else {
?>
<script>
sniffleAdd('Reee', 'We had a problem on our end, sowwy', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Reee', 'We had a problem on our end, sowwy', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
$error = $error + 1;
@ -277,7 +279,7 @@ if (isset($_POST['submit_signup'])) {
// No password entered
?>
<script>
sniffleAdd('What', 'You must enter a password, dont want just anyone seeing your stuff uwu', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('What', 'You must enter a password, dont want just anyone seeing your stuff uwu', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
$error = $error + 1;
@ -285,7 +287,7 @@ if (isset($_POST['submit_signup'])) {
// Password not long enough 👀
?>
<script>
sniffleAdd('👀', 'Nice (Password) but its not long enough 👀', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('👀', 'Nice (Password) but its not long enough 👀', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
$error = $error + 1;
@ -298,7 +300,7 @@ if (isset($_POST['submit_signup'])) {
// Did not confirm passowrd
?>
<script>
sniffleAdd('Eh?', 'Confirm the password pls, its very important you remember what it issss', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Eh?', 'Confirm the password pls, its very important you remember what it issss', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
$error = $error + 1;
@ -308,7 +310,7 @@ if (isset($_POST['submit_signup'])) {
// Password and re-entered Password does not match
?>
<script>
sniffleAdd('Try again', 'Passwords need to be the same, smelly smelly', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Try again', 'Passwords need to be the same, smelly smelly', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
$error = $error + 1;
@ -321,7 +323,7 @@ if (isset($_POST['submit_signup'])) {
if (empty($_POST['token'])) {
?>
<script>
sniffleAdd('smelly', 'Enter Invite Code ;3', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('smelly', 'Enter Invite Code ;3', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
mysqli_query($conn,"INSERT INTO logs (ipaddress, action) VALUES('$user_ip','Failed to enter correct Invite Code')");
@ -343,7 +345,7 @@ if (isset($_POST['submit_signup'])) {
} else {
?>
<script>
sniffleAdd('Argh', 'Your invite code/token did not check out, woopsie!', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Argh', 'Your invite code/token did not check out, woopsie!', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
$error = $error + 1;
@ -351,7 +353,7 @@ if (isset($_POST['submit_signup'])) {
} else {
?>
<script>
sniffleAdd('Woops', 'The server or website died inside and could not process your information, sowwy!', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Woops', 'The server or website died inside and could not process your information, sowwy!', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
$error = $error + 1;
@ -384,32 +386,17 @@ if (isset($_POST['submit_signup'])) {
$param_token = $_POST['token'];
if (mysqli_stmt_execute($stmt)) {
//
// Hey fluffy why didn't you do this
// Hey fluffy, thats not how you do this
// Thats wrong! Do this instead!!!!!!
//
// I DON'T KNOW HOW TO DO THIS, BUT IT WORKS
// SO LEAVE ME ALONEEEEEEEEEE
// anyway....
// Generate Token
$token_array = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz';
$new_token = substr(str_shuffle($token_array), 0, 15);
// Prepare sql
$sql = "INSERT INTO tokens (code, used) VALUES(?, False)";
$stmt = mysqli_prepare($conn, $sql);
mysqli_stmt_bind_param($stmt, "s", $param_new_token);
$param_new_token = $new_token;
mysqli_stmt_execute($stmt);
mysqli_query($conn, "INSERT INTO tokens (code, used) VALUES('$new_toke', False)");
}
// Yupeee! Account was made
?>
<script>
sniffleAdd('Success!', 'You account made for <?php echo $username; ?>!!!!! You must now login', 'var(--green)', 'assets/icons/hand-waving.svg');
//setTimeout(function(){window.location.href = "../account/login.php";}, 2000);
sniffleAdd('Success!', 'You account made for <?php echo $username; ?>!!!!! You must now login', 'var(--success)', 'assets/icons/hand-waving.svg');
loginShow();
</script>
<?php
@ -417,7 +404,7 @@ if (isset($_POST['submit_signup'])) {
} else {
?>
<script>
sniffleAdd('Bruh', 'Something went fuckywucky, please try later', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Bruh', 'Something went fuckywucky, please try later', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
}
@ -461,7 +448,7 @@ if (isset($_POST['toggle_admin'])) {
if (mysqli_stmt_execute($stmt)) {
?>
<script>
sniffleAdd('Bap!', '<?php echo $username; ?> has been <?php echo $admin_update_message; ?>!', 'var(--green)', 'assets/icons/check.svg');
sniffleAdd('Bap!', '<?php echo $username; ?> has been <?php echo $admin_update_message; ?>!', 'var(--success)', 'assets/icons/check.svg');
flyoutClose();
</script>
<?php
@ -469,7 +456,7 @@ if (isset($_POST['toggle_admin'])) {
} else {
?>
<script>
sniffleAdd('Bruh', 'Something went fuckywucky, please try later', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Bruh', 'Something went fuckywucky, please try later', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
@ -477,7 +464,7 @@ if (isset($_POST['toggle_admin'])) {
} else {
?>
<script>
sniffleAdd('Bruh', 'Something went fuckywucky, please try later', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Bruh', 'Something went fuckywucky, please try later', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
@ -485,7 +472,7 @@ if (isset($_POST['toggle_admin'])) {
} else {
?>
<script>
sniffleAdd('Bruh', 'You\'re not an admin, you cannot!!!!', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Bruh', 'You\'re not an admin, you cannot!!!!', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
@ -513,7 +500,7 @@ if (isset($_POST['password_reset_submit'])) {
if (empty(trim($_POST["new_password"]))) {
?>
<script>
sniffleAdd('Meep', 'Enter a new password!', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Meep', 'Enter a new password!', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
@ -521,7 +508,7 @@ if (isset($_POST['password_reset_submit'])) {
} elseif(strlen(trim($_POST["new_password"])) < 6) {
?>
<script>
sniffleAdd('Not long enough...', 'Password, must be 6 or more characters in length uwu', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Not long enough...', 'Password, must be 6 or more characters in length uwu', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
@ -534,7 +521,7 @@ if (isset($_POST['password_reset_submit'])) {
if (empty(trim($_POST["confirm_password"]))) {
?>
<script>
sniffleAdd('Meep', 'You must confirm the password!!!!', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Meep', 'You must confirm the password!!!!', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
@ -544,7 +531,7 @@ if (isset($_POST['password_reset_submit'])) {
if(empty($error) && ($new_password != $confirm_password)) {
?>
<script>
sniffleAdd('AAAA', 'Passwords do not match!!!', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('AAAA', 'Passwords do not match!!!', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
@ -559,7 +546,7 @@ if (isset($_POST['password_reset_submit'])) {
} else {
?>
<script>
sniffleAdd('Oopsie', 'An error occured while figuring out which user to change the password of... Are you an admin?', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Oopsie', 'An error occured while figuring out which user to change the password of... Are you an admin?', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
@ -586,7 +573,7 @@ if (isset($_POST['password_reset_submit'])) {
session_destroy();
?>
<script>
sniffleAdd('Password updated', 'Now goodbye.... you will be redirected in a moment', 'var(--green)', 'assets/icons/check.svg');
sniffleAdd('Password updated', 'Now goodbye.... you will be redirected in a moment', 'var(--success)', 'assets/icons/check.svg');
setTimeout(function(){window.location.href = "account/login.php";}, 2000);
</script>
<?php
@ -594,7 +581,7 @@ if (isset($_POST['password_reset_submit'])) {
// An admin has changed the password
?>
<script>
sniffleAdd('Password updated', 'Password has been reset for user! But their session may still be active', 'var(--green)', 'assets/icons/check.svg');
sniffleAdd('Password updated', 'Password has been reset for user! But their session may still be active', 'var(--success)', 'assets/icons/check.svg');
flyoutClose();
</script>
<?php
@ -602,7 +589,7 @@ if (isset($_POST['password_reset_submit'])) {
} else {
?>
<script>
sniffleAdd('Bruh', 'Something happened on our end, sowwy', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Bruh', 'Something happened on our end, sowwy', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
@ -623,7 +610,7 @@ if (isset($_POST['account_delete_submit'])) {
if ($_POST['delete_id'] == 1) {
?>
<script>
sniffleAdd('Sussy', 'You cannot delete the owners account!!!!!', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Sussy', 'You cannot delete the owners account!!!!!', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
@ -654,7 +641,7 @@ if (isset($_POST['account_delete_submit'])) {
} else {
?>
<script>
sniffleAdd('Sus', 'Try again! ;3', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Sus', 'Try again! ;3', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
@ -664,7 +651,7 @@ if (isset($_POST['account_delete_submit'])) {
} else {
?>
<script>
sniffleAdd('Sus', 'Try again! ;3', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Sus', 'Try again! ;3', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
@ -673,7 +660,7 @@ if (isset($_POST['account_delete_submit'])) {
} else {
?>
<script>
sniffleAdd('AAA', 'Something went wrong on our end, sowwy', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('AAA', 'Something went wrong on our end, sowwy', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
@ -683,7 +670,7 @@ if (isset($_POST['account_delete_submit'])) {
} else {
?>
<script>
sniffleAdd('oof', 'You did not enter a password!', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('oof', 'You did not enter a password!', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
@ -694,7 +681,7 @@ if (isset($_POST['account_delete_submit'])) {
} else {
?>
<script>
sniffleAdd('Ono', 'You aren\'t privilaged enough to delete accounts!', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Ono', 'You aren\'t privilaged enough to delete accounts!', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
@ -703,7 +690,7 @@ if (isset($_POST['account_delete_submit'])) {
} else {
?>
<script>
sniffleAdd('Oopsie', 'We couldn\'t find the account that was requested to be deleted', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Oopsie', 'We couldn\'t find the account that was requested to be deleted', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
@ -711,12 +698,6 @@ if (isset($_POST['account_delete_submit'])) {
}
if (empty($_POST['full']) || !isset($_POST['full'])) {
?>
<script>
sniffleAdd('Oopsie', 'Some error occured, unsure what to delete', 'var(--red)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
$error += 1;
}
@ -740,7 +721,7 @@ if (isset($_POST['account_delete_submit'])) {
?>
<script>
sniffleAdd('Progress', 'Deleted all images from the user', 'var(--green)', 'assets/icons/warning.svg');
sniffleAdd('Progress', 'Deleted all images from the user', 'var(--success)', 'assets/icons/warning.svg');
flyoutClose();
</script>
<?php
@ -757,7 +738,7 @@ if (isset($_POST['account_delete_submit'])) {
if ($_POST['delete_id'] == $_SESSION['id']) {
?>
<script>
sniffleAdd('Goodbye!', 'Successfully deleted your account! You will be redirected in a few seconds...', 'var(--green)', 'assets/icons/check.svg');
sniffleAdd('Goodbye!', 'Successfully deleted your account! You will be redirected in a few seconds...', 'var(--success)', 'assets/icons/check.svg');
flyoutClose();
setTimeout(function(){window.location.href = "app/account/logout.php";}, 2000);
@ -766,10 +747,93 @@ if (isset($_POST['account_delete_submit'])) {
} else {
?>
<script>
sniffleAdd('Goodbye!', 'Successfully deleted the user!', 'var(--green)', 'assets/icons/check.svg');
sniffleAdd('Goodbye!', 'Successfully deleted the user!', 'var(--success)', 'assets/icons/check.svg');
flyoutClose();
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Oopsie', 'Some error occured, working on fixing these things', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
}
/*
Profile Picture upload
*dies of cringe*
*/
if (isset($_POST['pfp_submit'])) {
if (isset($_SESSION['id'])) {
// Root paths
$dir = "../../images/pfp/";
// File name updating
$file_type = pathinfo($dir.$_FILES['image']['name'],PATHINFO_EXTENSION);
$image_newname = "PFP_".$_SESSION["id"].".".$file_type;
$image_path = $dir.$image_newname;
// Allowed file types
$allowed_types = array('jpg', 'jpeg', 'png', 'webp');
if (in_array($file_type, $allowed_types)) {
$query = mysqli_query($conn, "SELECT pfp_path FROM users WHERE id = ".$_SESSION['id']." LIMIT 1");
while ($pfp = mysqli_fetch_assoc($query)) {
$old_pfp = $pfp['pfp_path'];
}
if (is_file($dir.$old_pfp) && !empty($old_pfp)) {
unlink($dir.$old_pfp);
}
// Move file to server
if (move_uploaded_file($_FILES['image']['tmp_name'], $image_path)) {
if ($make_stuff->thumbnail($image_path, $image_path, 300) != "success") {
?>
<script>
sniffleAdd('Gwha!', 'We hit a small roadbump while compressing your profile picture', 'var(--alert)', 'assets/icons/bug.svg');
</script>
<?php
}
$sql = "UPDATE users SET pfp_path = '$image_newname' WHERE id=".$_SESSION['id'];
if (mysqli_query($conn, $sql)) {
?>
<script>
sniffleAdd(':3', 'Your Image uploaded successfully!', 'var(--success)', 'assets/icons/check.svg');
</script>
<?php
} else {
?>
<script>
sniffleAdd(':c', 'Something went fuckywucky, please try later', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Hmmff', 'Something happened when moving the file to the server. This may just been a 1-off so try again', 'var(--warning)', 'assets/icons/bug.svg');
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Woopsie', 'The file type you are trying to upload is not supported. Supported files include: JPEG, JPG, PNG and WEBP', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Denied!!!', 'As you are not logged in', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
}
}

View file

@ -1,6 +1,9 @@
<?php
namespace App;
use Exception;
use Throwable;
class Make {
/*
|-------------------------------------------------------------
@ -28,16 +31,73 @@ class Make {
Returns clean string of words with equal white space between it
*/
function tags($string) {
// Replace hyphens
$string = str_replace('-', '_', $string);
// Regex
$string = preg_replace('/[^A-Za-z0-9\_ ]/', '', $string);
// Change to lowercase
$string = strtolower($string);
// Removing extra spaces
$string = preg_replace('/ +/', ' ', $string);
$string = explode(' ', $string);
$string_list = array();
foreach ($string as $i) {
if (!in_array($i, $string_list)) {
$string_list[] = $i;
}
}
$string = implode(' ', $string_list);
return trim($string);
}
function get_image_colour($img) {
$img_type = pathinfo($img, PATHINFO_EXTENSION);
if ($img_type == "png") {
$img = imagecreatefrompng($img);
} elseif ($img_type == "jpg" || $img_type == "jpeg") {
$img = imagecreatefromjpeg($img);
} elseif ($img_type == "webp") {
$img = imagecreatefromwebp($img);
} else {
return null;
}
try {
$w = imagesx($img);
$h = imagesy($img);
$r = $g = $b = 0;
return $string;
for($y = 0; $y < $h; $y++) {
for($x = 0; $x < $w; $x++) {
$rgb = imagecolorat($img, $x, $y);
$r += $rgb >> 16;
$g += $rgb >> 8 & 255;
$b += $rgb & 255;
}
}
$pxls = $w * $h;
$r = dechex(round($r / $pxls));
$g = dechex(round($g / $pxls));
$b = dechex(round($b / $pxls));
if(strlen($r) < 2) {
$r = 0 . $r;
}
if(strlen($g) < 2) {
$g = 0 . $g;
}
if(strlen($b) < 2) {
$b = 0 . $b;
}
return "#" . $r . $g . $b;
} catch (Throwable $e) {
return null;
}
}
}
@ -61,12 +121,20 @@ class Account {
Returns array with user info
*/
function get_user_info($conn, $id) {
// Setting SQL query
$sql = "SELECT id, username FROM users WHERE id = ".$id;
// Getting results
$query = mysqli_query($conn, $sql);
// Fetching associated info
$user_array = mysqli_fetch_assoc($query);
$sql = "SELECT id, username, created_at, pfp_path FROM users WHERE id = ?";
if ($stmt = mysqli_prepare($conn, $sql)) {
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "i", $param_user_id);
$param_user_id = $id;
$stmt->execute();
$query = $stmt->get_result();
// Fetching associated info
$user_array = mysqli_fetch_assoc($query);
}
return($user_array);
}
@ -79,11 +147,21 @@ class Account {
function is_admin($conn, $id) {
if (isset($id) || !empty($id)) {
// Setting SQL query
$sql = "SELECT admin FROM users WHERE id = ".$id;
// Getting results
$query = mysqli_query($conn, $sql);
// Fetching associated info
$user_array = mysqli_fetch_assoc($query);
$sql = "SELECT admin FROM users WHERE id = ?";
if ($stmt = mysqli_prepare($conn, $sql)) {
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "i", $param_user_id);
$param_user_id = $id;
$stmt->execute();
$query = $stmt->get_result();
// Fetching associated info
$user_array = mysqli_fetch_assoc($query);
}
if ($user_array['admin'] || $id == 1) {
return True;
@ -117,14 +195,20 @@ class Image {
Returns array with image info
*/
function get_image_info($conn, $id) {
// Setting SQL query
$sql = "SELECT * FROM images WHERE id = ".$id;
// Getting results
$query = mysqli_query($conn, $sql);
// Fetching associated info
$image_array = mysqli_fetch_assoc($query);
$sql = "SELECT * FROM images WHERE id = ?";
if ($stmt = mysqli_prepare($conn, $sql)) {
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "i", $id);
$stmt->execute();
$query = $stmt->get_result();
// Fetching associated info
$group_array = mysqli_fetch_assoc($query);
}
return($image_array);
return($group_array);
}
/*
Check if user is image owner
@ -146,6 +230,61 @@ class Image {
}
}
class Group {
function get_group_info($conn, $id) {
// Setting SQL query
$sql = "SELECT * FROM groups WHERE id = ?";
if ($stmt = mysqli_prepare($conn, $sql)) {
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "i", $id);
$stmt->execute();
$query = $stmt->get_result();
// Fetching associated info
$group_array = mysqli_fetch_assoc($query);
}
return($group_array);
}
function get_group_members($conn, $id){
$user_array = array();
$sql = "SELECT * FROM groups WHERE id = ?";
if ($stmt = mysqli_prepare($conn, $sql)) {
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "i", $id);
$stmt->execute();
$query = $stmt->get_result();
// Fetching associated info
$group_array = mysqli_fetch_assoc($query);
}
try {
$image_list = explode(" ", $group_array['image_list']);
$user_array = array();
foreach ($image_list as $image) {
$image_request = mysqli_query($conn, "SELECT author FROM images WHERE id = ".$image);
while ($author = mysqli_fetch_column($image_request)) {
if (!in_array($author, $user_array)) {
$user_array[] = $author;
}
}
}
} catch (Exception) {
}
return($user_array);
}
}
class Diff {
function time($past_time, $full_date = false) {
$now = new \DateTime;
@ -175,4 +314,93 @@ class Diff {
if (!$full_date) $string = array_slice($string, 0, 1);
return $string ? implode(', ', $string) . ' ago' : 'just now';
}
}
class Sanity {
function check_json() {
$results = array();
if (!is_file(__DIR__."/settings/manifest.json")) {
$results[] = "Critical: manifest.json is missing";
} else {
$manifest = json_decode(file_get_contents(__DIR__."/settings/manifest.json"), true);
if (!isset($manifest['user_name']) || empty($manifest['user_name']) || $manifest['user_name'] == "[your name]") {
$results[] = "Warning: manifest.json is missing your name";
}
if ($manifest['upload']['rename_on_upload'] == true ) {
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;
if (str_contains($rename_to, '{{autoinc}}')) $rename_rate = 5;
if (str_contains($rename_to, '{{time}}')) $rename_rate = 5;
if (str_contains($rename_to, '{{date}}')) $rename_rate += 2;
if (str_contains($rename_to, '{{filename}}')) $rename_rate += 2;
if (str_contains($rename_to, '{{username}}') || str_contains($rename_to, '{{userid}}')) $rename_rate += 1;
if ($rename_rate == 0 || $rename_rate < 2) {
$results[] = "Critical: You will encounter errors when uploading images due to filenames, update your manifest.json";
} elseif ($rename_rate < 5 && $rename_rate > 2) {
$results[] = "Warning: You may encounter errors when uploading images due to filenames, concider update your manifest.json";
}
}
}
if ($manifest['is_testing']) {
$results[] = "Warning: You are currently in testing mode, errors will be displayed to the user";
}
}
return $results;
}
function check_files() {
$results = array();
if (!is_dir("images")) {
$results[] = "Critical: You need to setup an images folder, follow the guide on the GitHub repo";
}
if (!is_dir("images/pfp")) {
$results[] = "Critical: You need to setup an pfp folder, follow the guide on the GitHub repo";
}
if (!is_dir("images/previews")) {
$results[] = "Critical: You need to setup an previews folder, follow the guide on the GitHub repo";
}
if (!is_dir("images/thumbnails")) {
$results[] = "Critical: You need to setup an thumbnails folder, follow the guide on the GitHub repo";
}
return $results;
}
function check_version() {
$results = array();
if (PHP_VERSION_ID < 50102) {
$results[] = "Critical: Your current version of PHP is ".PHP_VERSION.". The reccomended version is 8.1.2";
}
return $results;
}
function get_results() {
$results = array();
foreach ($this->check_json() as $result) {
$results[] = $result;
}
foreach ($this->check_files() as $result) {
$results[] = $result;
}
foreach ($this->check_version() as $result) {
$results[] = $result;
}
return $results;
}
}

199
app/image/group.php Normal file
View file

@ -0,0 +1,199 @@
<?php
session_start();
// Include server connection
include dirname(__DIR__) . "/server/conn.php";
include dirname(__DIR__) . "/app.php";
use App\Account;
use App\Image;
use App\Group;
$user_info = new Account();
$image_info = new Image();
$group_info = new Group();
$user_ip = $user_info->get_ip();
/*
|-------------------------------------------------------------
| Image Groups
|-------------------------------------------------------------
| The Long-awaited feature
|-------------------------------------------------------------
*/
if (isset($_POST['group_submit'])) {
$query = $group_info->get_group_info($conn, $_POST['group_id']);
if ($_SESSION['id'] == $query['author'] || $user_info->is_admin($conn, $_SESSION['id'])) {
$sql = "UPDATE groups SET image_list = ? WHERE id = ?";
// Checking if databse is doing ok
if ($stmt = mysqli_prepare($conn, $sql)) {
mysqli_stmt_bind_param($stmt, "si", $param_images, $param_id);
// Setting parameters
$param_images = implode(" ", $_POST['group_images']);
$param_id = $_POST['group_id'];
// Attempt to execute the prepared statement
if (mysqli_stmt_execute($stmt)) {
?>
<script>
window.location.href = "group.php?id=<?php echo $_POST['group_id']; ?>";
</script>
<?php
$_SESSION['msg'] = "Updated the image group!";
} else {
?>
<script>
sniffleAdd('Oopsie....', 'An error occured on the servers', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
}
}
} else {
?>
<script>
sniffleAdd('Gwa Gwa', 'You\'re not privilaged enough to do thissss!', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
}
}
/*
|-------------------------------------------------------------
| Edit title
|-------------------------------------------------------------
|
|-------------------------------------------------------------
*/
if (isset($_POST['title_submit'])) {
$query = $group_info->get_group_info($conn, $_POST['group_id']);
if ($_SESSION['id'] == $query['author'] || $user_info->is_admin($conn, $_SESSION['id'])) {
// getting ready forSQL asky asky
$sql = "UPDATE groups SET group_name = ? WHERE id = ?";
// Checking if databse is doing ok
if ($stmt = mysqli_prepare($conn, $sql)) {
mysqli_stmt_bind_param($stmt, "si", $param_title, $param_id);
// Setting parameters
$param_title = $_POST['group_title'];
$param_id = $_POST['group_id'];
// Attempt to execute the prepared statement
if (mysqli_stmt_execute($stmt)) {
?>
<script>
sniffleAdd('Success!!!', 'The title has been updated successfully! You may need to refresh the page to see the new information.', 'var(--success)', 'assets/icons/check.svg');
flyoutClose();
</script>
<?php
} else {
?>
<script>
sniffleAdd('Error :c', 'An error occured on the servers', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Error :c', 'An error occured on the servers', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Denied', 'It seems that you do not have the right permitions to edit this image.', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
}
/*
|-------------------------------------------------------------
| New Group
|-------------------------------------------------------------
|
|-------------------------------------------------------------
*/
if (isset($_POST['new_group_submit'])) {
if ($user_info->is_loggedin()) {
$group_name = "New Group";
$sql = "INSERT INTO groups (group_name, author, image_list) VALUES('$group_name', '".$_SESSION['id']."', '')";
mysqli_query($conn, $sql);
$group_id = mysqli_insert_id($conn);
?>
<script>
window.location.href = "group.php?id=<?php echo $group_id; ?>";
</script>
<?php
$_SESSION['msg'] = "New Group successfully made!";
} else {
?>
<script>
sniffleAdd('Denied', 'You must have an account to preform this action!', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
}
}
/*
|-------------------------------------------------------------
| Delete Group
|-------------------------------------------------------------
|
|-------------------------------------------------------------
*/
if (isset($_POST['group_delete'])) {
$query = $group_info->get_group_info($conn, $_POST['group_id']);
if ($_SESSION['id'] == $query['author'] || $user_info->is_admin($conn, $_SESSION['id'])) {
$sql = "DELETE FROM groups WHERE id = ?";
if ($stmt = mysqli_prepare($conn, $sql)) {
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "i", $_POST['group_id']);
if ($stmt->execute()) {
?>
<script>
flyoutClose();
setTimeout(function(){window.location.href = "group.php";}, 500);
</script>
<?php
$_SESSION['msg'] = "Group successfully yeeted out";
} else {
?>
<script>
sniffleAdd('Ouchie', 'Something went wrong while deleting the group', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Ouchie', 'Something went wrong while deleting the image group', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Denied!!!', 'You do not have the right permitions to delete this group', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
}

View file

@ -23,64 +23,62 @@ $user_ip = $user_info->get_ip();
|-------------------------------------------------------------
*/
if (isset($_POST['submit_delete'])) {
// Get all image info
$image_array = $image_info->get_image_info($conn, $_POST['id']);
// Get all image info
$image_array = $image_info->get_image_info($conn, $_POST['id']);
// If user owns image or has the ID of 1
if ($image_info->image_privilage($image_array['author']) || $user_info->is_admin($conn, $_SESSION['id'])) {
// Delete from table
$sql = "DELETE FROM images WHERE id = ?";
if ($stmt = mysqli_prepare($conn, $sql)) {
mysqli_stmt_bind_param($stmt, "i", $param_id);
// If user owns image or has the ID of 1
if ($image_info->image_privilage($image_array['author']) || $user_info->is_admin($conn, $_SESSION['id'])) {
// Delete from table
$sql = "DELETE FROM images WHERE id = ?";
if ($stmt = mysqli_prepare($conn, $sql)) {
mysqli_stmt_bind_param($stmt, "i", $_POST['id']);
// Setting parameters
$param_id = $_POST['id'];
// Attempt to execute the prepared statement
if (mysqli_stmt_execute($stmt)) {
// See if image is in the directory
if (is_file(dirname(__DIR__)."/images/".$image_array['imagename'])) {
unlink(dirname(__DIR__)."/images/".$image_array['imagename']);
}
// Delete thumbnail if exitsts
if (is_file(dirname(__DIR__)."/images/thumbnails/".$image_array['imagename'])) {
unlink(dirname(__DIR__)."/images/thumbnails/".$image_array['imagename']);
}
// Delete preview if exitsts
if (is_file(dirname(__DIR__)."/images/previews/".$image_array['imagename'])) {
unlink(dirname(__DIR__)."/images/previews/".$image_array['imagename']);
}
// TP user to the homepage with a success message
mysqli_query($conn,"INSERT INTO logs (ipaddress, action) VALUES('$user_ip','Deleted image ".$_POST['id']."')");
?>
<script>
window.location.replace("index.php?del=true&id=<?php echo $_POST['id']; ?>");
</script>
<?php
} else {
?>
<script>
sniffleAdd('Oopsie', 'The image failed to delete off of the servers, contact Fluffy about his terrible programming', 'var(--red)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Error :c', 'An error occured on the servers', 'var(--red)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Denied', 'It seems that you do not have the right permitions to edit this image.', 'var(--red)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
// Attempt to execute the prepared statement
if (mysqli_stmt_execute($stmt)) {
// See if image is in the directory
if (is_file(dirname(__DIR__)."/images/".$image_array['imagename'])) {
unlink(dirname(__DIR__)."/images/".$image_array['imagename']);
}
// Delete thumbnail if exitsts
if (is_file(dirname(__DIR__)."/images/thumbnails/".$image_array['imagename'])) {
unlink(dirname(__DIR__)."/images/thumbnails/".$image_array['imagename']);
}
// Delete preview if exitsts
if (is_file(dirname(__DIR__)."/images/previews/".$image_array['imagename'])) {
unlink(dirname(__DIR__)."/images/previews/".$image_array['imagename']);
}
// TP user to the homepage with a success message
mysqli_query($conn, "INSERT INTO logs (ipaddress, action) VALUES('$user_ip','Deleted image " . $_POST['id'] . "')");
$_SESSION['del'] = $_POST['id'];
?>
<script>
window.location.replace("index.php");
</script>
<?php
} else {
?>
<script>
sniffleAdd('Oopsie', 'The image failed to delete off of the servers, contact Fluffy about his terrible programming', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Error :c', 'An error occured on the servers', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Denied', 'It seems that you do not have the right permitions to edit this image.', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
}
@ -98,53 +96,53 @@ if (isset($_POST['submit_delete'])) {
|-------------------------------------------------------------
*/
if (isset($_POST['submit_description'])) {
// Get all image info
$image_array = $image_info->get_image_info($conn, $_POST['id']);
// If user owns image or has the ID of 1
if ($image_info->image_privilage($image_array['author']) || $user_info->is_admin($conn, $_SESSION['id'])) {
// getting ready forSQL asky asky
$sql = "UPDATE images SET alt=? WHERE id=?";
// Get all image info
$image_array = $image_info->get_image_info($conn, $_POST['id']);
// If user owns image or has the ID of 1
if ($image_info->image_privilage($image_array['author']) || $user_info->is_admin($conn, $_SESSION['id'])) {
// getting ready forSQL asky asky
$sql = "UPDATE images SET alt=? WHERE id=?";
// Checking if databse is doing ok
if ($stmt = mysqli_prepare($conn, $sql)) {
mysqli_stmt_bind_param($stmt, "si", $param_alt, $param_id);
// Checking if databse is doing ok
if ($stmt = mysqli_prepare($conn, $sql)) {
mysqli_stmt_bind_param($stmt, "si", $param_alt, $param_id);
// Setting parameters
$param_alt = $_POST['input'];
$param_id = $_POST['id'];
// Setting parameters
$param_alt = $_POST['input'];
$param_id = $_POST['id'];
// Attempt to execute the prepared statement
if (mysqli_stmt_execute($stmt)) {
?>
<script>
sniffleAdd('Success!!!', 'Description has been updated successfully! You may need to refresh the page to see the new information.', 'var(--green)', 'assets/icons/check.svg');
flyoutClose();
</script>
<?php
} else {
?>
<script>
sniffleAdd('Error :c', 'An error occured on the servers', 'var(--red)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Error :c', 'An error occured on the servers', 'var(--red)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Denied', 'It seems that you do not have the right permitions to edit this image.', 'var(--red)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
// Attempt to execute the prepared statement
if (mysqli_stmt_execute($stmt)) {
?>
<script>
sniffleAdd('Success!!!', 'Description has been updated successfully! You may need to refresh the page to see the new information.', 'var(--success)', 'assets/icons/check.svg');
flyoutClose();
</script>
<?php
} else {
?>
<script>
sniffleAdd('Error :c', 'An error occured on the servers', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Error :c', 'An error occured on the servers', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Denied', 'It seems that you do not have the right permitions to edit this image.', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
}
@ -156,56 +154,56 @@ if (isset($_POST['submit_description'])) {
|-------------------------------------------------------------
*/
if (isset($_POST['submit_tags'])) {
// Get all image info
$image_array = $image_info->get_image_info($conn, $_POST['id']);
// If user owns image or has the ID of 1
if ($image_info->image_privilage($image_array['author']) || $user_info->is_admin($conn, $_SESSION['id'])) {
// Clean input
$tags_string = $make_stuff->tags(trim($_POST['input']));
// Get all image info
$image_array = $image_info->get_image_info($conn, $_POST['id']);
// If user owns image or has the ID of 1
if ($image_info->image_privilage($image_array['author']) || $user_info->is_admin($conn, $_SESSION['id'])) {
// Clean input
$tags_string = $make_stuff->tags(trim($_POST['input']));
// getting ready forSQL asky asky
$sql = "UPDATE images SET tags=? WHERE id=?";
// getting ready forSQL asky asky
$sql = "UPDATE images SET tags=? WHERE id=?";
// Checking if databse is doing ok
if ($stmt = mysqli_prepare($conn, $sql)) {
mysqli_stmt_bind_param($stmt, "si", $param_tags, $param_id);
// Checking if databse is doing ok
if ($stmt = mysqli_prepare($conn, $sql)) {
mysqli_stmt_bind_param($stmt, "si", $param_tags, $param_id);
// Setting parameters
$param_tags = $tags_string;
$param_id = $_POST['id'];
// Setting parameters
$param_tags = $tags_string;
$param_id = $_POST['id'];
// Attempt to execute the prepared statement
if (mysqli_stmt_execute($stmt)) {
?>
<script>
sniffleAdd('Success!!!', 'Tags have been modified successfully! You may need to refresh the page to see the new information.', 'var(--green)', 'assets/icons/check.svg');
flyoutClose();
</script>
<?php
} else {
?>
<script>
sniffleAdd('Error :c', 'An error occured on the servers', 'var(--red)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Error :c', 'An error occured on the servers', 'var(--red)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Denied', 'It seems that you do not have the right permitions to modify tags here.', 'var(--red)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
// Attempt to execute the prepared statement
if (mysqli_stmt_execute($stmt)) {
?>
<script>
sniffleAdd('Success!!!', 'Tags have been modified successfully! You may need to refresh the page to see the new information.', 'var(--success)', 'assets/icons/check.svg');
flyoutClose();
</script>
<?php
} else {
?>
<script>
sniffleAdd('Error :c', 'An error occured on the servers', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Error :c', 'An error occured on the servers', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Denied', 'It seems that you do not have the right permitions to modify tags here.', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
}
@ -217,42 +215,42 @@ if (isset($_POST['submit_tags'])) {
|-------------------------------------------------------------
*/
if (isset($_POST['submit_author'])) {
// If user has the ID of 1
if ($user_info->is_admin($conn, $_SESSION['id'])) {
// getting ready forSQL asky asky
$sql = "UPDATE images SET author=? WHERE id=?";
// If user has the ID of 1
if ($user_info->is_admin($conn, $_SESSION['id'])) {
// getting ready forSQL asky asky
$sql = "UPDATE images SET author=? WHERE id=?";
// Checking if databse is doing ok
if ($stmt = mysqli_prepare($conn, $sql)) {
mysqli_stmt_bind_param($stmt, "si", $param_author, $param_id);
// Checking if databse is doing ok
if ($stmt = mysqli_prepare($conn, $sql)) {
mysqli_stmt_bind_param($stmt, "si", $param_author, $param_id);
// Setting parameters
$param_author = $_POST['input'];
$param_id = $_POST["id"];
// Setting parameters
$param_author = $_POST['input'];
$param_id = $_POST["id"];
// Attempt to execute the prepared statement
if (mysqli_stmt_execute($stmt)) {
?>
<script>
sniffleAdd('Success!!!', 'The Author has been updated successfully! You may need to refresh the page to see the new information.', 'var(--green)', 'assets/icons/check.svg');
flyoutClose();
</script>
<?php
} else {
?>
<script>
sniffleAdd('Oopsie....', 'An error occured on the servers', 'var(--red)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
}
} else {
?>
<script>
sniffleAdd('Denied', 'Sussy wussy.', 'var(--red)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
}
// Attempt to execute the prepared statement
if (mysqli_stmt_execute($stmt)) {
?>
<script>
sniffleAdd('Success!!!', 'The Author has been updated successfully! You may need to refresh the page to see the new information.', 'var(--success)', 'assets/icons/check.svg');
flyoutClose();
</script>
<?php
} else {
?>
<script>
sniffleAdd('Oopsie....', 'An error occured on the servers', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
}
} else {
?>
<script>
sniffleAdd('Denied', 'Sussy wussy.', 'var(--warning)', 'assets/icons/cross.svg');
flyoutClose();
</script>
<?php
}
}

View file

@ -10,6 +10,7 @@ session_start();
// Include server connection
include dirname(__DIR__)."/server/conn.php";
include dirname(__DIR__)."/app.php";
include dirname(__DIR__)."/settings/settings.php";
use App\Make;
@ -17,23 +18,95 @@ $make_stuff = new Make();
if (isset($_POST['submit'])) {
if (isset($_SESSION['id'])) {
$error = 0;
// Root paths
$dir = "../../images/";
$thumb_dir = $dir."thumbnails/";
$preview_dir = $dir."previews/";
$dir = "../../images/";
$thumb_dir = $dir."thumbnails/";
$preview_dir = $dir."previews/";
// File name updating
$file_type = pathinfo($dir.$_FILES['image']['name'],PATHINFO_EXTENSION);
$image_newname = "IMG_".$_SESSION["username"]."_".round(microtime(true)).".".$file_type;
$image_path = $dir.$image_newname;
$file_type = pathinfo($dir.$_FILES['image']['name'],PATHINFO_EXTENSION);
// Clean tags
$tags = $make_stuff->tags(trim($_POST['tags']));
$tags = $make_stuff->tags(trim($_POST['tags']));
// Allowed file types
$allowed_types = array('jpg', 'jpeg', 'png', 'webp');
if (in_array($file_type, $allowed_types)) {
// Move file to server
// Check filetype
$allowed_types = array('jpg', 'jpeg', 'png', 'webp');
if (!in_array($file_type, $allowed_types)) {
?>
<script>
sniffleAdd('Woopsie', 'The file type you are trying to upload is not supported. Supported files include: JPEG, JPG, PNG and WEBP', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
$error += 1;
}
if ($upload_conf['rename_on_upload'] == true && $error <= 0) {
/* Accepted name templates includes
{{username}} -> Uploaders username
{{userid}} -> Uploaders ID
{{time}} -> microtime of upload
{{date}} -> date of upload
{{filename}} -> takes original filename
{{autoinc}} -> checks if file with name already exists
if so it adds a number on the end of it
"foo" -> Text is accepted between templates
*/
$name_template = $upload_conf['rename_to'];
$name_template = str_replace('{{username}}', $_SESSION["username"], $name_template);
$name_template = str_replace('{{userid}}', $_SESSION["id"], $name_template);
$name_template = str_replace('{{time}}', round(microtime(true)), $name_template);
$name_template = str_replace('{{date}}', date("Y-m-d"), $name_template);
$name_template = str_replace('{{filename}}', pathinfo($dir.$_FILES['image']['name'],PATHINFO_FILENAME), $name_template);
if (str_contains($name_template, "{{autoinc}}")) {
$autoinc = 0;
$autoinc_tmp_name = str_replace('{{autoinc}}', $autoinc, $name_template).".".$file_type;
while (is_file($dir.$autoinc_tmp_name)) {
$autoinc += 1;
$autoinc_tmp_name = str_replace('{{autoinc}}', $autoinc, $name_template).".".$file_type;
}
$name_template = str_replace('{{autoinc}}', $autoinc, $name_template);
}
$image_newname = $name_template.".".$file_type;
$image_path = $dir.$image_newname;
// Check for conflicting names, as the config could be setup wrong
if (is_file($image_path)) {
?>
<script>
sniffleAdd('Woopsie', 'There was an error in your manifest.json and cause filename errors, please setup a name with a unique template', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
$error += 1;
}
} else {
$image_newname = $_FILES['image']['name'];
$image_path = $dir.$image_newname;
// Check for file already existing under that name
if (is_file($image_path)) {
?>
<script>
sniffleAdd('Woopsie', 'A file under that name already exists!', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
$error += 1;
}
}
// Move file to server
if ($error <= 0) {
if (move_uploaded_file($_FILES['image']['tmp_name'], $image_path)) {
// Attempt making a thumbnail
list($width, $height) = getimagesize($image_path);
@ -41,7 +114,7 @@ if (isset($_POST['submit'])) {
if ($make_stuff->thumbnail($image_path, $thumb_dir.$image_newname, 300) != "success") {
?>
<script>
sniffleAdd('Gwha!', 'We hit a small roadbump during making of the thumbail. We will continue anyway! \n Full Error: <?php echo $make_thumbnail; ?>', 'var(--black)', 'assets/icons/bug.svg');
sniffleAdd('Gwha!', 'We hit a small roadbump during making of the thumbail. We will continue anyway! \n Full Error: <?php echo $make_thumbnail; ?>', 'var(--allert)', 'assets/icons/bug.svg');
</script>
<?php
}
@ -50,36 +123,36 @@ if (isset($_POST['submit'])) {
if ($make_stuff->thumbnail($image_path, $preview_dir.$image_newname, 900) != "success") {
?>
<script>
sniffleAdd('Gwha!', 'We hit a small roadbump during making of the preview. We will continue anyway! \n Full Error: <?php echo $make_preview; ?>', 'var(--black)', 'assets/icons/bug.svg');
sniffleAdd('Gwha!', 'We hit a small roadbump during making of the preview. We will continue anyway! \n Full Error: <?php echo $make_preview; ?>', 'var(--allert)', 'assets/icons/bug.svg');
</script>
<?php
}
}
// Prepare sql for destruction and filtering the sus
$sql = "INSERT INTO images (imagename, alt, tags, author) VALUES (?, ?, ?, ?)";
if ($stmt = mysqli_prepare($conn, $sql)) {
// Bind the smelly smelly
mysqli_stmt_bind_param($stmt, "ssss", $param_image_name, $param_alt_text, $param_tags, $param_user_id);
// Setting up parameters
$param_image_name = $image_newname;
$param_alt_text = $_POST['alt'];
$param_user_id = $_SESSION['id'];
$param_tags = $tags;
// Attempt to execute the prepared statement
if (mysqli_stmt_execute($stmt)) {
?>
<script>
sniffleAdd(':3', 'Your Image uploaded successfully!', 'var(--green)', 'assets/icons/check.svg');
sniffleAdd('Yeya :3', 'Your Image uploaded successfully!', 'var(--success)', 'assets/icons/check.svg');
</script>
<?php
} else {
?>
<script>
sniffleAdd(':c', 'Something went fuckywucky, please try later', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Gwaaa :c', 'Something went fuckywucky, please try later', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
}
@ -87,21 +160,15 @@ if (isset($_POST['submit'])) {
} else {
?>
<script>
sniffleAdd('Hmmff', 'Something happened when moving the file to the server. This may just been a 1-off so try again', 'var(--red)', 'assets/icons/bug.svg');
sniffleAdd('Hmmff', 'Something happened when moving the file to the server. This may just been a 1-off so try again', 'var(--warning)', 'assets/icons/bug.svg');
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Woopsie', 'The file type you are trying to upload is not supported. Supported files include: JPEG, JPG, PNG and WEBP', 'var(--red)', 'assets/icons/cross.svg');
</script>
<?php
}
} else {
?>
<script>
sniffleAdd('Denied!!!', 'As you are not loggedin, your upload has been stopped, L', 'var(--red)', 'assets/icons/cross.svg');
sniffleAdd('Denied!!!', 'As you are not loggedin, your upload has been stopped, L', 'var(--warning)', 'assets/icons/cross.svg');
</script>
<?php
}

13
app/required.php Normal file
View file

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

View file

@ -14,7 +14,7 @@ $conn_database = "gallery";
try {
$conn = @mysqli_connect($conn_ip, $conn_username, $conn_password , $conn_database);
} catch (Exception $e) {
header("location: error.php?e=conn");
die("Unable to connect to the database");
}
session_start();

View file

@ -1,25 +0,0 @@
<script>
console.log(". . /|/| . . . . . . .\n\
.. /0 0 \\ . . . . . ..\n\
(III% . \\________, . .\n\
.. .\\_, .%###%/ \\'\\,..\n\
. . . .||#####| |'\\ \\.\n\
.. . . ||. . .|/. .\\V.\n\
. . . .|| . . || . . .\n\
.. . . ||. . .||. . ..\n\
. . . .|| . . || . . .\n\
.. . . ||. . .||. . ..\n\
. . . .|| . . || . . .\n\
.. . . ||. . .||. . ..\n\
. . . .|| . . || . . .\n\
.. . . ||. . .||. . ..\n\
. . . .|| . . || . . .\n\
.. . . ||. . .||. . ..\n\
. . . .|| . . || . . .\n\
.. . . ||. . .||. . ..\n\
. . . .|| . . || . . .\n\
.. . . ||. . .||. . ..\n\
. . . .|| . . || . . .\n\
.. . . ||. . .||. . ..\n\
. . . cc/ . .cc/ . . .");
</script>

View file

@ -1,7 +1,6 @@
{
"website_name": "Only Legs",
"website_description": "A simple PHP gallery with multiple users in mind",
"tos": "When making an account and interacting with the login/signup page, you agree to have your IP logged for banning purposes.",
"welcome_msg": [
"*internal screaming*",
"Don't forget to drink water!",
@ -22,12 +21,15 @@
"The weather is dry",
"Need me a man 👀",
"Gods die too.",
"Eat hotchip and lie",
"The world will not be destroyed by those who do evil, but by those who watch them and do nothing."
"Eat hotchip and lie"
],
"license":"GPL 3.0",
"version": "22.09.20",
"user_name": "Michal",
"is_testing": "true",
"upload_max": "20"
"version": "22.09.29",
"user_name": "[your name]",
"is_testing": true,
"upload": {
"max_filesize": "32",
"rename_on_upload": true,
"rename_to": "IMG_{{username}}_{{time}}"
}
}

View file

@ -8,13 +8,6 @@
| the default background and accent colour
|-------------------------------------------------------------
*/
$user_import = file_get_contents(__DIR__."/manifest.json");
$user_settings = json_decode($user_import, true);
foreach ($user_settings->data as $website) {
foreach ($website->debug as $debug) {
}
}
$debug = $user_settings["website"]["debug"];
$user_import = file_get_contents(__DIR__."/manifest.json");
$user_settings = json_decode($user_import, true);
$upload_conf = $user_settings["upload"];

1
assets/icons/package.svg Normal file
View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="192" height="192" fill="#e8e3e3" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"></rect><path d="M224,177.3V78.7a8.1,8.1,0,0,0-4.1-7l-88-49.5a7.8,7.8,0,0,0-7.8,0l-88,49.5a8.1,8.1,0,0,0-4.1,7v98.6a8.1,8.1,0,0,0,4.1,7l88,49.5a7.8,7.8,0,0,0,7.8,0l88-49.5A8.1,8.1,0,0,0,224,177.3Z" fill="none" stroke="#e8e3e3" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"></path><polyline points="177 152.5 177 100.5 80 47" fill="none" stroke="#e8e3e3" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"></polyline><polyline points="222.9 74.6 128.9 128 33.1 74.6" fill="none" stroke="#e8e3e3" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"></polyline><line x1="128.9" y1="128" x2="128" y2="234.8" fill="none" stroke="#e8e3e3" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"></line></svg>

After

Width:  |  Height:  |  Size: 901 B

1
assets/icons/plus.svg Normal file
View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="192" height="192" fill="#e8e3e3" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"></rect><line x1="40" y1="128" x2="216" y2="128" fill="none" stroke="#e8e3e3" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"></line><line x1="128" y1="40" x2="128" y2="216" fill="none" stroke="#e8e3e3" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"></line></svg>

After

Width:  |  Height:  |  Size: 442 B

7
assets/ui/footer.php Normal file
View file

@ -0,0 +1,7 @@
<footer>
<p>Hosted by <?php echo $user_settings['user_name']; ?></p>
<hr>
<a class='link' href="https://github.com/Fluffy-Bean/image-gallery">Made by Fluffy</a>
<hr>
<p>Version <?php echo $user_settings['version']; ?></p>
</footer>

47
assets/ui/header.php Normal file
View file

@ -0,0 +1,47 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<?php
// Get image info for image meta
if ( basename($_SERVER['PHP_SELF']) == "image.php") {
$image = $image_info->get_image_info($conn, $_GET['id']);
}
?>
<!-- Auto generated header tags -->
<title><?php echo $user_settings['website_name']; ?></title>
<meta name="description" content="<?php echo $user_settings['website_description']; ?>"/>
<meta name="keywords" content="Image, Gallery"/>
<meta name="author" content="<?php echo $user_settings['user_name']; ?>"/>
<!-- OG -->
<meta property="og:title" content="<?php echo $user_settings['website_name']; ?>"/>
<meta property="og:description" content="<?php echo $user_settings['website_description']; ?>"/>
<meta property="og:image" content="<?php echo "images/".$image['imagename']; ?>"/>
<meta property="og:type" content="website"/>
<meta name="theme-color" content="#8C977D">
<!-- Twitter -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:description" content="<?php echo $user_settings['website_description']; ?>"/>
<meta name="twitter:title" content="<?php echo $user_settings['website_name']; ?>"/>
<!-- Stylesheets -->
<link rel="stylesheet" href="css/main.css">
<!-- Google Fonts -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Lexend+Deca:wght@600">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Secular+One&display=swap">
<!-- JQuery -->
<script
src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
crossorigin="anonymous">
</script>
<!-- Sniffle script! -->
<script src="Sniffle/sniffle.js"></script>
<link rel='stylesheet' href='Sniffle/sniffle.css'>
<!-- Flyout script! -->
<script src="Flyout/flyout.js"></script>
<link rel='stylesheet' href='Flyout/flyout.css'>

108
assets/ui/nav.php Normal file
View file

@ -0,0 +1,108 @@
<?php
use App\Account;
$loggedin = new Account();
?>
<nav class="nav-root">
<div class="nav-name">
<p><?php echo $user_settings['website_name']; ?></p>
</div>
<div class="nav-links">
<a class='btn' href='index.php'><img class='svg' src='assets/icons/house.svg'><span class='nav-hide'>Home</span></a>
<hr>
<a class='btn' href='group.php'><img class='svg' src='assets/icons/package.svg'><span class='nav-hide'>Groups</span></a>
<hr>
<?php
if ($_SESSION["loggedin"]) {
?>
<a class='btn' href='upload.php'><img class='svg' src='assets/icons/upload.svg'><span class='nav-hide'>Upload</span></a>
<hr>
<a class='btn' href='account.php'><img class='svg' src='assets/icons/gear.svg'><span class='nav-hide'><?php echo substr($_SESSION["username"], 0, 15); ?></span></a>
<?php
} else {
?>
<a class='btn' href='account.php'><img class='svg' src='assets/icons/sign-in.svg'><span class='nav-hide'>Login</span></a>
<?php
}
?>
</div>
</nav>
<script>
console.log(". . /|/| . . . . . . .\n\
.. /0 0 \\ . . . . . ..\n\
(III% . \\________, . .\n\
.. .\\_, .%###%/ \\'\\,..\n\
. . . .||#####| |'\\ \\.\n\
.. . . ||. . .|/. .\\V.\n\
. . . .|| . . || . . .\n\
.. . . ||. . .||. . ..\n\
. . . .|| . . || . . .\n\
.. . . ||. . .||. . ..\n\
. . . .|| . . || . . .\n\
.. . . ||. . .||. . ..\n\
. . . .|| . . || . . .\n\
.. . . ||. . .||. . ..\n\
. . . .|| . . || . . .\n\
.. . . ||. . .||. . ..\n\
. . . .|| . . || . . .\n\
.. . . ||. . .||. . ..\n\
. . . .|| . . || . . .\n\
.. . . ||. . .||. . ..\n\
. . . .|| . . || . . .\n\
.. . . ||. . .||. . ..\n\
. . . cc/ . .cc/ . . .");
</script>
<!--
Used by Sniffle to add Notifications
Div can be displayed all time as it has no width or height initself
-->
<div id='sniffle' class='sniffle'></div>
<span id="newSniff" style="display: none;"></span>
<!--
Div for information flyouts
Controlled by Flyout.js
-->
<div id='flyoutDim' class='flyout-dim'></div>
<div id='flyoutRoot' class='flyout'>
<p id='flyoutHeader' class='flyout-header'>Header</p>
<br>
<p id='flyoutDescription' class='flyout-description'>Description</p>
<br>
<div id='flyoutActionbox' class='flyout-actionbox'></div>
<button onclick='flyoutClose()' class='btn btn-neutral'>Close</button>
</div>
<!--
Back to top button
Used to quickly get back up to the top of the page,
At some point will be removed as the UI metures and
everything can always be accessed
-->
<a id="back-to-top" href="#">
<img src="assets/icons/caret-up.svg">
</a>
<script>
button = document.getElementById("back-to-top");
window.onscroll = function() {
scrollFunction()
};
function scrollFunction() {
if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 20) {
button.style.right = "1rem";
} else {
button.style.right = "-2.5rem";
}
}
</script>
<!--
Required so main objects are centered when NAV
is in mobile view
-->
<div class="nav-mobile"></div>

File diff suppressed because it is too large Load diff

View file

@ -78,7 +78,11 @@ body {
text-decoration: none;
border: none;
border-radius: calc($rad - (0.5rem + 3px));
@if calc($rad - 0.5rem) > 0 {
border-radius: calc($rad - 0.5rem);
} @else {
border-radius: 3px;
}
transition: outline 0.1s cubic-bezier(.19, 1, .22, 1);
@ -102,7 +106,11 @@ body {
background-color: $white;
border: none;
border-radius: $rad;
@if calc($rad - 0.5rem) > 0 {
border-radius: calc($rad - 0.5rem);
} @else {
border-radius: 3px;
}
}
}
@ -110,16 +118,22 @@ a.btn {
text-align: center;
}
.btn-good {
background-color: $page-accent;
}
.btn-bad {
background-color: $red;
background-color: $warning;
/*color: darken($warning, 40%);*/
}
.btn-warning {
background-color: $alert;
/*color: darken($warning, 40%);*/
}
.btn-good {
background-color: $page-accent;
/*color: darken($warning, 40%);*/
}
.btn-neutral {
background-color: $black;
background-color: $neutral;
/*color: $white;*/
}
/*
@ -131,7 +145,7 @@ form {
width: 100%;
box-sizing: content-box;
>* {
& > * {
margin-bottom: 0.5rem;
}
}
@ -166,6 +180,20 @@ br {
line-height: 0.25rem;
}
/*
|-------------------------------------------------------------
| Link text
|-------------------------------------------------------------
*/
a.link {
display: inline;
text-decoration: underline;
&:hover {
color: $page-accent;
}
}
/*
|-------------------------------------------------------------
| BACK TO TOP
@ -185,7 +213,12 @@ br {
background-color: $bg-alt;
backdrop-filter: blur(8px);
border-radius: 50%;
@if calc($rad - 0.5rem) > 0 {
border-radius: calc($rad - 0.5rem);
} @else {
border-radius: 3px;
}
box-shadow: $shadow;
transition: right 0.15s cubic-bezier(.19, 1, .22, 1);

View file

@ -1,26 +1,40 @@
/*
|-------------------------------------------------------------
| DEFAULTS
|-------------------------------------------------------------
*/
.defaultSpacing {
@include defaultSpacing();
}
.defaultDecoration {
@include defaultDecoration($page-accent);
}
.warningDecoration {
@include defaultDecoration($red);
}
.defaultFonts {
@include defaultFont();
}
/*
|-------------------------------------------------------------
| INDEX
|-------------------------------------------------------------
*/
.info-text {
@include defaultFont();
margin: 1rem 0 1rem 0.5rem;
padding: 0;
text-align: center;
h1 {
font-family: $font-header;
margin-top: 0;
margin-bottom: 1rem;
}
p {
font-family: $font-body;
margin-top: 0;
margin-bottom: 1rem;
}
@ -46,17 +60,7 @@
margin-bottom: 1rem;
padding: 0.25rem;
background-color: $bg;
color: $fg;
display: flex;
flex-direction: row;
flex-wrap: wrap;
border: 0.2rem solid $page-accent;
border-radius: $rad;
box-shadow: $shadow;
@include flexLeft(none);
}
.gallery-item {
@ -64,10 +68,15 @@
padding: 0;
height: auto;
max-width: calc(33.33% - 0.5rem);
max-width: calc(20% - 0.5rem);
min-width: calc(20% - 0.5rem);
background-color: $bg;
border-radius: calc($rad - 0.5rem);
@if calc($rad - 0.5rem) > 0 {
border-radius: calc($rad - 0.5rem);
} @else {
border-radius: 3px;
}
position: relative;
@ -84,6 +93,10 @@
z-index: 9;
}
&:active {
transform: scale(0.8) !important;
}
&:after {
content: "";
display: block;
@ -91,6 +104,19 @@
}
}
@media (max-width: 800px) {
.gallery-item {
max-width: calc(25% - 0.5rem);
min-width: calc(25% - 0.5rem);
}
}
@media (max-width: 550px) {
.gallery-item {
max-width: calc(33.33% - 0.5rem);
min-width: calc(33.33% - 0.5rem);
}
}
.gallery-image {
margin: 0;
padding: 0;
@ -108,7 +134,11 @@
object-fit: cover;
object-position: center;
border-radius: calc($rad - 0.5rem);
@if calc($rad - 0.5rem) > 0 {
border-radius: calc($rad - 0.5rem);
} @else {
border-radius: 3px;
}
}
.nsfw-blur {
@ -116,6 +146,9 @@
}
.nsfw-warning {
@include flexDown(center);
align-items: center;
width: 100%;
height: 100%;
@ -127,11 +160,6 @@
position: absolute;
z-index: 5;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-decoration: none;
font-family: $font-body;
@ -168,11 +196,78 @@
| IMAGE
|-------------------------------------------------------------
*/
.fullscreen-image {
width: 101vw; height: 101vh;
position: fixed;
top: 50%;
left: 50%;
transform: translateX(-050%) translateY(-50%);
background-color: $bg-alt;
backdrop-filter: blur(15px);
z-index: 999;
transition: opacity 0.5s cubic-bezier(0.075, 0.82, 0.165, 1);
display: none; // Automatically hidden, revealed on fullscreen
opacity: 0; // expose
img {
max-width: 95%; max-height: 95%;
position: absolute;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
border-radius: $rad;
z-index: +1;
}
button {
padding: 0.25rem;
width: 2rem; height: 2rem;
position: absolute;
top: 1.25rem;
right: 1.25rem;
display: block;
box-sizing: border-box;
border: none;
border-radius: $rad;
transition: outline 0.1s cubic-bezier(.19, 1, .22, 1);
background-color: $black;
z-index: +2;
img {
width: 1.5rem;
display: block;
}
&:hover {
outline: $white 0.2rem solid;
color: $fg;
cursor: pointer;
}
}
}
.image-container {
margin: 1rem 0 2rem 0;
padding: 0;
padding: 0.5rem;
width: 100%;
width: calc(100% - 1rem);
max-height: 50vh;
height: auto;
min-height: 30vh;
@ -201,15 +296,19 @@
max-height: inherit;
height: auto;
border-radius: $rad;
@if calc($rad - 0.5rem) > 0 {
border-radius: calc($rad - 0.5rem);
} @else {
border-radius: 3px;
}
transition: opacity 0.5s;
}
.preview-button {
width: 1.5rem;
padding: 0.25rem;
padding: 0;
width: 2rem; height: 2rem;
position: absolute;
bottom: 0.5rem;
@ -218,22 +317,18 @@
display: block;
box-sizing: border-box;
font-size: 14px;
font-weight: 500;
font-family: $font-body;
text-decoration: none;
border: none;
border-radius: calc($rad - (0.5rem + 3px));
@if calc($rad - 0.5rem) > 0 {
border-radius: calc($rad - 0.5rem);
} @else {
border-radius: 3px;
}
transition: outline 0.1s cubic-bezier(.19, 1, .22, 1);
background-color: $black;
background-color: $bg-alt;
opacity: 0.8;
box-shadow: $shadow;
z-index: +2;
img {
width: 1.5rem;
@ -244,21 +339,14 @@
&:hover {
outline: $white 0.2rem solid;
color: $fg;
}
}
// DESCRIPTION
.image-description {
@include defaultDecoration($page-accent);
@include defaultFont();
cursor: pointer;
}
}
// DETAILS
.image-detail {
@include defaultDecoration($page-accent);
@include defaultFont();
&>div {
width: 100%;
display: flex;
@ -289,12 +377,6 @@
}
}
// TAGS
.tags-root {
@include defaultDecoration($page-accent);
@include defaultFont();
}
.tags {
@include flexLeft(auto);
margin-bottom: 0;
@ -308,7 +390,11 @@
background-color: $page-accent;
border-radius: calc($rad - (0.5rem + 3px));
@if calc($rad - 0.5rem) > 0 {
border-radius: calc($rad - 0.5rem);
} @else {
border-radius: 3px;
}
font-family: $font-body;
@ -317,20 +403,307 @@
}
}
// DANGER ZONE
.danger-zone {
@include defaultDecoration($red);
@include defaultFont();
}
/*
|-------------------------------------------------------------
| ABOUT
| Groups
|-------------------------------------------------------------
*/
.about-root {
@include defaultDecoration($page-accent);
@include defaultFont();
.group-banner {
position: relative;
}
.group-description {
height: auto;
width: auto;
position: relative;
z-index: +1;
h2 {
span {
margin-left: 0.25rem;
font-size: 16px;
}
a {
margin-left: 0.25rem;
font-size: 16px;
color: $page-accent;
text-decoration: none;
}
}
& > * {
margin: 0 0 0.5rem 0;
}
a {
text-decoration: none;
&:hover {
color: $page-accent;
}
}
.btn:hover {
color: $fg;
}
}
.group-cover {
height: 100%;
max-width: 50%;
width: auto;
position: absolute;
display: inline-block;
right: 0;
top: 0;
overflow: hidden;
z-index: 0;
span {
width: 100%;
height: 100%;
position: absolute;
background: linear-gradient(to right, $bg, rgba($bg, 0.8), rgba($bg, 0.2));
z-index: +1;
border-radius: calc($rad - $border-thickness);
}
img {
width: 100%;
height: 100%;
object-fit: cover;
margin-left: auto;
border-radius: calc($rad - $border-thickness);
}
}
.selectedImage {
outline: $page-accent solid 0.3rem;
transform: scale(0.8) !important;
}
.group-name {
margin: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
transition: opacity 0.1s cubic-bezier(.19, 1, .22, 1);
z-index: 6;
opacity: 0;
font-size: 17px;
font-family: $font-body;
text-decoration: none;
text-align: center;
}
.gallery-group {
width: 100%;
height: 100%;
top: 0;
bottom: 0;
left: 0;
right: 0;
position: absolute;
z-index: 5;
}
.group-item {
& .gallery-group {
backdrop-filter: brightness(0.5);
}
& .nsfw-warning > * {
display: none;
}
& .group-name {
opacity: 1;
}
}
.group-make {
margin: 0.25rem;
padding: 0;
height: auto;
max-width: calc(20% - 0.5rem);
min-width: calc(20% - 0.5rem);
@if calc($rad - 0.5rem) > 0 {
border-radius: calc($rad - 0.5rem);
} @else {
border-radius: 3px;
}
position: relative;
overflow: hidden;
flex: 1 0 150px;
transition: outline 0.1s cubic-bezier(.19, 1, .22, 1);
&:hover {
outline: $white 0.2rem solid;
}
&:after {
content: "";
display: block;
padding-bottom: 100%;
}
button {
@include flexDown(center);
align-items: center;
width: 100%;
height: 100%;
padding: 0;
background-color: $black;
@if calc($rad - 0.5rem) > 0 {
border-radius: calc($rad - 0.5rem);
} @else {
border-radius: 3px;
}
border: none;
top: 0;
bottom: 0;
left: 0;
right: 0;
position: absolute;
z-index: 5;
text-decoration: none;
font-family: $font-body;
&:hover {
color: $fg;
cursor: pointer;
}
span {
text-align: center;
}
img {
margin: 0.25rem;
width: 2.5rem;
height: 2.5rem;
}
}
}
@media (max-width: 800px) {
.group-make {
max-width: calc(25% - 0.5rem);
min-width: calc(25% - 0.5rem);
}
}
@media (max-width: 550px) {
.group-make {
max-width: calc(33.33% - 0.5rem);
min-width: calc(33.33% - 0.5rem);
}
}
/*
|-------------------------------------------------------------
| profile
|-------------------------------------------------------------
*/
.profile-root {
margin: 3rem auto 1rem auto;
min-height: 7rem;
position: relative;
text-align: center;
img {
width: 9rem;
height: 9rem;
object-fit: cover;
position: absolute;
left: 6rem;
top: -3rem;
transform: translateX(-50%);
border-radius: $rad;
border: $border;
background-color: $bg;
}
h2, & > p {
margin: 0 0 0.5rem 0;
padding-left: 11rem;
}
}
.profile-info {
margin-top: 0;
margin-bottom: 0.5rem;
padding-left: 11rem;
display: flex; flex-direction: column;
text-align: center;
& > * {
margin-top: 0;
margin-bottom: 0.5rem;
}
}
@media (max-width: 669px) {
.profile-root {
img {
position: absolute;
left: 50%;
top: -3rem;
transform: translateX(-50%);
}
h2 {
margin: 7rem 0 0.5rem 0;
padding: 0;
}
& > p {
padding: 0;
}
}
.profile-info {
padding: 0;
& > * {
padding: 0;
}
}
}
/*
@ -338,9 +711,20 @@
| UPLOAD
|-------------------------------------------------------------
*/
.upload-root {
@include defaultDecoration($page-accent);
@include defaultFont();
.upload-root > img {
margin: 0 auto;
max-width: 100%;
max-height: 15rem;
@if calc($rad - 0.5rem) > 0 {
border-radius: calc($rad - 0.5rem);
} @else {
border-radius: 3px;
}
display: flex;
flex-direction: column;
}
/*
@ -348,13 +732,46 @@
| ACCOUNT
|-------------------------------------------------------------
*/
.account-root {
@include defaultDecoration($page-accent);
@include defaultFont();
.pfp-upload {
display: flex;
flex-direction: row;
& > img {
margin-left: 0.5rem;
width: 7.813rem;
height: 7.813rem;
object-fit: cover;
@if calc($rad - 0.5rem) > 0 {
border-radius: calc($rad - 0.5rem);
} @else {
border-radius: 3px;
}
background-color: $black;
}
form > * {
margin: 0 0 0.5rem 0;
}
form > *:last-child {
margin: 0 0 0 0;
}
}
.admin-root {
@include defaultDecoration($page-accent);
@include defaultFont();
@media (max-width: 621px) {
.pfp-upload {
display: flex;
flex-direction: column-reverse;
& > img {
margin: 0 auto 1rem;
width: 10rem;
height: 10rem;
}
}
}
.tabs {
@ -383,10 +800,14 @@
display: none; flex-direction: column;
background-color: $bg;
border-radius: calc($rad - (0.5rem + 3px));
@if calc($rad - 0.5rem) > 0 {
border-radius: calc($rad - 0.5rem);
} @else {
border-radius: 3px;
}
}
.log {
min-width: 769px;
min-width: 850px;
padding: 0.5rem;
@ -395,7 +816,7 @@
justify-content: space-between;
&:nth-child(even) {
background-color: #ffffff11;
background-color: #E8E3E311;
}
& > * {
@ -435,10 +856,14 @@
display: none; flex-direction: column;
background-color: $bg;
border-radius: calc($rad - (0.5rem + 3px));
@if calc($rad - 0.5rem) > 0 {
border-radius: calc($rad - 0.5rem);
} @else {
border-radius: 3px;
}
}
.ban {
min-width: 769px;
min-width: 900px;
padding: 0.5rem;
@ -447,7 +872,7 @@
justify-content: space-between;
&:nth-child(even) {
background-color: #ffffff11;
background-color: #E8E3E311;
}
& > * {
@ -474,7 +899,7 @@
}
}
.perm {
border-left: $red 0.2rem solid;
border-left: $border;
}
.ban:first-of-type {
background-color: $bg;
@ -493,10 +918,14 @@
display: none; flex-direction: column;
background-color: $bg;
border-radius: calc($rad - (0.5rem + 3px));
@if calc($rad - 0.5rem) > 0 {
border-radius: calc($rad - 0.5rem);
} @else {
border-radius: 3px;
}
}
.user {
min-width: 769px;
min-width: 950px;
padding: 0.5rem;
@ -505,7 +934,7 @@
justify-content: space-between;
&:nth-child(even) {
background-color: #ffffff11;
background-color: #E8E3E311;
}
& > * {
@ -535,41 +964,10 @@
}
}
.is-admin {
border-left: $page-accent 0.2rem solid;
border-left: $border;
}
.user:first-of-type {
background-color: $bg;
position: sticky;
top: 0;
}
.signup-root {
@include defaultDecoration($page-accent);
@include defaultFont();
// By default its hidden, in place is login
display: none;
}
.login-root {
@include defaultDecoration($page-accent);
@include defaultFont();
}
/*
|-------------------------------------------------------------
| PASSWORD RESET
|-------------------------------------------------------------
*/
.password-reset-root {
@include defaultDecoration($red);
@include defaultFont();
}
/*
|-------------------------------------------------------------
| ERROR PAGE
|-------------------------------------------------------------
*/
.error-root {
@include defaultDecoration($page-accent);
@include defaultFont();
}

View file

@ -6,23 +6,28 @@
footer {
margin: 0 auto;
width: calc(100% - 1.4rem);
width: auto;
text-align: center;
font-size: 12px;
text-transform: uppercase;
display: flex; flex-direction: row;
p {
margin: 0 0.5rem;
margin: 0.2rem;
padding: 0;
text-decoration: none;
font-size: 16px;
font-family: $font-body;
}
a {
margin: 0 0.5rem;
margin: 0.2rem;
padding: 0;
text-decoration: none;
font-size: 16px;
font-family: $font-body;

View file

@ -1,18 +1,18 @@
@mixin defaultDecoration($border) {
margin-bottom: 1rem;
padding: 0.5rem 0.5rem 0 0.5rem;
width: calc(100% - 1.4rem);
@mixin defaultDecoration($border-colour) {
background-color: $bg;
color: $fg;
border-radius: $rad;
border: 0.2rem solid $border;
border: $border-colour $border-thickness solid;
box-shadow: $shadow;
}
@mixin defaultSpacing() {
margin-bottom: 1rem;
padding: 0.5rem 0.5rem 0 0.5rem;
width: calc(100% - 1.4rem);
>* {
margin-top: 0;
@ -28,6 +28,7 @@
h4,
h5 {
font-family: $font-header;
text-rendering: optimizeLegibility;
}
p,
@ -35,6 +36,7 @@
button,
input {
font-family: $font-body;
text-rendering: optimizeLegibility;
}
}

View file

@ -11,7 +11,7 @@ nav {
padding: 0.5rem;
width: calc(100% - 1.4rem);
height: 2.5rem;
height: auto;
position: sticky;
z-index: 99;
@ -56,6 +56,10 @@ nav {
font-family: $font-body;
width: auto;
a.btn {
padding: 0.2rem 0.5rem;
}
}
.nav-mobile {
@ -77,6 +81,7 @@ nav {
margin: 0;
width: calc(100% - 1rem);
height: 2.5rem;
position: fixed;
top: auto;
@ -88,7 +93,7 @@ nav {
backdrop-filter: blur(8px);
border: none;
border-top: 3px solid $green;
border-top: $border;
border-radius: 0;
backdrop-filter: blur(16px);
@ -100,6 +105,12 @@ nav {
}
}
.nav-links {
a.btn {
padding: 0.5rem;
}
}
.nav-hide {
display: none;
}

View file

@ -5,15 +5,26 @@ $fg: #E8E3E3;
$fg-alt: #151515;
$red: #B66467;
$orange: #FF7700;
$orange: #D8A657;
$yellow: #D9BC8C;
$green: #8C977D;
$black: #151515;
$blue: #8DA3B9;
$purple: #A988B0;
$black: #121212;
$white: #E8E3E3;
$page-accent: #8C977D;
$warning: $red;
$alert: $orange;
$success: $green;
$neutral: $black;
$shadow: 6px 6px 2px #15151566;
$rad: 0.25rem;
$rad: 0.4rem;
$border-thickness: 0.2rem;
$border: $page-accent $border-thickness solid;
$weight-bold: 621;
$weight-normal: 400;
@ -35,13 +46,21 @@ sans-serif;
--red: #{$red};
--orange: #{$orange};
--yellow: #{$yellow};
--green: #{$green};
--blue: #{$blue};
--purple: #{$purple};
--black: #{$black};
--white: #{$white};
--accent: #{$page-accent};
--warning: #{$warning};
--alert: #{$alert};
--success: #{$success};
--neutral: #{$neutral};
--shadow: #{$shadow};
--rad: #{$rad};
--border: #{$border};
}

View file

@ -1,26 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<?php require_once __DIR__."/ui/header.php"; ?>
</head>
<body>
<div></div>
<div class="error-root">
<h2>Woops...</h2>
<?php
if ($_GET["e"] == "conn") {
echo "<p>An error occured while connecting to the server. If you're an admin, check the database configuration and/or make sure the database is alive</p>";
} else {
echo "<p>An error occured! But no description was provided.</p>";
}
?>
</div>
<?php require_once __DIR__."/ui/footer.php"; ?>
</body>
</html>

365
group.php Normal file
View file

@ -0,0 +1,365 @@
<?php
require_once __DIR__."/app/required.php";
use App\Account;
use App\Image;
use App\Group;
use App\Diff;
$user_info = new Account;
$image_info = new Image;
$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>
sniffleAdd("Error", "<?php echo $_SESSION['msg']; ?>", "var(--warning)", "assets/icons/trash.svg");
</script>
<?php
unset($_SESSION['err']);
}
?>
<!DOCTYPE html>
<html>
<head>
<?php require_once __DIR__."/assets/ui/header.php"; ?>
</head>
<body>
<?php
require_once __DIR__."/assets/ui/nav.php";
if (isset($_SESSION['msg'])) {
?>
<script>
sniffleAdd("Info", "<?php echo $_SESSION['msg']; ?>", "var(--green)", "assets/icons/check.svg");
</script>
<?php
unset($_SESSION['msg']);
}
?>
<?php
if (isset($_GET['id'])) {
$image_list = array_reverse(explode(" ", $group['image_list']));
echo "<div class='group-banner defaultDecoration defaultSpacing defaultFonts'>
<div class='group-description'>";
$author_info = $user_info->get_user_info($conn, $group['author']);
echo "<h2>".$group['group_name']."<span>by</span><a href='profile.php?user=".$author_info['id']."'>".$author_info['username']."</a></h2>";
$group_members = $group_info->get_group_members($conn, $_GET['id']);
if (!empty($group_members)) {
$members_array = array();
foreach ($group_members as $member) {
$member_info = $user_info->get_user_info($conn, $member);
if (!empty($member_info['username'])) $members_array[] = "<a href='profile.php?user=".$member_info['id']."'>".$member_info['username']."</a>";
}
echo "<p>Featured: ".implode(", ", $members_array)."</p>";
}
if (!empty($group['image_list'])) echo "<p>Images: ".count(explode(" ", $group['image_list']))."</p>";
$upload_time = new DateTime($group['created_on']);
echo "<p id='updateTime'>Created at: ".$upload_time->format('d/m/Y H:i:s T')."</p>";
?>
<script>
var updateDate = new Date('<?php echo $upload_time->format('m/d/Y H:i:s T'); ?>');
updateDate = updateDate.toLocaleDateString('en-GB', {year: 'numeric', month: 'short', day: 'numeric'});
$("#updateTime").html("Created at: "+updateDate);
</script>
<?php
echo "<p>Last Modified: ".$diff->time($group['last_modified'])."</p>";
if ($_GET['mode'] == "edit") {
if ($_SESSION['id'] == $group['author'] || $user_info->is_admin($conn, $_SESSION['id'])) {
echo "<br>";
echo "<button id='deleteGroup' class='btn btn-bad'>Delete</button>";
?>
<script>
$('#deleteGroup').click(function() {
var header = "Are you surrrrrre?";
var description = "The images will still be up, but all your hard work setting this group up will be gone!";
var actionBox = "<form id='titleForm' method='POST'>\
<button id='deleteSubmit' class='btn btn-bad' type='submit'><img class='svg' src='assets/icons/trash.svg'>Delete group</button>\
</form>";
flyoutShow(header, description, actionBox);
$("#titleForm").submit(function(event) {
event.preventDefault();
var deleteSubmit = $("#deleteSubmit").val();
$("#newSniff").load("app/image/group.php", {
group_id: <?php echo $_GET['id']; ?>,
group_delete: deleteSubmit
});
});
});
</script>
<?php
echo "<button id='editTitle' class='btn btn-bad'>Update title</button>";
?>
<script>
$('#editTitle').click(function() {
var header = "Newwww photo group name!";
var description = "What will it be? uwu";
var actionBox = "<form id='titleForm' action='app/image/edit_description.php' method='POST'>\
<input id='titleText' class='btn btn-neutral' type='text' placeholder='New title'>\
<button id='titleSubmit' class='btn btn-bad' type='submit'><img class='svg' src='assets/icons/edit.svg'>Update title</button>\
</form>";
flyoutShow(header, description, actionBox);
$("#titleForm").submit(function(event) {
event.preventDefault();
var titleText = $("#titleText").val();
var titleSubmit = $("#titleSubmit").val();
$("#newSniff").load("app/image/group.php", {
group_id: <?php echo $_GET['id']; ?>,
group_title: titleText,
title_submit: titleSubmit
});
});
});
</script>
<?php
echo "<br>";
$image_request = mysqli_query($conn, "SELECT * FROM images");
echo "<form id='groupForm'>";
while ($image = mysqli_fetch_array($image_request)) {
if (in_array($image['id'], $image_list)) {
echo "<input style='display: none;' type='checkbox' id='".$image['id']."' name='".$image['id']."' checked/>";
} else {
echo "<input style='display: none;' type='checkbox' id='".$image['id']."' name='".$image['id']."'/>";
}
}
echo "<button id='groupSubmit' class='btn btn-good' type='submit'>Save changes</button>
</form>";
echo "<a href='group.php?id=".$_GET['id']."' class='btn btn-neutral'>Back</a>";
}
} else {
if ($_SESSION['id'] == $group['author'] || $user_info->is_admin($conn, $_SESSION['id'])) {
echo "<a href='group.php?id=".$_GET['id']."&mode=edit' class='btn btn-neutral'>Edit</a>";
}
?>
<button class='btn btn-good' onclick='copyLink()'><img class='svg' src='assets/icons/clipboard-text.svg'>Copy link</button>
<script>
function copyLink() {
navigator.clipboard.writeText(window.location.href);
sniffleAdd("Info", "Link has been copied!", "var(--success)", "assets/icons/clipboard-text.svg");
}
</script>
<?php
}
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
}
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") {
$image_request = mysqli_query($conn, "SELECT * FROM images ORDER BY id DESC");
while ($image = mysqli_fetch_array($image_request)) {
// Getting thumbnail
if (file_exists("images/thumbnails/".$image['imagename'])) {
$image_path = "images/thumbnails/".$image['imagename'];
} else {
$image_path = "images/".$image['imagename'];
}
if (in_array($image['id'], $image_list)) {
echo "<div id='".$image['id']."' class='gallery-item selectedImage'>
<img class='gallery-image' loading='lazy' src='".$image_path."' id='".$image['id']."'>
</div>";
} else {
echo "<div id='".$image['id']."' class='gallery-item'>
<img class='gallery-image' loading='lazy' src='".$image_path."' id='".$image['id']."'>
</div>";
}
}
?>
<script>
$(".gallery-item").click(function() {
if (this.classList.contains("selectedImage")) {
deselect(this);
} else {
select(this);
}
});
function select(item) {
document.getElementById(item.id).checked = true;
item.classList.add("selectedImage");
}
function deselect(item) {
document.getElementById(item.id).checked = false;
item.classList.remove("selectedImage");
}
function getList() {
var checkedBoxes = document.querySelectorAll('input[type=checkbox]:checked');
var images = [];
checkedBoxes.forEach(element => { images.push(element.id); });
return images;
}
$("#groupForm").submit(function(event) {
event.preventDefault();
var groupSubmit = $("#groupSubmit").val();
var images = getList();
if (images <= 0) {
sniffleAdd('Oppsie', 'Groups need at least 1 image in them. Alternativly, you can delete this group.', 'var(--warning)', 'assets/icons/cross.svg');
} else {
$("#newSniff").load("app/image/group.php", {
group_images: images,
group_id: <?php echo $_GET['id']; ?>,
group_submit: groupSubmit
});
}
});
</script>
<?php
} else {
foreach ($image_list as $image) {
// Reading images from table
try {
$image_request = mysqli_query($conn, "SELECT * FROM images WHERE id = ".$image);
while ($image = mysqli_fetch_array($image_request)) {
// Getting thumbnail
if (file_exists("images/thumbnails/".$image['imagename'])) {
$image_path = "images/thumbnails/".$image['imagename'];
} else {
$image_path = "images/".$image['imagename'];
}
// 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>";
} 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>
</div>";
}
}
} catch(Exception $e) {
$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>";
?>
<script>
$('#createGroup').click(function() {
$("#newSniff").load("app/image/group.php", {
new_group_submit: "uwu"
});
});
</script>
<?php
}
$group_list = mysqli_query($conn, "SELECT * FROM groups ORDER BY id DESC");
if (empty($group_list) && !$_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)]);
// 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'];
}
} 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>";
}
}
}
?>
</div>
<?php require_once __DIR__."/assets/ui/footer.php"; ?>
</body>
</html>

333
image.php
View file

@ -1,184 +1,211 @@
<!DOCTYPE html>
<html>
<head>
<?php require_once __DIR__."/ui/header.php"; ?>
</head>
<body>
<?php
/*
|-------------------------------------------------------------
| Import Required
|-------------------------------------------------------------
| These are common scripts used across all pages of the
| website. At some point I want the whole website to be only
| one index page. But that's going to require many many many
| many rewrites and hours of learning....
|-------------------------------------------------------------
*/
require_once __DIR__."/ui/required.php";
require_once __DIR__."/ui/nav.php";
<?php
require_once __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();
?>
/*
|-------------------------------------------------------------
| 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']) && is_numeric($_GET['id'])) {
// Get all image info
$image = $image_info->get_image_info($conn, $_GET['id']);
<!DOCTYPE html>
<html>
// Check if image is avalible
if (isset($image['imagename'])) {
$image_present = True;
<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('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(--red)', 'assets/icons/cross.svg');
</script>
?>
<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;
}
} else {
?>
<script>
sniffleAdd('Where is da image?', 'The link you followed seems to be broken, or there was some other error, who knows!', 'var(--red)', '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
|-------------------------------------------------------------
|-------------------------------------------------------------
| 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 (isset($image['author'])) {
// Get all information on the user
$user = $user_info->get_user_info($conn, $image['author']);
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'];
if (isset($user['username'])) {
$image_author = $user['username'];
} else {
$image_author = "Deleted User";
}
} else {
$image_author = "Deleted User";
$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_author = "No author";
}
/*
|-------------------------------------------------------------
| Check if image path is good
|-------------------------------------------------------------
*/
if (isset($image['imagename'])) {
$image_path = "images/".$image['imagename'];
$image_alt = $image['alt'];
} else {
/*
|-------------------------------------------------------------
| Image was not present
|-------------------------------------------------------------
*/
$image_path = "assets/no_image.png";
$image_alt = "No image could be found, sowwy";
}
/*
|-------------------------------------------------------------
| If description not set or empty, replace with filler
|-------------------------------------------------------------
|-------------------------------------------------------------
| Check user privilge
|-------------------------------------------------------------
*/
if (!isset($image_alt) || empty($image_alt)) {
$image_alt = "No description avalible";
if ($image_info->image_privilage($image['author']) || $user_info->is_admin($conn, $_SESSION['id'])) {
$privilaged = True;
} else {
$privilaged = False;
}
} 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;
}
echo "<div class='fullscreen-image'>
<button onclick='closeFullScreen()'><img src='assets/icons/cross.svg'></button>
<img>
</div>";
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>
</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>
</div>";
}
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='showFull()'><img src='assets/icons/scan.svg'></button>
</div>";
?>
<script>
function showFull() {
document.querySelector(".image").style.opacity = 0;
document.querySelector(".preview-button").style.display = "none";
setTimeout(function(){
document.querySelector(".image").src = "<?php echo $image_path;?>";
document.querySelector(".image").style.opacity = 1;
}, 500);
}
</script>
<script>
function fullScreen() {
document.querySelector(".preview-button").style.display = "none";
document.querySelector("html").style.overflow = "hidden";
document.querySelector(".fullscreen-image").style.display = "block";
document.querySelector(".fullscreen-image > img").src = "<?php echo $image_path;?>";
setTimeout(function(){
document.querySelector(".fullscreen-image").style.opacity = 1;
}, 1);
}
function closeFullScreen() {
document.querySelector(".preview-button").style.display = "block";
document.querySelector("html").style.overflow = "auto";
document.querySelector(".fullscreen-image").style.opacity = 0;
setTimeout(function(){
document.querySelector(".fullscreen-image").style.display = "none";
}, 500);
}
</script>
<?php
} else {
echo "<div class='image-container'>
<img class='image' id='".$image['id']."' src='".$image_path."' alt='".$image_alt."'>
</div>";
}
/*
|-------------------------------------------------------------
| Start of displaying all info on image
|-------------------------------------------------------------
*/
if ($image_present) {
/*
|-------------------------------------------------------------
| Start of displaying all info on image
|-------------------------------------------------------------
*/
if ($image_present) {
?>
<div class="image-description default-window">
<div class="defaultDecoration defaultSpacing defaultFonts">
<h2>Description</h2>
<p><?php echo htmlentities($image_alt, ENT_QUOTES); ?></p>
</div>
<div class="image-detail">
<div class="image-detail defaultDecoration defaultSpacing defaultFonts">
<h2>Details</h2>
<div>
<div>
<?php
// User
if ($user_info->is_admin($conn, $image['author'])) {
echo "<p>Author: ".$image_author."<img class='svg' style='margin: 0 0 0.1rem 0.2rem;' src='assets/icons/crown-simple.svg'></p>";
} else {
if (empty($image['author'])) {
echo "<p>Author: ".$image_author."</p>";
} else {
echo "<p>Author: <a href='profile.php?user=".$image['author']."' class='link'>".$image_author."</a></p>";
}
// Image ID
@ -235,7 +262,7 @@
<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>
<script>
$("#download").click(function() {
sniffleAdd("Info", "Image download started!", "var(--green)", "assets/icons/download.svg");
sniffleAdd("Info", "Image download started!", "var(--success)", "assets/icons/download.svg");
});
</script>
@ -245,12 +272,12 @@
function copyLink() {
navigator.clipboard.writeText(window.location.href);
sniffleAdd("Info", "Link has been copied!", "var(--green)", "assets/icons/clipboard-text.svg");
sniffleAdd("Info", "Link has been copied!", "var(--success)", "assets/icons/clipboard-text.svg");
}
</script>
</div>
<div class="tags-root default-window">
<div class="defaultDecoration defaultSpacing defaultFonts">
<h2>Tags</h2>
<div class="tags">
<?php
@ -283,7 +310,7 @@
if ($privilaged) {
?>
<!-- Danger zone -->
<div class='danger-zone flex-down default-window'>
<div class='warningDecoration defaultSpacing defaultFonts'>
<h2>Danger zone</h2>
<!--
@ -307,7 +334,7 @@
$("#deleteConfirm").submit(function(event) {
event.preventDefault();
var deleteSubmit = $("#deleteSubmit").val();
$("#sniffle").load("app/image/image.php", {
$("#newSniff").load("app/image/image.php", {
id: <?php echo $_GET['id']; ?>,
submit_delete: deleteSubmit
});
@ -316,13 +343,13 @@
</script>
<!--
|-------------------------------------------------------------
| 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.
|-------------------------------------------------------------
|-------------------------------------------------------------
| 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>
@ -330,7 +357,7 @@
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'>\
<textarea id='descriptionInput' class='btn btn-neutral space-bottom' placeholder='Description/Alt for image' rows='3'></textarea>\
<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);
@ -341,7 +368,7 @@
event.preventDefault();
var descriptionInput = $("#descriptionInput").val();
var descriptionSubmit = $("#descriptionSubmit").val();
$("#sniffle").load("app/image/image.php", {
$("#newSniff").load("app/image/image.php", {
id: <?php echo $_GET['id']; ?>,
input: descriptionInput,
submit_description: descriptionSubmit
@ -366,7 +393,7 @@
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'>\
<textarea id='tagsInput' class='btn btn-neutral space-bottom' placeholder='Tags are seperated by spaces' row='3'></textarea>\
<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);
@ -377,7 +404,7 @@
event.preventDefault();
var tagsInput = $("#tagsInput").val();
var tagsSubmit = $("#tagsSubmit").val();
$("#sniffle").load("app/image/image.php", {
$("#newSniff").load("app/image/image.php", {
id: <?php echo $_GET['id']; ?>,
input: tagsInput,
submit_tags: tagsSubmit
@ -411,7 +438,7 @@
event.preventDefault();
var authorInput = $("#authorInput").val();
var authorSubmit = $("#authorSubmit").val();
$("#sniffle").load("app/image/image.php", {
$("#newSniff").load("app/image/image.php", {
id: <?php echo $_GET['id']; ?>,
input: authorInput,
submit_author: authorSubmit
@ -432,7 +459,7 @@
}
?>
<?php require_once __DIR__."/ui/footer.php"; ?>
<?php require_once __DIR__."/assets/ui/footer.php"; ?>
</body>
</html>

164
index.php
View file

@ -1,90 +1,118 @@
<!DOCTYPE html>
<html>
<head>
<?php require_once __DIR__."/ui/header.php"; ?>
</head>
<body>
<?php
require_once __DIR__."/ui/required.php";
require_once __DIR__."/ui/nav.php";
require_once __DIR__."/app/required.php";
use App\Account;
use App\Sanity;
if ($_GET['del']) {
?>
<script>
sniffleAdd("Image Deleted", "Successfully deleted image: <?php echo $_GET['id']; ?>", "var(--green)", "assets/icons/trash.svg");
</script>
<?php
}
$user_info = new Account();
$sanity = new Sanity();
?>
<div class="info-text">
<!DOCTYPE html>
<html>
<head>
<?php require_once __DIR__."/assets/ui/header.php"; ?>
</head>
<body>
<?php
// Set time for message
$time = date("H");
$timezone = date("e");
if ($time < "12") {
$time_welc = "Good morning";
} else if ($time >= "12" && $time < "17") {
$time_welc = "Good afternoon";
} else if ($time >= "17" && $time < "19") {
$time_welc = "Good evening";
} else if ($time >= "19") {
$time_welc = "Good night";
}
require_once __DIR__."/assets/ui/nav.php";
// Welcome depending on if user is logged in or not
if (isset($_SESSION["username"])) {
echo "<h1>".$time_welc." ".$_SESSION['username']."!</h1>";
} else {
echo "<h1>".$time_welc."!</h1>";
if (isset($_SESSION['del'])) {
?>
<script>
sniffleAdd("Image Deleted", "Successfully deleted image: <?php echo $_SESSION['del']; ?>", "var(--success)", "assets/icons/trash.svg");
</script>
<?php
unset($_SESSION['del']);
}
if (isset($_SESSION['welc'])) {
?>
<script>
sniffleAdd('O hi <?php echo $_SESSION["username"]; ?>', 'You are now logged in, enjoy your stay!', 'var(--success)', 'assets/icons/hand-waving.svg');
</script>
<?php
unset($_SESSION['welc']);
// Random welcome message
$welcome_message = $user_settings['welcome_msg'];
echo "<p>".$welcome_message[array_rand($welcome_message, 1)]."</p>";
if ($user_info->is_admin($conn, $_SESSION['id'])) {
$check_sanity = $sanity->get_results();
if (!empty($check_sanity) || isset($check_sanity)) {
?>
<script>
sniffleAdd('Uh oh', 'Website has not passed some Sanity checks, please check your settings for more information', 'var(--warning)', 'assets/icons/warning.svg');
</script>
<?php
}
}
}
?>
</div>
<!--
<div class="gallery-order">
<button class="btn btn-neutral">Grid</button>
<button class="btn btn-neutral">List</button>
</div>
-->
<div class="gallery-root">
<?php
// Reading images from table
$image_request = mysqli_query($conn, "SELECT * FROM images ORDER BY id DESC");
while ($image = mysqli_fetch_array($image_request)) {
// Getting thumbnail
if (file_exists("images/thumbnails/".$image['imagename'])) {
$image_path = "images/thumbnails/".$image['imagename'];
} else {
$image_path = "images/".$image['imagename'];
if (!empty($image_request)) {
?>
<div class="info-text defaultFonts">
<?php
// Set time for message
$time = date("H");
$timezone = date("e");
if ($time < "12") {
$time_welc = "Good morning";
} else if ($time >= "12" && $time < "17") {
$time_welc = "Good afternoon";
} else if ($time >= "17" && $time < "19") {
$time_welc = "Good evening";
} else if ($time >= "19") {
$time_welc = "Good night";
}
// Welcome depending on if user is logged in or not
if (isset($_SESSION["username"])) {
echo "<h1>".$time_welc." ".$_SESSION['username']."!</h1>";
} else {
echo "<h1>".$time_welc."!</h1>";
}
// Random welcome message
$welcome_message = $user_settings['welcome_msg'];
echo "<p>".$welcome_message[array_rand($welcome_message, 1)]."</p>";
?>
</div>
<?php
echo "<div class='gallery-root defaultDecoration'>";
while ($image = mysqli_fetch_array($image_request)) {
// Getting thumbnail
if (file_exists("images/thumbnails/".$image['imagename'])) {
$image_path = "images/thumbnails/".$image['imagename'];
} else {
$image_path = "images/".$image['imagename'];
}
// 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>";
} 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>
</div>";
}
}
// Check for NSFW tag
if (str_contains($image['tags'], "nsfw")) {
$image_nsfw = "nsfw-blur";
$nsfw_warning = "<a href='image.php?id=".$image['id']."' class='nsfw-warning'><img class='svg' src='assets/icons/warning_red.svg'><span>NSFW</span></a>";
} else {
$image_nsfw = "";
$nsfw_warning = "";
}
// Image loading
echo "<div class='gallery-item'>";
echo $nsfw_warning;
echo "<a href='image.php?id=".$image['id']."'><img class='gallery-image ".$image_nsfw."' loading='lazy' src='".$image_path."' id='".$image['id']."'></a>";
echo "</div>";
} else {
echo "<div class='info-text defaultFonts' style='text-align: center !important;'>
<h1>Nothing here!</h1>
<p>There are no images in the gallery, upload some!</p>
</div>";
}
?>
</div>
<?php require_once __DIR__."/ui/footer.php"; ?>
<?php require_once __DIR__."/assets/ui/footer.php"; ?>
</body>
</html>

View file

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Before After
Before After

View file

@ -1,28 +1,28 @@
<?php require_once __DIR__."/app/required.php"; ?>
<!DOCTYPE html>
<html>
<head>
<?php require_once __DIR__."/ui/header.php"; ?>
<?php require_once __DIR__."/assets/ui/header.php"; ?>
</head>
<body>
<?php
require_once __DIR__."/ui/required.php";
require_once __DIR__."/ui/nav.php";
require_once __DIR__."/assets/ui/nav.php";
use App\Account;
use App\Account;
$user_info = new 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;
}
// Check if the user is logged in, otherwise redirect to login page
if ($user_info->is_loggedin() != true) {
header("location: account.php");
exit;
}
?>
<div class="password-reset-root">
<div class="warningDecoration defaultSpacing defaultFonts">
<h2>Reset Password</h2>
<p>After reset, you will be kicked out to login again</p>
<br>
@ -32,6 +32,8 @@
<br>
<button id="passwordSubmit" class="btn btn-bad" type="submit" name="reset"><img class="svg" src="assets/icons/sign-in.svg">Reset</button>
</form>
<br>
<a href="account.php" class="btn btn-neutral" ><img class="svg" src="assets/icons/sign-in.svg">Cancel</a>
</div>
<script>
@ -40,7 +42,7 @@
var new_password = $("#newPassword").val();
var confirm_password = $("#confirmPassword").val();
var submit = $("#passwordSubmit").val();
$("#sniffle").load("app/account/account.php", {
$("#newSniff").load("app/account/account.php", {
new_password: new_password,
confirm_password: confirm_password,
password_reset_submit: submit
@ -48,7 +50,7 @@
});
</script>
<?php require_once __DIR__."/ui/footer.php"; ?>
<?php require_once __DIR__."/assets/ui/footer.php"; ?>
</body>
</html>

134
profile.php Normal file
View file

@ -0,0 +1,134 @@
<?php
require_once __DIR__."/app/required.php";
use App\Make;
use App\Account;
use App\Diff;
$make_stuff = new Make();
$user_info = new Account();
$diff = new Diff();
if (!isset($_GET['user']) || empty($_GET['user'])) {
header("Location: index.php");
} elseif (isset($_GET['user'])) {
$user = $user_info->get_user_info($conn, $_GET['user']);
$join_date = new DateTime($user['created_at']);
?>
<!DOCTYPE html>
<html>
<head>
<?php require_once __DIR__."/assets/ui/header.php"; ?>
</head>
<body>
<?php require_once __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']."'>";
$pfp_colour = $make_stuff->get_image_colour("images/pfp/".$user['pfp_path']);
if (!empty($pfp_colour)) {
$pfp_colour = $pfp_colour;
} else {
$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'>";
}
?>
<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>
<?php
} else {
echo "<img src='assets/no_image.png'>
<h2>Failed to load user info</h2>";
}
?>
</div>
<div id="gallery" class="gallery-root defaultDecoration">
<?php
// Reading images from table
$sql = "SELECT * FROM images WHERE author = ? ORDER BY id DESC";
if ($stmt = mysqli_prepare($conn, $sql)) {
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param($stmt, "i", $param_user_id);
$param_user_id = $_GET['user'];
$stmt->execute();
$query = $stmt->get_result();
while ($image = mysqli_fetch_array($query)) {
// Getting thumbnail
if (file_exists("images/thumbnails/".$image['imagename'])) {
$image_path = "images/thumbnails/".$image['imagename'];
} else {
$image_path = "images/".$image['imagename'];
}
// 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>";
} 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>
</div>";
}
}
}
?>
</div>
<script>
var postCount = $("#gallery").children().length;
$("#postCount").html("Posts: "+postCount);
var updateDate = new Date('<?php echo $join_date->format('m/d/Y T'); ?>');
var format = {year: 'numeric', month: 'short', day: 'numeric'};
updateDate = updateDate.toLocaleDateString('en-GB', format);
$("#joinDate").html("Member since: "+updateDate);
</script>
<?php
}
require_once __DIR__."/assets/ui/footer.php";
?>
</body>
</html>

View file

@ -1,5 +0,0 @@
<footer>
<p>Hosted by <?php echo $user_settings['user_name']; ?> under <?php echo $user_settings['license']; ?></p>
<p>Version <?php echo $user_settings['version']; ?></p>
<a class='link' href="about.php">About</a>
</footer>

View file

@ -1,25 +0,0 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Stylesheets -->
<link rel="stylesheet" href="css/main.css">
<!-- Google Fonts -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Lexend+Deca:wght@600">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Secular+One&display=swap">
<!-- JQuery -->
<script
src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
crossorigin="anonymous">
</script>
<!-- Sniffle script! -->
<script src="Sniffle/sniffle.js"></script>
<link rel='stylesheet' href='Sniffle/sniffle.css'>
<!-- Flyout script! -->
<script src="Flyout/flyout.js"></script>
<link rel='stylesheet' href='Flyout/flyout.css'>

View file

@ -1,28 +0,0 @@
<?php
use App\Account;
$loggedin = new Account();
?>
<nav class="nav-root flex-left">
<div class="nav-name flex-left">
<p><?php echo $user_settings['website_name']; ?></p>
</div>
<div class="nav-links flex-left">
<a class='btn' href='index.php'><img class='svg' src='assets/icons/house.svg'><span class='nav-hide'>Home</span></a>
<hr>
<?php
if ($loggedin->is_loggedin()) {
?>
<a class='btn' href='upload.php'><img class='svg' src='assets/icons/upload.svg'><span class='nav-hide'>Upload</span></a>
<hr>
<a class='btn' href='account.php'><img class='svg' src='assets/icons/gear.svg'><span class='nav-hide'><?php echo substr($_SESSION["username"], 0, 15); ?></span></a>
<?php
} else {
?>
<a class='btn' href='account.php'><img class='svg' src='assets/icons/sign-in.svg'><span class='nav-hide'>Login</span></a>
<?php
}
?>
</div>
</nav>

View file

@ -1,81 +0,0 @@
<!--
Used by Sniffle to add Notifications
Div can be displayed all time as it has no width or height initself
-->
<div id='sniffle' class='sniffle'></div>
<!--
Div for information flyouts
Controlled by Flyout.js
-->
<div id='flyoutDim' class='flyout-dim'></div>
<div id='flyoutRoot' class='flyout'>
<p id='flyoutHeader' class='flyout-header'>Header</p>
<br>
<p id='flyoutDescription' class='flyout-description'>Description</p>
<br>
<div id='flyoutActionbox' class='flyout-actionbox'></div>
<button onclick='flyoutClose()' class='btn btn-neutral'>Close</button>
</div>
<!--
Back to top button
Used to quickly get back up to the top of the page,
At some point will be removed as the UI metures and
everything can always be accessed
-->
<a id="back-to-top" href="#">
<img src="assets/icons/caret-up.svg">
</a>
<script>
button = document.getElementById("back-to-top");
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 20) {
button.style.right = "1rem";
} else {
button.style.right = "-2.5rem";
}
}
</script>
<!--
Required so main objects are centered when NAV
is in mobile view
-->
<div class="nav-mobile"></div>
<?php
/*
User defined settings
*/
require_once dirname(__DIR__)."/app/settings/settings.php";
ini_set('post_max_size', $user_settings['upload_max']."M");
ini_set('upload_max_filesize', ($user_settings['upload_max'] + 1)."M");
if ($user_settings['is_testing'] == "true") {
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ERROR | E_PARSE | E_NOTICE);
?>
<script>
sniffleAdd('Notice', 'This website is currently in a testing state', 'var(--red)', 'assets/icons/cross.svg');
</script>
<?php
}
/*
Connect to the server
*/
require_once dirname(__DIR__)."/app/server/conn.php";
require_once dirname(__DIR__)."/app/server/secrete.php";
/*
Classes
*/
require_once dirname(__DIR__)."/app/app.php";
?>

View file

@ -1,90 +1,101 @@
<?php require_once __DIR__."/app/required.php"; ?>
<!DOCTYPE html>
<html>
<head>
<?php require_once __DIR__."/ui/header.php"; ?>
<!-- Upload Script -->
<script>
$(document).ready(function() {
$("#uploadSubmit").submit(function(event) {
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);
// Get ALT
var alt = $("#alt").val();
formData.append("alt", alt);
// Get TAGS
var tags = $("#tags").val();
formData.append("tags", tags);
// Submit data
var submit = $("#submit").val();
formData.append("submit", submit);
// Upload the information
$.ajax({
url: 'app/image/upload_image.php',
type: 'post',
data: formData,
contentType: false,
processData: false,
success: function(response) {
$("#sniffle").html(response);
}
});
// Empty values
$("#image").val("");
$("#alt").val("");
$("#tags").val("");
$("#submit").val("");
} else {
sniffleAdd('Gwha!', 'Pls provide image', 'var(--red)', 'assets/icons/file-search.svg');
}
});
});
</script>
<?php require_once __DIR__."/assets/ui/header.php"; ?>
</head>
<body>
<?php
require_once __DIR__."/ui/required.php";
require_once __DIR__."/ui/nav.php";
require_once __DIR__."/assets/ui/nav.php";
use App\Account;
$user_info = new Account();
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 loggedin to upload things, sowwy!', 'var(--red)', 'assets/icons/cross.svg');
</script>
<?php
}
// Check if user is logged in
if (!$user_info->is_loggedin()) {
?>
<script>
sniffleAdd('Who are you!', 'You must be loggedin to upload things, sowwy!', 'var(--alert)', 'assets/icons/cross.svg');
</script>
<?php
}
?>
<div class="upload-root">
<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>
<img id="imagePreview" src="">
<br>
<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">
<textarea id="alt" class="btn btn-neutral" placeholder="Description/Alt for image" rows="3"></textarea>
<textarea id="tags" class="btn btn-neutral" placeholder="Tags, seperated by white-space" rows="3"></textarea>
<br>
<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'>
<br>
<button id="submit" class="btn btn-good" type="submit"><img class="svg" src="assets/icons/upload.svg">Upload Image</button>
</form>
<script>
image.onchange = evt => {
const [file] = image.files
if (file) {
imagePreview.src = URL.createObjectURL(file);
} else {
imagePreview.src = "assets/no_image.png";
}
}
</script>
</div>
<?php require_once __DIR__."/ui/footer.php"; ?>
<script>
$("#uploadSubmit").submit(function(event) {
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);
// Get ALT
var alt = $("#alt").val();
formData.append("alt", alt);
// Get TAGS
var tags = $("#tags").val();
formData.append("tags", tags);
// Submit data
var submit = $("#submit").val();
formData.append("submit", submit);
// Upload the information
$.ajax({
url: 'app/image/upload_image.php',
type: 'post',
data: formData,
contentType: false,
processData: false,
success: function(response) {
$("#newSniff").html(response);
}
});
// Empty values
imagePreview.src = "";
$("#image").val("");
$("#alt").val("");
$("#tags").val("");
$("#submit").val("");
} else {
sniffleAdd('Gwha!', 'Pls provide image', 'var(--warning)', 'assets/icons/file-search.svg');
}
});
</script>
<?php require_once __DIR__."/assets/ui/footer.php"; ?>
</body>
</html>