Advertisement
Guest User

Untitled

a guest
Jul 10th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.37 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. include("config.php");
  5.  
  6. switch ($_GET['content']) {
  7. case 'logout' : include 'logout.php'; break;
  8. case 'create.thread' : include 'create.thread.php'; break;
  9. }
  10.  
  11. if (isset($_POST['checkData'])) {
  12. $username = mysql_real_escape_string($_POST['username']);
  13. $password = mysql_real_escape_string(md5($_POST['password']));
  14. $query = mysql_query("SELECT * FROM `users` WHERE `username` = '$username' AND `password` = '$password'");
  15. if (mysql_num_rows($query) == 1) {
  16. $_SESSION['id'] = mysql_result($query, 0, 'id');
  17. $_SESSION['username'] = $_POST['username'];
  18. header("location: ?");
  19. } else {
  20. echo "<script>alert(\"Fel användarnamn eller lösenord\");</script>";
  21. }
  22. }
  23. ?>
  24.  
  25. <html>
  26. <head>
  27. <link rel="shortcut icon" type="image/icon" href="images/favicon.png">
  28. <title>Minecraftportalen</title>
  29. <link rel="stylesheet" type="text/css" href="stylesheet.css">
  30. </head>
  31. <body>
  32. <form method="POST">
  33. <!-- Fungerar inte i Internet Explorer... -->
  34. <div style="width:300px; margin:auto;">
  35. <!-- Logotyp -->
  36. <div id="logo">
  37. </div>
  38. </div>
  39. <!-- Fungerar inte i Internet Explorer... -->
  40. <div style="width:800px; margin:auto;">
  41. <div id="background">
  42. <table width="380">
  43. <?php
  44. if (!isset($_SESSION['username'])) {
  45.    echo "<tr><td><input name=\"username\" type=\"text\"></td><td><input name=\"password\" type=\"password\"></td><td><input name=\"checkData\" type=\"submit\" value=\"Logga in\"></td></tr>";
  46.    } else {
  47.    echo "<a href=\"?userID={$_SESSION['id']}\">{$_SESSION['username']}</a> (<a href=\"?content=logout\">Logga ut</a>)</br>";
  48. }
  49. ?>
  50. </table>
  51. </div>
  52. </br>
  53. <div id="background">
  54. <?php
  55.  
  56. if (isset($_GET['userID'])) {
  57.  
  58.     $id     = intval($_GET['userID']);
  59.     $query  = "SELECT * FROM `users` WHERE `id` = '$id' LIMIT 1";
  60.     $result = mysql_query($query);
  61.     if (mysql_num_rows($result) == 1) {
  62.    
  63.         while ($row     = mysql_fetch_assoc($result)) {
  64.        
  65.             $username = htmlspecialchars($row['username']);
  66.             $email    = htmlspecialchars($row['email']);
  67.             echo "<strong>{$username}</strong></br>";
  68.             echo "{$email}</br>";
  69.  
  70.         }
  71.  
  72.     } else {
  73.  
  74.         echo "Användaren hittades inte!</br>";
  75.  
  76.     }
  77.  
  78. } elseif (isset($_GET['categoryID'])) {
  79.  
  80.             $id     = intval($_GET['categoryID']);
  81.             $query  = "SELECT * FROM `categories` WHERE `id` = '$id' LIMIT 1";
  82.             $result = mysql_query($query);
  83.            
  84.             if (mysql_num_rows($result) == 1) {
  85.            
  86.                 $query      = "SELECT * FROM `threads` WHERE `category` = '1'";
  87.                 $result     = mysql_query($query);
  88.                 while ($row = mysql_fetch_assoc($result)) {
  89.                
  90.                     $id         = htmlspecialchars($row['id']);
  91.                     $name       = htmlspecialchars($row['name']);
  92.                     $writer     = htmlspecialchars($row['writer']);
  93.                     echo "<a href=\"?threadID={$id}\"><strong>{$name}</strong></a></br>";
  94.                     echo "Redaktör: {$writer}</br>";
  95.  
  96.                }
  97.  
  98.             } else {
  99.  
  100.                echo "Kategorin hittades inte!</br>";
  101.  
  102.             }
  103.  
  104. } elseif (isset($_GET['threadID'])) {
  105.  
  106.     $id     = intval($_GET['threadID']);
  107.     $query  = "SELECT * FROM `threads` WHERE `id` = '$id' LIMIT 1";
  108.     $result = mysql_query($query);
  109.                  
  110.     if (mysql_num_rows($result) == 1) {
  111.                  
  112.         while ($row = mysql_fetch_assoc($result)) {
  113.                      
  114.             name = htmlspecialchars($row['name']);
  115.             $text = htmlspecialchars($row['text']);
  116.             echo "#0 <strong>{$name}</strong></br>";
  117.             echo "</br>";
  118.             echo "{$text}</br>";
  119.             echo "</br>";
  120.             echo "</br>";
  121.             $query  = "SELECT * FROM `comments` WHERE `thread` = '1'";
  122.             $result = mysql_query($query);
  123.             if (mysql_num_rows($result) == 1) {
  124.            
  125.                 while ($row   = mysql_fetch_assoc($result)) {
  126.                
  127.                     $id     = htmlspecialchars($row['id']);
  128.                     $writer = htmlspecialchars($row['writer']);
  129.                     $text   = htmlspecialchars($row['text']);
  130.                     echo "#{$id} <strong>{$writer}</strong></br>";
  131.                     echo "{$text}</br>";
  132.                     echo "</br>";
  133.                    
  134.                 }
  135.                
  136.             } else {
  137.            
  138.                 echo "Tråden hittades inte!</br>";
  139.            
  140.             }
  141.                
  142.         }
  143.            
  144.     }
  145. } else {
  146.  
  147.     $query       = "SELECT * FROM `categories` ORDER BY `id` DESC";
  148.     $result      = mysql_query($query);
  149.     while ($row  = mysql_fetch_assoc($result)) {
  150.                    
  151.         $id          = $row['id'];
  152.         $name        = $row['name'];
  153.         $description = $row['description'];
  154.         echo "<a href=\"?categoryID={$id}\"><strong>{$name}</strong></a></br>";
  155.         echo "{$description}</br>";
  156.    
  157.     }
  158.    
  159. }
  160.  
  161. ?>
  162. </div>
  163. </div>
  164. </form>
  165. </body>
  166. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement