mirror of
https://github.com/Fluffy-Bean/image-gallery.git
synced 2025-06-21 09:20:37 +00:00
Moved functions into classes
This commit is contained in:
parent
951871b983
commit
92a1c3500e
22 changed files with 224 additions and 234 deletions
|
@ -35,15 +35,15 @@
|
||||||
|
|
||||||
<h2>Where to find me</h2>
|
<h2>Where to find me</h2>
|
||||||
<a class='link' href="https://gay.fluffybean.gay">
|
<a class='link' href="https://gay.fluffybean.gay">
|
||||||
<img class='svg' src='<?php echo $root_dir; ?>assets/icons/link.svg'>
|
<img class='svg' src='assets/icons/link.svg'>
|
||||||
My website!
|
My website!
|
||||||
</a>
|
</a>
|
||||||
<a class='link' href="https://t.me/Fluffy_Bean">
|
<a class='link' href="https://t.me/Fluffy_Bean">
|
||||||
<img class='svg' src='<?php echo $root_dir; ?>assets/icons/telegram-logo.svg'>
|
<img class='svg' src='assets/icons/telegram-logo.svg'>
|
||||||
Telegram
|
Telegram
|
||||||
</a>
|
</a>
|
||||||
<a class='link' href="https://twitter.com/fluffybeanUwU">
|
<a class='link' href="https://twitter.com/fluffybeanUwU">
|
||||||
<img class='svg' src='<?php echo $root_dir; ?>assets/icons/twitter-logo.svg'>
|
<img class='svg' src='assets/icons/twitter-logo.svg'>
|
||||||
Twitter
|
Twitter
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
|
10
account.php
10
account.php
|
@ -9,10 +9,14 @@
|
||||||
<?php
|
<?php
|
||||||
include "ui/required.php";
|
include "ui/required.php";
|
||||||
include "ui/nav.php";
|
include "ui/nav.php";
|
||||||
|
|
||||||
|
use App\Account;
|
||||||
|
|
||||||
|
$user_info = new Account();
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if (isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true) {
|
if ($user_info->is_loggedin()) {
|
||||||
?>
|
?>
|
||||||
<div class="account-root">
|
<div class="account-root">
|
||||||
<h2>Settings</h2>
|
<h2>Settings</h2>
|
||||||
|
@ -24,7 +28,7 @@
|
||||||
<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'>Logout</a>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
if ($_SESSION["id"] == 1) {
|
if ($user_info->is_admin($_SESSION['id'])) {
|
||||||
?>
|
?>
|
||||||
<div class="admin-root">
|
<div class="admin-root">
|
||||||
<h2>Admin controlls</h2>
|
<h2>Admin controlls</h2>
|
||||||
|
@ -37,7 +41,7 @@
|
||||||
<script>
|
<script>
|
||||||
function copyCode() {
|
function copyCode() {
|
||||||
navigator.clipboard.writeText("<?php echo $token['code']; ?>");
|
navigator.clipboard.writeText("<?php echo $token['code']; ?>");
|
||||||
sniffleAdd("Info", "Invite code has been copied!", "var(--green)", "<?php echo $root_dir; ?>assets/icons/clipboard-text.svg");
|
sniffleAdd("Info", "Invite code has been copied!", "var(--green)", "assets/icons/clipboard-text.svg");
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
Get full user info from database
|
|
||||||
|
|
||||||
Returns array with user info
|
|
||||||
*/
|
|
||||||
function get_user_info($conn, $id) {
|
|
||||||
// Setting SQL query
|
|
||||||
$sql = "SELECT * FROM users WHERE id = ".$id;
|
|
||||||
// Getting results
|
|
||||||
$query = mysqli_query($conn, $sql);
|
|
||||||
// Fetching associated info
|
|
||||||
$user_array = mysqli_fetch_assoc($query);
|
|
||||||
|
|
||||||
return($user_array);
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
Check if user is admin
|
|
||||||
|
|
||||||
Returns True if user is privilaged
|
|
||||||
Returns False if user is NOT privilaged
|
|
||||||
*/
|
|
||||||
function is_admin($id) {
|
|
||||||
if (isset($id) || !empty($id)) {
|
|
||||||
if ($id == 1) {
|
|
||||||
return True;
|
|
||||||
} else {
|
|
||||||
return False;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return False;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
Check if user is loggedin
|
|
||||||
|
|
||||||
Returns True if user is
|
|
||||||
Returns False if user is NOT
|
|
||||||
*/
|
|
||||||
function loggedin() {
|
|
||||||
if (isset($_SESSION["loggedin"]) == true && $_SESSION["loggedin"] == true) {
|
|
||||||
return True;
|
|
||||||
} else {
|
|
||||||
return False;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -90,7 +90,7 @@ if (isset($_POST['submit'])) {
|
||||||
?>
|
?>
|
||||||
<script>
|
<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(--green)', '../assets/icons/check.svg');
|
||||||
setTimeout(function(){window.location.href = "../account/login.php";}, 4000);
|
setTimeout(function(){window.location.href = "../account/login.php";}, 2000);
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
} else {
|
} else {
|
||||||
|
|
127
app/app.php
Normal file
127
app/app.php
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
<?php
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
class Make {
|
||||||
|
/*
|
||||||
|
|-------------------------------------------------------------
|
||||||
|
| Create Thumbnails
|
||||||
|
|-------------------------------------------------------------
|
||||||
|
| Default resolution for a preview image is 300px (max-width)
|
||||||
|
| ** Not yet implemented **
|
||||||
|
|-------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
function thumbnail($image_path, $thumbnail_path, $resolution) {
|
||||||
|
try {
|
||||||
|
$thumbnail = new Imagick($image_path);
|
||||||
|
$thumbnail->resizeImage($resolution,null,null,1,null);
|
||||||
|
$thumbnail->writeImage($thumbnail_path);
|
||||||
|
|
||||||
|
return "success";
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Clean up long text input and turn into an array for tags
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Account {
|
||||||
|
/*
|
||||||
|
Check if user is loggedin
|
||||||
|
|
||||||
|
Returns True if user is
|
||||||
|
Returns False if user is NOT
|
||||||
|
*/
|
||||||
|
function is_loggedin() {
|
||||||
|
if (isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true) {
|
||||||
|
return True;
|
||||||
|
} else {
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
Get full user info from database
|
||||||
|
|
||||||
|
Returns array with user info
|
||||||
|
*/
|
||||||
|
function get_user_info($conn, $id) {
|
||||||
|
// Setting SQL query
|
||||||
|
$sql = "SELECT * FROM users WHERE id = ".$id;
|
||||||
|
// Getting results
|
||||||
|
$query = mysqli_query($conn, $sql);
|
||||||
|
// Fetching associated info
|
||||||
|
$user_array = mysqli_fetch_assoc($query);
|
||||||
|
|
||||||
|
return($user_array);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
Check if user is admin
|
||||||
|
|
||||||
|
Returns True if user is privilaged
|
||||||
|
Returns False if user is NOT privilaged
|
||||||
|
*/
|
||||||
|
function is_admin($id) {
|
||||||
|
if (isset($id) || !empty($id)) {
|
||||||
|
if ($id == 1) {
|
||||||
|
return True;
|
||||||
|
} else {
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Image {
|
||||||
|
/*
|
||||||
|
Get full image info from database
|
||||||
|
|
||||||
|
Returns array with image info
|
||||||
|
*/
|
||||||
|
function get_image_info($conn, $id) {
|
||||||
|
// Setting SQL query
|
||||||
|
$sql = "SELECT * FROM swag_table WHERE id = ".$id;
|
||||||
|
// Getting results
|
||||||
|
$query = mysqli_query($conn, $sql);
|
||||||
|
// Fetching associated info
|
||||||
|
$image_array = mysqli_fetch_assoc($query);
|
||||||
|
|
||||||
|
return($image_array);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
Check if user is image owner
|
||||||
|
|
||||||
|
Returns True if user is privilaged
|
||||||
|
Returns False if user is NOT privilaged
|
||||||
|
*/
|
||||||
|
function image_privilage($id) {
|
||||||
|
$session_id = $_SESSION['id'];
|
||||||
|
if (isset($session_id) || !empty($session_id)) {
|
||||||
|
if ($session_id == $id) {
|
||||||
|
return True;
|
||||||
|
} else {
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,20 +0,0 @@
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
|-------------------------------------------------------------
|
|
||||||
| Create Thumbnails
|
|
||||||
|-------------------------------------------------------------
|
|
||||||
| Default resolution for a preview image is 300px (max-width)
|
|
||||||
| ** Not yet implemented **
|
|
||||||
|-------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
function make_thumbnail($image_path, $thumbnail_path, $resolution) {
|
|
||||||
try {
|
|
||||||
$thumbnail = new Imagick($image_path);
|
|
||||||
$thumbnail->resizeImage($resolution,null,null,1,null);
|
|
||||||
$thumbnail->writeImage($thumbnail_path);
|
|
||||||
|
|
||||||
return "success";
|
|
||||||
} catch (Exception $e) {
|
|
||||||
return $e;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
Clean up long text input and turn into an array for tags
|
|
||||||
|
|
||||||
Returns clean string of words with equal white space between it
|
|
||||||
*/
|
|
||||||
function tag_clean($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);
|
|
||||||
|
|
||||||
return $string;
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
Get full image info from database
|
|
||||||
|
|
||||||
Returns array with image info
|
|
||||||
*/
|
|
||||||
function get_image_info($conn, $id) {
|
|
||||||
// Setting SQL query
|
|
||||||
$sql = "SELECT * FROM swag_table WHERE id = ".$id;
|
|
||||||
// Getting results
|
|
||||||
$query = mysqli_query($conn, $sql);
|
|
||||||
// Fetching associated info
|
|
||||||
$image_array = mysqli_fetch_assoc($query);
|
|
||||||
|
|
||||||
return($image_array);
|
|
||||||
}
|
|
|
@ -2,11 +2,15 @@
|
||||||
session_start();
|
session_start();
|
||||||
// Include server connection
|
// Include server connection
|
||||||
include "../server/conn.php";
|
include "../server/conn.php";
|
||||||
// Include required checks
|
include "../app.php";
|
||||||
include "get_image_info.php";
|
|
||||||
include "image_privilage.php";
|
use App\Account;
|
||||||
// Required to format tags correctly
|
use App\Image;
|
||||||
include "../format/string_to_tags.php";
|
use App\Make;
|
||||||
|
|
||||||
|
$user_info = new Account();
|
||||||
|
$image_info = new Image();
|
||||||
|
$make_stuff = new Make();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|-------------------------------------------------------------
|
|-------------------------------------------------------------
|
||||||
|
@ -18,10 +22,10 @@ include "../format/string_to_tags.php";
|
||||||
*/
|
*/
|
||||||
if (isset($_POST['submit_delete'])) {
|
if (isset($_POST['submit_delete'])) {
|
||||||
// Get all image info
|
// Get all image info
|
||||||
$image_array = get_image_info($conn, $_POST['id']);
|
$image_array = $image_info->get_image_info($conn, $_POST['id']);
|
||||||
|
|
||||||
// If user owns image or has the ID of 1
|
// If user owns image or has the ID of 1
|
||||||
if (image_privilage($image_array['author']) || $_SESSION['id'] == 1) {
|
if ($image_info->image_privilage($image_array['author']) || $_SESSION['id'] == 1) {
|
||||||
// Delete from table
|
// Delete from table
|
||||||
$sql = "DELETE FROM swag_table WHERE id = ?";
|
$sql = "DELETE FROM swag_table WHERE id = ?";
|
||||||
if ($stmt = mysqli_prepare($conn, $sql)) {
|
if ($stmt = mysqli_prepare($conn, $sql)) {
|
||||||
|
@ -92,9 +96,9 @@ if (isset($_POST['submit_delete'])) {
|
||||||
*/
|
*/
|
||||||
if (isset($_POST['submit_description'])) {
|
if (isset($_POST['submit_description'])) {
|
||||||
// Get all image info
|
// Get all image info
|
||||||
$image_array = get_image_info($conn, $_POST['id']);
|
$image_array = $image_info->get_image_info($conn, $_POST['id']);
|
||||||
// If user owns image or has the ID of 1
|
// If user owns image or has the ID of 1
|
||||||
if (image_privilage($image_array['author']) || $_SESSION['id'] == 1) {
|
if ($image_info->image_privilage($image_array['author']) || $_SESSION['id'] == 1) {
|
||||||
// getting ready forSQL asky asky
|
// getting ready forSQL asky asky
|
||||||
$sql = "UPDATE swag_table SET alt=? WHERE id=?";
|
$sql = "UPDATE swag_table SET alt=? WHERE id=?";
|
||||||
|
|
||||||
|
@ -150,11 +154,11 @@ if (isset($_POST['submit_description'])) {
|
||||||
*/
|
*/
|
||||||
if (isset($_POST['submit_tags'])) {
|
if (isset($_POST['submit_tags'])) {
|
||||||
// Get all image info
|
// Get all image info
|
||||||
$image_array = get_image_info($conn, $_POST['id']);
|
$image_array = $image_info->get_image_info($conn, $_POST['id']);
|
||||||
// If user owns image or has the ID of 1
|
// If user owns image or has the ID of 1
|
||||||
if (image_privilage($image_array['author']) || $_SESSION['id'] == 1) {
|
if ($image_info->image_privilage($image_array['author']) || $_SESSION['id'] == 1) {
|
||||||
// Clean input
|
// Clean input
|
||||||
$tags_string = tag_clean(trim($_POST['input']));
|
$tags_string = $make_stuff->tags(trim($_POST['input']));
|
||||||
|
|
||||||
// getting ready forSQL asky asky
|
// getting ready forSQL asky asky
|
||||||
$sql = "UPDATE swag_table SET tags=? WHERE id=?";
|
$sql = "UPDATE swag_table SET tags=? WHERE id=?";
|
||||||
|
@ -211,7 +215,7 @@ if (isset($_POST['submit_tags'])) {
|
||||||
*/
|
*/
|
||||||
if (isset($_POST['submit_author'])) {
|
if (isset($_POST['submit_author'])) {
|
||||||
// If user has the ID of 1
|
// If user has the ID of 1
|
||||||
if ($_SESSION['id'] == 1) {
|
if ($user_info->is_admin($_SESSION['id'])) {
|
||||||
// getting ready forSQL asky asky
|
// getting ready forSQL asky asky
|
||||||
$sql = "UPDATE swag_table SET author=? WHERE id=?";
|
$sql = "UPDATE swag_table SET author=? WHERE id=?";
|
||||||
|
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
Check if user is image owner
|
|
||||||
|
|
||||||
Returns True if user is privilaged
|
|
||||||
Returns False if user is NOT privilaged
|
|
||||||
*/
|
|
||||||
function image_privilage($id) {
|
|
||||||
$session_id = $_SESSION['id'];
|
|
||||||
if (isset($session_id) || !empty($session_id)) {
|
|
||||||
if ($session_id == $id) {
|
|
||||||
return True;
|
|
||||||
} else {
|
|
||||||
return False;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return False;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -9,8 +9,11 @@
|
||||||
session_start();
|
session_start();
|
||||||
// Include server connection
|
// Include server connection
|
||||||
include "../server/conn.php";
|
include "../server/conn.php";
|
||||||
include "../format/string_to_tags.php";
|
include "../app.php";
|
||||||
include "../format/create_thumbnail.php";
|
|
||||||
|
use App\Make;
|
||||||
|
|
||||||
|
$make_stuff = new Make();
|
||||||
|
|
||||||
if (isset($_POST['submit'])) {
|
if (isset($_POST['submit'])) {
|
||||||
if (isset($_SESSION['id'])) {
|
if (isset($_SESSION['id'])) {
|
||||||
|
@ -25,7 +28,7 @@ if (isset($_POST['submit'])) {
|
||||||
$image_path = $dir.$image_newname;
|
$image_path = $dir.$image_newname;
|
||||||
|
|
||||||
// Clean tags
|
// Clean tags
|
||||||
$tags = tag_clean(trim($_POST['tags']));
|
$tags = $make_stuff->tags(trim($_POST['tags']));
|
||||||
|
|
||||||
// Allowed file types
|
// Allowed file types
|
||||||
$allowed_types = array('jpg', 'jpeg', 'png', 'webp');
|
$allowed_types = array('jpg', 'jpeg', 'png', 'webp');
|
||||||
|
@ -35,7 +38,7 @@ if (isset($_POST['submit'])) {
|
||||||
// Attempt making a thumbnail
|
// Attempt making a thumbnail
|
||||||
list($width, $height) = getimagesize($image_path);
|
list($width, $height) = getimagesize($image_path);
|
||||||
if ($width > 300) {
|
if ($width > 300) {
|
||||||
$make_thumbnail = make_thumbnail($image_path, $thumb_dir.$image_newname, 300);
|
$make_stuff->thumbnail($image_path, $thumb_dir.$image_newname, 300);
|
||||||
if ($make_thumbnail != "success") {
|
if ($make_thumbnail != "success") {
|
||||||
?>
|
?>
|
||||||
<script>
|
<script>
|
||||||
|
@ -45,7 +48,7 @@ if (isset($_POST['submit'])) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($width > 1100) {
|
if ($width > 1100) {
|
||||||
$make_preview = make_thumbnail($image_path, $preview_dir.$image_newname, 900);
|
$make_stuff->thumbnail($image_path, $preview_dir.$image_newname, 900);
|
||||||
if ($make_preview != "success") {
|
if ($make_preview != "success") {
|
||||||
?>
|
?>
|
||||||
<script>
|
<script>
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
/*
|
/*
|
||||||
Connect to database
|
Connect to database
|
||||||
|
|
||||||
In the future I want this section to be configurable, but that'll require some work to be done.
|
Dunno what else to put here lol
|
||||||
For now it's hard-coded, shouldn't be an issue as most people wont be changing this often anyway
|
|
||||||
*/
|
*/
|
||||||
$conn_ip = "192.168.0.79:3306";
|
$conn_ip = "192.168.0.79:3306";
|
||||||
$conn_username = "uwu";
|
$conn_username = "uwu";
|
||||||
|
@ -11,11 +10,6 @@ $conn_password = "fennec621";
|
||||||
$conn_database = "gallery";
|
$conn_database = "gallery";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$conn_ip = $database['ip'].":".$database['port'];
|
|
||||||
$conn_username = $database['username'];
|
|
||||||
$conn_password = $database['password'];
|
|
||||||
$conn_database = $database['database'];
|
|
||||||
|
|
||||||
echo $_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['SCRIPT_NAME']);
|
echo $_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['SCRIPT_NAME']);
|
||||||
echo $_SERVER['PHP_SELF'];
|
echo $_SERVER['PHP_SELF'];
|
||||||
*/
|
*/
|
||||||
|
@ -29,9 +23,4 @@ if ($conn->connect_error) {
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Start session
|
|
||||||
|
|
||||||
This is important as most pages use the PHP session and will complain if its not possible to access.
|
|
||||||
*/
|
|
||||||
session_start();
|
session_start();
|
||||||
|
|
|
@ -39,41 +39,3 @@ class GetEnv {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Aaa;
|
|
||||||
|
|
||||||
class GetEnv {
|
|
||||||
protected $path;
|
|
||||||
|
|
||||||
public function __construct(string $path)
|
|
||||||
{
|
|
||||||
if(!file_exists($path)) {
|
|
||||||
throw new \InvalidArgumentException(sprintf('%s does not exist', $path));
|
|
||||||
}
|
|
||||||
$this->path = $path;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function load() :void
|
|
||||||
{
|
|
||||||
if (!is_readable($this->path)) {
|
|
||||||
throw new \RuntimeException(sprintf('%s file is not readable', $this->path));
|
|
||||||
}
|
|
||||||
|
|
||||||
$lines = file($this->path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
|
||||||
foreach ($lines as $line) {
|
|
||||||
|
|
||||||
if (strpos(trim($line), '#') === 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
list($name, $value) = explode('=', $line, 2);
|
|
||||||
$name = trim($name);
|
|
||||||
$value = trim($value);
|
|
||||||
|
|
||||||
if (!array_key_exists($name, $_SERVER) && !array_key_exists($name, $_ENV)) {
|
|
||||||
putenv(sprintf('%s=%s', $name, $value));
|
|
||||||
$_ENV[$name] = $value;
|
|
||||||
$_SERVER[$name] = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -27,15 +27,14 @@
|
||||||
],
|
],
|
||||||
"license":"GPL 3.0",
|
"license":"GPL 3.0",
|
||||||
"database": {
|
"database": {
|
||||||
"ip": "192.168.0.79",
|
"ip": "192.168.0.79:3306",
|
||||||
"port": "3306",
|
|
||||||
"username": "uwu",
|
"username": "uwu",
|
||||||
"password": "fennec621",
|
"password": "fennec621",
|
||||||
"database": "gallery"
|
"database": "gallery"
|
||||||
},
|
},
|
||||||
"debug": {
|
"debug": {
|
||||||
"testing": true,
|
"testing": true,
|
||||||
"version": "22.09.08"
|
"version": "22.09.12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"plugins": {
|
"plugins": {
|
||||||
|
|
20
image.php
20
image.php
|
@ -21,11 +21,11 @@
|
||||||
include "ui/required.php";
|
include "ui/required.php";
|
||||||
include "ui/nav.php";
|
include "ui/nav.php";
|
||||||
|
|
||||||
include "app/image/get_image_info.php";
|
use App\Account;
|
||||||
include "app/image/image_privilage.php";
|
use App\Image;
|
||||||
|
|
||||||
include "app/format/string_to_tags.php";
|
|
||||||
|
|
||||||
|
$image_info = new Image;
|
||||||
|
$user_info = new Account;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|-------------------------------------------------------------
|
|-------------------------------------------------------------
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
*/
|
*/
|
||||||
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
|
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
|
||||||
// Get all image info
|
// Get all image info
|
||||||
$image = get_image_info($conn, $_GET['id']);
|
$image = $image_info->get_image_info($conn, $_GET['id']);
|
||||||
|
|
||||||
// Check if image is avalible
|
// Check if image is avalible
|
||||||
if (isset($image['imagename'])) {
|
if (isset($image['imagename'])) {
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
} else {
|
} else {
|
||||||
?>
|
?>
|
||||||
<script>
|
<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)', '<?php echo $root_dir; ?>assets/icons/cross.svg');
|
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>
|
||||||
<?php
|
<?php
|
||||||
$image_present = False;
|
$image_present = False;
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
} else {
|
} else {
|
||||||
?>
|
?>
|
||||||
<script>
|
<script>
|
||||||
sniffleAdd('Where is da image?', 'The link you followed seems to be broken, or there was some other error, who knows!', 'var(--red)', '<?php echo $root_dir; ?>assets/icons/cross.svg');
|
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>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
$image_present = False;
|
$image_present = False;
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
*/
|
*/
|
||||||
if (isset($image['author'])) {
|
if (isset($image['author'])) {
|
||||||
// Get all information on the user
|
// Get all information on the user
|
||||||
$user = get_user_info($conn, $image['author']);
|
$user = $user_info->get_user_info($conn, $image['author']);
|
||||||
|
|
||||||
if (isset($user['username'])) {
|
if (isset($user['username'])) {
|
||||||
$image_author = $user['username'];
|
$image_author = $user['username'];
|
||||||
|
@ -123,7 +123,7 @@
|
||||||
| Check user privilge
|
| Check user privilge
|
||||||
|-------------------------------------------------------------
|
|-------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
if (image_privilage($image['author']) || is_admin($_SESSION['id'])) {
|
if ($image_info->image_privilage($image['author']) || $user_info->is_admin($_SESSION['id'])) {
|
||||||
$privilaged = True;
|
$privilaged = True;
|
||||||
} else {
|
} else {
|
||||||
$privilaged = False;
|
$privilaged = False;
|
||||||
|
@ -363,7 +363,7 @@
|
||||||
|-------------------------------------------------------------
|
|-------------------------------------------------------------
|
||||||
-->
|
-->
|
||||||
<?php
|
<?php
|
||||||
if (is_admin($_SESSION['id'])) {
|
if ($user_info->is_admin($_SESSION['id'])) {
|
||||||
?>
|
?>
|
||||||
<button id='authorButton' class='btn btn-bad'><img class='svg' src='assets/icons/edit.svg'>Edit author</button>
|
<button id='authorButton' class='btn btn-bad'><img class='svg' src='assets/icons/edit.svg'>Edit author</button>
|
||||||
<script>
|
<script>
|
||||||
|
|
|
@ -83,7 +83,6 @@ include "ui/nav.php";
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<?php include "ui/footer.php"; ?>
|
<?php include "ui/footer.php"; ?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -11,8 +11,12 @@
|
||||||
include "ui/required.php";
|
include "ui/required.php";
|
||||||
include "ui/nav.php";
|
include "ui/nav.php";
|
||||||
|
|
||||||
|
use App\Account;
|
||||||
|
|
||||||
|
$user_info = new Account();
|
||||||
|
|
||||||
// Check if the user is logged in, otherwise redirect to login page
|
// Check if the user is logged in, otherwise redirect to login page
|
||||||
if (!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true) {
|
if ($user_info->is_loggedin() != true) {
|
||||||
header("location: account.php");
|
header("location: account.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
20
ui/nav.php
20
ui/nav.php
|
@ -1,3 +1,9 @@
|
||||||
|
<?php
|
||||||
|
use App\Account;
|
||||||
|
|
||||||
|
$loggedin = new Account();
|
||||||
|
?>
|
||||||
|
|
||||||
<nav class="nav-root flex-left">
|
<nav class="nav-root flex-left">
|
||||||
<div class="nav-name flex-left">
|
<div class="nav-name flex-left">
|
||||||
<p><?php echo $user_settings['website']['name']; ?></p>
|
<p><?php echo $user_settings['website']['name']; ?></p>
|
||||||
|
@ -8,12 +14,16 @@
|
||||||
<a class='btn' href='search.php'><img class='svg' src='assets/icons/binoculars.svg'><span class='nav-hide'>Search</span></a>
|
<a class='btn' href='search.php'><img class='svg' src='assets/icons/binoculars.svg'><span class='nav-hide'>Search</span></a>
|
||||||
<hr>
|
<hr>
|
||||||
<?php
|
<?php
|
||||||
if (loggedin()) {
|
if ($loggedin->is_loggedin()) {
|
||||||
echo "<a class='btn' href='upload.php'><img class='svg' src='assets/icons/upload.svg'><span class='nav-hide'>Upload</span></a>";
|
?>
|
||||||
echo "<hr>";
|
<a class='btn' href='upload.php'><img class='svg' src='assets/icons/upload.svg'><span class='nav-hide'>Upload</span></a>
|
||||||
echo "<a class='btn' href='account.php'><img class='svg' src='assets/icons/user-circle.svg'><span class='nav-hide'>".substr($_SESSION["username"], 0, 15)."</span></a>";
|
<hr>
|
||||||
|
<a class='btn' href='account.php'><img class='svg' src='assets/icons/user-circle.svg'><span class='nav-hide'><?php echo substr($_SESSION["username"], 0, 15); ?></span></a>
|
||||||
|
<?php
|
||||||
} else {
|
} else {
|
||||||
echo "<a class='btn' href='account.php'><img class='svg' src='assets/icons/sign-in.svg'><span class='nav-hide'>Login</span></a>";
|
?>
|
||||||
|
<a class='btn' href='account.php'><img class='svg' src='assets/icons/sign-in.svg'><span class='nav-hide'>Login</span></a>
|
||||||
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -4,10 +4,8 @@
|
||||||
*/
|
*/
|
||||||
include "app/settings/settings.php";
|
include "app/settings/settings.php";
|
||||||
|
|
||||||
if ($debug["testing"]) {
|
/*if ($debug["testing"]) {
|
||||||
/*
|
// Used for testing, do not use this in production
|
||||||
Used for testing, do not use this in production
|
|
||||||
*/
|
|
||||||
ini_set('display_errors', 1);
|
ini_set('display_errors', 1);
|
||||||
ini_set('display_startup_errors', 1);
|
ini_set('display_startup_errors', 1);
|
||||||
error_reporting(E_ERROR | E_PARSE | E_NOTICE);
|
error_reporting(E_ERROR | E_PARSE | E_NOTICE);
|
||||||
|
@ -16,10 +14,18 @@ if ($debug["testing"]) {
|
||||||
sniffleAdd('Notice', 'This website is currently in a testing state, bugs may occur', 'var(--red)', 'assets/icons/cross.svg');
|
sniffleAdd('Notice', 'This website is currently in a testing state, bugs may occur', 'var(--red)', 'assets/icons/cross.svg');
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
}
|
}*/
|
||||||
|
|
||||||
ini_set('post_max_size', '20M');
|
ini_set('post_max_size', '20M');
|
||||||
ini_set('upload_max_filesize', '20M');
|
ini_set('upload_max_filesize', '20M');
|
||||||
|
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, bugs may occur', 'var(--red)', 'assets/icons/cross.svg');
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
|
||||||
if (is_file("index.php")) {
|
if (is_file("index.php")) {
|
||||||
$root_dir = "";
|
$root_dir = "";
|
||||||
|
@ -33,9 +39,10 @@ if (is_file("index.php")) {
|
||||||
include "app/server/conn.php";
|
include "app/server/conn.php";
|
||||||
include "app/server/secrete.php";
|
include "app/server/secrete.php";
|
||||||
|
|
||||||
include "app/account/get_info.php";
|
/*
|
||||||
include "app/account/is_admin.php";
|
Classes
|
||||||
include "app/account/login_status.php";
|
*/
|
||||||
|
include 'app/app.php';
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<script>
|
<script>
|
||||||
|
|
|
@ -58,13 +58,16 @@
|
||||||
include "ui/required.php";
|
include "ui/required.php";
|
||||||
include "ui/nav.php";
|
include "ui/nav.php";
|
||||||
|
|
||||||
|
use App\Account;
|
||||||
|
$user_info = new Account();
|
||||||
|
|
||||||
// Check if user is logged in
|
// Check if user is logged in
|
||||||
if (!loggedin()) {
|
if (!$user_info->is_loggedin()) {
|
||||||
echo "
|
?>
|
||||||
<script>
|
<script>
|
||||||
sniffleAdd('Who are you!', 'You must be loggedin to upload things, sowwy!', 'var(--red)', 'assets/icons/cross.svg');
|
sniffleAdd('Who are you!', 'You must be loggedin to upload things, sowwy!', 'var(--red)', 'assets/icons/cross.svg');
|
||||||
</script>
|
</script>
|
||||||
";
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue