Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class forums {
- function index() {
- global $client;
- section_content("<table id='forum_table'>");
- $fetch1 = mysql_query("SELECT * FROM `forum_category`");
- while ($category = mysql_fetch_array($fetch1))
- {
- section_content ("<tr>
- <td id='mains'><b>$category[name]<b><br></td><td id='mains'>Último mensaje</td><td id='mains'><center>Temas</center></td>
- </tr>
- ");
- $fetch2 = mysql_query("SELECT * FROM `forum_topic` WHERE `cat_id` = '$category[id]'");
- while ($topic = mysql_fetch_array($fetch2))
- {
- section_content("<tr>
- <td id='fields'><a href='index.php?p=forums/forum&id=$topic[id]'><b>$topic[name]</b></a><br><i>$topic[description]</i></td>");
- $fetchthreads = mysql_query("SELECT * FROM `forum_thread` WHERE `thr_id` = '".$topic['id']."' ORDER BY `latestreply` DESC LIMIT 1");
- $threadinfo = mysql_fetch_array($fetchthreads);
- $getnumthreads = mysql_query("SELECT * FROM `forum_thread` WHERE `thr_id` = '".$topic['id']."'");
- $numthreads = mysql_num_rows($getnumthreads);
- $getlatestposter = mysql_query("SELECT * FROM `forum_posts` WHERE `thr_id` = '".$threadinfo['id']."' ORDER BY time desc");
- $latestposter = mysql_fetch_array($getlatestposter);
- $getnumposts = mysql_query("SELECT * FROM `forum_posts` WHERE `thr_id` = '".$threadinfo['id']."'");
- $numposts = mysql_num_rows($getnumposts);
- if($numthreads > '0'){
- section_content("<td id='fields'><a href='index.php?p=forums/forumdisplay&id=".$threadinfo['id']."'>".$threadinfo['title']."</a><br>by ");
- if(mysql_num_rows($getlatestposter) == 0){
- section_content("".$threadinfo['poster']."");
- }else{
- section_content("".$latestposter['poster']."");
- }
- section_content("<font size=\"1\">(".time_elapsed_string($threadinfo['latestreply']).")</td>");
- }else{
- section_content("<td id='fields'>--</td>");
- }
- section_content("<td id='fields'><center>".$numthreads."</center></td>");
- section_content("</tr>
- ");
- }
- }
- section_content ("</table>");
- $rows = mysql_num_rows($fetch1);
- if ($rows == 0)
- {
- sys_notice("Forum is Empty");
- }
- }
- function forum() {
- global $client;
- section_content ("<table id='forum_table'>");
- $fetch1 = mysql_query("SELECT * FROM `forum_topic` WHERE `id` = '$_GET[id]'");
- $topic = mysql_fetch_array($fetch1);
- set_title(''.$topic['name'].'');
- section_content ("<tr><td id='mains'><b>$topic[name]</b> - <a href='index.php?p=forums/newthread&id=$_GET[id]'>Nuevo Tema</a></td><td id='mains'>Creado</td><td id='mains'>Última respuesta</td><td id='mains'>Vistas</td><td id='mains'>Respuestas</td></tr>");
- $fetch2 = mysql_query("SELECT * FROM `forum_thread` WHERE `thr_id` = '$_GET[id]' AND `sticky` = 'Yes'");
- while($thread = mysql_fetch_array($fetch2)){
- $fetchreplies = mysql_query("SELECT * FROM `forum_posts` WHERE `thr_id` = '$thread[id]'");
- $numreplies = mysql_num_rows($fetchreplies);
- $latestreply = mysql_query("SELECT * FROM `forum_posts` WHERE `thr_id` = '$thread[id]' order by time desc limit 1");
- $getreply = mysql_fetch_assoc($latestreply);
- $threadtitle = $thread['title'];
- $bbctt1 = forum_bb($threadtitle);
- section_content ("<tr><td id='fields'><a href='index.php?p=forums/forumdisplay&id=$thread[id]'><b>Sticky: $bbctt1</b></a><br><i>by ".$thread['poster']."</i></td><td id='fields'><font size=\"1\">".date('D jS M Y', $thread['time'])."<br>".time_elapsed_string($thread['time'])."</font></td>");
- if($getreply){
- section_content("<td id='fields'><font size=\"1\">".time_elapsed_string($getreply['time'])."<br>by ".$getreply['poster']."</font></td><td id='fields'>".$thread['views']."</td><td id='fields'>$numreplies</td></tr>");
- }else{
- section_content("<td id='fields'>--</td><td id='fields'>".$thread['views']."</td><td id='fields'>$numreplies</td></tr>");
- }
- }
- $nonsticky = mysql_query("SELECT * FROM `forum_thread` WHERE `thr_id` = '$_GET[id]' AND `sticky` = 'No' ORDER BY `latestreply` DESC");
- while($thread2 = mysql_fetch_assoc($nonsticky)){
- $fetchreplies = mysql_query("SELECT * FROM `forum_posts` WHERE `thr_id` = '$thread2[id]'");
- $numreplies = mysql_num_rows($fetchreplies);
- $latestreply = mysql_query("SELECT * FROM `forum_posts` WHERE `thr_id` = '$thread2[id]' order by time desc limit 1");
- $getreply = mysql_fetch_array($latestreply);
- $threadtitle = $thread2['title'];
- $bbctt1 = forum_bb($threadtitle);
- section_content ("<tr><td id='fields'><a href='index.php?p=forums/forumdisplay&id=$thread2[id]'><b>$bbctt1</b></a><br><i>by ".$thread2['poster']."</i></td><td id='fields'><font size=\"1\">".date('D jS M Y', $thread2['time'])."<br>".time_elapsed_string($thread2['time'])."</font></td>");
- if($getreply){
- section_content("<td id='fields'><font size=\"1\">".time_elapsed_string($getreply['time'])."<br>by ".$getreply['poster']."</font></td><td id='fields'>".$thread2['views']."</td><td id='fields'>$numreplies</td></tr>");
- }else{
- section_content("<td id='fields'>--</td><td id='fields'>".$thread2['views']."</td><td id='fields'>$numreplies</td></tr>");
- }
- }
- section_content ("</table>");
- }
- function forumdisplay() {
- global $client;
- section_content("<script src=\"modules/forums/ioquatix-jquery-syntax-36a1d65/examples/jquery-1.4.4.min.js\" type=\"text/javascript\"></script>
- <script src=\"modules/forums/ioquatix-jquery-syntax-36a1d65/public/jquery.syntax.min.js\" type=\"text/javascript\"></script>
- <script type=\"text/javascript\">
- // This function is executed when the page has finished loading.
- jQuery(function($) {
- // This function highlights (by default) pre and code tags which are annotated correctly.
- $.syntax();
- replace: true
- });
- </script>
- ");
- section_content ("<table id='forum_table'>");
- $fetch1 = mysql_query("SELECT * FROM `forum_thread` WHERE `id` = '$_GET[id]'");
- $thread = mysql_fetch_array($fetch1);
- $updateviews = mysql_query("UPDATE `forum_thread` SET `views` = views+1 WHERE `id` = '$_GET[id]'");
- $fetch3 = mysql_query("SELECT * FROM `".tb()."accounts` WHERE `username` = '$thread[poster]'");
- $threadavatar = mysql_fetch_array($fetch3);
- set_title(''.$thread['title'].'');
- $threadtitle = "$thread[title]";
- $bbctt2 = forum_bb($threadtitle);
- $threadmessage = "$thread[message]";
- $bbctm = forum_bb(nl2br(htmlentities($threadmessage)));
- section_content ("<tr>
- ");
- if($thread['sticky'] == Yes)
- {
- section_content ("<td id='mains' colspan=\"2\"><b>Sticky:</b> $bbctt2 <font size=\"1\" style=\"float:right;\">".date('D jS M Y', $thread['time'])." (".time_elapsed_string($thread['time']).")</font></td></tr>");
- }
- else
- {
- section_content ("<td id='mains' colspan=\"2\"><b>$bbctt2</b> <font size=\"1\" style=\"float:right;\">".date('D jS M Y', $thread['time'])." (".time_elapsed_string($thread['time']).")</font></td></tr>");
- }
- section_content ("<tr>
- <td id='fields' align='center' width='120' valign='top'>".$thread['poster']."<br>
- ".avatar($threadavatar,50)."
- ");
- if (allow_access(3))
- {
- if($thread['locked'] == Yes){
- section_content("<br><a href='index.php?p=forums/unlock&id=$thread[id]'>Unlock</a>");
- }else{
- section_content("<br><a href='index.php?p=forums/lock&id=$thread[id]'>Lock</a>");
- }
- section_content (" - <a href='index.php?p=forums/editthread&id=$thread[id]'>Edit</a> - <a href='index.php?p=forums/sticky&id=$thread[id]'>Sticky</a>");
- }
- if ($thread['poster'] == $client['username'])
- {
- section_content ("<br><a href='index.php?p=forums/editthread&id=$thread[id]'>Edit Post</a>");
- }
- section_content ("
- </td><td id='fields' align='left' valign='top'>$bbctm</td></tr>");
- $fetch2 = mysql_query("SELECT * FROM `forum_posts` WHERE `thr_id` = '".$_GET['id']."'");
- while ($posts = mysql_fetch_array($fetch2))
- {
- $postsmessage = $posts['message'];
- $bbcpm = forum_bb(nl2br(htmlentities($postsmessage)));
- $fetch4 = mysql_query("SELECT * FROM `".tb()."accounts` WHERE `username` = '".$posts['poster']."'");
- $postsavatar = mysql_fetch_array($fetch4);
- section_content ("<tr><td id='replymains' colspan='2'><font size=\"1\" style=\"float:right;\">".date('D jS M Y', $posts['time'])." (".time_elapsed_string($posts['time']).")</font></td></tr>
- <tr>
- <td id='fields' align='center' valign='top'>$posts[poster]
- <br>
- ".avatar($postsavatar,50)."
- ");
- if (allow_access(3))
- {
- section_content ("<br><a href='index.php?p=forums/delete&id=$posts[id]'>Delete</a> - <a href='index.php?p=forums/editpost&id=$posts[id]'>Edit</a>");
- }
- if ($client['username'] == $posts['poster'])
- {
- section_content ("<br><a href='index.php?p=forums/editpost&id=$posts[id]'>Edit Post</a>");
- }
- section_content ("
- </td>
- <td id='fields' align='left' valign='top'>$bbcpm</td>
- </tr>");
- }
- if ($thread['locked'] == 'Yes')
- {
- section_content ("<tr><td id='fields'> </td><td id='fields' valign='top'><b>This Thread is locked.</b></td></tr>");
- }
- else
- {
- section_content ("
- <tr>
- <td id='fields'valign='top'><center><font size=\"2\">BBcode list</font></center>
- <font size=\"1\">
- <ul>
- <li>[code]</li>
- <li>[php]</li>
- <li>[js]</li>
- <li>[quote]</li>
- <li>[b]</li>
- <li>[i]</li>
- <li>[u]</li>
- <li>[url]</li>
- <li>[img]</li>
- </ul></font></td>
- <form method='POST' action='index.php?p=forums/addreply'>
- <td id='fields'>Quick Reply<br /><textarea id='forumtxtarea' name='message' rows='8' cols='30'></textarea><br>
- <input type='submit' name='submit' value='Post'>
- <input type='hidden' name='id' value='".$_GET['id']."'></td>
- </tr>
- </form>
- ");
- }
- }
- function addreply(){
- global $client;
- $id = mysql_real_escape_string($_POST['id']);
- $message = mysql_real_escape_string($_POST['message']);
- $insert = mysql_query("INSERT INTO `forum_posts` (`message`, `poster`, `thr_id`, `time`) VALUES ('$message', '$client[username]', '$id', '".time()."')");
- $update = mysql_query("UPDATE `forum_thread` SET `latestreply` = '".time()."' WHERE `id` = '$id'");
- sys_notice ("Thanks for your reply. You will be re-directed back to the thread. <meta http-equiv='refresh' content='2;url=index.php?p=forums/forumdisplay&id=$id'>");
- }
- function newthread(){
- global $client;
- section_content ("<form method='POST' action='index.php?p=forums/addthread'>
- <table width='100%'>
- <tr>
- <td>Titulo</td>
- <td><input type='text' name='title'></td>
- </tr>
- <tr>
- <td>Mensaje</td>
- <td><textarea id=\"forumtxtarea\" name='message' rows='10' cols='40'></textarea></td>
- </tr>
- <tr>
- <td></td>
- <td><input type='submit' name='submit' value='Post'>
- <input type='hidden' name='id' value='$_GET[id]'></td>
- </tr>
- </table>
- </form>
- ");
- }
- function addthread(){
- global $client;
- $id = mysql_real_escape_string($_POST['id']);
- $query = mysql_query("SELECT * FROM `forum_thread` WHERE `id` = '$id'");
- $array = mysql_fetch_array($query);
- if ($array['locked'] == 'Yes')
- {
- sys_notice ("You can't post that in here.");
- }
- else
- {
- $title = mysql_real_escape_string($_POST['title']);
- $message = mysql_real_escape_string($_POST['message']);
- $insert = mysql_query("INSERT INTO `forum_thread` (`title`, `message`, `poster`, `thr_id`, `time`, `latestreply`)VALUES ('$title', '$message', '$client[username]', '$id', '".time()."', '".time()."')");
- $query2 = mysql_query("SELECT * FROM `forum_thread` WHERE `thr_id` = '$id' ORDER BY time DESC");
- $getinfo = mysql_fetch_array($query2);
- sys_notice ("Your thread has been added. You will be re-directed back to the forum! <meta http-equiv='refresh' content='2;url=index.php?p=forums/forum&id=$id'>");
- stream_publish( t('posted a new thread in forum<br><br>{1}<br><font size="1">'.substr(mysql_real_escape_string($message),0,200).'...</font>',url('forums/forumdisplay&id='.$getinfo['id'].'',t('<b>'.$getinfo['title'].'</b>'))));
- }
- }
- function editthread(){
- global $client;
- $fetch = mysql_query("SELECT * FROM `forum_thread` WHERE `id` = '$_GET[id]'");
- $thread = mysql_fetch_array($fetch);
- if ($client['username'] == $thread['poster'] || allow_access(3))
- {
- section_content ("
- <form method='POST' action='index.php?p=forums/updatethread'>
- <table width='100%'>
- <tr>
- <td>Title</td>
- <td><input type='text' name='title' value='$thread[title]'></td>
- </tr>
- <tr>
- <td>Message</td>
- <td><textarea id='forumtxtarea' name='message' rows='10' cols='40'>$thread[message]</textarea></td>
- </tr>
- <tr>
- <td></td>
- <td><input type='submit' name='submit' value='Post'>
- <input type='hidden' name='id' value='$_GET[id]'></td>
- </tr>
- </table>
- </form>
- ");
- }
- else
- {
- sys_notice ("You can't edit this thread.");
- }
- }
- function updatethread(){
- global $client;
- $id = mysql_real_escape_string($_POST['id']);
- $query = mysql_query("SELECT * FROM `forum_thread` WHERE `id` = '$id'");
- $array = mysql_fetch_array($query);
- if ($array['poster'] == $client['username'] || allow_access(3))
- {
- $title = mysql_real_escape_string($_POST['title']);
- $message = mysql_real_escape_string($_POST['message']);
- $query = mysql_query("UPDATE `forum_thread` SET `title` = '$title', `message` = '$message' WHERE `id` = '$id'");
- sys_notice ("Thread has been updated. Re-directing you back to thread! <meta http-equiv='refresh' content='2;url=index.php?p=forums/forumdisplay&id=$id'>");
- }
- else
- {
- sys_notice ("You can't edit this thread.");
- }
- }
- function editpost(){
- global $client;
- $fetch = mysql_query("SELECT * FROM `forum_posts` WHERE `id` = '$_GET[id]'");
- $post = mysql_fetch_array($fetch);
- if ($client['username'] == $post['poster'] || allow_access(3))
- {
- section_content ("
- <form method='POST' action='index.php?p=forums/updatepost'>
- <table width='100%'>
- <tr>
- <td>Message</td>
- <td><textarea id='forumtxtarea' name='message' rows='10' cols='40'>$post[message]</textarea></td>
- </tr>
- <tr>
- <td></td>
- <td><input type='submit' name='submit' value='Post'>
- <input type='hidden' name='id' value='$_GET[id]'>
- <input type='hidden' name='thr_id' value='$post[thr_id]'>
- </td>
- </tr>
- </table>
- </form>
- ");
- }
- else
- {
- sys_notice ("You can't edit this post.");
- }
- }
- function updatepost(){
- global $client;
- $id = mysql_real_escape_string($_POST['id']);
- $thrid = mysql_real_escape_string($_POST['thr_id']);
- $query = mysql_query("SELECT * FROM `forum_thread` WHERE `id` = '$id'");
- $array = mysql_fetch_array($query);
- if ($array['poster'] == $client['username'] || allow_access(3))
- {
- $message = mysql_real_escape_string($_POST['message']);
- $update = mysql_query("UPDATE `forum_posts` SET `message` = '$message' WHERE `id` = '$id'");
- sys_notice ("Thread updated. You will now be re-directed back to thread! <meta http-equiv='refresh' content='2;url=index.php?p=forums/forumdisplay&id=$thrid'>");
- }
- else
- {
- sys_notice ("You can't edit this thread.");
- }
- }
- function sticky(){
- global $client;
- $id = (int) mysql_real_escape_string($_GET['id']);
- $fetch = mysql_query("SELECT * FROM `forum_thread` WHERE `id` = '$id'");
- $thread = mysql_fetch_array($fetch);
- if ($thread['sticky'] == 'Yes')
- {
- sys_notice ("This has already been sticked. <meta http-equiv='refresh' content='2;url=index.php?p=forums/forumdisplay&id=$id'>");
- }
- else
- {
- $update = mysql_query("UPDATE `forum_thread` SET `sticky` = 'Yes' WHERE `id` = '$id'");
- sys_notice ("Thread has been stickied. Re-directing you now!<meta http-equiv='refresh' content='2;url=index.php?p=forums/forumdisplay&id=$id'>");
- }
- }
- function lock(){
- global $client;
- $id = (int) mysql_real_escape_string($_GET['id']);
- $fetch = mysql_query("SELECT * FROM `forum_thread` WHERE `id` = '$id'");
- $thread = mysql_fetch_array($fetch);
- if ($thread['locked'] == 'Yes')
- {
- sys_notice ("This has already been locked. <meta http-equiv='refresh' content='2;url=index.php?p=forums/forumdisplay&id=$id'>");
- }
- else
- {
- $update = mysql_query("UPDATE `forum_thread` SET `locked` = 'Yes' WHERE `id` = '$id'");
- sys_notice ("Thread has been locked. Re-directing you now! <meta http-equiv='refresh' content='2;url=index.php?p=forums/forumdisplay&id=$id'>");
- }
- }
- function unlock(){
- global $client;
- $id = (int) mysql_real_escape_string($_GET['id']);
- $fetch = mysql_query("SELECT * FROM `forum_thread` WHERE `id` = '$id'");
- $thread = mysql_fetch_array($fetch);
- if ($thread['locked'] == 'No')
- {
- sys_notice ("This has already been unlocked. <meta http-equiv='refresh' content='2;url=index.php?p=forums/forumdisplay&id=$id'>");
- }
- else
- {
- $update = mysql_query("UPDATE `forum_thread` SET `locked` = 'No' WHERE `id` = '$id'");
- sys_notice ("Thread has been unlocked. Re-directing you now! <meta http-equiv='refresh' content='2;url=index.php?p=forums/forumdisplay&id=$id'>");
- }
- }
- function delete(){
- global $client;
- $id = (int) mysql_real_escape_string($_GET['id']);
- $fetch = mysql_query("DELETE FROM `forum_posts` WHERE `id` = '$id'");
- section_content ("Post has been deleted.<br><a href='javascript: history.go(-1)'>Go back.</a>");
- }
- function admin(){
- global $client;
- section_content ("
- <a href='index.php?p=forums/addcategory'>Add Category</a>
- <br>
- <a href='index.php?p=forums/deletecategory'>Delete Category</a>
- <br>
- <a href='index.php?p=forums/addtopic'>Add Topic</a>
- <br>
- <a href='index.php?p=forums/deletetopic'>Delete Topic</a>
- ");
- }
- function addcategory(){
- global $client;
- section_content ("
- <form method='POST' action='index.php?p=forums/insertcategory'>
- <table width='100%'>
- <tr>
- <td align='right' width='25%'>New Category Name</td>
- <td align='left'>
- <input size='25' name='category'></td>
- </tr>
- <tr>
- <td align='center'></td>
- <td align='left'>
- <input type='submit' name='submit' value='Update'></td>
- </tr>
- </table>
- </form>
- ");
- }
- function insertcategory(){
- global $client;
- $category = strip_tags(mysql_real_escape_string($_POST['category']));
- $insert = mysql_query("INSERT INTO `forum_category` (`name`) VALUES ('$category')");
- section_content ("New Category Created. Redirecting...<meta http-equiv='refresh' content='2;url=index.php?p=forums/admin'>");
- }
- function deletecategory(){
- global $client;
- section_content ("
- <form method='POST' action='index.php?p=forums/removecategory'>
- <table width='100%'>
- <tr>
- <td align='right' width='25%'>Delete Category</td>
- <td align='left'>
- <select name='category'>
- ");
- $fetch = mysql_query("SELECT * FROM `forum_category`"); //fetches all the forum categories from the database and displays them
- while ($category = mysql_fetch_array($fetch))
- {
- section_content ("<option value='$category[name]'>$category[name]</option>");
- }
- section_content ("
- </select>
- </td>
- </tr>
- <tr>
- <td align='center'></td>
- <td align='left'>
- <input type='submit' name='submit' value='Update'></td>
- </tr>
- </table>
- </form>
- ");
- }
- function removecategory(){
- global $client;
- $category = strip_tags(mysql_real_escape_string($_POST['category']));
- $insert = mysql_query("DELETE FROM `forum_category` WHERE name = '$category'");
- section_content ("Category Deleted. Redirecting...<meta http-equiv='refresh' content='2;url=index.php?p=forums/admin'>");
- }
- function addtopic(){
- global $client;
- section_content ("
- <form method='POST' action='index.php?p=forums/inserttopic'>
- <table width='100%'>
- <tr>
- <td align='right' width='25%'>New Topic Name</td>
- <td align='left'>
- <input size='25' name='topic'></td>
- </tr>
- <tr>
- <td align='right' width='25%'>Description</td>
- <td align='left'>
- <input size='25' name='description'></td>
- </tr>
- <tr>
- <td align='right' width='25%'>Under Category</td>
- <td align='left'>
- <select name='cid'>
- ");
- $fetch = mysql_query("SELECT * FROM `forum_category`");
- while ($category = mysql_fetch_array($fetch))
- {
- section_content ("<option value='$category[id]'>$category[name]</option>");
- }
- section_content ("
- </select>
- </td>
- </tr>
- <tr>
- <td align='center'></td>
- <td align='left'>
- <input type='submit' name='submit' value='Update'></td>
- </tr>
- </table>
- </form>
- ");
- }
- function inserttopic(){
- global $client;
- $description = strip_tags(mysql_real_escape_string($_POST['description']));
- $topic = strip_tags(mysql_real_escape_string($_POST['topic']));
- $cid = (int) mysql_real_escape_string($_POST['cid']);
- $insert = mysql_query("INSERT INTO `forum_topic` (`name`, `cat_id`, `description`) VALUES ('$topic', '$cid', '$description')");
- section_content ("New Category Created. Redirecting...<meta http-equiv='refresh' content='2;url=index.php?p=forums/admin'>");
- }
- function deletetopic(){
- global $client;
- section_content ("
- <form method='POST' action='index.php?p=forums/removetopic'>
- <table width='100%'>
- <tr>
- <td align='right' width='25%'>Delete Topic</td>
- <td align='left'>
- <select name='topic'>
- ");
- $fetch = mysql_query("SELECT * FROM `forum_topic`");
- while ($topic = mysql_fetch_array($fetch))
- {
- section_content ("<option value='$topic[name]'>$topic[name]</option>");
- }
- section_content ("
- </select>
- </td>
- </tr>
- <tr>
- <td align='center'></td>
- <td align='left'>
- <input type='submit' name='submit' value='Update'></td>
- </tr>
- </table>
- </form>
- ");
- }
- function removetopic(){
- global $client;
- $topic = mysql_real_escape_string(strip_tags($_POST['topic']));
- $insert = mysql_query("DELETE FROM `forum_topic` WHERE name = '$topic'");
- section_content("Category Deleted. Redirecting...<meta http-equiv='refresh' content='2;url=index.php?p=forums/admin'>");
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment