mirror of
https://github.com/Fluffy-Bean/image-gallery.git
synced 2025-06-05 09:53:12 +00:00
Remaking file structure for easier updating
This commit is contained in:
parent
e7a2284809
commit
d897215023
17 changed files with 119 additions and 103 deletions
|
@ -41,8 +41,8 @@
|
|||
<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']."'>";
|
||||
if (is_file("usr/images/pfp/".$profile_info['pfp_path'])) {
|
||||
echo "<img src='usr/images/pfp/".$profile_info['pfp_path']."'>";
|
||||
} else {
|
||||
echo "<img src='assets/no_image.png'>";
|
||||
}
|
||||
|
@ -251,8 +251,8 @@
|
|||
if ($user['admin'] || $user['id'] == 1) {
|
||||
echo "<div class='user is-admin'>";
|
||||
} else {
|
||||
echo "<div class='user'>";
|
||||
}
|
||||
echo "<div class='user'>";
|
||||
}
|
||||
?>
|
||||
<p><?php echo $user['id']; ?></p>
|
||||
<p><?php echo $user['username']; ?></p>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
// Include server connection
|
||||
include dirname(__DIR__)."/server/conn.php";
|
||||
include dirname(__DIR__)."/conn.php";
|
||||
include dirname(__DIR__)."/app.php";
|
||||
|
||||
use App\Account;
|
||||
|
@ -131,11 +131,6 @@ if (isset($_POST['submit_login'])) {
|
|||
$_SESSION['welc'] = true;
|
||||
|
||||
mysqli_query($conn,"INSERT INTO logs (ipaddress, action) VALUES('$user_ip','New loggin to ".$_SESSION['username']."')");
|
||||
|
||||
// This is a terrible way of doing this, but is has to be done
|
||||
if ($id == 1 && $user_info->is_admin($conn, $id) == false) {
|
||||
mysqli_query($conn,"UPDATE users SET admin = 1 WHERE id = 1");
|
||||
}
|
||||
} else {
|
||||
?>
|
||||
<script>
|
||||
|
@ -379,6 +374,11 @@ if (isset($_POST['submit_signup'])) {
|
|||
|
||||
// Attempt to execute the prepared statement
|
||||
if (mysqli_stmt_execute($stmt)) {
|
||||
// If first user, set as admin
|
||||
if (mysqli_insert_id($conn) == 1) {
|
||||
mysqli_query($conn,"UPDATE users SET admin = 1 WHERE id = 1");
|
||||
}
|
||||
|
||||
// Prepare sql
|
||||
$sql = "UPDATE tokens SET used = True WHERE code = ?";
|
||||
$stmt = mysqli_prepare($conn, $sql);
|
||||
|
@ -438,7 +438,7 @@ if (isset($_POST['toggle_admin'])) {
|
|||
if ($admin_status) {
|
||||
$param_admin_status = 0;
|
||||
$admin_update_message = "removed from the admins list";
|
||||
} elseif (!$admin_status) {
|
||||
} else {
|
||||
$param_admin_status = 1;
|
||||
$admin_update_message = "added to the admins list";
|
||||
}
|
||||
|
|
76
app/app.php
76
app/app.php
|
@ -14,7 +14,8 @@ class Make {
|
|||
| ** Not yet implemented **
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
function thumbnail($image_path, $thumbnail_path, $resolution) {
|
||||
function thumbnail($image_path, $thumbnail_path, $resolution): Exception|string
|
||||
{
|
||||
try {
|
||||
$thumbnail = new Imagick($image_path);
|
||||
$thumbnail->resizeImage($resolution,null,null,1,null);
|
||||
|
@ -31,7 +32,8 @@ class Make {
|
|||
|
||||
Returns clean string of words with equal white space between it
|
||||
*/
|
||||
function tags($string) {
|
||||
function tags($string): string
|
||||
{
|
||||
$string = str_replace('-', '_', $string);
|
||||
$string = preg_replace('/[^A-Za-z0-9\_ ]/', '', $string);
|
||||
$string = strtolower($string);
|
||||
|
@ -50,7 +52,8 @@ class Make {
|
|||
return trim($string);
|
||||
}
|
||||
|
||||
function get_image_colour($img) {
|
||||
function get_image_colour($img): ?string
|
||||
{
|
||||
$img_type = pathinfo($img, PATHINFO_EXTENSION);
|
||||
|
||||
if ($img_type == "png") {
|
||||
|
@ -106,10 +109,11 @@ class Account {
|
|||
Returns True if user is
|
||||
Returns False if user is NOT
|
||||
*/
|
||||
function is_loggedin($conn) {
|
||||
function is_loggedin($conn): bool
|
||||
{
|
||||
$error = 0;
|
||||
|
||||
if (!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] == false) $error += 1;
|
||||
if (!isset($_SESSION["loggedin"]) || !$_SESSION["loggedin"]) $error += 1;
|
||||
|
||||
if (empty($this->get_user_info($conn, $_SESSION["id"])) || $this->get_user_info($conn, $_SESSION["id"]) == null) $error += 1;
|
||||
|
||||
|
@ -124,7 +128,8 @@ class Account {
|
|||
|
||||
Returns array with user info
|
||||
*/
|
||||
function get_user_info($conn, $id) {
|
||||
function get_user_info($conn, $id): bool|array|null
|
||||
{
|
||||
$sql = "SELECT id, username, created_at, pfp_path FROM users WHERE id = ?";
|
||||
|
||||
if ($stmt = mysqli_prepare($conn, $sql)) {
|
||||
|
@ -148,7 +153,8 @@ class Account {
|
|||
Returns True if user is privilaged
|
||||
Returns False if user is NOT privilaged
|
||||
*/
|
||||
function is_admin($conn, $id) {
|
||||
function is_admin($conn, $id): bool
|
||||
{
|
||||
if (isset($id) && !empty($id)) {
|
||||
// Setting SQL query
|
||||
$sql = "SELECT admin FROM users WHERE id = ?";
|
||||
|
@ -179,7 +185,8 @@ class Account {
|
|||
/*
|
||||
Get target IP, used for logging
|
||||
*/
|
||||
function get_ip() {
|
||||
function get_ip(): mixed
|
||||
{
|
||||
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
|
||||
$target_ip = $_SERVER['HTTP_CLIENT_IP'];
|
||||
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||
|
@ -198,7 +205,8 @@ class Image {
|
|||
|
||||
Returns array with image info
|
||||
*/
|
||||
function get_image_info($conn, $id) {
|
||||
function get_image_info($conn, $id): bool|array|null
|
||||
{
|
||||
$sql = "SELECT * FROM images WHERE id = ?";
|
||||
|
||||
if ($stmt = mysqli_prepare($conn, $sql)) {
|
||||
|
@ -220,7 +228,8 @@ class Image {
|
|||
Returns True if user is privilaged
|
||||
Returns False if user is NOT privilaged
|
||||
*/
|
||||
function image_privilage($id) {
|
||||
function image_privilage($id): bool
|
||||
{
|
||||
$session_id = $_SESSION['id'];
|
||||
if (isset($session_id) || !empty($session_id)) {
|
||||
if ($session_id == $id) {
|
||||
|
@ -235,7 +244,8 @@ class Image {
|
|||
}
|
||||
|
||||
class Group {
|
||||
function get_group_info($conn, $id) {
|
||||
function get_group_info($conn, $id): bool|array|null
|
||||
{
|
||||
// Setting SQL query
|
||||
$sql = "SELECT * FROM groups WHERE id = ?";
|
||||
|
||||
|
@ -253,7 +263,8 @@ class Group {
|
|||
return($group_array);
|
||||
}
|
||||
|
||||
function get_group_members($conn, $id){
|
||||
function get_group_members($conn, $id): array
|
||||
{
|
||||
$user_array = array();
|
||||
|
||||
$sql = "SELECT * FROM groups WHERE id = ?";
|
||||
|
@ -290,7 +301,8 @@ class Group {
|
|||
}
|
||||
|
||||
class Diff {
|
||||
function time($past_time, $full_date = false) {
|
||||
function time($past_time, $full_date = false): string
|
||||
{
|
||||
$now = new \DateTime;
|
||||
$ago = new \DateTime($past_time);
|
||||
$diff = $now->diff($ago);
|
||||
|
@ -321,19 +333,20 @@ class Diff {
|
|||
}
|
||||
|
||||
class Sanity {
|
||||
function check_json() {
|
||||
function check_json(): array
|
||||
{
|
||||
$results = array();
|
||||
|
||||
if (!is_file(__DIR__."/settings/manifest.json")) {
|
||||
if (!is_file(__DIR__."/../usr/conf/manifest.json")) {
|
||||
$results[] = "Critical: manifest.json is missing";
|
||||
} else {
|
||||
$manifest = json_decode(file_get_contents(__DIR__."/settings/manifest.json"), true);
|
||||
$manifest = json_decode(file_get_contents(__DIR__."/../usr/conf/manifest.json"), true);
|
||||
|
||||
if (!isset($manifest['user_name']) || empty($manifest['user_name']) || $manifest['user_name'] == "[your name]") {
|
||||
if (empty($manifest['user_name']) || $manifest['user_name'] == "[your name]") {
|
||||
$results[] = "Warning: manifest.json is missing your name";
|
||||
}
|
||||
if ($manifest['upload']['rename_on_upload'] == true ) {
|
||||
if (!isset($manifest['upload']['rename_to']) || empty($manifest['upload']['rename_to'])) {
|
||||
if ($manifest['upload']['rename_on_upload']) {
|
||||
if (empty($manifest['upload']['rename_to'])) {
|
||||
$results[] = "Critical: manifest.json doesnt know what to rename your files to";
|
||||
} else {
|
||||
$rename_to = $manifest['upload']['rename_to'];
|
||||
|
@ -347,7 +360,7 @@ class Sanity {
|
|||
|
||||
if (str_contains($rename_to, '{{username}}') || str_contains($rename_to, '{{userid}}')) $rename_rate += 1;
|
||||
|
||||
if ($rename_rate == 0 || $rename_rate < 2) {
|
||||
if ($rename_rate < 2) {
|
||||
$results[] = "Critical: You will encounter errors when uploading images due to filenames, update your manifest.json";
|
||||
} elseif ($rename_rate < 5 && $rename_rate > 2) {
|
||||
$results[] = "Warning: You may encounter errors when uploading images due to filenames, concider update your manifest.json";
|
||||
|
@ -363,26 +376,28 @@ class Sanity {
|
|||
return $results;
|
||||
}
|
||||
|
||||
function check_files() {
|
||||
function check_files(): array
|
||||
{
|
||||
$results = array();
|
||||
|
||||
if (!is_dir("images")) {
|
||||
if (!is_dir("usr/images")) {
|
||||
$results[] = "Critical: You need to setup an images folder, follow the guide on the GitHub repo";
|
||||
}
|
||||
if (!is_dir("images/pfp")) {
|
||||
if (!is_dir("usr/images/pfp")) {
|
||||
$results[] = "Critical: You need to setup an pfp folder, follow the guide on the GitHub repo";
|
||||
}
|
||||
if (!is_dir("images/previews")) {
|
||||
if (!is_dir("usr/images/previews")) {
|
||||
$results[] = "Critical: You need to setup an previews folder, follow the guide on the GitHub repo";
|
||||
}
|
||||
if (!is_dir("images/thumbnails")) {
|
||||
if (!is_dir("usr/images/thumbnails")) {
|
||||
$results[] = "Critical: You need to setup an thumbnails folder, follow the guide on the GitHub repo";
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
function check_version() {
|
||||
function check_version(): array
|
||||
{
|
||||
$results = array();
|
||||
|
||||
$url = "https://raw.githubusercontent.com/Fluffy-Bean/image-gallery/main/app/settings/manifest.json";
|
||||
|
@ -396,7 +411,7 @@ class Sanity {
|
|||
curl_close($ch);
|
||||
|
||||
$manifest_repo = json_decode($result, true);
|
||||
$manifest_local = json_decode(file_get_contents(__DIR__."/settings/manifest.json"), true);
|
||||
$manifest_local = json_decode(file_get_contents(__DIR__."/../usr/conf/manifest.json"), true);
|
||||
|
||||
if ($manifest_local['version'] < $manifest_repo['version']) {
|
||||
$results[] = "Critical: You are not running the latest version of the app v".$manifest_repo['version']."";
|
||||
|
@ -404,14 +419,15 @@ class Sanity {
|
|||
$results[] = "Warning: You are running a version of the app that is newer than the latest release v".$manifest_repo['version']."";
|
||||
}
|
||||
|
||||
if (PHP_VERSION_ID < 80100) {
|
||||
$results[] = "Critical: Your current version of PHP is ".PHP_VERSION.". The reccomended version is 8.1.2";
|
||||
if (PHP_VERSION_ID < 80000) {
|
||||
$results[] = "Critical: Your current version of PHP is ".PHP_VERSION.". The reccomended version is 8.0.0 or higher";
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
function get_results() {
|
||||
function get_results(): array
|
||||
{
|
||||
$results = array();
|
||||
|
||||
foreach ($this->check_json() as $result) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
session_start();
|
||||
// Include server connection
|
||||
include dirname(__DIR__) . "/server/conn.php";
|
||||
include dirname(__DIR__) . "/conn.php";
|
||||
include dirname(__DIR__) . "/app.php";
|
||||
|
||||
use App\Account;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
session_start();
|
||||
// Include server connection
|
||||
include dirname(__DIR__)."/server/conn.php";
|
||||
include dirname(__DIR__)."/conn.php";
|
||||
include dirname(__DIR__)."/app.php";
|
||||
|
||||
use App\Account;
|
||||
|
@ -36,16 +36,16 @@ if (isset($_POST['submit_delete'])) {
|
|||
// 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']);
|
||||
if (is_file(dirname(__DIR__)."/usr/images/".$image_array['imagename'])) {
|
||||
unlink(dirname(__DIR__)."/usr/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']);
|
||||
if (is_file(dirname(__DIR__)."/usr/images/thumbnails/".$image_array['imagename'])) {
|
||||
unlink(dirname(__DIR__)."/usr/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']);
|
||||
if (is_file(dirname(__DIR__)."/usr/images/previews/".$image_array['imagename'])) {
|
||||
unlink(dirname(__DIR__)."/usr/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'] . "')");
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
*/
|
||||
session_start();
|
||||
// Include server connection
|
||||
include dirname(__DIR__)."/server/conn.php";
|
||||
include dirname(__DIR__)."/conn.php";
|
||||
include dirname(__DIR__)."/app.php";
|
||||
include dirname(__DIR__)."/settings/settings.php";
|
||||
include dirname(__DIR__)."/settings.php";
|
||||
|
||||
use App\Make;
|
||||
|
||||
|
@ -21,7 +21,7 @@ if (isset($_POST['submit'])) {
|
|||
$error = 0;
|
||||
|
||||
// Root paths
|
||||
$dir = "../../images/";
|
||||
$dir = "../../usr/images/";
|
||||
$thumb_dir = $dir."thumbnails/";
|
||||
$preview_dir = $dir."previews/";
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
<?php
|
||||
$exec_start = microtime(true);
|
||||
|
||||
require_once dirname(__DIR__)."/app/server/conn.php";
|
||||
require_once dirname(__DIR__)."/app/conn.php";
|
||||
require_once dirname(__DIR__)."/app/app.php";
|
||||
require_once dirname(__DIR__)."/app/settings/settings.php";
|
||||
require_once dirname(__DIR__)."/app/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) {
|
||||
if ($user_settings['is_testing']) {
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ERROR | E_PARSE | E_NOTICE);
|
||||
|
|
|
@ -8,6 +8,6 @@
|
|||
| the default background and accent colour
|
||||
|-------------------------------------------------------------
|
||||
*/
|
||||
$user_import = file_get_contents(__DIR__."/manifest.json");
|
||||
$user_import = file_get_contents(__DIR__."/../usr/conf/manifest.json");
|
||||
$user_settings = json_decode($user_import, true);
|
||||
$upload_conf = $user_settings["upload"];
|
|
@ -1015,7 +1015,7 @@ html {
|
|||
body {
|
||||
margin: 0 auto;
|
||||
padding: 1rem;
|
||||
max-width: 1200px;
|
||||
max-width: 1100px;
|
||||
min-height: calc(100vh - 2rem);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
|
|
@ -45,7 +45,7 @@ body {
|
|||
margin: 0 auto;
|
||||
padding: 1rem;
|
||||
|
||||
max-width: 1200px;
|
||||
max-width: 1100px;
|
||||
|
||||
min-height: calc(100vh - 2rem);
|
||||
|
||||
|
|
54
group.php
54
group.php
|
@ -11,10 +11,10 @@
|
|||
$group_info = new Group;
|
||||
$diff = new Diff();
|
||||
|
||||
if (!empty($_GET['id']) && isset($_GET['id']) && $_GET['id'] != null) {
|
||||
if (isset($_GET['id'])) {
|
||||
$group = $group_info->get_group_info($conn, $_GET['id']);
|
||||
|
||||
if (empty($group) || !isset($group)) {
|
||||
if (!isset($group)) {
|
||||
$_SESSION['err'] = "You followed a broken link";
|
||||
header("Location: group.php");
|
||||
}
|
||||
|
@ -53,7 +53,7 @@
|
|||
</script>
|
||||
<?php
|
||||
unset($_SESSION['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['id']) && !empty($_GET['id'])) {
|
||||
$image_list = array_reverse(explode(" ", $group['image_list']));
|
||||
|
@ -77,10 +77,10 @@
|
|||
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>";
|
||||
echo "<p id='updateTime'>Created at: ".$upload_time->format(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'); ?>');
|
||||
var updateDate = new Date('<?php echo $upload_time->format(format: 'm/d/Y H:i:s T'); ?>');
|
||||
updateDate = updateDate.toLocaleDateString('en-GB', {year: 'numeric', month: 'short', day: 'numeric'});
|
||||
$("#updateTime").html("Created at: "+updateDate);
|
||||
</script>
|
||||
|
@ -101,7 +101,7 @@
|
|||
<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();
|
||||
|
@ -125,7 +125,7 @@
|
|||
<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();
|
||||
|
@ -143,13 +143,13 @@
|
|||
echo "<br>";
|
||||
|
||||
$image_request = mysqli_query($conn, "SELECT * FROM images");
|
||||
echo "<form id='groupForm'>";
|
||||
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>";
|
||||
|
@ -178,24 +178,24 @@
|
|||
?>
|
||||
<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']; ?>'/>
|
||||
<img <?php if(str_contains($cover_image['tags'], "nsfw")) echo "class='nsfw-blur'"; ?> src='usr/images/<?php echo $cover_image['imagename']; ?>'/>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
echo "</div>";
|
||||
|
||||
if ($_GET['mode'] == "edit") {
|
||||
echo "<div class='gallery-root defaultDecoration'>";
|
||||
echo "<div class='gallery-root defaultDecoration'>";
|
||||
$image_request = mysqli_query($conn, "SELECT * FROM images ORDER BY id DESC");
|
||||
|
||||
while ($image = mysqli_fetch_array($image_request)) {
|
||||
// Getting thumbnail
|
||||
if (file_exists("images/thumbnails/".$image['imagename'])) {
|
||||
$image_path = "images/thumbnails/".$image['imagename'];
|
||||
if (file_exists("usr/images/thumbnails/".$image['imagename'])) {
|
||||
$image_path = "usr/images/thumbnails/".$image['imagename'];
|
||||
} else {
|
||||
$image_path = "images/".$image['imagename'];
|
||||
$image_path = "usr/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']."'>
|
||||
|
@ -204,7 +204,7 @@
|
|||
echo "<div id='".$image['id']."' class='gallery-item'>
|
||||
<img class='gallery-image' loading='lazy' src='".$image_path."' id='".$image['id']."'>
|
||||
</div>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -265,15 +265,15 @@
|
|||
// 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'];
|
||||
if (file_exists("usr/images/thumbnails/".$image['imagename'])) {
|
||||
$image_path = "usr/images/thumbnails/".$image['imagename'];
|
||||
} else {
|
||||
$image_path = "images/".$image['imagename'];
|
||||
$image_path = "usr/images/".$image['imagename'];
|
||||
}
|
||||
|
||||
|
||||
// Check for NSFW tag
|
||||
if (str_contains($image['tags'], "nsfw")) {
|
||||
echo "<div class='gallery-item'>
|
||||
|
@ -301,7 +301,7 @@
|
|||
|
||||
?>
|
||||
<script>
|
||||
$('#createGroup').click(function() {
|
||||
$('#createGroup').click(function() {
|
||||
$("#newSniff").load("app/image/group.php", {
|
||||
new_group_submit: "uwu"
|
||||
});
|
||||
|
@ -331,15 +331,15 @@
|
|||
|
||||
// Getting thumbnail
|
||||
if (!empty($image['imagename'])) {
|
||||
if (file_exists("images/thumbnails/".$image['imagename'])) {
|
||||
$image_path = "images/thumbnails/".$image['imagename'];
|
||||
if (file_exists("usr/images/thumbnails/".$image['imagename'])) {
|
||||
$image_path = "usr/images/thumbnails/".$image['imagename'];
|
||||
} else {
|
||||
$image_path = "images/".$image['imagename'];
|
||||
}
|
||||
$image_path = "usr/images/".$image['imagename'];
|
||||
}
|
||||
} else {
|
||||
$image_path = "assets/no_image.png";
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Check for NSFW tag
|
||||
if (str_contains($image['tags'], "nsfw")) {
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
header("Location: index.php");
|
||||
}
|
||||
|
||||
$image_path = "images/".$image['imagename'];
|
||||
$image_path = "usr/images/".$image['imagename'];
|
||||
$image_alt = $image['alt'];
|
||||
$image_colour = $make_stuff->get_image_colour($image_path);
|
||||
|
||||
|
@ -54,9 +54,9 @@
|
|||
<img>
|
||||
</div>";
|
||||
|
||||
if (is_file("images/previews/".$image['imagename'])) {
|
||||
if (is_file("usr/images/previews/".$image['imagename'])) {
|
||||
echo "<div class='image-container'>
|
||||
<img class='image' id='".$image['id']."' src='images/previews/".$image['imagename']."' alt='".$image_alt."'>
|
||||
<img class='image' id='".$image['id']."' src='usr/images/previews/".$image['imagename']."' alt='".$image_alt."'>
|
||||
<button class='preview-button' onclick='fullScreen()'><img src='assets/icons/scan.svg'></button>
|
||||
</div>";
|
||||
} else {
|
||||
|
@ -164,7 +164,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<!-- Download Image -->
|
||||
<a id='download' class='btn btn-good' href='<?php echo "images/".$image['imagename']; ?>' download='<?php echo $image['imagename']; ?>'><img class='svg' src='assets/icons/download.svg'>Download image</a>
|
||||
<a id='download' class='btn btn-good' href='<?php echo "usr/images/".$image['imagename']; ?>' download='<?php echo $image['imagename']; ?>'><img class='svg' src='assets/icons/download.svg'>Download image</a>
|
||||
<script>
|
||||
$("#download").click(function() {
|
||||
sniffleAdd("Info", "Image download started!", "var(--success)", "assets/icons/download.svg");
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
if (isset($user['pfp_path'])) {
|
||||
?>
|
||||
<script>
|
||||
sniffleAdd('O hi <?php echo $_SESSION["username"]; ?>', 'You are now logged in, enjoy your stay!', 'var(--success)', 'images/pfp/<?php echo $user["pfp_path"]; ?>');
|
||||
sniffleAdd('O hi <?php echo $_SESSION["username"]; ?>', 'You are now logged in, enjoy your stay!', 'var(--success)', 'usr/images/pfp/<?php echo $user["pfp_path"]; ?>');
|
||||
</script>
|
||||
<?php
|
||||
} else {
|
||||
|
@ -106,10 +106,10 @@
|
|||
|
||||
while ($image = mysqli_fetch_array($image_request)) {
|
||||
// Getting thumbnail
|
||||
if (file_exists("images/thumbnails/".$image['imagename'])) {
|
||||
$image_path = "images/thumbnails/".$image['imagename'];
|
||||
if (file_exists("usr/images/thumbnails/".$image['imagename'])) {
|
||||
$image_path = "usr/images/thumbnails/".$image['imagename'];
|
||||
} else {
|
||||
$image_path = "images/".$image['imagename'];
|
||||
$image_path = "usr/images/".$image['imagename'];
|
||||
}
|
||||
|
||||
// Check for NSFW tag
|
||||
|
|
12
profile.php
12
profile.php
|
@ -32,10 +32,10 @@
|
|||
|
||||
<div class="profile-root defaultDecoration defaultSpacing defaultFonts">
|
||||
<?php
|
||||
if (is_file("images/pfp/".$user['pfp_path'])) {
|
||||
echo "<img src='images/pfp/".$user['pfp_path']."'>";
|
||||
if (is_file("usr/images/pfp/".$user['pfp_path'])) {
|
||||
echo "<img src='usr/images/pfp/".$user['pfp_path']."'>";
|
||||
|
||||
$pfp_colour = $make_stuff->get_image_colour("images/pfp/".$user['pfp_path']);
|
||||
$pfp_colour = $make_stuff->get_image_colour("usr/images/pfp/".$user['pfp_path']);
|
||||
if (empty($pfp_colour)) $pfp_colour = "var(--bg-3)";
|
||||
?>
|
||||
<style>
|
||||
|
@ -86,10 +86,10 @@
|
|||
|
||||
while ($image = mysqli_fetch_array($query)) {
|
||||
// Getting thumbnail
|
||||
if (file_exists("images/thumbnails/".$image['imagename'])) {
|
||||
$image_path = "images/thumbnails/" . $image['imagename'];
|
||||
if (file_exists("usr/images/thumbnails/".$image['imagename'])) {
|
||||
$image_path = "usr/images/thumbnails/" . $image['imagename'];
|
||||
} else {
|
||||
$image_path = "images/" . $image['imagename'];
|
||||
$image_path = "usr/images/" . $image['imagename'];
|
||||
}
|
||||
|
||||
// Check for NSFW tag
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="">
|
||||
|
||||
<head>
|
||||
<?php include __DIR__."/assets/ui/header.php"; ?>
|
||||
|
@ -29,8 +29,8 @@
|
|||
<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">
|
||||
<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'>
|
||||
<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>
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
"Eat hotchip and lie"
|
||||
],
|
||||
"license":"GPL 3.0",
|
||||
"version": "22.10.12",
|
||||
"version": "22.10.13",
|
||||
"user_name": "[your name]",
|
||||
"is_testing": true,
|
||||
"upload": {
|
Loading…
Add table
Add a link
Reference in a new issue