function get() { $args_list = func_get_args(); $number_to_get = (int) $args_list[0]; $start_number = (int) $args_list[1]; if ($number_to_get && $start_number) { $query = "select ID from Users order by ID asc limit {$start_number}, {$number_to_get}"; } else { if ($number_to_get) { $query = "select ID from Users order by ID asc limit 0, {$number_to_get}"; } else { if ($start_number) { $query = "select ID from Users order by ID asc limit {$start_number}, 10"; } else { $query = "select ID from Users order by ID asc limit 0, 10"; } } } $q = "select count(ID) as total from Users"; $r = mysql_query($q); if (!$r) { return Error::MySQL(); } $row = mysql_fetch_assoc($r); $this->total = $row['total']; $r = mysql_query($query); if (!$r) { return Error::MySQL(); } $user = array(); while ($row = mysql_fetch_assoc($r)) { $user[] = User::get($row['ID']); } return $user; }
function update($setting, $value) { if (!Config::isValidSetting($setting)) { return Error::create("Unrecognized setting: {$setting}"); } $q = "delete from Config where name = '{$setting}'"; $r = @mysql_query($q); if (!$r) { return Error::MySQL(); } $q = "insert into Config (name, value) values ('{$setting}', '" . db::sanitize_to_db($value) . "')"; $r = @mysql_query($q); if (!$r) { return Error::MySQL(); } return true; }
function populateShowsArray($m, $y) { $db = new db(); $mPadded = sprintf("%02d", $m); $q = "select DATE_FORMAT(date, '%d') as day, ID from Shows where is_active = 1 and DATE_FORMAT(date, '%m') = '{$mPadded}' and DATE_FORMAT(date, '%Y') = '{$y}' order by date asc"; $r = mysql_query($q); if ($db->isError($r)) { return Error::MySQL(); } while ($row = mysql_fetch_assoc($r)) { $this->showsArray[(int) $row['day']][] = Show::get($row['ID']); } }
function update($postArray) { $db = new db(); $e = new Error(); if (User::isAdmin()) { $genreID = $db->sanitize_to_db($postArray['genreID']); if (!$this->isValidGenreID($postArray['genreID'])) { $e->add("Invalid genre specified"); } $name = $db->sanitize_to_db($postArray['name']); if ($name == '' || $name == null) { $e->add("You must specify a name for your band."); } $managerName = $db->sanitize_to_db($postArray['managerName']); $address1 = $db->sanitize_to_db($postArray['address1']); $address2 = $db->sanitize_to_db($postArray['address2']); $city = $db->sanitize_to_db($postArray['city']); $stateProvince = $db->sanitize_to_db($postArray['stateProvince']); if ($stateProvince == "??") { $stateProvince = $db->sanitize_to_db($postArray['stateProvinceOther']); } $postalCode = $db->sanitize_to_db($postArray['postalCode']); $bio = $db->sanitize_to_db($postArray['bio']); $miscellaneous = $db->sanitize_to_db($postArray['miscellaneous']); $country = $db->sanitize_to_db($postArray['country']); $defaultStateProvince = $db->sanitize_to_db($postArray['defaultStateProvince']); if ($defaultStateProvince == "??") { $defaultStateProvince = $db->sanitize_to_db($postArray['defaultStateProvince']); } $defaultCountry = $db->sanitize_to_db($postArray['defaultCountry']); $defaultCity = $db->sanitize_to_db($postArray['defaultCity']); $description = $db->sanitize_to_db($postArray['description']); if ($e->hasErrors()) { return $e; } $q = "delete from Band_Information"; $r = mysql_query($q); if (!$r) { return Error::MySQL(); } $q = "insert into Band_Information (name, managerName, address1, address2, city, stateProvince, postalCode, bio, miscellaneous, country, defaultStateProvince, defaultCountry, defaultCity, genreID, description) "; $q .= "values ('{$name}', '{$managerName}', '{$address1}', '{$address2}', '{$city}', '{$stateProvince}', '{$postalCode}', '{$bio}', '{$miscellaneous}', '{$country}', '{$defaultStateProvince}', '{$defaultCountry}', '{$defaultCity}', '{$genreID}', '{$description}')"; $r = mysql_query($q); // ping auditionrocks.com // aborted attempt at creating an audition directory /* include_class('xmlrpc'); $xc = new xmlrpc_client("/ping/", "www.auditionrocks.com"); $message = new xmlrpcmsg("audition.pingBack", array( new xmlrpcval($_SERVER["HTTP_HOST"] . SITE_WEB_DIRECTORY, "string"), new xmlrpcval($name, "string"), new xmlrpcval($bio, "string"), new xmlrpcval($genreID, "int"), new xmlrpcval($city, "string"), new xmlrpcval($stateProvince, "string"), new xmlrpcval($postalCode, "string"), new xmlrpcval($country, "string")) ); $response = $xc->send($message, 5, "POST"); */ if ($r) { return true; } else { return Error::create("An unexplained error occurred when trying to update your information."); } } }
function remove() { if ($this->canEdit()) { $r = @mysql_query("delete from Band_News where ID = " . $this->ID); if (!$r) { return Error::MySQL(); } } else { return Error::create('You may not remove a post that is not yours.'); } }
function registerMedia($mediaType) { $type = $mediaType == 'av' ? 'av' : 'photos'; if (User::isAdmin()) { if ($type == 'av' && $this->av_area_id < 1 || $type == 'photos' && $this->photo_area_id < 1) { $areaTitle = $type == 'av' ? "Tour Audio/Video: " : "Tour Photos: "; $areaIDField = $type == 'av' ? "av_area_id" : "photo_area_id"; if ($type == 'av') { $allowed_extensions = MEDIA_EXTENSIONS_ALLOWED_AV; $display = "list"; } else { $allowed_extensions = MEDIA_EXTENSIONS_ALLOWED_PHOTO; $display = "grid"; } $ma = MediaArea::add(0, $areaTitle . $this->title, null, $allowed_extensions, $display); if (db::isError($ma)) { return $ma; } $ma->activate(); $q = "update Tours set {$areaIDField} = " . $ma->getID() . " where ID = {$this->ID}"; $r = mysql_query($q); if (!$r) { return Error::MySQL(); } else { return $r; } return $r; } else { return Error::create("A tour with an ID of {$this->ID} is already registered."); } } else { return Error::create('Only an admin user may authorize a tour for media.'); } }
function remove() { if (User::isAdmin()) { $r = @mysql_query("delete from Band_Guest_Performers where ID = " . $this->ID); if (!$r) { return Error::MySQL(); } } else { return Error::create("Only an administrator may remove guest performers."); } }
function moveDown($filterObj = null) { if ($filterObj) { $proceed = $filterObj->validateMediaOperation("MOVEDOWN"); if (db::isError($proceed)) { return $proceed; } } $a = MediaArea::get($this->area_id); if (!db::isError($a)) { $a->updateDisplayOrder(); } $q = "select display_order from DarkRoom_Media_to_Areas where ID = {$this->ID}"; $r = mysql_query($q); if (!$r) { return Error::MySQL(); } $row = mysql_fetch_assoc($r); if ($row['display_order']) { $this->display_order = $row['display_order']; } $newDO = $this->display_order + 1; $r1 = mysql_query("update DarkRoom_Media_to_Areas set display_order = {$this->display_order} where display_order = {$newDO} and area_id = {$this->area_id}"); $r2 = mysql_query("\tupdate DarkRoom_Media_to_Areas set display_order = {$newDO} where ID = {$this->ID}"); if ($r1 && $r2) { return true; } else { $e = new Error(); $e->add(mysql_error()); return $e; } }
function add($postArray) { if (User::isAdmin()) { $db = new db(); $name = $db->sanitize_to_db($postArray['name']); $description = $db->sanitize_to_db($postArray['description']); $url = $db->sanitize_to_db($postArray['url']); $category_id = $postArray['category_id']; if (!$name) { $name = '(untitled link)'; } if (strlen($url) < 6) { return Error::create("Please enter a valid URL. A URL typically begins with \"http://\""); } $r = mysql_query("INSERT INTO Links (name, description, url, category_id, is_active) VALUES ('{$name}', '{$description}', '{$url}', '{$category_id}', " . DEFAULT_ACTIVE . ")"); if ($r) { $nl = Link::get(mysql_insert_id()); return $nl; } else { return Error::MySQL(); } } else { return Error::create("Only an administrator may add links."); } }
function add($postArray) { $db = new db(); $uo = User::getCurrent(); if (User::isAdmin()) { $uo = User::get($postArray['user_id']); if (db::isError($uo)) { $e->add($uo); } else { if (!$uo->isAdmin() && $uo->isBandMember()) { $e->add("Invalid user. User must be a band member or an administrator."); } } } else { $uo = User::getCurrent(); } $user_id = $uo->getID(); $name = $db->sanitize_to_db($postArray['name']); $address1 = $db->sanitize_to_db($postArray['address1']); $address2 = $db->sanitize_to_db($postArray['address2']); $city = $db->sanitize_to_db($postArray['city']); $stateProvince = $db->sanitize_to_db($postArray['stateProvince']); if ($stateProvince == "??") { $stateProvince = $db->sanitize_to_db($postArray['stateProvinceOther']); } $postalCode = $db->sanitize_to_db($postArray['postalCode']); $directions = $db->sanitize_to_db($postArray['directions']); $country = $db->sanitize_to_db($postArray['country']); $country = $country == null ? VENUE_DEFAULT_COUNTRY : $country; if (!$name) { $name = '(untitled venue)'; } $r = mysql_query("insert into Venues (user_id, country, name, address1, address2, city, stateProvince, postalCode, directions, is_active) values ('{$user_id}', '{$country}', '{$name}', '{$address1}', '{$address2}', '{$city}', '{$stateProvince}', '{$postalCode}', '{$directions}'," . DEFAULT_ACTIVE . ")"); if ($r) { return Venue::get(mysql_insert_id()); } else { return Error::MySQL(); } }
function getMemberPhoto() { // the album cover is actually the first piece of media that's active in a given member's media area // first we get the media area ID for the given release. if ($this->photo_area_id) { // if we have an area ID, we continue $q = "select ID from DarkRoom_Media_to_Areas where area_id = {$this->photo_area_id} and is_active = 1 order by display_order asc limit 1"; $r = mysql_query($q); if (!$r) { return Error::MySQL(); } $row = mysql_fetch_assoc($r); if ($row['ID']) { $mi = MediaInstance::get($row['ID']); return $mi; } } }
function registerMedia() { if (User::isAdmin()) { if ($this->av_area_id < 1) { $areaTitle = "Track Audio/Video: "; $allowed_extensions = MEDIA_EXTENSIONS_ALLOWED_AV; $display = "list"; $ma = MediaArea::add(0, $areaTitle . $this->title, null, $allowed_extensions, $display); if (db::isError($ma)) { return $ma; } $ma->activate(); $q = "update Release_Tracks set av_area_id = " . $ma->getID() . " where ID = {$this->ID}"; $r = mysql_query($q); if (!$r) { return Error::MySQL(); } else { return $r; } return $r; } else { return Error::create("A track with an ID of {$this->ID} is already registered."); } } else { return Error::create('Only an admin user may authorize a track for media.'); } }