Gazelle/sections/bookmarks/add.php

103 lines
2.9 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
2013-05-27 08:00:58 +00:00
include(SERVER_ROOT.'/classes/feed.class.php'); // RSS feeds
include(SERVER_ROOT.'/classes/text.class.php'); // strip_bbcode
2012-02-08 08:00:20 +00:00
2011-03-28 14:21:28 +00:00
authorize();
2013-05-05 08:00:31 +00:00
if (!Bookmarks::can_bookmark($_GET['type'])) {
error(404);
}
2012-02-08 08:00:20 +00:00
$Feed = new FEED;
$Text = new TEXT;
$Type = $_GET['type'];
2013-03-29 08:00:08 +00:00
list($Table, $Col) = Bookmarks::bookmark_schema($Type);
2013-05-05 08:00:31 +00:00
if (!is_number($_GET['id'])) {
2011-03-28 14:21:28 +00:00
error(0);
}
2013-05-05 08:00:31 +00:00
$DB->query("
SELECT UserID
FROM $Table
WHERE UserID='$LoggedUser[ID]'
AND $Col='".db_string($_GET['id'])."'");
2013-07-10 00:08:53 +00:00
if (!$DB->has_results()) {
2012-10-27 08:00:09 +00:00
if ($Type === 'torrent') {
2013-07-10 00:08:53 +00:00
$DB->query('
SELECT MAX(Sort)
FROM `bookmarks_torrents`
WHERE UserID = ' . $LoggedUser['ID']);
2012-10-27 08:00:09 +00:00
list($Sort) = $DB->next_record();
if (!$Sort) $Sort = 0;
$Sort += 1;
2013-05-05 08:00:31 +00:00
$DB->query("
INSERT IGNORE INTO $Table (UserID, $Col, Time, Sort)
VALUES ('$LoggedUser[ID]', '".db_string($_GET['id'])."', '".sqltime()."', $Sort)");
2012-10-27 08:00:09 +00:00
} else {
2013-05-05 08:00:31 +00:00
$DB->query("
INSERT IGNORE INTO $Table (UserID, $Col, Time)
VALUES ('$LoggedUser[ID]', '".db_string($_GET['id'])."', '".sqltime()."')");
2012-10-27 08:00:09 +00:00
}
$Cache->delete_value('bookmarks_'.$Type.'_'.$LoggedUser['ID']);
if ($Type == 'torrent') {
2013-02-25 21:16:55 +00:00
$Cache->delete_value('bookmarks_group_ids_' . $UserID);
2012-12-25 08:00:49 +00:00
$GroupID = (int) $_GET['id'];
2012-10-27 08:00:09 +00:00
2013-05-05 08:00:31 +00:00
$DB->query("
SELECT Name, Year, WikiBody, TagList
FROM torrents_group
WHERE ID = '$GroupID'");
2012-02-08 08:00:20 +00:00
list($GroupTitle, $Year, $Body, $TagList) = $DB->next_record();
2013-07-10 00:08:53 +00:00
$TagList = str_replace('_', '.', $TagList);
2012-10-27 08:00:09 +00:00
2013-05-05 08:00:31 +00:00
$DB->query("
SELECT ID, Format, Encoding, HasLog, HasCue, LogScore, Media, Scene, FreeTorrent, UserID
FROM torrents
WHERE GroupID = '$GroupID'");
2012-02-08 08:00:20 +00:00
// RSS feed stuff
while ($Torrent = $DB->next_record()) {
$Title = $GroupTitle;
list($TorrentID, $Format, $Bitrate, $HasLog, $HasCue, $LogScore, $Media, $Scene, $Freeleech, $UploaderID) = $Torrent;
2013-05-05 08:00:31 +00:00
$Title .= " [$Year] - ";
2013-07-10 00:08:53 +00:00
$Title .= "$Format / $Bitrate";
2013-05-05 08:00:31 +00:00
if ($HasLog == "'1'") {
2013-07-10 00:08:53 +00:00
$Title .= ' / Log';
2013-05-05 08:00:31 +00:00
}
if ($HasLog) {
2013-07-10 00:08:53 +00:00
$Title .= " / $LogScore%";
2013-05-05 08:00:31 +00:00
}
if ($HasCue == "'1'") {
2013-07-10 00:08:53 +00:00
$Title .= ' / Cue';
2013-05-05 08:00:31 +00:00
}
2013-07-10 00:08:53 +00:00
$Title .= ' / '.trim($Media);
2013-05-05 08:00:31 +00:00
if ($Scene == '1') {
2013-07-10 00:08:53 +00:00
$Title .= ' / Scene';
2013-05-05 08:00:31 +00:00
}
if ($Freeleech == '1') {
2013-07-10 00:08:53 +00:00
$Title .= ' / Freeleech!';
2013-05-05 08:00:31 +00:00
}
if ($Freeleech == '2') {
2013-07-10 00:08:53 +00:00
$Title .= ' / Neutral leech!';
2013-05-05 08:00:31 +00:00
}
2012-10-27 08:00:09 +00:00
2012-10-11 08:00:15 +00:00
$UploaderInfo = Users::user_info($UploaderID);
2012-10-27 08:00:09 +00:00
$Item = $Feed->item($Title,
2012-02-08 08:00:20 +00:00
$Text->strip_bbcode($Body),
'torrents.php?action=download&amp;authkey=[[AUTHKEY]]&amp;torrent_pass=[[PASSKEY]]&amp;id='.$TorrentID,
$UploaderInfo['Username'],
2013-07-10 00:08:53 +00:00
"torrents.php?id=$GroupID",
2012-02-08 08:00:20 +00:00
trim($TagList));
$Feed->populate('torrents_bookmarks_t_'.$LoggedUser['torrent_pass'], $Item);
}
} elseif ($Type == 'request') {
2013-07-10 00:08:53 +00:00
$DB->query("
SELECT UserID
FROM $Table
WHERE $Col = '".db_string($_GET['id'])."'");
$Bookmarkers = $DB->collect('UserID');
2011-08-24 08:00:06 +00:00
$SS->UpdateAttributes('requests requests_delta', array('bookmarker'), array($_GET['id'] => array($Bookmarkers)), true);
}
2013-05-05 08:00:31 +00:00
}