Guest User

Untitled

a guest
Jan 19th, 2019
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.08 KB | None | 0 0
  1. <htlm>
  2. <head>
  3. </head>
  4. <body>
  5. <?php
  6.    session_start();
  7.    if(!isset($_SESSION["key"]){
  8.         $_SESSION["key"] = -1;
  9.    }else if(isset($_GET["key"]){
  10.         $_SESSION["key"] = $_GET["key"];
  11.    }else{
  12.         $_SESSION["key"] = -1;
  13.    }
  14.  
  15.    // ----- VARIABLES -------
  16.     $address = "jdbc:mysql://127.0.0.1:3306/ikmc"; // Indirizzo del database
  17.     $admin = "admin"; // Username deldatabase
  18.     $password = "admin"; // Password del database
  19.     $q_topicList = "SELECT `topic_id`, `topic_title`, `topic_last_post_id` FROM `avphpbb_topics` ORDER BY `topic_last_post_id` DESC"; // Lista i nomi dei topic
  20.     $q_posts = "SELECT `avphpbb_topics`.`topic_title` AS `title`, `avphpbb_users`.`username` AS `username`, `avphpbb_posts`.`post_text` AS `text`, `avphpbb_posts`.`post_id` AS `post_id` FROM `avphpbb_posts`, `avphpbb_topics`, `avphpbb_users` WHERE `avphpbb_topics`.`topic_id` = ? ORDER BY `avphpbb_posts`.`post_id` DESC"; // Lista i post di un topic
  21.    // ------------------------
  22.  
  23.    // ----- FUNCTIONS ------
  24.     function getPosts($topicID){
  25.         $query = mysql_query($q_topicList, $conn);
  26.             if ($query==false) die("get posts query sucks");
  27.         printPosts($query);
  28.     }
  29.  
  30.     function printPosts($q){
  31.         echo '<h3>' . $row['title'] . '</h3>';
  32.         while($row=mysql_fetch_array($q)){
  33.             echo $row['username'] . ":" . " ";
  34.             echo $row['text'];
  35.             echo '<br/>';
  36.         }
  37.         echo '<p><a href="spyforum.php?key=-1">[TOPIC LIST]</a></p>'
  38.     }
  39.  
  40.     function getTopicList(){
  41.         $query = mysql_query($q_topicList)
  42.             if ($query==false) die("get topic list query sucks");
  43.         printTopicList($query);
  44.     }
  45.  
  46.     function printTopicList($q){
  47.         while($row=mysql_fetch_array($q)){
  48.             echo "<p><a href='spyforum.php?key=" . $row['topic_id'] . "'>";
  49.             echo $row['topic_title'];
  50.             echo "</a></p>";
  51.         }
  52.     }
  53.     // ------------------------
  54.  
  55.     $conn = mysql_connect("$address","$admin","password")or die("connection failed: " . mysql_error());
  56.     mysql_select_db($database, $conn) or die("database connection failed");
  57.  
  58.     if($_SESSION["key"] = -1){
  59.         getTopicList();
  60.     }else{
  61.         $key = $_SESSION["key"];
  62.         getPosts($key);
  63.     }  
  64. ?>
  65. </body>
  66. </html>
Add Comment
Please, Sign In to add comment