/* * Yeah, that's right, edit and new are the same place again. * It makes the page uglier to read but ultimately better as the alternative means * maintaining 2 copies of almost identical files. */ $NewRequest = ($_GET['action'] == "new" ? true : false); if(!$NewRequest) { $RequestID = $_GET['id']; if(!is_number($RequestID)) { error(404); } } if($NewRequest && ($LoggedUser['BytesUploaded'] < 250*1024*1024 || !check_perms('site_submit_requests'))) { error('You do not have enough uploaded to make a request.'); } if(!$NewRequest) { if(empty($ReturnEdit)) { $Request = get_requests(array($RequestID)); $Request = $Request['matches'][$RequestID]; if(empty($Request)) { error(404); } list($RequestID, $RequestorID, $RequestorName, $TimeAdded, $LastVote, $CategoryID, $Title, $Year, $Image, $Description, $CatalogueNumber, $ReleaseType, $BitrateList, $FormatList, $MediaList, $LogCue, $FillerID, $FillerName, $TorrentID, $TimeFilled) = $Request; $VoteArray = get_votes_array($RequestID); $VoteCount = count($VoteArray['Voters']); $NeedCue = (strpos($LogCue, "Cue") !== false); $NeedLog = (strpos($LogCue, "Log") !== false); if($NeedLog) { if(strpos($LogCue, "%")) { preg_match("/\d+/", $LogCue, $Matches); $MinLogScore = (int) $Matches[0]; } } $IsFilled = !empty($TorrentID); $CategoryName = $Categories[$CategoryID - 1]; $ProjectCanEdit = (check_perms('project_team') && !$IsFilled && (($CategoryID == 0) || ($CategoryName == "Music" && $Year == 0))); $CanEdit = ((!$IsFilled && $LoggedUser['ID'] == $RequestorID && $VoteCount < 2) || $ProjectCanEdit || check_perms('site_moderate_requests')); if(!$CanEdit) { error(403); } if($CategoryName == "Music") { $ArtistForm = get_request_artists($RequestID); $BitrateArray = array(); if($BitrateList == "Any") { $BitrateArray = array_keys($Bitrates); } else { $BitrateArray = array_keys(array_intersect($Bitrates,explode('|', $BitrateList))); } $FormatArray = array(); if($FormatList == "Any") { $FormatArray = array_keys($Formats); } else { foreach ($Formats as $Key => $Val) { if(strpos($FormatList, $Val) !== false) { $FormatArray[] = $Key; } } } $MediaArray = array(); if($MediaList == "Any") { $MediaArray = array_keys($Media); } else { foreach ($Media as $Key => $Val) { if(strpos($MediaList, $Val) !== false) { $MediaArray[] = $Key; } } } } $Tags = implode(", ", $Request['Tags']); } } if($NewRequest && !empty($_GET['artistid']) && is_number($_GET['artistid'])) { $DB->query("SELECT Name FROM artists_group WHERE artistid = ".$_GET['artistid']." LIMIT 1"); list($ArtistName) = $DB->next_record(); $ArtistForm = array( 1 => array(array('name' => trim($ArtistName))), 2 => array(), 3 => array() ); } elseif($NewRequest && !empty($_GET['groupid']) && is_number($_GET['groupid'])) { $ArtistForm = get_artist($_GET['groupid']); $DB->query("SELECT tg.Name, tg.Year, tg.ReleaseType, tg.WikiImage, GROUP_CONCAT(t.Name SEPARATOR ', ') FROM torrents_group AS tg JOIN torrents_tags AS tt ON tt.GroupID=tg.ID JOIN tags AS t ON t.ID=tt.TagID WHERE tg.ID = ".$_GET['groupid']); list($Title, $Year, $ReleaseType, $Image, $Tags) = $DB->next_record(); } show_header(($NewRequest ? "Create a request" : "Edit a request"), 'requests'); ?>