File: /home/awaldron/public_html/archive/demo/thread_add.php
<?php
session_start();
include("_functions.php");
echo dbconnect();
if (isset($_GET["q"])) {
$quote = quickSQL("SELECT thread_body FROM tbl_threads WHERE thread_id=".$_GET["q"]);
$username = quickSQL("SELECT username FROM tbl_threads WHERE thread_id=".$_GET["q"]);
$headline = "RE: ".quickSQL("SELECT thread_headline FROM tbl_threads WHERE thread_id=".$_GET["q"]);
$name = get_user($username,"fullname");
$quote = "[quote=".$name."]".$quote."[/quote]";
}
$sql = "SELECT tbl_notices.*, tbl_notice_types.*, tbl_icons.icon_file, tbl_employees.fname, tbl_employees.lname FROM tbl_notices, tbl_notice_types, tbl_icons, tbl_employees WHERE tbl_notices.notice_id=".$_GET["nid"]." AND tbl_notices.notice_type_id=tbl_notice_types.notice_type_id AND tbl_notices.icon_id=tbl_icons.icon_id AND tbl_employees.username=tbl_notices.username";
$result = mysql_query($sql);
$n = mysql_fetch_array($result);
$page_title = "Add a comment : ".$n["notice_headline"];
if (isset($_GET["sf"])) {
$GLOBALS["breadcrumb"] = "<a href=\"/content.php?p=1\">Intranet Home</a> > <a href=\"/content.php?p=209\">Social</a> > <a href=\"/forums.php\">Discussion Forums</a> > <a href=\"/noticeboard.php?ntid=".$n["notice_type_id"]."&sf=1\">".$n["notice_type_name"]."</a> > <a href=\"/notice.php?nid=".$n["notice_id"]."&sf=1\">".(strlen($n["notice_headline"])>37?substr($n["notice_headline"],0,37)."...":$n["notice_headline"])."</a> > Add a Comment";
$_GET["p"] = 5;
} else $_GET["p"] = $n["parent_id"]; // SET FAUX PARENT ID
$lnav_mods = get_layout($_GET["p"],1);
$rnav_mods = get_layout($_GET["p"],3);
if (isset($_POST["post"])) { // IF POST IS BEING SUBMITTED
$date = date_caltounix($_POST["thread_date"]);
$sql = "INSERT INTO tbl_threads (notice_id, username, thread_date, thread_headline, thread_body, thread_updated) ";
$sql .= "VALUES (".$_POST["notice_id"].",'".$_POST["username"]."','".$date."','".$_POST["thread_headline"]."','".$_POST["message"]."',".time().")";
//echo $sql;
$result = mysql_query($sql);
$sql = "UPDATE tbl_notices SET latest_thread=".time()." WHERE notice_id=".$_POST["notice_id"];
$result = mysql_query($sql);
header("Location: /notice.php?nid=".$_POST["notice_id"].(isset($_GET["sf"])?"&sf=1":""));
}
if (!isset($_POST["post"])) $bbjava = true;
include("_pagestart.php");
if (!isset($_POST["post"]) && !isset($_POST["preview"])) echo "<body onload=\"disableBody()\"></body>\n";
echo "<P><div class=\"headline\">Add a Comment : ".$n["notice_headline"]."</div>\n";
if (!isset($_POST["post"])) {
$preview = FALSE;
if (isset($_POST["preview"])) { // IF POST IS BEING PREVIEWED
$preview = TRUE;
echo "<br><center><div style=\"width:95%;text-align:left;\"><span style=\"font-size:14px\"><b>Preview of Your Post:</b></span><br>\n";
echo "<div style=\"background:#EEEEEE;width:100%;text-align:left;border:solid 2px #999999;padding:10px;\">\n";
if ($_POST["thread_headline"] != "0") echo "<P><span style=\"font-size:12px\"><b>".$_POST["thread_headline"]."</b></span>\n";
if ($_POST["message"] != "0") echo "<P>".format_body($_POST["message"])."\n";
echo "</div><P><div id=\"stamp\"> </div>\n";
echo "</div></center>\n";
}
echo "<center>\n";
if (!$preview) echo "<br><br><b>Use this page to create a new comment to<br>'".$n["notice_headline"]."'</b>\n";
if ((!$preview) && (!isset($_GET["q"]))) $headline = "RE: ".quickSQL("SELECT notice_headline FROM tbl_notices WHERE notice_id=".$_GET["nid"]);
echo "<form action=\"thread_add.php?nid=".$_GET["nid"].(isset($_GET["sf"])?"&sf=1":"")."\" method=\"post\" name=\"post\" onSubmit=\"MM_validateForm('username','','R');return document.MM_returnValue\">\n";
echo "<input type=\"hidden\" name=\"notice_id\" value=\"".(isset($_POST["notice_id"])?$_POST["notice_id"]:$_GET["nid"])."\">\n";
echo "<input type=\"hidden\" name=\"username\" value=\"".$_SESSION["auth_user"]."\">\n";
echo "<P><table border=\"0\" cellpadding=\"3\" cellspacing=\"1\">\n";
echo "<tr><td><b>Username</b></td><td><input type=\"text\" name=\"dummy_username\" size=\"45\" maxlength=\"32\" style=\"width:150px\" value=\"".$_SESSION["auth_user"]."\" DISABLED></td></tr>\n";
echo "<tr><td><b>Date</b></td><td><input type=\"text\" name=\"thread_date\" style=\"width:80px\" value=\"".(isset($_POST["thread_date"])?$_POST["thread_date"]:date("m/d/Y"))."\" onMouseOver=\"helpline('nd')\"> (mm/dd/yyyy)</td></tr>\n";
echo "<tr><td><b>Headline</b></td><td><input type=\"text\" name=\"thread_headline\" size=\"45\" maxlength=\"255\" style=\"width:550px\" value=\"".(isset($headline)?$headline:stripslashes($_POST["thread_headline"]))."\" onMouseOver=\"helpline('hl')\" /></td></tr>\n";
echo "<tr><td colspan=3> </td></tr>\n";
echo "<tr><td valign=\"top\" colspan=3><b>Message Body</b> : <a href=\"#\" onClick=\"openWindow('/button_buddy.php','','resizable=yes,width=650,height=425')\">Need help? Click Here to Open the Button Buddy</a></td></tr>\n";
echo "<tr><td colspan=3 class=\"row2\" valign=\"top\" bgcolor=\"#EBEFF5\" style=\"border:solid 1px #999999;\">\n";
echo ins_textarea((!$preview?$quote:stripslashes($_POST["message"])));
// Preview & Submit Buttons
echo "<P><center><input type=\"submit\" name=\"preview\" value=\" Preview \"> <input type=\"submit\" name=\"post\" value=\" Submit \" /></center>\n";
echo "</td></tr></table>\n";
echo "</form>\n";
echo "</center>\n";
}
boxfoot();
include("_pageend.php");
?>