Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <htlm>
- <head>
- </head>
- <body>
- <?php
- session_start();
- if(!isset($_SESSION["key"]){
- $_SESSION["key"] = -1;
- }else if(isset($_GET["key"]){
- $_SESSION["key"] = $_GET["key"];
- }else{
- $_SESSION["key"] = -1;
- }
- // ----- VARIABLES -------
- $address = "jdbc:mysql://127.0.0.1:3306/ikmc"; // Indirizzo del database
- $admin = "admin"; // Username deldatabase
- $password = "admin"; // Password del database
- $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
- $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
- // ------------------------
- // ----- FUNCTIONS ------
- function getPosts($topicID){
- $query = mysql_query($q_topicList, $conn);
- if ($query==false) die("get posts query sucks");
- printPosts($query);
- }
- function printPosts($q){
- echo '<h3>' . $row['title'] . '</h3>';
- while($row=mysql_fetch_array($q)){
- echo $row['username'] . ":" . " ";
- echo $row['text'];
- echo '<br/>';
- }
- echo '<p><a href="spyforum.php?key=-1">[TOPIC LIST]</a></p>'
- }
- function getTopicList(){
- $query = mysql_query($q_topicList)
- if ($query==false) die("get topic list query sucks");
- printTopicList($query);
- }
- function printTopicList($q){
- while($row=mysql_fetch_array($q)){
- echo "<p><a href='spyforum.php?key=" . $row['topic_id'] . "'>";
- echo $row['topic_title'];
- echo "</a></p>";
- }
- }
- // ------------------------
- $conn = mysql_connect("$address","$admin","password")or die("connection failed: " . mysql_error());
- mysql_select_db($database, $conn) or die("database connection failed");
- if($_SESSION["key"] = -1){
- getTopicList();
- }else{
- $key = $_SESSION["key"];
- getPosts($key);
- }
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment