Want more features on Pastebin? Sign Up, it's FREE!
Guest

section.php

By: a guest on Oct 4th, 2012  |  syntax: None  |  size: 4.46 KB  |  views: 28  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. /* Web Intersect Social Network Template System and CMS v1.34
  3.  * Copyright (c) 2011 Adam Khoury
  4.  * Licensed under the GNU General Public License version 3.0 (GPLv3)
  5.  * http://www.webintersect.com/license.php
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License as published by
  9.  * the Free Software Foundation, either version 3 of the License, or
  10.  * (at your option) any later version.
  11.  
  12.  * This program is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
  15.  * See the GNU General Public License for more details.
  16.  
  17.  * You should have received a copy of the GNU General Public License
  18.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  19.  *
  20.  * Date: February 9, 2010
  21.  *------------------------------------------------------------------------------------------------*/
  22. session_start();
  23. include_once ("../wi_class_files/agoTimeFormat.php");
  24. $myAgoObject = new convertToAgo;
  25. include_once "../scripts/connect_to_mysql.php"; // Connect to the database
  26. // Get the section ID from the url variable coming in
  27. if (isset($_GET['id']) && $_GET['id'] != "") {
  28.         $sid = preg_replace('#[^0-9]#i', '', $_GET['id']); // filter all characters except numbers for security
  29. } else {
  30.         echo "ERROR: Variables to run this script have been removed from the URL.";
  31.         exit();
  32. }
  33. // Query the database for that section id, make sure it exists and get the section title
  34. $sql = mysql_query("SELECT * FROM forum_sections WHERE id='$sid' LIMIT 1");
  35. $numRows = mysql_num_rows($sql);
  36. if ($numRows < 1) {
  37.         echo "ERROR: That section deos not exist you have tampered with our URLs.";
  38.         exit();
  39. }
  40. while($row = mysql_fetch_array($sql)){
  41.         $sectionTitle = $row["title"];
  42. }
  43. // Use the section ID to query the "forum_posts" table in the database to get all the threads for this section
  44. $sql = mysql_query("SELECT * FROM forum_posts WHERE type='a' AND section_id='$sid' ORDER BY date_time DESC LIMIT 25");
  45. $dynamicList = "";
  46. $numRows = mysql_num_rows($sql)or die(mysql_error());
  47. if ($numRows < 1) {
  48.         $dynamicList = "There are no threads in this section yet. You can be the first to post.";
  49. } else {
  50.         while($row = mysql_fetch_array($sql)){
  51.             $thread_id = $row["id"];
  52.                 $post_author = $row["post_author"];
  53.                 $post_author_id = $row["post_author_id"];
  54.                 $date_time = $row["date_time"];
  55.                 $convertedTime = ($myAgoObject -> convert_datetime($date_time));
  56.         $whenPost = ($myAgoObject -> makeAgo($convertedTime));
  57.                 $thread_title = $row["thread_title"];
  58.                 $dynamicList .= '<img src="style/threadPic.jpg" width="26" height="18" alt="Topic" /> ' . $post_author . ' - <a href="view_thread.php?id=' . $thread_id . '">' . $thread_title . '</a> - ' . $whenPost . '<br />';
  59.     }
  60. }
  61. ?>
  62. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  63. <html xmlns="http://www.w3.org/1999/xhtml">
  64. <head>
  65. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  66. <link href="style/style.css" rel="stylesheet" type="text/css" />
  67. <title><?php echo $sectionTitle; ?> Forum</title>
  68. </head>
  69. <body>
  70. <?php include_once("template_header.php"); ?>
  71. <table style="background-color: #F0F0F0; border:#069 1px solid; border-top:none;" width="900" border="0" align="center" cellpadding="12" cellspacing="0">
  72.   <tr>
  73.     <td width="731" valign="top">
  74.     <div id="breadcrumbs"><a href="http://www.webintersect.com">Web Intersect Home</a> &larr; <a href="http://www.webintersect.com/forum">Forum Home</a></div>
  75.     <h1 style="margin-left:12px;"><?php echo $sectionTitle; ?> Forum</h1>
  76.       <form action="new_topic.php" method="post">
  77.       <input name="forum_id" type="hidden" value="<?php echo $sid; ?>" />
  78.       <input name="forum_title" type="hidden" value="<?php echo $sectionTitle; ?>" />
  79.       <input name="myBtn1" type="submit" value="Create New Topic" style="font-size:16px; padding:12px;" />
  80.      </form>
  81.       <br /><br />
  82.       <div style="margin-left:12px; font-size:14px; line-height:1.5em;"><?php echo $dynamicList; ?></div>
  83.     <br /><br /><br /></td>
  84.     <td width="189" valign="top"><div style=" width:160px; height:600px; background-color: #999; color: #CCC; padding:12px;"> <br />
  85.       <br />
  86.       <br />
  87.       <h3>Ad Space or Whatever</h3>
  88.     </div></td>
  89.   </tr>
  90. </table>
  91. <?php include_once("template_footer.php"); ?>
  92. </body>
  93. </html>
clone this paste RAW Paste Data