[PHP] Cloud 9 Entertainment
Print Your Pass
Recent Photos
Its Your Birthday
Home Events Gallery Register Party Planner C9 Services Store Contact Us
More.. More..
\n"; // div that goes around the calendar grid and the eventlist/key print "
\n"; print "\n"; print "
\n"; print "

Venue Events

"; // 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("

%A

", $row["receivedepoch"]) . "
"; print "• {$date} Event: {$row[title]} Type: {$row[event_type]} price: {$row[price]}
\n"; } print <<
  • M - Mainstream
  • E - Elite/Exclusive
  • CG - College
  • P - Selective
  • L - Lounge
  • D - Nightclub
KEY; print ""; // div around event list and key print ""; // 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 "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
Date"; print ""; print "/"; print ""; print "/"; print "
Title
Venue
Price
Type
Flier"; if (!empty($flier)) { print "
"; } print ""; print "
Location
Description
"; } // 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:
" . mysql_error() . "
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:
"; 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 ""; print ""; while ($row = mysql_fetch_assoc($res)) { $recv = $row["received"]; $title = $row["title"]; $id = $row["id"]; print ""; } print "
DateTitleActions
{$recv}{$title}edit, delete
"; } } // 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 "
"; print ""; print "
"; print "
"; print "Title: " . $row["title"] . "

"; print "Date: " . strftime("%Y-%m-%d", $row["receivedepoch"]) . "

"; print "Price: " . $row["price"] . "

"; print "Location:
" . $row["location"] . "

"; print "Description:
" . $row["description"] . "


"; print ""; print "
"; print "
"; } 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 "\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'], '')); /* display the data */ echo ""; echo "\n"; echo "\n"; if ($_SESSION["user_level"] == 3) { print ""; print ""; print ""; } /* finish up table*/ echo "
$title
"; echo "$date
$news
"; print "edit"; print " "; print "delete"; print "
\n"; echo "
\n"; } /* if we aren't displaying all news, * then give a link to do so */ if ($all == 0) { echo "
View all news\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 "\n"; /* easier to read variables and * striping out tags */ $title = htmlentities ($row['title']); $news = nl2br (strip_tags ($row['newstext'], '')); /* display the items */ echo "\n"; echo "\n"; echo "
$title
$news
\n"; echo "
\n"; } /* this is where the script decides what do do */ $action = isset($_GET["action"]) ? $_GET["action"] : ""; echo "
\n"; switch ($action) { case 'show': displayOneItem($_GET['id']); break; case 'all': displayNews(1); break; case 'addcomment': addComment($_GET['id']); break; default: displayNews(); break; } echo "
\n"; ?>
[/PHP]