Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.00 KB | None | 0 0
  1. <?php
  2. session_start(); //start new or resume existing session
  3. //set session variable "view" to an empty string -- this is for the viewImage.php page
  4. echo("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); //echo opening xml statement
  5. ?>
  6.  
  7. <!DOCTYPE html> <!-- set DOCTYPE to html -->
  8. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <!--set xml version-->
  9. <head> <!--open head tag-->
  10. <meta charset="utf-8" /> <!-- set charset -->
  11. <title>Image Resizer - Home</title> <!-- title of page -->
  12. <script src="http://code.jquery.com/jquery-latest.js"></script>
  13. </head> <!--close head tag -->
  14.  
  15. <body> <!-- open body tag-->
  16. <?php
  17.  
  18. include("includes/header.php"); //include the header.php page contents
  19. include("includes/OpenDBConn.php");
  20. if(empty($_SESSION["view"])) {
  21. $_SESSION["view"] = "All";
  22. }
  23.  
  24. if($_SESSION["loggedin"] == "true" && $_SESSION["role"] != "User" && $_SESSION["role"] != "Super Admin") {
  25. ?>
  26. <center><b><h1 style ="color:red;"> Welcome, <?php echo $_SESSION["role"] . " Cuisine Admin " . $_SESSION["firstname"] . " " . $_SESSION["lastname"]; ?>! </h1></b></center>
  27.  
  28. <?php } ?>
  29.  
  30. <?php
  31. if($_SESSION["loggedin"] == "true" && ($_SESSION["role"] == "User" || $_SESSION["role"] == "Super Admin")) {
  32. ?>
  33. <center><b><h1 style ="color:red;"> Welcome, <?php echo $_SESSION["role"] . " " . $_SESSION["firstname"] . " " . $_SESSION["lastname"]; ?>! </h1></b></center>
  34.  
  35. <?php } ?>
  36. <center><b><h4 style="color:green;"> Welcome to <i>Culinary Clicks</i>, your one-stop shop for anything food image related!</h4></b>
  37. <?php if($_SESSION["loggedin"] != "true" && $_SESSION["errormessage2"] != "") { ?>
  38. <div class="alert alert-warning" role="alert">
  39. We are sorry, but we are unable to register your account at this time due to the following error - <br>
  40. <?php echo $_SESSION["errormessage2"]; ?> <br>
  41. Please try again.
  42. </div>
  43. <?php }
  44. if($_SESSION["loggedin"] != "true" && $_SESSION["errormessage"] != "") {
  45. ?>
  46. <div class="alert alert-warning" role="alert">
  47. We are sorry, but we are unable to log you in to your account at this time due to the following error - <br>
  48. <?php echo $_SESSION["errormessage"]; ?> <br>
  49. Please try again, or create a new account if you don't already have one.
  50. </div>
  51. <?php }
  52. if($_SESSION["loggedin"] != "true" && $_SESSION["status"] != "") {
  53. ?>
  54. <div class="alert alert-success" role="alert">
  55. <?php echo $_SESSION["status"]; ?>
  56. </div>
  57. <?php } ?>
  58. </center>
  59.  
  60. <center><b> Please select a cuisine to view all sorts of foods that it has to offer.</b></center>
  61. <center>
  62. <form id = "form0" action = "doViewImage.php" method = "POST"><!--form with action being doViewImage.php and method being POST-->
  63. <select class="form-control form-control-lg" name = "imgs" id = "imgs"><!--dropdown menu in form to select image to view in original size and resized size-->
  64. <option value = "All">All</option>
  65. <?php
  66. $sql = "SELECT cuisine FROM Categories"; //sql statement to select all the imageID elements from table Images
  67. $result = $conn->query($sql); //process sql statement for my database;
  68. if($result->num_rows > 0) { //if there are more than 0 rows of elements in the result variable
  69. $num_results = $result->num_rows; //set $num_results to num_rows
  70. }
  71. else {
  72. $num_results = 0; //otherwise set $num_results to 0
  73. }
  74.  
  75. while ($row = $result->fetch_assoc()) { //while there are still rows of imageID elements left in the associative array $result
  76.  
  77. ?>
  78. <option value = <?php echo $row["cuisine"]; ?> <?php if($_SESSION["view"] == $row["cuisine"]) { echo "Selected";} ?>><?php echo $row["cuisine"]; ?></option> <!-- create a form dropdown menu element with the text being the imageID in the current row in $result-->
  79. <?php } ?> <!-- close while loop -->
  80. </select> <!--close select tag -- end of dropdown menu -->
  81. <br> <!--new line-->
  82. <center><button type="submit" class="btn btn-primary">View Image</button></center><br><br><!--button to submit form to doViewImage.php-->
  83. </form></center> <!--close form tag -- end of form -->
  84. <center>
  85. <!-- READ FROM HERE -->
  86. <?php
  87. if($_SESSION["view"] != "All") {
  88. $sql2 = "SELECT primarykey, imageID, imgDesc, imageNum FROM Images WHERE typeID = '". $_SESSION["view"] . "'";
  89. } else {
  90. $sql2 = "SELECT primarykey, imageID, imgDesc, imageNum FROM Images";
  91. }
  92. $result2 = $conn->query($sql2);
  93. if($result2->num_rows > 0) { //if there are more than 0 rows of elements in the result variable
  94. $num_results2 = $result2->num_rows; //set $num_results to num_rows
  95. }
  96. else {
  97. $num_results2 = 0; //otherwise set $num_results to 0
  98. }
  99. ?>
  100. <?php if($num_results2 == 0) { ?>
  101. <h4 style ="color:#f14d00"> No images avialable for this category.</h4>
  102. <?php } ?>
  103. <div id = "easyPaginate" class = "image-row">
  104. <?php while ($row2 = $result2->fetch_assoc()) { //while there are still rows of imageID elements left in the associative array $result
  105.  
  106. ?>
  107.  
  108. <a href= "<?php echo "upload/" . $row2["imageID"]; ?>" data-lightbox="<?php echo "img - " . $row2["primarykey"]; ?>" data-title="<?php echo $row2["imgDesc"]; ?>">
  109. <img src = <?php echo "thumb/" . $row2["imageID"]; ?>>
  110. </a>
  111. <a href= "<?php echo "upload/" . $row2["imageID"]; ?>" class="btn btn-info" role="button" download>Download Image</a>
  112. <br><br>
  113. <?php } ?>
  114. </div>
  115.  
  116.  
  117. </center>
  118. <script src="lightbox.js"></script>
  119. <script src="jquery.easyPaginate.js"></script>
  120. <script src="jquery.easyPaginate.js"></script>
  121. <script>
  122. $('#easyPaginate').easyPaginate({
  123. paginateElement: 'img',
  124. elementsPerPage: 8,
  125. effect: 'climb'
  126. });
  127. </script>
  128. </body>
  129.  
  130. <!-- <script src="lightbox.js"></script> -->
  131. <!--<script src="jquery.easyPaginate.js"></script>
  132. <script>
  133. $('#easyPaginate').easyPaginate({
  134. paginateElement: 'img',
  135. elementsPerPage: 8,
  136. effect: 'climb'
  137. });
  138. </script> -->
  139. </html>
  140. <?php include("includes/CloseDBConn.php"); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement