Empty commit

This commit is contained in:
Git 2013-04-21 08:00:52 +00:00
parent 271dfafde4
commit b8e7deff78
12 changed files with 279 additions and 246 deletions

View File

@ -330,7 +330,7 @@ function write_artists() {
$FontSize = 12;
}
?>
<div style="position: absolute; top: <?=$Artist->y - 5 ?>px; left: <?=$xPosition?> px; font-size: <?=$FontSize?>pt; white-space: nowrap;">
<div style="position: absolute; top: <?=$Artist->y - 5 ?>px; left: <?=$xPosition?>px; font-size: <?=$FontSize?>pt; white-space: nowrap;">
<a href="artist.php?id=<?=$Artist->ID?>" class="similar_artist"><?=$Artist->Name?></a>
</div>
<?

View File

@ -123,7 +123,7 @@ public static function get_ratio_html($Dividend, $Divisor, $Color = true) {
* Returns ratio
* @param int $Dividend
* @param int $Divisor
* @param int $Decimal floor to n decimals (eg Subtract .005 to floor to 2 decimals)
* @param int $Decimal floor to n decimals (e.g. Subtract .005 to floor to 2 decimals)
* @return boolean|string
*/
public function get_ratio ($Dividend, $Divisor, $Decimal = 2) {
@ -148,7 +148,7 @@ public static function get_url($Exclude = false) {
parse_str($_SERVER['QUERY_STRING'], $QueryItems);
foreach ($QueryItems AS $Key => $Val) {
if (!in_array(strtolower($Key),$Exclude)) {
if (!in_array(strtolower($Key), $Exclude)) {
$Query[$Key] = $Val;
}
}
@ -171,34 +171,38 @@ public static function get_url($Exclude = false) {
* If this parameter is not specified, we will default to page 1
*
* @return array(int,string) What page we are on, and what to use in the LIMIT section of a query
* i.e. "SELECT [...] LIMIT $Limit;"
* e.g. "SELECT [...] LIMIT $Limit;"
*/
public static function page_limit($PerPage, $DefaultResult = 1) {
if (!isset($_GET['page'])) {
$Page = ceil($DefaultResult/$PerPage);
if ($Page == 0) $Page = 1;
$Limit=$PerPage;
$Page = ceil($DefaultResult / $PerPage);
if ($Page == 0) {
$Page = 1;
}
$Limit = $PerPage;
} else {
if (!is_number($_GET['page'])) {
error(0);
}
$Page = $_GET['page'];
if ($Page <= 0) { $Page = 1; }
$Limit=$PerPage*$Page-$PerPage . ', ' . $PerPage;
if ($Page <= 0) {
$Page = 1;
}
$Limit = $PerPage * $Page - $PerPage . ', ' . $PerPage;
}
return array($Page,$Limit);
return array($Page, $Limit);
}
// A9 magic. Some other poor soul can write the phpdoc.
// For data stored in memcached catalogues (giant arrays), eg. forum threads
public static function catalogue_limit($Page, $PerPage, $CatalogueSize=500) {
$CatalogueID = floor(($PerPage*$Page-$PerPage)/$CatalogueSize);;
$CatalogueLimit = ($CatalogueID*$CatalogueSize).', '.$CatalogueSize;
// For data stored in memcached catalogues (giant arrays), e.g. forum threads
public static function catalogue_limit($Page, $PerPage, $CatalogueSize = 500) {
$CatalogueID = floor(($PerPage * $Page - $PerPage) / $CatalogueSize);;
$CatalogueLimit = ($CatalogueID * $CatalogueSize).', '.$CatalogueSize;
return array($CatalogueID, $CatalogueLimit);
}
public static function catalogue_select($Catalogue, $Page, $PerPage, $CatalogueSize = 500) {
return array_slice($Catalogue,(($PerPage * $Page - $PerPage) % $CatalogueSize),$PerPage,true);
return array_slice($Catalogue, (($PerPage * $Page - $PerPage) % $CatalogueSize), $PerPage, true);
}
@ -258,7 +262,7 @@ public static function get_pages($StartPage, $TotalRecords, $ItemsPerPage, $Show
if ($StartPage > 1) {
$Pages .= '<a href="'.$Location.'?page=1'.$QueryString.$Anchor.'"><strong>&lt;&lt; First</strong></a> ';
$Pages .= '<a href="'.$Location.'?page='.($StartPage-1).$QueryString.$Anchor.'" class="pager_prev"><strong>&lt; Prev</strong></a> | ';
$Pages .= '<a href="'.$Location.'?page='.($StartPage - 1).$QueryString.$Anchor.'" class="pager_prev"><strong>&lt; Prev</strong></a> | ';
}
//End change
@ -307,7 +311,8 @@ public static function get_pages($StartPage, $TotalRecords, $ItemsPerPage, $Show
public static function get_size($Size, $Levels = 2) {
$Units = array(' B',' KB',' MB',' GB',' TB',' PB',' EB',' ZB',' YB');
$Size = (double) $Size;
for($Steps = 0; abs($Size) >= 1024; $Size /= 1024, $Steps++) {}
for ($Steps = 0; abs($Size) >= 1024; $Size /= 1024, $Steps++) {
}
if (func_num_args() == 1 && $Steps >= 4) {
$Levels++;
}
@ -316,7 +321,7 @@ public static function get_size($Size, $Levels = 2) {
/**
* Format a number as a multiple of its highest power of 1000 (eg. 10035 -> '10.04k')
* Format a number as a multiple of its highest power of 1000 (e.g. 10035 -> '10.04k')
*
* @param int $Number
* @return string formatted number.
@ -343,8 +348,8 @@ public static function human_format($Number) {
/**
* Given a formatted string of a size, get the number of bytes it represents.
*
* @param string $Size formatted size string, eg. 123.45k
* @return Number of bytes it represents, eg. (123.45 * 1024)
* @param string $Size formatted size string, e.g. 123.45k
* @return Number of bytes it represents, e.g. (123.45 * 1024)
*/
public static function get_bytes($Size) {
list($Value,$Unit) = sscanf($Size, "%f%s");
@ -352,7 +357,7 @@ public static function get_bytes($Size) {
if (empty($Unit)) {
return $Value ? round($Value) : 0;
}
switch(strtolower($Unit[0])) {
switch (strtolower($Unit[0])) {
case 'k': return round($Value * 1024);
case 'm': return round($Value * 1048576);
case 'g': return round($Value * 1073741824);
@ -523,8 +528,7 @@ public static function is_utf8($Str) {
* @param string $text Search string
* @return string CSS class(es)
*/
public static function find_torrent_label_class ($text)
{
public static function find_torrent_label_class ($text) {
$index = mb_eregi_replace('(?:[^\w\d\s]+)', '', strtolower($text));
if (isset(self::$TorrentLabels[$index])) {
return self::$TorrentLabels[$index];
@ -535,7 +539,7 @@ public static function find_torrent_label_class ($text)
/**
* Creates a strong element that notes the torrent's state.
* Eg: snatched/freeleech/neutral leech/reported
* E.g.: snatched/freeleech/neutral leech/reported
*
* The CSS class is infered using find_torrent_label_class($text)
*
@ -543,8 +547,7 @@ public static function find_torrent_label_class ($text)
* @param string $class Custom CSS class
* @return string Strong element
*/
public static function torrent_label ($text, $class = '')
{
public static function torrent_label ($text, $class = '') {
if (empty($class)) {
$class = self::find_torrent_label_class($text);
}
@ -558,8 +561,7 @@ public static function torrent_label ($text, $class = '')
* @param int|string $CategoryID This number will be subtracted by one
* @return string
*/
public static function css_category ($CategoryID = 1)
{
public static function css_category ($CategoryID = 1) {
global $Categories;
return 'cats_' . strtolower(str_replace(array('-', ' '), '',
$Categories[$CategoryID - 1]));

View File

@ -4,12 +4,16 @@
}
function time_ago($TimeStamp) {
if(!is_number($TimeStamp)) { // Assume that $TimeStamp is SQL timestamp
if($TimeStamp == '0000-00-00 00:00:00') { return false; }
if (!is_number($TimeStamp)) { // Assume that $TimeStamp is SQL timestamp
if ($TimeStamp == '0000-00-00 00:00:00') {
return false;
}
$TimeStamp = strtotime($TimeStamp);
}
if($TimeStamp == 0) { return false; }
return time()-$TimeStamp;
if ($TimeStamp == 0) {
return false;
}
return time() - $TimeStamp;
}
function time_diff($TimeStamp, $Levels=2, $Span=true, $Lowercase=false) {
@ -17,43 +21,47 @@ function time_diff($TimeStamp, $Levels=2, $Span=true, $Lowercase=false) {
Returns a <span> by default but can optionally return the raw time
difference in text (e.g. "16 hours and 28 minutes", "1 day, 18 hours").
*/
if(!is_number($TimeStamp)) { // Assume that $TimeStamp is SQL timestamp
if($TimeStamp == '0000-00-00 00:00:00') { return 'Never'; }
if (!is_number($TimeStamp)) { // Assume that $TimeStamp is SQL timestamp
if ($TimeStamp == '0000-00-00 00:00:00') {
return 'Never';
}
$TimeStamp = strtotime($TimeStamp);
}
if($TimeStamp == 0) { return 'Never'; }
$Time = time()-$TimeStamp;
if ($TimeStamp == 0) {
return 'Never';
}
$Time = time() - $TimeStamp;
// If the time is negative, then it expires in the future.
if($Time < 0) {
if ($Time < 0) {
$Time = -$Time;
$HideAgo = true;
}
$Years=floor($Time/31556926); // seconds in one year
$Remain = $Time - $Years*31556926;
$Years = floor($Time / 31556926); // seconds in one year
$Remain = $Time - $Years * 31556926;
$Months = floor($Remain/2629744); // seconds in one month
$Remain = $Remain - $Months*2629744;
$Months = floor($Remain / 2629744); // seconds in one month
$Remain = $Remain - $Months * 2629744;
$Weeks = floor($Remain/604800); // seconds in one week
$Remain = $Remain - $Weeks*604800;
$Weeks = floor($Remain / 604800); // seconds in one week
$Remain = $Remain - $Weeks * 604800;
$Days = floor($Remain/86400); // seconds in one day
$Remain = $Remain - $Days*86400;
$Days = floor($Remain / 86400); // seconds in one day
$Remain = $Remain - $Days * 86400;
$Hours=floor($Remain/3600); // seconds in one hour
$Remain = $Remain - $Hours*3600;
$Hours=floor($Remain / 3600); // seconds in one hour
$Remain = $Remain - $Hours * 3600;
$Minutes=floor($Remain/60); // seconds in one minute
$Remain = $Remain - $Minutes*60;
$Minutes = floor($Remain / 60); // seconds in one minute
$Remain = $Remain - $Minutes * 60;
$Seconds=$Remain;
$Seconds = $Remain;
$Return = '';
if ($Years>0 && $Levels>0) {
if ($Years>1) {
if ($Years > 0 && $Levels > 0) {
if ($Years > 1) {
$Return .= $Years.' years';
} else {
$Return .= $Years.' year';
@ -61,11 +69,11 @@ function time_diff($TimeStamp, $Levels=2, $Span=true, $Lowercase=false) {
$Levels--;
}
if ($Months>0 && $Levels>0) {
if ($Return!='') {
if ($Months > 0 && $Levels > 0) {
if ($Return != '') {
$Return.=', ';
}
if ($Months>1) {
if ($Months > 1) {
$Return.=$Months.' months';
} else {
$Return.=$Months.' month';
@ -73,8 +81,8 @@ function time_diff($TimeStamp, $Levels=2, $Span=true, $Lowercase=false) {
$Levels--;
}
if ($Weeks>0 && $Levels>0) {
if ($Return!="") {
if ($Weeks > 0 && $Levels > 0) {
if ($Return != '') {
$Return.=', ';
}
if ($Weeks>1) {
@ -85,11 +93,11 @@ function time_diff($TimeStamp, $Levels=2, $Span=true, $Lowercase=false) {
$Levels--;
}
if ($Days>0 && $Levels>0) {
if ($Return!='') {
if ($Days > 0 && $Levels > 0) {
if ($Return != '') {
$Return.=', ';
}
if ($Days>1) {
if ($Days > 1) {
$Return.=$Days.' days';
} else {
$Return.=$Days.' day';
@ -97,11 +105,11 @@ function time_diff($TimeStamp, $Levels=2, $Span=true, $Lowercase=false) {
$Levels--;
}
if ($Hours>0 && $Levels>0) {
if ($Return!='') {
if ($Hours > 0 && $Levels > 0) {
if ($Return != '') {
$Return.=', ';
}
if ($Hours>1) {
if ($Hours > 1) {
$Return.=$Hours.' hours';
} else {
$Return.=$Hours.' hour';
@ -109,8 +117,8 @@ function time_diff($TimeStamp, $Levels=2, $Span=true, $Lowercase=false) {
$Levels--;
}
if ($Minutes>0 && $Levels>0) {
if ($Return!='') {
if ($Minutes > 0 && $Levels > 0) {
if ($Return != '') {
$Return.=' and ';
}
if ($Minutes>1) {
@ -121,7 +129,7 @@ function time_diff($TimeStamp, $Levels=2, $Span=true, $Lowercase=false) {
$Levels--;
}
if($Return == '') {
if ($Return == '') {
$Return = 'Just now';
} elseif (!isset($HideAgo)) {
$Return .= ' ago';
@ -141,14 +149,14 @@ function time_diff($TimeStamp, $Levels=2, $Span=true, $Lowercase=false) {
/* SQL utility functions */
function time_plus($Offset) {
return date('Y-m-d H:i:s', time()+$Offset);
return date('Y-m-d H:i:s', time() + $Offset);
}
function time_minus($Offset, $Fuzzy = false) {
if($Fuzzy) {
return date('Y-m-d 00:00:00', time()-$Offset);
if ($Fuzzy) {
return date('Y-m-d 00:00:00', time() - $Offset);
} else {
return date('Y-m-d H:i:s', time()-$Offset);
return date('Y-m-d H:i:s', time() - $Offset);
}
}
@ -160,17 +168,23 @@ function sqltime($timestamp = false) {
}
function validDate($DateString) {
$DateTime = explode(" ", $DateString);
if(count($DateTime) != 2) return false;
$DateTime = explode(' ', $DateString);
if (count($DateTime) != 2) {
return false;
}
list($Date, $Time) = $DateTime;
$SplitTime = explode(":", $Time);
if(count($SplitTime) != 3) return false;
$SplitTime = explode(':', $Time);
if (count($SplitTime) != 3) {
return false;
}
list($H, $M, $S) = $SplitTime;
if($H != 0 && !(is_number($H) && $H < 24 && $H >= 0)) return false;
if($M != 0 && !(is_number($M) && $M < 60 && $M >= 0)) return false;
if($S != 0 && !(is_number($S) && $S < 60 && $S >= 0)) return false;
$SplitDate = explode("-", $Date);
if(count($SplitDate) != 3) return false;
if ($H != 0 && !(is_number($H) && $H < 24 && $H >= 0)) return false;
if ($M != 0 && !(is_number($M) && $M < 60 && $M >= 0)) return false;
if ($S != 0 && !(is_number($S) && $S < 60 && $S >= 0)) return false;
$SplitDate = explode('-', $Date);
if (count($SplitDate) != 3) {
return false;
}
list($Y, $M, $D) = $SplitDate;
return checkDate($M, $D, $Y);
}

View File

@ -214,16 +214,6 @@ CREATE TABLE `concerts` (
KEY `TopicID` (`TopicID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `disable_list` (
`Nick` varchar(255) COLLATE utf8_bin NOT NULL,
`Username` varchar(255) COLLATE utf8_bin NOT NULL,
`UserID` int(10) unsigned NOT NULL,
`Time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`Moderator` varchar(255) COLLATE utf8_bin DEFAULT NULL,
PRIMARY KEY (`Nick`),
KEY `UserID` (`UserID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE `do_not_upload` (
`ID` int(10) NOT NULL AUTO_INCREMENT,
`Name` varchar(255) COLLATE utf8_bin NOT NULL,
@ -1580,17 +1570,6 @@ CREATE TABLE `users_warnings_forums` (
PRIMARY KEY (`UserID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `watchlist_hits` (
`ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`UserID` int(10) unsigned NOT NULL,
`WatcherID` int(10) unsigned NOT NULL,
`Date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`Triggered` varchar(50) COLLATE utf8_swedish_ci NOT NULL,
`Item` varchar(100) COLLATE utf8_swedish_ci NOT NULL,
`Checked` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_swedish_ci;
CREATE TABLE `wiki_aliases` (
`Alias` varchar(50) NOT NULL,
`UserID` int(10) NOT NULL,

View File

@ -527,7 +527,10 @@ function compare($X, $Y) {
</div>
<? /* Misc::display_recommend($ArtistID, "artist"); */ ?>
<div class="sidebar">
<? if ($Image) { ?>
<? if ($Image) {
if (check_perms('site_proxy_images')) {
$Image = 'http'.($SSL?'s':'').'://'.SITE_URL.'/image.php?i='.urlencode($Image);
} ?>
<div class="box box_image">
<div class="head"><strong><?=$Name?></strong></div>
<div style="text-align: center; padding: 10px 0px;">

View File

@ -7,6 +7,10 @@
}
if(is_number($FeaturedAlbum['GroupID'])) {
$Artists = Artists::get_artist($FeaturedAlbum['GroupID']);
if (check_perms('site_proxy_images')) {
$FeaturedAlbum['WikiImage'] = 'http'.($SSL?'s':'').'://'.SITE_URL.'/image.php?i='.urlencode($FeaturedAlbum['WikiImage']);
}
?>
<div class="box">
<div class="head colhead_dark"><strong>Featured Album</strong></div>

View File

@ -14,7 +14,7 @@
$TorrentID = $_GET['torrentid'];
} else {
if (empty($_POST['link'])) {
$Err = "You forgot to supply a link to the filling torrent";
$Err = 'You forgot to supply a link to the filling torrent';
} else {
$Link = $_POST['link'];
if (preg_match("/".TORRENT_REGEX."/i", $Link, $Matches) < 1) {
@ -36,21 +36,22 @@
}
//Torrent exists, check it's applicable
$DB->query("SELECT t.UserID,
t.Time,
tg.ReleaseType,
t.Encoding,
t.Format,
t.Media,
t.HasLog,
t.HasCue,
t.LogScore,
tg.CategoryID,
IF(t.Remastered = '1', t.RemasterCatalogueNumber, tg.CatalogueNumber)
FROM torrents AS t
LEFT JOIN torrents_group AS tg ON t.GroupID=tg.ID
WHERE t.ID = ".$TorrentID."
LIMIT 1");
$DB->query("
SELECT t.UserID,
t.Time,
tg.ReleaseType,
t.Encoding,
t.Format,
t.Media,
t.HasLog,
t.HasCue,
t.LogScore,
tg.CategoryID,
IF(t.Remastered = '1', t.RemasterCatalogueNumber, tg.CatalogueNumber)
FROM torrents AS t
LEFT JOIN torrents_group AS tg ON t.GroupID=tg.ID
WHERE t.ID = ".$TorrentID."
LIMIT 1");
if ($DB->record_count() < 1) {
@ -65,7 +66,7 @@
$FillerUsername = $_POST['user'];
$DB->query("SELECT ID FROM users_main WHERE Username LIKE '".db_string($FillerUsername)."'");
if ($DB->record_count() < 1) {
$Err = "No such user to fill for!";
$Err = 'No such user to fill for!';
} else {
list($FillerID) = $DB->next_record();
}
@ -77,7 +78,8 @@
$DB->query("SELECT
$DB->query("
SELECT
Title,
UserID,
TorrentID,
@ -160,14 +162,13 @@
error($Err);
}
//We're all good! Fill!
$DB->query("UPDATE requests SET
FillerID = $FillerID,
TorrentID = $TorrentID,
TimeFilled = '".sqltime()."'
WHERE ID = $RequestID");
$DB->query("
UPDATE requests
SET FillerID = $FillerID,
TorrentID = $TorrentID,
TimeFilled = '".sqltime()."'
WHERE ID = $RequestID");
if ($CategoryName == 'Music') {
$ArtistForm = get_request_artists($RequestID);

View File

@ -80,7 +80,7 @@
if (!is_number($Bounty)) {
$Err = 'Your entered bounty is not a number';
} elseif ($Bounty < 100 * 1024 * 1024) {
$Err = 'Minumum bounty is 100 MB.';
$Err = 'Minimum bounty is 100 MB.';
}
$Bytes = $Bounty; //From MB to B
}
@ -333,32 +333,34 @@
//Query time!
if ($CategoryName == 'Music') {
if ($NewRequest) {
$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)."')");
$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)."')");
$RequestID = $DB->inserted_id();
} else {
$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);
$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);
//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);
@ -388,10 +390,10 @@
//1. See if each artist given already exists and if it does, grab the ID.
$DB->query("
SELECT
aa.ArtistID,
aa.AliasID,
aa.Name,
aa.Redirect
aa.ArtistID,
aa.AliasID,
aa.Name,
aa.Redirect
FROM artists_alias AS aa
WHERE aa.Name = '".db_string($Artist['name'])."'");
@ -406,12 +408,16 @@
}
if (!$ArtistID) {
//2. For each artist that didn't exist, create an artist.
$DB->query("INSERT INTO artists_group (Name) VALUES ('".db_string($Artist['name'])."')");
$DB->query("
INSERT INTO artists_group (Name)
VALUES ('".db_string($Artist['name'])."')");
$ArtistID = $DB->inserted_id();
$Cache->increment('stats_artist_count');
$DB->query("INSERT INTO artists_alias (ArtistID, Name) VALUES (".$ArtistID.", '".db_string($Artist['name'])."')");
$DB->query("
INSERT INTO artists_alias (ArtistID, Name)
VALUES ($ArtistID, '".db_string($Artist['name'])."')");
$AliasID = $DB->inserted_id();
$ArtistForm[$Importance][$Num] = array('id' => $ArtistID, 'aliasid' => $AliasID, 'name' => $Artist['name']);
@ -423,7 +429,9 @@
//3. Create a row in the requests_artists table for each artist, based on the ID.
foreach ($ArtistForm as $Importance => $Artists) {
foreach ($Artists as $Num => $Artist) {
$DB->query("INSERT IGNORE INTO requests_artists (RequestID, ArtistID, AliasID, Importance) VALUES (".$RequestID.", ".$Artist['id'].", ".$Artist['aliasid'].", '".$Importance."')");
$DB->query("
INSERT IGNORE INTO requests_artists (RequestID, ArtistID, AliasID, Importance)
VALUES ($RequestID, ".$Artist['id'].", ".$Artist['aliasid'].", '$Importance')");
$Cache->increment('stats_album_count');
$Cache->delete_value('artists_requests_'.$Artist['id']);
}
@ -437,19 +445,23 @@
$DB->query("SELECT ArtistID FROM requests_artists WHERE RequestID = ".$RequestID);
$OldArtists = $DB->collect('ArtistID');
foreach ($OldArtists as $ArtistID) {
if (empty($ArtistID)) { continue; }
if (empty($ArtistID)) {
continue;
}
//Get a count of how many groups or requests use the artist ID
$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'");
$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'");
list($ReqCount) = $DB->next_record();
$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'");
$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'");
list($GroupCount) = $DB->next_record();
if (($ReqCount + $GroupCount) == 0) {
//The only group to use this artist
@ -468,15 +480,16 @@
$DB->query("INSERT INTO requests (
UserID, TimeAdded, LastVote, CategoryID, Title, Year, Image, Description, Visible, OCLC)
VALUES
(".$LoggedUser['ID'].", '".sqltime()."', '".sqltime()."', ".$CategoryID.", '".db_string($Title)."', ".$Year.", '".db_string($Image)."', '".db_string($Description)."', '1', '".db_string($OCLC)."')");
(".$LoggedUser['ID'].", '".sqltime()."', '".sqltime()."', $CategoryID, '".db_string($Title)."', $Year, '".db_string($Image)."', '".db_string($Description)."', '1', '".db_string($OCLC)."')");
$RequestID = $DB->inserted_id();
} else {
$DB->query("UPDATE requests
SET CategoryID = ".$CategoryID.",
$DB->query("
UPDATE requests
SET CategoryID = $CategoryID,
Title = '".db_string($Title)."',
Year = ".$Year.",
Year = $Year,
Image = '".db_string($Image)."',
Description = '".db_string($Description)."',
OCLC = '".db_string($OCLC)."'
@ -484,21 +497,23 @@
}
} else {
if ($NewRequest) {
$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)."')");
$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)."')");
$RequestID = $DB->inserted_id();
} else {
$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);
$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);
}
}
}
@ -516,7 +531,7 @@
$DB->query("INSERT INTO tags
(Name, UserID)
VALUES
('".$Tag."', ".$LoggedUser['ID'].")
('$Tag', ".$LoggedUser['ID'].")
ON DUPLICATE KEY UPDATE Uses=Uses+1");
$TagID = $DB->inserted_id();
@ -524,7 +539,7 @@
$DB->query("INSERT IGNORE INTO requests_tags
(TagID, RequestID)
VALUES
(".$TagID.", ".$RequestID.")");
($TagID, $RequestID)");
}
if ($NewRequest) {
@ -532,17 +547,17 @@
$DB->query("INSERT INTO requests_votes
(RequestID, UserID, Bounty)
VALUES
(".$RequestID.", ".$LoggedUser['ID'].", ".($Bytes * (1 - $RequestTax)).")");
($RequestID, ".$LoggedUser['ID'].', '.($Bytes * (1 - $RequestTax)).')');
$DB->query("UPDATE users_main SET Uploaded = (Uploaded - ".$Bytes.") WHERE ID = ".$LoggedUser['ID']);
$DB->query("UPDATE users_main SET Uploaded = (Uploaded - $Bytes) WHERE ID = ".$LoggedUser['ID']);
$Cache->delete_value('user_stats_'.$LoggedUser['ID']);
if ($CategoryName == "Music") {
$Announce = "'".$Title."' - ".Artists::display_artists($ArtistForm, false, false)." https://".SSL_SITE_URL."/requests.php?action=view&id=".$RequestID." - ".implode(" ", $Tags);
if ($CategoryName == 'Music') {
$Announce = "\"$Title\" - ".Artists::display_artists($ArtistForm, false, false).' https://'.SSL_SITE_URL."/requests.php?action=view&id=$RequestID - ".implode(' ', $Tags);
} else {
$Announce = "'".$Title."' - https://".SSL_SITE_URL."/requests.php?action=view&id=".$RequestID." - ".implode(" ", $Tags);
$Announce = "\"$Title\" - https://".SSL_SITE_URL."/requests.php?action=view&id=$RequestID - ".implode(' ', $Tags);
}
send_irc('PRIVMSG #'.SSL_SITE_URL.'-requests :'.$Announce);

View File

@ -5,11 +5,12 @@
authorize();
$RequestID = $_POST['id'];
if(!is_number($RequestID)){
if (!is_number($RequestID)) {
error(0);
}
$DB->query("SELECT
$DB->query("
SELECT
r.CategoryID,
r.UserID,
r.FillerID,
@ -21,21 +22,22 @@
WHERE r.ID= ".$RequestID);
list($CategoryID, $UserID, $FillerID, $Title, $Uploaded, $GroupID) = $DB->next_record();
if((($LoggedUser['ID'] != $UserID && $LoggedUser['ID'] != $FillerID) && !check_perms('site_moderate_requests')) || $FillerID == 0) {
if ((($LoggedUser['ID'] != $UserID && $LoggedUser['ID'] != $FillerID) && !check_perms('site_moderate_requests')) || $FillerID == 0) {
error(403);
}
// Unfill
$DB->query("UPDATE requests SET
TorrentID = 0,
FillerID = 0,
TimeFilled = '0000-00-00 00:00:00',
Visible = 1
WHERE ID = ".$RequestID);
$DB->query("
UPDATE requests
SET TorrentID = 0,
FillerID = 0,
TimeFilled = '0000-00-00 00:00:00',
Visible = 1
WHERE ID = ".$RequestID);
$CategoryName = $Categories[$CategoryID - 1];
if($CategoryName == "Music") {
if ($CategoryName == 'Music') {
$ArtistForm = get_request_artists($RequestID);
$ArtistName = Artists::display_artists($ArtistForm, false, true);
$FullName = $ArtistName.$Title;
@ -47,20 +49,20 @@
if ($RequestVotes['TotalBounty'] > $Uploaded) {
// If we can't take it all out of upload, zero that out and add whatever is left as download.
$DB->query("UPDATE users_main SET Uploaded = 0 WHERE ID = ".$FillerID);
$DB->query("UPDATE users_main SET Downloaded = Downloaded + ".($RequestVotes['TotalBounty']-$Uploaded)." WHERE ID = ".$FillerID);
$DB->query('UPDATE users_main SET Uploaded = 0 WHERE ID = '.$FillerID);
$DB->query('UPDATE users_main SET Downloaded = Downloaded + '.($RequestVotes['TotalBounty'] - $Uploaded).' WHERE ID = '.$FillerID);
} else {
$DB->query("UPDATE users_main SET Uploaded = Uploaded - ".$RequestVotes['TotalBounty']." WHERE ID = ".$FillerID);
$DB->query('UPDATE users_main SET Uploaded = Uploaded - '.$RequestVotes['TotalBounty'].' WHERE ID = '.$FillerID);
}
Misc::send_pm($FillerID, 0, "A request you filled has been unfilled", "The request '[url=https://".SSL_SITE_URL."/requests.php?action=view&amp;id=".$RequestID."]".$FullName."[/url]' was unfilled by [url=https://".SSL_SITE_URL."/user.php?id=".$LoggedUser['ID']."]".$LoggedUser['Username']."[/url] for the reason: ".$_POST['reason']);
Misc::send_pm($FillerID, 0, 'A request you filled has been unfilled', "The request \"[url=https://".SSL_SITE_URL."/requests.php?action=view&amp;id=$RequestID]".$FullName."[/url]\" was unfilled by [url=https://".SSL_SITE_URL.'/user.php?id='.$LoggedUser['ID'].']'.$LoggedUser['Username']."[/url] for the reason: ".$_POST['reason']);
$Cache->delete_value('user_stats_'.$FillerID);
if($UserID != $LoggedUser['ID']) {
Misc::send_pm($UserID, 0, "A request you created has been unfilled", "The request '[url=https://".SSL_SITE_URL."/requests.php?action=view&amp;id=".$RequestID."]".$FullName."[/url]' was unfilled by [url=https://".SSL_SITE_URL."/user.php?id=".$LoggedUser['ID']."]".$LoggedUser['Username']."[/url] for the reason: ".$_POST['reason']);
if ($UserID != $LoggedUser['ID']) {
Misc::send_pm($UserID, 0, 'A request you created has been unfilled', "The request \"[url=https://".SSL_SITE_URL."/requests.php?action=view&amp;id=$RequestID]".$FullName."[/url]\" was unfilled by [url=https://".SSL_SITE_URL.'/user.php?id='.$LoggedUser['ID'].']'.$LoggedUser['Username']."[/url] for the reason: ".$_POST['reason']);
}
Misc::write_log("Request $RequestID ($FullName), with a ".Format::get_size($RequestVotes['TotalBounty'])." bounty, was unfilled by user ".$LoggedUser['ID']." (".$LoggedUser['Username'].") for the reason: ".$_POST['reason']);
Misc::write_log("Request $RequestID ($FullName), with a ".Format::get_size($RequestVotes['TotalBounty']).' bounty, was unfilled by user '.$LoggedUser['ID'].' ('.$LoggedUser['Username'].') for the reason: '.$_POST['reason']);
$Cache->delete_value('request_'.$RequestID);
$Cache->delete_value('request_artists_'.$RequestID);
@ -70,9 +72,9 @@
Requests::update_sphinx_requests($RequestID);
if(!empty($ArtistForm)) {
foreach($ArtistForm as $ArtistType) {
foreach($ArtistType as $Artist) {
if (!empty($ArtistForm)) {
foreach ($ArtistForm as $ArtistType) {
foreach ($ArtistType as $Artist) {
$Cache->delete_value('artists_requests_'.$Artist['id']);
}
}

View File

@ -3,19 +3,19 @@
//--------------- Vote on a request --------------------------------------------//
//This page is ajax!
if(!check_perms('site_vote')) {
if (!check_perms('site_vote')) {
error(403);
}
authorize();
if(empty($_GET['id']) || !is_number($_GET['id'])) {
if (empty($_GET['id']) || !is_number($_GET['id'])) {
error(0);
}
$RequestID = $_GET['id'];
if(empty($_GET['amount']) || !is_number($_GET['amount']) || $_GET['amount'] < $MinimumVote) {
if (empty($_GET['amount']) || !is_number($_GET['amount']) || $_GET['amount'] < $MinimumVote) {
$Amount = $MinimumVote;
} else {
$Amount = $_GET['amount'];
@ -26,25 +26,26 @@
$DB->query('SELECT TorrentID FROM requests WHERE ID='.$RequestID);
list($Filled) = $DB->next_record();
if($LoggedUser['BytesUploaded'] >= $Amount && $Filled == 0){
if ($LoggedUser['BytesUploaded'] >= $Amount && $Filled == 0) {
// Create vote!
$DB->query("INSERT IGNORE INTO requests_votes
(RequestID, UserID, Bounty)
VALUES
(".$RequestID.", ".$LoggedUser['ID'].", ".$Bounty.")");
$DB->query("
INSERT IGNORE INTO requests_votes
(RequestID, UserID, Bounty)
VALUES
($RequestID, ".$LoggedUser['ID'].", $Bounty)");
if($DB->affected_rows() < 1) {
if ($DB->affected_rows() < 1) {
//Insert failed, probably a dupe vote, just increase their bounty.
$DB->query("UPDATE requests_votes
SET Bounty = (Bounty + ".$Bounty.")
WHERE
UserID = ".$LoggedUser['ID']."
AND RequestID = ".$RequestID);
$DB->query("
UPDATE requests_votes
SET Bounty = (Bounty + $Bounty)
WHERE UserID = ".$LoggedUser['ID']."
AND RequestID = ".$RequestID);
echo 'dupe';
}
$DB->query("UPDATE requests SET LastVote = NOW() WHERE ID = ".$RequestID);
@ -52,19 +53,19 @@
$Cache->delete_value('request_votes_'.$RequestID);
$ArtistForm = get_request_artists($RequestID);
foreach($ArtistForm as $Importance) {
foreach($Importance as $Artist) {
foreach ($ArtistForm as $Importance) {
foreach ($Importance as $Artist) {
$Cache->delete_value('artists_requests_'.$Artist['id']);
}
}
// Subtract amount from user
$DB->query("UPDATE users_main SET Uploaded = (Uploaded - ".$Amount.") WHERE ID = ".$LoggedUser['ID']);
$DB->query("UPDATE users_main SET Uploaded = (Uploaded - $Amount) WHERE ID = ".$LoggedUser['ID']);
$Cache->delete_value('user_stats_'.$LoggedUser['ID']);
Requests::update_sphinx_requests($RequestID);
echo 'success';
} elseif($LoggedUser['BytesUploaded'] < $Amount) {
} elseif ($LoggedUser['BytesUploaded'] < $Amount) {
echo 'bankrupt';
}

View File

@ -334,13 +334,14 @@ function next_hour() {
// If a user has downloaded more than 10 GiBs while on ratio watch, disable leeching privileges and send the user a message
$DB->query("SELECT ID
FROM users_info AS i
JOIN users_main AS m ON m.ID=i.UserID
WHERE i.RatioWatchEnds!='0000-00-00 00:00:00'
AND i.RatioWatchDownload+10*1024*1024*1024<m.Downloaded
AND m.Enabled='1'
AND m.can_leech='1'");
$DB->query("
SELECT ID
FROM users_info AS i
JOIN users_main AS m ON m.ID=i.UserID
WHERE i.RatioWatchEnds!='0000-00-00 00:00:00'
AND i.RatioWatchDownload+10*1024*1024*1024<m.Downloaded
AND m.Enabled='1'
AND m.can_leech='1'");
$UserIDs = $DB->collect('ID');
if (count($UserIDs) > 0) {
@ -351,11 +352,12 @@ function next_hour() {
send_irc('PRIVMSG #reports :!leechdisabled Downloaded 10 GB+ on Ratio Watch. https://'.SSL_SITE_URL."/user.php?id=$UserID");
}
$DB->query("UPDATE users_info AS i
JOIN users_main AS m ON m.ID=i.UserID
SET m.can_leech='0',
i.AdminComment=CONCAT('$sqltime - Leech disabled by ratio watch system for downloading more than 10 GBs on ratio watch. - required ratio: ', m.RequiredRatio,'', i.AdminComment)
WHERE m.ID IN(".implode(',',$UserIDs).")");
$DB->query("
UPDATE users_info AS i
JOIN users_main AS m ON m.ID=i.UserID
SET m.can_leech='0',
i.AdminComment=CONCAT('$sqltime - Leeching privileges disabled by ratio watch system for downloading more than 10 GBs on ratio watch. - required ratio: ', m.RequiredRatio, '\n\n', i.AdminComment)
WHERE m.ID IN(".implode(',',$UserIDs).')');
}
}

View File

@ -537,7 +537,10 @@ function check_paranoia_here($Setting) {
</tr>
<tr>
<?
foreach ($RecentSnatches as $RS) { ?>
foreach ($RecentSnatches as $RS) {
if (check_perms('site_proxy_images')) {
$RS['WikiImage'] = 'http'.($SSL?'s':'').'://'.SITE_URL.'/image.php?i='.urlencode($RS['WikiImage']);
} ?>
<td>
<a href="torrents.php?id=<?=$RS['ID']?>" title="<?=display_str($RS['Artist'])?><?=display_str($RS['Name'])?>"><img src="<?=ImageTools::thumbnail($RS['WikiImage'])?>" alt="<?=display_str($RS['Artist'])?><?=display_str($RS['Name'])?>" width="107" /></a>
</td>
@ -578,7 +581,10 @@ function check_paranoia_here($Setting) {
<td colspan="5">Recent uploads</td>
</tr>
<tr>
<? foreach ($RecentUploads as $RU) { ?>
<? foreach ($RecentUploads as $RU) {
if (check_perms('site_proxy_images')) {
$RU['WikiImage'] = 'http'.($SSL?'s':'').'://'.SITE_URL.'/image.php?i='.urlencode($RU['WikiImage']);
} ?>
<td>
<a href="torrents.php?id=<?=$RU['ID']?>" title="<?=$RU['Artist']?><?=$RU['Name']?>"><img src="<?=ImageTools::thumbnail($RU['WikiImage'])?>" alt="<?=$RU['Artist']?><?=$RU['Name']?>" width="107" /></a>
</td>
@ -622,6 +628,10 @@ function check_paranoia_here($Setting) {
$Name = '';
$Name .= Artists::display_artists(array('1'=>$Artists), false, true);
$Name .= $GroupName;
if (check_perms('site_proxy_images')) {
$C['WikiImage'] = 'http'.($SSL?'s':'').'://'.SITE_URL.'/image.php?i='.urlencode($C['WikiImage']);
}
?>
<td>
<a href="torrents.php?id=<?=$GroupID?>" title="<?=$Name?>"><img src="<?=ImageTools::thumbnail($C['WikiImage'])?>" alt="<?=$Name?>" width="107" /></a>