File: /home/awaldron/www/archive/demo/notice_add.php
<?php
session_start();
$stickypower = array("awaldron","mbennett","apoorman","rbyford");
include("_functions.php");
echo dbconnect();
$sql = "SELECT * FROM tbl_notice_types WHERE notice_type_id=".(isset($_POST["notice_type_id"])?$_POST["notice_type_id"]:$_GET["ntid"]);
$result = mysql_query($sql);
$n = mysql_fetch_array($result);
$page_title = "Add New Topic : ".$n["notice_type_name"];
$GLOBALS["ntid"] = $n["notice_type_id"];
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> > Add New Topic";
$_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["notice_date"]);
$sql = "INSERT INTO tbl_notices (notice_type_id, icon_id, username, notice_date, notice_headline, notice_subhead, notice_linkto, notice_body, notice_updated, notice_sticky, latest_thread) ";
$sql .= "VALUES (".$_POST["notice_type_id"].",".$_POST["icon_id"].",'".$_POST["username"]."','".$date."','".strip_tags($_POST["notice_headline"])."','".$_POST["notice_subhead"]."','".$_POST["notice_linkto"]."','".$_POST["message"]."',".time().",".$_POST["notice_sticky"].",".time().")";
//echo $sql;
$result = mysql_query($sql);
$sql2 = "SELECT MAX(notice_id) AS nid FROM tbl_notices WHERE 1";
$result2 = mysql_query($sql2);
$n = mysql_fetch_array($result2);
header("Location: /notice.php?nid=".$n["nid"]);
}
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\">".$page_title."</div>\n";
if (!isset($_POST["post"])) {
$preview = FALSE;
if (isset($_POST["preview"])) { // IF POST IS BEING PREVIEWED
$preview = TRUE;
$sql = "SELECT * FROM tbl_icons WHERE icon_id=".$_POST["icon_id"];
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$preview_date = date_caltounix($_POST["notice_date"]);
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";
echo "<div id=\"stamp\"><img src=\"".$row["icon_file"]."\"> ".date("l, F j, Y h:i a",$preview_date)."</div>\n";
if ($_POST["notice_headline"] != "0") echo "<P><span class=\"headline\">".stripslashes(strip_tags($_POST["notice_headline"]))."</span>\n";
if ($_POST["notice_subhead"] != "0") echo "<P><span class=\"subhead\">".stripslashes($_POST["notice_subhead"])."</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 post on the ".$n["notice_type_name"]."</b>\n";
echo "<form action=\"notice_add.php?ntid=".$_GET["ntid"].(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_type_id\" value=\"".(isset($_POST["notice_type_id"])?$_POST["notice_type_id"]:$n["notice_type_id"])."\">\n";
echo "<P><table border=\"0\" cellpadding=\"3\" cellspacing=\"1\">\n";
if (is_admin()) {
echo "<tr><td><b>Username</b></td><td><input type=\"text\" name=\"username\" style=\"width:140px\" value=\"".$_SESSION["auth_user"]."\"></td></tr>\n";
} else {
echo "<input type=\"hidden\" name=\"username\" value=\"".$_SESSION["auth_user"]."\">\n";
echo "<tr><td><b>Username</b></td><td><input type=\"text\" name=\"dummy_username\" style=\"width:140px\" value=\"".$_SESSION["auth_user"]."\" DISABLED></td></tr>\n";
}
echo "<tr><td><b>Notice Date</b></td><td><input type=\"text\" name=\"notice_date\" style=\"width:80px\" value=\"".(isset($_POST["notice_date"])?$_POST["notice_date"]:date("m/d/Y"))."\" onMouseOver=\"helpline('nd')\"> (mm/dd/yyyy)</td></tr>\n";
if (in_array($_SESSION["auth_user"],$stickypower)) echo "<tr><td><b>Make Sticky?</b></td><td><SELECT name=\"notice_sticky\" onMouseOver=\"helpline('st')\"><option value=\"0\"".($_POST["notice_sticky"]==0?" SELECTED":"").">No</option><option value=\"1\"".($_POST["notice_sticky"]==1?" SELECTED":"").">Yes</option></SELECT></td></tr>\n";
else echo "<input type=\"hidden\" name=\"notice_sticky\" value=\"0\">\n";
echo "<tr><td><b>Icon</b></td><td>\n";
$sql = "SELECT * FROM tbl_icons WHERE 1 ORDER BY icon_id";
$result = mysql_query($sql);
for ($i=0; $i < mysql_num_rows($result); $i++) {
$icon = mysql_fetch_array($result);
if (!$preview) echo "<input type=radio name=\"icon_id\" value=\"".$icon["icon_id"]."\" onMouseOver=\"helpline('ic')\"".($icon["icon_id"]==11?" CHECKED":"")."><img src=\"".$icon["icon_file"]."\" alt=\"".$icon["icon_name"]."\"> ";
else echo "<input type=radio name=\"icon_id\" value=\"".$icon["icon_id"]."\" onMouseOver=\"helpline('ic')\"".($_POST["icon_id"]==$icon["icon_id"]?" CHECKED":"")."><img src=\"".$icon["icon_file"]."\" alt=\"".$icon["icon_name"]."\"> ";
}
echo "</td></tr>\n";
echo "<tr><td><b>Headline</b></td><td><input type=\"text\" name=\"notice_headline\" size=\"45\" maxlength=\"255\" style=\"width:550px\" value=\"".stripslashes($_POST["notice_headline"])."\" onMouseOver=\"helpline('hl')\" /></td></tr>\n";
echo "<tr><td><b>Sub-Head</b></td><td><input type=\"text\" name=\"notice_subhead\" id=\"subheadbox\" size=\"45\" maxlength=\"255\" style=\"width:550px\" value=\"".stripslashes($_POST["notice_subhead"])."\" onMouseOver=\"helpline('sh')\" /></td></tr>\n";
echo "<tr><td><b>Link To URL</b></td><td><input type=\"text\" name=\"notice_linkto\" onChange=\"disableBody()\" size=\"45\" maxlength=\"255\" style=\"width:550px\" value=\"http://\" onMouseOver=\"helpline('lt')\" /></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?"":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";
}
include("_pageend.php");
?>