Advertisement
Guest User

Untitled

a guest
Sep 18th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.72 KB | None | 0 0
  1. THIS IS THE AUTHENTICATION SCRIPT
  2.  
  3. <?php
  4. session_start(); // Start a new session
  5.  
  6.  
  7. // Get the data passed from the form
  8. $username = $_POST['user'];
  9. $password = $_POST['pass'];
  10.  
  11. // Do some basic sanitizing
  12. $username = stripslashes($username);
  13. $password = stripslashes($password);
  14.  
  15. $sql = "select * from user where username = '$username' and password = '$password'";
  16. $result = mysql_query($sql) or die ( mysql_error() );
  17.  
  18. $count = 0;
  19.  
  20. while ($line = mysql_fetch_assoc($result)) {
  21. $count++;
  22. }
  23.  
  24. if ($count == 1) {
  25. $_SESSION['loggedIn'] = "true";
  26. header("Location: ../admin.php"); // This is wherever you want to redirect the user to
  27. } else {
  28. $_SESSION['loggedIn'] = "false";
  29. header("Location: ../index.php"); // Wherever you want the user to go when they fail the login
  30. }
  31.  
  32. ?>
  33.  
  34. THE ADMIN AREA
  35. <?php
  36. session_start();
  37. if ($_SESSION['loggedIn'] != "true") {
  38. header("Location: admin.php");
  39. }
  40.  
  41. <!DOCTYPE html>
  42. <html lang="en">
  43. <head>
  44. <title>Japanese Proverbs</title>
  45. <meta charset="utf-8">
  46. <link rel="stylesheet" type="text/css" href="style.css" />
  47. <script language="javascript" src="js/jquery.js"></script>
  48. <script language="javascript" src="js/tweet.js" type="text/javascript"></script>
  49. <script type="text/javascript" src="js/vote.js"></script>
  50. <script type="text/javascript" src="js/contact.js"></script>
  51. <script language="javascript">
  52. $(function() {
  53. $("document").ready(function() {
  54. $(".tweet").tweet({
  55. username: "japaneseprov3rb",
  56. avatar_size: 32,
  57. count: 3,
  58. loading_text: "loading tweets..."
  59. });
  60. })
  61. //handles the showing and hiding submit div
  62. $(".showsubmission").click(function() {
  63. $("#submit_proverb").toggle('slow');
  64. })
  65. $("#submitbutton").click(function() {
  66. $("#submit_proverb").hide('fast');
  67. $('#submit_success').show('fast');
  68. setTimeout(function () {$('#submit_success').hide('slow');
  69. }, 60000);
  70. })
  71. //voting
  72. $('.up_click').click( function() { $.post('include/vote.php', { id: $(this).parent().data('post'), vote: 'up' }) });
  73.  
  74.  
  75.  
  76.  
  77. })
  78. </script>
  79.  
  80. </head>
  81. <body>
  82. <div class="top_status"><div id="submit_success">Proverb has been submitted</div></div>
  83. <div id="wrapper">
  84. <div id="header">
  85. <?php include("include/header.php"); ?>
  86. <div id="menu">
  87. <?php include("include/menu.php"); ?>
  88. </div>
  89. </div>
  90. <div id="content">
  91. <div id="submit_proverb">
  92. <p>Submit a proverb. All proverbs will be reviewed and approved by a moderator.</p>
  93. <form method="post" action="include/insert.php">
  94. <label for="proverb"></label>
  95. <input name="proverb" type="text" id="proverb2" size="60">
  96. <input type="submit" value="Submit" id="submitbutton">
  97. </form>
  98. </div>
  99.  
  100. <table width="600" border="1" align="center">
  101. <tr>
  102. <th width="80" scope="col">Proverb ID</th>
  103. <th width="326" scope="col">Submission</th>
  104. <th width="74" scope="col">Approve</th>
  105. </tr>
  106.  
  107. <?php
  108.  
  109. // Grabbing all of the unapproved proverbs
  110. $result = mysql_query("SELECT * FROM proverb WHERE statusid=0 ORDER BY rating DESC LIMIT 10") or die (mysql_error());
  111.  
  112. while($row = mysql_fetch_array($result)) {
  113. $id =$row['ProverbID'];
  114. $rating = $row['Rating'];
  115. echo "<tr><td>" . $id . "</td>";
  116. //If malicious input somehow passes input validation, htmlspecialchars function is used to strip output
  117. echo "<td>" . $row['Message'] . "</td>";
  118. echo "<td><a href=\"include/do_approve.php?id=$id\" name=\"id\">Approve</a></td></tr>";
  119. }
  120.  
  121.  
  122. ?>
  123.  
  124. </table>
  125.  
  126. <p><a href="include/logout.php">Logout</a>
  127.  
  128.  
  129. </div>
  130. <div id="footer">
  131. <?php include("include/footer.php"); ?>
  132. </div>
  133.  
  134. <?php include("include/contact.php"); ?>
  135.  
  136. </div>
  137. </body>
  138. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement