diff --git a/assets/icons/circle-wavy-green.svg b/assets/icons/circle-wavy-green.svg new file mode 100644 index 0000000..ca218f7 --- /dev/null +++ b/assets/icons/circle-wavy-green.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/icons/circle-wavy.svg b/assets/icons/circle-wavy.svg new file mode 100644 index 0000000..839e559 --- /dev/null +++ b/assets/icons/circle-wavy.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/image.php b/image.php index 84bdd43..39c329c 100644 --- a/image.php +++ b/image.php @@ -1,56 +1,3 @@ -Could not find image with ID: ".$_GET['id']."

"; - - // Replacement "no image" image and description - $image_path = "assets/no_image.png"; - $image_alt = "No image could be found, sowwy"; - } -} else { - // No ID toast - echo "

No ID present

"; - - // Replacement "no image" image and description - $image_path = "assets/no_image.png"; - $image_alt = "No image could be found, sowwy"; -} - - -// Get all user details -if (isset($image['author'])) { - $get_user = "SELECT * FROM users WHERE id = ".$image['author']; - $user_results = mysqli_query($conn, $get_user); - $user = mysqli_fetch_assoc($user_results); -} -?> - - @@ -64,13 +11,6 @@ if (isset($image['author'])) { - "; - - list($meta_width, $meta_height) = getimagesize($image_path); - echo ""; - echo ""; - - echo ""?> @@ -79,9 +19,6 @@ if (isset($image['author'])) { Something went fuckywucky, please try later

"; } + // If ID present pull all image data + if (isset($_GET['id'])) { + $image = get_image_info($conn, $_GET['id']); - /* - Check if the user is an admin session id = 1 - Or the owner of the image, image author == session id + // Check if image is avalible + if (isset($image['imagename'])) { + // Display image + $image_path = "images/".$image['imagename']; + $image_alt = $image['alt']; + } else { + // ID not avalible toast + echo "

Could not find image with ID: ".$_GET['id']."

"; - This may not be the best system of doing this, but much better than not having it at all - I plan on adding an array of privilaged users that user with the id of 1 can modify, - sort of like a mod/admin list of users - */ - if (isset($_SESSION['id']) && $image['author'] == $_SESSION['id'] || $_SESSION['id'] == 1) { + // Replacement "no image" image and description + $image_path = "assets/no_image.png"; + $image_alt = "No image could be found, sowwy"; + } + } else { + // No ID toast + echo "

No ID present

"; + + // Replacement "no image" image and description + $image_path = "assets/no_image.png"; + $image_alt = "No image could be found, sowwy"; + } + + + // Get all user details + if (isset($image['author'])) { + $user = get_user_info($conn, $image['author']); + } + + // Check user privilge + if (image_privilage($image['author']) || is_admin($_SESSION['id'])) { $privilaged = True; } else { $privilaged = False; @@ -248,7 +209,7 @@ if (isset($image['author'])) { /* Description athor */ - if (isset($_POST['author_flyout']) && $_SESSION['id'] == 1) { + if (isset($_POST['author_flyout']) && is_admin($_SESSION['id'])) { $header = "Who owns the image?????"; $content = "Enter ID of image owner"; $action = "
@@ -261,7 +222,7 @@ if (isset($image['author'])) { /* Author confirm */ - if (isset($_POST['author_confirm']) && $_SESSION['id'] == 1) { + if (isset($_POST['author_confirm']) && is_admin($_SESSION['id'])) { // Unset all the variables, needed by flyout unset($header, $content, $action); @@ -352,7 +313,6 @@ if (isset($image['author'])) { } else { echo "

No tags present

"; } - ?> @@ -385,7 +345,7 @@ if (isset($image['author'])) {
"; // Edit authro - if ($_SESSION['id'] == 1) { + if (is_admin($_SESSION['id'])) { echo "
"; diff --git a/index.php b/index.php index 829c084..d8f4b7c 100644 --- a/index.php +++ b/index.php @@ -13,9 +13,6 @@ Successfully deleted image: ".$_GET['id']."

"; @@ -44,18 +41,6 @@ // Unset all the variables, needed by flyout unset($header, $content, $action); - // Clean tags before adding - function clean($string) { - // Change to lowercase - $string = strtolower($string); - // Replace hyphens - $string = str_replace('-', '_', $string); - // Regex - $string = preg_replace('/[^A-Za-z0-9\_ ]/', '', $string); - // Return string - return preg_replace('/ +/', ' ', $string); - } - // Clean input $tags_string = clean(trim($_POST['search'])); diff --git a/ui/flyout.php b/ui/flyout.php deleted file mode 100644 index 2310f19..0000000 --- a/ui/flyout.php +++ /dev/null @@ -1,25 +0,0 @@ -"; - // Div Start - echo "
"; - - // Header for the flyout, must be included - if (isset($flyout_header) && !empty($flyout_header)) { - echo "

".$flyout_header."

"; - } - // Flyout content, must be included!!!! - if (isset($flyout_content) && !empty($flyout_content)) { - echo "

".$flyout_content."

"; - } - // Flyout button, not required so must need more information when added - if (isset($flyout_action) && !empty($flyout_action)) { - echo $flyout_action; - } - - // Exit button + Div End - echo " -
"; -} -?> diff --git a/ui/functions.php b/ui/functions.php new file mode 100644 index 0000000..8cb251d --- /dev/null +++ b/ui/functions.php @@ -0,0 +1,154 @@ + + At the bottom of the HTML document +*/ +function flyout($header, $content, $action) { + // Used for background dimming + echo "
"; + // Div Start + echo "
"; + + // Header for the flyout, must be included + if (isset($header) && !empty($header)) { + echo "

".$header."

"; + } else { + echo "

Header

"; + } + + // Flyout content, must be included!!!! + if (isset($content) && !empty($content)) { + echo "

".$content."

"; + } else { + echo "

Description

"; + } + + // Flyout button, not required so must need more information when added + if (isset($action) && !empty($action)) { + echo $action; + } + + // Exit button + Div End + echo " +
"; +} +?> diff --git a/ui/header.php b/ui/header.php index be395fb..0bd92b3 100644 --- a/ui/header.php +++ b/ui/header.php @@ -1,6 +1,15 @@ Search"; echo "
"; - if (isset($_SESSION["username"])) { + if (loggedin()) { echo "Upload"; echo "
"; echo "".substr($_SESSION["username"], 0, 15).""; diff --git a/upload.php b/upload.php index cc06289..a76e673 100644 --- a/upload.php +++ b/upload.php @@ -15,7 +15,7 @@ include_once("ui/conn.php"); // Check if user is logged in - if (isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true) { + if (loggedin()) { // User is logged in } else { $error = "You must be logged in to upload images";