diff --git a/app/account/get_info.php b/app/account/get_info.php new file mode 100644 index 0000000..cd65e21 --- /dev/null +++ b/app/account/get_info.php @@ -0,0 +1,16 @@ +"); + } +} diff --git a/app/image/edit_author.php b/app/image/edit_author.php index e69de29..fb3874d 100644 --- a/app/image/edit_author.php +++ b/app/image/edit_author.php @@ -0,0 +1,26 @@ +/* + Author confirm +*/ +if (isset($_POST['author_confirm']) && is_admin($_SESSION['id'])) { + // Unset all the variables, needed by flyout + unset($header, $content, $action); + + // getting ready forSQL asky asky + $sql = "UPDATE swag_table 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); + + // Setting parameters + $param_author = $_POST['update_author']; + $param_id = $image["id"]; + + // Attempt to execute the prepared statement + if (mysqli_stmt_execute($stmt)) { + header("Location:image.php?id=".$image["id"]."&update=success"); + } else { + header("Location:image.php?id=".$image["id"]."&update=error"); + } + } +} diff --git a/app/image/edit_description.php b/app/image/edit_description.php index 8a9a547..378fa2b 100644 --- a/app/image/edit_description.php +++ b/app/image/edit_description.php @@ -30,4 +30,3 @@ if (isset($_POST['submit'])) { } } } -?> diff --git a/app/image/edit_tags.php b/app/image/edit_tags.php index e69de29..7787578 100644 --- a/app/image/edit_tags.php +++ b/app/image/edit_tags.php @@ -0,0 +1,41 @@ +/* + Tags Confirm +*/ +if (isset($_POST['tags_confirm']) && $privilaged) { + // 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 = tag_clean(trim($_POST['add_tags'])); + + // getting ready forSQL asky asky + $sql = "UPDATE swag_table 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); + + // Setting parameters + $param_tags = $tags_string; + $param_id = $image["id"]; + + // Attempt to execute the prepared statement + if (mysqli_stmt_execute($stmt)) { + header("Location:image.php?id=".$image["id"]."&update=success"); + } else { + header("Location:image.php?id=".$image["id"]."&update=error"); + } + } +} diff --git a/app/image/get_image_info.php b/app/image/get_image_info.php new file mode 100644 index 0000000..b2b9fb6 --- /dev/null +++ b/app/image/get_image_info.php @@ -0,0 +1,16 @@ +connect_error) { - // Send notification that connection couldn't be made + echo ""; } diff --git a/app/server/secrete.php b/app/server/secrete.php new file mode 100644 index 0000000..e69de29 diff --git a/image.php b/image.php index 1a5b507..249dfcc 100644 --- a/image.php +++ b/image.php @@ -1,57 +1,10 @@ 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"; + return "No information provided."; } -} 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 - - This gets the user info from the image -*/ -if (isset($image['author'])) { - $user = get_user_info($conn, $image['author']); -} - -/* - Check user privilge - - This requires the user to be logged in or an admin -*/ -if (image_privilage($image['author']) || is_admin($_SESSION['id'])) { - $privilaged = True; -} else { - $privilaged = False; } ?> @@ -79,7 +32,63 @@ if (image_privilage($image['author']) || is_admin($_SESSION['id'])) { - + 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 + + This gets the user info from the image + */ + if (isset($image['author'])) { + $user = get_user_info($conn, $image['author']); + } + + /* + Check user privilge + + This requires the user to be logged in or an admin + */ + if (image_privilage($image['author']) || is_admin($_SESSION['id'])) { + $privilaged = True; + } else { + $privilaged = False; + } + + include"ui/nav.php"; ?> - "); - } - } - - /* - Tags Confirm - */ - if (isset($_POST['tags_confirm']) && $privilaged) { - // 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 = tag_clean(trim($_POST['add_tags'])); - - // getting ready forSQL asky asky - $sql = "UPDATE swag_table 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); - - // Setting parameters - $param_tags = $tags_string; - $param_id = $image["id"]; - - // Attempt to execute the prepared statement - if (mysqli_stmt_execute($stmt)) { - header("Location:image.php?id=".$image["id"]."&update=success"); - } else { - header("Location:image.php?id=".$image["id"]."&update=error"); - } - } - } - - /* - Description athor - */ - if (isset($_POST['author_flyout']) && is_admin($_SESSION['id'])) { - $header = "Who owns the image?????"; - $content = "Enter ID of image owner"; - $action = ""; - - flyout($header, $content, $action); - } - /* - Author confirm - */ - if (isset($_POST['author_confirm']) && is_admin($_SESSION['id'])) { - // Unset all the variables, needed by flyout - unset($header, $content, $action); - - // getting ready forSQL asky asky - $sql = "UPDATE swag_table 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); - - // Setting parameters - $param_author = $_POST['update_author']; - $param_id = $image["id"]; - - // Attempt to execute the prepared statement - if (mysqli_stmt_execute($stmt)) { - header("Location:image.php?id=".$image["id"]."&update=success"); - } else { - header("Location:image.php?id=".$image["id"]."&update=error"); - } - } - } - ?> -Search results for: ".$_GET['q']."
"; - } - ?> -".$content."
"; - } else { - echo "".$text."
"; - } elseif ($level == "low") { - $text_string = "".$text."
"; - } elseif ($level == "default") { - $text_string = "".$text."
"; - } else { - $text_string = "".$text."
"; - } - - return $text_string; -} diff --git a/ui/required.php b/ui/required.php index 838f2b4..1a72f8d 100644 --- a/ui/required.php +++ b/ui/required.php @@ -25,18 +25,18 @@ if (is_file("index.php")) { include $root_dir."app/server/conn.php"; /* - Include functions - - Maybe I should put all the functions in this file? Dunno + Add functions */ -include $root_dir."ui/functions.php"; +include $root_dir."app/account/get_info.php"; +include $root_dir."app/account/is_admin.php"; +include $root_dir."app/account/login_status.php"; -/* - Notification system +include $root_dir."app/format/string_to_tags.php"; - This is the notification system used by the website. Probably a little too much for what its used for -*/ -echo ""; +include $root_dir."app/image/get_image_info.php"; +include $root_dir."app/image/image_privilage.php"; + +include $root_dir."app/server/secrete.php"; ?>