2011-03-28 14:21:28 +00:00
|
|
|
<?
|
|
|
|
|
|
|
|
//******************************************************************************//
|
|
|
|
//----------------- Take request -----------------------------------------------//
|
|
|
|
authorize();
|
|
|
|
|
|
|
|
|
2013-05-30 08:00:30 +00:00
|
|
|
if ($_POST['action'] != 'takenew' && $_POST['action'] != 'takeedit') {
|
2011-03-28 14:21:28 +00:00
|
|
|
error(0);
|
|
|
|
}
|
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
$NewRequest = ($_POST['action'] == 'takenew');
|
2011-03-28 14:21:28 +00:00
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
if (!$NewRequest) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$ReturnEdit = true;
|
|
|
|
}
|
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
if ($NewRequest) {
|
|
|
|
if (!check_perms('site_submit_requests') || $LoggedUser['BytesUploaded'] < 250 * 1024 * 1024) {
|
2011-03-28 14:21:28 +00:00
|
|
|
error(403);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$RequestID = $_POST['requestid'];
|
2013-04-19 08:00:55 +00:00
|
|
|
if (!is_number($RequestID)) {
|
2011-03-28 14:21:28 +00:00
|
|
|
error(0);
|
|
|
|
}
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2012-10-11 08:00:15 +00:00
|
|
|
$Request = Requests::get_requests(array($RequestID));
|
2011-03-28 14:21:28 +00:00
|
|
|
$Request = $Request['matches'][$RequestID];
|
2013-04-19 08:00:55 +00:00
|
|
|
if (empty($Request)) {
|
2011-03-28 14:21:28 +00:00
|
|
|
error(404);
|
|
|
|
}
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2012-02-03 08:00:22 +00:00
|
|
|
list($RequestID, $RequestorID, $RequestorName, $TimeAdded, $LastVote, $CategoryID, $Title, $Year, $Image, $Description, $CatalogueNumber, $RecordLabel,
|
2013-04-19 08:00:55 +00:00
|
|
|
$ReleaseType, $BitrateList, $FormatList, $MediaList, $LogCue, $FillerID, $FillerName, $TorrentID, $TimeFilled, $GroupID, $OCLC) = $Request;
|
2013-05-13 08:00:33 +00:00
|
|
|
$VoteArray = Requests::get_votes_array($RequestID);
|
2011-03-28 14:21:28 +00:00
|
|
|
$VoteCount = count($VoteArray['Voters']);
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
$IsFilled = !empty($TorrentID);
|
|
|
|
|
|
|
|
$CategoryName = $Categories[$CategoryID - 1];
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
$ProjectCanEdit = (check_perms('project_team') && !$IsFilled && (($CategoryID == 0) || ($CategoryName == 'Music' && $Year == 0)));
|
2011-03-28 14:21:28 +00:00
|
|
|
$CanEdit = ((!$IsFilled && $LoggedUser['ID'] == $RequestorID && $VoteCount < 2) || $ProjectCanEdit || check_perms('site_moderate_requests'));
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
if (!$CanEdit) {
|
2011-03-28 14:21:28 +00:00
|
|
|
error(403);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Validate
|
2013-04-19 08:00:55 +00:00
|
|
|
if (empty($_POST['type'])) {
|
2011-03-28 14:21:28 +00:00
|
|
|
error(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
$CategoryName = $_POST['type'];
|
|
|
|
$CategoryID = (array_search($CategoryName, $Categories) + 1);
|
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
if (empty($CategoryID)) {
|
2011-03-28 14:21:28 +00:00
|
|
|
error(0);
|
|
|
|
}
|
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
if (empty($_POST['title'])) {
|
|
|
|
$Err = 'You forgot to enter the title!';
|
2011-03-28 14:21:28 +00:00
|
|
|
} else {
|
|
|
|
$Title = trim($_POST['title']);
|
|
|
|
}
|
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
if (empty($_POST['tags'])) {
|
|
|
|
$Err = 'You forgot to enter any tags!';
|
2011-03-28 14:21:28 +00:00
|
|
|
} else {
|
|
|
|
$Tags = trim($_POST['tags']);
|
|
|
|
}
|
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
if ($NewRequest) {
|
|
|
|
if (empty($_POST['amount'])) {
|
|
|
|
$Err = 'You forgot to enter any bounty!';
|
2011-03-28 14:21:28 +00:00
|
|
|
} else {
|
|
|
|
$Bounty = trim($_POST['amount']);
|
2013-04-19 08:00:55 +00:00
|
|
|
if (!is_number($Bounty)) {
|
|
|
|
$Err = 'Your entered bounty is not a number';
|
|
|
|
} elseif ($Bounty < 100 * 1024 * 1024) {
|
2013-04-21 08:00:52 +00:00
|
|
|
$Err = 'Minimum bounty is 100 MB.';
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
$Bytes = $Bounty; //From MB to B
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
if (empty($_POST['image'])) {
|
|
|
|
$Image = '';
|
2011-03-28 14:21:28 +00:00
|
|
|
} else {
|
2013-04-19 08:00:55 +00:00
|
|
|
ImageTools::blacklisted($_POST['image']);
|
|
|
|
if (preg_match('/'.IMAGE_REGEX.'/', trim($_POST['image'])) > 0) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$Image = trim($_POST['image']);
|
|
|
|
} else {
|
2013-04-19 08:00:55 +00:00
|
|
|
$Err = display_str($_POST['image']).' does not appear to be a valid link to an image.';
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
if (empty($_POST['description'])) {
|
|
|
|
$Err = 'You forgot to enter a description.';
|
2011-03-28 14:21:28 +00:00
|
|
|
} else {
|
|
|
|
$Description = trim($_POST['description']);
|
|
|
|
}
|
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
if ($CategoryName == "Music") {
|
|
|
|
if (empty($_POST['artists'])) {
|
|
|
|
$Err = 'You did not enter any artists.';
|
2011-03-28 14:21:28 +00:00
|
|
|
} else {
|
|
|
|
$Artists = $_POST['artists'];
|
|
|
|
$Importance = $_POST['importance'];
|
|
|
|
}
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
if (!is_number($_POST['releasetype']) || !array_key_exists($_POST['releasetype'], $ReleaseTypes)) {
|
|
|
|
$Err = 'Please pick a release type';
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$ReleaseType = $_POST['releasetype'];
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
if (empty($_POST['all_formats']) && count($_POST['formats']) != count($Formats)) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$FormatArray = $_POST['formats'];
|
2013-04-19 08:00:55 +00:00
|
|
|
if (count($FormatArray) < 1) {
|
|
|
|
$Err = 'You must require at least one format';
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$AllFormats = true;
|
|
|
|
}
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
if (empty($_POST['all_bitrates']) && count($_POST['bitrates']) != count($Bitrates)) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$BitrateArray = $_POST['bitrates'];
|
2013-04-19 08:00:55 +00:00
|
|
|
if (count($BitrateArray) < 1) {
|
|
|
|
$Err = 'You must require at least one bitrate';
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$AllBitrates = true;
|
|
|
|
}
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
if (empty($_POST['all_media']) && count($_POST['media']) != count($Media)) {
|
2013-02-19 08:00:30 +00:00
|
|
|
$MediaArray = $_POST['media'];
|
2013-04-19 08:00:55 +00:00
|
|
|
if (count($MediaArray) < 1) {
|
|
|
|
$Err = 'You must require at least one medium.';
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$AllMedia = true;
|
|
|
|
}
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
//$Bitrates[1] = FLAC
|
2013-06-27 08:01:06 +00:00
|
|
|
if (!empty($FormatArray) && in_array(array_search('FLAC', $Formats), $FormatArray)) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$NeedLog = empty($_POST['needlog']) ? false : true;
|
2013-04-19 08:00:55 +00:00
|
|
|
if ($NeedLog) {
|
|
|
|
if ($_POST['minlogscore']) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$MinLogScore = trim($_POST['minlogscore']);
|
|
|
|
} else {
|
|
|
|
$MinLogScore = 0;
|
|
|
|
}
|
2013-04-19 08:00:55 +00:00
|
|
|
if (!is_number($MinLogScore)) {
|
|
|
|
$Err = 'You have entered a minimum log score that is not a number.';
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
2013-02-19 08:00:30 +00:00
|
|
|
}
|
2011-03-28 14:21:28 +00:00
|
|
|
$NeedCue = empty($_POST['needcue']) ? false : true;
|
|
|
|
//FLAC was picked, require either Lossless or 24 bit Lossless
|
2013-06-27 08:01:06 +00:00
|
|
|
if (!$AllBitrates && !in_array(array_search('Lossless', $Bitrates), $BitrateArray) && !in_array(array_search('24bit Lossless', $Bitrates), $BitrateArray)) {
|
2013-04-19 08:00:55 +00:00
|
|
|
$Err = 'You selected FLAC as a format but no possible bitrate to fill it (Lossless or 24bit Lossless)';
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (($NeedCue || $NeedLog)) {
|
2013-02-07 08:00:47 +00:00
|
|
|
if (!(empty($_POST['all_media']) && $MediaArray[0] == 0)) {
|
2013-04-19 08:00:55 +00:00
|
|
|
$Err = 'Only CD is allowed as media for FLAC + log/cue requests.';
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$NeedLog = false;
|
|
|
|
$NeedCue = false;
|
2013-02-19 08:00:30 +00:00
|
|
|
$MinLogScore = false;
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2012-02-03 08:00:22 +00:00
|
|
|
// GroupID
|
|
|
|
if (!empty($_POST['groupid'])) {
|
|
|
|
$GroupID = trim($_POST['groupid']);
|
2013-06-11 08:01:24 +00:00
|
|
|
if (preg_match('/^'.TORRENT_GROUP_REGEX.'/i', $GroupID, $Matches)) {
|
|
|
|
$GroupID = $Matches[4];
|
2012-02-03 08:00:22 +00:00
|
|
|
}
|
|
|
|
if (is_number($GroupID)) {
|
2012-02-07 08:00:20 +00:00
|
|
|
$DB->query("SELECT 1 FROM torrents_group WHERE ID = '$GroupID' AND CategoryID = 1");
|
2012-02-03 08:00:22 +00:00
|
|
|
if ($DB->record_count() == 0) {
|
2013-04-19 08:00:55 +00:00
|
|
|
$Err = 'The torrent group, if entered, must correspond to a music torrent group on the site.';
|
2012-02-03 08:00:22 +00:00
|
|
|
}
|
|
|
|
} else {
|
2013-04-19 08:00:55 +00:00
|
|
|
$Err = 'The torrent group, if entered, must correspond to a music torrent group on the site.';
|
2012-02-03 08:00:22 +00:00
|
|
|
}
|
2013-03-31 08:00:37 +00:00
|
|
|
} elseif ($_POST['groupid'] == '0') {
|
|
|
|
$GroupID = 0;
|
2012-02-03 08:00:22 +00:00
|
|
|
}
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
//Not required
|
2013-04-19 08:00:55 +00:00
|
|
|
if (!empty($_POST['editioninfo'])) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$EditionInfo = trim($_POST['editioninfo']);
|
|
|
|
} else {
|
2013-04-19 08:00:55 +00:00
|
|
|
$EditionInfo = '';
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
2013-04-19 08:00:55 +00:00
|
|
|
if (!empty($_POST['cataloguenumber'])) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$CatalogueNumber = trim($_POST['cataloguenumber']);
|
|
|
|
} else {
|
2013-04-19 08:00:55 +00:00
|
|
|
$CatalogueNumber = '';
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
2013-04-19 08:00:55 +00:00
|
|
|
if (!empty($_POST['recordlabel'])) {
|
2012-02-03 08:00:22 +00:00
|
|
|
$RecordLabel = trim($_POST['recordlabel']);
|
|
|
|
} else {
|
2013-04-19 08:00:55 +00:00
|
|
|
$RecordLabel = '';
|
2012-02-03 08:00:22 +00:00
|
|
|
}
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
if ($CategoryName == 'Music' || $CategoryName == 'Audiobooks' || $CategoryName == 'Comedy') {
|
|
|
|
if (empty($_POST['year'])) {
|
|
|
|
$Err = 'You forgot to enter the year!';
|
2011-03-28 14:21:28 +00:00
|
|
|
} else {
|
|
|
|
$Year = trim($_POST['year']);
|
2013-04-19 08:00:55 +00:00
|
|
|
if (!is_number($Year)) {
|
|
|
|
$Err = 'Your entered year is not a number.';
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-24 08:00:15 +00:00
|
|
|
//Apply OCLC to all types
|
|
|
|
if (!empty($_POST['oclc'])) {
|
|
|
|
$OCLC = trim($_POST['oclc']);
|
|
|
|
} else {
|
2013-04-19 08:00:55 +00:00
|
|
|
$OCLC = '';
|
2012-08-24 08:00:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
//For refilling on error
|
2013-04-19 08:00:55 +00:00
|
|
|
if ($CategoryName == 'Music') {
|
2011-03-28 14:21:28 +00:00
|
|
|
$MainArtistCount = 0;
|
|
|
|
$ArtistNames = array();
|
|
|
|
$ArtistForm = array(
|
|
|
|
1 => array(),
|
|
|
|
2 => array(),
|
|
|
|
3 => array()
|
|
|
|
);
|
2013-04-19 08:00:55 +00:00
|
|
|
for ($i = 0, $il = count($Artists); $i < $il; $i++) {
|
|
|
|
if (trim($Artists[$i]) != '') {
|
|
|
|
if (!in_array($Artists[$i], $ArtistNames)) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$ArtistForm[$Importance[$i]][] = array('name' => trim($Artists[$i]));
|
2013-04-19 08:00:55 +00:00
|
|
|
if (in_array($Importance[$i], array(1,4,5,6))) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$MainArtistCount++;
|
|
|
|
}
|
|
|
|
$ArtistNames[] = trim($Artists[$i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-04-19 08:00:55 +00:00
|
|
|
if ($MainArtistCount < 1) {
|
|
|
|
$Err = 'Please enter at least one main artist, conductor, composer, or DJ.';
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
2013-04-19 08:00:55 +00:00
|
|
|
if (!isset($ArtistNames[0])) {
|
2011-03-28 14:21:28 +00:00
|
|
|
unset($ArtistForm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
if (!empty($Err)) {
|
2011-03-28 14:21:28 +00:00
|
|
|
error($Err);
|
2013-04-19 08:00:55 +00:00
|
|
|
$Div = $_POST['unit'] == 'mb' ? 1024 * 1024 : 1024 * 1024 * 1024;
|
2011-03-28 14:21:28 +00:00
|
|
|
$Bounty /= $Div;
|
|
|
|
include(SERVER_ROOT.'/sections/requests/new_edit.php');
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
|
|
|
|
//Databasify the input
|
2013-04-19 08:00:55 +00:00
|
|
|
if ($CategoryName == 'Music') {
|
|
|
|
if (empty($AllBitrates)) {
|
|
|
|
foreach ($BitrateArray as $Index => $MasterIndex) {
|
|
|
|
if (array_key_exists($Index, $Bitrates)) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$BitrateArray[$Index] = $Bitrates[$MasterIndex];
|
|
|
|
} else {
|
|
|
|
//Hax
|
|
|
|
error(0);
|
|
|
|
}
|
|
|
|
}
|
2013-04-19 08:00:55 +00:00
|
|
|
$BitrateList = implode('|', $BitrateArray);
|
2011-03-28 14:21:28 +00:00
|
|
|
} else {
|
2013-04-19 08:00:55 +00:00
|
|
|
$BitrateList = 'Any';
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
if (empty($AllFormats)) {
|
|
|
|
foreach ($FormatArray as $Index => $MasterIndex) {
|
|
|
|
if (array_key_exists($Index, $Formats)) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$FormatArray[$Index] = $Formats[$MasterIndex];
|
|
|
|
} else {
|
|
|
|
//Hax
|
|
|
|
error(0);
|
|
|
|
}
|
|
|
|
}
|
2013-04-19 08:00:55 +00:00
|
|
|
$FormatList = implode('|', $FormatArray);
|
2011-03-28 14:21:28 +00:00
|
|
|
} else {
|
2013-04-19 08:00:55 +00:00
|
|
|
$FormatList = 'Any';
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
if (empty($AllMedia)) {
|
|
|
|
foreach ($MediaArray as $Index => $MasterIndex) {
|
|
|
|
if (array_key_exists($Index, $Media)) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$MediaArray[$Index] = $Media[$MasterIndex];
|
|
|
|
} else {
|
|
|
|
//Hax
|
|
|
|
error(0);
|
|
|
|
}
|
|
|
|
}
|
2013-04-19 08:00:55 +00:00
|
|
|
$MediaList = implode('|', $MediaArray);
|
2011-03-28 14:21:28 +00:00
|
|
|
} else {
|
2013-04-19 08:00:55 +00:00
|
|
|
$MediaList = 'Any';
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
$LogCue = '';
|
|
|
|
if ($NeedLog) {
|
|
|
|
$LogCue .= 'Log';
|
|
|
|
if ($MinLogScore > 0) {
|
|
|
|
if ($MinLogScore >= 100) {
|
|
|
|
$LogCue .= ' (100%)';
|
2011-03-28 14:21:28 +00:00
|
|
|
} else {
|
2013-04-19 08:00:55 +00:00
|
|
|
$LogCue .= ' (>= '.$MinLogScore.'%)';
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-04-19 08:00:55 +00:00
|
|
|
if ($NeedCue) {
|
|
|
|
if ($LogCue != '') {
|
|
|
|
$LogCue .= ' + Cue';
|
2011-03-28 14:21:28 +00:00
|
|
|
} else {
|
2013-04-19 08:00:55 +00:00
|
|
|
$LogCue = 'Cue';
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Query time!
|
2013-04-19 08:00:55 +00:00
|
|
|
if ($CategoryName == 'Music') {
|
|
|
|
if ($NewRequest) {
|
2013-04-21 08:00:52 +00:00
|
|
|
$DB->query('
|
|
|
|
INSERT INTO requests (
|
|
|
|
UserID, TimeAdded, LastVote, CategoryID, Title, Year, Image, Description, RecordLabel,
|
|
|
|
CatalogueNumber, ReleaseType, BitrateList, FormatList, MediaList, LogCue, Visible, GroupID, OCLC)
|
|
|
|
VALUES
|
|
|
|
('.$LoggedUser['ID'].", '".sqltime()."', '".sqltime()."', $CategoryID, '".db_string($Title)."', $Year, '".db_string($Image)."', '".db_string($Description)."','".db_string($RecordLabel)."',
|
|
|
|
'".db_string($CatalogueNumber)."', $ReleaseType, '$BitrateList','$FormatList', '$MediaList', '$LogCue', '1', '$GroupID', '".db_string($OCLC)."')");
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
$RequestID = $DB->inserted_id();
|
2013-04-21 08:00:52 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
} else {
|
2013-04-21 08:00:52 +00:00
|
|
|
$DB->query("
|
|
|
|
UPDATE requests
|
|
|
|
SET CategoryID = $CategoryID,
|
|
|
|
Title = '".db_string($Title)."',
|
|
|
|
Year = $Year,
|
|
|
|
Image = '".db_string($Image)."',
|
|
|
|
Description = '".db_string($Description)."',
|
|
|
|
CatalogueNumber = '".db_string($CatalogueNumber)."',
|
|
|
|
RecordLabel = '".db_string($RecordLabel)."',
|
|
|
|
ReleaseType = $ReleaseType,
|
|
|
|
BitrateList = '$BitrateList',
|
|
|
|
FormatList = '$FormatList',
|
|
|
|
MediaList = '$MediaList',
|
|
|
|
LogCue = '$LogCue',
|
|
|
|
GroupID = '$GroupID',
|
|
|
|
OCLC = '".db_string($OCLC)."'
|
|
|
|
WHERE ID = ".$RequestID);
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
//I almost didn't think of this, we need to be able to delete artists / tags
|
|
|
|
$DB->query("SELECT ArtistID FROM requests_artists WHERE RequestID = ".$RequestID);
|
|
|
|
$RequestArtists = $DB->to_array();
|
2013-04-19 08:00:55 +00:00
|
|
|
foreach ($RequestArtists as $RequestArtist) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$Cache->delete_value('artists_requests_'.$RequestArtist);
|
|
|
|
}
|
|
|
|
$DB->query("DELETE FROM requests_artists WHERE RequestID = ".$RequestID);
|
|
|
|
$Cache->delete_value('request_artists_'.$RequestID);
|
|
|
|
}
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2012-02-03 08:00:22 +00:00
|
|
|
if ($GroupID) {
|
|
|
|
$Cache->delete_value('requests_group_'.$GroupID);
|
|
|
|
}
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
/*
|
|
|
|
* Multiple Artists!
|
|
|
|
* For the multiple artists system, we have 3 steps:
|
|
|
|
* 1. See if each artist given already exists and if it does, grab the ID.
|
|
|
|
* 2. For each artist that didn't exist, create an artist.
|
2013-02-19 08:00:30 +00:00
|
|
|
* 3. Create a row in the requests_artists table for each artist, based on the ID.
|
2011-03-28 14:21:28 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
foreach ($ArtistForm as $Importance => $Artists) {
|
|
|
|
foreach ($Artists as $Num => $Artist) {
|
2011-03-28 14:21:28 +00:00
|
|
|
//1. See if each artist given already exists and if it does, grab the ID.
|
|
|
|
$DB->query("
|
|
|
|
SELECT
|
2013-04-21 08:00:52 +00:00
|
|
|
aa.ArtistID,
|
|
|
|
aa.AliasID,
|
|
|
|
aa.Name,
|
|
|
|
aa.Redirect
|
2011-03-28 14:21:28 +00:00
|
|
|
FROM artists_alias AS aa
|
2012-06-02 08:00:16 +00:00
|
|
|
WHERE aa.Name = '".db_string($Artist['name'])."'");
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
while (list($ArtistID, $AliasID, $AliasName, $Redirect) = $DB->next_record(MYSQLI_NUM, false)) {
|
|
|
|
if (!strcasecmp($Artist['name'], $AliasName)) {
|
|
|
|
if ($Redirect) {
|
2012-06-13 08:00:16 +00:00
|
|
|
$AliasID = $Redirect;
|
2012-05-18 13:35:17 +00:00
|
|
|
}
|
2012-06-13 08:00:16 +00:00
|
|
|
$ArtistForm[$Importance][$Num] = array('id' => $ArtistID, 'aliasid' => $AliasID, 'name' => $AliasName);
|
|
|
|
break;
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
2012-06-13 08:00:16 +00:00
|
|
|
}
|
2013-04-19 08:00:55 +00:00
|
|
|
if (!$ArtistID) {
|
2011-03-28 14:21:28 +00:00
|
|
|
//2. For each artist that didn't exist, create an artist.
|
2013-04-21 08:00:52 +00:00
|
|
|
$DB->query("
|
|
|
|
INSERT INTO artists_group (Name)
|
|
|
|
VALUES ('".db_string($Artist['name'])."')");
|
2011-03-28 14:21:28 +00:00
|
|
|
$ArtistID = $DB->inserted_id();
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
$Cache->increment('stats_artist_count');
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2013-04-21 08:00:52 +00:00
|
|
|
$DB->query("
|
|
|
|
INSERT INTO artists_alias (ArtistID, Name)
|
|
|
|
VALUES ($ArtistID, '".db_string($Artist['name'])."')");
|
2011-03-28 14:21:28 +00:00
|
|
|
$AliasID = $DB->inserted_id();
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
$ArtistForm[$Importance][$Num] = array('id' => $ArtistID, 'aliasid' => $AliasID, 'name' => $Artist['name']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-02-19 08:00:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
//3. Create a row in the requests_artists table for each artist, based on the ID.
|
2013-04-19 08:00:55 +00:00
|
|
|
foreach ($ArtistForm as $Importance => $Artists) {
|
|
|
|
foreach ($Artists as $Num => $Artist) {
|
2013-04-21 08:00:52 +00:00
|
|
|
$DB->query("
|
|
|
|
INSERT IGNORE INTO requests_artists (RequestID, ArtistID, AliasID, Importance)
|
|
|
|
VALUES ($RequestID, ".$Artist['id'].", ".$Artist['aliasid'].", '$Importance')");
|
2011-03-28 14:21:28 +00:00
|
|
|
$Cache->increment('stats_album_count');
|
|
|
|
$Cache->delete_value('artists_requests_'.$Artist['id']);
|
|
|
|
}
|
|
|
|
}
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
//End Music only
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
} else {
|
|
|
|
//Not a music request anymore, delete music only fields.
|
2013-04-19 08:00:55 +00:00
|
|
|
if (!$NewRequest) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$DB->query("SELECT ArtistID FROM requests_artists WHERE RequestID = ".$RequestID);
|
|
|
|
$OldArtists = $DB->collect('ArtistID');
|
2013-04-19 08:00:55 +00:00
|
|
|
foreach ($OldArtists as $ArtistID) {
|
2013-04-21 08:00:52 +00:00
|
|
|
if (empty($ArtistID)) {
|
|
|
|
continue;
|
|
|
|
}
|
2011-03-28 14:21:28 +00:00
|
|
|
//Get a count of how many groups or requests use the artist ID
|
2013-04-21 08:00:52 +00:00
|
|
|
$DB->query("
|
|
|
|
SELECT COUNT(ag.ArtistID)
|
|
|
|
FROM artists_group as ag
|
|
|
|
LEFT JOIN requests_artists AS ra ON ag.ArtistID=ra.ArtistID
|
|
|
|
WHERE ra.ArtistID IS NOT NULL
|
|
|
|
AND ag.ArtistID = '$ArtistID'");
|
2011-03-28 14:21:28 +00:00
|
|
|
list($ReqCount) = $DB->next_record();
|
2013-04-21 08:00:52 +00:00
|
|
|
$DB->query("
|
|
|
|
SELECT COUNT(ag.ArtistID)
|
|
|
|
FROM artists_group as ag
|
|
|
|
LEFT JOIN torrents_artists AS ta ON ag.ArtistID=ta.ArtistID
|
|
|
|
WHERE ta.ArtistID IS NOT NULL
|
|
|
|
AND ag.ArtistID = '$ArtistID'");
|
2011-03-28 14:21:28 +00:00
|
|
|
list($GroupCount) = $DB->next_record();
|
2013-04-19 08:00:55 +00:00
|
|
|
if (($ReqCount + $GroupCount) == 0) {
|
2011-03-28 14:21:28 +00:00
|
|
|
//The only group to use this artist
|
2012-10-11 08:00:15 +00:00
|
|
|
Artists::delete_artist($ArtistID);
|
2011-03-28 14:21:28 +00:00
|
|
|
} else {
|
|
|
|
//Not the only group, still need to clear cache
|
|
|
|
$Cache->delete_value('artists_requests_'.$ArtistID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$DB->query("DELETE FROM requests_artists WHERE RequestID = ".$RequestID);
|
|
|
|
}
|
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
if ($CategoryName == 'Audiobooks' || $CategoryName == 'Comedy') {
|
2011-03-28 14:21:28 +00:00
|
|
|
//These types require a year field.
|
2013-04-19 08:00:55 +00:00
|
|
|
if ($NewRequest) {
|
2013-02-19 08:00:30 +00:00
|
|
|
$DB->query("INSERT INTO requests (
|
2012-08-24 08:00:15 +00:00
|
|
|
UserID, TimeAdded, LastVote, CategoryID, Title, Year, Image, Description, Visible, OCLC)
|
2011-03-28 14:21:28 +00:00
|
|
|
VALUES
|
2013-04-21 08:00:52 +00:00
|
|
|
(".$LoggedUser['ID'].", '".sqltime()."', '".sqltime()."', $CategoryID, '".db_string($Title)."', $Year, '".db_string($Image)."', '".db_string($Description)."', '1', '".db_string($OCLC)."')");
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
$RequestID = $DB->inserted_id();
|
2013-04-21 08:00:52 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
} else {
|
2013-04-21 08:00:52 +00:00
|
|
|
$DB->query("
|
|
|
|
UPDATE requests
|
|
|
|
SET CategoryID = $CategoryID,
|
2013-02-19 08:00:30 +00:00
|
|
|
Title = '".db_string($Title)."',
|
2013-04-21 08:00:52 +00:00
|
|
|
Year = $Year,
|
2011-03-28 14:21:28 +00:00
|
|
|
Image = '".db_string($Image)."',
|
2012-08-24 08:00:15 +00:00
|
|
|
Description = '".db_string($Description)."',
|
2013-02-19 08:00:30 +00:00
|
|
|
OCLC = '".db_string($OCLC)."'
|
2011-03-28 14:21:28 +00:00
|
|
|
WHERE ID = ".$RequestID);
|
|
|
|
}
|
|
|
|
} else {
|
2013-04-19 08:00:55 +00:00
|
|
|
if ($NewRequest) {
|
2013-04-21 08:00:52 +00:00
|
|
|
$DB->query("
|
|
|
|
INSERT INTO requests (
|
|
|
|
UserID, TimeAdded, LastVote, CategoryID, Title, Image, Description, Visible, OCLC)
|
|
|
|
VALUES
|
|
|
|
(".$LoggedUser['ID'].", '".sqltime()."', '".sqltime()."', $CategoryID, '".db_string($Title)."', '".db_string($Image)."', '".db_string($Description)."', '1', '".db_string($OCLC)."')");
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
$RequestID = $DB->inserted_id();
|
2013-04-21 08:00:52 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
} else {
|
2013-04-21 08:00:52 +00:00
|
|
|
$DB->query("
|
|
|
|
UPDATE requests
|
|
|
|
SET CategoryID = $CategoryID,
|
|
|
|
Title = '".db_string($Title)."',
|
|
|
|
Image = '".db_string($Image)."',
|
|
|
|
Description = '".db_string($Description)."',
|
|
|
|
OCLC = '".db_string($OCLC)."'
|
|
|
|
WHERE ID = ".$RequestID);
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Tags
|
2013-04-19 08:00:55 +00:00
|
|
|
if (!$NewRequest) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$DB->query("DELETE FROM requests_tags WHERE RequestID = ".$RequestID);
|
|
|
|
}
|
|
|
|
|
|
|
|
$Tags = array_unique(explode(',', $Tags));
|
2013-04-19 08:00:55 +00:00
|
|
|
foreach ($Tags as $Index => $Tag) {
|
2012-10-11 08:00:15 +00:00
|
|
|
$Tag = Misc::sanitize_tag($Tag);
|
2013-01-30 08:00:20 +00:00
|
|
|
$Tag = Misc::get_alias_tag($Tag);
|
2011-03-28 14:21:28 +00:00
|
|
|
$Tags[$Index] = $Tag; //For announce
|
2013-02-19 08:00:30 +00:00
|
|
|
$DB->query("INSERT INTO tags
|
2011-03-28 14:21:28 +00:00
|
|
|
(Name, UserID)
|
2013-02-19 08:00:30 +00:00
|
|
|
VALUES
|
2013-04-21 08:00:52 +00:00
|
|
|
('$Tag', ".$LoggedUser['ID'].")
|
2011-03-28 14:21:28 +00:00
|
|
|
ON DUPLICATE KEY UPDATE Uses=Uses+1");
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
$TagID = $DB->inserted_id();
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
$DB->query("INSERT IGNORE INTO requests_tags
|
|
|
|
(TagID, RequestID)
|
2013-02-19 08:00:30 +00:00
|
|
|
VALUES
|
2013-04-21 08:00:52 +00:00
|
|
|
($TagID, $RequestID)");
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
|
2013-04-19 08:00:55 +00:00
|
|
|
if ($NewRequest) {
|
2011-03-28 14:21:28 +00:00
|
|
|
//Remove the bounty and create the vote
|
2013-02-19 08:00:30 +00:00
|
|
|
$DB->query("INSERT INTO requests_votes
|
2011-03-28 14:21:28 +00:00
|
|
|
(RequestID, UserID, Bounty)
|
|
|
|
VALUES
|
2013-04-21 08:00:52 +00:00
|
|
|
($RequestID, ".$LoggedUser['ID'].', '.($Bytes * (1 - $RequestTax)).')');
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2013-04-21 08:00:52 +00:00
|
|
|
$DB->query("UPDATE users_main SET Uploaded = (Uploaded - $Bytes) WHERE ID = ".$LoggedUser['ID']);
|
2011-03-28 14:21:28 +00:00
|
|
|
$Cache->delete_value('user_stats_'.$LoggedUser['ID']);
|
|
|
|
|
2013-02-19 08:00:30 +00:00
|
|
|
|
2013-04-21 08:00:52 +00:00
|
|
|
|
|
|
|
if ($CategoryName == 'Music') {
|
|
|
|
$Announce = "\"$Title\" - ".Artists::display_artists($ArtistForm, false, false).' https://'.SSL_SITE_URL."/requests.php?action=view&id=$RequestID - ".implode(' ', $Tags);
|
2011-03-28 14:21:28 +00:00
|
|
|
} else {
|
2013-04-21 08:00:52 +00:00
|
|
|
$Announce = "\"$Title\" - https://".SSL_SITE_URL."/requests.php?action=view&id=$RequestID - ".implode(' ', $Tags);
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
2013-02-19 08:00:30 +00:00
|
|
|
send_irc('PRIVMSG #'.SSL_SITE_URL.'-requests :'.$Announce);
|
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
} else {
|
|
|
|
$Cache->delete_value('request_'.$RequestID);
|
|
|
|
$Cache->delete_value('request_artists_'.$RequestID);
|
|
|
|
}
|
|
|
|
|
2012-10-11 08:00:15 +00:00
|
|
|
Requests::update_sphinx_requests($RequestID);
|
2011-03-28 14:21:28 +00:00
|
|
|
|
|
|
|
header('Location: requests.php?action=view&id='.$RequestID);
|
|
|
|
?>
|