rendered paste body
[PHP]<?php
require_once("cloud9ny.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><head>
<!-- TinyMCE -->
<script language="javascript" type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "advanced",
plugins : "style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,flash,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable",
theme_advanced_buttons1_add : "fontselect,fontsizeselect",
theme_advanced_buttons2_add : "separator,insertdate,inserttime,preview,separator,forecolor,backcolor",
theme_advanced_buttons2_add_before: "cut,copy,paste,pastetext,pasteword,separator,search,replace,separator",
theme_advanced_buttons3_add_before : "tablecontrols,separator",
theme_advanced_buttons3_add : "emotions,iespell,flash,advhr,separator,fullscreen",
theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_path_location : "bottom",
content_css : "example_full.css",
plugin_insertdate_dateFormat : "%Y-%m-%d",
plugin_insertdate_timeFormat : "%H:%M:%S",
extended_valid_elements : "hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
external_link_list_url : "example_link_list.js",
file_browser_callback : "fileBrowserCallBack",
theme_advanced_resize_horizontal : false,
theme_advanced_resizing : false
});
</script>
<!-- /TinyMCE -->
<style type="text/css">
td img {display: block;}body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #FFFFFF;
}
body {
background-color: #000000;
}
a:link {
color: #999999;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #CCCCCC;
}
a:hover {
text-decoration: underline;
color: #000000;
}
a:active {
text-decoration: none;
color: #CCCCCC;
}
.style1 {color: #000000}
</style>
<title>Cloud 9 Entertainment</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="cloud 9 entertainment venue service parties partys gallery nine club fun">
<meta name="description" content="Cloud 9 Entertainment - Club & Venue Service">
</head>
<body>
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><img src="images/spacer.gif" width="35" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="3" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="100" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="111" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="45" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="11" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="3" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="18" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="23" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="68" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="6" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="36" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="38" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="60" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="4" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="9" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="3" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="97" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="101" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="25" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="60" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="3" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="3" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="35" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="1" border="0" alt="" /></td>
</tr>
<tr>
<td rowspan="8"><img name="rd_c9_01" src="images/rd_c9_01.jpg" width="35" height="509" border="0" id="rd_c9_01" alt="" /></td>
<td colspan="25"><img name="rd_c9_02" src="images/rd_c9_02.jpg" width="830" height="9" border="0" id="rd_c9_02" alt="" /></td>
<td rowspan="8"><img name="rd_c9_03" src="images/rd_c9_03.jpg" width="35" height="509" border="0" id="rd_c9_03" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="9" border="0" alt="" /></td>
</tr>
<tr>
<td colspan="25" background="images/rd_c9_04.jpg"><div align="center" class="style1">
<?php include('sub/c9_header.php'); ?></div></td>
<td><img src="images/spacer.gif" width="1" height="20" border="0" alt="" /></td>
</tr>
<tr>
<td colspan="25"><img name="rd_c9_05" src="images/rd_c9_05.jpg" width="830" height="3" border="0" id="rd_c9_05" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="3" border="0" alt="" /></td>
</tr>
<tr>
<td rowspan="3" colspan="10"><img name="rd_c9_06" src="images/rd_c9_06.jpg" width="383" height="435" border="0" id="rd_c9_06" alt="" /></td>
<td rowspan="4"><img name="rd_c9_07" src="images/rd_c9_07.jpg" width="6" height="438" border="0" id="rd_c9_07" alt="" /></td>
<td colspan="14"><a href="events.php"><img name="rd_c9_08" src="images/rd_c9_08.jpg" width="441" height="146" border="0" id="rd_c9_08" alt="Print Your Pass" /></a></td>
<td><img src="images/spacer.gif" width="1" height="146" border="0" alt="" /></td>
</tr>
<tr>
<td colspan="14"><a href="gallery.php"><img name="rd_c9_09" src="images/rd_c9_09.jpg" width="441" height="146" border="0" id="rd_c9_09" alt="Recent Photos" /></a></td>
<td><img src="images/spacer.gif" width="1" height="146" border="0" alt="" /></td>
</tr>
<tr>
<td rowspan="2" colspan="14"><a href="partyplanner.php"><img name="rd_c9_10" src="images/rd_c9_10.jpg" width="441" height="146" border="0" id="rd_c9_10" alt="Its Your Birthday" /></a></td>
<td><img src="images/spacer.gif" width="1" height="143" border="0" alt="" /></td>
</tr>
<tr>
<td colspan="10"><img name="rd_c9_11" src="images/rd_c9_11.jpg" width="383" height="3" border="0" id="rd_c9_11" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="3" border="0" alt="" /></td>
</tr>
<tr>
<td colspan="3"><a href="index.php"><img name="rd_c9_12" src="images/rd_c9_12.jpg" width="104" height="39" border="0" id="rd_c9_12" alt="Home" /></a></td>
<td><a href="events.php"><img name="rd_c9_13" src="images/rd_c9_13.jpg" width="111" height="39" border="0" id="rd_c9_13" alt="Events" /></a></td>
<td colspan="5"><a href="gallery.php"><img name="rd_c9_14" src="images/rd_c9_14.jpg" width="100" height="39" border="0" id="rd_c9_14" alt="Gallery" /></a></td>
<td colspan="3"><a href="users.php?act=register"><img name="rd_c9_15" src="images/rd_c9_15.jpg" width="110" height="39" border="0" id="rd_c9_15" alt="Register" /></a></td>
<td colspan="4"><a href="partyplanner.php"><img name="rd_c9_16" src="images/rd_c9_16.jpg" width="111" height="39" border="0" id="rd_c9_16" alt="Party Planner" /></a></td>
<td colspan="2"><a href="services.php"><img name="rd_c9_17" src="images/rd_c9_17.jpg" width="100" height="39" border="0" id="rd_c9_17" alt="C9 Services" /></a></td>
<td><a href="store.php"><img name="rd_c9_18" src="images/rd_c9_18.jpg" width="101" height="39" border="0" id="rd_c9_18" alt="Store" /></a></td>
<td colspan="6"><a href="contact.php"><img name="rd_c9_19" src="images/rd_c9_19.jpg" width="93" height="39" border="0" id="rd_c9_19" alt="Contact Us" /></a></td>
<td><img src="images/spacer.gif" width="1" height="39" border="0" alt="" /></td>
</tr>
<tr>
<td colspan="27"><img name="rd_c9_20" src="images/rd_c9_20.jpg" width="900" height="3" border="0" id="rd_c9_20" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="3" border="0" alt="" /></td>
</tr>
<tr>
<td colspan="27"><img name="rd_c9_21" src="images/rd_c9_21.jpg" width="900" height="21" border="0" id="rd_c9_21" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="21" border="0" alt="" /></td>
</tr>
<tr>
<td colspan="27"><img name="rd_c9_22" src="images/rd_c9_22.jpg" width="900" height="2" border="0" id="rd_c9_22" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="2" border="0" alt="" /></td>
</tr>
<tr>
<td rowspan="4" colspan="3"><img name="rd_c9_23" src="images/rd_c9_23.jpg" width="39" height="131" border="0" id="rd_c9_23" alt="" /></td>
<td colspan="3" rowspan="3" background="images/rd_c9_24.jpg"><div align="center"> <?php include('sub/c9_login.php'); ?> </div></td>
<td rowspan="4"><img name="rd_c9_25" src="images/rd_c9_25.jpg" width="11" height="131" border="0" id="rd_c9_25" alt="" /></td>
<td colspan="9" background="images/rd_c9_26.jpg"><div align="center">
<?php include('sub/c9_events.php'); ?>
</div></td>
<td rowspan="4" colspan="2"><img name="rd_c9_27" src="images/rd_c9_27.jpg" width="12" height="131" border="0" id="rd_c9_27" alt="" /></td>
<td colspan="5" background="images/rd_c9_28.jpg"><div align="center">
<?php include('sub/c9_thumbs.php'); ?>
</div></td>
<td rowspan="4" colspan="4"><img name="rd_c9_29" src="images/rd_c9_29.jpg" width="40" height="131" border="0" id="rd_c9_29" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="100" border="0" alt="" /></td>
</tr>
<tr>
<td rowspan="3" colspan="7"><img name="rd_c9_30" src="images/rd_c9_30.jpg" width="192" height="31" border="0" id="rd_c9_30" alt="" /></td>
<td><a href="events.php"><img name="rd_c9_31" src="images/rd_c9_31.jpg" width="60" height="22" border="0" id="rd_c9_31" alt="More.." /></a></td>
<td rowspan="3"><img name="rd_c9_32" src="images/rd_c9_32.jpg" width="4" height="31" border="0" id="rd_c9_32" alt="" /></td>
<td rowspan="3" colspan="3"><img name="rd_c9_33" src="images/rd_c9_33.jpg" width="223" height="31" border="0" id="rd_c9_33" alt="" /></td>
<td><a href="gallery.php"><img name="rd_c9_34" src="images/rd_c9_34.jpg" width="60" height="22" border="0" id="rd_c9_34" alt="More.." /></a></td>
<td rowspan="3"><img name="rd_c9_35" src="images/rd_c9_35.jpg" width="3" height="31" border="0" id="rd_c9_35" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="22" border="0" alt="" /></td>
</tr>
<tr>
<td rowspan="2"><img name="rd_c9_36" src="images/rd_c9_36.jpg" width="60" height="9" border="0" id="rd_c9_36" alt="" /></td>
<td rowspan="2"><img name="rd_c9_37" src="images/rd_c9_37.jpg" width="60" height="9" border="0" id="rd_c9_37" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="2" border="0" alt="" /></td>
</tr>
<tr>
<td colspan="3"><img name="rd_c9_38" src="images/rd_c9_38.jpg" width="256" height="7" border="0" id="rd_c9_38" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="7" border="0" alt="" /></td>
</tr>
<tr>
<td colspan="27"><img name="rd_c9_39" src="images/rd_c9_39.jpg" width="900" height="39" border="0" id="rd_c9_39" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="39" border="0" alt="" /></td>
</tr>
<tr>
<td colspan="27" background="images/rd_c9_40.jpg">
<table width="830" align=center border="0" >
<tr>
<td width="824" align=center valign="top">
<div align=center>
<?php
class events
{
function showgrid()
{
$date = getdate();
$month_num = $date["mon"];
$month_name = $date["month"];
$year = $date["year"];
$date_today = getdate(mktime(0,0,0,$month_num,1,$year));
$first_week_day = $date_today["wday"];
$cont = true;
$today = 27;
while (($today <= 32) && ($cont))
{
$date_today = getdate(mktime(0,0,0,$month_num,$today,$year));
if ($date_today["mon"] != $month_num)
{
$lastday = $today - 1;
$cont = false;
}
$today++;
}
print "<div class='events'>\n"; // div that goes around the calendar grid and the eventlist/key
print "<div class='calendargrid'>\n";
print "<table width='500' border='0' cellspacing=0 cellpadding=2>\n";
print "<div class='eventlist'>\n";
print "<h1>Venue Events</h1>";
// show events for the current week similar in format/layout to
// http://www.velvetlist.com/
//
// thanks to rhk3 and pmc for the assistance with this part of the project.
//
$dow = intval(strftime("%u"));
if ($dow == 1) // monday
{
$monday = strtotime("today");
}
else
{
$monday = strtotime("last monday");
}
$startdate = strftime("%Y-%m-%d %H:%M", $monday);
$sunday = strtotime("+6 days", $monday);
$enddate = strftime("%Y-%m-%d %H:%M", $sunday);
$sql = "select *, unix_timestamp(received) as receivedepoch from calendar where received between '{$startdate}' and '{$enddate}' order by received";
$res = mysql_query($sql);
while ($row = mysql_fetch_assoc($res))
{
$date = strftime("%m/%d", $row["receivedepoch"]);
$d = intval(strftime("%u", $row["received"]));
$currentday = $row["received"];
print strftime("<h2>%A</h2>", $row["receivedepoch"]) . "<br />";
print "• {$date} <font color='#FF00FF'>Event: </font><a href='events.php?mode=view&id={$row[id]}'>{$row[title]}</a> <font color='#FF00FF'>Type:</font> {$row[event_type]} <font color='#FF00FF'>price: </font>{$row[price]}<br />\n";
}
print <<<KEY
<div>
<ul>
<li> M - Mainstream</li>
<li> E - Elite/Exclusive</li>
<li> CG - College</li>
<li> P - Selective</li>
<li> L - Lounge</li>
<li> D - Nightclub</li>
</ul>
</div>
KEY;
print "</div>"; // div around event list and key
print "</div>"; // div around calendar and the event-list/key
return;
}
function displayform($mode, $values=null)
{
$id = 0;
$title = "";
$description = "";
$location = "";
$price = 0;
$type = "M";
$received = "today";
$venue = "";
$flier = "";
if (is_array($values))
{
$id = isset($values["id"]) ? intval($values["id"]) : 0;
$title = isset($values["title"]) ? $values["title"] : "";
$description = isset($values["description"]) ? $values["description"] : "";
$location = isset($values["location"]) ? $values["location"] : "";
$price = isset($values["price"]) ? $values["price"] : 0;
$type = isset($values["type"]) ? $values["type"] : "M";
$received = isset($values["received"]) ? $values["received"] : "";
$venue = isset($values["venue"]) ? $values["venue"] : "";
$flier = isset($values["flier"]) ? $values["flier"] : "";
}
$month = intval(strftime("%m", strtotime($received)));
$date = intval(strftime("%d", strtotime($received)));
$year = intval(strftime("%Y", strtotime($received)));
print "<table>";
print "<form method='post' action='events.php' enctype='multipart/form-data'>";
print "<input type='hidden' name='mode' value='{$mode}'>";
print "<input type='hidden' name='id' value='{$id}'>";
print "<td>Date</td>";
print "<td>";
print "<select class='login11' name='month'>";
$months = array();
$months[] = "Month";
$months[] = "Jan";
$months[] = "Feb";
$months[] = "Mar";
$months[] = "Apr";
$months[] = "May";
$months[] = "Jun";
$months[] = "Jul";
$months[] = "Aug";
$months[] = "Sep";
$months[] = "Oct";
$months[] = "Nov";
$months[] = "Dec";
for ($m = 0; $m <= 12; $m++)
{
if ($month == $m)
{
print "<option value='{$m}' selected='yes'>" . $months[$m] . "</option>";
}
else
{
print "<option value='{$m}'>" . $months[$m] . "</option>";
}
}
print "</select>";
print "<b>/</b>";
print "<select class='login11' name='date'>";
for ($d = 0; $d <= 31; $d++)
{
if ($date == $d)
{
print "<option value='{$d}' selected='yes'>{$d}</option>";
}
else
{
print "<option value='{$d}'>{$d}</option>";
}
}
print "</select>";
print "<b>/</b>";
print "<select class='login11' name='year'>";
for ($y = 2008; $y > 2000; $y--)
{
if ($year == $y)
{
print "<option value='{$y}' selected='yes'>{$y}</option>";
}
else
{
print "<option value='{$y}'>{$y}</option>";
}
}
print "</select></td>";
print "</tr>";
print "<tr><td>Title</td><td><input type='text' name='title' value='{$title}'></td></tr>";
print "<tr><td>Venue</td><td><input type='text' name='venue' value='{$venue}'></td></tr>";
print "<tr><td>Price</td><td><input type='text' name='price' value='{$price}'></td></tr>";
print "<tr><td>Type</td><td><select name='type' size='1'>";
$t = array();
$t["M"] = "Mainstream";
$t["E"] = "Exclusive";
$t["CG"] = "College";
$t["P"] = "Selective";
$t["L"] = "Lounge";
$t["D"] = "Nightclub";
foreach ($t as $k => $v)
{
if ($type == $k)
{
print "<option value='{$k}' selected>{$v}</option>";
}
else
{
print "<option value='{$k}'>{$v}</option>";
}
}
print "</select></td></tr>";
print "<tr><td>Flier</td>";
print "<td>";
if (!empty($flier))
{
print "<img src='{$flier}' height='300' width='300'><br> ";
}
print "<input type='file' name='flier'>";
print "</td>";
print "</tr>";
print "<tr><td>Location</td><td><textarea name='location' rows=4 cols=25>{$location}</textarea></td></tr>";
print "<tr><td>Description</td><td><textarea name='description' rows=30 cols=80>{$description}</textarea></td></tr>";
print "<tr><td colspan='2'><input type='submit' name='submit' value='{$mode}'></td></tr>";
print "</form>";
print "</table>";
}
// FIX: add permission check to add()
function add()
{
$this->displayform("insert");
return;
}
// FIX: add permission check
function insert()
{
$userid = intval($_SESSION["userid"]);
$title = $_REQUEST["title"];
$venue = $_REQUEST["venue"];
$price = $_REQUEST["price"];
$type = $_REQUEST["type"];
$location = $_REQUEST["location"];
$desc = $_REQUEST["description"];
$month = intval($_REQUEST["month"]);
$date = intval($_REQUEST["date"]);
$year = intval($_REQUEST["year"]);
$uploadfile = FLIERUPLOADDIR . basename($_FILES["flier"]["name"]);
if (is_uploaded_file($_FILES["flier"]["tmp_name"]))
{
$uploadfile = FLIERUPLOADDIR . basename($_FILES["flier"]["name"]);
if (!is_dir(FLIERUPLOADDIR))
{
mkdir(FLIERUPLOADDIR);
}
if (!move_uploaded_file($_FILES["flier"]["tmp_name"], $uploadfile))
{
print "I'm sorry, there was a problem with the upload of your flier image. Please try again. Thanks!";
return;
}
}
$sql = "insert into calendar(id, userid, title, venue, price, event_type, location, description, received, flier) ";
$sql.= "values (null, '{$userid}', '{$title}', '{$venue}', '{$price}', '{$type}', ' {$location}', '{$desc}', '{$year}-{$month}-{$date}', '{$uploadfile}')";
$res = mysql_query($sql);
if ($res == false)
{
print "There was an error adding an event to the database:<br />" . mysql_error() . "<br />Please notify support.";
return;
}
print "An Event has been added to the database successfully.";
return;
}
function edit()
{
$id = isset($_REQUEST["id"]) ? intval($_REQUEST["id"]) : 0;
$sql = "select * from calendar where id={$id} limit 1";
$res = mysql_query($sql);
$row = mysql_fetch_assoc($res);
$values = array();
$values["id"] = $row["id"];
$values["userid"] = $row["userid"];
$values["title"] = $row["title"];
$values["venue"] = $row["venue"];
$values["price"] = $row["price"];
$values["type"] = $row["event_type"];
$values["received"] = $row["received"];
$values["flier"] = $row["flier"];
$values["location"] = $row["location"];
$values["description"] = $row["description"];
$this->displayform("update", $values);
return;
}
function update()
{
$id = isset($_REQUEST["id"]) ? intval($_REQUEST["id"]) : 0;
$title = isset($_REQUEST["title"]) ? $_REQUEST["title"] : "";
$location = isset($_REQUEST["location"]) ? $_REQUEST["location"] : "";
$desc = isset($_REQUEST["description"]) ? $_REQUEST["description"] : "";
$venue = isset($_REQUEST["venue"]) ? $_REQUEST["venue"] : "";
$price = isset($_REQUEST["price"]) ? $_REQUEST["price"] : 0;
$type = isset($_REQUEST["type"]) ? $_REQUEST["type"] : "";
$month = isset($_REQUEST["month"]) ? intval($_REQUEST["month"]) : 0;
$date = isset($_REQUEST["date"]) ? intval($_REQUEST["date"]) : 0;
$year = isset($_REQUEST["year"]) ? intval($_REQUEST["year"]) : 0;
if (is_uploaded_file($_FILES["flier"]["tmp_name"]))
{
$uploadfile = FLIERUPLOADDIR . basename($_FILES["flier"]["name"]);
if (!is_dir(FLIERUPLOADDIR))
{
mkdir(FLIERUPLOADDIR);
}
if (!move_uploaded_file($_FILES["flier"]["tmp_name"], $uploadfile))
{
print "I'm sorry, there was a problem with the upload of your flier image. Please try again. Thanks!";
return;
}
$sql = "update calendar set flier='{$uploadfile}' where id={$id}";
$res = mysql_query($sql);
}
$sql = "update calendar set location='{$location}', description='{$desc}', title='{$title}', venue='{$venue}', price='{$price}', event_type='{$type}', received='{$year}-{$month}-{$date}' where id={$id}";
$res = mysql_query($sql);
if ($res == false)
{
print "There was an error updating the event record:<br />";
print mysql_error();
return;
}
print "An event was updated successfully";
return;
}
function summary()
{
$sql = "select * from calendar order by received desc";
$res = mysql_query($sql);
if (mysql_num_rows($res) > 0)
{
print "<table>";
print "<tr><th>Date</th><th>Title</th><th>Actions</th></tr>";
while ($row = mysql_fetch_assoc($res))
{
$recv = $row["received"];
$title = $row["title"];
$id = $row["id"];
print "<tr><td>{$recv}</td><td>{$title}</td><td><a href='events.php?mode=edit&id={$id}'>edit</a>, <a href='events.php?mode=delete&id={$id}'>delete</a></td></tr>";
}
print "</table>";
}
}
// FIX: add permission check
function delete()
{
$id = isset($_REQUEST["id"]) ? intval($_REQUEST["id"]) : 0;
$sql = "select id from calendar where id={$id} limit 1";
$res = mysql_query($sql);
if (mysql_num_rows($res) != 1)
{
print "You have supplied an invalid Event ID. Please try again.";
return;
}
$sql = "delete from calendar where id={$id}";
$res = mysql_query($sql);
print "An Event has been deleted successfully";
return;
}
function view()
{
$id = isset($_REQUEST["id"]) ? intval($_REQUEST["id"]) : 0;
$sql = "select *, unix_timestamp(received) as receivedepoch from calendar where id={$id} limit 1";
$res = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($res) != 1)
{
print "You have selected an invalid event.";
return;
}
$row = mysql_fetch_assoc($res) or die(mysql_error());
$path = $row["flier"];
print "<div style='float: top;'>";
print "<img src='{$path}'>";
print "</div>";
print "<div>";
print "<font color='#FF00FF'>Title: </font> " . $row["title"] . "<br><br>";
print "<font color='#FF00FF'>Date: </font> " . strftime("%Y-%m-%d", $row["receivedepoch"]) . "<br><br>";
print "<font color='#FF00FF'>Price:</font> " . $row["price"] . "<br><br>";
print "<font color='#FF00FF'>Location:</font><br>" . $row["location"] . "<BR><BR>";
print "<font color='#FF00FF'>Description:</font><br>" . $row["description"] . "<br><br><br>";
print "<a href='contact.php'><img src='http://cloud9ny.com/Public/logo/guestlbttnwhite.JPG' border='off'></a>";
print "</div>";
print "</div>";
}
function main()
{
$mode = isset($_REQUEST["mode"]) ? $_REQUEST["mode"] : "";
switch ($mode)
{
case "add":
$this->add();
break;
case "insert":
$this->insert();
break;
case "edit":
$this->edit();
break;
case "update":
$this->update();
break;
case "delete":
$this->delete();
break;
case "view":
$this->view();
break;
case "summary":
$this->summary();
break;
case "view":
$this->view();
break;
default:
$this->showgrid();
break;
}
}
}
$e = new events();
$e->main();
/* user config variables */
$max_items = 5; /* max number of news items to show */
function displayNews($all = 0) {
/* bring in two variables
* $db is our database connection
* $max_items is the maximum number
* of news items we want to display */
global $db, $max_items;
$level = isset($_SESSION["user_level"]) ? intval($_SESSION["user_level"]) : 0;
/* query for news items */
if ($all == 0) {
/* this query is for up to $max_items */
$query = "SELECT id,title,newstext," .
"DATE_FORMAT(postdate, '%Y-%m-%d') as date " .
"FROM news ORDER BY postdate DESC LIMIT $max_items";
} else {
/* this query will get all news */
$query = "SELECT id,title,newstext," .
"DATE_FORMAT(postdate, '%Y-%m-%d') as date " .
"FROM news ORDER BY postdate DESC";
}
$result = mysql_query ($query) or die("index.php: " . mysql_error());
while ($row = mysql_fetch_assoc ($result))
{
/* display news in a simple table */
echo "<TABLE border=\"0\" width=\"550\">\n";
/* place table row data in
* easier to use variables.
* Here we also make sure no
* HTML tags, other than the
* ones we want are displayed */
$id = $row['id'];
$date = $row['date'];
$title = htmlentities ($row['title']);
$news = nl2br (strip_tags ($row['newstext'], '<a><b><i><u>'));
/* display the data */
echo "<TR align=left><TD><font size='4'><b>$title</b></font></TD></TR>";
echo "<TR align=left><TD><font size='1'>";
echo "$date </font><BR></TD></TR>\n";
echo "<TR align=left><TD><font size='2'>$news</font></TD></TR>\n";
if ($_SESSION["user_level"] == 3)
{
print "<tr align=left>";
print "<td>";
print "<a href='news.php?mode=edit&id={$id}'>edit</a>";
print " ";
print "<a href='news.php?mode=delete&id={$id}'>delete</a>";
print "</td>";
print "</tr>";
}
/* finish up table*/
echo "</TABLE>\n";
echo "<BR>\n";
}
/* if we aren't displaying all news,
* then give a link to do so */
if ($all == 0) {
echo "<a href=\"{$_SERVER['PHP_SELF']}" .
"?action=all\">View all news</a>\n";
}
}
function displayOneItem($id) {
global $db;
/* query for item */
$query = "SELECT * FROM news WHERE id=$id";
$result = mysql_query ($query);
/* if we get no results back, error out */
if (mysql_num_rows ($result) == 0) {
echo "Bad news id\n";
return;
}
$row = mysql_fetch_assoc($result);
echo "<TABLE align=center border=\"1\" width=\"300\">\n";
/* easier to read variables and
* striping out tags */
$title = htmlentities ($row['title']);
$news = nl2br (strip_tags ($row['newstext'], '<a><b><i><u>'));
/* display the items */
echo "<TR><TD><b>$title</b></TD></TR>\n";
echo "<TR><TD>$news</TD></TR>\n";
echo "</TABLE>\n";
echo "<BR>\n";
}
/* this is where the script decides what do do */
$action = isset($_GET["action"]) ? $_GET["action"] : "";
echo "<CENTER>\n";
switch ($action) {
case 'show':
displayOneItem($_GET['id']);
break;
case 'all':
displayNews(1);
break;
case 'addcomment':
addComment($_GET['id']);
break;
default:
displayNews();
break;
}
echo "</CENTER>\n";
?>
</td>
</tr>
</table>
</div></td>
<td><img src="images/spacer.gif" width="1" height="402" border="0" alt="" /></td>
</tr>
<tr>
<td colspan="27"><img name="rd_c9_41" src="images/rd_c9_41.jpg" width="900" height="1" border="0" id="rd_c9_41" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="1" border="0" alt="" /></td>
</tr>
<tr>
<td colspan="27"><img name="rd_c9_42" src="images/rd_c9_42.jpg" width="900" height="17" border="0" id="rd_c9_42" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="17" border="0" alt="" /></td>
</tr>
<tr>
<td colspan="27"><img name="rd_c9_43" src="images/rd_c9_43.jpg" width="900" height="16" border="0" id="rd_c9_43" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="16" border="0" alt="" /></td>
</tr>
<tr>
<td colspan="9"><img name="rd_c9_44" src="images/rd_c9_44.jpg" width="327" height="1" border="0" id="rd_c9_44" alt="" /></td>
<td colspan="15" rowspan="2" background="images/rd_c9_45.jpg"><div align="center">
<?php include('sub/c9_advertisments.php'); ?>
</div></td>
<td rowspan="3" colspan="3"><img name="rd_c9_46" src="images/rd_c9_46.jpg" width="39" height="118" border="0" id="rd_c9_46" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="1" border="0" alt="" /></td>
</tr>
<tr>
<td rowspan="2" colspan="3"><img name="rd_c9_47" src="images/rd_c9_47.jpg" width="39" height="117" border="0" id="rd_c9_47" alt="" /></td>
<td colspan="5" background="images/rd_c9_48.jpg"><div align="center">
<?php include('sub/c9_media.php'); ?>
</div></td>
<td rowspan="2"><img name="rd_c9_49" src="images/rd_c9_49.jpg" width="18" height="117" border="0" id="rd_c9_49" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="95" border="0" alt="" /></td>
</tr>
<tr>
<td colspan="5"><img name="rd_c9_50" src="images/rd_c9_50.jpg" width="270" height="22" border="0" id="rd_c9_50" alt="" /></td>
<td colspan="15"><img name="rd_c9_51" src="images/rd_c9_51.jpg" width="534" height="22" border="0" id="rd_c9_51" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="22" border="0" alt="" /></td>
</tr>
<tr>
<td rowspan="2" colspan="2"><img name="rd_c9_52" src="images/rd_c9_52.jpg" width="38" height="41" border="0" id="rd_c9_52" alt="" /></td>
<td colspan="23" background="images/rd_c9_53.jpg"><div align="center">
<?php include('sub/footer.html'); ?>
</div></td>
<td rowspan="2" colspan="2"><img name="rd_c9_54" src="images/rd_c9_54.jpg" width="36" height="41" border="0" id="rd_c9_54" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="20" border="0" alt="" /></td>
</tr>
<tr>
<td colspan="23"><img name="rd_c9_55" src="images/rd_c9_55.jpg" width="826" height="21" border="0" id="rd_c9_55" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="21" border="0" alt="" /></td>
</tr>
</table>
</body>
</html>
[/PHP]