Advertisement
Guest User

Untitled

a guest
Mar 7th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.04 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <HTML>
  3. <HEAD>
  4.  
  5. <!--NOTE: FIX LOGOUT BUTTON-->
  6.  
  7. <meta name="viewport" content="width=device-width, initial-scale=1">
  8. <title>Bedan Kiosk</title>
  9. <link rel="stylesheet" href="css/css_dashboard.css">
  10. <link rel="stylesheet" href="css/css_mainnav.css">
  11. <link rel="stylesheet" href="css/css_datatable.css">
  12. </HEAD>
  13.  
  14. <script>
  15. // Get the modal
  16. var modal = document.getElementById('id01');
  17.  
  18. // Get the <span> element that closes the modal
  19. var span = document.getElementsByClassName("close")[0];
  20.  
  21. // When the user clicks anywhere outside of the modal, close it
  22. window.onclick = function(event) {
  23. if (event.target == modal) {
  24. modal.style.display = "none";
  25. }
  26. }
  27. </script>
  28.  
  29. <style>
  30.  
  31. table {
  32. width: 100%;
  33. }
  34. Table tr > *:nth-child(1) {
  35. display: none;
  36. }
  37. Table tr > *:nth-child(3) {
  38. display: none;
  39. }
  40. Table tr > *:nth-child(4) {
  41. display: none;
  42. }
  43. Table tr > *:nth-child(5) {
  44. display: none;
  45. }
  46. Table tr > *:nth-child(6) {
  47. display: none;
  48. }
  49. Table tr > *:nth-child(7) {
  50. display: none;
  51. }
  52. Table tr > *:nth-child(8) {
  53. display: none;
  54. }
  55.  
  56. </style>
  57.  
  58.  
  59. <BODY onload="makeTableScroll();">
  60.  
  61. <?php
  62. session_start();
  63.  
  64. include "Connect.php";
  65.  
  66. if(!empty($_SESSION['username'])){
  67. $db_login = $_SESSION['username'];
  68. }
  69. else{
  70. $db_login =null;
  71.  
  72. }
  73.  
  74. $view_query = mysqli_query($connections, "select * from tblusers where Username = '$db_login' ");
  75. while($row = mysqli_fetch_assoc($view_query)){
  76. $db_login = $row["Username"];
  77. }
  78.  
  79. if($db_login == null){
  80. $_SESSION['username'] = 'Logged-out!';
  81. }
  82.  
  83. ?>
  84.  
  85. <img style="height: auto; width: 40%; position:absolute; z-index : -1;" src="img/top_bg.png"/>
  86.  
  87. <nav id="main_nav">
  88. <a href="dashboard.html"> <img style="height: auto; width: 11%; margin:8px; margin-left:23px; float:left;" src="img/main_logo.png"/> </a>
  89. <ul>
  90.  
  91.  
  92. <a onclick="logout()" style='text-decoration:none; cursor: pointer; <?php
  93. if(isset($_SESSION['username'])){
  94. if($_SESSION['username'] == 'Logged-out!' || empty($_SESSION['username'])){
  95. echo 'visibility: hidden;';
  96. }
  97. }?>'><li class="item">LOG OUT</li></a>
  98.  
  99. <a onclick="document.getElementById('id01').style.display='block'" style='text-decoration:none; cursor: pointer; <?php
  100. if(isset($_SESSION['username'])){
  101. if($_SESSION['username'] != 'Logged-out!'){
  102. echo 'visibility: hidden;';
  103. }
  104. }?>'><li class="item">LOG IN</li></a>
  105. <a href='<?php
  106. if(isset($_SESSION['Role'])){
  107. if($_SESSION['Role'] == 'Logged-out!'){
  108. echo 'Dashboard.php';
  109. }
  110. else{
  111. echo 'Forum.php';
  112. }
  113. }
  114. ?>' style="text-decoration:none"><li class="item">FORUMS</li></a>
  115. <a href='<?php
  116. if(isset($_SESSION['Role'])){
  117. if($_SESSION['Role'] == 'Member'){
  118. echo 'Member.php';
  119. }
  120. else if($_SESSION['Role'] == 'Admin'){
  121. echo 'Admin.php';
  122. }
  123. else{
  124. echo 'Dashboard.php';
  125. }
  126. }
  127. ?>' style="text-decoration:none"><li class="item">GUARDHOUSE</li></a>
  128. <a href="Dashboard.php" style="text-decoration:none"><li class="item">HOME</li></a>
  129. </ul>
  130. </nav>
  131.  
  132.  
  133. <div id="form_login" style='
  134. <?php
  135. if(isset($_SESSION['username'])){
  136. if($_SESSION['username'] != 'Logged-out!'){
  137. echo 'visibility: hidden;';
  138. }
  139. }?>'>
  140.  
  141. <div id="id01" class="modal">
  142.  
  143. <form class="modal-content animate" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="POST">
  144.  
  145. <div class="imgcontainer">
  146. <span onclick="document.getElementById('id01').style.display='none'" class="close">&times;</span>
  147. </div>
  148.  
  149. <div class="container">
  150. <label for="uname"><b>Username</b></label>
  151. <input type="text" name="username" placeholder="Enter Your Name" required>
  152.  
  153. <label for="psw"><b>Password</b></label>
  154. <input type="text" name="password" placeholder="Enter Your Password" required>
  155. <button type="submit" name="bttnLogin">Login</button>
  156.  
  157. <label>
  158. <input type="checkbox" checked="checked" name="remember"> Remember me
  159. </label>
  160.  
  161. </div>
  162.  
  163. <div class="container" style="background-color:#f1f1f1">
  164. <span class="psw"><a href="#">Forgot password?</a></span>
  165. </div>
  166.  
  167. </form>
  168. </div>
  169. </div>
  170.  
  171. <div id="form_logout" style='<?php if(isset($_SESSION['username'])){
  172.  
  173.  
  174. if($_SESSION['username'] == '' || $_SESSION['username'] == 'Logged-out!'){
  175. echo 'visibility: hidden;';
  176. }
  177. }?>'>
  178.  
  179. <form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="POST">
  180. <input type="submit" class="button" value="LOG OUT" name="bttnLogout"> <br>
  181. </form>
  182. </div>
  183.  
  184. <?php
  185. if(isset($_SESSION['username'])){
  186. echo $_SESSION['username'];
  187. }
  188.  
  189. //login account
  190.  
  191. if(isset($_POST['bttnLogin'])){
  192. require 'Connect.php';
  193.  
  194. $username = $_POST["username"];
  195. $password = $_POST["password"];
  196.  
  197. //getting entry
  198. $result = mysqli_query($connections, "SELECT * FROM `tblusers` WHERE username ='$username' and password = '$password'");
  199.  
  200. //role checking
  201. if(mysqli_num_rows($result) == 1){
  202. $_SESSION['username'] = $username;
  203.  
  204. $admin = mysqli_query($connections, "SELECT * FROM `tblusers` WHERE username ='$username' and role ='Admin'");
  205. $member = mysqli_query($connections, "SELECT * FROM `tblusers` WHERE username ='$username' and role ='Member'");
  206. $student = mysqli_query($connections, "SELECT * FROM `tblusers` WHERE username ='$username' and role ='Student'");
  207. $author = mysqli_query($connections, "SELECT * FROM `tblusers` WHERE username ='$username' and role ='Author'");
  208. $moderator = mysqli_query($connections, "SELECT * FROM `tblusers` WHERE username ='$username' and role ='Moderator'");
  209. $user = mysqli_query($connections, "SELECT * FROM `tblusers` WHERE username ='$username' and role ='User'");
  210.  
  211.  
  212. //admin
  213. if(mysqli_num_rows($admin) == 1){ header('location: Admin.php');
  214. $_SESSION['Role'] = 'Admin';
  215. }
  216.  
  217. //member
  218. else if(mysqli_num_rows($member) == 1){ header('location: Member.php');
  219. $_SESSION['Role'] = 'Member';
  220. }
  221.  
  222. //Student
  223. else if(mysqli_num_rows($student) == 1){ header('location: Dashboard.php');
  224. $_SESSION['Role'] = 'Student';
  225. }
  226.  
  227. //Author
  228. else if(mysqli_num_rows($author) == 1){ header('location: Author.php');
  229. $_SESSION['Role'] = 'Author';
  230. }
  231.  
  232. //Moderator
  233. else if(mysqli_num_rows($moderator) == 1){ header('location: Dashboard.php');
  234. $_SESSION['Role'] = 'Moderator';
  235. }
  236. //User
  237. else if(mysqli_num_rows($moderator) == 1){ header('location: Dashboard.php');
  238. $_SESSION['Role'] = 'User';
  239. }
  240.  
  241. //invalid role
  242. else{echo "<script language='javascript'> alert('Account invalid!')</script>";}
  243.  
  244. }
  245.  
  246. else{echo "<script language='javascript'> alert('Account invalid!')</script>";}
  247.  
  248. }
  249.  
  250. ?>
  251.  
  252. <div id="dashboard_main">
  253.  
  254. <div id="article_menu">
  255.  
  256.  
  257. <?php
  258.  
  259. include 'Connect.php';
  260. $view_query = mysqli_query($connections, "select * from tblnews limit 6");
  261.  
  262. echo '<div class="scrollingTable">';
  263. echo "<br><table border='1' width='60%' id='table'>";
  264. echo "<tr>";
  265. echo "<td>ArticleID</td>";
  266. echo "<td><img style='height: auto; width: 93%; margin:10px;' src='img/article_head.png'/></td>";
  267. echo "<td>Author</td>";
  268. echo "<td>Date</td>";
  269. echo "<td>Content</td>";
  270. echo "<td>Photographer</td>";
  271. echo "<td>PhotoID</td>";
  272. echo "<td></td>";
  273. echo "</tr>";
  274. echo "<tr>";
  275. echo "<td></td>";
  276. echo "</tr>";
  277.  
  278. //while loop for table
  279. while($row = mysqli_fetch_assoc($view_query)){
  280. $db_article = $row["ArticleID"];
  281. $db_title = $row["Title"];
  282. $db_author = $row["Author"];
  283. $db_date = $row["Date"];
  284. $db_content = $row["Content"];
  285. $db_photographer = $row["Photographer"];
  286. $db_photo = $row["PhotoID"];
  287. $photo = "";
  288. $photo2 = "";
  289.  
  290. //can be removed later
  291. if(empty($db_photo)){
  292. $photo = "Empty";
  293. }
  294. else{$photo = "<img src='uploads/$db_photo' style='width: 100px;'>";
  295. $photo2 = "uploads/$db_photo";
  296. }
  297.  
  298. echo "<tr>
  299. <td>$db_article</td>
  300. <td>$db_title</td>
  301. <td>$db_author</td>
  302. <td>$db_date</td>
  303. <td>$db_content</td>
  304. <td>$db_photographer</td>
  305. <td>$photo</td>
  306. <td>$photo2</td>
  307. </tr>";
  308. }
  309. echo "<tr>
  310. <td></td>
  311. <td></td>
  312. </tr>";
  313. echo "</table>";
  314. echo "</div>";
  315. echo '<a href="News.php"><button>View all</button></a>';
  316. echo "<script></script>";
  317. echo "<br>";
  318.  
  319.  
  320. ?>
  321. </div>
  322.  
  323. <div id="carousel_main">
  324. Title <input type="text" name="username" id="title" readonly><br>
  325. Author <input type="text" name="username" id="author" readonly><br>
  326. Date <input type="text" name="username" id="date" readonly><br>
  327. <textarea rows="4" cols="50" id="content" readonly>
  328. </textarea><br>
  329. <img src='uploads/sanbeda.png' style='width: 300px;' id="articlepic">
  330. </div>
  331. </div>
  332.  
  333.  
  334.  
  335. <img style="height: auto; width: 15%; position: relative; float:right;transform: scaleX(-1); top:4px;" src="img/foot_trans.png"/>
  336. <img style="height: auto; width: 15%; position: relative; margin:0 auto; top:4px;" src="img/foot_trans.png"/>
  337. <footer id="main_footer">
  338. <img style="height: auto; width: 20%; vertical-align:middle; float:left; margin-top:55px; margin-left:30px;" src="img/sub_logo.png"/>
  339.  
  340. <h3>Back-End Programmer</h3>
  341. <hr style="width: 290px;" align="left">
  342. <span>Vince Ryan Bufete</span>
  343.  
  344. <footer id="copyright">
  345. &nbsp;&nbsp;&nbsp;&copy; Team Variabois 2018 - 2019. All Rights Reserved
  346. </footer>
  347. </footer>
  348.  
  349.  
  350. <script>
  351.  
  352. <!--MAIN SCRIPT FOR CLIENT-SIDE FUNCTIONALITY-->
  353. <span id="spnText"></span>
  354. <script src="jquery.min.js"></script>
  355. <script>
  356.  
  357.  
  358.  
  359. //JAVASCRIPT FOR MAKING TABLE SCROLLABLE
  360.  
  361. var maxRows;
  362. function makeTableScroll() {
  363. // Constant retrieved from server-side via JSP
  364. maxRows = 9;
  365. var table = document.getElementById('table');
  366. var wrapper = table.parentNode;
  367. var rowsInTable = table.rows.length;
  368. var height = 50;
  369. if (rowsInTable > maxRows) {
  370. for (var i = 0; i < maxRows; i++) {
  371. height += table.rows[i].clientHeight;
  372. }
  373. wrapper.style.height = height + "px";
  374. }
  375. }
  376.  
  377. function myFunction() {
  378. maxRows = 3;
  379. }
  380.  
  381. var table = document.getElementById('table'),rIndex;
  382. var picture;
  383.  
  384.  
  385. //CLICKABLE TABLE
  386. for (var i = 0; i < table.rows.length; i++){
  387. if(i!=0){
  388. table.rows[i].onclick = function()
  389. {
  390. this.name = document.getElementById("title").value = this.cells[1].innerHTML;
  391. this.role = document.getElementById("author").value = this.cells[2].innerHTML;
  392. this.email = document.getElementById("date").value =
  393. this.cells[3].innerHTML;
  394. this.password = document.getElementById("content").value =
  395. this.cells[4].innerHTML;
  396. var picture = this.cells[7].innerHTML;
  397.  
  398. this.student = document.getElementById("articlepic").src = picture;
  399.  
  400.  
  401.  
  402. if(typeof rIndex !== "undefined"){
  403. table.rows[rIndex].classList.toggle("highlight");
  404. }
  405. rIndex = this.rowIndex;
  406. this.classList.toggle("highlight");
  407. //shorter form of code above, without textbox dependency. Just gets the values from the cells
  408. /* this.name = this.cells[0].innerHTML;
  409. this.age = this.cells[1].innerHTML;
  410. this.country = this.cells[2].innerHTML;
  411. alert(this.name + ", " + this.age + ", " + this.country);
  412. */
  413. }
  414. }
  415.  
  416. }
  417.  
  418. function logout(){
  419. window.location.href='Logout.php';
  420. }
  421. </script>
  422.  
  423. </BODY>
  424.  
  425. </HTML>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement