Empty commit

This commit is contained in:
Git 2013-07-04 08:00:56 +00:00
parent f86bb1f066
commit 888e8708d4
83 changed files with 2323 additions and 1749 deletions

0
CONTRIBUTING.md Normal file
View File

View File

@ -199,7 +199,7 @@ function music_form($GenreTags) {
foreach ($Torrent['Artists'] as $Importance => $Artists) {
foreach ($Artists as $Artist) {
?>
<input type="text" id="artist" name="artists[]" size="45" value="<?=display_str($Artist['name']) ?>" onblur="CheckVA();" <? Users::has_autocomplete_enabled('other'); ?> <?=$this->Disabled?> />
<input type="text" id="artist" name="artists[]" size="45" value="<?=display_str($Artist['name']) ?>" onblur="CheckVA();"<? Users::has_autocomplete_enabled('other'); ?><?=$this->Disabled?> />
<select id="importance" name="importance[]"<?=$this->Disabled?>>
<option value="1"<?=($Importance == '1' ? ' selected="selected"' : '')?>>Main</option>
<option value="2"<?=($Importance == '2' ? ' selected="selected"' : '')?>>Guest</option>
@ -220,7 +220,7 @@ function music_form($GenreTags) {
}
} else {
?>
<input type="text" id="artist" name="artists[]" size="45" onblur="CheckVA();" <? Users::has_autocomplete_enabled('other'); ?> <?=$this->Disabled?> />
<input type="text" id="artist" name="artists[]" size="45" onblur="CheckVA();"<? Users::has_autocomplete_enabled('other'); ?><?=$this->Disabled?> />
<select id="importance" name="importance[]"<?=$this->Disabled?>>
<option value="1">Main</option>
<option value="2">Guest</option>
@ -586,9 +586,9 @@ function show() {
<? } ?>
</select>
<? } ?>
<input type="text" id="tags" name="tags" size="40" value="<?=display_str($Torrent['TagList']) ?>" <? Users::has_autocomplete_enabled('other'); ?> <?=$this->Disabled?> />
<input type="text" id="tags" name="tags" size="40" value="<?=display_str($Torrent['TagList']) ?>"<? Users::has_autocomplete_enabled('other'); ?><?=$this->Disabled?> />
<br />
<? Rules::display_site_tag_rules(true) // indent the opening PHP tag with 3 tabs for proper HTML generation ?>
<? Rules::display_site_tag_rules(true); ?>
</td>
</tr>
<tr>
@ -694,7 +694,7 @@ function audiobook_form() {
<tr>
<td class="label">Tags:</td>
<td>
<input type="text" id="tags" name="tags" size="60" value="<?=display_str($Torrent['TagList']) ?>" <? Users::has_autocomplete_enabled('other'); ?> />
<input type="text" id="tags" name="tags" size="60" value="<?=display_str($Torrent['TagList']) ?>"<? Users::has_autocomplete_enabled('other'); ?> />
</td>
</tr>
<tr>
@ -736,7 +736,7 @@ function simple_form($CategoryID) {
</tr>
<tr>
<td class="label">Tags:</td>
<td><input type="text" id="tags" name="tags" size="60" value="<?=display_str($Torrent['TagList']) ?>" <? Users::has_autocomplete_enabled('other'); ?>/></td>
<td><input type="text" id="tags" name="tags" size="60" value="<?=display_str($Torrent['TagList']) ?>"<? Users::has_autocomplete_enabled('other'); ?> /></td>
</tr>
<tr>
<td class="label">Image (optional):</td>

View File

@ -269,11 +269,11 @@ public static function update_site_options($UserID, $NewOptions) {
/**
* Generates a check list of release types, ordered by the user or default
* @global array $SiteOptions
* @param array $SiteOptions
* @param boolean $Default Returns the default list if true
*/
public static function release_order ($Default = false) {
global $SiteOptions, $ReleaseTypes;
public static function release_order(&$SiteOptions, $Default = false) {
global $ReleaseTypes;
$RT = $ReleaseTypes + array(
1024 => 'Guest Appearance',
@ -286,6 +286,12 @@ public static function release_order ($Default = false) {
$Defaults = !empty($SiteOptions['HideTypes']);
} else {
$Sort =& $SiteOptions['SortHide'];
$MissingTypes = array_diff_key($ReleaseTypes, $Sort);
if (!empty($MissingTypes)) {
foreach (array_keys($MissingTypes) as $Missing) {
$Sort[$Missing] = 0;
}
}
}
foreach ($Sort as $Key => $Val) {
@ -312,9 +318,9 @@ public static function release_order ($Default = false) {
* Returns the default order for the sort list in a JS-friendly string
* @return string
*/
public static function release_order_default_js () {
public static function release_order_default_js(&$SiteOptions) {
ob_start();
self::release_order(true);
self::release_order($SiteOptions, true);
$HTML = ob_get_contents();
ob_end_clean();
return json_encode($HTML);
@ -627,7 +633,7 @@ public static function has_avatars_enabled() {
* 0 - Enabled everywhere (default), 1 - Disabled, 2 - Searches only
*
* @param string $Type the type of the input.
* @param boolean $Output echo out html
* @param boolean $Output echo out HTML
* @return boolean
*/
public static function has_autocomplete_enabled($Type, $Output = true) {
@ -635,9 +641,8 @@ public static function has_autocomplete_enabled($Type, $Output = true) {
$Enabled = false;
if (empty($LoggedUser['AutoComplete'])) {
$Enabled = true;
}
elseif ($LoggedUser['AutoComplete'] !== 1) {
switch($Type) {
} elseif ($LoggedUser['AutoComplete'] !== 1) {
switch ($Type) {
case 'search':
if ($LoggedUser['AutoComplete'] == 2) {
$Enabled = true;
@ -651,7 +656,7 @@ public static function has_autocomplete_enabled($Type, $Output = true) {
}
}
if ($Enabled && $Output) {
echo 'data-gazelle-autocomplete="true"';
echo ' data-gazelle-autocomplete="true"';
}
return $Enabled;
}

View File

@ -637,7 +637,7 @@ class="stat"
<li id="searchbar_artists"><span class="hidden">Artist: </span>
<form class="search_form" name="artists" action="artist.php"
method="get">
<input id="artistsearch" <? Users::has_autocomplete_enabled('search'); ?>
<input id="artistsearch"<? Users::has_autocomplete_enabled('search'); ?>
accesskey="a"
spellcheck="false" autocomplete="off"
onfocus="if (this.value == 'Artists') this.value='';"

View File

@ -1,5 +1,11 @@
CHANGELOG
2013-07-04 by Ajax
added collages to api
2013-07-03 by Ajax
Option to enable/disable autocomplete in user profile settings.
2013-07-01 by alderaan
Serve Google Charts API images over HTTPS

View File

@ -5,6 +5,34 @@ NOTE: The standards defined in this document will likely differ from
what is actually seen in the Gazelle code. This document is the first
step in properly enforcing coding standards throughout the project.
# Table of Contents
1. FILE FORMATTING
2. CODE STYLING
1. Code styling for PHP and JavaScript
2. Code styling for CSS
3. Code styling for SQL
3. NAMING CONVENTIONS
1. Function names
2. Variable names
3. Class names
4. SQL names
5. Miscellaneous names
4. COMMENTS
5. USER INTERFACE
6. EXAMPLES
1. PHP examples
2. CSS examples
3. SQL examples
This document contains the coding standards for Gazelle.
This document is a work-in-progress and is subject to change.
NOTE: The standards defined in this document will likely differ from
what is actually seen in the Gazelle code. This document is the first
step in properly enforcing coding standards throughout the project.
== TABLE OF CONTENTS ==
@ -27,7 +55,7 @@ step in properly enforcing coding standards throughout the project.
6.3 SQL examples
1. FILE FORMATTING
# FILE FORMATTING
Tabs shall always be used for indentation.
@ -41,22 +69,22 @@ File names for PHP, CSS, and JavaScript files shall be all lowercase and
use underscores instead of spaces.
2. CODE STYLING
# CODE STYLING
2.1 Code styling for PHP and JavaScript
## Code styling for PHP and JavaScript
All statement blocks, including functions, shall have the opening brace
at the end of the same line with a space before the brace. The astute
reader will note that this is K&R style with the exception of functions.
There shall be a space between a control structure statement (e.g. if,
elseif, for) and the following parenthesis.
There shall be a space between a control structure statement (e.g. `if`,
`elseif`, `for`) and the following parenthesis.
There shall be a space around conditional operators.
When using ternary operators, spaces shall be used around the operators.
For conditional blocks, "elseif" is to be used instead of "else if".
For conditional blocks, `elseif` is to be used instead of `else if`.
In loops and conditional blocks, there shall be braces even if there is
only one statement.
@ -64,7 +92,7 @@ only one statement.
In loops and conditional blocks, the statement(s) shall be placed on the
following lines.
When opening a PHP statement, "<?" shall be used instead of "<?php".
When opening a PHP statement, `<?` shall be used instead of `<?php`.
Switch cases in index files shall not contain substantial code. The use
of include statements is acceptable.
@ -72,11 +100,11 @@ of include statements is acceptable.
When building strings in PHP, single quotes shall be used when not
printing a variable.
When declaring JavaScript variables, "var" shall always be used.
When declaring JavaScript variables, `var` shall always be used.
2.2 Code styling for CSS
## Code styling for CSS
"property: value;" pairs shall be separated by a space, and the value
`property: value;` pairs shall be separated by a space, and the value
shall be followed by a semi-colon.
Multiple, related CSS selectors with the same declarations shall appear
@ -85,7 +113,7 @@ on multiple lines to improve readability.
The opening brace shall be on the same line as the last related
selector with a space between the selector and the brace.
2.3 Code styling for SQL
## Code styling for SQL
Long SQL queries shall be separated on multiple lines.
@ -96,169 +124,167 @@ part of a JOIN or other complex statement.
Use indents as appropriate to aid readability.
The SQL keywords JOIN, RIGHT JOIN, LEFT JOIN must be indented once from
the SELECT statement.
The SQL keywords `JOIN`, `RIGHT JOIN`, `LEFT JOIN` must be indented once from
the `SELECT` statement.
The SQL keyword AND must be indented once from the WHILE (and similar)
The SQL keyword `AND` must be indented once from the `WHILE` (and similar)
statements.
The "not equal to" operator "!=" must be used instead of the alternative
operator "<>".
The "not equal to" operator `!=` must be used instead of the alternative
operator `<>`.
3. NAMING CONVENTIONS
# NAMING CONVENTIONS
Function, variable, and class names shall always be descriptive.
3.1 Function names
## Function names
PHP function names shall be written in lowercase_with_underscores.
PHP function names shall be written in `lowercase_with_underscores`.
JavaScript function names shall be written in camelCase with a leading
JavaScript function names shall be written in `camelCase` with a leading
lowercase letter.
3.2 Variable names
## Variable names
PHP variable names shall be written in CamelCase with a leading
PHP variable names shall be written in `CamelCase` with a leading
uppercase letter.
JavaScript global-scope variables shall be written in camelCase with a
JavaScript global-scope variables shall be written in `camelCase` with a
leading lowercase letter.
JavaScript local-scope variables shall be written in
lowercase_with_underscores.
`lowercase_with_underscores`.
3.3 Class names
## Class names
PHP class names shall be written in CamelCase with a leading uppercase
PHP class names shall be written in `CamelCase` with a leading uppercase
letter.
PHP class constants shall be written in CamelCase with a leading
PHP class constants shall be written in `CamelCase` with a leading
uppercase letter.
3.4 SQL names
## SQL names
All SQL keywords shall be written in all UPPERCASE.
All SQL table names shall be written in lowercase_with_underscores.
All SQL table names shall be written in `lowercase_with_underscores`.
All SQL column names shall be written in CamelCase with a leading
All SQL column names shall be written in `CamelCase` with a leading
uppercase letter.
All automatically-incremented ID columns shall be named "ID", while the
other columns for ID numbers shall have names like RequestID, TorrentID,
All automatically-incremented ID columns shall be named `ID`, while the
other columns for Identification numbers shall have names like `RequestID`, `TorrentID`,
etc.
3.5 Miscellaneous names
## Miscellaneous names
PHP global constants shall be written in ALL_CAPS.
PHP global constants shall be written in `ALL_CAPS`.
PHP constants true, false, and null shall be written in all lowercase.
PHP constants `true`, `false`, and `null` shall be written in all lowercase.
4. COMMENTS
# COMMENTS
Use C89-style "/* ... */" comments for multi-line comments.
Use C89-style `/* ... */` comments for multi-line comments.
Use C99-style "// ..." comments for single-line comments.
Use C99-style `// ...` comments for single-line comments.
5. USER INTERFACE
# USER INTERFACE
All button labels shall use sentence case.
All table headings shall use sentence case.
All text-based buttons shall use the "brackets" CSS class.
All text-based buttons shall use the `brackets` CSS class.
Use common sense for design-related code. Microsoft's UI design guidelines
explain when certain form input controls should be used over others to
provide a familiar and intuitive interface. Refer to the following links
for the most likely issues to encounter in web design:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa511452.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/aa511453.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/aa511488.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/aa511494.aspx
* http://msdn.microsoft.com/en-us/library/windows/desktop/aa511452.aspx
* http://msdn.microsoft.com/en-us/library/windows/desktop/aa511453.aspx
* http://msdn.microsoft.com/en-us/library/windows/desktop/aa511488.aspx
* http://msdn.microsoft.com/en-us/library/windows/desktop/aa511494.aspx
6. EXAMPLES
# EXAMPLES
6.1 PHP examples
## PHP examples
if ($Foo >= 0) {
$SomeString = "this is a string $DiffString with more text";
} elseif ($Foo == 0) {
// other things happen
} else {
// more magic
}
if ($Foo >= 0) {
$SomeString = "this is a string $DiffString with more text";
} elseif ($Foo == 0) {
// other things happen
} else {
// more magic
}
function works_magic($Foo, $Bar) {
return $Foo;
}
function works_magic($Foo, $Bar) {
return $Foo;
}
echo ($Foo == true ? 'foo is true' : 'foo is false');
echo ($Foo == true ? 'foo is true' : 'foo is false');
if ($Foo == true) {
// magic happens
}
if ($Foo == true) {
// magic happens
}
/*
* This is a good, multi-line comment.
*
* Please comment your code!
*/
/*
* This is a good, multi-line comment.
*
* Please comment your code!
*/
// This is a good, single-line comment.
// This is a good, single-line comment.
6.2 CSS examples
## CSS examples
<a href="foobar.php" style="font-weight: bold;">link text</a>
<a href="foobar.php" style="font-weight: bold;">link text</a>
.spellcheck {
margin: 10px 0;
font-size: 1.25em;
font-weight: bold;
}
.spellcheck {
margin: 10px 0;
font-size: 1.25em;
font-weight: bold;
}
.linkbox .brackets:before,
.linkbox .brackets:after,
.top10_quantity_links .brackets:before,
.top10_quantity_links .brackets:after {
color: #757575;
}
.linkbox .brackets:before,
.linkbox .brackets:after,
.top10_quantity_links .brackets:before,
.top10_quantity_links .brackets:after {
color: #757575;
}
6.3 SQL examples
# SQL examples
SELECT
r.ID, e.EditionID, r.Title, r.Year, r.CatalogueNumber,
l.Name AS Label, r.LabelID, r.Image, r.MusicBrainzID
FROM releases AS r
JOIN editions AS e ON e.ReleaseID = r.ID
LEFT JOIN labels AS l ON l.ID = r.LabelID
WHERE r.ID IN ($ReleaseIDsSQL)
ORDER BY e.EditionID, r.Year ASC
SELECT
r.ID, e.EditionID, r.Title, r.Year, r.CatalogueNumber,
l.Name AS Label, r.LabelID, r.Image, r.MusicBrainzID
FROM releases AS r
JOIN editions AS e ON e.ReleaseID = r.ID
LEFT JOIN labels AS l ON l.ID = r.LabelID
WHERE r.ID IN ($ReleaseIDsSQL)
ORDER BY e.EditionID, r.Year ASC
SELECT SQL_CALC_FOUND_ROWS c.ID, c.Subject, cu.Unread, cu.Sticky,
cu.ForwardedTo, cu2.UserID, cu.ReceivedDate AS Date
FROM pm_conversations AS c
LEFT JOIN pm_conversations_users AS cu ON cu.ConvID = c.ID
AND cu.UserID = '1'
LEFT JOIN pm_conversations_users AS cu2 ON cu2.ConvID = c.ID
AND cu2.UserID != '1'
AND cu2.ForwardedTo = 0
LEFT JOIN users_main AS um ON um.ID = cu2.UserID
WHERE um.Username LIKE 'test'
AND cu.InInbox = '1'
GROUP BY c.ID
ORDER BY cu.Sticky, Date DESC
LIMIT 25
SELECT SQL_CALC_FOUND_ROWS c.ID, c.Subject, cu.Unread, cu.Sticky,
cu.ForwardedTo, cu2.UserID, cu.ReceivedDate AS Date
FROM pm_conversations AS c
LEFT JOIN pm_conversations_users AS cu ON cu.ConvID = c.ID
AND cu.UserID = '1'
LEFT JOIN pm_conversations_users AS cu2 ON cu2.ConvID = c.ID
AND cu2.UserID != '1'
AND cu2.ForwardedTo = 0
LEFT JOIN users_main AS um ON um.ID = cu2.UserID
WHERE um.Username LIKE 'test'
AND cu.InInbox = '1'
GROUP BY c.ID
ORDER BY cu.Sticky, Date DESC
LIMIT 25
SELECT RequestID AS ID, UserID FROM bookmarks_requests
EOF
SELECT RequestID AS ID, UserID FROM bookmarks_requests

184
image.php
View File

@ -1,10 +1,5 @@
<?
/*-- Image Start Class ---------------------------------*/
/*------------------------------------------------------*/
/* Simplified version of script_start, used for the */
/* sitewide image proxy. */
/*------------------------------------------------------*/
/********************************************************/
// Functions and headers needed by the image proxy
error_reporting(E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR);
if (isset($_SERVER['http_if_modified_since'])) {
@ -15,35 +10,11 @@
header('Expires: '.date('D, d-M-Y H:i:s \U\T\C', time() + 3600 * 24 * 120)); // 120 days
header('Last-Modified: '.date('D, d-M-Y H:i:s \U\T\C', time()));
require('classes/config.php'); // The config contains all site wide configuration information as well as memcached rules
if (!extension_loaded('gd')) {
error('nogd');
}
require(SERVER_ROOT.'/classes/cache.class.php'); // Require the caching class
require(SERVER_ROOT.'/classes/encrypt.class.php'); // Require the encryption class
require(SERVER_ROOT.'/classes/regex.php');
$Cache = NEW CACHE($MemcachedServers); // Load the caching class
$Enc = NEW CRYPT; // Load the encryption class
if (isset($_COOKIE['session'])) {
$LoginCookie = $Enc->decrypt($_COOKIE['session']);
}
if (isset($LoginCookie)) {
list($SessionID, $UserID) = explode('|~|', $Enc->decrypt($LoginCookie));
$UserID = (int)$UserID;
$UserInfo = $Cache->get_value("user_info_$UserID");
$Permissions = $Cache->get_value('perm_'.$UserInfo['PermissionID']);
}
function check_perms($PermissionName) {
global $Permissions;
return (isset($Permissions['Permissions'][$PermissionName])) ? true : false;
}
function error($Type) {
function img_error($Type) {
header('Content-type: image/gif');
die(file_get_contents(SERVER_ROOT.'/sections/image/'.$Type.'.gif'));
}
@ -62,16 +33,6 @@ function invisible($Image) {
}
function is_number($Str) {
$Return = true;
if ($Str < 0) {
$Return = false;
}
// We're converting input to a int, then string and comparing to original
$Return = ($Str == strval(intval($Str)) ? true : false);
return $Return;
}
function verysmall($Image) {
return ((imagesx($Image) * imagesy($Image)) < 25) ? true : false;
}
@ -136,144 +97,5 @@ function image_height($Type, $Data) {
}
}
function send_pm($ToID, $FromID, $Subject, $Body, $ConvID = '') {
global $DB, $Cache;
if ($ToID == 0) {
// Don't allow users to send messages to the system
return;
}
if ($ConvID == '') {
$DB->query("
INSERT INTO pm_conversations (Subject)
VALUES ('$Subject')");
$ConvID = $DB->inserted_id();
$DB->query("
INSERT INTO pm_conversations_users
(UserID, ConvID, InInbox, InSentbox, SentDate, ReceivedDate, UnRead)
VALUES
('$ToID', '$ConvID', '1', '0', '".sqltime()."', '".sqltime()."', '1')");
if ($FromID != 0) {
$DB->query("
INSERT INTO pm_conversations_users
(UserID, ConvID, InInbox, InSentbox, SentDate, ReceivedDate, UnRead)
VALUES
('$FromID', '$ConvID', '0', '1', '".sqltime()."', '".sqltime()."', '0')");
}
} else {
$DB->query("
UPDATE pm_conversations_users
SET
InInbox = '1',
UnRead = '1',
ReceivedDate = '".sqltime()."'
WHERE UserID = '$ToID'
AND ConvID = '$ConvID'");
$DB->query("
UPDATE pm_conversations_users
SET
InSentbox = '1',
SentDate = '".sqltime()."'
WHERE UserID = '$FromID'
AND ConvID = '$ConvID'");
}
$DB->query("
INSERT INTO pm_messages
(SenderID, ConvID, SentDate, Body)
VALUES
('$FromID', '$ConvID', '".sqltime()."', '$Body')");
// Clear the caches of the inbox and sentbox
/*$DB->query("
SELECT UnRead
FROM pm_conversations_users
WHERE ConvID = '$ConvID'
AND UserID = '$ToID'");
*/
$DB->query("
SELECT COUNT(ConvID)
FROM pm_conversations_users
WHERE UnRead = '1'
AND UserID = '$ToID'
AND InInbox = '1'");
list($UnRead) = $DB->next_record(MYSQLI_BOTH, FALSE);
$Cache->cache_value("inbox_new_$ToID", $UnRead);
//if ($UnRead == 0) {
// $Cache->increment("inbox_new_$ToID");
//}
return $ConvID;
}
function send_irc($Raw) {
$IRCSocket = fsockopen(SOCKET_LISTEN_ADDRESS, SOCKET_LISTEN_PORT);
fwrite($IRCSocket, $Raw);
fclose($IRCSocket);
}
function display_str($Str) {
if ($Str === NULL || $Str === false || is_array($Str)) {
return '';
}
if ($Str != '' && !is_number($Str)) {
$Str = make_utf8($Str);
$Str = mb_convert_encoding($Str, 'HTML-ENTITIES', 'UTF-8');
$Str = preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/m", '&amp;', $Str);
$Replace = array(
"'",'"',"<",">",
'&#128;','&#130;','&#131;','&#132;','&#133;','&#134;','&#135;','&#136;',
'&#137;','&#138;','&#139;','&#140;','&#142;','&#145;','&#146;','&#147;',
'&#148;','&#149;','&#150;','&#151;','&#152;','&#153;','&#154;','&#155;',
'&#156;','&#158;','&#159;'
);
$With = array(
'&#39;','&quot;','&lt;','&gt;',
'&#8364;','&#8218;','&#402;','&#8222;','&#8230;','&#8224;','&#8225;','&#710;',
'&#8240;','&#352;','&#8249;','&#338;','&#381;','&#8216;','&#8217;','&#8220;',
'&#8221;','&#8226;','&#8211;','&#8212;','&#732;','&#8482;','&#353;','&#8250;',
'&#339;','&#382;','&#376;'
);
$Str = str_replace($Replace, $With, $Str);
}
return $Str;
}
function make_utf8($Str) {
if ($Str != '') {
if (is_utf8($Str)) {
$Encoding = 'UTF-8';
}
if (empty($Encoding)) {
$Encoding = mb_detect_encoding($Str, 'UTF-8, ISO-8859-1');
}
if (empty($Encoding)) {
$Encoding = 'ISO-8859-1';
}
if ($Encoding == 'UTF-8') {
return $Str;
} else {
return @mb_convert_encoding($Str, 'UTF-8', $Encoding);
}
}
}
function is_utf8($Str) {
return preg_match('%^(?:
[\x09\x0A\x0D\x20-\x7E] // ASCII
| [\xC2-\xDF][\x80-\xBF] // non-overlong 2-byte
| \xE0[\xA0-\xBF][\x80-\xBF] // excluding overlongs
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} // straight 3-byte
| \xED[\x80-\x9F][\x80-\xBF] // excluding surrogates
| \xF0[\x90-\xBF][\x80-\xBF]{2} // planes 1-3
| [\xF1-\xF3][\x80-\xBF]{3} // planes 4-15
| \xF4[\x80-\x8F][\x80-\xBF]{2} // plane 16
)*$%xs', $Str
);
}
require(SERVER_ROOT.'/sections/image/index.php');
require('classes/script_start.php'); // script_start contains all we need and includes sections/image/index.php
?>

59
sections/ajax/collage.php Normal file
View File

@ -0,0 +1,59 @@
<?
include(SERVER_ROOT.'/classes/text.class.php'); // Text formatting class
$Text = new TEXT;
if (empty($_GET['id'])) {
json_die("failure", "bad parameters");
}
$CollageID = $_GET['id'];
if ($CollageID && !is_number($CollageID)) {
json_die("failure");
}
$CacheKey = "collage_$CollageID";
$Data = $Cache->get_value($CacheKey);
if ($Data) {
list($K, list($Name, $Description, , , , $Deleted, $CollageCategoryID, $CreatorID, $Locked, $MaxGroups, $MaxGroupsPerUser)) = each($Data);
} else {
$sql = "
SELECT
Name,
Description,
UserID,
Deleted,
CategoryID,
Locked,
MaxGroups,
MaxGroupsPerUser,
Subscribers
FROM collages
WHERE ID='$CollageID'";
$DB->query($sql);
if ($DB->record_count() == 0) {
json_die("failure");
}
list($Name, $Description, $CreatorID, $Deleted, $CollageCategoryID, $Locked, $MaxGroups, $MaxGroupsPerUser) = $DB->next_record();
}
$Cache->cache_value($CacheKey, array(array($Name, $Description, array(), array(), array(), $Deleted, $CollageCategoryID, $CreatorID, $Locked, $MaxGroups, $MaxGroupsPerUser)), 3600);
json_die("success", array(
'id' => (int) $CollageID,
'name' => $Name,
'description' => $Text->full_format($Description),
'creatorID' => (int) $CreatorID,
'deleted' => (bool) $Deleted,
'collageCategoryID' => (int) $CollageCategoryID,
'locked' => (bool) $Locked,
'categoryID' => (int) $CategoryID,
'maxGroups' => (int) $MaxGroups,
'maxGroupsPerUser' => (int) $MaxGroupsPerUser,
'hasBookmarked' => Bookmarks::has_bookmarked('collage', $CollageID),
'cached' => (bool) $Cached,
));
?>

View File

@ -13,7 +13,7 @@
/* AJAX_LIMIT = array(x,y) = 'x' requests every 'y' seconds.
e.g. array(5,10) = 5 requests every 10 seconds */
$AJAX_LIMIT = array(5,10);
$LimitedPages = array('tcomments','user','forum','top10','browse','usersearch','requests','artist','inbox','subscriptions','bookmarks','announcements','notifications','request','better','similar_artists','userhistory','votefavorite','wiki','torrentgroup','news_ajax','user_recents');
$LimitedPages = array('tcomments','user','forum','top10','browse','usersearch','requests','artist','inbox','subscriptions','bookmarks','announcements','notifications','request','better','similar_artists','userhistory','votefavorite','wiki','torrentgroup','news_ajax','user_recents', 'collage');
// These users aren't rate limited.
// This array should contain user IDs.
@ -158,6 +158,9 @@
case 'user_recents':
require(SERVER_ROOT . '/sections/ajax/user_recents.php');
break;
case 'collage':
require(SERVER_ROOT . '/sections/ajax/collage.php');
break;
default:
// If they're screwing around with the query string
json_die("failure");

View File

@ -3,7 +3,6 @@
include(SERVER_ROOT.'/classes/text.class.php'); // Text formatting class
$Text = new TEXT(true);
if (!empty($_POST['AdminComment'])) {
echo $Text->full_format($_POST['AdminComment']);
} else {

View File

@ -14,7 +14,7 @@
empty($_GET['key']) ||
!is_number($_GET['uid']) ||
!is_number($_GET['aid']) ||
!in_array($_GET['req'],$Available,true)
!in_array($_GET['req'], $Available, true)
) {
error('invalid');
}
@ -23,15 +23,19 @@
$AppID = $_GET['aid'];
$UserID = $_GET['uid'];
$App = $Cache->get_value('api_apps_'.$AppID);
$App = $Cache->get_value("api_apps_$AppID");
if (!is_array($App)) {
if (!isset($DB)) {
require(SERVER_ROOT.'/classes/mysql.class.php');
$DB = new DB_MYSQL;
}
$DB->query("SELECT Token, Name FROM api_applications WHERE ID='$AppID' LIMIT 1");
$App = $DB->to_array(false,MYSQLI_ASSOC);
$Cache->cache_value('api_apps_'.$AppID, $App, 0);
$DB->query("
SELECT Token, Name
FROM api_applications
WHERE ID = '$AppID'
LIMIT 1");
$App = $DB->to_array(false, MYSQLI_ASSOC);
$Cache->cache_value("api_apps_$AppID", $App, 0);
}
$App = $App[0];
@ -41,7 +45,7 @@
error('invalid');
}
} else {
$User = $Cache->get_value('api_users_'.$UserID);
$User = $Cache->get_value("api_users_$UserID");
if (!is_array($User)) {
if (!isset($DB)) {
require(SERVER_ROOT.'/classes/mysql.class.php');
@ -50,14 +54,14 @@
$DB->query("
SELECT AppID, Token, State, Time, Access
FROM api_users
WHERE UserID='$UserID'
WHERE UserID = '$UserID'
LIMIT 1"); //int, no db_string
$User = $DB->to_array('AppID',MYSQLI_ASSOC);
$Cache->cache_value('api_users_'.$UserID, $User, 0);
$User = $DB->to_array('AppID', MYSQLI_ASSOC);
$Cache->cache_value("api_users_$UserID", $User, 0);
}
$User = $User[$AppID];
if (md5($User['Token'].$App['Token']) !== $_GET['key']) {
if (md5($User['Token'] . $App['Token']) !== $_GET['key']) {
error('invalid');
}
}

View File

@ -696,7 +696,7 @@ function compare($X, $Y) {
<input type="hidden" name="action" value="add_similar" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="artistid" value="<?=$ArtistID?>" />
<input type="text" autocomplete="off" id="artistsimilar" name="artistname" size="20" <? Users::has_autocomplete_enabled('other'); ?>/>
<input type="text" autocomplete="off" id="artistsimilar" name="artistname" size="20"<? Users::has_autocomplete_enabled('other'); ?> />
<input type="submit" value="+" />
</form>
</li>

View File

@ -180,7 +180,7 @@
<tr id="tagfilter">
<td class="label">Tags (comma-separated):</td>
<td>
<input type="text" id="tags" name="tags" size="70" value="<?=(!empty($_GET['tags']) ? display_str($_GET['tags']) : '')?> <? Users::has_autocomplete_enabled('other'); ?>" />&nbsp;
<input type="text" id="tags" name="tags" size="70" value="<?=(!empty($_GET['tags']) ? display_str($_GET['tags']) : '')?>"<? Users::has_autocomplete_enabled('other'); ?> />&nbsp;
<input type="radio" name="tags_type" id="tags_type0" value="0"<?Format::selected('tags_type',0,'checked')?> /><label for="tags_type0"> Any</label>&nbsp;&nbsp;
<input type="radio" name="tags_type" id="tags_type1" value="1"<?Format::selected('tags_type',1,'checked')?> /><label for="tags_type1"> All</label>
</td>

View File

@ -18,7 +18,10 @@ function btc_balance() {
function btc_address($UserID, $GenAddress = false) {
global $DB;
$UserID = (int)$UserID;
$DB->query("SELECT BitcoinAddress FROM users_info WHERE UserID = '$UserID'");
$DB->query("
SELECT BitcoinAddress
FROM users_info
WHERE UserID = '$UserID'");
list($Addr) = $DB->next_record();
if (!empty($Addr)) {

View File

@ -4,7 +4,10 @@
//Include the header
if (!$UserCount = $Cache->get_value('stats_user_count')) {
$DB->query("SELECT COUNT(ID) FROM users_main WHERE Enabled='1'");
$DB->query("
SELECT COUNT(ID)
FROM users_main
WHERE Enabled = '1'");
list($UserCount) = $DB->next_record();
$Cache->cache_value('stats_user_count', $UserCount, 0); //inf cache
}

View File

@ -8,7 +8,10 @@
}
if (!$UserCount = $Cache->get_value('stats_user_count')) {
$DB->query("SELECT COUNT(ID) FROM users_main WHERE Enabled='1'");
$DB->query("
SELECT COUNT(ID)
FROM users_main
WHERE Enabled = '1'");
list($UserCount) = $DB->next_record();
$Cache->cache_value('stats_user_count', $UserCount, 0); //inf cache
}
@ -28,7 +31,7 @@
<form class="donate_form" name="test_paypal" method="post" action="donate.php">
<input type="hidden" name="action" value="ipn" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<?=PAYPAL_SYMBOL?> <input type="text" name="mc_gross" value="<?=number_format(PAYPAL_MINIMUM,2)?>" />
<?=PAYPAL_SYMBOL?> <input type="text" name="mc_gross" value="<?=number_format(PAYPAL_MINIMUM, 2)?>" />
<input type="hidden" name="custom" value="<?=$LoggedUser['ID']?>" />
<input type="hidden" name="payment_status" value="Completed" />
<input type="hidden" name="mc_fee" value="0.45" />

View File

@ -25,9 +25,12 @@
if (!$Enabled = $Cache->get_value('enabled_'.$User)) {
require(SERVER_ROOT.'/classes/mysql.class.php');
$DB=NEW DB_MYSQL; //Load the database wrapper
$DB->query("SELECT Enabled FROM users_main WHERE ID='$User'");
$DB->query("
SELECT Enabled
FROM users_main
WHERE ID = '$User'");
list($Enabled) = $DB->next_record();
$Cache->cache_value('enabled_'.$User, $Enabled, 0);
$Cache->cache_value("enabled_$User", $Enabled, 0);
}
if (md5($User.RSS_HASH.$_GET['passkey']) != $_GET['auth'] || $Enabled != 1) {
@ -48,16 +51,17 @@
if (!$News = $Cache->get_value('news')) {
require(SERVER_ROOT.'/classes/mysql.class.php'); //Require the database wrapper
$DB=NEW DB_MYSQL; //Load the database wrapper
$DB->query("SELECT
ID,
Title,
Body,
Time
$DB->query("
SELECT
ID,
Title,
Body,
Time
FROM news
ORDER BY Time DESC
LIMIT 10");
$News = $DB->to_array(false,MYSQLI_NUM,false);
$Cache->cache_value('news',$News,1209600);
$News = $DB->to_array(false, MYSQLI_NUM, false);
$Cache->cache_value('news', $News, 1209600);
}
$Count = 0;
foreach ($News as $NewsItem) {
@ -65,7 +69,7 @@
if (strtotime($NewsTime) >= time()) {
continue;
}
echo $Feed->item($Title, $Text->strip_bbcode($Body), 'index.php#news'.$NewsID, SITE_NAME.' Staff','','',$NewsTime);
echo $Feed->item($Title, $Text->strip_bbcode($Body), "index.php#news$NewsID", SITE_NAME.' Staff', '', '', $NewsTime);
if (++$Count > 4) {
break;
}
@ -87,18 +91,18 @@
b.Time,
b.ThreadID
FROM blog AS b
LEFT JOIN users_main AS um ON b.UserID=um.ID
LEFT JOIN users_main AS um ON b.UserID = um.ID
ORDER BY Time DESC
LIMIT 20");
$Blog = $DB->to_array();
$Cache->cache_value('Blog',$Blog,1209600);
$Cache->cache_value('Blog', $Blog, 1209600);
}
foreach ($Blog as $BlogItem) {
list($BlogID, $Author, $Title, $Body, $BlogTime, $ThreadID) = $BlogItem;
if ($ThreadID) {
echo $Feed->item($Title, $Text->strip_bbcode($Body), 'forums.php?action=viewthread&amp;threadid='.$ThreadID, SITE_NAME.' Staff','','',$BlogTime);
echo $Feed->item($Title, $Text->strip_bbcode($Body), 'forums.php?action=viewthread&amp;threadid='.$ThreadID, SITE_NAME.' Staff', '', '', $BlogTime);
} else {
echo $Feed->item($Title, $Text->strip_bbcode($Body), 'blog.php#blog'.$BlogID, SITE_NAME.' Staff','','',$BlogTime);
echo $Feed->item($Title, $Text->strip_bbcode($Body), "blog.php#blog$BlogID", SITE_NAME.' Staff', '', '', $BlogTime);
}
}
break;
@ -109,84 +113,88 @@
require(SERVER_ROOT.'/classes/misc.class.php');
$DB = NEW DB_MYSQL;
$DB->query("SELECT Message, Author, Date(Time) FROM changelog ORDER BY Time DESC LIMIT 20");
$DB->query("
SELECT Message, Author, Date(Time)
FROM changelog
ORDER BY Time DESC
LIMIT 20");
$Changelog = $DB->to_array();
$Cache->cache_value('changelog', $Changelog, 86400);
}
foreach ($Changelog as $Change) {
list($Message, $Author, $Date) = $Change;
echo $Feed->item($Date . " by " . $Author, $Message, 'tools.php?action=change_log', SITE_NAME.' Staff','','',$Date);
echo $Feed->item("$Date by $Author", $Message, 'tools.php?action=change_log', SITE_NAME.' Staff', '', '', $Date);
}
break;
case 'torrents_all':
$Feed->channel('All Torrents', 'RSS feed for all new torrent uploads.');
$Feed->retrieve('torrents_all',$_GET['authkey'],$_GET['passkey']);
$Feed->retrieve('torrents_all', $_GET['authkey'], $_GET['passkey']);
break;
case 'torrents_music':
$Feed->channel('Music Torrents', 'RSS feed for all new music torrents.');
$Feed->retrieve('torrents_music',$_GET['authkey'],$_GET['passkey']);
$Feed->retrieve('torrents_music', $_GET['authkey'], $_GET['passkey']);
break;
case 'torrents_apps':
$Feed->channel('Application Torrents', 'RSS feed for all new application torrents.');
$Feed->retrieve('torrents_apps',$_GET['authkey'],$_GET['passkey']);
$Feed->retrieve('torrents_apps', $_GET['authkey'], $_GET['passkey']);
break;
case 'torrents_ebooks':
$Feed->channel('E-Book Torrents', 'RSS feed for all new e-book torrents.');
$Feed->retrieve('torrents_ebooks',$_GET['authkey'],$_GET['passkey']);
$Feed->retrieve('torrents_ebooks', $_GET['authkey'], $_GET['passkey']);
break;
case 'torrents_abooks':
$Feed->channel('Audiobook Torrents', 'RSS feed for all new audiobook torrents.');
$Feed->retrieve('torrents_abooks',$_GET['authkey'],$_GET['passkey']);
$Feed->retrieve('torrents_abooks', $_GET['authkey'], $_GET['passkey']);
break;
case 'torrents_evids':
$Feed->channel('E-Learning Video Torrents', 'RSS feed for all new e-learning video torrents.');
$Feed->retrieve('torrents_evids',$_GET['authkey'],$_GET['passkey']);
$Feed->retrieve('torrents_evids', $_GET['authkey'], $_GET['passkey']);
break;
case 'torrents_comedy':
$Feed->channel('Comedy Torrents', 'RSS feed for all new comedy torrents.');
$Feed->retrieve('torrents_comedy',$_GET['authkey'],$_GET['passkey']);
$Feed->retrieve('torrents_comedy', $_GET['authkey'], $_GET['passkey']);
break;
case 'torrents_comics':
$Feed->channel('Comic Torrents', 'RSS feed for all new comic torrents.');
$Feed->retrieve('torrents_comics',$_GET['authkey'],$_GET['passkey']);
$Feed->retrieve('torrents_comics', $_GET['authkey'], $_GET['passkey']);
break;
case 'torrents_mp3':
$Feed->channel('MP3 Torrents', 'RSS feed for all new mp3 torrents.');
$Feed->retrieve('torrents_mp3',$_GET['authkey'],$_GET['passkey']);
$Feed->retrieve('torrents_mp3', $_GET['authkey'], $_GET['passkey']);
break;
case 'torrents_flac':
$Feed->channel('FLAC Torrents', 'RSS feed for all new FLAC torrents.');
$Feed->retrieve('torrents_flac',$_GET['authkey'],$_GET['passkey']);
$Feed->retrieve('torrents_flac', $_GET['authkey'], $_GET['passkey']);
break;
case 'torrents_vinyl':
$Feed->channel('Vinyl Sourced Torrents', 'RSS feed for all new vinyl sourced torrents.');
$Feed->retrieve('torrents_vinyl',$_GET['authkey'],$_GET['passkey']);
$Feed->retrieve('torrents_vinyl', $_GET['authkey'], $_GET['passkey']);
break;
case 'torrents_lossless':
$Feed->channel('Lossless Torrents', 'RSS feed for all new lossless uploads.');
$Feed->retrieve('torrents_lossless',$_GET['authkey'],$_GET['passkey']);
$Feed->retrieve('torrents_lossless', $_GET['authkey'], $_GET['passkey']);
break;
case 'torrents_lossless24':
$Feed->channel('24bit Lossless Torrents', 'RSS feed for all new 24bit uploads.');
$Feed->retrieve('torrents_lossless24',$_GET['authkey'],$_GET['passkey']);
$Feed->retrieve('torrents_lossless24', $_GET['authkey'], $_GET['passkey']);
break;
default:
// Personalized torrents
if (empty($_GET['name']) && substr($_GET['feed'], 0, 16) == 'torrents_notify_') {
// All personalized torrent notifications
$Feed->channel('Personalized torrent notifications', 'RSS feed for personalized torrent notifications.');
$Feed->retrieve($_GET['feed'],$_GET['authkey'],$_GET['passkey']);
$Feed->retrieve($_GET['feed'], $_GET['authkey'], $_GET['passkey']);
} elseif (!empty($_GET['name']) && substr($_GET['feed'], 0, 16) == 'torrents_notify_') {
// Specific personalized torrent notification channel
$Feed->channel(display_str($_GET['name']), 'Personal RSS feed: '.display_str($_GET['name']));
$Feed->retrieve($_GET['feed'],$_GET['authkey'],$_GET['passkey']);
$Feed->retrieve($_GET['feed'], $_GET['authkey'], $_GET['passkey']);
} elseif (!empty($_GET['name']) && substr($_GET['feed'], 0, 21) == 'torrents_bookmarks_t_') {
// Bookmarks
$Feed->channel('Bookmarked torrent notifications', 'RSS feed for bookmarked torrents.');
$Feed->retrieve($_GET['feed'],$_GET['authkey'],$_GET['passkey']);
$Feed->retrieve($_GET['feed'], $_GET['authkey'], $_GET['passkey']);
} else {
$Feed->channel('All Torrents', 'RSS feed for all new torrent uploads.');
$Feed->retrieve('torrents_all',$_GET['authkey'],$_GET['passkey']);
$Feed->retrieve('torrents_all', $_GET['authkey'], $_GET['passkey']);
}
}
$Feed->close_feed();

View File

@ -4,16 +4,16 @@
// Bear this in mind when you try to use script_start functions.
if (!check_perms('site_proxy_images')) {
error('forbidden');
img_error('forbidden');
}
$URL = isset($_GET['i']) ? htmlspecialchars_decode($_GET['i']) : null;
if (!extension_loaded('openssl') && strtoupper($URL[4]) == 'S') {
error('badprotocol');
img_error('badprotocol');
}
if (!preg_match('/^'.IMAGE_REGEX.'/is',$URL,$Matches)) {
error('invalid');
img_error('invalid');
}
if (isset($_GET['c'])) {
@ -24,16 +24,16 @@
$Cached = false;
$Data = @file_get_contents($URL,0,stream_context_create(array('http'=>array('timeout'=>15))));
if (!$Data || empty($Data)) {
error('timeout');
img_error('timeout');
}
$Type = image_type($Data);
if ($Type && function_exists('imagecreatefrom'.$Type)) {
$Image = imagecreatefromstring($Data);
if (invisible($Image)) {
error('invisible');
img_error('invisible');
}
if (verysmall($Image)) {
error('small');
img_error('small');
}
}
@ -60,8 +60,6 @@
if (strlen($Data2) > 256 * 1024 || image_height($Type, $Data2) > 400) {
require_once(SERVER_ROOT.'/classes/mysql.class.php');
require_once(SERVER_ROOT.'/classes/time.class.php'); //Require the time class
$DB = new DB_MYSQL;
$DBURL = db_string($URL);
// Reset avatar, add mod note
@ -76,7 +74,7 @@
// Send PM
send_pm($UserID,0,"Your avatar has been automatically reset","The following avatar rules have been in effect for months now:
Misc::send_pm($UserID,0,"Your avatar has been automatically reset","The following avatar rules have been in effect for months now:
[b]Avatars must not exceed 256 kB or be vertically longer than 400px. [/b]
@ -90,7 +88,7 @@
/*
TODO: solve this properly for photoshop output images which prepend shit to the image file. skip it or strip it
if (!isset($Type)) {
error('timeout');
img_error('timeout');
}
*/
if (isset($Type)) {

View File

@ -84,7 +84,7 @@
<div class="box pad">
<? if ($Count == 0 && empty($_GET['search'])) { ?>
<h2>Your <?=(($Section == 'sentbox') ? 'sentbox' : 'inbox')?> is currently empty</h2>
<h2>Your <?=(($Section == 'sentbox') ? 'sentbox' : 'inbox')?> is empty.</h2>
<? } else { ?>
<form class="search_form" name="<?=(($Section == 'sentbox') ? 'sentbox' : 'inbox')?>" action="inbox.php" method="get" id="searchbox">
<div>

View File

@ -18,15 +18,15 @@
$DB->query("
SELECT ID
FROM users_main
WHERE torrent_pass='".db_string($_REQUEST['confirm'])."'
AND Enabled='0'");
WHERE torrent_pass = '".db_string($_REQUEST['confirm'])."'
AND Enabled = '0'");
list($UserID) = $DB->next_record();
if ($UserID) {
$DB->query("
UPDATE users_main
SET Enabled='1'
WHERE ID='$UserID'");
SET Enabled = '1'
WHERE ID = '$UserID'");
$Cache->increment('stats_user_count');
include('step2.php');
}
@ -35,7 +35,7 @@
$Val->SetFields('username', true, 'regex', 'You did not enter a valid username.', array('regex' => USERNAME_REGEX));
$Val->SetFields('email', true, 'email', 'You did not enter a valid email address.');
$Val->SetFields('password', true, 'regex', 'A strong password is between 8 and 40 characters long, contains at least 1 lowercase and uppercase letter, and contains at least a number or symbol', array('regex'=>'/(?=^.{8,}$)(?=.*[^a-zA-Z])(?=.*[A-Z])(?=.*[a-z]).*$/'));
$Val->SetFields('confirm_password', true, 'compare', 'Your passwords do not match.', array('comparefield'=>'password'));
$Val->SetFields('confirm_password', true, 'compare', 'Your passwords do not match.', array('comparefield' => 'password'));
$Val->SetFields('readrules', true, 'checkbox', 'You did not select the box that says you will read the rules.');
$Val->SetFields('readwiki', true, 'checkbox', 'You did not select the box that says you will read the wiki.');
$Val->SetFields('agereq', true, 'checkbox', 'You did not select the box that says you are 13 years of age or older.');
@ -70,7 +70,7 @@
$DB->query("
SELECT InviterID, Email
FROM invites
WHERE InviteKey='".db_string($_REQUEST['invite'])."'");
WHERE InviteKey = '".db_string($_REQUEST['invite'])."'");
if ($DB->record_count() == 0) {
$Err = 'Invite does not exist.';
$InviterID = 0;
@ -107,10 +107,10 @@
INSERT INTO users_main
(Username, Email, PassHash, torrent_pass, IP, PermissionID, Enabled, Invites, Uploaded, ipcc)
VALUES
('".db_string(trim($_POST['username']))."','".db_string($_POST['email'])."','".db_string(Users::make_crypt_hash($_POST['password']))."','".db_string($torrent_pass)."','".db_string($_SERVER['REMOTE_ADDR'])."','$Class','$Enabled','".STARTING_INVITES."', '524288000', '$IPcc')");
('".db_string(trim($_POST['username']))."', '".db_string($_POST['email'])."', '".db_string(Users::make_crypt_hash($_POST['password']))."', '".db_string($torrent_pass)."', '".db_string($_SERVER['REMOTE_ADDR'])."', '$Class', '$Enabled', '".STARTING_INVITES."', '524288000', '$IPcc')");
$UserID = $DB->inserted_id();
// User created, delete invite. If things break after this point, then it's better to have a broken account to fix than a 'free' invite floating around that can be reused
$DB->query("
@ -165,7 +165,9 @@
// If the inviter doesn't have an invite tree
// Note: This should never happen unless you've transferred from another database, like What.CD did
if ($DB->record_count() == 0) {
$DB->query("SELECT MAX(TreeID)+1 FROM invite_tree");
$DB->query("
SELECT MAX(TreeID) + 1
FROM invite_tree");
list($TreeID) = $DB->next_record();
$DB->query("
@ -230,7 +232,7 @@
$TPL->set('SITE_NAME', SITE_NAME);
$TPL->set('SITE_URL', SITE_URL);
Misc::send_email($_REQUEST['email'],'New account confirmation at '.SITE_NAME,$TPL->get(),'noreply');
Misc::send_email($_REQUEST['email'], 'New account confirmation at '.SITE_NAME, $TPL->get(), 'noreply');
Tracker::update_tracker('add_user', array('id' => $UserID, 'passkey' => $torrent_pass));
$Sent = 1;

View File

@ -11,7 +11,10 @@
}
$ID = (int)$_POST['id'];
$DB->query("SELECT ClaimerID FROM reports WHERE ID = '$ID'");
$DB->query("
SELECT ClaimerID
FROM reports
WHERE ID = '$ID'");
list($ClaimerID) = $DB->next_record();
if ($ClaimerID) {
print
@ -23,7 +26,10 @@
die();
} else {
$UserID = $LoggedUser['ID'];
$DB->query("UPDATE reports SET ClaimerID = '$UserID' WHERE ID = '$ID'");
$DB->query("
UPDATE reports
SET ClaimerID = '$UserID'
WHERE ID = '$ID'");
print
json_encode(
array(

View File

@ -7,7 +7,10 @@
$ReportID = $_POST['reportid'];
$DB->query('SELECT Type FROM reports WHERE ID = '.$ReportID);
$DB->query("
SELECT Type
FROM reports
WHERE ID = $ReportID");
list($Type) = $DB->next_record();
if (!check_perms('admin_reports')) {
if (check_perms('site_moderate_forums')) {
@ -23,11 +26,10 @@
$DB->query("
UPDATE reports
SET Status='Resolved',
ResolvedTime='".sqltime()."',
ResolverID='".$LoggedUser['ID']."'
WHERE ID='".db_string($ReportID)."'");
SET Status = 'Resolved',
ResolvedTime = '".sqltime()."',
ResolverID = '".$LoggedUser['ID']."'
WHERE ID = '".db_string($ReportID)."'");
$Channels = array();
@ -41,12 +43,14 @@
$Cache->decrement('num_forum_reports');
}
$DB->query("SELECT COUNT(ID) FROM reports WHERE Status = 'New'");
$DB->query("
SELECT COUNT(ID)
FROM reports
WHERE Status = 'New'");
list($Remaining) = $DB->next_record();
foreach ($Channels as $Channel) {
send_irc("PRIVMSG $Channel :Report $ReportID resolved by ".preg_replace("/^(.{2})/", "$", $LoggedUser['Username']).' on site ('.(int)$Remaining.' remaining).');
send_irc("PRIVMSG $Channel :Report $ReportID resolved by ".preg_replace('/^(.{2})/', '$1·', $LoggedUser['Username']).' on site ('.(int)$Remaining.' remaining).');
}
$Cache->delete_value('num_other_reports');
@ -54,12 +58,12 @@
ajax_success();
function ajax_error($Error = 'error') {
echo json_encode(array('status'=>$Error));
echo json_encode(array('status' => $Error));
die();
}
function ajax_success() {
echo json_encode(array("status"=>"success"));
echo json_encode(array('status' => 'success'));
die();
}
?>

View File

@ -15,97 +15,118 @@
$ID = $_GET['id'];
switch ($Short) {
case 'user' :
$DB->query("SELECT Username FROM users_main WHERE ID=".$ID);
case 'user':
$DB->query("
SELECT Username
FROM users_main
WHERE ID = $ID");
if ($DB->record_count() < 1) {
error(404);
}
list($Username) = $DB->next_record();
break;
case 'request_update' :
case 'request_update':
$NoReason = true;
$DB->query("SELECT Title, Description, TorrentID, CategoryID, Year FROM requests WHERE ID=".$ID);
$DB->query("
SELECT Title, Description, TorrentID, CategoryID, Year
FROM requests
WHERE ID = $ID");
if ($DB->record_count() < 1) {
error(404);
}
list($Name, $Desc, $Filled, $CategoryID, $Year) = $DB->next_record();
if ($Filled || ($CategoryID != 0 && ($Categories[$CategoryID-1] != 'Music' || $Year != 0))) {
if ($Filled || ($CategoryID != 0 && ($Categories[$CategoryID - 1] != 'Music' || $Year != 0))) {
error(403);
}
break;
case 'request' :
$DB->query("SELECT Title, Description, TorrentID FROM requests WHERE ID=".$ID);
case 'request':
$DB->query("
SELECT Title, Description, TorrentID
FROM requests
WHERE ID = $ID");
if ($DB->record_count() < 1) {
error(404);
}
list($Name, $Desc, $Filled) = $DB->next_record();
break;
case 'collage' :
$DB->query("SELECT Name, Description FROM collages WHERE ID=".$ID);
case 'collage':
$DB->query("
SELECT Name, Description
FROM collages
WHERE ID = $ID");
if ($DB->record_count() < 1) {
error(404);
}
list($Name, $Desc) = $DB->next_record();
break;
case 'thread' :
case 'thread':
$DB->query("
SELECT ft.Title, ft.ForumID, um.Username
FROM forums_topics AS ft
JOIN users_main AS um ON um.ID=ft.AuthorID
WHERE ft.ID=".$ID);
JOIN users_main AS um ON um.ID = ft.AuthorID
WHERE ft.ID = $ID");
if ($DB->record_count() < 1) {
error(404);
}
list($Title, $ForumID, $Username) = $DB->next_record();
$DB->query("SELECT MinClassRead FROM forums WHERE ID = ".$ForumID);
$DB->query("
SELECT MinClassRead
FROM forums
WHERE ID = $ForumID");
list($MinClassRead) = $DB->next_record();
if (!empty($LoggedUser['DisableForums']) ||
($MinClassRead > $LoggedUser['EffectiveClass'] && (!isset($LoggedUser['CustomForums'][$ForumID]) || $LoggedUser['CustomForums'][$ForumID] == 0)) ||
(isset($LoggedUser['CustomForums'][$ForumID]) && $LoggedUser['CustomForums'][$ForumID] == 0)) {
if (!empty($LoggedUser['DisableForums'])
|| ($MinClassRead > $LoggedUser['EffectiveClass'] && (!isset($LoggedUser['CustomForums'][$ForumID]) || $LoggedUser['CustomForums'][$ForumID] == 0))
|| (isset($LoggedUser['CustomForums'][$ForumID]) && $LoggedUser['CustomForums'][$ForumID] == 0)) {
error(403);
}
break;
case 'post' :
$DB->query('
case 'post':
$DB->query("
SELECT fp.Body, fp.TopicID, um.Username
FROM forums_posts AS fp
JOIN users_main AS um ON um.ID=fp.AuthorID
WHERE fp.ID='.$ID);
JOIN users_main AS um ON um.ID = fp.AuthorID
WHERE fp.ID = $ID");
if ($DB->record_count() < 1) {
error(404);
}
list($Body, $TopicID, $Username) = $DB->next_record();
$DB->query('SELECT ForumID FROM forums_topics WHERE ID = '.$TopicID);
$DB->query("
SELECT ForumID
FROM forums_topics
WHERE ID = $TopicID");
list($ForumID) = $DB->next_record();
$DB->query('SELECT MinClassRead FROM forums WHERE ID = '.$ForumID);
$DB->query("
SELECT MinClassRead
FROM forums
WHERE ID = $ForumID");
list($MinClassRead) = $DB->next_record();
if (!empty($LoggedUser['DisableForums']) ||
($MinClassRead > $LoggedUser['EffectiveClass'] && (!isset($LoggedUser['CustomForums'][$ForumID]) || $LoggedUser['CustomForums'][$ForumID] == 0)) ||
(isset($LoggedUser['CustomForums'][$ForumID]) && $LoggedUser['CustomForums'][$ForumID] == 0)) {
if (!empty($LoggedUser['DisableForums'])
|| ($MinClassRead > $LoggedUser['EffectiveClass'] && (!isset($LoggedUser['CustomForums'][$ForumID]) || $LoggedUser['CustomForums'][$ForumID] == 0))
|| (isset($LoggedUser['CustomForums'][$ForumID]) && $LoggedUser['CustomForums'][$ForumID] == 0)) {
error(403);
}
break;
case 'requests_comment' :
case 'torrents_comment' :
case 'requests_comment':
case 'torrents_comment':
case 'artist_comment':
case 'collages_comment' :
$Table = $Short.'s';
case 'collages_comment':
$Table = "{$Short}s";
if ($Short == 'collages_comment') {
$Column = 'UserID';
} else {
$Column = 'AuthorID';
}
$DB->query('
SELECT '.$Short.".Body, um.Username
$DB->query("
SELECT $Short.Body, um.Username
FROM $Table AS $Short
JOIN users_main AS um ON um.ID=$Short.$Column
WHERE $Short.ID=".$ID);
JOIN users_main AS um ON um.ID = $Short.$Column
WHERE $Short.ID = $ID");
if ($DB->record_count() < 1) {
error(404);
}
@ -113,7 +134,7 @@
break;
}
View::show_header('Report a '.$Type['title'],'bbcode,jquery.validate,form_validate');
View::show_header('Report a '.$Type['title'], 'bbcode,jquery.validate,form_validate');
?>
<div class="thin">
<div class="header">
@ -123,11 +144,9 @@
<div class="box pad">
<p>Following these guidelines will help the moderators deal with your report in a timely fashion. </p>
<ul>
<?
foreach ($Type['guidelines'] as $Guideline) {
?>
<? foreach ($Type['guidelines'] as $Guideline) { ?>
<li><?=$Guideline?></li>
<? } ?>
<? } ?>
</ul>
<p>In short, please include as much detail as possible when reporting. Thank you. </p>
</div>
@ -138,12 +157,12 @@
switch ($Short) {
case 'user' :
case 'user':
?>
<p>You are reporting the user <strong><?=display_str($Username)?></strong></p>
<?
break;
case 'request_update' :
case 'request_update':
?>
<p>You are reporting the request:</p>
<table>
@ -179,12 +198,9 @@
<td>
<select id="releasetype" name="releasetype">
<option value="0">---</option>
<?
foreach ($ReleaseTypes as $Key => $Val) {
?> <option value="<?=$Key?>"<?=(!empty($ReleaseType) ? ($Key == $ReleaseType ? ' selected="selected"' : '') : '')?>><?=$Val?></option>
<?
}
?>
<? foreach ($ReleaseTypes as $Key => $Val) { ?>
<option value="<?=$Key?>"<?=(!empty($ReleaseType) ? ($Key == $ReleaseType ? ' selected="selected"' : '') : '')?>><?=$Val?></option>
<? } ?>
</select>
</td>
</tr>
@ -202,7 +218,7 @@
</div>
<?
break;
case 'request' :
case 'request':
?>
<p>You are reporting the request:</p>
<table>
@ -219,10 +235,10 @@
</table>
<?
break;
case 'collage' :
case 'collage':
?>
<p>You are reporting the collage:</p>
<table>
<p>You are reporting the collage:</p>
<table>
<tr class="colhead">
<td>Title</td>
<td>Description</td>
@ -234,10 +250,10 @@
</table>
<?
break;
case 'thread' :
case 'thread':
?>
<p>You are reporting the thread:</p>
<table>
<p>You are reporting the thread:</p>
<table>
<tr class="colhead">
<td>Username</td>
<td>Title</td>
@ -249,10 +265,10 @@
</table>
<?
break;
case 'post' :
case 'post':
?>
<p>You are reporting the post:</p>
<table>
<p>You are reporting the post:</p>
<table>
<tr class="colhead">
<td>Username</td>
<td>Body</td>
@ -264,13 +280,13 @@
</table>
<?
break;
case 'requests_comment' :
case 'torrents_comment' :
case 'requests_comment':
case 'torrents_comment':
case 'artist_comment':
case 'collages_comment' :
case 'collages_comment':
?>
<p>You are reporting the <?=$Types[$Short]['title']?>:</p>
<table>
<p>You are reporting the <?=$Types[$Short]['title']?>:</p>
<table>
<tr class="colhead">
<td>Username</td>
<td>Body</td>

View File

@ -18,16 +18,16 @@
View::show_header('Reports', 'bbcode,reports');
if ($_GET['id'] && is_number($_GET['id'])) {
$View = "Single report";
$Where = "r.ID = " . $_GET['id'];
$View = 'Single report';
$Where = 'r.ID = ' . $_GET['id'];
} else if (empty($_GET['view'])) {
$View = "New";
$Where = "Status='New'";
$View = 'New';
$Where = "Status = 'New'";
} else {
$View = $_GET['view'];
switch ($_GET['view']) {
case 'old' :
$Where = "Status='Resolved'";
$Where = "Status = 'Resolved'";
break;
default :
error(404);
@ -60,7 +60,7 @@
r.Notes,
r.ResolverID
FROM reports AS r
JOIN users_main AS um ON r.UserID=um.ID
JOIN users_main AS um ON r.UserID = um.ID
WHERE $Where
ORDER BY ReportedTime DESC
LIMIT $Limit");
@ -93,7 +93,7 @@
<?
while (list($ReportID, $SnitchID, $SnitchName, $ThingID, $Short, $ReportedTime, $Reason, $Status, $ClaimerID, $Notes, $ResolverID) = $DB->next_record()) {
$Type = $Types[$Short];
$Reference = "reports.php?id=" . $ReportID . "#report" . $ReportID;
$Reference = "reports.php?id=$ReportID#report$ReportID";
?>
<div id="report_<?=$ReportID?>">
<table cellpadding="5" id="report_<?=$ReportID?>">
@ -108,8 +108,11 @@
<td class="center" colspan="2">
<strong>
<? switch ($Short) {
case "user" :
$DB->query("SELECT Username FROM users_main WHERE ID=" . $ThingID);
case 'user':
$DB->query("
SELECT Username
FROM users_main
WHERE ID = $ThingID");
if ($DB->record_count() < 1) {
echo 'No user with the reported ID found';
} else {
@ -117,9 +120,12 @@
echo "<a href=\"user.php?id=$ThingID\">" . display_str($Username) . '</a>';
}
break;
case "request" :
case "request_update" :
$DB->query("SELECT Title FROM requests WHERE ID=" . $ThingID);
case 'request':
case 'request_update':
$DB->query("
SELECT Title
FROM requests
WHERE ID = $ThingID");
if ($DB->record_count() < 1) {
echo 'No request with the reported ID found';
} else {
@ -127,8 +133,11 @@
echo "<a href=\"requests.php?action=view&amp;id=$ThingID\">" . display_str($Name) . '</a>';
}
break;
case "collage" :
$DB->query("SELECT Name FROM collages WHERE ID=" . $ThingID);
case 'collage':
$DB->query("
SELECT Name
FROM collages
WHERE ID = $ThingID");
if ($DB->record_count() < 1) {
echo 'No collage with the reported ID found';
} else {
@ -136,8 +145,11 @@
echo "<a href=\"collages.php?id=$ThingID\">" . display_str($Name) . '</a>';
}
break;
case "thread" :
$DB->query("SELECT Title FROM forums_topics WHERE ID=" . $ThingID);
case 'thread':
$DB->query("
SELECT Title
FROM forums_topics
WHERE ID = $ThingID");
if ($DB->record_count() < 1) {
echo 'No forum thread with the reported ID found';
} else {
@ -145,7 +157,7 @@
echo "<a href=\"forums.php?action=viewthread&amp;threadid=$ThingID\">" . display_str($Title) . '</a>';
}
break;
case "post" :
case 'post':
if (isset($LoggedUser['PostsPerPage'])) {
$PerPage = $LoggedUser['PostsPerPage'];
} else {
@ -159,18 +171,18 @@
( SELECT COUNT(ID)
FROM forums_posts
WHERE forums_posts.TopicID = p.TopicID
AND forums_posts.ID<=p.ID
AND forums_posts.ID <= p.ID
) AS PostNum
FROM forums_posts AS p
WHERE ID=$ThingID");
WHERE ID = $ThingID");
if ($DB->record_count() < 1) {
echo 'No forum post with the reported ID found';
} else {
list($PostID, $Body, $TopicID, $PostNum) = $DB->next_record();
echo "<a href=\"forums.php?action=viewthread&amp;threadid=" . $TopicID . "&amp;post=" . $PostNum . "#post" . $PostID . "\">FORUM POST</a>";
echo "<a href=\"forums.php?action=viewthread&amp;threadid=$TopicID&amp;post=$PostNum#post$PostID\">FORUM POST</a>";
}
break;
case "requests_comment" :
case 'requests_comment':
$DB->query("
SELECT
rc.RequestID,
@ -181,16 +193,16 @@
AND requests_comments.RequestID = rc.RequestID
) AS CommentNum
FROM requests_comments AS rc
WHERE ID=$ThingID");
WHERE ID = $ThingID");
if ($DB->record_count() < 1) {
echo 'No request comment with the reported ID found';
} else {
list($RequestID, $Body, $PostNum) = $DB->next_record();
$PageNum = ceil($PostNum / TORRENT_COMMENTS_PER_PAGE);
echo "<a href=\"requests.php?action=view&amp;id=" . $RequestID . "&amp;page=" . $PageNum . "#post" . $ThingID . "\">REQUEST COMMENT</a>";
echo "<a href=\"requests.php?action=view&amp;id=$RequestID&amp;page=$PageNum#post$ThingID\">REQUEST COMMENT</a>";
}
break;
case "torrents_comment" :
case 'torrents_comment':
$DB->query("
SELECT
tc.GroupID,
@ -201,16 +213,16 @@
AND torrents_comments.GroupID = tc.GroupID
) AS CommentNum
FROM torrents_comments AS tc
WHERE ID=$ThingID");
WHERE ID = $ThingID");
if ($DB->record_count() < 1) {
echo 'No torrent comment with the reported ID found';
} else {
list($GroupID, $Body, $PostNum) = $DB->next_record();
$PageNum = ceil($PostNum / TORRENT_COMMENTS_PER_PAGE);
echo "<a href=\"torrents.php?id=" . $GroupID . "&amp;page=" . $PageNum . "#post" . $ThingID . "\">TORRENT COMMENT</a>";
echo "<a href=\"torrents.php?id=$GroupID&amp;page=$PageNum#post$ThingID\">TORRENT COMMENT</a>";
}
break;
case "artist_comment" :
case 'artist_comment':
$DB->query("
SELECT
ac.ArtistID,
@ -221,17 +233,17 @@
AND artist_comments.ArtistID = ac.ArtistID
) AS CommentNum
FROM artist_comments AS ac
WHERE ID=$ThingID");
WHERE ID = $ThingID");
if ($DB->record_count() < 1) {
echo 'No comment with the reported ID found';
} else {
list($ArtistID, $Body, $PostNum) = $DB->next_record();
$PageNum = ceil($PostNum / TORRENT_COMMENTS_PER_PAGE);
echo "<a href=\"artist.php?id=" . $ArtistID . "&amp;page=" . $PageNum . "#post" . $ThingID . "\">ARTIST COMMENT</a>";
echo "<a href=\"artist.php?id=$ArtistID&amp;page=$PageNum#post$ThingID\">ARTIST COMMENT</a>";
}
break;
case "collages_comment" :
case 'collages_comment':
$DB->query("
SELECT
cc.CollageID,
@ -242,14 +254,14 @@
AND collages_comments.CollageID = cc.CollageID
) AS CommentNum
FROM collages_comments AS cc
WHERE ID=$ThingID");
WHERE ID = $ThingID");
if ($DB->record_count() < 1) {
echo 'No collage comment with the reported ID found';
} else {
list($CollageID, $Body, $PostNum) = $DB->next_record();
$PerPage = POSTS_PER_PAGE;
$PageNum = ceil($PostNum / $PerPage);
echo "<a href=\"collage.php?action=comments&amp;collageid=" . $CollageID . "&amp;page=" . $PageNum . "#post" . $ThingID . "\">COLLAGE COMMENT</a>";
echo "<a href=\"collage.php?action=comments&amp;collageid=$CollageID&amp;page=$PageNum#post$ThingID\">COLLAGE COMMENT</a>";
}
break;
}
@ -272,7 +284,7 @@
&nbsp;&nbsp;
<a href="#" onclick="toggleNotes(<?=$ReportID?>); return false;" class="brackets">Toggle notes</a>
<div id="notes_div_<?=$ReportID?>" style="display: <?=empty($Notes) ? "none" : "block"?>;">
<div id="notes_div_<?=$ReportID?>" style="display: <?=empty($Notes) ? 'none' : 'block'; ?>;">
<textarea cols="50" rows="3" id="notes_<?=$ReportID?>"><?=$Notes?></textarea>
<br />
<input type="submit" onclick="saveNotes(<?=$ReportID?>)" value="Save" />
@ -289,9 +301,10 @@
</form>
</td>
</tr>
<? } else {
<?
} else {
$ResolverInfo = Users::user_info($ResolverID);
?>
?>
<tr>
<td colspan="2">
Resolved by <a href="users.php?id=<?=$ResolverID?>"><?=$ResolverInfo['Username']?></a>

View File

@ -18,14 +18,15 @@
<table class="layout">
<?
if (check_perms('admin_reports')) :
$DB->query("SELECT um.Username,
COUNT(r.ID) AS Reports
FROM reports AS r
JOIN users_main AS um ON um.ID=r.ResolverID
WHERE r.ReportedTime > '2009-08-21 22:39:41'
AND r.ReportedTime > NOW() - INTERVAL 24 HOUR
GROUP BY r.ResolverID
ORDER BY Reports DESC");
$DB->query("
SELECT um.Username,
COUNT(r.ID) AS Reports
FROM reports AS r
JOIN users_main AS um ON um.ID = r.ResolverID
WHERE r.ReportedTime > '2009-08-21 22:39:41'
AND r.ReportedTime > NOW() - INTERVAL 24 HOUR
GROUP BY r.ResolverID
ORDER BY Reports DESC");
$Results = $DB->to_array();
?>
<tr>
@ -36,7 +37,8 @@
<td class="head colhead_dark">Username</td>
<td class="head colhead_dark">Reports</td>
</tr>
<? foreach ($Results as $Result) {
<?
foreach ($Results as $Result) {
list($Username, $Reports) = $Result;
?>
<tr>
@ -49,14 +51,15 @@
</tr>
<tr>
<?
$DB->query("SELECT um.Username,
COUNT(r.ID) AS Reports
FROM reports AS r
JOIN users_main AS um ON um.ID=r.ResolverID
WHERE r.ReportedTime > '2009-08-21 22:39:41'
AND r.ReportedTime > NOW() - INTERVAL 1 WEEK
GROUP BY r.ResolverID
ORDER BY Reports DESC");
$DB->query("
SELECT um.Username,
COUNT(r.ID) AS Reports
FROM reports AS r
JOIN users_main AS um ON um.ID = r.ResolverID
WHERE r.ReportedTime > '2009-08-21 22:39:41'
AND r.ReportedTime > NOW() - INTERVAL 1 WEEK
GROUP BY r.ResolverID
ORDER BY Reports DESC");
$Results = $DB->to_array();
?>
<td class="label"><strong>Reports resolved in the last week</strong></td>
@ -66,7 +69,8 @@
<td class="head colhead_dark">Username</td>
<td class="head colhead_dark">Reports</td>
</tr>
<? foreach ($Results as $Result) {
<?
foreach ($Results as $Result) {
list($Username, $Reports) = $Result;
?>
<tr>
@ -79,14 +83,15 @@
</tr>
<tr>
<?
$DB->query("SELECT um.Username,
COUNT(r.ID) AS Reports
FROM reports AS r
JOIN users_main AS um ON um.ID=r.ResolverID
WHERE r.ReportedTime > '2009-08-21 22:39:41'
AND r.ReportedTime > NOW() - INTERVAL 1 MONTH
GROUP BY r.ResolverID
ORDER BY Reports DESC");
$DB->query("
SELECT um.Username,
COUNT(r.ID) AS Reports
FROM reports AS r
JOIN users_main AS um ON um.ID = r.ResolverID
WHERE r.ReportedTime > '2009-08-21 22:39:41'
AND r.ReportedTime > NOW() - INTERVAL 1 MONTH
GROUP BY r.ResolverID
ORDER BY Reports DESC");
$Results = $DB->to_array();
?>
<td class="label"><strong>Reports resolved in the last month</strong></td>
@ -96,7 +101,8 @@
<td class="head colhead_dark">Username</td>
<td class="head colhead_dark">Reports</td>
</tr>
<? foreach ($Results as $Result) {
<?
foreach ($Results as $Result) {
list($Username, $Reports) = $Result;
?>
<tr>
@ -109,12 +115,13 @@
</tr>
<tr>
<?
$DB->query("SELECT um.Username,
COUNT(r.ID) AS Reports
FROM reports AS r
JOIN users_main AS um ON um.ID=r.ResolverID
GROUP BY r.ResolverID
ORDER BY Reports DESC");
$DB->query("
SELECT um.Username,
COUNT(r.ID) AS Reports
FROM reports AS r
JOIN users_main AS um ON um.ID = r.ResolverID
GROUP BY r.ResolverID
ORDER BY Reports DESC");
$Results = $DB->to_array();
?>
<td class="label"><strong>Reports resolved since "other" reports (2009-08-21)</strong></td>
@ -124,7 +131,8 @@
<td class="head colhead_dark">Username</td>
<td class="head colhead_dark">Reports</td>
</tr>
<? foreach ($Results as $Result) {
<?
foreach ($Results as $Result) {
list($Username, $Reports) = $Result;
?>
<tr>
@ -138,14 +146,15 @@
<? endif; ?>
<tr>
<?
$DB->query("SELECT u.Username,
count(LastPostAuthorID) as Trashed
FROM forums_topics as f
LEFT JOIN users_main as u on u.id = LastPostAuthorID
WHERE ForumID = 12
GROUP BY LastPostAuthorID
ORDER BY Trashed DESC
LIMIT 30;");
$DB->query("
SELECT u.Username,
count(LastPostAuthorID) as Trashed
FROM forums_topics as f
LEFT JOIN users_main as u on u.id = LastPostAuthorID
WHERE ForumID = 12
GROUP BY LastPostAuthorID
ORDER BY Trashed DESC
LIMIT 30");
$Results = $DB->to_array();
?>
<td class="label"><strong>Threads trashed since the beginning of time</strong></td>
@ -166,7 +175,8 @@
<td><?=$Username?></td>
<td><?=number_format($Trashed)?></td>
</tr>
<? $i++;
<?
$i++;
} ?>
</table>
</td>

View File

@ -20,7 +20,11 @@
$Err = 'A recipient does not exist.';
}
}
$DB->query("SELECT UserID FROM pm_conversations_users WHERE UserID='$LoggedUser[ID]' AND ConvID='$ConvID'");
$DB->query("
SELECT UserID
FROM pm_conversations_users
WHERE UserID = '$LoggedUser[ID]'
AND ConvID = '$ConvID'");
if ($DB->record_count() == 0) {
error(403);
}

View File

@ -16,7 +16,7 @@
if ($Short == 'request_update') {
if (empty($_POST['year']) || !is_number($_POST['year'])) {
error('Year must be specified.');
header('Location: reports.php?action=report&type=request_update&id='.$ID);
header("Location: reports.php?action=report&type=request_update&id=$ID");
die();
}
$Reason = '[b]Year[/b]: '.$_POST['year'].".\n\n";
@ -28,20 +28,20 @@
}
switch ($Short) {
case 'request' :
case 'request_update' :
$Link = 'requests.php?action=view&id='.$ID;
case 'request':
case 'request_update':
$Link = "requests.php?action=view&id=$ID";
break;
case 'user' :
$Link = 'user.php?id='.$ID;
case 'user':
$Link = "user.php?id=$ID";
break;
case 'collage' :
$Link = 'collages.php?id='.$ID;
case 'collage':
$Link = "collages.php?id=$ID";
break;
case 'thread' :
$Link = 'forums.php?action=viewthread&threadid='.$ID;
case 'thread':
$Link = "forums.php?action=viewthread&threadid=$ID";
break;
case 'post' :
case 'post':
$DB->query("
SELECT
p.ID,
@ -49,14 +49,14 @@
( SELECT COUNT(ID)
FROM forums_posts
WHERE forums_posts.TopicID = p.TopicID
AND forums_posts.ID<=p.ID
AND forums_posts.ID <= p.ID
) AS PostNum
FROM forums_posts AS p
WHERE ID=".$ID);
list($PostID,$TopicID,$PostNum) = $DB->next_record();
$Link = 'forums.php?action=viewthread&threadid='.$TopicID.'&post='.$PostNum.'#post'.$PostID;
WHERE ID = $ID");
list($PostID, $TopicID, $PostNum) = $DB->next_record();
$Link = "forums.php?action=viewthread&threadid=$TopicID&post=$PostNum#post$PostID";
break;
case 'requests_comment' :
case 'requests_comment':
$DB->query("
SELECT
rc.RequestID,
@ -67,12 +67,12 @@
AND requests_comments.RequestID = rc.RequestID
) AS CommentNum
FROM requests_comments AS rc
WHERE ID=".$ID);
WHERE ID = $ID");
list($RequestID, $Body, $PostNum) = $DB->next_record();
$PageNum = ceil($PostNum / TORRENT_COMMENTS_PER_PAGE);
$Link = 'requests.php?action=view&id='.$RequestID.'&page='.$PageNum.'#post'.$ID;
$Link = "requests.php?action=view&id=$RequestID&page=$PageNum#post$ID";
break;
case 'torrents_comment' :
case 'torrents_comment':
$DB->query("
SELECT
tc.GroupID,
@ -83,12 +83,12 @@
AND torrents_comments.GroupID = tc.GroupID
) AS CommentNum
FROM torrents_comments AS tc
WHERE ID=".$ID);
WHERE ID = $ID");
list($GroupID, $Body, $PostNum) = $DB->next_record();
$PageNum = ceil($PostNum / TORRENT_COMMENTS_PER_PAGE);
$Link = 'torrents.php?id='.$GroupID.'&page='.$PageNum.'#post'.$ID;
$Link = "torrents.php?id=$GroupID&page=$PageNum#post$ID";
break;
case 'artist_comment' :
case 'artist_comment':
$DB->query("
SELECT
ac.ArtistID,
@ -99,12 +99,12 @@
AND artist_comments.ArtistID = ac.ArtistID
) AS CommentNum
FROM artist_comments AS ac
WHERE ID=".$ID);
WHERE ID = $ID");
list($ArtistID, $Body, $PostNum) = $DB->next_record();
$PageNum = ceil($PostNum / TORRENT_COMMENTS_PER_PAGE);
$Link = 'artist.php?id='.$ArtistID.'&page='.$PageNum.'#post'.$ID;
$Link = "artist.php?id=$ArtistID&page=$PageNum#post$ID";
break;
case 'collages_comment' :
case 'collages_comment':
$DB->query("
SELECT
cc.CollageID,
@ -115,11 +115,11 @@
AND collages_comments.CollageID = cc.CollageID
) AS CommentNum
FROM collages_comments AS cc
WHERE ID=".$ID);
WHERE ID = $ID");
list($CollageID, $Body, $PostNum) = $DB->next_record();
$PerPage = POSTS_PER_PAGE;
$PageNum = ceil($PostNum / $PerPage);
$Link = 'collage.php?action=comments&collageid='.$CollageID.'&page='.$PageNum.'#post'.$ID;
$Link = "collage.php?action=comments&collageid=$CollageID&page=$PageNum#post$ID";
break;
}
@ -147,5 +147,5 @@
$Cache->delete_value('num_other_reports');
header('Location: '.$Link);
header("Location: $Link");
?>

View File

@ -11,7 +11,10 @@
$ReportID = $_POST['reportid'];
$DB->query("SELECT Type FROM reports WHERE ID = ".$ReportID);
$DB->query("
SELECT Type
FROM reports
WHERE ID = $ReportID");
list($Type) = $DB->next_record();
if (!check_perms('admin_reports')) {
if (check_perms('site_moderate_forums')) {
@ -25,12 +28,12 @@
}
}
$DB->query("UPDATE reports
SET Status='Resolved',
ResolvedTime='".sqltime()."',
ResolverID='".$LoggedUser['ID']."'
WHERE ID='".db_string($ReportID)."'");
$DB->query("
UPDATE reports
SET Status = 'Resolved',
ResolvedTime = '".sqltime()."',
ResolverID = '".$LoggedUser['ID']."'
WHERE ID = '".db_string($ReportID)."'");
$Channels = array();
@ -44,12 +47,14 @@
$Cache->decrement('num_forum_reports');
}
$DB->query("SELECT COUNT(ID) FROM reports WHERE Status = 'New'");
$DB->query("
SELECT COUNT(ID)
FROM reports
WHERE Status = 'New'");
list($Remaining) = $DB->next_record();
foreach ($Channels as $Channel) {
send_irc("PRIVMSG ".$Channel." :Report ".$ReportID." resolved by ".preg_replace("/^(.{2})/", "$", $LoggedUser['Username'])." on site (".(int)$Remaining." remaining).");
send_irc("PRIVMSG $Channel :Report $ReportID resolved by ".preg_replace('/^(.{2})/', '$1·', $LoggedUser['Username']).' on site ('.(int)$Remaining.' remaining).');
}
$Cache->delete_value('num_other_reports');

View File

@ -260,7 +260,7 @@
<option value="<?=$Genre?>"><?=$Genre?></option>
<? } ?>
</select>
<input type="text" id="tags" name="tags" size="45" value="<?=(!empty($Tags) ? display_str($Tags) : '')?>" <? Users::has_autocomplete_enabled('other'); ?>/>
<input type="text" id="tags" name="tags" size="45" value="<?=(!empty($Tags) ? display_str($Tags) : '')?>"<? Users::has_autocomplete_enabled('other'); ?> />
<br />
Tags should be comma-separated, and you should use a period (".") to separate words inside a tag&#8202;&mdash;&#8202;e.g. "<strong class="important_text_alt">hip.hop</strong>".
<br /><br />

View File

@ -389,9 +389,9 @@
<tr id="tagfilter">
<td class="label">Tags (comma-separated):</td>
<td>
<input type="text" name="tags" id="tags" size="60" value="<?= (!empty($TagNames) ? display_str(implode(', ', $TagNames)) : '') ?>" <? Users::has_autocomplete_enabled('other'); ?>/>&nbsp;
<input type="radio" name="tags_type" id="tags_type0" value="0"<? Format::selected('tags_type',0,'checked')?> /><label for="tags_type0"> Any</label>&nbsp;&nbsp;
<input type="radio" name="tags_type" id="tags_type1" value="1"<? Format::selected('tags_type',1,'checked')?> /><label for="tags_type1"> All</label>
<input type="text" name="tags" id="tags" size="60" value="<?=(!empty($TagNames) ? display_str(implode(', ', $TagNames)) : '') ?>"<? Users::has_autocomplete_enabled('other'); ?> />&nbsp;
<input type="radio" name="tags_type" id="tags_type0" value="0"<? Format::selected('tags_type', 0, 'checked')?> /><label for="tags_type0"> Any</label>&nbsp;&nbsp;
<input type="radio" name="tags_type" id="tags_type1" value="1"<? Format::selected('tags_type', 1, 'checked')?> /><label for="tags_type1"> All</label>
</td>
</tr>
<tr id="include_filled">

View File

@ -7,13 +7,14 @@
View::show_header('Bitcoin donation balance');
$Balance = btc_balance() . " BTC";
$Balance = btc_balance() . ' BTC';
$Receiveds = btc_received();
$DB->query("SELECT i.UserID, i.BitcoinAddress
FROM users_info AS i
JOIN users_main AS m ON m.ID = i.UserID
WHERE BitcoinAddress IS NOT NULL
ORDER BY m.Username ASC");
$DB->query("
SELECT i.UserID, i.BitcoinAddress
FROM users_info AS i
JOIN users_main AS m ON m.ID = i.UserID
WHERE BitcoinAddress IS NOT NULL
ORDER BY m.Username ASC");
?>
<div class="thin">
<div class="header">
@ -42,7 +43,7 @@
<td><tt><?=$row['BitcoinAddress']?></tt></td>
<td><?=$amount?></td>
</tr>
<?
<?
}
?>
</table>

View File

@ -35,7 +35,7 @@
$DB->query("
SELECT SUM(Uploaded), SUM(Downloaded), COUNT(ID)
FROM users_main
WHERE Enabled='1'");
WHERE Enabled = '1'");
list($TotalUpload, $TotalDownload, $NumUsers) = $DB->next_record();
$DB->query("
SELECT SUM(Bounty)
@ -44,21 +44,29 @@
$DB->query("
SELECT SUM(rv.Bounty)
FROM requests_votes AS rv
JOIN requests AS r ON r.ID=rv.RequestID
WHERE TorrentID>0");
JOIN requests AS r ON r.ID = rv.RequestID
WHERE TorrentID > 0");
list($AvailableBounty) = $DB->next_record();
$DB->query("
SELECT SUM(Snatched), COUNT(ID)
FROM torrents");
list($TotalSnatches, $TotalTorrents) = $DB->next_record(); // This is the total number of snatches for torrents that still exist
$DB->query("SELECT COUNT(uid) FROM xbt_snatched");
$DB->query("
SELECT COUNT(uid)
FROM xbt_snatched");
list($TotalOverallSnatches) = $DB->next_record();
if (($PeerStats = $Cache->get_value('stats_peers')) === false) {
$DB->query("SELECT COUNT(fid) FROM xbt_files_users WHERE remaining=0");
$DB->query("
SELECT COUNT(fid)
FROM xbt_files_users
WHERE remaining = 0");
list($TotalSeeders) = $DB->next_record();
$DB->query("SELECT COUNT(fid) FROM xbt_files_users WHERE remaining>0");
$DB->query("
SELECT COUNT(fid)
FROM xbt_files_users
WHERE remaining > 0");
list($TotalLeechers) = $DB->next_record();
} else {
list($TotalLeechers,$TotalSeeders) = $PeerStats;
@ -67,19 +75,21 @@
$DB->query("
SELECT COUNT(ID)
FROM users_main
WHERE ( SELECT COUNT(uid)
FROM xbt_files_users
WHERE uid=users_main.ID)>0");
WHERE (
SELECT COUNT(uid)
FROM xbt_files_users
WHERE uid = users_main.ID
) > 0");
list($TotalPeerUsers) = $DB->next_record();
$Cache->cache_value('new_economic_stats',
array($TotalUpload,$TotalDownload,$NumUsers,$TotalBounty,
$AvailableBounty,$TotalSnatches,$TotalTorrents,
$TotalOverallSnatches,$TotalSeeders,$TotalPeers,
array($TotalUpload, $TotalDownload, $NumUsers, $TotalBounty,
$AvailableBounty, $TotalSnatches, $TotalTorrents,
$TotalOverallSnatches, $TotalSeeders, $TotalPeers,
$TotalPeerUsers), 3600);
} else {
list($TotalUpload,$TotalDownload,$NumUsers,$TotalBounty,$AvailableBounty,
$TotalSnatches,$TotalTorrents,$TotalOverallSnatches,$TotalSeeders,
$TotalPeers,$TotalPeerUsers) = $EconomicStats;
list($TotalUpload, $TotalDownload, $NumUsers, $TotalBounty, $AvailableBounty,
$TotalSnatches, $TotalTorrents, $TotalOverallSnatches, $TotalSeeders,
$TotalPeers, $TotalPeerUsers) = $EconomicStats;
}
$TotalLeechers = $TotalPeers - $TotalSeeders;
@ -111,10 +121,10 @@
<ul class="stats nobullet">
<li><strong>Total seeders: </strong><?=number_format($TotalSeeders)?></li>
<li><strong>Total leechers: </strong><?=number_format($TotalLeechers)?></li>
<li><strong>Total peers: </strong><?=number_format($TotalSeeders+$TotalLeechers)?></li>
<li><strong>Total peers: </strong><?=number_format($TotalSeeders + $TotalLeechers)?></li>
<li><strong>Total snatches: </strong><?=number_format($TotalOverallSnatches)?></li>
<li><strong>Seeder/leecher ratio: </strong><?=Format::get_ratio_html($TotalSeeders,$TotalLeechers)?></li>
<li><strong>Seeder/snatch ratio: </strong><?=Format::get_ratio_html($TotalSeeders,$TotalOverallSnatches)?></li>
<li><strong>Seeder/leecher ratio: </strong><?=Format::get_ratio_html($TotalSeeders, $TotalLeechers)?></li>
<li><strong>Seeder/snatch ratio: </strong><?=Format::get_ratio_html($TotalSeeders, $TotalOverallSnatches)?></li>
<br />
<li><strong>Mean seeders per torrent: </strong><?=number_format($TotalSeeders / $TotalTorrents, 2)?></li>
<li><strong>Mean leechers per torrent: </strong><?=number_format($TotalLeechers / $TotalTorrents, 2)?></li>

View File

@ -6,10 +6,11 @@
?>
<div class="thin">
<?
$DB->query("SELECT m.ID
FROM users_main AS m
WHERE m.CustomPermissions != ''
AND m.CustomPermissions != 'a:0:{}'");
$DB->query("
SELECT m.ID
FROM users_main AS m
WHERE m.CustomPermissions != ''
AND m.CustomPermissions != 'a:0:{}'");
if ($DB->record_count()) {
?>
<table width="100%">

View File

@ -5,9 +5,14 @@
View::show_header('Torrents');
if (!$TorrentStats = $Cache->get_value('new_torrent_stats')) {
$DB->query("SELECT COUNT(ID), SUM(Size), SUM(FileCount) FROM torrents");
$DB->query("
SELECT COUNT(ID), SUM(Size), SUM(FileCount)
FROM torrents");
list($TorrentCount, $TotalSize, $TotalFiles) = $DB->next_record();
$DB->query("SELECT COUNT(ID) FROM users_main WHERE Enabled='1'");
$DB->query("
SELECT COUNT(ID)
FROM users_main
WHERE Enabled = '1'");
list($NumUsers) = $DB->next_record();
$DB->query("SELECT COUNT(ID), SUM(Size), SUM(FileCount) FROM torrents WHERE Time > SUBDATE('".sqltime()."', INTERVAL 1 DAY)");
list($DayNum, $DaySize, $DayFiles) = $DB->next_record();
@ -15,13 +20,13 @@
list($WeekNum, $WeekSize, $WeekFiles) = $DB->next_record();
$DB->query("SELECT COUNT(ID), SUM(Size), SUM(FileCount) FROM torrents WHERE Time > SUBDATE('".sqltime()."', INTERVAL 30 DAY)");
list($MonthNum, $MonthSize, $MonthFiles) = $DB->next_record();
$Cache->cache_value('new_torrent_stats',array($TorrentCount,$TotalSize,$TotalFiles,
$NumUsers,$DayNum,$DaySize,$DayFiles,
$WeekNum,$WeekSize,$WeekFiles,$MonthNum,
$MonthSize,$MonthFiles),3600);
$Cache->cache_value('new_torrent_stats', array($TorrentCount, $TotalSize, $TotalFiles,
$NumUsers, $DayNum, $DaySize, $DayFiles,
$WeekNum, $WeekSize, $WeekFiles, $MonthNum,
$MonthSize, $MonthFiles), 3600);
} else {
list($TorrentCount,$TotalSize,$TotalFiles,$NumUsers,$DayNum,$DaySize,$DayFiles,
$WeekNum,$WeekSize,$WeekFiles,$MonthNum,$MonthSize,$MonthFiles) = $TorrentStats;
list($TorrentCount, $TotalSize, $TotalFiles, $NumUsers, $DayNum, $DaySize, $DayFiles,
$WeekNum, $WeekSize, $WeekFiles, $MonthNum, $MonthSize, $MonthFiles) = $TorrentStats;
}
?>

View File

@ -469,6 +469,9 @@
error(403);
}
break;
case 'bbcode_sandbox':
include('misc/bbcode_sandbox.php');
break;
default:
include(SERVER_ROOT.'/sections/tools/tools.php');

View File

@ -9,15 +9,17 @@
if (!is_number($_POST['id']) || $_POST['id'] == '') {
error(0);
}
$DB->query('DELETE FROM forums WHERE ID='.$_POST['id']);
$DB->query('
DELETE FROM forums
WHERE ID = '.$_POST['id']);
} else { //Edit & Create, Shared Validation
$Val->SetFields('name', '1','string','The name must be set, and has a max length of 40 characters', array('maxlength'=>40, 'minlength'=>1));
$Val->SetFields('description', '0','string','The description has a max length of 255 characters', array('maxlength'=>255));
$Val->SetFields('sort', '1','number','Sort must be set');
$Val->SetFields('categoryid', '1','number','Category must be set');
$Val->SetFields('minclassread', '1','number','MinClassRead must be set');
$Val->SetFields('minclasswrite', '1','number','MinClassWrite must be set');
$Val->SetFields('minclasscreate', '1','number','MinClassCreate must be set');
$Val->SetFields('name', '1', 'string', 'The name must be set, and has a max length of 40 characters', array('maxlength' => 40, 'minlength' => 1));
$Val->SetFields('description', '0', 'string', 'The description has a max length of 255 characters', array('maxlength' => 255));
$Val->SetFields('sort', '1', 'number', 'Sort must be set');
$Val->SetFields('categoryid', '1', 'number', 'Category must be set');
$Val->SetFields('minclassread', '1', 'number', 'MinClassRead must be set');
$Val->SetFields('minclasswrite', '1', 'number', 'MinClassWrite must be set');
$Val->SetFields('minclasscreate', '1', 'number', 'MinClassCreate must be set');
$Err = $Val->ValidateForm($_POST); // Validate the form
if ($Err) {
error($Err);
@ -32,7 +34,10 @@
if (!is_number($_POST['id']) || $_POST['id'] == '') {
error(0);
}
$DB->query('SELECT MinClassRead FROM forums WHERE ID=' . $P['id']);
$DB->query('
SELECT MinClassRead
FROM forums
WHERE ID = ' . $P['id']);
if ($DB->record_count() < 1) {
error(404);
} else {
@ -45,20 +50,22 @@
$DB->query("
UPDATE forums
SET
Sort='$P[sort]',
CategoryID='$P[categoryid]',
Name='$P[name]',
Description='$P[description]',
MinClassRead='$P[minclassread]',
MinClassWrite='$P[minclasswrite]',
MinClassCreate='$P[minclasscreate]',
AutoLock='$P[autolock]',
AutoLockWeeks='$P[autolockweeks]'
WHERE ID='$P[id]'");
Sort = '$P[sort]',
CategoryID = '$P[categoryid]',
Name = '$P[name]',
Description = '$P[description]',
MinClassRead = '$P[minclassread]',
MinClassWrite = '$P[minclasswrite]',
MinClassCreate = '$P[minclasscreate]',
AutoLock = '$P[autolock]',
AutoLockWeeks = '$P[autolockweeks]'
WHERE ID = '$P[id]'");
} else { //Create
$DB->query("INSERT INTO forums
(Sort, CategoryID, Name, Description, MinClassRead, MinClassWrite, MinClassCreate, AutoLock, AutoLockWeeks) VALUES
('$P[sort]', '$P[categoryid]', '$P[name]','$P[description]','$P[minclassread]','$P[minclasswrite]','$P[minclasscreate]','$P[autolock]','$P[autolockweeks]')");
$DB->query("
INSERT INTO forums
(Sort, CategoryID, Name, Description, MinClassRead, MinClassWrite, MinClassCreate, AutoLock, AutoLockWeeks)
VALUES
('$P[sort]', '$P[categoryid]', '$P[name]', '$P[description]', '$P[minclassread]', '$P[minclasswrite]', '$P[minclasscreate]', '$P[autolock]', '$P[autolockweeks]')");
}
}

View File

@ -9,11 +9,11 @@ function class_list($Selected = 0) {
$Name = $Class['Name'];
$Level = $Class['Level'];
$Return.='<option value="'.$Level.'"';
$Return .= "<option value=\"$Level\"";
if ($Selected == $Level) {
$Return.=' selected="selected"';
$Return .= ' selected="selected"';
}
$Return.='>'.Format::cut_string($Name, 20, 1).'</option>'."\n";
$Return .= '>'.Format::cut_string($Name, 20, 1)."</option>\n";
}
reset($Classes);
return $Return;
@ -24,14 +24,19 @@ function class_list($Selected = 0) {
}
View::show_header('Forum Management');
$DB->query('SELECT ID, Name FROM forums ORDER BY Sort');
$DB->query('
SELECT ID, Name
FROM forums
ORDER BY Sort');
$ForumArray = $DB->to_array(); // used for generating the 'parent' drop down list
// Replace the old hard-coded forum categories
unset($ForumCats);
$ForumCats = $Cache->get_value('forums_categories');
if ($ForumCats === false) {
$DB->query('SELECT ID, Name FROM forums_categories');
$DB->query('
SELECT ID, Name
FROM forums_categories');
$ForumCats = array();
while (list($ID, $Name) = $DB->next_record()) {
$ForumCats[$ID] = $Name;
@ -55,7 +60,7 @@ function class_list($Selected = 0) {
ORDER BY CategoryID, Sort ASC');
?>
<div class="header">
<script type="text/javacript">document.getElementByID('content').style.overflow='visible';</script>
<script type="text/javacript">document.getElementByID('content').style.overflow = 'visible';</script>
<h2>Forum control panel</h2>
</div>
<table width="100%">
@ -67,8 +72,8 @@ function class_list($Selected = 0) {
<td>Min class read</td>
<td>Min class write</td>
<td>Min class create</td>
<td>Autolock</td>
<td>Autolock weeks</td>
<td>Auto-lock</td>
<td>Auto-lock weeks</td>
<td>Submit</td>
</tr>
<?
@ -86,7 +91,7 @@ function class_list($Selected = 0) {
<? reset($ForumCats);
foreach ($ForumCats as $CurCat => $CatName) {
?>
<option value="<?=$CurCat?>" <? if ($CurCat == $CategoryID) { echo ' selected="selected"'; } ?>><?=$CatName?></option>
<option value="<?=$CurCat?>"<? if ($CurCat == $CategoryID) { echo ' selected="selected"'; } ?>><?=$CatName?></option>
<? } ?>
</select>
</td>

View File

@ -6,7 +6,7 @@
include(SERVER_ROOT.'/classes/text.class.php');
$Text = new TEXT;
View::show_header('Manage news','bbcode');
View::show_header('Manage news', 'bbcode');
switch ($_GET['action']) {
case 'takeeditnews':
@ -16,7 +16,10 @@
if (is_number($_POST['newsid'])) {
authorize();
$DB->query("UPDATE news SET Title='".db_string($_POST['title'])."', Body='".db_string($_POST['body'])."' WHERE ID='".db_string($_POST['newsid'])."'");
$DB->query("
UPDATE news
SET Title = '".db_string($_POST['title'])."', Body = '".db_string($_POST['body'])."'
WHERE ID = '".db_string($_POST['newsid'])."'");
$Cache->delete_value('news');
$Cache->delete_value('feed_news');
}
@ -25,7 +28,10 @@
case 'editnews':
if (is_number($_GET['id'])) {
$NewsID = $_GET['id'];
$DB->query("SELECT Title, Body FROM news WHERE ID=$NewsID");
$DB->query("
SELECT Title, Body
FROM news
WHERE ID = $NewsID");
list($Title, $Body) = $DB->next_record();
}
}

View File

@ -15,19 +15,32 @@
}
$OldTagIDs = implode(', ', $OldTagIDs);
$DB->query("UPDATE tags SET TagType = 'other' WHERE ID IN ($OldTagIDs)");
$DB->query("
UPDATE tags
SET TagType = 'other'
WHERE ID IN ($OldTagIDs)");
}
if ($_POST['newtag']) {
$TagName = Misc::sanitize_tag($_POST['newtag']);
$DB->query("SELECT t.ID FROM tags AS t WHERE t.Name LIKE '".$TagName."'");
$DB->query("
SELECT t.ID
FROM tags AS t
WHERE t.Name LIKE '$TagName'");
list($TagID) = $DB->next_record();
if ($TagID) {
$DB->query("UPDATE tags SET TagType = 'genre' WHERE ID = $TagID");
$DB->query("
UPDATE tags
SET TagType = 'genre'
WHERE ID = $TagID");
} else { // Tag doesn't exist yet - create tag
$DB->query("INSERT INTO tags (Name, UserID, TagType, Uses) VALUES ('".$TagName."', ".$LoggedUser['ID'].", 'genre', 0)");
$DB->query("
INSERT INTO tags
(Name, UserID, TagType, Uses)
VALUES
('$TagName', ".$LoggedUser['ID'].", 'genre', 0)");
$TagID = $DB->inserted_id();
}
}
@ -62,7 +75,11 @@
</tr>
<?
$i = 0;
$DB->query("SELECT ID, Name, Uses FROM tags WHERE TagType='genre' ORDER BY Name ASC");
$DB->query("
SELECT ID, Name, Uses
FROM tags
WHERE TagType = 'genre'
ORDER BY Name ASC");
$TagCount = $DB->record_count();
$Tags = $DB->to_array();
for ($i = 0; $i < $TagCount / 3; $i++) {

View File

@ -4,7 +4,7 @@
<script type="text/javascript">//<![CDATA[
function confirmDelete(id) {
if (confirm("Are you sure you want to remove this permission class?")) {
location.href="tools.php?action=permissions&removeid="+id;
location.href = "tools.php?action=permissions&removeid=" + id;
}
return false;
}
@ -18,17 +18,18 @@ function confirmDelete(id) {
</div>
</div>
<?
$DB->query("SELECT
p.ID,
p.Name,
p.Level,
p.Secondary,
COUNT(u.ID)+COUNT(DISTINCT l.UserID)
FROM permissions AS p
LEFT JOIN users_main AS u ON u.PermissionID=p.ID
LEFT JOIN users_levels AS l ON l.PermissionID=p.ID
GROUP BY p.ID
ORDER BY p.Secondary ASC, p.Level ASC");
$DB->query("
SELECT
p.ID,
p.Name,
p.Level,
p.Secondary,
COUNT(u.ID) + COUNT(DISTINCT l.UserID)
FROM permissions AS p
LEFT JOIN users_main AS u ON u.PermissionID = p.ID
LEFT JOIN users_levels AS l ON l.PermissionID = p.ID
GROUP BY p.ID
ORDER BY p.Secondary ASC, p.Level ASC");
if ($DB->record_count()) {
?>
<table width="100%">
@ -38,14 +39,14 @@ function confirmDelete(id) {
<td>User count</td>
<td class="center">Actions</td>
</tr>
<? while (list($ID,$Name,$Level,$Secondary,$UserCount)=$DB->next_record()) { ?>
<? while (list($ID, $Name, $Level, $Secondary, $UserCount) = $DB->next_record()) { ?>
<tr>
<td><?=display_str($Name); ?></td>
<td><?=($Secondary ? 'Secondary' : $Level) ?></td>
<td><?=number_format($UserCount); ?></td>
<td class="center">
<a href="tools.php?action=permissions&amp;id=<?=$ID ?>" class="brackets">Edit</a>
<a href="#" onclick="return confirmDelete(<?=$ID?>)" class="brackets">Remove</a>
<a href="#" onclick="return confirmDelete(<?=$ID?>);" class="brackets">Remove</a>
</td>
</tr>
<? } ?>

View File

@ -12,14 +12,19 @@
}
if (!check_perms('site_manage_recommendations')) {
$DB->query("SELECT UserID FROM torrents_recommended WHERE GroupID='$GroupID'");
$DB->query("
SELECT UserID
FROM torrents_recommended
WHERE GroupID = '$GroupID'");
list($UserID) = $DB->next_record();
if ($UserID != $LoggedUser['ID']) {
error(403);
}
}
$DB->query("DELETE FROM torrents_recommended WHERE GroupID='$GroupID'");
$DB->query("
DELETE FROM torrents_recommended
WHERE GroupID = '$GroupID'");
$Cache->delete_value('recommend');
header('Location: '.$_SERVER['HTTP_REFERER']);

View File

@ -8,7 +8,9 @@
error(403);
}
$DB->query('SELECT GroupID FROM torrents_recommended');
$DB->query('
SELECT GroupID
FROM torrents_recommended');
$ToNL = $DB->next_record();
Torrents::freeleech_groups($ToNL, 2, 3);
?>

View File

@ -10,9 +10,14 @@
error('1');
}
$DB->query("SELECT peer_id FROM xbt_client_whitelist WHERE id = ".$_POST['id']);
$DB->query('
SELECT peer_id
FROM xbt_client_whitelist
WHERE id = '.$_POST['id']);
list($PeerID) = $DB->next_record();
$DB->query('DELETE FROM xbt_client_whitelist WHERE id='.$_POST['id']);
$DB->query('
DELETE FROM xbt_client_whitelist
WHERE id = '.$_POST['id']);
Tracker::update_tracker('remove_whitelist', array('peer_id' => $PeerID));
} else { //Edit & Create, Shared Validation
@ -28,21 +33,25 @@
if (empty($_POST['id']) || !is_number($_POST['id'])) {
error('3');
} else {
$DB->query("SELECT peer_id FROM xbt_client_whitelist WHERE id = ".$_POST['id']);
$DB->query('
SELECT peer_id
FROM xbt_client_whitelist
WHERE id = '.$_POST['id']);
list($OldPeerID) = $DB->next_record();
$DB->query("
UPDATE xbt_client_whitelist
SET
vstring='".$Client."',
peer_id='".$PeerID."'
WHERE ID=".$_POST['id']);
vstring = '$Client',
peer_id = '$PeerID'
WHERE ID = ".$_POST['id']);
Tracker::update_tracker('edit_whitelist', array('old_peer_id' => $OldPeerID, 'new_peer_id' => $PeerID));
}
} else { //Create
$DB->query("
INSERT INTO xbt_client_whitelist (vstring, peer_id)
INSERT INTO xbt_client_whitelist
(vstring, peer_id)
VALUES
('$Client','$PeerID')");
('$Client', '$PeerID')");
Tracker::update_tracker('add_whitelist', array('peer_id' => $PeerID));
}
}

View File

@ -4,7 +4,10 @@
}
View::show_header('Whitelist Management');
$DB->query('SELECT id, vstring, peer_id FROM xbt_client_whitelist ORDER BY peer_id ASC');
$DB->query('
SELECT id, vstring, peer_id
FROM xbt_client_whitelist
ORDER BY peer_id ASC');
?>
<div class="header">
<h2>Allowed Clients</h2>

View File

@ -0,0 +1,16 @@
<?
if (!check_perms("users_mod")) {
error(403);
}
View::show_header("BBCode Sandbox", 'bbcode_sandbox');
?>
<div class="thin">
<textarea id="sandbox" class="wbbarea" style="width: 98%;" onkeyup="resize('sandbox');" name="body" cols="90" rows="8"></textarea>
<br />
<br />
<div id="preview" class="">
</div>
</div>
<?
View::show_footer();

View File

@ -51,7 +51,8 @@
// validate input
$Err = $Val->ValidateForm($_GET);
if ($Err) {
echo ' <div class="box pad center">
echo '
<div class="box pad center">
<strong>Error:</strong> '.$Err.'
</div>';
} else {
@ -60,8 +61,9 @@
// trying to merge tag with itself would create big problems
if ($Tag == $Replacement) {
echo " <div class=\"box pad center\">
<strong>Error:</strong> Cannot merge tag $Tag with itself (doh).
echo "
<div class=\"box pad center\">
<strong>Error:</strong> Cannot merge tag $Tag with itself!
</div>
</div>";
View::show_footer();
@ -75,7 +77,8 @@
WHERE Name = '$Tag'
LIMIT 1;");
if ($DB->record_count() == 0) {
echo " <div class=\"box pad center\">
echo "
<div class=\"box pad center\">
<strong>Error:</strong> No such tag found: $Tag
</div>
</div>";
@ -107,9 +110,9 @@
ag.Name,
tg.Name
FROM torrents_group AS tg
LEFT JOIN artists_group AS ag ON ag.ArtistID=tg.ArtistID
JOIN torrents_tags AS t ON t.GroupID=tg.ID
WHERE t.TagID=$TagID;");
LEFT JOIN artists_group AS ag ON ag.ArtistID = tg.ArtistID
JOIN torrents_tags AS t ON t.GroupID = tg.ID
WHERE t.TagID = $TagID;");
while (list($TorrentID, $ArtistID, $ArtistName, $TorrentName) = $DB->next_record()) {
$Row = ($ArtistName ? "<a href=\"artist.php?id=$ArtistID\">$ArtistName</a> - " : '');
$Row.= "<a href=\"torrents.php?id=$TorrentID\">".display_str($TorrentName).'</a>';
@ -124,10 +127,10 @@
ag.Name,
r.Title
FROM requests AS r
LEFT JOIN requests_artists AS ra ON r.ID=ra.RequestID
LEFT JOIN artists_group AS ag ON ag.ArtistID=ra.ArtistID
JOIN requests_tags AS t ON t.RequestID=r.ID
WHERE t.TagID=$TagID;");
LEFT JOIN requests_artists AS ra ON r.ID = ra.RequestID
LEFT JOIN artists_group AS ag ON ag.ArtistID = ra.ArtistID
JOIN requests_tags AS t ON t.RequestID = r.ID
WHERE t.TagID = $TagID;");
while (list($RequestID, $ArtistID, $ArtistName, $RequestName) = $DB->next_record()) {
$Row = ($ArtistName ? "<a href=\"artist.php?id=$ArtistID\">$ArtistName</a> - " : '');
$Row.= "<a href=\"requests.php?action=viewrequest&amp;id=$RequestID\">".display_str($RequestName).'</a>';
@ -149,14 +152,17 @@
// HARD! merge two tags together and update usage
// 5) remove dupe tags from torrents
// (torrents that have both "old tag" and "replacement tag" set)
$DB->query("SELECT GroupID FROM torrents_tags WHERE TagID=$ReplacementID;");
$DB->query("
SELECT GroupID
FROM torrents_tags
WHERE TagID = $ReplacementID;");
if ($DB->record_count() > 0 ) {
$Query = "
DELETE FROM torrents_tags
WHERE TagID=$TagID
WHERE TagID = $TagID
AND GroupID IN (";
while (list($GroupID) = $DB->next_record()) {
$Query.= $GroupID.',';
$Query .= "$GroupID,";
}
$Query = substr($Query, 0, -1) . ');';
$DB->query($Query);
@ -166,19 +172,22 @@
// 6) replace old tag in torrents
$DB->query("
UPDATE torrents_tags
SET TagID=$ReplacementID
WHERE TagID=$TagID;");
SET TagID = $ReplacementID
WHERE TagID = $TagID;");
$UsageChange = $DB->affected_rows();
// 7) remove dupe tags from artists
$DB->query("SELECT ArtistID FROM artists_tags WHERE TagID=$ReplacementID;");
$DB->query("
SELECT ArtistID
FROM artists_tags
WHERE TagID = $ReplacementID;");
if ($DB->record_count() > 0 ) {
$Query = "
DELETE FROM artists_tags
WHERE TagID=$TagID
WHERE TagID = $TagID
AND ArtistID IN (";
while (list($ArtistID) = $DB->next_record()) {
$Query.= $ArtistID.',';
$Query .= "$ArtistID,";
}
$Query = substr($Query, 0, -1) . ');';
$DB->query($Query);
@ -188,19 +197,22 @@
// 8) replace old tag in artists
$DB->query("
UPDATE artists_tags
SET TagID=$ReplacementID
WHERE TagID=$TagID;");
SET TagID = $ReplacementID
WHERE TagID = $TagID;");
$UsageChange += $DB->affected_rows();
// 9) remove dupe tags from requests
$DB->query("SELECT RequestID FROM requests_tags WHERE TagID=$ReplacementID;");
$DB->query("
SELECT RequestID
FROM requests_tags
WHERE TagID = $ReplacementID;");
if ($DB->record_count() > 0) {
$Query = "
DELETE FROM requests_tags
WHERE TagID=$TagID
WHERE TagID = $TagID
AND RequestID IN (";
while (list($RequestID) = $DB->next_record()) {
$Query.= $RequestID.',';
$Query .= "$RequestID,";
}
$Query = substr($Query, 0, -1) . ');';
$DB->query($Query);
@ -210,27 +222,27 @@
// 10) replace old tag in requests
$DB->query("
UPDATE requests_tags
SET TagID=$ReplacementID
WHERE TagID=$TagID;");
SET TagID = $ReplacementID
WHERE TagID = $TagID;");
$UsageChange += $DB->affected_rows();
$TotalAffected += $UsageChange;
// 11) finally, remove old tag completely
$DB->query("
DELETE FROM tags
WHERE ID=$TagID
WHERE ID = $TagID
LIMIT 1");
// 12) update usage count for replacement tag
$DB->query("
UPDATE tags
SET Uses=Uses+$UsageChange
WHERE ID=$ReplacementID
SET Uses = Uses + $UsageChange
WHERE ID = $ReplacementID
LIMIT 1");
} // if ($Mode == MODE_MERGE)
echo '<div class="box pad center"><strong>Success!</strong> Affected entries: '.number_format($TotalAffected).'</div>';
echo "\n".'<div class="box pad center"><strong>Success!</strong> Affected entries: '.number_format($TotalAffected).'</div>';
if ($_GET['list']) {
?>
@ -244,7 +256,7 @@
<?
if (count($AffectedTorrents)) {
foreach ($AffectedTorrents as $Row) {
echo "<tr><td>$Row</td></tr>";
echo "\n\t\t<tr><td>$Row</td></tr>";
}
}
?>
@ -256,7 +268,7 @@
<?
if (count($AffectedRequests)) {
foreach ($AffectedRequests as $Row) {
echo "<tr><td>$Row</td></tr>";
echo "\n\t\t<tr><td>$Row</td></tr>";
}
}
?>

View File

@ -89,6 +89,7 @@
<? } if (check_perms('admin_clear_cache') || check_perms('users_mod')) { ?>
<tr><td><a href="tools.php?action=rerender_gallery">Rerender stylesheet gallery images</a></td></tr>
<? } if (check_perms('users_mod')) { ?>
<tr><td><a href="tools.php?action=bbcode_sandbox">BBCode Sandbox</a></td></tr>
<tr><td><strong><a href="tools.php?action=public_sandbox">Public sandbox</a></strong></td></tr>
<? } if (check_perms('users_mod')) { ?>
<tr><td><strong><a href="tools.php?action=mod_sandbox">Mod-level sandbox</a></strong></td></tr>

View File

@ -52,15 +52,20 @@
if (empty($_GET['datetype']) || $_GET['datetype'] == 'day') {
$Type = 'day';
$Where = "WHERE th.Date BETWEEN '".$SQLTime."' AND '".$SQLTime."' + INTERVAL 24 HOUR AND Type='Daily'";
$Where = "
WHERE th.Date BETWEEN '$SQLTime' AND '$SQLTime' + INTERVAL 24 HOUR
AND Type = 'Daily'";
} else {
$Type = 'week';
$Where = "WHERE th.Date BETWEEN '".$SQLTime."' - AND '".$SQLTime."' + INTERVAL 7 DAY' AND Type='Weekly'";
$Where = "
WHERE th.Date BETWEEN '$SQLTime' - AND '$SQLTime' + INTERVAL 7 DAY
AND Type = 'Weekly'";
}
$Details = $Cache->get_value('top10_history_'.$SQLTime);
$Details = $Cache->get_value("top10_history_$SQLTime");
if ($Details === false) {
$DB->query("SELECT
$DB->query("
SELECT
tht.Rank,
tht.TitleString,
tht.TagString,
@ -83,12 +88,12 @@
LEFT JOIN top10_history_torrents AS tht ON tht.HistoryID = th.ID
LEFT JOIN torrents AS t ON t.ID = tht.TorrentID
LEFT JOIN torrents_group AS g ON g.ID = t.GroupID
".$Where."
$Where
ORDER BY tht.Rank ASC");
$Details = $DB->to_array();
$Cache->cache_value('top10_history_'.$SQLTime, $Details, 3600*24);
$Cache->cache_value("top10_history_$SQLTime", $Details, 3600 * 24);
}
?>
@ -103,16 +108,16 @@
</tr>
<?
foreach ($Details as $Detail) :
list($Rank, $TitleString, $TagString, $TorrentID, $GroupID,$GroupName,$GroupCategoryID,$TorrentTags,
$Format,$Encoding,$Media,$Scene,$HasLog,$HasCue,$LogScore,$Year,$GroupYear,
$RemasterTitle,$Snatched,$Seeders,$Leechers,$Data) = $Detail;
list($Rank, $TitleString, $TagString, $TorrentID, $GroupID, $GroupName, $GroupCategoryID, $TorrentTags,
$Format, $Encoding, $Media, $Scene, $HasLog, $HasCue, $LogScore, $Year, $GroupYear,
$RemasterTitle, $Snatched, $Seeders, $Leechers, $Data) = $Detail;
// highlight every other row
$Highlight = ($Rank % 2 ? 'a' : 'b');
if ($GroupID) :
//Group still exists
$DisplayName='';
// Group still exists
$DisplayName = '';
$Artists = Artists::get_artist($GroupID);
@ -123,43 +128,43 @@
$DisplayName .= "<a href=\"torrents.php?id=$GroupID&amp;torrentid=$TorrentID\" title=\"View Torrent\">$GroupName</a>";
if ($GroupCategoryID == 1 && $GroupYear > 0) {
$DisplayName.= " [$GroupYear]";
$DisplayName .= " [$GroupYear]";
}
// append extra info to torrent title
$ExtraInfo = '';
$AddExtra = '';
if ($Format) {
$ExtraInfo.= $Format;
$ExtraInfo .= $Format;
$AddExtra = ' / ';
}
if ($Encoding) {
$ExtraInfo.= $AddExtra.$Encoding;
$ExtraInfo .= $AddExtra.$Encoding;
$AddExtra = ' / ';
}
//"FLAC / Lossless / Log (100%) / Cue / CD";
if ($HasLog) {
$ExtraInfo.= "$AddExtra Log ($LogScore".'%)';
$ExtraInfo .= "$AddExtra Log ($LogScore%)";
$AddExtra = ' / ';
}
if ($HasCue) {
$ExtraInfo.= $AddExtra.'Cue';
$ExtraInfo .= "{$AddExtra}Cue";
$AddExtra = ' / ';
}
if ($Media) {
$ExtraInfo.= $AddExtra.$Media;
$ExtraInfo .= $AddExtra.$Media;
$AddExtra = ' / ';
}
if ($Scene) {
$ExtraInfo.= $AddExtra.'Scene';
$ExtraInfo .= "{$AddExtra}Scene";
$AddExtra = ' / ';
}
if ($Year > 0) {
$ExtraInfo.= $AddExtra.$Year;
$ExtraInfo .= $AddExtra.$Year;
$AddExtra = ' ';
}
if ($RemasterTitle) {
$ExtraInfo.= $AddExtra.$RemasterTitle;
$ExtraInfo .= $AddExtra.$RemasterTitle;
}
if ($ExtraInfo != '') {
$ExtraInfo = "- [$ExtraInfo]";
@ -168,7 +173,7 @@
$DisplayName .= $ExtraInfo;
$TorrentTags = new Tags($TorrentTags);
else:
$DisplayName = $TitleString.' (Deleted)';
$DisplayName = "$TitleString (Deleted)";
$TorrentTags = new Tags($TagString);
endif;

View File

@ -68,7 +68,7 @@
<tr id="tagfilter">
<td class="label">Tags (comma-separated):</td>
<td class="ft_taglist">
<input type="text" name="tags" id="tags" size="75" value="<? if (!empty($_GET['tags'])) { echo display_str($_GET['tags']);} ?>" <? Users::has_autocomplete_enabled('other'); ?>/>&nbsp;
<input type="text" name="tags" id="tags" size="75" value="<? if (!empty($_GET['tags'])) { echo display_str($_GET['tags']);} ?>"<? Users::has_autocomplete_enabled('other'); ?> />&nbsp;
<input type="radio" id="rdoAll" name="anyall" value="all"<?=($_GET['anyall']!='any'?' checked="checked"':'')?> /><label for="rdoAll"> All</label>&nbsp;&nbsp;
<input type="radio" id="rdoAny" name="anyall" value="any"<?=($_GET['anyall']=='any'?' checked="checked"':'')?> /><label for="rdoAny"> Any</label>
</td>

View File

@ -16,12 +16,15 @@
$AliasName = Artists::normalise_artist_name($AliasNames[$i]);
$Importance = $Importances[$i];
if ($Importance!='1' && $Importance!='2' && $Importance!='3' && $Importance!='4' && $Importance!='5' && $Importance!='6' && $Importance!='7') {
if ($Importance != '1' && $Importance != '2' && $Importance != '3' && $Importance != '4' && $Importance != '5' && $Importance != '6' && $Importance != '7') {
break;
}
if (strlen($AliasName) > 0) {
$DB->query("SELECT AliasID, ArtistID, Redirect, Name FROM artists_alias WHERE Name = '".db_string($AliasName)."'");
$DB->query("
SELECT AliasID, ArtistID, Redirect, Name
FROM artists_alias
WHERE Name = '".db_string($AliasName)."'");
while (list($AliasID, $ArtistID, $Redirect, $FoundAliasName) = $DB->next_record(MYSQLI_NUM, false)) {
if (!strcasecmp($AliasName, $FoundAliasName)) {
if ($Redirect) {
@ -32,43 +35,56 @@
}
if (!$AliasID) {
$AliasName = db_string($AliasName);
$DB->query("INSERT INTO artists_group (Name) VALUES ('$AliasName')");
$DB->query("
INSERT INTO artists_group (Name)
VALUES ('$AliasName')");
$ArtistID = $DB->inserted_id();
$DB->query("INSERT INTO artists_alias (ArtistID, Name) VALUES ('$ArtistID', '$AliasName')");
$DB->query("
INSERT INTO artists_alias (ArtistID, Name)
VALUES ('$ArtistID', '$AliasName')");
$AliasID = $DB->inserted_id();
}
$DB->query("SELECT Name FROM torrents_group WHERE ID=".$GroupID);
$DB->query("
SELECT Name
FROM torrents_group
WHERE ID = $GroupID");
list($GroupName) = $DB->next_record(MYSQLI_NUM, false);
$DB->query("SELECT Name FROM artists_group WHERE ArtistID=".$ArtistID);
$DB->query("
SELECT Name
FROM artists_group
WHERE ArtistID = $ArtistID");
list($ArtistName) = $DB->next_record(MYSQLI_NUM, false);
$DB->query("INSERT IGNORE INTO torrents_artists
(GroupID, ArtistID, AliasID, Importance, UserID) VALUES
('$GroupID', '$ArtistID', '$AliasID', '$Importance', '$UserID')");
$DB->query("
INSERT IGNORE INTO torrents_artists
(GroupID, ArtistID, AliasID, Importance, UserID)
VALUES
('$GroupID', '$ArtistID', '$AliasID', '$Importance', '$UserID')");
if ($DB->affected_rows()) {
$Changed = true;
$DB->query("INSERT INTO torrents_group (ID, NumArtists)
$DB->query("
INSERT INTO torrents_group (ID, NumArtists)
SELECT ta.GroupID, COUNT(ta.ArtistID)
FROM torrents_artists AS ta
WHERE ta.GroupID='$GroupID'
AND ta.Importance='1'
WHERE ta.GroupID = '$GroupID'
AND ta.Importance = '1'
GROUP BY ta.GroupID
ON DUPLICATE KEY UPDATE
NumArtists=VALUES(NumArtists);");
NumArtists = VALUES (NumArtists);");
Misc::write_log("Artist ".$ArtistID." (".$ArtistName.") was added to the group ".$GroupID." (".$GroupName.") as ".$ArtistTypes[$Importance]." by user ".$LoggedUser['ID']." (".$LoggedUser['Username'].")");
Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "added artist ".$ArtistName." as ".$ArtistTypes[$Importance], 0);
Misc::write_log("Artist $ArtistID ($ArtistName) was added to the group $GroupID ($GroupName) as ".$ArtistTypes[$Importance].' by user '.$LoggedUser['ID'].' ('.$LoggedUser['Username'].')');
Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "added artist $ArtistName as ".$ArtistTypes[$Importance], 0);
}
}
}
if ($Changed) {
$Cache->delete_value('torrents_details_'.$GroupID);
$Cache->delete_value('groups_artists_'.$GroupID); // Delete group artist cache
$Cache->delete_value("torrents_details_$GroupID");
$Cache->delete_value("groups_artists_$GroupID"); // Delete group artist cache
Torrents::update_hash($GroupID);
}

View File

@ -21,7 +21,7 @@
$ErrorPage = true;
define('EXPLAIN_HACK',false);
define('EXPLAIN_HACK', false);
if (EXPLAIN_HACK) {
$SCFR = '';
@ -39,62 +39,62 @@ function build_search($SearchStr, $Field, $Exact = false, $SQLWhere = '', $FullT
}
if (!$Exact) {
if ($FullText && preg_match('/[^a-zA-Z0-9 ]/i',$SearchStr)) {
if ($FullText && preg_match('/[^a-zA-Z0-9 ]/i', $SearchStr)) {
$FullText = 0;
}
$SearchLength = strlen(trim($SearchStr));
$SearchStr = preg_replace('/\s\s+/',' ',trim($SearchStr));
$SearchStr = preg_replace_callback('/"(([^"])*)"/','quotes',$SearchStr);
$SearchStr = explode(' ',$SearchStr);
$SearchStr = preg_replace('/\s\s+/', ' ', trim($SearchStr));
$SearchStr = preg_replace_callback('/"(([^"])*)"/', 'quotes', $SearchStr);
$SearchStr = explode(' ', $SearchStr);
$FilterString = '(.+?)';
foreach ($SearchStr as $SearchVal) {
if (trim($SearchVal) != '') {
$SearchVal = trim($SearchVal);
$SearchVal = str_replace('{{SPACE}}',' ',$SearchVal);
$SearchVal = str_replace('{{SPACE}}', ' ', $SearchVal);
// Choose between fulltext or LIKE based off length of the string
if ($FullText && strlen($SearchVal) > 2) {
if ($SQLWhere != '') {
$SQLWhere.= ' AND ';
$SQLWhere .= ' AND ';
}
if (substr($SearchVal,0,1) == '-') {
$SQLWhere.="MATCH ($Field) AGAINST ('".db_string($SearchVal)."' IN BOOLEAN MODE)";
if (substr($SearchVal, 0, 1) == '-') {
$SQLWhere .= "MATCH ($Field) AGAINST ('".db_string($SearchVal)."' IN BOOLEAN MODE)";
} else {
$SQLWhere.="MATCH ($Field) AGAINST ('".db_string($SearchVal)."')";
$SQLWhere .= "MATCH ($Field) AGAINST ('".db_string($SearchVal)."')";
}
} else {
if ($SQLWhere != '') {
$SQLWhere.= ' AND ';
$SQLWhere .= ' AND ';
}
if (substr($SearchVal,0,1) == '-') {
$SQLWhere.=$Field." NOT LIKE '%".db_string(substr($SearchVal,1))."%'";
$SQLWhere .= "$Field NOT LIKE '%".db_string(substr($SearchVal,1))."%'";
} else {
$SQLWhere.=$Field." LIKE '%".db_string($SearchVal)."%'";
$SQLWhere .= "$Field LIKE '%".db_string($SearchVal)."%'";
}
}
$FilterString.="($SearchVal)(.+?)";
$FilterString .= "($SearchVal)(.+?)";
}
}
} else {
if ($SQLWhere != '') {
$SQLWhere.= ' AND ';
$SQLWhere .= ' AND ';
}
$SQLWhere.= $Field." LIKE '".db_string($SearchStr)."'";
$FilterString.= "(.+?)($SearchStr)(.+?)";
$SQLWhere .= "$Field LIKE '".db_string($SearchStr)."'";
$FilterString .= "(.+?)($SearchStr)(.+?)";
}
$Search = 1;
$FilterString = "/$FilterString/si";
if ($SQLWhere != '' && $AddWhere) {
$SQLWhere = 'WHERE '.$SQLWhere;
$SQLWhere = "WHERE $SQLWhere";
}
return $SQLWhere;
}
function quotes($Str) {
$Str = str_replace(' ', '{{SPACE}}', trim($Str[1]));
return ' '.$Str.' ';
return " $Str ";
}
// The "order by x" links on columns headers
@ -110,7 +110,7 @@ function header_link($SortKey, $DefaultWay = 'DESC') {
$NewWay = $DefaultWay;
}
return 'torrents.php?order_way='.$NewWay.'&amp;order_by='.$SortKey.'&amp;'.Format::get_url(array('order_way','order_by'));
return "torrents.php?order_way=$NewWay&amp;order_by=$SortKey&amp;" . Format::get_url(array('order_way', 'order_by'));
}
// Setting default search options
@ -118,29 +118,41 @@ function header_link($SortKey, $DefaultWay = 'DESC') {
$UnsetList[] = '/(&?page\=.+?&?)/i';
$UnsetList[] = '/(&?setdefault\=.+?&?)/i';
$DB->query("SELECT SiteOptions FROM users_info WHERE UserID='".db_string($LoggedUser['ID'])."'");
$DB->query("
SELECT SiteOptions
FROM users_info
WHERE UserID = '".db_string($LoggedUser['ID'])."'");
list($SiteOptions) = $DB->next_record(MYSQLI_NUM, true);
$SiteOptions = unserialize($SiteOptions);
$SiteOptions['DefaultSearch'] = preg_replace($UnsetList,'',$_SERVER['QUERY_STRING']);
$DB->query("UPDATE users_info SET SiteOptions='".db_string(serialize($SiteOptions))."' WHERE UserID='".db_string($LoggedUser['ID'])."'");
$Cache->begin_transaction('user_info_heavy_'.$UserID);
$Cache->update_row(false, array('DefaultSearch'=>preg_replace($UnsetList,'',$_SERVER['QUERY_STRING'])));
$SiteOptions['DefaultSearch'] = preg_replace($UnsetList, '', $_SERVER['QUERY_STRING']);
$DB->query("
UPDATE users_info
SET SiteOptions = '".db_string(serialize($SiteOptions))."'
WHERE UserID = '".db_string($LoggedUser['ID'])."'");
$Cache->begin_transaction("user_info_heavy_$UserID");
$Cache->update_row(false, array('DefaultSearch' => preg_replace($UnsetList, '', $_SERVER['QUERY_STRING'])));
$Cache->commit_transaction(0);
// Clearing default search options
} elseif ($_GET['cleardefault']) {
$DB->query("SELECT SiteOptions FROM users_info WHERE UserID='".db_string($LoggedUser['ID'])."'");
$DB->query("
SELECT SiteOptions
FROM users_info
WHERE UserID = '".db_string($LoggedUser['ID'])."'");
list($SiteOptions) = $DB->next_record(MYSQLI_NUM, true);
$SiteOptions = unserialize($SiteOptions);
$SiteOptions['DefaultSearch'] = '';
$DB->query("UPDATE users_info SET SiteOptions='".db_string(serialize($SiteOptions))."' WHERE UserID='".db_string($LoggedUser['ID'])."'");
$Cache->begin_transaction('user_info_heavy_'.$UserID);
$Cache->update_row(false, array('DefaultSearch'=>''));
$DB->query("
UPDATE users_info
SET SiteOptions = '".db_string(serialize($SiteOptions))."'
WHERE UserID = '".db_string($LoggedUser['ID'])."'");
$Cache->begin_transaction("user_info_heavy_$UserID");
$Cache->update_row(false, array('DefaultSearch' => ''));
$Cache->commit_transaction(0);
// Use default search options
} elseif (!$_SERVER['QUERY_STRING'] && $LoggedUser['DefaultSearch']) {
parse_str($LoggedUser['DefaultSearch'],$_GET);
parse_str($LoggedUser['DefaultSearch'], $_GET);
}
// If a user is hammering the search page (either via a <script type="text/javascript">, or just general zeal)
@ -157,38 +169,38 @@ function header_link($SortKey, $DefaultWay = 'DESC') {
list($Page, $Limit) = Format::page_limit(TORRENTS_PER_PAGE);
if (preg_match('/^s[1-7]$/',$_GET['order_by'])) {
if (preg_match('/^s[1-7]$/', $_GET['order_by'])) {
$OrderBy = strtolower($_GET['order_by']);
}
if (in_array(strtolower($_GET['order_way']),array('desc','asc'))) {
if (in_array(strtolower($_GET['order_way']), array('desc', 'asc'))) {
$OrderWay = strtoupper($_GET['order_way']);
}
// Uploaded, seeding, leeching, snatched lists
if ($_GET['userid'] && is_number($_GET['userid'])) {
$UserID=ceil($_GET['userid']);
$UserID = ceil($_GET['userid']);
$DB->query("
SELECT m.Paranoia, p.Level
FROM users_main AS m
JOIN permissions AS p ON p.ID=m.PermissionID
WHERE ID='$UserID'");
JOIN permissions AS p ON p.ID = m.PermissionID
WHERE ID = '$UserID'");
list($Paranoia, $UserClass) = $DB->next_record();
$TorrentWhere='';
$TorrentJoin='';
$TorrentWhere = '';
$TorrentJoin = '';
if ($_GET['type'] == 'uploaded') {
if (!check_paranoia('uploads', $Paranoia, $UserClass, $UserID)) {
error(403);
}
$TorrentWhere = "WHERE t.UserID='".$UserID."'";
$TorrentWhere = "WHERE t.UserID = '$UserID'";
$Title = 'Uploaded Torrents';
} elseif ($_GET['type'] == 'seeding') {
if (!check_paranoia('seeding', $Paranoia, $UserClass, $UserID)) {
error(403);
}
$TorrentJoin = "JOIN xbt_files_users AS xfu ON xfu.fid=t.ID AND xfu.uid='$UserID' AND xfu.remaining=0";
$TorrentJoin = "JOIN xbt_files_users AS xfu ON xfu.fid = t.ID AND xfu.uid = '$UserID' AND xfu.remaining = 0";
$Title = 'Seeding Torrents';
$TimeField = 'xfu.mtime';
$TimeLabel = 'Seeding Time';
@ -197,7 +209,7 @@ function header_link($SortKey, $DefaultWay = 'DESC') {
if (!check_paranoia('leeching', $Paranoia, $UserClass, $UserID)) {
error(403);
}
$TorrentJoin = "JOIN xbt_files_users AS xfu ON xfu.fid=t.ID AND xfu.uid='$UserID' AND xfu.remaining>0";
$TorrentJoin = "JOIN xbt_files_users AS xfu ON xfu.fid = t.ID AND xfu.uid = '$UserID' AND xfu.remaining > 0";
$Title = 'Leeching Torrents';
$TimeField = 'xfu.mtime';
$TimeLabel = 'Leeching Time';
@ -206,7 +218,7 @@ function header_link($SortKey, $DefaultWay = 'DESC') {
if (!check_paranoia('snatched', $Paranoia, $UserClass, $UserID)) {
error(403);
}
$TorrentJoin = "JOIN xbt_snatched AS xs ON xs.fid=t.ID AND xs.uid='$UserID'";
$TorrentJoin = "JOIN xbt_snatched AS xs ON xs.fid = t.ID AND xs.uid = '$UserID'";
$Title = 'Snatched Torrents';
$TimeField = 'xs.tstamp';
$TimeLabel = 'Snatched Time';
@ -232,7 +244,7 @@ function header_link($SortKey, $DefaultWay = 'DESC') {
if ((strtolower($_GET['action']) == 'advanced' || ($LoggedUser['SearchType'] && strtolower($_GET['action']) != 'basic')) && check_perms('site_advanced_search')) {
$TorrentSpecifics = 0; // How many options are we searching by? (Disabled grouping only)
if ($DisableGrouping) {
foreach ($_GET as $SearchType=>$SearchStr) {
foreach ($_GET as $SearchType => $SearchStr) {
switch ($SearchType) {
case 'bitrate':
case 'format':
@ -259,177 +271,177 @@ function header_link($SortKey, $DefaultWay = 'DESC') {
$TorrentJoin .= '
LEFT JOIN torrents_artists AS ta ON g.ID = ta.GroupID
LEFT JOIN artists AS a ON ta.ArtistID = a.ID';
$TorrentWhere = build_search($_GET['artistname'],'a.Name',$_GET['exactartist'],$TorrentWhere);
$TorrentWhere = build_search($_GET['artistname'], 'a.Name', $_GET['exactartist'], $TorrentWhere);
}
if ($_GET['torrentname'] != '') {
if (!$DisableGrouping) {
$GroupWhere = build_search($_GET['torrentname'],'GroupName',$_GET['exacttorrent'],$GroupWhere);
$GroupWhere = build_search($_GET['torrentname'], 'GroupName', $_GET['exacttorrent'], $GroupWhere);
} else {
$TorrentWhere = build_search($_GET['torrentname'],'g.Name',$_GET['exacttorrent'],$TorrentWhere);
$TorrentWhere = build_search($_GET['torrentname'], 'g.Name', $_GET['exacttorrent'], $TorrentWhere);
}
}
if ($_GET['remastertitle'] != '') {
$RemasterTitle = $_GET['remastertitle'];
if ($_GET['exactremaster']) {
$RemasterTitle = '%'.$RemasterTitle.'%';
$RemasterTitle = "%$RemasterTitle%";
}
$GroupWhere = build_search($RemasterTitle,'RemasterTitleList',$_GET['exactremaster'],$GroupWhere,0,$RemasterRegEx);
$GroupWhere = build_search($RemasterTitle, 'RemasterTitleList', $_GET['exactremaster'], $GroupWhere, 0, $RemasterRegEx);
if ($TorrentSpecifics > 0) {
$TorrentWhere = build_search($_GET['remastertitle'],'t.RemasterTitle',$_GET['exactremaster'],$TorrentWhere);
$TorrentWhere = build_search($_GET['remastertitle'], 't.RemasterTitle', $_GET['exactremaster'], $TorrentWhere);
}
}
if ($_GET['year'] != '' && is_numeric($_GET['year'])) {
if (!$DisableGrouping) {
if ($GroupWhere == '') {
$GroupWhere='WHERE ';
$GroupWhere = 'WHERE ';
} else {
$GroupWhere.= ' AND ';
$GroupWhere .= ' AND ';
}
$GroupWhere.="GroupYear='".db_string($_GET['year'])."'";
$GroupWhere .= "GroupYear = '".db_string($_GET['year'])."'";
} else {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
$TorrentWhere.= ' AND ';
$TorrentWhere .= ' AND ';
}
$TorrentWhere.="g.Year='".db_string($_GET['year'])."'";
$TorrentWhere .= "g.Year = '".db_string($_GET['year'])."'";
}
}
if ($_GET['bitrate'] != '') {
if (in_array($_GET['bitrate'],$Bitrates)) {
if (in_array($_GET['bitrate'], $Bitrates)) {
if ($_GET['bitrate'] == 'Other') {
if ($_GET['other_bitrate'] != '') {
$GroupWhere=build_search(db_string($_GET['other_bitrate']),'EncodingList',false,$GroupWhere);
$GroupWhere = build_search(db_string($_GET['other_bitrate']), 'EncodingList', false, $GroupWhere);
if ($TorrentSpecifics > 0) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
$TorrentWhere.= ' AND ';
$TorrentWhere .= ' AND ';
}
}
$TorrentWhere.="t.Encoding LIKE '%".db_string($_GET['other_bitrate'])."%'";
$TorrentWhere .= "t.Encoding LIKE '%".db_string($_GET['other_bitrate'])."%'";
}
} else {
$GroupWhere = build_search(db_string($_GET['bitrate']),'EncodingList',false,$GroupWhere);
$GroupWhere = build_search(db_string($_GET['bitrate']), 'EncodingList', false, $GroupWhere);
if ($TorrentSpecifics > 0) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
$TorrentWhere.= ' AND ';
$TorrentWhere .= ' AND ';
}
$TorrentWhere.="t.Encoding LIKE '".db_string($_GET['bitrate'])."'";
$TorrentWhere .= "t.Encoding LIKE '".db_string($_GET['bitrate'])."'";
}
}
}
}
if ($_GET['format'] != '' && in_array($_GET['format'],$Formats)) {
$GroupWhere = build_search('%'.$_GET['format'].'%','FormatList',f,$GroupWhere);
if ($_GET['format'] != '' && in_array($_GET['format'], $Formats)) {
$GroupWhere = build_search('%'.$_GET['format'].'%', 'FormatList', false, $GroupWhere);
if ($TorrentSpecifics > 0) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
$TorrentWhere.= ' AND ';
$TorrentWhere .= ' AND ';
}
$TorrentWhere.="t.Format='".db_string($_GET['format'])."'";
$TorrentWhere .= "t.Format = '".db_string($_GET['format'])."'";
}
}
if ($_GET['media'] != '' && in_array($_GET['media'],$Media)) {
$GroupWhere = build_search('%'.$_GET['media'].'%','MediaList',false,$GroupWhere);
if ($_GET['media'] != '' && in_array($_GET['media'], $Media)) {
$GroupWhere = build_search('%'.$_GET['media'].'%', 'MediaList', false, $GroupWhere);
if ($TorrentSpecifics > 0) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
$TorrentWhere.= ' AND ';
$TorrentWhere .= ' AND ';
}
$TorrentWhere.="t.Media='".db_string($_GET['media'])."'";
$TorrentWhere .= "t.Media = '".db_string($_GET['media'])."'";
}
}
if ($_GET['filelist'] != '') {
$TorrentWhere = build_search('%'.$_GET['filelist'].'%','t.FileList',true,$TorrentWhere);
$TorrentWhere = build_search('%'.$_GET['filelist'].'%', 't.FileList', true, $TorrentWhere);
}
if ($_GET['haslog'] != '') {
$HasLog = ceil($_GET['haslog']);
if ($_GET['haslog'] == '100' || $_GET['haslog'] == '-100') {
$GroupWhere = build_search($_GET['haslog'],'LogScoreList',false,$GroupWhere);
$GroupWhere = build_search($_GET['haslog'], 'LogScoreList', false, $GroupWhere);
$HasLog = 1;
}
$GroupWhere = build_search('%'.$HasLog.'%','LogList',true,$GroupWhere);
$GroupWhere = build_search('%'.$HasLog.'%', 'LogList', true, $GroupWhere);
if ($TorrentSpecifics > 0) {
if ($_GET['haslog'] == '100' || $_GET['haslog'] == '-100') {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
$TorrentWhere.= ' AND ';
$TorrentWhere .= ' AND ';
}
if ($_GET['haslog'] == '-100') {
$TorrentWhere.= "t.LogScore!='100'";
$TorrentWhere .= "t.LogScore != '100'";
} else {
$TorrentWhere.= "t.LogScore='100'";
$TorrentWhere .= "t.LogScore = '100'";
}
}
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
$TorrentWhere.= ' AND ';
$TorrentWhere .= ' AND ';
}
$TorrentWhere.= "t.HasLog='$HasLog'";
$TorrentWhere .= "t.HasLog = '$HasLog'";
}
}
if ($_GET['hascue'] != '') {
$GroupWhere = build_search('%'.$_GET['hascue'].'%','CueList',true,$GroupWhere);
$GroupWhere = build_search('%'.$_GET['hascue'].'%', 'CueList', true, $GroupWhere);
if ($TorrentSpecifics > 0) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
$TorrentWhere.= ' AND ';
$TorrentWhere .= ' AND ';
}
$TorrentWhere.= "t.HasCue='".ceil($_GET['hascue'])."'";
$TorrentWhere .= "t.HasCue = '".ceil($_GET['hascue'])."'";
}
}
if ($_GET['scene'] != '') {
$GroupWhere = build_search('%'.$_GET['scene'].'%','SceneList',true,$GroupWhere);
$GroupWhere = build_search('%'.$_GET['scene'].'%', 'SceneList', true, $GroupWhere);
if ($TorrentSpecifics > 0) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
$TorrentWhere.= ' AND ';
$TorrentWhere .= ' AND ';
}
$TorrentWhere.= "t.Scene='".ceil($_GET['scene'])."'";
$TorrentWhere .= "t.Scene = '".ceil($_GET['scene'])."'";
}
}
if ($_GET['freeleech'] != '') {
$GroupWhere = build_search('%'.$_GET['freeleech'].'%','FreeTorrentList',true,$GroupWhere);
$GroupWhere = build_search('%'.$_GET['freeleech'].'%', 'FreeTorrentList', true, $GroupWhere);
if ($TorrentSpecifics > 0) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
$TorrentWhere.= ' AND ';
$TorrentWhere .= ' AND ';
}
$TorrentWhere.= "t.FreeTorrent='".ceil($_GET['freeleech'])."'";
$TorrentWhere .= "t.FreeTorrent = '".ceil($_GET['freeleech'])."'";
}
}
if ($_GET['remastered'] != '') {
$GroupWhere = build_search('%'.$_GET['remastered'].'%','RemasterList',true,$GroupWhere);
$GroupWhere = build_search('%'.$_GET['remastered'].'%', 'RemasterList', true, $GroupWhere);
if ($TorrentSpecifics > 0) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
$TorrentWhere.= ' AND ';
$TorrentWhere .= ' AND ';
}
$TorrentWhere.= "t.Remastered='".ceil($_GET['remastered'])."'";
$TorrentWhere .= "t.Remastered = '".ceil($_GET['remastered'])."'";
}
}
@ -437,12 +449,12 @@ function header_link($SortKey, $DefaultWay = 'DESC') {
// Basic search
if ($_GET['searchstr'] != '') {
// Change special characters into 'normal' characters
$SearchStr = strtr($_GET['searchstr'],$SpecialChars);
$SearchStr = strtr($_GET['searchstr'], $SpecialChars);
if (!$DisableGrouping) {
$GroupWhere = build_search($SearchStr,'SearchText',false,$GroupWhere,1);
$GroupWhere = build_search($SearchStr, 'SearchText', false, $GroupWhere, 1);
} else {
$TorrentWhere = build_search($SearchStr,'g.SearchText',false,$TorrentWhere);
$TorrentWhere = build_search($SearchStr, 'g.SearchText', false, $TorrentWhere);
}
}
}
@ -455,26 +467,26 @@ function header_link($SortKey, $DefaultWay = 'DESC') {
$TagField = 'h.TagList';
}
$Tags = explode(',',$_GET['searchtags']);
$Tags = explode(',', $_GET['searchtags']);
foreach ($Tags as $Key => $Tag) :
if (trim($Tag) != '') {
if ($TagSearch != '') {
if ($_GET['tags_type']) {
$TagSearch.= ' AND ';
$TagSearch .= ' AND ';
} else {
$TagSearch.= ' OR ';
$TagSearch .= ' OR ';
}
}
$Tag = trim(str_replace('.','_',$Tag));
$Tag = trim(str_replace('.', '_', $Tag));
if (!$DisableGrouping) {
// Fulltext
$TagSearch.= " MATCH ($TagField) AGAINST ('".db_string($Tag)."'";
if (substr($Tag,0,1) == '-') {
$TagSearch.=' IN BOOLEAN MODE';
$TagSearch .= " MATCH ($TagField) AGAINST ('".db_string($Tag)."'";
if (substr($Tag, 0, 1) == '-') {
$TagSearch .=' IN BOOLEAN MODE';
}
$TagSearch.= ')';
$TagSearch .= ')';
} else {
$TagSearch.=$TagField." LIKE '%".db_string($Tag)."%'";
$TagSearch .= "$TagField LIKE '%".db_string($Tag)."%'";
}
}
endforeach;
@ -508,25 +520,25 @@ function header_link($SortKey, $DefaultWay = 'DESC') {
foreach ($_GET['filter_cat'] as $CatKey => $CatVal) {
if ($CatFilter != '') {
$CatFilter.= ' OR ';
$CatFilter .= ' OR ';
}
$CatFilter.=$CategoryField."='".db_string(ceil($CatKey))."'";
$CatFilter .= "$CategoryField = '".db_string(ceil($CatKey))."'";
}
if ($DisableGrouping) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
$TorrentWhere.= ' AND ';
$TorrentWhere .= ' AND ';
}
$TorrentWhere.= "($CatFilter)";
$TorrentWhere .= "($CatFilter)";
} else {
if ($GroupWhere == '') {
$GroupWhere = 'WHERE ';
} else {
$GroupWhere.= ' AND ';
$GroupWhere .= ' AND ';
}
$GroupWhere.="($CatFilter)";
$GroupWhere .= "($CatFilter)";
}
}
@ -542,50 +554,66 @@ function header_link($SortKey, $DefaultWay = 'DESC') {
if ($GroupWhere == '') {
$GroupWhere = 'WHERE ';
} else {
$GroupWhere.= ' AND ';
$GroupWhere .= ' AND ';
}
$GroupWhere.= "(SELECT t.GroupID FROM torrents AS t $TorrentWhere AND t.GroupID=h.GroupID LIMIT 1)";
$GroupWhere .= "
(
SELECT t.GroupID
FROM torrents AS t
$TorrentWhere
AND t.GroupID = h.GroupID
LIMIT 1
)";
}
$DB->query("SELECT $SCFR
h.GroupID,
h.GroupName,
h.GroupYear AS s2,
h.GroupCategoryID,
h.GroupTime AS s3,
h.MaxTorrentSize AS s4,
h.TotalSnatches AS s5,
h.TotalSeeders AS s6,
h.TotalLeechers AS s7,
h.TorrentIDList,
h.TagList,
h.MediaList,
h.FormatList,
h.EncodingList,
h.YearList,
h.RemasterList,
h.RemasterTitleList,
h.SceneList,
h.LogList,
h.CueList,
h.LogScoreList,
h.FileCountList,
h.FreeTorrentList,
h.SizeList,
h.LeechersList,
h.SeedersList,
h.SnatchedList,
h.TimeList,
h.SearchText AS s1
FROM torrent_hash AS h
$TorrentJoin
$GroupWhere
ORDER BY $OrderBy $OrderWay
LIMIT $Limit");
$DB->query("
SELECT $SCFR
h.GroupID,
h.GroupName,
h.GroupYear AS s2,
h.GroupCategoryID,
h.GroupTime AS s3,
h.MaxTorrentSize AS s4,
h.TotalSnatches AS s5,
h.TotalSeeders AS s6,
h.TotalLeechers AS s7,
h.TorrentIDList,
h.TagList,
h.MediaList,
h.FormatList,
h.EncodingList,
h.YearList,
h.RemasterList,
h.RemasterTitleList,
h.SceneList,
h.LogList,
h.CueList,
h.LogScoreList,
h.FileCountList,
h.FreeTorrentList,
h.SizeList,
h.LeechersList,
h.SeedersList,
h.SnatchedList,
h.TimeList,
h.SearchText AS s1
FROM torrent_hash AS h
$TorrentJoin
$GroupWhere
ORDER BY $OrderBy $OrderWay
LIMIT $Limit");
$TorrentList=$DB->to_array();
if (EXPLAIN_HACK) {
$DB->query("EXPLAIN SELECT NULL FROM (SELECT NULL FROM torrent_hash AS h $TorrentJoin $GroupWhere) AS Count");
list($Null,$Null,$Null,$Null,$Null,$Null,$Null,$Null,$TorrentCount)=$DB->next_record();
$DB->query("
EXPLAIN
SELECT NULL
FROM (
SELECT NULL
FROM torrent_hash AS h
$TorrentJoin
$GroupWhere
) AS Count");
list($Null, $Null, $Null, $Null, $Null, $Null, $Null, $Null, $TorrentCount) = $DB->next_record();
} else {
$DB->query('SELECT FOUND_ROWS()');
list($TorrentCount) = $DB->next_record();
@ -595,42 +623,51 @@ function header_link($SortKey, $DefaultWay = 'DESC') {
if (!$TimeField) {
$TimeField = 't.Time';
}
$DB->query("SELECT $SCFR
g.ID,
g.Name,
g.Year AS s2,
g.CategoryID,
$TimeField AS s3,
t.Size AS s4,
t.Snatched AS s5,
t.Seeders AS s6,
t.Leechers AS s7,
t.ID,
g.TagList,
t.Media,
t.Format,
t.Encoding,
t.RemasterYear,
t.Remastered,
t.RemasterTitle,
t.Scene,
t.HasLog,
t.HasCue,
t.LogScore,
t.FileCount,
t.FreeTorrent,
g.SearchText AS s1
FROM torrents AS t
INNER JOIN torrents_group AS g ON g.ID=t.GroupID
$TorrentJoin
$TorrentWhere
ORDER BY $OrderBy $OrderWay
LIMIT $Limit");
$DB->query("
SELECT $SCFR
g.ID,
g.Name,
g.Year AS s2,
g.CategoryID,
$TimeField AS s3,
t.Size AS s4,
t.Snatched AS s5,
t.Seeders AS s6,
t.Leechers AS s7,
t.ID,
g.TagList,
t.Media,
t.Format,
t.Encoding,
t.RemasterYear,
t.Remastered,
t.RemasterTitle,
t.Scene,
t.HasLog,
t.HasCue,
t.LogScore,
t.FileCount,
t.FreeTorrent,
g.SearchText AS s1
FROM torrents AS t
INNER JOIN torrents_group AS g ON g.ID = t.GroupID
$TorrentJoin
$TorrentWhere
ORDER BY $OrderBy $OrderWay
LIMIT $Limit");
$TorrentList = $DB->to_array();
if (EXPLAIN_HACK) {
$DB->query("EXPLAIN SELECT NULL FROM (SELECT NULL FROM torrent_hash AS h $TorrentJoin $GroupWhere) AS Count");
list($Null,$Null,$Null,$Null,$Null,$Null,$Null,$Null,$TorrentCount)=$DB->next_record();
$DB->query("
EXPLAIN
SELECT NULL
FROM (
SELECT NULL
FROM torrent_hash AS h
$TorrentJoin
$GroupWhere
) AS Count");
list($Null, $Null, $Null, $Null, $Null, $Null, $Null, $Null, $TorrentCount) = $DB->next_record();
} else {
$DB->query('SELECT FOUND_ROWS()');
list($TorrentCount) = $DB->next_record();
@ -639,7 +676,10 @@ function header_link($SortKey, $DefaultWay = 'DESC') {
if ($UserID) {
// Get the username, so we can display the title as "<user>'s snatched torrents", etc
$DB->query("SELECT Username FROM users_main WHERE ID='".db_string($UserID)."'");
$DB->query("
SELECT Username
FROM users_main
WHERE ID = '".db_string($UserID)."'");
list($TitleUser) = $DB->next_record();
}
} else {
@ -663,7 +703,7 @@ function header_link($SortKey, $DefaultWay = 'DESC') {
$Title = 'Browse Torrents';
}
View::show_header($Title,'browse');
View::show_header($Title, 'browse');
?>
<form name="filter" method="get" action="">
<? if ($UserID) { ?>
@ -798,7 +838,7 @@ function header_link($SortKey, $DefaultWay = 'DESC') {
</tr>
<tr>
<td class="label">Order by:</td>
<td colspan="<?=($AdvancedSearch) ? '3' : '1' ?>">
<td colspan="<?=$AdvancedSearch ? '3' : '1'; ?>">
<select name="order_by" style="width: auto;">
<option value="s1"<? if ($OrderBy == 's1') { ?> selected="selected"<? } ?>>Name</option>
<option value="s2"<? if ($OrderBy == 's2') { ?> selected="selected"<? } ?>>Year</option>
@ -849,7 +889,11 @@ function header_link($SortKey, $DefaultWay = 'DESC') {
<?
$GenreTags = $Cache->get_value('genre_tags');
if (!$GenreTags) {
$DB->query('SELECT Name FROM tags WHERE TagType=\'genre\' ORDER BY Name');
$DB->query('
SELECT Name
FROM tags
WHERE TagType = \'genre\'
ORDER BY Name');
$GenreTags = $DB->collect('Name');
$Cache->cache_value('genre_tags', $GenreTags, 3600 * 6);
}
@ -869,7 +913,7 @@ function header_link($SortKey, $DefaultWay = 'DESC') {
endforeach;
if ($x % 7 != 0) { // Padding
?>
<td colspan="<?=7 - ($x % 7) ?>"> </td>
<td colspan="<?= 7 - ($x % 7); ?>"> </td>
<?
} ?>
</tr>
@ -930,25 +974,28 @@ function header_link($SortKey, $DefaultWay = 'DESC') {
}
$Artists = Artists::get_artists($GroupIDs);
foreach ($TorrentList as $Key => $Properties) {
list($GroupID,$GroupName,$GroupYear,$GroupCategoryID,$GroupTime,$MaxSize,$TotalSnatched,$TotalSeeders,$TotalLeechers,$TorrentsID,$TagsList,$TorrentsMedia,$TorrentsFormat,$TorrentsEncoding,$TorrentsYear,$TorrentsRemastered,$TorrentsRemasterTitle,$TorrentsScene,$TorrentsLog,$TorrentsCue,$TorrentsLogScores,$TorrentsFileCount,$TorrentsFreeTorrent,$TorrentsSize,$TorrentsLeechers,$TorrentsSeeders,$TorrentsSnatched,$TorrentsTime) = $Properties;
$Torrents['id'] = explode('|',$TorrentsID);
$Torrents['media'] = explode('|',$TorrentsMedia);
$Torrents['format'] = explode('|',$TorrentsFormat);
$Torrents['encoding'] = explode('|',$TorrentsEncoding);
$Torrents['year'] = explode('|',$TorrentsYear);
$Torrents['remastered'] = explode('|',$TorrentsRemastered);
$Torrents['remastertitle'] = explode('|',$TorrentsRemasterTitle);
$Torrents['scene'] = explode('|',$TorrentsScene);
$Torrents['log'] = explode('|',$TorrentsLog);
$Torrents['cue'] = explode('|',$TorrentsCue);
$Torrents['score'] = explode('|',$TorrentsLogScores);
$Torrents['filecount'] = explode('|',$TorrentsFileCount);
$Torrents['size'] = explode('|',$TorrentsSize);
$Torrents['leechers'] = explode('|',$TorrentsLeechers);
$Torrents['seeders'] = explode('|',$TorrentsSeeders);
$Torrents['snatched'] = explode('|',$TorrentsSnatched);
$Torrents['freetorrent'] = explode('|',$TorrentsFreeTorrent);
$Torrents['time'] = explode('|',$TorrentsTime);
list($GroupID, $GroupName, $GroupYear, $GroupCategoryID, $GroupTime, $MaxSize, $TotalSnatched, $TotalSeeders, $TotalLeechers,
$TorrentsID, $TagsList, $TorrentsMedia, $TorrentsFormat, $TorrentsEncoding, $TorrentsYear, $TorrentsRemastered,
$TorrentsRemasterTitle, $TorrentsScene, $TorrentsLog, $TorrentsCue, $TorrentsLogScores, $TorrentsFileCount, $TorrentsFreeTorrent,
$TorrentsSize, $TorrentsLeechers, $TorrentsSeeders, $TorrentsSnatched, $TorrentsTime) = $Properties;
$Torrents['id'] = explode('|', $TorrentsID);
$Torrents['media'] = explode('|', $TorrentsMedia);
$Torrents['format'] = explode('|', $TorrentsFormat);
$Torrents['encoding'] = explode('|', $TorrentsEncoding);
$Torrents['year'] = explode('|', $TorrentsYear);
$Torrents['remastered'] = explode('|', $TorrentsRemastered);
$Torrents['remastertitle'] = explode('|', $TorrentsRemasterTitle);
$Torrents['scene'] = explode('|', $TorrentsScene);
$Torrents['log'] = explode('|', $TorrentsLog);
$Torrents['cue'] = explode('|', $TorrentsCue);
$Torrents['score'] = explode('|', $TorrentsLogScores);
$Torrents['filecount'] = explode('|', $TorrentsFileCount);
$Torrents['size'] = explode('|', $TorrentsSize);
$Torrents['leechers'] = explode('|', $TorrentsLeechers);
$Torrents['seeders'] = explode('|', $TorrentsSeeders);
$Torrents['snatched'] = explode('|', $TorrentsSnatched);
$Torrents['freetorrent'] = explode('|', $TorrentsFreeTorrent);
$Torrents['time'] = explode('|', $TorrentsTime);
if (!$DisableGrouping) {
// Since these fields are surrounded by |s, we get extra elements added to the arrays
@ -985,9 +1032,9 @@ function header_link($SortKey, $DefaultWay = 'DESC') {
$DisplayName = Artists::display_artists($Artists[$GroupID]);
if ((count($Torrents['id']) > 1 || $GroupCategoryID == 1) && !$DisableGrouping) {
// These torrents are in a group
$DisplayName.='<a href="torrents.php?id='.$GroupID.'" title="View Torrent">'.$GroupName.'</a>';
$DisplayName .= "<a href=\"torrents.php?id=$GroupID\" title=\"View Torrent\">$GroupName</a>";
if ($GroupYear > 0) {
$DisplayName.=" [$GroupYear]";
$DisplayName .= " [$GroupYear]";
}
?>
<tr class="group">
@ -1062,7 +1109,7 @@ function header_link($SortKey, $DefaultWay = 'DESC') {
$Continue = false;
$RemasterParts = explode(' ', $_GET['remastertitle']);
foreach ($RemasterParts as $RemasterPart) {
if (stripos($Torrents['remastertitle'][$Key],$RemasterPart) === false) {
if (stripos($Torrents['remastertitle'][$Key], $RemasterPart) === false) {
$Continue = true;
}
}
@ -1075,45 +1122,45 @@ function header_link($SortKey, $DefaultWay = 'DESC') {
$AddExtra = '';
if ($Torrents['format'][$Key]) {
$ExtraInfo.=$Torrents['format'][$Key];
$ExtraInfo .= $Torrents['format'][$Key];
$AddExtra = ' / ';
}
if ($Torrents['encoding'][$Key]) {
$ExtraInfo.=$AddExtra.$Torrents['encoding'][$Key];
$ExtraInfo .= $AddExtra.$Torrents['encoding'][$Key];
$AddExtra = ' / ';
}
if ($Torrents['log'][$Key] == '1') {
$ExtraInfo.=$AddExtra.'Log';
$ExtraInfo .= $AddExtra.'Log';
$AddExtra = ' / ';
if ($Torrents['score'][$Key]) {
$ExtraInfo.=' ('.$Torrents['score'][$Key].'%) ';
$ExtraInfo .= ' ('.$Torrents['score'][$Key].'%) ';
}
}
if ($Torrents['cue'][$Key] == '1') {
$ExtraInfo.=$AddExtra.'Cue';
$ExtraInfo .= "{$AddExtra}Cue";
$AddExtra = ' / ';
}
if ($Torrents['media'][$Key]) {
$ExtraInfo.=$AddExtra.$Torrents['media'][$Key];
$ExtraInfo .= $AddExtra.$Torrents['media'][$Key];
$AddExtra = ' / ';
}
if ($Torrents['scene'][$Key] == '1') {
$ExtraInfo.=$AddExtra.'Scene';
$ExtraInfo .= "{$AddExtra}Scene";
$AddExtra = ' / ';
}
if (trim($Torrents['remastertitle'][$Key])) {
$ExtraInfo.=$AddExtra.$Torrents['remastertitle'][$Key];
$ExtraInfo .= $AddExtra.$Torrents['remastertitle'][$Key];
$AddExtra = ' - ';
} elseif ($Torrents['remastered'][$Key] == '1') {
$ExtraInfo.=$AddExtra.'Remastered';
$ExtraInfo .= "{$AddExtra}Remastered";
$AddExtra = ' - ';
}
if ($Torrents['year'][$Key] > '0') {
$ExtraInfo.=$AddExtra.$Torrents['year'][$Key];
$ExtraInfo .= $AddExtra.$Torrents['year'][$Key];
$AddExtra = ' / ';
}
if ($Torrents['freetorrent'][$Key] == '1') {
$ExtraInfo.=$AddExtra. Format::torrent_label('Freeleech!');
$ExtraInfo .= $AddExtra. Format::torrent_label('Freeleech!');
$AddExtra = ' / ';
}
?>
@ -1137,61 +1184,61 @@ function header_link($SortKey, $DefaultWay = 'DESC') {
} else {
// Either grouping is disabled, or we're viewing a type that does not require grouping
if ($GroupCategoryID == 1) {
$DisplayName.='<a href="torrents.php?id='.$GroupID.'&amp;torrentid='.$Torrents['id'][0].'" title="View Torrent">'.$GroupName.'</a>';
$DisplayName .= '<a href="torrents.php?id='.$GroupID.'&amp;torrentid='.$Torrents['id'][0].'" title="View Torrent">'.$GroupName.'</a>';
} else {
$DisplayName.='<a href="torrents.php?id='.$GroupID.'" title="View Torrent">'.$GroupName.'</a>';
$DisplayName .= '<a href="torrents.php?id='.$GroupID.'" title="View Torrent">'.$GroupName.'</a>';
}
$ExtraInfo = '';
$AddExtra = '';
if ($Torrents['format'][0]) {
$ExtraInfo.=$Torrents['format'][0];
$AddExtra=' / ';
$ExtraInfo .= $Torrents['format'][0];
$AddExtra = ' / ';
}
if ($Torrents['encoding'][0]) {
$ExtraInfo.=$AddExtra.$Torrents['encoding'][0];
$AddExtra=' / ';
$ExtraInfo .= $AddExtra.$Torrents['encoding'][0];
$AddExtra = ' / ';
}
if ($Torrents['log'][0] == '1') {
$ExtraInfo.=$AddExtra.'Log';
$ExtraInfo .= "{$AddExtra}Log";
$AddExtra = ' / ';
}
if ($Torrents['score'][0]) {
$ExtraInfo.=' ('.$Torrents['score'][0].'%) ';
$ExtraInfo .= ' ('.$Torrents['score'][0].'%) ';
}
if ($Torrents['cue'][0] == '1') {
$ExtraInfo.=$AddExtra.'Cue';
$ExtraInfo .= "{$AddExtra}Cue";
$AddExtra = ' / ';
}
if ($Torrents['media'][0]) {
$ExtraInfo.=$AddExtra.$Torrents['media'][0];
$ExtraInfo .= $AddExtra.$Torrents['media'][0];
$AddExtra = ' / ';
}
if ($Torrents['scene'][0] == '1') {
$ExtraInfo.=$AddExtra.'Scene';
$ExtraInfo .= "{$AddExtra}Scene";
$AddExtra = ' / ';
}
if (trim($Torrents['remastertitle'][0])) {
$ExtraInfo.=$AddExtra.$Torrents['remastertitle'][0];
$ExtraInfo .= $AddExtra.$Torrents['remastertitle'][0];
$AddExtra = ' - ';
} elseif ($Torrents['remastered'][0] == '1') {
$ExtraInfo.=$AddExtra.'Remastered';
$ExtraInfo .= "{$AddExtra}Remastered";
$AddExtra = ' - ';
}
if ($Torrents['year'][0] > '0') {
$ExtraInfo.=$AddExtra.$Torrents['year'][0];
$ExtraInfo .= $AddExtra.$Torrents['year'][0];
$AddExtra = ' / ';
}
if ($Torrents['freetorrent'][0] == '1') {
$ExtraInfo.=$AddExtra. Format::torrent_label('Freeleech!');
$ExtraInfo .= $AddExtra. Format::torrent_label('Freeleech!');
$AddExtra = ' / ';
}
if ($ExtraInfo != '') {
$ExtraInfo = "[$ExtraInfo]";
}
if ($GroupYear > 0) {
$ExtraInfo.=" [$GroupYear]";
$ExtraInfo .= " [$GroupYear]";
}
if (!isset($TimeField) || $TimeField == 't.Time') {
@ -1229,23 +1276,24 @@ function header_link($SortKey, $DefaultWay = 'DESC') {
?>
</table>
<? } else {
$DB->query("SELECT
tags.Name,
((COUNT(tags.Name)-2)*(SUM(tt.PositiveVotes)-SUM(tt.NegativeVotes)))/(tags.Uses*0.8) AS Score
FROM xbt_snatched AS s
INNER JOIN torrents AS t ON t.ID=s.fid
INNER JOIN torrents_group AS g ON t.GroupID=g.ID
INNER JOIN torrents_tags AS tt ON tt.GroupID=g.ID
INNER JOIN tags ON tags.ID=tt.TagID
WHERE s.uid='$LoggedUser[ID]'
AND tt.TagID != '13679'
AND tt.TagID != '4820'
AND tt.TagID != '2838'
AND g.CategoryID='1'
AND tags.Uses > '10'
GROUP BY tt.TagID
ORDER BY Score DESC
LIMIT 8");
$DB->query("
SELECT
tags.Name,
((COUNT(tags.Name) - 2) * (SUM(tt.PositiveVotes) - SUM(tt.NegativeVotes))) / (tags.Uses * 0.8) AS Score
FROM xbt_snatched AS s
INNER JOIN torrents AS t ON t.ID = s.fid
INNER JOIN torrents_group AS g ON t.GroupID = g.ID
INNER JOIN torrents_tags AS tt ON tt.GroupID = g.ID
INNER JOIN tags ON tags.ID = tt.TagID
WHERE s.uid = '$LoggedUser[ID]'
AND tt.TagID != '13679'
AND tt.TagID != '4820'
AND tt.TagID != '2838'
AND g.CategoryID = '1'
AND tags.Uses > '10'
GROUP BY tt.TagID
ORDER BY Score DESC
LIMIT 8");
?>
<div class="box pad" align="center">
<h2>Your search did not match anything.</h2>

View File

@ -25,13 +25,18 @@
// The "order by x" links on columns headers
function header_link($SortKey,$DefaultWay="desc") {
global $OrderBy,$OrderWay;
if ($SortKey==$OrderBy) {
if ($OrderWay=="desc") { $NewWay="asc"; }
else { $NewWay="desc"; }
} else { $NewWay=$DefaultWay; }
return "torrents.php?order_way=".$NewWay."&amp;order_by=".$SortKey."&amp;".Format::get_url(array('order_way','order_by'));
function header_link($SortKey, $DefaultWay = 'desc') {
global $OrderBy, $OrderWay;
if ($SortKey == $OrderBy) {
if ($OrderWay == 'desc') {
$NewWay = 'asc';
} else {
$NewWay = 'desc';
}
} else {
$NewWay = $DefaultWay;
}
return "torrents.php?order_way=$NewWay&amp;order_by=$SortKey&amp;".Format::get_url(array('order_way', 'order_by'));
}
/** Start default parameters and validation **/
@ -44,11 +49,14 @@ function header_link($SortKey,$DefaultWay="desc") {
// Search by infohash
if ($InfoHash = is_valid_torrenthash($InfoHash)) {
$InfoHash = db_string(pack("H*", $InfoHash));
$DB->query("SELECT ID,GroupID FROM torrents WHERE info_hash='$InfoHash'");
$InfoHash = db_string(pack('H*', $InfoHash));
$DB->query("
SELECT ID, GroupID
FROM torrents
WHERE info_hash = '$InfoHash'");
if ($DB->record_count() > 0) {
list($ID, $GroupID) = $DB->next_record();
header('Location: torrents.php?id='.$GroupID.'&torrentid='.$ID);
header("Location: torrents.php?id=$GroupID&torrentid=$ID");
die();
}
}
@ -62,7 +70,7 @@ function header_link($SortKey,$DefaultWay="desc") {
$DB->query("
SELECT SiteOptions
FROM users_info
WHERE UserID='".db_string($LoggedUser['ID'])."'");
WHERE UserID = '".db_string($LoggedUser['ID'])."'");
list($SiteOptions) = $DB->next_record(MYSQLI_NUM, false);
if (!empty($SiteOptions)) {
$SiteOptions = unserialize($SiteOptions);
@ -72,10 +80,10 @@ function header_link($SortKey,$DefaultWay="desc") {
$SiteOptions['DefaultSearch'] = preg_replace($UnsetRegexp, '', $_SERVER['QUERY_STRING']);
$DB->query("
UPDATE users_info
SET SiteOptions='".db_string(serialize($SiteOptions))."'
WHERE UserID='".db_string($LoggedUser['ID'])."'");
$Cache->begin_transaction('user_info_heavy_'.$UserID);
$Cache->update_row(false, array('DefaultSearch'=>$SiteOptions['DefaultSearch']));
SET SiteOptions = '".db_string(serialize($SiteOptions))."'
WHERE UserID = '".db_string($LoggedUser['ID'])."'");
$Cache->begin_transaction("user_info_heavy_$UserID");
$Cache->update_row(false, array('DefaultSearch' => $SiteOptions['DefaultSearch']));
$Cache->commit_transaction(0);
// Clearing default search options
@ -83,16 +91,16 @@ function header_link($SortKey,$DefaultWay="desc") {
$DB->query("
SELECT SiteOptions
FROM users_info
WHERE UserID='".db_string($LoggedUser['ID'])."'");
WHERE UserID = '".db_string($LoggedUser['ID'])."'");
list($SiteOptions) = $DB->next_record(MYSQLI_NUM, false);
$SiteOptions = unserialize($SiteOptions);
$SiteOptions['DefaultSearch'] = '';
$DB->query("
UPDATE users_info
SET SiteOptions='".db_string(serialize($SiteOptions))."'
WHERE UserID='".db_string($LoggedUser['ID'])."'");
$Cache->begin_transaction('user_info_heavy_'.$UserID);
$Cache->update_row(false, array('DefaultSearch'=>''));
SET SiteOptions = '".db_string(serialize($SiteOptions))."'
WHERE UserID = '".db_string($LoggedUser['ID'])."'");
$Cache->begin_transaction("user_info_heavy_$UserID");
$Cache->update_row(false, array('DefaultSearch' => ''));
$Cache->commit_transaction(0);
// Use default search options
@ -100,10 +108,10 @@ function header_link($SortKey,$DefaultWay="desc") {
if (!empty($LoggedUser['DefaultSearch'])) {
if (!empty($_GET['page'])) {
$Page = $_GET['page'];
parse_str($LoggedUser['DefaultSearch'],$_GET);
parse_str($LoggedUser['DefaultSearch'], $_GET);
$_GET['page'] = $Page;
} else {
parse_str($LoggedUser['DefaultSearch'],$_GET);
parse_str($LoggedUser['DefaultSearch'], $_GET);
}
}
}
@ -124,6 +132,7 @@ function header_link($SortKey,$DefaultWay="desc") {
'leechers' => array('sumleechers', 'leechers'),
'snatched' => array('sumsnatched', 'snatched'),
'random' => false);
$AggregateExp = array(
'maxsize' => 'MAX(size) AS maxsize',
'sumseeders' => 'SUM(seeders) AS sumseeders',
@ -195,7 +204,7 @@ function header_link($SortKey,$DefaultWay="desc") {
$Filtered = false;
$EnableNegation = false; // Sphinx needs at least one positive search condition to support the NOT operator
// Filelist searches makes use of the proximity operator to ensure that all keywords match the same file
// File list searches make use of the proximity operator to ensure that all keywords match the same file
if (!empty($_GET['filelist'])) {
$SearchString = trim($_GET['filelist']);
if ($SearchString != '') {
@ -208,7 +217,7 @@ function header_link($SortKey,$DefaultWay="desc") {
}
// Collect all entered search terms to find out whether to enable the NOT operator
$GroupFields = array('artistname','groupname', 'recordlabel', 'cataloguenumber', 'taglist');
$GroupFields = array('artistname', 'groupname', 'recordlabel', 'cataloguenumber', 'taglist');
$TorrentFields = array('remastertitle', 'remasteryear', 'remasterrecordlabel', 'remastercataloguenumber', 'encoding', 'format', 'media');
$SearchWords = array();
foreach (array('artistname', 'groupname', 'recordlabel', 'cataloguenumber',
@ -231,7 +240,7 @@ function header_link($SortKey,$DefaultWay="desc") {
continue;
}
if ($Word[0] == '!' && strlen($Word) >= 2) {
if (strpos($Word,'!',1) === false) {
if (strpos($Word, '!', 1) === false) {
$SearchWords[$Search]['exclude'][] = $Word;
} else {
$SearchWords[$Search]['include'][] = $Word;
@ -321,10 +330,10 @@ function header_link($SortKey,$DefaultWay="desc") {
//Get tag aliases.
$TagAliases = $Cache->get_value('tag_aliases_search');
if (!$TagAliases) {
$DB->query("
$DB->query('
SELECT ID, BadTag, AliasTag
FROM tag_aliases
ORDER BY BadTag");
ORDER BY BadTag');
$TagAliases = $DB->to_array();
//Unify tag aliases to be in_this_format as tags not in.this.format
array_walk_recursive($TagAliases, create_function('&$val', '$val = preg_replace("/\./","_", $val);'));
@ -361,7 +370,7 @@ function header_link($SortKey,$DefaultWay="desc") {
//Only keep unique entries after unifying tag standard
$Tags['include'] = array_unique($Tags['include']);
$Tags['exclude'] = array_unique($Tags['exclude']);
$TagListString = implode(", ", array_merge($Tags['include'], $Tags['exclude']));
$TagListString = implode(', ', array_merge($Tags['include'], $Tags['exclude']));
if (!$EnableNegation && !empty($Tags['exclude'])) {
$Tags['include'] = array_merge($Tags['include'], $Tags['exclude']);
unset($Tags['exclude']);
@ -520,7 +529,7 @@ function header_link($SortKey,$DefaultWay="desc") {
if (isset($Random) && $GroupResults) {
// ORDER BY RAND() can't be used together with GROUP BY, so we need some special tactics
$Page = 1;
$SphQL->limit(0, 5*TORRENTS_PER_PAGE, 5*TORRENTS_PER_PAGE);
$SphQL->limit(0, 5 * TORRENTS_PER_PAGE, 5 * TORRENTS_PER_PAGE);
$SphQLResult = $SphQL->query();
$TotalCount = $SphQLResult->get_meta('total_found');
$Results = $SphQLResult->to_array('groupid');
@ -548,7 +557,7 @@ function header_link($SortKey,$DefaultWay="desc") {
if (check_perms('site_search_many')) {
$Page = $_GET['page'];
} else {
$Page = min(SPHINX_MAX_MATCHES/TORRENTS_PER_PAGE, $_GET['page']);
$Page = min(SPHINX_MAX_MATCHES / TORRENTS_PER_PAGE, $_GET['page']);
}
$Offset = ($Page - 1) * TORRENTS_PER_PAGE;
$SphQL->limit($Offset, TORRENTS_PER_PAGE, $Offset + TORRENTS_PER_PAGE);
@ -608,7 +617,7 @@ function header_link($SortKey,$DefaultWay="desc") {
}
View::show_header('Browse Torrents','browse');
View::show_header('Browse Torrents', 'browse');
?>
<div class="thin widethin">
@ -660,11 +669,11 @@ function header_link($SortKey,$DefaultWay="desc") {
</td>
</tr>
<tr id="edition_expand" class="ftr_advanced<?=$HideAdvanced?>">
<td colspan="4" class="center ft_edition_expand"><a href="#" class="brackets" onclick="ToggleEditionRows();return false;">Click here to toggle searching for specific remaster information</a></td>
<td colspan="4" class="center ft_edition_expand"><a href="#" class="brackets" onclick="ToggleEditionRows(); return false;">Click here to toggle searching for specific remaster information</a></td>
</tr>
<?
if (Format::form('remastertitle', true) == "" && Format::form('remasteryear', true) == "" &&
Format::form('remasterrecordlabel', true) == "" && Format::form('remastercataloguenumber', true) == "") {
if (Format::form('remastertitle', true) == '' && Format::form('remasteryear', true) == '' &&
Format::form('remasterrecordlabel', true) == '' && Format::form('remastercataloguenumber', true) == '') {
$Hidden = ' hidden';
} else {
$Hidden = '';
@ -715,13 +724,13 @@ function header_link($SortKey,$DefaultWay="desc") {
<select name="media" class="ft_media fti_advanced">
<option value="">Media</option>
<? foreach ($Media as $MediaName) { ?>
<option value="<?=display_str($MediaName); ?>"<?Format::selected('media',$MediaName)?>><?=display_str($MediaName); ?></option>
<option value="<?=display_str($MediaName); ?>"<?Format::selected('media', $MediaName)?>><?=display_str($MediaName); ?></option>
<? } ?>
</select>
<select name="releasetype" class="ft_releasetype fti_advanced">
<option value="">Release type</option>
<? foreach ($ReleaseTypes as $ID=>$Type) { ?>
<option value="<?=display_str($ID); ?>"<?Format::selected('releasetype',$ID)?>><?=display_str($Type); ?></option>
<option value="<?=display_str($ID); ?>"<?Format::selected('releasetype', $ID)?>><?=display_str($Type); ?></option>
<? } ?>
</select>
</td>
@ -731,32 +740,32 @@ function header_link($SortKey,$DefaultWay="desc") {
<td class="nobr ft_misc" colspan="3">
<select name="haslog" class="ft_haslog fti_advanced">
<option value="">Has Log</option>
<option value="1"<?Format::selected('haslog','1')?>>Yes</option>
<option value="0"<?Format::selected('haslog','0')?>>No</option>
<option value="100"<?Format::selected('haslog','100')?>>100% only</option>
<option value="-1"<?Format::selected('haslog','-1')?>>&lt;100%/Unscored</option>
<option value="1"<?Format::selected('haslog', '1')?>>Yes</option>
<option value="0"<?Format::selected('haslog', '0')?>>No</option>
<option value="100"<?Format::selected('haslog', '100')?>>100% only</option>
<option value="-1"<?Format::selected('haslog', '-1')?>>&lt;100%/Unscored</option>
</select>
<select name="hascue" class="ft_hascue fti_advanced">
<option value="">Has Cue</option>
<option value="1"<?Format::selected('hascue',1)?>>Yes</option>
<option value="0"<?Format::selected('hascue',0)?>>No</option>
<option value="1"<?Format::selected('hascue', 1)?>>Yes</option>
<option value="0"<?Format::selected('hascue', 0)?>>No</option>
</select>
<select name="scene" class="ft_scene fti_advanced">
<option value="">Scene</option>
<option value="1"<?Format::selected('scene',1)?>>Yes</option>
<option value="0"<?Format::selected('scene',0)?>>No</option>
<option value="1"<?Format::selected('scene', 1)?>>Yes</option>
<option value="0"<?Format::selected('scene', 0)?>>No</option>
</select>
<select name="vanityhouse" class="ft_vanityhouse fti_advanced">
<option value="">Vanity House</option>
<option value="1"<?Format::selected('vanityhouse',1)?>>Yes</option>
<option value="0"<?Format::selected('vanityhouse',0)?>>No</option>
<option value="1"<?Format::selected('vanityhouse', 1)?>>Yes</option>
<option value="0"<?Format::selected('vanityhouse', 0)?>>No</option>
</select>
<select name="freetorrent" class="ft_freetorrent fti_advanced">
<option value="">Leech Status</option>
<option value="1"<?Format::selected('freetorrent',1)?>>Freeleech</option>
<option value="2"<?Format::selected('freetorrent',2)?>>Neutral Leech</option>
<option value="3"<?Format::selected('freetorrent',3)?>>Either</option>
<option value="0"<?Format::selected('freetorrent',0)?>>Normal</option>
<option value="1"<?Format::selected('freetorrent', 1)?>>Freeleech</option>
<option value="2"<?Format::selected('freetorrent', 2)?>>Neutral Leech</option>
<option value="3"<?Format::selected('freetorrent', 3)?>>Either</option>
<option value="0"<?Format::selected('freetorrent', 0)?>>Normal</option>
</select>
</td>
</tr>
@ -769,26 +778,26 @@ function header_link($SortKey,$DefaultWay="desc") {
<tr id="tagfilter">
<td class="label">Tags (comma-separated):</td>
<td colspan="3" class="ft_taglist">
<input type="text" size="40" id="tags" name="taglist" class="inputtext smaller" title="Use !tag to exclude tag" value="<?=str_replace('_','.',display_str($TagListString)) /* Use aliased tags, not actual query string. */ ?>" />&nbsp;
<input type="radio" name="tags_type" id="tags_type0" value="0"<?Format::selected('tags_type',0,'checked')?> /><label for="tags_type0"> Any</label>&nbsp;&nbsp;
<input type="radio" name="tags_type" id="tags_type1" value="1"<?Format::selected('tags_type',1,'checked')?> /><label for="tags_type1"> All</label>
<input type="text" size="40" id="tags" name="taglist" class="inputtext smaller" title="Use !tag to exclude tag" value="<?=str_replace('_', '.', display_str($TagListString)) /* Use aliased tags, not actual query string. */ ?>" />&nbsp;
<input type="radio" name="tags_type" id="tags_type0" value="0"<?Format::selected('tags_type', 0, 'checked')?> /><label for="tags_type0"> Any</label>&nbsp;&nbsp;
<input type="radio" name="tags_type" id="tags_type1" value="1"<?Format::selected('tags_type', 1, 'checked')?> /><label for="tags_type1"> All</label>
</td>
</tr>
<tr id="order">
<td class="label">Order by:</td>
<td colspan="3" class="ft_order">
<select name="order_by" style="width: auto;" class="ft_order_by">
<option value="time"<?Format::selected('order_by','time')?>>Time added</option>
<option value="year"<?Format::selected('order_by','year')?>>Year</option>
<option value="size"<?Format::selected('order_by','size')?>>Size</option>
<option value="snatched"<?Format::selected('order_by','snatched')?>>Snatched</option>
<option value="seeders"<?Format::selected('order_by','seeders')?>>Seeders</option>
<option value="leechers"<?Format::selected('order_by','leechers')?>>Leechers</option>
<option value="random"<?Format::selected('order_by','random')?>>Random</option>
<option value="time"<?Format::selected('order_by', 'time')?>>Time added</option>
<option value="year"<?Format::selected('order_by', 'year')?>>Year</option>
<option value="size"<?Format::selected('order_by', 'size')?>>Size</option>
<option value="snatched"<?Format::selected('order_by', 'snatched')?>>Snatched</option>
<option value="seeders"<?Format::selected('order_by', 'seeders')?>>Seeders</option>
<option value="leechers"<?Format::selected('order_by', 'leechers')?>>Leechers</option>
<option value="random"<?Format::selected('order_by', 'random')?>>Random</option>
</select>
<select name="order_way" class="ft_order_way">
<option value="desc"<?Format::selected('order_way','desc')?>>Descending</option>
<option value="asc"<?Format::selected('order_way','asc')?>>Ascending</option>
<option value="desc"<?Format::selected('order_way', 'desc')?>>Descending</option>
<option value="asc"<?Format::selected('order_way', 'asc')?>>Ascending</option>
</select>
</td>
</tr>
@ -830,7 +839,11 @@ function header_link($SortKey,$DefaultWay="desc") {
<?
$GenreTags = $Cache->get_value('genre_tags');
if (!$GenreTags) {
$DB->query('SELECT Name FROM tags WHERE TagType=\'genre\' ORDER BY Name');
$DB->query('
SELECT Name
FROM tags
WHERE TagType = \'genre\'
ORDER BY Name');
$GenreTags = $DB->collect('Name');
$Cache->cache_value('genre_tags', $GenreTags, 3600 * 6);
}
@ -857,7 +870,7 @@ function header_link($SortKey,$DefaultWay="desc") {
<table class="layout cat_list" width="100%">
<tr>
<td class="label">
<a class="brackets" href="#" onclick="$('#taglist').gtoggle(); if (this.innerHTML=='View tags') {this.innerHTML='Hide tags';} else {this.innerHTML='View tags';}; return false;"><?=((empty($LoggedUser['ShowTags'])) ? 'View tags' : 'Hide tags')?></a>
<a class="brackets" href="#" onclick="$('#taglist').gtoggle(); if (this.innerHTML == 'View tags') { this.innerHTML = 'Hide tags'; } else { this.innerHTML = 'View tags'; }; return false;"><?=((empty($LoggedUser['ShowTags'])) ? 'View tags' : 'Hide tags')?></a>
</td>
</tr>
</table>
@ -866,7 +879,7 @@ function header_link($SortKey,$DefaultWay="desc") {
<input type="submit" value="Filter torrents" />
<input type="hidden" name="action" id="ft_type" value="<?=($AdvancedSearch ? 'advanced' : 'basic')?>" />
<input type="hidden" name="searchsubmit" value="1" />
<input type="button" value="Reset" onclick="location.href='torrents.php<? if (isset($_GET['action']) && $_GET['action'] == 'advanced') { ?>?action=advanced<? } ?>'" />
<input type="button" value="Reset" onclick="location.href = 'torrents.php<? if (isset($_GET['action']) && $_GET['action'] == 'advanced') { ?>?action=advanced<? } ?>'" />
&nbsp;&nbsp;
<? if ($Filtered) { ?>
<input type="submit" name="setdefault" value="Make default" />
@ -883,23 +896,24 @@ function header_link($SortKey,$DefaultWay="desc") {
</form>
<?
if ($TorrentCount == 0) {
$DB->query("SELECT
tags.Name,
((COUNT(tags.Name)-2)*(SUM(tt.PositiveVotes)-SUM(tt.NegativeVotes)))/(tags.Uses*0.8) AS Score
FROM xbt_snatched AS s
INNER JOIN torrents AS t ON t.ID=s.fid
INNER JOIN torrents_group AS g ON t.GroupID=g.ID
INNER JOIN torrents_tags AS tt ON tt.GroupID=g.ID
INNER JOIN tags ON tags.ID=tt.TagID
WHERE s.uid='$LoggedUser[ID]'
AND tt.TagID != '13679'
AND tt.TagID != '4820'
AND tt.TagID != '2838'
AND g.CategoryID='1'
AND tags.Uses > '10'
GROUP BY tt.TagID
ORDER BY Score DESC
LIMIT 8");
$DB->query("
SELECT
tags.Name,
((COUNT(tags.Name) - 2) * (SUM(tt.PositiveVotes) - SUM(tt.NegativeVotes))) / (tags.Uses * 0.8) AS Score
FROM xbt_snatched AS s
INNER JOIN torrents AS t ON t.ID = s.fid
INNER JOIN torrents_group AS g ON t.GroupID = g.ID
INNER JOIN torrents_tags AS tt ON tt.GroupID = g.ID
INNER JOIN tags ON tags.ID = tt.TagID
WHERE s.uid = '$LoggedUser[ID]'
AND tt.TagID != '13679'
AND tt.TagID != '4820'
AND tt.TagID != '2838'
AND g.CategoryID = '1'
AND tags.Uses > '10'
GROUP BY tt.TagID
ORDER BY Score DESC
LIMIT 8");
?>
<div class="box pad" align="center">
<h2>Your search did not match anything.</h2>
@ -992,7 +1006,7 @@ function header_link($SortKey,$DefaultWay="desc") {
if ($GroupResults && (count($Torrents) > 1 || isset($GroupedCategories[$CategoryID - 1]))) {
// These torrents are in a group
$DisplayName .= '<a href="torrents.php?id='.$GroupID.'" title="View Torrent" dir="ltr">'.$GroupName.'</a>';
$DisplayName .= "<a href=\"torrents.php?id=$GroupID\" title=\"View Torrent\" dir=\"ltr\">$GroupName</a>";
if ($GroupYear > 0) {
$DisplayName .= " [$GroupYear]";
}
@ -1112,7 +1126,7 @@ function header_link($SortKey,$DefaultWay="desc") {
// Viewing a type that does not require grouping
list($TorrentID, $Data) = each($Torrents);
$DisplayName .= '<a href="torrents.php?id='.$GroupID.'&amp;torrentid='.$TorrentID.'#torrent'.$TorrentID.'" title="View Torrent" dir="ltr">'.$GroupName.'</a>';
$DisplayName .= "<a href=\"torrents.php?id=$GroupID&amp;torrentid=$TorrentID#torrent$TorrentID\" title=\"View Torrent\" dir=\"ltr\">$GroupName</a>";
if (isset($GroupedCategories[$CategoryID - 1])) {
if ($GroupYear) {
$DisplayName .= " [$GroupYear]";

View File

@ -10,47 +10,60 @@
error(403);
}
$DB->query("DELETE FROM torrents_artists WHERE GroupID='$GroupID' AND ArtistID='$ArtistID' AND Importance='$Importance'");
$DB->query("SELECT Name FROM artists_group WHERE ArtistID=".$ArtistID);
$DB->query("
DELETE FROM torrents_artists
WHERE GroupID = '$GroupID'
AND ArtistID = '$ArtistID'
AND Importance = '$Importance'");
$DB->query("
SELECT Name
FROM artists_group
WHERE ArtistID = $ArtistID");
list($ArtistName) = $DB->next_record(MYSQLI_NUM, false);
$DB->query("SELECT Name FROM torrents_group WHERE ID=".$GroupID);
$DB->query("
SELECT Name
FROM torrents_group
WHERE ID = $GroupID");
list($GroupName) = $DB->next_record(MYSQLI_NUM, false);
//Get a count of how many groups or requests use this artist ID
$DB->query("SELECT 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);
// Get a count of how many groups or requests use this artist ID
$DB->query("
SELECT 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");
$ReqCount = $DB->record_count();
$DB->query("SELECT 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 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");
$GroupCount = $DB->record_count();
if (($ReqCount + $GroupCount) == 0) {
//The only group to use this artist
// The only group to use this artist
Artists::delete_artist($ArtistID);
}
$DB->query("INSERT INTO torrents_group (ID, NumArtists)
$DB->query("
INSERT INTO torrents_group (ID, NumArtists)
SELECT ta.GroupID, COUNT(ta.ArtistID)
FROM torrents_artists AS ta
WHERE ta.GroupID='$GroupID'
AND ta.Importance='1'
WHERE ta.GroupID = '$GroupID'
AND ta.Importance = '1'
GROUP BY ta.GroupID
ON DUPLICATE KEY UPDATE
NumArtists=VALUES(NumArtists);");
NumArtists = VALUES (NumArtists);");
$Cache->delete_value('torrents_details_'.$GroupID); // Delete torrent group cache
$Cache->delete_value('groups_artists_'.$GroupID); // Delete group artist cache
Misc::write_log("Artist (".$ArtistTypes[$Importance].") ".$ArtistID." (".$ArtistName.") was removed from the group ".$GroupID." (".$GroupName.") by user ".$LoggedUser['ID']." (".$LoggedUser['Username'].")");
Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "removed artist ".$ArtistName." (".$ArtistTypes[$Importance].")", 0);
$Cache->delete_value("torrents_details_$GroupID"); // Delete torrent group cache
$Cache->delete_value("groups_artists_$GroupID"); // Delete group artist cache
Misc::write_log('Artist ('.$ArtistTypes[$Importance].") $ArtistID ($ArtistName) was removed from the group $GroupID ($GroupName) by user ".$LoggedUser['ID'].' ('.$LoggedUser['Username'].')');
Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "removed artist $ArtistName (".$ArtistTypes[$Importance].')', 0);
Torrents::update_hash($GroupID);
$Cache->delete_value('artist_groups_'.$ArtistID);
$Cache->delete_value("artist_groups_$ArtistID");
header('Location: '.$_SERVER['HTTP_REFERER']);
?>

View File

@ -409,7 +409,7 @@ function compare($X, $Y) {
<input type="hidden" name="action" value="add_alias" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="groupid" value="<?=$GroupID?>" />
<input type="text" id="artist" name="aliasname[]" size="17" <? Users::has_autocomplete_enabled('other'); ?>/>
<input type="text" id="artist" name="aliasname[]" size="17"<? Users::has_autocomplete_enabled('other'); ?> />
<select name="importance[]">
<option value="1">Main</option>
<option value="2">Guest</option>
@ -490,7 +490,7 @@ function compare($X, $Y) {
<input type="hidden" name="action" value="add_tag" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="groupid" value="<?=$GroupID?>" />
<input type="text" name="tagname" id="tagname" size="20" <? Users::has_autocomplete_enabled('other'); ?> />
<input type="text" name="tagname" id="tagname" size="20"<? Users::has_autocomplete_enabled('other'); ?> />
<input type="submit" value="+" />
</form>
<br /><br />
@ -546,7 +546,8 @@ function filelist($Str) {
unset($ReportedTimes);
$Reports = $Cache->get_value('reports_torrent_'.$TorrentID);
if ($Reports === false) {
$DB->query("SELECT r.ID,
$DB->query("
SELECT r.ID,
r.ReporterID,
r.Type,
r.UserComment,
@ -556,12 +557,12 @@ function filelist($Str) {
AND Type != 'edited'
AND Status != 'Resolved'");
$Reports = $DB->to_array();
$Cache->cache_value('reports_torrent_'.$TorrentID, $Reports, 0);
$Cache->cache_value("reports_torrent_$TorrentID", $Reports, 0);
}
if (count($Reports) > 0) {
$Reported = true;
include(SERVER_ROOT.'/sections/reportsv2/array.php');
$ReportInfo = '<table class="reportinfo_table"><tr class="colhead_dark" style="font-weight: bold;"><td>This torrent has '.count($Reports).' active '.(count($Reports) > 1 ? "reports" : "report").':</td></tr>';
$ReportInfo = "\n<table class=\"reportinfo_table\">\n\t<tr class=\"colhead_dark\" style=\"font-weight: bold;\">\n\t\t<td>This torrent has ".count($Reports).' active '.(count($Reports) > 1 ? 'reports' : 'report').":</td>\n\t</tr>";
foreach ($Reports as $Report) {
list($ReportID, $ReporterID, $ReportType, $ReportReason, $ReportedTime) = $Report;
@ -577,10 +578,10 @@ function filelist($Str) {
//There was a type but it wasn't an option!
$ReportType = $Types['master']['other'];
}
$ReportInfo .= "<tr><td>".(check_perms('admin_reports') ? "<a href=\"user.php?id=$ReporterID\">$ReporterName</a> <a href=\"reportsv2.php?view=report&amp;id=$ReportID\">reported it</a> " : 'Someone reported it ') . time_diff($ReportedTime, 2, true, true) . ' for the reason "' . $ReportType['title'] . '":';
$ReportInfo .= "<blockquote>".$Text->full_format($ReportReason)."</blockquote></td></tr>";
$ReportInfo .= "\n\t<tr>\n\t\t<td>".(check_perms('admin_reports') ? "<a href=\"user.php?id=$ReporterID\">$ReporterName</a> <a href=\"reportsv2.php?view=report&amp;id=$ReportID\">reported it</a> " : 'Someone reported it ') . time_diff($ReportedTime, 2, true, true) . ' for the reason "' . $ReportType['title'] . '":';
$ReportInfo .= "\n<blockquote>".$Text->full_format($ReportReason)."</blockquote>\n\t\t</td>\n\t</tr>";
}
$ReportInfo .= "</table>";
$ReportInfo .= "\n</table>";
}
$CanEdit = (check_perms('torrents_edit') || (($UserID == $LoggedUser['ID'] && !$LoggedUser['DisableWiki']) && !($Remastered && !$RemasterYear)));
@ -589,7 +590,7 @@ function filelist($Str) {
$FileTable = '
<table class="filelist_table">
<tr class="colhead_dark"><td>
<div class="filelist_title" style="float: left;">File Name' . $RegenLink . '</div>
<div class="filelist_title" style="float: left;">File name' . $RegenLink . '</div>
<div class="filelist_path" style="float: right;">' . ($FilePath ? "/$FilePath/" : '') . '</div>
</td><td>
<strong>Size</strong>
@ -733,7 +734,7 @@ function filelist($Str) {
<div id="reported_<?=$TorrentID?>" class="hidden"><?=$ReportInfo?></div>
<? }
if (!empty($Description)) {
echo '<blockquote>'.$Text->full_format($Description).'</blockquote>';}
echo "\n<blockquote>".$Text->full_format($Description).'</blockquote>';}
?>
</td>
</tr>

View File

@ -8,18 +8,17 @@
} else {
$UserInfo = $Cache->get_value('user_'.$_REQUEST['torrent_pass']);
if (!is_array($UserInfo)) {
$DB->query("SELECT
ID,
DownloadAlt
$DB->query("
SELECT ID, DownloadAlt
FROM users_main AS m
INNER JOIN users_info AS i ON i.UserID=m.ID
WHERE m.torrent_pass='".db_string($_REQUEST['torrent_pass'])."'
AND m.Enabled='1'");
INNER JOIN users_info AS i ON i.UserID = m.ID
WHERE m.torrent_pass = '".db_string($_REQUEST['torrent_pass'])."'
AND m.Enabled = '1'");
$UserInfo = $DB->next_record();
$Cache->cache_value('user_'.$_REQUEST['torrent_pass'], $UserInfo, 3600);
}
$UserInfo = array($UserInfo);
list($UserID,$DownloadAlt)=array_shift($UserInfo);
list($UserID, $DownloadAlt) = array_shift($UserInfo);
if (!$UserID) {
error(0);
}
@ -35,47 +34,53 @@
error(0);
}
/* uTorrent remote redownloads .torrent files every fifteen minutes
to prevent this retardation from blowing bandwidth etc., let's block it
if he's downloaded the .torrent file twice before */
/* uTorrent Remote redownloads .torrent files every fifteen minutes.
To prevent this retardation from blowing bandwidth etc., let's block it
if he has downloaded the .torrent file twice before */
if (strpos($_SERVER['HTTP_USER_AGENT'], 'BTWebClient') !== false) {
$DB->query("SELECT 1 FROM users_downloads WHERE UserID=$UserID AND TorrentID=$TorrentID LIMIT 3");
$DB->query("
SELECT 1
FROM users_downloads
WHERE UserID = $UserID
AND TorrentID = $TorrentID
LIMIT 3");
if ($DB->record_count() > 2) {
error('You have already downloaded this .torrent three times. If you need to download it again, please do so from your browser, not through uTorrent remote.');
error('You have already downloaded this torrent file three times. If you need to download it again, please do so from your browser, not through μTorrent Remote.');
die();
}
}
$Info = $Cache->get_value('torrent_download_'.$TorrentID);
if (!is_array($Info) || !array_key_exists('PlainArtists', $Info) || empty($Info[10])) {
$DB->query("SELECT
t.Media,
t.Format,
t.Encoding,
IF(t.RemasterYear=0,tg.Year,t.RemasterYear),
tg.ID AS GroupID,
tg.Name,
tg.WikiImage,
tg.CategoryID,
t.Size,
t.FreeTorrent,
t.info_hash
$DB->query("
SELECT
t.Media,
t.Format,
t.Encoding,
IF(t.RemasterYear = 0, tg.Year, t.RemasterYear),
tg.ID AS GroupID,
tg.Name,
tg.WikiImage,
tg.CategoryID,
t.Size,
t.FreeTorrent,
t.info_hash
FROM torrents AS t
INNER JOIN torrents_group AS tg ON tg.ID=t.GroupID
WHERE t.ID='".db_string($TorrentID)."'");
INNER JOIN torrents_group AS tg ON tg.ID = t.GroupID
WHERE t.ID = '".db_string($TorrentID)."'");
if ($DB->record_count() < 1) {
error(404);
}
$Info = array($DB->next_record(MYSQLI_NUM, array(4,5,6,10)));
$Artists = Artists::get_artist($Info[0][4],false);
$Info = array($DB->next_record(MYSQLI_NUM, array(4, 5, 6, 10)));
$Artists = Artists::get_artist($Info[0][4], false);
$Info['Artists'] = Artists::display_artists($Artists, false, true);
$Info['PlainArtists'] = Artists::display_artists($Artists, false, true, false);
$Cache->cache_value('torrent_download_'.$TorrentID, $Info, 0);
$Cache->cache_value("torrent_download_$TorrentID", $Info, 0);
}
if (!is_array($Info[0])) {
error(404);
}
list($Media,$Format,$Encoding,$Year,$GroupID,$Name,$Image, $CategoryID, $Size, $FreeTorrent, $InfoHash) = array_shift($Info); // used for generating the filename
list($Media, $Format, $Encoding, $Year, $GroupID, $Name, $Image, $CategoryID, $Size, $FreeTorrent, $InfoHash) = array_shift($Info); // used for generating the filename
$Artists = $Info['Artists'];
// If he's trying use a token on this, we need to make sure he has one,
@ -99,40 +104,52 @@
if (!Torrents::has_token($TorrentID)) {
if ($FLTokens <= 0) {
error("You do not have any freeleech tokens left. Please use the regular DL link.");
error('You do not have any freeleech tokens left. Please use the regular DL link.');
}
if ($Size >= 1073741824) {
error("This torrent is too large. Please use the regular DL link.");
error('This torrent is too large. Please use the regular DL link.');
}
// Let the tracker know about this
if (!Tracker::update_tracker('add_token', array('info_hash' => rawurlencode($InfoHash), 'userid' => $UserID))) {
error("Sorry! An error occurred while trying to register your token. Most often, this is due to the tracker being down or under heavy load. Please try again later.");
error('Sorry! An error occurred while trying to register your token. Most often, this is due to the tracker being down or under heavy load. Please try again later.');
}
if (!Torrents::has_token($TorrentID)) {
$DB->query("INSERT INTO users_freeleeches (UserID, TorrentID, Time) VALUES ($UserID, $TorrentID, NOW())
ON DUPLICATE KEY UPDATE Time=VALUES(Time), Expired=FALSE, Uses=Uses+1");
$DB->query("UPDATE users_main SET FLTokens = FLTokens - 1 WHERE ID=$UserID");
$DB->query("
INSERT INTO users_freeleeches (UserID, TorrentID, Time)
VALUES ($UserID, $TorrentID, NOW())
ON DUPLICATE KEY UPDATE
Time = VALUES(Time),
Expired = FALSE,
Uses = Uses + 1");
$DB->query("
UPDATE users_main
SET FLTokens = FLTokens - 1
WHERE ID = $UserID");
// Fix for downloadthemall messing with the cached token count
$UInfo = Users::user_heavy_info($UserID);
$FLTokens = $UInfo['FLTokens'];
$Cache->begin_transaction('user_info_heavy_'.$UserID);
$Cache->update_row(false, array('FLTokens'=>($FLTokens - 1)));
$Cache->begin_transaction("user_info_heavy_$UserID");
$Cache->update_row(false, array('FLTokens' => ($FLTokens - 1)));
$Cache->commit_transaction(0);
$Cache->delete_value('users_tokens_'.$UserID);
$Cache->delete_value("users_tokens_$UserID");
}
}
}
//Stupid Recent Snatches On User Page
if ($CategoryID == '1' && $Image != '') {
$RecentSnatches = $Cache->get_value('recent_snatches_'.$UserID);
$RecentSnatches = $Cache->get_value("recent_snatches_$UserID");
if (!empty($RecentSnatches)) {
$Snatch = array('ID'=>$GroupID,'Name'=>$Name,'Artist'=>$Artists,'WikiImage'=>$Image);
$Snatch = array(
'ID' => $GroupID,
'Name' => $Name,
'Artist' => $Artists,
'WikiImage' => $Image);
if (!in_array($Snatch, $RecentSnatches)) {
if (count($RecentSnatches) == 5) {
array_pop($RecentSnatches);
@ -141,7 +158,7 @@
} elseif (!is_array($RecentSnatches)) {
$RecentSnatches = array($Snatch);
}
$Cache->cache_value('recent_snatches_'.$UserID, $RecentSnatches, 0);
$Cache->cache_value("recent_snatches_$UserID", $RecentSnatches, 0);
}
}
@ -149,7 +166,10 @@
INSERT IGNORE INTO users_downloads (UserID, TorrentID, Time)
VALUES ('$UserID', '$TorrentID', '".sqltime()."')");
$DB->query("SELECT File FROM torrents_files WHERE TorrentID='$TorrentID'");
$DB->query("
SELECT File
FROM torrents_files
WHERE TorrentID = '$TorrentID'");
list($Contents) = $DB->next_record(MYSQLI_NUM, false);
$FileName = TorrentsDL::construct_file_name($Info['PlainArtists'], $Name, $Year, $Media, $Format, $Encoding, false, $DownloadAlt);

View File

@ -23,17 +23,23 @@
//Everything is legit, let's just confim they're not retarded
if (empty($_POST['confirm'])) {
$DB->query("SELECT Name FROM torrents_group WHERE ID = ".$OldGroupID);
$DB->query("
SELECT Name
FROM torrents_group
WHERE ID = $OldGroupID");
if ($DB->record_count() < 1) {
//Trying to move to an empty group? I think not!
set_message("That group doesn't exist!");
set_message('That group does not exist!');
header('Location: '.$_SERVER['HTTP_REFERER']);
die();
}
list($Name) = $DB->next_record();
$DB->query("SELECT CategoryID, Name FROM torrents_group WHERE ID = ".$GroupID);
$DB->query("
SELECT CategoryID, Name
FROM torrents_group
WHERE ID = $GroupID");
list($CategoryID, $NewName) = $DB->next_record();
if ($Categories[$CategoryID-1] != 'Music') {
if ($Categories[$CategoryID - 1] != 'Music') {
error('Target must be a music group.');
}
@ -54,9 +60,13 @@
<input type="hidden" name="oldgroupid" value="<?=$OldGroupID?>" />
<input type="hidden" name="groupid" value="<?=$GroupID?>" />
<h3>You are attempting to move the torrent with ID <?=$TorrentID?> from the group:</h3>
<ul><li><?= Artists::display_artists($Artists[$OldGroupID], true, false)?> - <a href="torrents.php?id=<?=$OldGroupID?>"><?=$Name?></a></li></ul>
<ul>
<li><?= Artists::display_artists($Artists[$OldGroupID], true, false)?> - <a href="torrents.php?id=<?=$OldGroupID?>"><?=$Name?></a></li>
</ul>
<h3>Into the group:</h3>
<ul><li><?= Artists::display_artists($Artists[$GroupID], true, false)?> - <a href="torrents.php?id=<?=$GroupID?>"><?=$NewName?></a></li></ul>
<ul>
<li><?= Artists::display_artists($Artists[$GroupID], true, false)?> - <a href="torrents.php?id=<?=$GroupID?>"><?=$NewName?></a></li>
</ul>
<input type="submit" value="Confirm" />
</form>
</div>
@ -67,16 +77,22 @@
authorize();
$DB->query("UPDATE torrents
SET GroupID='$GroupID'
WHERE ID=$TorrentID");
SET GroupID = '$GroupID'
WHERE ID = $TorrentID");
// Delete old torrent group if it's empty now
$DB->query("SELECT COUNT(ID) FROM torrents WHERE GroupID='$OldGroupID'");
$DB->query("
SELECT COUNT(ID)
FROM torrents
WHERE GroupID = '$OldGroupID'");
list($TorrentsInGroup) = $DB->next_record();
if ($TorrentsInGroup == 0) {
$DB->query("UPDATE torrents_comments SET GroupID='$GroupID' WHERE GroupID='$OldGroupID'");
$Cache->delete_value('torrent_comments_'.$GroupID.'_catalogue_0');
$Cache->delete_value('torrent_comments_'.$GroupID);
$DB->query("
UPDATE torrents_comments
SET GroupID = '$GroupID'
WHERE GroupID = '$OldGroupID'");
$Cache->delete_value("torrent_comments_{$GroupID}_catalogue_0");
$Cache->delete_value("torrent_comments_$GroupID");
Torrents::delete_group($OldGroupID);
} else {
Torrents::update_hash($OldGroupID);
@ -84,11 +100,14 @@
Torrents::update_hash($GroupID);
Misc::write_log("Torrent $TorrentID was edited by " . $LoggedUser['Username']); // TODO: this is probably broken
Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "merged group ".$OldGroupID, 0);
$DB->query("UPDATE group_log SET GroupID = ".$GroupID." WHERE GroupID = ".$OldGroupID);
Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "merged group $OldGroupID", 0);
$DB->query("
UPDATE group_log
SET GroupID = $GroupID
WHERE GroupID = $OldGroupID");
$Cache->delete_value('torrents_details_'.$GroupID);
$Cache->delete_value('torrent_download_'.$TorrentID);
$Cache->delete_value("torrents_details_$GroupID");
$Cache->delete_value("torrent_download_$TorrentID");
header("Location: torrents.php?id=$GroupID");
}

View File

@ -17,16 +17,16 @@ function get_group_info($GroupID, $Return = true, $RevisionID = 0, $PersonalProp
if ($RevisionID || !is_array($TorrentCache) || isset($OutdatedCache)) {
// Fetch the group details
$SQL = "SELECT ";
$SQL = 'SELECT ';
if (!$RevisionID) {
$SQL .= "
$SQL .= '
g.WikiBody,
g.WikiImage, ";
g.WikiImage, ';
} else {
$SQL .= "
$SQL .= '
w.Body,
w.Image, ";
w.Image, ';
}
$SQL .= "
@ -45,16 +45,17 @@ function get_group_info($GroupID, $Return = true, $RevisionID = 0, $PersonalProp
GROUP_CONCAT(tt.PositiveVotes SEPARATOR '|'),
GROUP_CONCAT(tt.NegativeVotes SEPARATOR '|')
FROM torrents_group AS g
LEFT JOIN torrents_tags AS tt ON tt.GroupID=g.ID
LEFT JOIN tags ON tags.ID=tt.TagID";
LEFT JOIN torrents_tags AS tt ON tt.GroupID = g.ID
LEFT JOIN tags ON tags.ID = tt.TagID";
if ($RevisionID) {
$SQL .= "
LEFT JOIN wiki_torrents AS w ON w.PageID='".db_string($GroupID)."' AND w.RevisionID='".db_string($RevisionID)."' ";
LEFT JOIN wiki_torrents AS w ON w.PageID = '".db_string($GroupID)."'
AND w.RevisionID = '".db_string($RevisionID)."' ";
}
$SQL .= "
WHERE g.ID='".db_string($GroupID)."'
WHERE g.ID = '".db_string($GroupID)."'
GROUP BY NULL";
$DB->query($SQL);
@ -100,14 +101,14 @@ function get_group_info($GroupID, $Return = true, $RevisionID = 0, $PersonalProp
tln.TorrentID AS LogInDB,
t.ID AS HasFile
FROM torrents AS t
LEFT JOIN torrents_bad_tags AS tbt ON tbt.TorrentID=t.ID
LEFT JOIN torrents_bad_folders AS tbf on tbf.TorrentID=t.ID
LEFT JOIN torrents_bad_files AS tfi on tfi.TorrentID=t.ID
LEFT JOIN torrents_cassette_approved AS ca on ca.TorrentID=t.ID
LEFT JOIN torrents_lossymaster_approved AS lma on lma.TorrentID=t.ID
LEFT JOIN torrents_lossyweb_approved AS lwa on lwa.TorrentID=t.ID
LEFT JOIN torrents_logs_new AS tln ON tln.TorrentID=t.ID
WHERE t.GroupID='".db_string($GroupID)."'
LEFT JOIN torrents_bad_tags AS tbt ON tbt.TorrentID = t.ID
LEFT JOIN torrents_bad_folders AS tbf on tbf.TorrentID = t.ID
LEFT JOIN torrents_bad_files AS tfi on tfi.TorrentID = t.ID
LEFT JOIN torrents_cassette_approved AS ca on ca.TorrentID = t.ID
LEFT JOIN torrents_lossymaster_approved AS lma on lma.TorrentID = t.ID
LEFT JOIN torrents_lossyweb_approved AS lwa on lwa.TorrentID = t.ID
LEFT JOIN torrents_logs_new AS tln ON tln.TorrentID = t.ID
WHERE t.GroupID = '".db_string($GroupID)."'
GROUP BY t.ID
ORDER BY t.Remastered ASC,
(t.RemasterYear != 0) DESC,
@ -122,7 +123,7 @@ function get_group_info($GroupID, $Return = true, $RevisionID = 0, $PersonalProp
$TorrentList = $DB->to_array('ID', MYSQLI_ASSOC);
if (count($TorrentList) == 0 && $ApiCall == false) {
header("Location: log.php?search=".(empty($_GET['torrentid']) ? "Group+$GroupID" : "Torrent+$_GET[torrentid]"));
header('Location: log.php?search='.(empty($_GET['torrentid']) ? "Group+$GroupID" : "Torrent+$_GET[torrentid]"));
die();
} else if (count($TorrentList) == 0 && $ApiCall == true) {
return NULL;
@ -134,7 +135,7 @@ function get_group_info($GroupID, $Return = true, $RevisionID = 0, $PersonalProp
}
// Store it all in cache
if (!$RevisionID) {
$Cache->cache_value('torrents_details_'.$GroupID, array($TorrentDetails, $TorrentList), $CacheTime);
$Cache->cache_value("torrents_details_$GroupID", array($TorrentDetails, $TorrentList), $CacheTime);
}
} else { // If we're reading from cache
$TorrentDetails = $TorrentCache[0];
@ -188,7 +189,10 @@ function is_valid_torrenthash($Str) {
function torrenthash_to_torrentid($Str) {
global $Cache, $DB;
$DB->query("SELECT t.ID FROM torrents AS t WHERE HEX(t.info_hash)='".db_string($Str)."'");
$DB->query("
SELECT t.ID
FROM torrents AS t
WHERE HEX(t.info_hash) = '".db_string($Str)."'");
$TorrentID = (int)array_pop($DB->next_record(MYSQLI_ASSOC));
if ($TorrentID) {
return $TorrentID;
@ -198,7 +202,10 @@ function torrenthash_to_torrentid($Str) {
function torrenthash_to_groupid($Str) {
global $Cache, $DB;
$DB->query("SELECT t.GroupID FROM torrents AS t WHERE HEX(t.info_hash)='".db_string($Str)."'");
$DB->query("
SELECT t.GroupID
FROM torrents AS t
WHERE HEX(t.info_hash) = '".db_string($Str)."'");
$GroupID = (int)array_pop($DB->next_record(MYSQLI_ASSOC));
if ($GroupID) {
return $GroupID;
@ -208,7 +215,10 @@ function torrenthash_to_groupid($Str) {
function torrentid_to_groupid($TorrentID) {
global $Cache, $DB;
$DB->query("SELECT t.GroupID FROM torrents AS t WHERE t.ID='".db_string($TorrentID)."'");
$DB->query("
SELECT t.GroupID
FROM torrents AS t
WHERE t.ID = '".db_string($TorrentID)."'");
$GroupID = (int)array_pop($DB->next_record(MYSQLI_ASSOC));
if ($GroupID) {
return $GroupID;
@ -219,7 +229,14 @@ function torrentid_to_groupid($TorrentID) {
//After adjusting / deleting logs, recalculate the score for the torrent.
function set_torrent_logscore($TorrentID) {
global $DB;
$DB->query("UPDATE torrents SET LogScore = (SELECT FLOOR(AVG(Score)) FROM torrents_logs_new WHERE TorrentID = ".$TorrentID.") WHERE ID = ".$TorrentID);
$DB->query("
UPDATE torrents
SET LogScore = (
SELECT FLOOR(AVG(Score))
FROM torrents_logs_new
WHERE TorrentID = $TorrentID
)
WHERE ID = $TorrentID");
}
function get_group_requests($GroupID) {
@ -228,11 +245,15 @@ function get_group_requests($GroupID) {
}
global $DB, $Cache;
$Requests = $Cache->get_value('requests_group_'.$GroupID);
$Requests = $Cache->get_value("requests_group_$GroupID");
if ($Requests === false) {
$DB->query("SELECT ID FROM requests WHERE GroupID = $GroupID AND TimeFilled = '0000-00-00 00:00:00'");
$DB->query("
SELECT ID
FROM requests
WHERE GroupID = $GroupID
AND TimeFilled = '0000-00-00 00:00:00'");
$Requests = $DB->collect('ID');
$Cache->cache_value('requests_group_'.$GroupID, $Requests, 0);
$Cache->cache_value("requests_group_$GroupID", $Requests, 0);
}
$Requests = Requests::get_requests($Requests);
return $Requests['matches'];
@ -241,7 +262,7 @@ function get_group_requests($GroupID) {
//Used to get reports info on a unison cache in both browsing pages and torrent pages.
function get_reports($TorrentID) {
global $Cache, $DB;
$Reports = $Cache->get_value('reports_torrent_' . $TorrentID);
$Reports = $Cache->get_value("reports_torrent_$TorrentID");
if ($Reports === false) {
$DB->query("
SELECT
@ -255,7 +276,7 @@ function get_reports($TorrentID) {
AND Type != 'edited'
AND Status != 'Resolved'");
$Reports = $DB->to_array();
$Cache->cache_value('reports_torrent_' . $TorrentID, $Reports, 0);
$Cache->cache_value("reports_torrent_$TorrentID", $Reports, 0);
}
return $Reports;
}
@ -264,7 +285,7 @@ function get_reports($TorrentID) {
function build_torrents_table($Cache, $DB, $LoggedUser, $GroupID, $GroupName, $GroupCategoryID, $ReleaseType, $TorrentList, $Types, $Text, $Username, $ReportedTimes) {
function filelist($Str) {
return '</td><td>' . Format::get_size($Str[1]) . '</td></tr>';
return "</td>\n<td>" . Format::get_size($Str[1]) . "</td>\n</tr>";
}
$LastRemasterYear = '-';
@ -295,7 +316,7 @@ function filelist($Str) {
$Reported = false;
unset($ReportedTimes);
$Reports = $Cache->get_value('reports_torrent_' . $TorrentID);
$Reports = $Cache->get_value("reports_torrent_$TorrentID");
if ($Reports === false) {
$DB->query("
SELECT
@ -309,31 +330,31 @@ function filelist($Str) {
AND Type != 'edited'
AND Status != 'Resolved'");
$Reports = $DB->to_array();
$Cache->cache_value('reports_torrent_' . $TorrentID, $Reports, 0);
$Cache->cache_value("reports_torrent_$TorrentID", $Reports, 0);
}
if (count($Reports) > 0) {
$Reported = true;
include(SERVER_ROOT . '/sections/reportsv2/array.php');
$ReportInfo = '<table><tr class="colhead_dark" style="font-weight: bold;"><td>This torrent has ' . count($Reports) . ' active ' . (count($Reports) > 1 ? 'reports' : 'report') . ':</td></tr>';
$ReportInfo = "\n<table>\n\t<tr class=\"colhead_dark\" style=\"font-weight: bold;\">\n\t\t<td>This torrent has " . count($Reports) . ' active ' . (count($Reports) > 1 ? 'reports' : 'report') . ":</td>\n\t</tr>";
foreach ($Reports as $Report) {
list($ReportID, $ReporterID, $ReportType, $ReportReason, $ReportedTime) = $Report;
list($ReportID, $ReporterID, $ReportType, $ReportReason, $ReportedTime) = $Report;
$Reporter = Users::user_info($ReporterID);
$ReporterName = $Reporter['Username'];
$Reporter = Users::user_info($ReporterID);
$ReporterName = $Reporter['Username'];
if (array_key_exists($ReportType, $Types[$GroupCategoryID])) {
$ReportType = $Types[$GroupCategoryID][$ReportType];
} else if (array_key_exists($ReportType, $Types['master'])) {
$ReportType = $Types['master'][$ReportType];
} else {
//There was a type but it wasn't an option!
$ReportType = $Types['master']['other'];
if (array_key_exists($ReportType, $Types[$GroupCategoryID])) {
$ReportType = $Types[$GroupCategoryID][$ReportType];
} else if (array_key_exists($ReportType, $Types['master'])) {
$ReportType = $Types['master'][$ReportType];
} else {
//There was a type but it wasn't an option!
$ReportType = $Types['master']['other'];
}
$ReportInfo .= "\n\t<tr>\n\t\t<td>" . (check_perms('admin_reports') ? "<a href=\"user.php?id=$ReporterID\">$ReporterName</a> <a href=\"reportsv2.php?view=report&amp;id=$ReportID\">reported it</a> " : 'Someone reported it ') . time_diff($ReportedTime, 2, true, true) . ' for the reason "' . $ReportType['title'] . '":';
$ReportInfo .= "\n\t\t\t<blockquote>" . $Text->full_format($ReportReason) . "</blockquote>\n\t\t</td>\n\t</tr>";
}
$ReportInfo .= '<tr><td>' . (check_perms('admin_reports') ? "<a href=\"user.php?id=$ReporterID\">$ReporterName</a> <a href=\"reportsv2.php?view=report&amp;id=$ReportID\">reported it</a> " : 'Someone reported it ') . time_diff($ReportedTime, 2, true, true) . ' for the reason "' . $ReportType['title'] . '":';
$ReportInfo .= '<blockquote>' . $Text->full_format($ReportReason) . '</blockquote></td></tr>';
}
$ReportInfo .= '</table>';
$ReportInfo .= "\n</table>";
}
$CanEdit = (check_perms('torrents_edit') || (($UserID == $LoggedUser['ID'] && !$LoggedUser['DisableWiki']) && !($Remastered && !$RemasterYear)));
@ -377,26 +398,26 @@ function filelist($Str) {
$TorrentUploader = $Username; // Save this for "Uploaded by:" below
// similar to Torrents::torrent_info()
if ($Format) {
$ExtraInfo.=display_str($Format);
$ExtraInfo .= display_str($Format);
$AddExtra = ' / ';
}
if ($Encoding) {
$ExtraInfo.=$AddExtra . display_str($Encoding);
$ExtraInfo .= $AddExtra . display_str($Encoding);
$AddExtra = ' / ';
}
if ($HasLog) {
$ExtraInfo.=$AddExtra . 'Log';
$ExtraInfo .= "{$AddExtra}Log";
$AddExtra = ' / ';
}
if ($HasLog && $LogInDB) {
$ExtraInfo.=' (' . (int) $LogScore . '%)';
$ExtraInfo .= ' (' . (int) $LogScore . '%)';
}
if ($HasCue) {
$ExtraInfo.=$AddExtra . 'Cue';
$ExtraInfo .= "{$AddExtra}Cue";
$AddExtra = ' / ';
}
if ($Scene) {
$ExtraInfo.=$AddExtra . 'Scene';
$ExtraInfo .= "{$AddExtra}Scene";
$AddExtra = ' / ';
}
if (!$ExtraInfo) {
@ -404,47 +425,47 @@ function filelist($Str) {
$AddExtra = ' / ';
}
if ($IsSnatched) {
$ExtraInfo.=$AddExtra . Format::torrent_label('Snatched!');
$ExtraInfo .= $AddExtra . Format::torrent_label('Snatched!');
$AddExtra = ' / ';
}
if ($FreeTorrent == '1') {
$ExtraInfo.=$AddExtra . Format::torrent_label('Freeleech!');
$ExtraInfo .= $AddExtra . Format::torrent_label('Freeleech!');
$AddExtra = ' / ';
}
if ($FreeTorrent == '2') {
$ExtraInfo.=$AddExtra . Format::torrent_label('Neutral Leech!');
$ExtraInfo .= $AddExtra . Format::torrent_label('Neutral Leech!');
$AddExtra = ' / ';
}
if ($PersonalFL) {
$ExtraInfo.=$AddExtra . Format::torrent_label('Personal Freeleech!');
$ExtraInfo .= $AddExtra . Format::torrent_label('Personal Freeleech!');
$AddExtra = ' / ';
}
if ($Reported) {
$ExtraInfo.=$AddExtra . Format::torrent_label('Reported');
$ExtraInfo .= $AddExtra . Format::torrent_label('Reported');
$AddExtra = ' / ';
}
if (!empty($BadTags)) {
$ExtraInfo.=$AddExtra . Format::torrent_label('Bad Tags');
$ExtraInfo .= $AddExtra . Format::torrent_label('Bad Tags');
$AddExtra = ' / ';
}
if (!empty($BadFolders)) {
$ExtraInfo.=$AddExtra . Format::torrent_label('Bad Folders');
$ExtraInfo .= $AddExtra . Format::torrent_label('Bad Folders');
$AddExtra = ' / ';
}
if (!empty($CassetteApproved)) {
$ExtraInfo.=$AddExtra . Format::torrent_label('Cassette Approved');
$ExtraInfo .= $AddExtra . Format::torrent_label('Cassette Approved');
$AddExtra = ' / ';
}
if (!empty($LossymasterApproved)) {
$ExtraInfo.=$AddExtra . Format::torrent_label('Lossy Master Approved');
$ExtraInfo .= $AddExtra . Format::torrent_label('Lossy Master Approved');
$AddExtra = ' / ';
}
if (!empty($LossywebApproved)) {
$ExtraInfo.=$AddExtra . Format::torrent_label('Lossy WEB Approved');
$ExtraInfo .= $AddExtra . Format::torrent_label('Lossy WEB Approved');
$AddExtra = ' / ';
}
if (!empty($BadFiles)) {
$ExtraInfo.=$AddExtra . Format::torrent_label('Bad File Names');
$ExtraInfo .= $AddExtra . Format::torrent_label('Bad File Names');
$AddExtra = ' / ';
}
@ -459,7 +480,7 @@ function filelist($Str) {
$EditionID++;
?>
<tr class="releases_<?=($ReleaseType)?> groupid_<?=($GroupID)?> edition group_torrent">
<td colspan="5" class="edition_info"><strong><a href="#" onclick="toggle_edition(<?=($GroupID)?>, <?=($EditionID)?>, this, event)" title="Collapse this edition. Hold &quot;Ctrl&quot; while clicking to collapse all editions in this torrent group.">&minus;</a> <?= Torrents::edition_string($Torrent, $TorrentDetails) ?></strong></td>
<td colspan="5" class="edition_info"><strong><a href="#" onclick="toggle_edition(<?=($GroupID)?>, <?=($EditionID)?>, this, event);" title="Collapse this edition. Hold &quot;Ctrl&quot; while clicking to collapse all editions in this torrent group.">&minus;</a> <?= Torrents::edition_string($Torrent, $TorrentDetails) ?></strong></td>
</tr>
<?
}
@ -512,14 +533,14 @@ function filelist($Str) {
</div>
<? } ?>
<div class="linkbox">
<a href="#" class="brackets" onclick="show_peers('<?=($TorrentID)?>', 0);return false;">View peer list</a>
<a href="#" class="brackets" onclick="show_peers('<?=($TorrentID)?>', 0); return false;">View peer list</a>
<? if (check_perms('site_view_torrent_snatchlist')) { ?>
<a href="#" class="brackets" onclick="show_downloads('<?=($TorrentID)?>', 0);return false;" title="View the list of users that have clicked the &quot;DL&quot; button.">View download list</a>
<a href="#" class="brackets" onclick="show_snatches('<?=($TorrentID)?>', 0);return false;" title="View the list of users that have reported a snatch to the tracker.">View snatch list</a>
<a href="#" class="brackets" onclick="show_downloads('<?=($TorrentID)?>', 0); return false;" title="View the list of users that have clicked the &quot;DL&quot; button.">View download list</a>
<a href="#" class="brackets" onclick="show_snatches('<?=($TorrentID)?>', 0); return false;" title="View the list of users that have reported a snatch to the tracker.">View snatch list</a>
<? } ?>
<a href="#" class="brackets" onclick="show_files('<?=($TorrentID)?>');return false;">View file list</a>
<a href="#" class="brackets" onclick="show_files('<?=($TorrentID)?>'); return false;">View file list</a>
<? if ($Reported) { ?>
<a href="#" class="brackets" onclick="show_reported('<?=($TorrentID)?>');return false;">View report information</a>
<a href="#" class="brackets" onclick="show_reported('<?=($TorrentID)?>'); return false;">View report information</a>
<? } ?>
</div>
<div id="peers_<?=($TorrentID)?>" class="hidden"></div>
@ -530,7 +551,7 @@ function filelist($Str) {
<div id="reported_<?=($TorrentID)?>" class="hidden"><?=($ReportInfo)?></div>
<? }
if (!empty($Description)) {
echo '<blockquote>' . $Text->full_format($Description) . '</blockquote>';
echo "\n\t\t\t\t\t\t<blockquote>" . $Text->full_format($Description) . '</blockquote>';
} ?>
</td>
</tr>

View File

@ -8,10 +8,10 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
if ($i == $CurrentPage) {
$PageLinks[] = $i;
} else {
$PageLinks[] = '<a href="#" onclick="'.$Action.'('.$TorrentID.', '.$i.')">'.$i.'</a>';
$PageLinks[] = "<a href=\"#\" onclick=\"$Action($TorrentID, $i)\">$i</a>";
}
}
return implode(' | ',$PageLinks);
return implode(' | ', $PageLinks);
}
// This gets used in a few places
@ -194,33 +194,36 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
$DB->query("
SELECT
CEIL((
SELECT COUNT(ID)+1
SELECT COUNT(ID) + 1
FROM torrents_comments AS tc
WHERE tc.GroupID='".db_string($GroupID)."')/".TORRENT_COMMENTS_PER_PAGE."
) AS Pages");
WHERE tc.GroupID = '".db_string($GroupID)."'
) / ".TORRENT_COMMENTS_PER_PAGE.'
) AS Pages');
list($Pages) = $DB->next_record();
$DB->query("
INSERT INTO torrents_comments (GroupID,AuthorID,AddedTime,Body)
VALUES ('".db_string($GroupID)."', '".db_string($LoggedUser['ID'])."','".sqltime()."','".db_string($_POST['body'])."')");
INSERT INTO torrents_comments
(GroupID, AuthorID, AddedTime, Body)
VALUES
('".db_string($GroupID)."', '".db_string($LoggedUser['ID'])."', '".sqltime()."', '".db_string($_POST['body'])."')");
$PostID = $DB->inserted_id();
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Pages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
$Cache->begin_transaction('torrent_comments_'.$GroupID.'_catalogue_'.$CatalogueID);
$Cache->begin_transaction("torrent_comments_{$GroupID}_catalogue_$CatalogueID");
$Post = array(
'ID'=>$PostID,
'AuthorID'=>$LoggedUser['ID'],
'AddedTime'=>sqltime(),
'Body'=>$_POST['body'],
'EditedUserID'=>0,
'EditedTime'=>'0000-00-00 00:00:00',
'Username'=>''
'ID' => $PostID,
'AuthorID' => $LoggedUser['ID'],
'AddedTime' => sqltime(),
'Body' => $_POST['body'],
'EditedUserID' => 0,
'EditedTime' => '0000-00-00 00:00:00',
'Username' => ''
);
$Cache->insert('', $Post);
$Cache->commit_transaction(0);
$Cache->increment('torrent_comments_'.$GroupID);
$Cache->increment("torrent_comments_$GroupID");
header('Location: torrents.php?id='.$GroupID.'&page='.$Pages);
header("Location: torrents.php?id=$GroupID&page=$Pages");
break;
case 'get_post':
@ -228,7 +231,10 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
if (!$_GET['post'] || !is_number($_GET['post'])) {
error(0);
}
$DB->query("SELECT Body FROM torrents_comments WHERE ID='".db_string($_GET['post'])."'");
$DB->query("
SELECT Body
FROM torrents_comments
WHERE ID = '".db_string($_GET['post'])."'");
list($Body) = $DB->next_record(MYSQLI_NUM);
echo trim($Body);
@ -254,8 +260,8 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
tc.GroupID,
tc.AddedTime
FROM torrents_comments AS tc
WHERE tc.ID='".db_string($_POST['post'])."'");
list($OldBody, $AuthorID,$GroupID,$AddedTime) = $DB->next_record();
WHERE tc.ID = '".db_string($_POST['post'])."'");
list($OldBody, $AuthorID, $GroupID, $AddedTime) = $DB->next_record();
$DB->query("
SELECT ceil(COUNT(ID) / ".TORRENT_COMMENTS_PER_PAGE.") AS Page
@ -278,25 +284,28 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
Body = '".db_string($_POST['body'])."',
EditedUserID = '".db_string($LoggedUser['ID'])."',
EditedTime = '".sqltime()."'
WHERE ID='".db_string($_POST['post'])."'");
WHERE ID = '".db_string($_POST['post'])."'");
// Update the cache
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
$Cache->begin_transaction('torrent_comments_'.$GroupID.'_catalogue_'.$CatalogueID);
$Cache->begin_transaction("torrent_comments_{$GroupID}_catalogue_$CatalogueID");
$Cache->update_row($_POST['key'], array(
'ID'=>$_POST['post'],
'AuthorID'=>$AuthorID,
'AddedTime'=>$AddedTime,
'Body'=>$_POST['body'],
'EditedUserID'=>db_string($LoggedUser['ID']),
'EditedTime'=>sqltime(),
'Username'=>$LoggedUser['Username']
'ID' => $_POST['post'],
'AuthorID' => $AuthorID,
'AddedTime' => $AddedTime,
'Body' => $_POST['body'],
'EditedUserID' => db_string($LoggedUser['ID']),
'EditedTime' => sqltime(),
'Username' => $LoggedUser['Username']
));
$Cache->commit_transaction(0);
$DB->query("INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)
VALUES ('torrents', ".db_string($_POST['post']).", ".db_string($LoggedUser['ID']).", '".sqltime()."', '".db_string($OldBody)."')");
$DB->query("
INSERT INTO comments_edits
(Page, PostID, EditUser, EditTime, Body)
VALUES
('torrents', ".db_string($_POST['post']).", ".db_string($LoggedUser['ID']).", '".sqltime()."', '".db_string($OldBody)."')");
// This gets sent to the browser, which echoes it in place of the old body
echo $Text->full_format($_POST['body']);
@ -317,33 +326,39 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
}
// Get topicid, forumid, number of pages
$DB->query("SELECT
GroupID,
CEIL(COUNT(tc.ID)/".TORRENT_COMMENTS_PER_PAGE.") AS Pages,
CEIL(SUM(IF(tc.ID<=".$_GET['postid'].",1,0))/".TORRENT_COMMENTS_PER_PAGE.") AS Page
$DB->query("
SELECT
GroupID,
CEIL(COUNT(tc.ID) / ".TORRENT_COMMENTS_PER_PAGE.") AS Pages,
CEIL(SUM(IF(tc.ID <= ".$_GET['postid'].", 1, 0)) / ".TORRENT_COMMENTS_PER_PAGE.") AS Page
FROM torrents_comments AS tc
WHERE tc.GroupID=(SELECT GroupID FROM torrents_comments WHERE ID=".$_GET['postid'].")
GROUP BY tc.GroupID");
WHERE tc.GroupID =
(SELECT GroupID
FROM torrents_comments
WHERE ID = ".$_GET['postid'].')
GROUP BY tc.GroupID');
list($GroupID, $Pages, $Page) = $DB->next_record();
// $Pages = number of pages in the thread
// $Page = which page the post is on
// These are set for cache clearing.
$DB->query("DELETE FROM torrents_comments WHERE ID='".db_string($_GET['postid'])."'");
$DB->query("
DELETE FROM torrents_comments
WHERE ID = '".db_string($_GET['postid'])."'");
//We need to clear all subsequential catalogues as they've all been bumped with the absence of this post
$ThisCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
$LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $Pages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
for ($i = $ThisCatalogue; $i <= $LastCatalogue; $i++) {
$Cache->delete_value('torrent_comments_'.$GroupID.'_catalogue_'.$i);
$Cache->delete_value("torrent_comments_{$GroupID}_catalogue_$i");
}
// Delete thread info cache (eg. number of pages)
$Cache->delete_value('torrent_comments_'.$GroupID);
// Delete thread info cache (e.g. number of pages)
$Cache->delete_value("torrent_comments_$GroupID");
break;
case 'regen_filelist' :
case 'regen_filelist':
if (check_perms('users_mod') && !empty($_GET['torrentid']) && is_number($_GET['torrentid'])) {
Torrents::regenerate_filelist($_GET['torrentid']);
header('Location: torrents.php?torrentid='.$_GET['torrentid']);
@ -352,9 +367,12 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
error(403);
}
break;
case 'fix_group' :
case 'fix_group':
if ((check_perms('users_mod') || check_perms('torrents_fix_ghosts')) && authorize() && !empty($_GET['groupid']) && is_number($_GET['groupid'])) {
$DB->query("SELECT COUNT(ID) FROM torrents WHERE GroupID = ".$_GET['groupid']);
$DB->query('
SELECT COUNT(ID)
FROM torrents
WHERE GroupID = '.$_GET['groupid']);
list($Count) = $DB->next_record();
if ($Count == 0) {
Torrents::delete_group($_GET['groupid']);
@ -369,10 +387,10 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
error(403);
}
break;
case 'warn' :
case 'warn':
include(SERVER_ROOT.'/sections/torrents/warn.php');
break;
case 'take_warn' :
case 'take_warn':
include(SERVER_ROOT.'/sections/torrents/take_warn.php');
break;
case 'add_cover_art':
@ -390,10 +408,13 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
if (!empty($_GET['id'])) {
include(SERVER_ROOT.'/sections/torrents/details.php');
} elseif (isset($_GET['torrentid']) && is_number($_GET['torrentid'])) {
$DB->query("SELECT GroupID FROM torrents WHERE ID=".$_GET['torrentid']);
$DB->query('
SELECT GroupID
FROM torrents
WHERE ID = '.$_GET['torrentid']);
list($GroupID) = $DB->next_record();
if ($GroupID) {
header("Location: torrents.php?id=".$GroupID."&torrentid=".$_GET['torrentid']);
header("Location: torrents.php?id=$GroupID&torrentid=".$_GET['torrentid']);
}
} else {
include(SERVER_ROOT.'/sections/torrents/browse2.php');
@ -406,26 +427,31 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
if (!empty($_GET['id'])) {
include(SERVER_ROOT.'/sections/torrents/details.php');
} elseif (isset($_GET['torrentid']) && is_number($_GET['torrentid'])) {
$DB->query("SELECT GroupID FROM torrents WHERE ID=".$_GET['torrentid']);
$DB->query("
SELECT GroupID
FROM torrents
WHERE ID = ".$_GET['torrentid']);
list($GroupID) = $DB->next_record();
if ($GroupID) {
header("Location: torrents.php?id=".$GroupID."&torrentid=".$_GET['torrentid']."#torrent".$_GET['torrentid']);
header("Location: torrents.php?id=$GroupID&torrentid=".$_GET['torrentid'].'#torrent'.$_GET['torrentid']);
} else {
header("Location: log.php?search=Torrent+$_GET[torrentid]");
}
} elseif (!empty($_GET['type'])) {
include(SERVER_ROOT.'/sections/torrents/user.php');
} elseif (!empty($_GET['groupname']) && !empty($_GET['forward'])) {
$DB->query("SELECT ID FROM torrents_group WHERE Name LIKE '".db_string($_GET['groupname'])."'");
$DB->query("
SELECT ID
FROM torrents_group
WHERE Name LIKE '".db_string($_GET['groupname'])."'");
list($GroupID) = $DB->next_record();
if ($GroupID) {
header("Location: torrents.php?id=".$GroupID);
header("Location: torrents.php?id=$GroupID");
} else {
include(SERVER_ROOT.'/sections/torrents/browse2.php');
}
} else {
include(SERVER_ROOT.'/sections/torrents/browse2.php');
}
}
?>

View File

@ -16,7 +16,10 @@
if ($NewGroupID == $GroupID) {
error('Old group ID is the same as new group ID!');
}
$DB->query("SELECT CategoryID, Name FROM torrents_group WHERE ID='$NewGroupID'");
$DB->query("
SELECT CategoryID, Name
FROM torrents_group
WHERE ID = '$NewGroupID'");
if ($DB->record_count() == 0) {
error('Target group does not exist.');
}
@ -25,10 +28,13 @@
error('Only music groups can be merged.');
}
$DB->query("SELECT Name FROM torrents_group WHERE ID = ".$GroupID);
$DB->query("
SELECT Name
FROM torrents_group
WHERE ID = $GroupID");
list($Name) = $DB->next_record();
//Everything is legit, let's just confim they're not retarded
// Everything is legit, let's just confim they're not retarded
if (empty($_POST['confirm'])) {
$Artists = Artists::get_artists(array($GroupID, $NewGroupID));
@ -46,9 +52,13 @@
<input type="hidden" name="groupid" value="<?=$GroupID?>" />
<input type="hidden" name="targetgroupid" value="<?=$NewGroupID?>" />
<h3>You are attempting to merge the group:</h3>
<ul><li><?= Artists::display_artists($Artists[$GroupID], true, false)?> - <a href="torrents.php?id=<?=$GroupID?>"><?=$Name?></a></li></ul>
<ul>
<li><?= Artists::display_artists($Artists[$GroupID], true, false)?> - <a href="torrents.php?id=<?=$GroupID?>"><?=$Name?></a></li>
</ul>
<h3>Into the group:</h3>
<ul><li><?= Artists::display_artists($Artists[$NewGroupID], true, false)?> - <a href="torrents.php?id=<?=$NewGroupID?>"><?=$NewName?></a></li></ul>
<ul>
<li><?= Artists::display_artists($Artists[$NewGroupID], true, false)?> - <a href="torrents.php?id=<?=$NewGroupID?>"><?=$NewName?></a></li>
</ul>
<input type="submit" value="Confirm" />
</form>
</div>
@ -60,78 +70,122 @@
// Votes ninjutsu. This is so annoyingly complicated.
// 1. Get a list of everybody who voted on the old group and clear their cache keys
$DB->query("SELECT UserID FROM users_votes WHERE GroupID='$GroupID'");
$DB->query("
SELECT UserID
FROM users_votes
WHERE GroupID = '$GroupID'");
while (list($UserID) = $DB->next_record()) {
$Cache->delete_value('voted_albums_'.$UserID);
$Cache->delete_value("voted_albums_$UserID");
}
// 2. Update the existing votes where possible, clear out the duplicates left by key
// conflicts, and update the torrents_votes table
$DB->query("UPDATE IGNORE users_votes SET GroupID='$NewGroupID' WHERE GroupID='$GroupID'");
$DB->query("DELETE FROM users_votes WHERE GroupID='$GroupID'");
$DB->query("INSERT INTO torrents_votes (GroupID, Ups, Total, Score)
SELECT $NewGroupID, UpVotes, TotalVotes, VoteScore
FROM (SELECT IFNULL(SUM(IF(Type='Up',1,0)),0) As UpVotes,
COUNT(1) AS TotalVotes,
binomial_ci(IFNULL(SUM(IF(Type='Up',1,0)),0), COUNT(1)) AS VoteScore
FROM users_votes
WHERE GroupID = $NewGroupID
GROUP BY GroupID) AS a
ON DUPLICATE KEY UPDATE
Ups = a.UpVotes,
Total = a.TotalVotes,
Score = a.VoteScore;");
$DB->query("
UPDATE IGNORE users_votes
SET GroupID = '$NewGroupID'
WHERE GroupID = '$GroupID'");
$DB->query("
DELETE FROM users_votes
WHERE GroupID = '$GroupID'");
$DB->query("
INSERT INTO torrents_votes (GroupID, Ups, Total, Score)
SELECT $NewGroupID, UpVotes, TotalVotes, VoteScore
FROM (
SELECT
IFNULL(SUM(IF(Type = 'Up', 1, 0)), 0) As UpVotes,
COUNT(1) AS TotalVotes,
binomial_ci(IFNULL(SUM(IF(Type = 'Up', 1, 0)), 0), COUNT(1)) AS VoteScore
FROM users_votes
WHERE GroupID = $NewGroupID
GROUP BY GroupID
) AS a
ON DUPLICATE KEY UPDATE
Ups = a.UpVotes,
Total = a.TotalVotes,
Score = a.VoteScore;");
// 3. Clear the votes_pairs keys!
$DB->query("SELECT v2.GroupID
FROM users_votes AS v1
INNER JOIN users_votes AS v2 USING (UserID)
WHERE (v1.Type = 'Up' OR v2.Type='Up')
AND (v1.GroupID IN($GroupID, $NewGroupID))
AND (v2.GroupID NOT IN($GroupID, $NewGroupID));");
$DB->query("
SELECT v2.GroupID
FROM users_votes AS v1
INNER JOIN users_votes AS v2 USING (UserID)
WHERE (v1.Type = 'Up' OR v2.Type = 'Up')
AND (v1.GroupID IN($GroupID, $NewGroupID))
AND (v2.GroupID NOT IN($GroupID, $NewGroupID));");
while (list($CacheGroupID) = $DB->next_record()) {
$Cache->delete_value('vote_pairs_'.$CacheGroupID);
$Cache->delete_value("vote_pairs_$CacheGroupID");
}
// 4. Clear the new groups vote keys
$Cache->delete_value('votes_'.$NewGroupID);
$Cache->delete_value("votes_$NewGroupID");
$DB->query("UPDATE torrents SET GroupID='$NewGroupID' WHERE GroupID='$GroupID'");
$DB->query("UPDATE wiki_torrents SET PageID='$NewGroupID' WHERE PageID='$GroupID'");
$DB->query("UPDATE torrents_comments SET GroupID='$NewGroupID' WHERE GroupID='$GroupID'");
$DB->query("
UPDATE torrents
SET GroupID = '$NewGroupID'
WHERE GroupID = '$GroupID'");
$DB->query("
UPDATE wiki_torrents
SET PageID = '$NewGroupID'
WHERE PageID = '$GroupID'");
$DB->query("
UPDATE torrents_comments
SET GroupID = '$NewGroupID'
WHERE GroupID = '$GroupID'");
Torrents::delete_group($GroupID);
Torrents::write_group_log($NewGroupID, 0, $LoggedUser['ID'], "Merged Group ".$GroupID." (".$Name.") to ".$NewGroupID." (".$NewName.")", 0);
$DB->query("UPDATE group_log SET GroupID = ".$NewGroupID." WHERE GroupID = ".$GroupID);
Torrents::write_group_log($NewGroupID, 0, $LoggedUser['ID'], "Merged Group $GroupID ($Name) to $NewGroupID ($NewName)", 0);
$DB->query("
UPDATE group_log
SET GroupID = $NewGroupID
WHERE GroupID = $GroupID");
$GroupID=$NewGroupID;
$GroupID = $NewGroupID;
//Collages
$DB->query("SELECT CollageID FROM collages_torrents WHERE GroupID='$OldGroupID'"); //Select all collages that contain edited group
$DB->query("
SELECT CollageID
FROM collages_torrents
WHERE GroupID = '$OldGroupID'"); // Select all collages that contain edited group
while (list($CollageID) = $DB->next_record()) {
$DB->query("UPDATE IGNORE collages_torrents SET GroupID='$NewGroupID' WHERE GroupID='$OldGroupID' AND CollageID='$CollageID'"); //Change collage groupid to new ID
$DB->query("DELETE FROM collages_torrents WHERE GroupID='$OldGroupID' AND CollageID='$CollageID'");
$Cache->delete_value('collage_'.$CollageID);
$DB->query("
UPDATE IGNORE collages_torrents
SET GroupID = '$NewGroupID'
WHERE GroupID = '$OldGroupID'
AND CollageID = '$CollageID'"); // Change collage group ID to new ID
$DB->query("
DELETE FROM collages_torrents
WHERE GroupID = '$OldGroupID'
AND CollageID = '$CollageID'");
$Cache->delete_value("collage_$CollageID");
}
$Cache->delete_value('torrent_collages_'.$NewGroupID);
$Cache->delete_value('torrent_collages_personal_'.$NewGroupID);
$Cache->delete_value("torrent_collages_$NewGroupID");
$Cache->delete_value("torrent_collages_personal_$NewGroupID");
//Requests
$DB->query("SELECT ID FROM requests WHERE GroupID='$OldGroupID'");
// Requests
$DB->query("
SELECT ID
FROM requests
WHERE GroupID = '$OldGroupID'");
$Requests = $DB->collect('ID');
$DB->query("UPDATE requests SET GroupID = 'NewGroupID' WHERE GroupID = '$OldGroupID'");
$DB->query("
UPDATE requests
SET GroupID = 'NewGroupID'
WHERE GroupID = '$OldGroupID'");
foreach ($Requests as $RequestID) {
$Cache->delete_value('request_'.$RequestID);
$Cache->delete_value("request_$RequestID");
}
$DB->query("SELECT ID FROM torrents WHERE GroupID='$OldGroupID'");
$DB->query("
SELECT ID
FROM torrents
WHERE GroupID = '$OldGroupID'");
while (list($TorrentID) = $DB->next_record()) {
$Cache->delete_value('torrent_download_'.$TorrentID);
$Cache->delete_value("torrent_download_$TorrentID");
}
$Cache->delete_value('torrents_details_'.$GroupID);
$Cache->delete_value('torrent_comments_'.$GroupID.'_catalogue_0');
$Cache->delete_value('torrent_comments_'.$GroupID);
$Cache->delete_value('groups_artists_'.$GroupID);
$Cache->delete_value("torrents_details_$GroupID");
$Cache->delete_value("torrent_comments_{$GroupID}_catalogue_0");
$Cache->delete_value("torrent_comments_$GroupID");
$Cache->delete_value("groups_artists_$GroupID");
Torrents::update_hash($GroupID);
header('Location: torrents.php?id='.$GroupID);
header("Location: torrents.php?id=" . $GroupID);
}
?>

View File

@ -10,7 +10,10 @@
//Usual perm checks
if (!check_perms('torrents_edit')) {
$DB->query("SELECT UserID FROM torrents WHERE GroupID = ".$GroupID);
$DB->query("
SELECT UserID
FROM torrents
WHERE GroupID = $GroupID");
if (!in_array($LoggedUser['ID'], $DB->collect('UserID'))) {
error(403);
}
@ -26,7 +29,7 @@
$Free = 0;
}
if (isset($_POST['freeleechtype']) && in_array($_POST['freeleechtype'], array(0,1,2,3))) {
if (isset($_POST['freeleechtype']) && in_array($_POST['freeleechtype'], array(0, 1, 2, 3))) {
$FreeType = $_POST['freeleechtype'];
} else {
error(404);
@ -41,28 +44,37 @@
$CatalogueNumber = db_string($_POST['catalogue_number']);
// Get some info for the group log
$DB->query("SELECT Year FROM torrents_group WHERE ID = $GroupID");
$DB->query("
SELECT Year
FROM torrents_group
WHERE ID = $GroupID");
list($OldYear) = $DB->next_record();
$DB->query("UPDATE torrents_group SET
Year = '$Year',
RecordLabel = '".$RecordLabel."',
CatalogueNumber = '".$CatalogueNumber."'
WHERE ID = ".$GroupID);
$DB->query("
UPDATE torrents_group
SET
Year = '$Year',
RecordLabel = '".$RecordLabel."',
CatalogueNumber = '".$CatalogueNumber."'
WHERE ID = $GroupID");
if ($OldYear != $Year) {
$DB->query("INSERT INTO group_log (GroupID, UserID, Time, Info)
VALUES ('$GroupID',".$LoggedUser['ID'].",'".sqltime()."','".db_string("Year changed from $OldYear to $Year")."')");
$DB->query("
INSERT INTO group_log (GroupID, UserID, Time, Info)
VALUES ('$GroupID', ".$LoggedUser['ID'].", '".sqltime()."', '".db_string("Year changed from $OldYear to $Year")."')");
}
$DB->query("SELECT ID FROM torrents WHERE GroupID='$GroupID'");
$DB->query("
SELECT ID
FROM torrents
WHERE GroupID = '$GroupID'");
while (list($TorrentID) = $DB->next_record()) {
$Cache->delete_value('torrent_download_'.$TorrentID);
$Cache->delete_value("torrent_download_$TorrentID");
}
Torrents::update_hash($GroupID);
$Cache->delete_value('torrents_details_'.$GroupID);
$Cache->delete_value("torrents_details_$GroupID");
header("Location: torrents.php?id=".$GroupID);
header("Location: torrents.php?id=$GroupID");
?>

View File

@ -12,14 +12,22 @@
error(404);
}
$DB->query("SELECT Image, Summary FROM cover_art WHERE ID = '$ID'");
$DB->query("
SELECT Image, Summary
FROM cover_art
WHERE ID = '$ID'");
list($Image, $Summary) = $DB->next_record();
$DB->query("DELETE FROM cover_art WHERE ID = '$ID'");
$DB->query("
DELETE FROM cover_art
WHERE ID = '$ID'");
$DB->query("INSERT INTO group_log (GroupID, UserID, Time, Info)
VALUES ('$GroupID',".$LoggedUser['ID'].",'".sqltime()."','".db_string('Additional Cover "'.$Summary . ' - ' . $Image .'" removed from group')."')");
$DB->query("
INSERT INTO group_log
(GroupID, UserID, Time, Info)
VALUES
('$GroupID', ".$LoggedUser['ID'].", '".sqltime()."', '".db_string("Additional Cover \"$Summary - $Image\" removed from group")."')");
$Cache->delete_value('torrents_cover_art_' . $GroupID);
$Cache->delete_value("torrents_cover_art_$GroupID");
header('Location: '.$_SERVER['HTTP_REFERER']);
?>

View File

@ -24,51 +24,56 @@
$Subject = 'You have received a warning';
$PrivateMessage = "You have received a $Length week warning for [url=$URL]this post.[/url]\n\n" . $PrivateMessage;
$WarnTime = time_plus($Time);
$AdminComment = date('Y-m-d') . ' - Warned until ' . $WarnTime . ' by ' . $LoggedUser['Username'] . " for $URL \nReason: $Reason\n\n";
$AdminComment = date('Y-m-d') . " - Warned until $WarnTime by " . $LoggedUser['Username'] . " for $URL \nReason: $Reason\n\n";
} else {
$Subject = 'You have received a verbal warning';
$PrivateMessage = "You have received a verbal warning for [url=$URL]this post.[/url]\n\n" . $PrivateMessage;
$AdminComment = date('Y-m-d') . ' - Verbally warned by ' . $LoggedUser['Username'] . " for $URL \nReason: $Reason\n\n";
}
$DB->query("INSERT INTO users_warnings_forums (UserID, Comment)
VALUES('$UserID', '" . db_string($AdminComment) . "')
ON DUPLICATE KEY UPDATE Comment = CONCAT('" . db_string($AdminComment) . "', Comment)");
$DB->query("
INSERT INTO users_warnings_forums (UserID, Comment)
VALUES('$UserID', '" . db_string($AdminComment) . "')
ON DUPLICATE KEY UPDATE Comment = CONCAT('" . db_string($AdminComment) . "', Comment)");
Tools::update_user_notes($UserID, $AdminComment);
Misc::send_pm($UserID, $LoggedUser['ID'], $Subject, $PrivateMessage);
// Mainly
$DB->query("SELECT
tc.Body,
tc.AuthorID,
tc.GroupID,
tc.AddedTime
FROM torrents_comments AS tc
WHERE tc.ID='$PostID'");
$DB->query("
SELECT
tc.Body,
tc.AuthorID,
tc.GroupID,
tc.AddedTime
FROM torrents_comments AS tc
WHERE tc.ID = '$PostID'");
list($OldBody, $AuthorID, $GroupID, $AddedTime) = $DB->next_record();
$DB->query("SELECT ceil(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page
FROM torrents_comments
WHERE GroupID = $GroupID AND ID <= $PostID");
$DB->query("
SELECT ceil(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page
FROM torrents_comments
WHERE GroupID = $GroupID
AND ID <= $PostID");
list($Page) = $DB->next_record();
// Perform the update
$DB->query("UPDATE torrents_comments
SET Body = '" . db_string($Body) . "',
EditedUserID = '" . db_string($LoggedUser['ID']) . "',
EditedTime = '" . sqltime() . "'
WHERE ID='$PostID'");
$DB->query("
UPDATE torrents_comments
SET Body = '" . db_string($Body) . "',
EditedUserID = '" . db_string($LoggedUser['ID']) . "',
EditedTime = '" . sqltime() . "'
WHERE ID = '$PostID'");
// Update the cache
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
$Cache->begin_transaction('torrent_comments_' . $GroupID . '_catalogue_' . $CatalogueID);
$Cache->begin_transaction("torrent_comments_{$GroupID}_catalogue_$CatalogueID");
$Cache->update_row($_POST['key'], array('ID' => $_POST['postid'], 'AuthorID' => $AuthorID, 'AddedTime' => $AddedTime, 'Body' => $Body,
'EditedUserID' => db_string($LoggedUser['ID']), 'EditedTime' => sqltime(), 'Username' => $LoggedUser['Username']));
$Cache->commit_transaction(0);
$DB->query("INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)
VALUES ('torrents', " . db_string($_POST['postid']) . ", " . db_string($LoggedUser['ID']) . ", '" . sqltime() . "', '" . db_string($OldBody) . "')");
$DB->query("
INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)
VALUES ('torrents', " . db_string($_POST['postid']) . ", " . db_string($LoggedUser['ID']) . ", '" . sqltime() . "', '" . db_string($OldBody) . "')");
header("Location: torrents.php?id=$GroupID&postid=$PostID#post$PostID");
?>
;

View File

@ -6,24 +6,25 @@
error(404);
}
if ($Cache->get_value('torrent_'.$TorrentID.'_lock')) {
if ($Cache->get_value("torrent_{$TorrentID}_lock")) {
error('Torrent cannot be deleted because the upload process is not completed yet. Please try again later.');
}
$DB->query("SELECT
t.UserID,
t.GroupID,
t.Size,
t.info_hash,
tg.Name,
ag.Name,
t.Time,
COUNT(x.uid)
$DB->query("
SELECT
t.UserID,
t.GroupID,
t.Size,
t.info_hash,
tg.Name,
ag.Name,
t.Time,
COUNT(x.uid)
FROM torrents AS t
LEFT JOIN torrents_group AS tg ON tg.ID=t.GroupID
LEFT JOIN artists_group AS ag ON ag.ArtistID=tg.ArtistID
LEFT JOIN xbt_snatched AS x ON x.fid=t.ID
WHERE t.ID='$TorrentID'");
LEFT JOIN torrents_group AS tg ON tg.ID = t.GroupID
LEFT JOIN artists_group AS ag ON ag.ArtistID = tg.ArtistID
LEFT JOIN xbt_snatched AS x ON x.fid = t.ID
WHERE t.ID = '$TorrentID'");
list($UserID, $GroupID, $Size, $InfoHash, $Name, $ArtistName, $Time, $Snatches) = $DB->next_record(MYSQLI_NUM, false);
if (($LoggedUser['ID'] != $UserID || time_ago($Time) > 3600 * 24 * 7 || $Snatches > 4) && !check_perms('torrents_delete')) {
@ -31,22 +32,22 @@
}
if ($ArtistName) {
$Name = $ArtistName.' - '.$Name;
$Name = "$ArtistName - $Name";
}
if (isset($_SESSION['logged_user']['multi_delete'])) {
if ($_SESSION['logged_user']['multi_delete'] >= 3 && !check_perms('torrents_delete_fast')) {
error('You have recently deleted 3 torrents, please contact a staff member if you need to delete more.');
error('You have recently deleted 3 torrents. Please contact a staff member if you need to delete more.');
}
$_SESSION['logged_user']['multi_delete']++;
} else {
$_SESSION['logged_user']['multi_delete'] = 1;
}
$InfoHash = unpack("H*", $InfoHash);
$InfoHash = unpack('H*', $InfoHash);
Torrents::delete_torrent($TorrentID, $GroupID);
Misc::write_log('Torrent '.$TorrentID.' ('.$Name.') ('.number_format($Size / (1024 * 1024), 2).' MB) ('.strtoupper($InfoHash[1]).') was deleted by '.$LoggedUser['Username'].': ' .$_POST['reason'].' '.$_POST['extra']);
Torrents::write_group_log($GroupID, $TorrentID, $LoggedUser['ID'], "deleted torrent (".number_format($Size / (1024 * 1024), 2)." MB, ".strtoupper($InfoHash[1]).") for reason: ".$_POST['reason']." ".$_POST['extra'], 0);
Misc::write_log("Torrent $TorrentID ($Name) (".number_format($Size / (1024 * 1024), 2).' MB) ('.strtoupper($InfoHash[1]).') was deleted by '.$LoggedUser['Username'].': ' .$_POST['reason'].' '.$_POST['extra']);
Torrents::write_group_log($GroupID, $TorrentID, $LoggedUser['ID'], 'deleted torrent ('.number_format($Size / (1024 * 1024), 2).' MB, '.strtoupper($InfoHash[1]).') for reason: '.$_POST['reason'].' '.$_POST['extra'], 0);
View::show_header('Torrent deleted');
?>

View File

@ -61,7 +61,7 @@
}
if (check_perms('torrents_freeleech')) {
$Free = (int)$_POST['freeleech'];
if (!in_array($Free, array(0,1,2))) {
if (!in_array($Free, array(0, 1, 2))) {
error(404);
}
$Properties['FreeLeech'] = $Free;
@ -70,7 +70,7 @@
$FreeType = 0;
} else {
$FreeType = (int)$_POST['freeleechtype'];
if (!in_array($Free, array(0,1,2,3))) {
if (!in_array($Free, array(0, 1, 2, 3))) {
error(404);
}
}
@ -80,7 +80,10 @@
//******************************************************************************//
//--------------- Validate data in edit form -----------------------------------//
$DB->query('SELECT UserID, Remastered, RemasterYear, FreeTorrent FROM torrents WHERE ID='.$TorrentID);
$DB->query("
SELECT UserID, Remastered, RemasterYear, FreeTorrent
FROM torrents
WHERE ID = $TorrentID");
if ($DB->record_count() == 0) {
error(404);
}
@ -254,12 +257,15 @@
//--------------- Start database stuff -----------------------------------------//
$DBTorVals = array();
$DB->query("SELECT Media, Format, Encoding, RemasterYear, Remastered, RemasterTItle, RemasterRecordLabel, RemasterCatalogueNumber, Scene, Description FROM torrents WHERE ID = ".$TorrentID);
$DB->query("
SELECT Media, Format, Encoding, RemasterYear, Remastered, RemasterTItle, RemasterRecordLabel, RemasterCatalogueNumber, Scene, Description
FROM torrents
WHERE ID = $TorrentID");
$DBTorVals = $DB->to_array(false, MYSQLI_ASSOC);
$DBTorVals = $DBTorVals[0];
$LogDetails = "";
$LogDetails = '';
foreach ($DBTorVals as $Key => $Value) {
$Value = "'".$Value."'";
$Value = "'$Value'";
if ($Value != $T[$Key]) {
if (!isset($T[$Key])) {
continue;
@ -267,166 +273,245 @@
if ((empty($Value) && empty($T[$Key])) || ($Value == "'0'" && $T[$Key] == "''")) {
continue;
}
if ($LogDetails == "") {
$LogDetails = $Key.": ".$Value." -> ".$T[$Key];
if ($LogDetails == '') {
$LogDetails = "$Key: $Value -> ".$T[$Key];
} else {
$LogDetails = $LogDetails.", ".$Key.": ".$Value." -> ".$T[$Key];
$LogDetails = "$LogDetails, $Key: $Value -> ".$T[$Key];
}
}
}
// Update info for the torrent
$SQL = "
UPDATE torrents SET
Media=$T[Media],
Format=$T[Format],
Encoding=$T[Encoding],
RemasterYear=$T[RemasterYear],
Remastered=$T[Remastered],
RemasterTitle=$T[RemasterTitle],
RemasterRecordLabel=$T[RemasterRecordLabel],
RemasterCatalogueNumber=$T[RemasterCatalogueNumber],
Scene=$T[Scene],
Description=$T[TorrentDescription],";
UPDATE torrents
SET
Media = $T[Media],
Format = $T[Format],
Encoding = $T[Encoding],
RemasterYear = $T[RemasterYear],
Remastered = $T[Remastered],
RemasterTitle = $T[RemasterTitle],
RemasterRecordLabel = $T[RemasterRecordLabel],
RemasterCatalogueNumber = $T[RemasterCatalogueNumber],
Scene = $T[Scene],
Description = $T[TorrentDescription],";
if (check_perms('torrents_freeleech')) {
$SQL .= "FreeTorrent=$T[FreeLeech],";
$SQL .= "FreeLeechType=$T[FreeLeechType],";
$SQL .= "FreeTorrent = $T[FreeLeech],";
$SQL .= "FreeLeechType = $T[FreeLeechType],";
}
if (check_perms('users_mod')) {
if ($T[Format] != "'FLAC'") {
$SQL .= "
HasLog='0',
HasCue='0',
";
HasLog = '0',
HasCue = '0',";
} else {
$SQL .= "
HasLog=$T[HasLog],
HasCue=$T[HasCue],
";
HasLog = $T[HasLog],
HasCue = $T[HasCue],";
}
$DB->query("SELECT TorrentID FROM torrents_bad_tags WHERE TorrentID='$TorrentID'");
$DB->query("
SELECT TorrentID
FROM torrents_bad_tags
WHERE TorrentID = '$TorrentID'");
list($btID) = $DB->next_record();
if (!$btID && $Properties['BadTags']) {
$DB->query("INSERT INTO torrents_bad_tags VALUES($TorrentID, $LoggedUser[ID], '".sqltime()."')");
$DB->query("
INSERT INTO torrents_bad_tags
VALUES ($TorrentID, $LoggedUser[ID], '".sqltime()."')");
}
if ($btID && !$Properties['BadTags']) {
$DB->query("DELETE FROM torrents_bad_tags WHERE TorrentID='$TorrentID'");
$DB->query("
DELETE FROM torrents_bad_tags
WHERE TorrentID = '$TorrentID'");
}
$DB->query("SELECT TorrentID FROM torrents_bad_folders WHERE TorrentID='$TorrentID'");
$DB->query("
SELECT TorrentID
FROM torrents_bad_folders
WHERE TorrentID = '$TorrentID'");
list($bfID) = $DB->next_record();
if (!$bfID && $Properties['BadFolders']) {
$DB->query("INSERT INTO torrents_bad_folders VALUES($TorrentID, $LoggedUser[ID], '".sqltime()."')");
$DB->query("
INSERT INTO torrents_bad_folders
VALUES ($TorrentID, $LoggedUser[ID], '".sqltime()."')");
}
if ($bfID && !$Properties['BadFolders']) {
$DB->query("DELETE FROM torrents_bad_folders WHERE TorrentID='$TorrentID'");
$DB->query("
DELETE FROM torrents_bad_folders
WHERE TorrentID = '$TorrentID'");
}
$DB->query("SELECT TorrentID FROM torrents_bad_files WHERE TorrentID='$TorrentID'");
$DB->query("
SELECT TorrentID
FROM torrents_bad_files
WHERE TorrentID = '$TorrentID'");
list($bfiID) = $DB->next_record();
if (!$bfiID && $Properties['BadFiles']) {
$DB->query("INSERT INTO torrents_bad_files VALUES($TorrentID, $LoggedUser[ID], '".sqltime()."')");
$DB->query("
INSERT INTO torrents_bad_files
VALUES ($TorrentID, $LoggedUser[ID], '".sqltime()."')");
}
if ($bfiID && !$Properties['BadFiles']) {
$DB->query("DELETE FROM torrents_bad_files WHERE TorrentID='$TorrentID'");
$DB->query("
DELETE FROM torrents_bad_files
WHERE TorrentID = '$TorrentID'");
}
$DB->query("SELECT TorrentID FROM library_contest WHERE TorrentID='$TorrentID'");
$DB->query("
SELECT TorrentID
FROM library_contest
WHERE TorrentID = '$TorrentID'");
list($lbID) = $DB->next_record();
if (!$lbID && $Properties['LibraryUpload'] && $Properties['LibraryPoints'] > 0) {
$DB->query("SELECT UserID FROM torrents WHERE ID = ".$TorrentID);
$DB->query("
SELECT UserID
FROM torrents
WHERE ID = $TorrentID");
list($UploaderID) = $DB->next_record();
$DB->query("INSERT INTO library_contest VALUES ($UploaderID, $TorrentID, $Properties[LibraryPoints])");
$DB->query("
INSERT INTO library_contest
VALUES ($UploaderID, $TorrentID, $Properties[LibraryPoints])");
}
if ($lbID && !$Properties['LibraryUpload']) {
$DB->query("DELETE FROM library_contest WHERE TorrentID='$TorrentID'");
$DB->query("
DELETE FROM library_contest
WHERE TorrentID = '$TorrentID'");
}
$DB->query("SELECT TorrentID FROM torrents_cassette_approved WHERE TorrentID='$TorrentID'");
$DB->query("
SELECT TorrentID
FROM torrents_cassette_approved
WHERE TorrentID = '$TorrentID'");
list($caID) = $DB->next_record();
if (!$caID && $Properties['CassetteApproved']) {
$DB->query("INSERT INTO torrents_cassette_approved VALUES($TorrentID, $LoggedUser[ID], '".sqltime()."')");
$DB->query("
INSERT INTO torrents_cassette_approved
VALUES ($TorrentID, $LoggedUser[ID], '".sqltime()."')");
}
if ($caID && !$Properties['CassetteApproved']) {
$DB->query("DELETE FROM torrents_cassette_approved WHERE TorrentID='$TorrentID'");
$DB->query("
DELETE FROM torrents_cassette_approved
WHERE TorrentID = '$TorrentID'");
}
$DB->query("SELECT TorrentID FROM torrents_lossymaster_approved WHERE TorrentID='$TorrentID'");
$DB->query("
SELECT TorrentID
FROM torrents_lossymaster_approved
WHERE TorrentID = '$TorrentID'");
list($lmaID) = $DB->next_record();
if (!$lmaID && $Properties['LossymasterApproved']) {
$DB->query("INSERT INTO torrents_lossymaster_approved VALUES($TorrentID, $LoggedUser[ID], '".sqltime()."')");
$DB->query("
INSERT INTO torrents_lossymaster_approved
VALUES ($TorrentID, $LoggedUser[ID], '".sqltime()."')");
}
if ($lmaID && !$Properties['LossymasterApproved']) {
$DB->query("DELETE FROM torrents_lossymaster_approved WHERE TorrentID='$TorrentID'");
$DB->query("
DELETE FROM torrents_lossymaster_approved
WHERE TorrentID = '$TorrentID'");
}
$DB->query("SELECT TorrentID FROM torrents_lossyweb_approved WHERE TorrentID='$TorrentID'");
$DB->query("
SELECT TorrentID
FROM torrents_lossyweb_approved
WHERE TorrentID = '$TorrentID'");
list($lwID) = $DB->next_record();
if (!$lwID && $Properties['LossywebApproved']) {
$DB->query("INSERT INTO torrents_lossyweb_approved VALUES($TorrentID, $LoggedUser[ID], '".sqltime()."')");
$DB->query("
INSERT INTO torrents_lossyweb_approved
VALUES ($TorrentID, $LoggedUser[ID], '".sqltime()."')");
}
if ($lwID && !$Properties['LossywebApproved']) {
$DB->query("DELETE FROM torrents_lossyweb_approved WHERE TorrentID='$TorrentID'");
$DB->query("
DELETE FROM torrents_lossyweb_approved
WHERE TorrentID = '$TorrentID'");
}
}
$SQL .= "
flags='2'
WHERE ID=$TorrentID
";
flags = '2'
WHERE ID = $TorrentID";
$DB->query($SQL);
if (check_perms('torrents_freeleech') && $Properties['FreeLeech'] != $CurFreeLeech) {
Torrents::freeleech_torrents($TorrentID, $Properties['FreeLeech'], $Properties['FreeLeechType']);
}
$DB->query("SELECT GroupID, Time FROM torrents WHERE ID='$TorrentID'");
$DB->query("
SELECT GroupID, Time
FROM torrents
WHERE ID = '$TorrentID'");
list($GroupID, $Time) = $DB->next_record();
// Competition
if (strtotime($Time)>1241352173) {
if (strtotime($Time) > 1241352173) {
if ($_POST['log_score'] == '100') {
$DB->query("INSERT IGNORE into users_points (GroupID, UserID, Points) VALUES ('$GroupID', '$UserID', '1')");
$DB->query("
INSERT IGNORE into users_points (GroupID, UserID, Points)
VALUES ('$GroupID', '$UserID', '1')");
}
}
// End competiton
$DB->query("SELECT LogScore FROM torrents WHERE ID = ".$TorrentID);
$DB->query("
SELECT LogScore
FROM torrents
WHERE ID = $TorrentID");
list($LogScore) = $DB->next_record();
if ($Properties['Trumpable'] == 1 && $LogScore == 100) {
$DB->query("UPDATE torrents SET LogScore = 99 WHERE ID = ".$TorrentID);
$DB->query("
UPDATE torrents
SET LogScore = 99
WHERE ID = $TorrentID");
$Results = array();
$Results[] = "The original uploader has chosen to allow this log to be deducted one point for using EAC v0.95., -1 point [1]";
$Results[] = 'The original uploader has chosen to allow this log to be deducted one point for using EAC v0.95., -1 point [1]';
$Details = db_string(serialize($Results));
$DB->query("UPDATE torrents_logs_new SET Score = 99, Details = '".$Details."' WHERE TorrentID = ".$TorrentID);
$DB->query("
UPDATE torrents_logs_new
SET Score = 99, Details = '$Details'
WHERE TorrentID = $TorrentID");
}
$DB->query("SELECT Enabled FROM users_main WHERE ID =".$UserID);
$DB->query("
SELECT Enabled
FROM users_main
WHERE ID = $UserID");
list($Enabled) = $DB->next_record();
if ($Properties['Trumpable'] == 0 && $LogScore == 99 && $Enabled == 1 && strtotime($Time) < 1284422400) {
$DB->query("SELECT Log FROM torrents_logs_new WHERE TorrentID = ".$TorrentID);
$DB->query("
SELECT Log
FROM torrents_logs_new
WHERE TorrentID = $TorrentID");
list($Log) = $DB->next_record();
if (strpos($Log, "EAC extraction") === 0) {
$DB->query("UPDATE torrents SET LogScore = 100 WHERE ID = ".$TorrentID);
$DB->query("UPDATE torrents_logs_new SET Score = 100, Details = '' WHERE TorrentID = ".$TorrentID);
if (strpos($Log, 'EAC extraction') === 0) {
$DB->query("
UPDATE torrents
SET LogScore = 100
WHERE ID = $TorrentID");
$DB->query("
UPDATE torrents_logs_new
SET Score = 100, Details = ''
WHERE TorrentID = $TorrentID");
}
}
$DB->query("SELECT Name FROM torrents_group WHERE ID=$GroupID");
$DB->query("
SELECT Name
FROM torrents_group
WHERE ID = $GroupID");
list($Name) = $DB->next_record(MYSQLI_NUM, false);
Misc::write_log("Torrent $TorrentID ($Name) in group $GroupID was edited by ".$LoggedUser['Username']." (".$LogDetails.")"); // TODO: this is probably broken
Misc::write_log("Torrent $TorrentID ($Name) in group $GroupID was edited by ".$LoggedUser['Username']." ($LogDetails)"); // TODO: this is probably broken
Torrents::write_group_log($GroupID, $TorrentID, $LoggedUser['ID'], $LogDetails, 0);
$Cache->delete_value('torrents_details_'.$GroupID);
$Cache->delete_value('torrent_download_'.$TorrentID);
$Cache->delete_value("torrents_details_$GroupID");
$Cache->delete_value("torrent_download_$TorrentID");
Torrents::update_hash($GroupID);
// All done!

View File

@ -26,10 +26,10 @@
error(403);
}
$Validate->SetFields('torrentid','1','number','Invalid torrent ID.',array('maxlength'=>1000000000, 'minlength'=>1)); // we shouldn't have torrent IDs higher than a billion
$Validate->SetFields('groupid','1','number','Invalid group ID.',array('maxlength'=>1000000000, 'minlength'=>1)); // we shouldn't have group IDs higher than a billion either
$Validate->SetFields('subject','0','string','Invalid subject.',array('maxlength'=>1000, 'minlength'=>1));
$Validate->SetFields('message','0','string','Invalid message.',array('maxlength'=>10000, 'minlength'=>1));
$Validate->SetFields('torrentid', '1', 'number', 'Invalid torrent ID.', array('maxlength' => 1000000000, 'minlength' => 1)); // we shouldn't have torrent IDs higher than a billion
$Validate->SetFields('groupid', '1', 'number', 'Invalid group ID.', array('maxlength' => 1000000000, 'minlength' => 1)); // we shouldn't have group IDs higher than a billion either
$Validate->SetFields('subject', '0', 'string', 'Invalid subject.', array('maxlength' => 1000, 'minlength' => 1));
$Validate->SetFields('message', '0', 'string', 'Invalid message.', array('maxlength' => 10000, 'minlength' => 1));
$Err = $Validate->ValidateForm($_POST); // Validate the form
if ($Err) {
@ -41,7 +41,10 @@
//******************************************************************************//
//--------------- Send PMs to users --------------------------------------------//
$DB->query('SELECT uid FROM xbt_snatched WHERE fid='.$TorrentID);
$DB->query("
SELECT uid
FROM xbt_snatched
WHERE fid = $TorrentID");
if ($DB->record_count() > 0) {
// Save this because send_pm uses $DB to run its own query... Oops...

View File

@ -48,12 +48,19 @@
<?
View::show_footer();
} else {
$DB->query("SELECT ArtistID, AliasID, Redirect, Name FROM artists_alias WHERE Name = '$ArtistName'");
$DB->query("
SELECT ArtistID, AliasID, Redirect, Name
FROM artists_alias
WHERE Name = '$ArtistName'");
if ($DB->record_count() == 0) {
$Redirect = 0;
$DB->query("INSERT INTO artists_group (Name) VALUES ('$ArtistName')");
$DB->query("
INSERT INTO artists_group (Name)
VALUES ('$ArtistName')");
$ArtistID = $DB->inserted_id();
$DB->query("INSERT INTO artists_alias (ArtistID, Name) VALUES ('$ArtistID', '$ArtistName')");
$DB->query("
INSERT INTO artists_alias (ArtistID, Name)
VALUES ('$ArtistID', '$ArtistName')");
$AliasID = $DB->inserted_id();
} else {
list($ArtistID, $AliasID, $Redirect, $ArtistName) = $DB->next_record();
@ -62,22 +69,29 @@
}
}
$DB->query("INSERT INTO torrents_group
(ArtistID, NumArtists, CategoryID, Name, Year, Time, WikiBody, WikiImage, SearchText)
$DB->query("
INSERT INTO torrents_group
(ArtistID, NumArtists, CategoryID, Name, Year, Time, WikiBody, WikiImage, SearchText)
VALUES
($ArtistID, '1', '1', '$Title', '$Year', '".sqltime()."', '', '', '$SearchText')");
($ArtistID, '1', '1', '$Title', '$Year', '".sqltime()."', '', '', '$SearchText')");
$GroupID = $DB->inserted_id();
$DB->query("INSERT INTO torrents_artists
(GroupID, ArtistID, AliasID, Importance, UserID) VALUES
('$GroupID', '$ArtistID', '$AliasID', '1', '$LoggedUser[ID]')");
$DB->query("
INSERT INTO torrents_artists
(GroupID, ArtistID, AliasID, Importance, UserID)
VALUES
('$GroupID', '$ArtistID', '$AliasID', '1', '$LoggedUser[ID]')");
$DB->query("UPDATE torrents SET
GroupID='$GroupID'
WHERE ID='$TorrentID'");
$DB->query("
UPDATE torrents
SET GroupID = '$GroupID'
WHERE ID = '$TorrentID'");
// Delete old group if needed
$DB->query("SELECT ID FROM torrents WHERE GroupID='$OldGroupID'");
$DB->query("
SELECT ID
FROM torrents
WHERE GroupID = '$OldGroupID'");
if ($DB->record_count() == 0) {
Torrents::delete_group($OldGroupID);
} else {
@ -86,7 +100,7 @@
Torrents::update_hash($GroupID);
$Cache->delete_value('torrent_download_'.$TorrentID);
$Cache->delete_value("torrent_download_$TorrentID");
Misc::write_log("Torrent $TorrentID was edited by " . $LoggedUser['Username']);

View File

@ -42,16 +42,24 @@
$ThisInsert['TotalSize'] = $ExtraTotalSize;
$Debug->set_flag('upload: torrent decoded');
$DB->query("SELECT ID FROM torrents WHERE info_hash='" . db_string($ThisInsert['InfoHash']) . "'");
$DB->query("
SELECT ID
FROM torrents
WHERE info_hash = '" . db_string($ThisInsert['InfoHash']) . "'");
if ($DB->record_count() > 0) {
list($ExtraID) = $DB->next_record();
$DB->query('SELECT TorrentID FROM torrents_files WHERE TorrentID = ' . $ExtraID);
$DB->query("
SELECT TorrentID
FROM torrents_files
WHERE TorrentID = $ExtraID");
if ($DB->record_count() > 0) {
$Err = '<a href="torrents.php?torrentid=' . $ExtraID . '">The exact same torrent file already exists on the site!</a>';
$Err = "<a href=\"torrents.php?torrentid=$ExtraID\">The exact same torrent file already exists on the site!</a>";
} else {
//One of the lost torrents.
$DB->query("INSERT INTO torrents_files (TorrentID, File) VALUES ($ExtraID, '$ThisInsert[TorEnc]')");
$Err = "<a href=\"torrents.php?torrentid=$ExtraID\">Thank you for fixing this torrent</a>";
$DB->query("
INSERT INTO torrents_files (TorrentID, File)
VALUES ($ExtraID, '$ThisInsert[TorEnc]')");
$Err = "<a href=\"torrents.php?torrentid=$ExtraID\">Thank you for fixing this torrent.</a>";
}
}
}

View File

@ -9,8 +9,8 @@
// called again. //
//**********************************************************************//
ini_set('max_file_uploads','100');
View::show_header('Upload','upload,validate_upload,valid_tags,musicbrainz,multiformat_uploader');
ini_set('max_file_uploads', '100');
View::show_header('Upload', 'upload,validate_upload,valid_tags,musicbrainz,multiformat_uploader');
if (empty($Properties) && !empty($_GET['groupid']) && is_number($_GET['groupid'])) {
$DB->query('
@ -27,7 +27,7 @@
tg.VanityHouse
FROM torrents_group AS tg
LEFT JOIN torrents AS t ON t.GroupID = tg.ID
WHERE tg.ID='.$_GET['groupid'].'
WHERE tg.ID = '.$_GET['groupid'].'
GROUP BY tg.ID');
if ($DB->record_count()) {
list($Properties) = $DB->to_array(false, MYSQLI_BOTH);
@ -39,8 +39,8 @@
SELECT
GROUP_CONCAT(tags.Name SEPARATOR ', ') AS TagList
FROM torrents_tags AS tt
JOIN tags ON tags.ID=tt.TagID
WHERE tt.GroupID='$_GET[groupid]'");
JOIN tags ON tags.ID = tt.TagID
WHERE tt.GroupID = '$_GET[groupid]'");
list($Properties['TagList']) = $DB->next_record();
} else {
@ -61,9 +61,9 @@
r.ReleaseType,
r.Image
FROM requests AS r
WHERE r.ID='.$_GET['requestid']);
WHERE r.ID = '.$_GET['requestid']);
list($Properties) = $DB->to_array(false,MYSQLI_BOTH);
list($Properties) = $DB->to_array(false, MYSQLI_BOTH);
$UploadForm = $Categories[$Properties['CategoryID'] - 1];
$Properties['CategoryName'] = $Categories[$Properties['CategoryID'] - 1];
$Properties['Artists'] = Requests::get_artists($_GET['requestid']);
@ -84,7 +84,11 @@
$GenreTags = $Cache->get_value('genre_tags');
if (!$GenreTags) {
$DB->query("SELECT Name FROM tags WHERE TagType='genre' ORDER BY Name");
$DB->query("
SELECT Name
FROM tags
WHERE TagType = 'genre'
ORDER BY Name");
$GenreTags = $DB->collect('Name');
$Cache->cache_value('genre_tags', $GenreTags, 3600 * 6);
}
@ -100,7 +104,7 @@
list($Name, $Comment, $Updated) = reset($DNU);
reset($DNU);
$DB->query("
SELECT IF(MAX(t.Time) < '$Updated' OR MAX(t.Time) IS NULL,1,0)
SELECT IF(MAX(t.Time) < '$Updated' OR MAX(t.Time) IS NULL, 1, 0)
FROM torrents AS t
WHERE UserID = ".$LoggedUser['ID']);
list($NewDNU) = $DB->next_record();
@ -110,9 +114,9 @@
<h3 id="dnu_header">Do not upload</h3>
<p><?=$NewDNU ? '<strong class="important_text">' : '' ?>Last updated: <?=time_diff($Updated)?><?=$NewDNU ? '</strong>' : '' ?></p>
<p>The following releases are currently forbidden from being uploaded to the site. Do not upload them unless your torrent meets a condition specified in the comment.
<? if ($HideDNU) { ?>
<? if ($HideDNU) { ?>
<span id="showdnu"><a href="#" onclick="$('#dnulist').gtoggle(); this.innerHTML = (this.innerHTML == 'Hide' ? 'Show' : 'Hide'); return false;" class="brackets">Show</a></span>
<? } ?>
<? } ?>
</p>
<table id="dnulist" class="<?=($HideDNU ? 'hidden' : '')?>">
<tr class="colhead">

View File

@ -581,7 +581,7 @@
foreach ($Artists as $Num => $Artist) {
$DB->query("
INSERT IGNORE INTO torrents_artists (GroupID, ArtistID, AliasID, UserID, Importance)
VALUES ($GroupID, ".$Artist['id'].", ".$Artist['aliasid'].", ".$LoggedUser['ID'].", '$Importance')");
VALUES ($GroupID, ".$Artist['id'].', '.$Artist['aliasid'].', '.$LoggedUser['ID'].", '$Importance')");
$Cache->increment('stats_album_count');
}
}
@ -591,13 +591,16 @@
} else {
$DB->query("
UPDATE torrents_group
SET Time='".sqltime()."'
WHERE ID=$GroupID");
$Cache->delete_value('torrent_group_'.$GroupID);
$Cache->delete_value('torrents_details_'.$GroupID);
$Cache->delete_value('detail_files_'.$GroupID);
SET Time = '".sqltime()."'
WHERE ID = $GroupID");
$Cache->delete_value("torrent_group_$GroupID");
$Cache->delete_value("torrents_details_$GroupID");
$Cache->delete_value("detail_files_$GroupID");
if ($Type == 'Music') {
$DB->query("SELECT ReleaseType FROM torrents_group WHERE ID='$GroupID'");
$DB->query("
SELECT ReleaseType
FROM torrents_group
WHERE ID = '$GroupID'");
list($Properties['ReleaseType']) = $DB->next_record();
}
}
@ -614,8 +617,8 @@
// Revision ID
$DB->query("
UPDATE torrents_group
SET RevisionID='$RevisionID'
WHERE ID=$GroupID");
SET RevisionID = '$RevisionID'
WHERE ID = $GroupID");
}
// Tags
@ -630,7 +633,7 @@
(Name, UserID)
VALUES
('$Tag', $LoggedUser[ID])
ON DUPLICATE KEY UPDATE Uses=Uses+1;
ON DUPLICATE KEY UPDATE Uses = Uses + 1;
");
$TagID = $DB->inserted_id();
@ -639,7 +642,7 @@
(TagID, GroupID, UserID, PositiveVotes)
VALUES
($TagID, $GroupID, $LoggedUser[ID], 10)
ON DUPLICATE KEY UPDATE PositiveVotes=PositiveVotes+1;
ON DUPLICATE KEY UPDATE PositiveVotes = PositiveVotes + 1;
");
}
}
@ -654,8 +657,8 @@
INSERT INTO torrents
(GroupID, UserID, Media, Format, Encoding,
Remastered, RemasterYear, RemasterTitle, RemasterRecordLabel, RemasterCatalogueNumber,
Scene, HasLog, HasCue, info_hash, FileCount, FileList, FilePath, Size, Time,
Description, LogScore, FreeTorrent, FreeLeechType)
Scene, HasLog, HasCue, info_hash, FileCount, FileList, FilePath,
Size, Time, Description, LogScore, FreeTorrent, FreeLeechType)
VALUES
($GroupID, $LoggedUser[ID], $T[Media], $T[Format], $T[Encoding], " .
"$T[Remastered], $T[RemasterYear], $T[RemasterTitle], $T[RemasterRecordLabel], $T[RemasterCatalogueNumber], " .
@ -670,7 +673,7 @@
// Prevent deletion of this torrent until the rest of the upload process is done
// (expire the key after 10 minutes to prevent locking it for too long in case there's a fatal error below)
$Cache->cache_value('torrent_'.$TorrentID.'_lock', true, 600);
$Cache->cache_value("torrent_{$TorrentID}_lock", true, 600);
//******************************************************************************//
//--------------- Write torrent file -------------------------------------------//
@ -678,7 +681,7 @@
$DB->query("
INSERT INTO torrents_files (TorrentID, File)
VALUES ($TorrentID, '$TorEnc')");
Misc::write_log("Torrent $TorrentID ($LogName) (".number_format($TotalSize / (1024 * 1024), 2)." MB) was uploaded by " . $LoggedUser['Username']);
Misc::write_log("Torrent $TorrentID ($LogName) (".number_format($TotalSize / (1024 * 1024), 2).' MB) was uploaded by ' . $LoggedUser['Username']);
Torrents::write_group_log($GroupID, $TorrentID, $LoggedUser['ID'], 'uploaded ('.number_format($TotalSize / (1024 * 1024), 2).' MB)', 0);
Torrents::update_hash($GroupID);
@ -722,8 +725,8 @@
if (count($RecentUploads) == 5) {
array_pop($RecentUploads);
}
array_unshift($RecentUploads, array('ID'=>$GroupID, 'Name'=>trim($Properties['Title']), 'Artist'=>Artists::display_artists($ArtistForm, false, true), 'WikiImage'=>trim($Properties['Image'])));
$Cache->cache_value('recent_uploads_'.$UserID, $RecentUploads, 0);
array_unshift($RecentUploads, array('ID' => $GroupID, 'Name' => trim($Properties['Title']), 'Artist' => Artists::display_artists($ArtistForm, false, true), 'WikiImage' => trim($Properties['Image'])));
$Cache->cache_value("recent_uploads_$UserID", $RecentUploads, 0);
} while (0);
}
}
@ -732,8 +735,10 @@
//--------------- Contest ------------------------------------------------------//
if ($Properties['LibraryImage'] != '') {
$DB->query("
INSERT INTO reportsv2 (ReporterID, TorrentID, Type, UserComment, Status, ReportedTime, Track, Image, ExtraID, Link)
VALUES (0, $TorrentID, 'library', '".db_string(($Properties['MultiDisc'] ? 'Multi-disc' : ''))."', 'New', '".sqltime()."', '', '".db_string($Properties['LibraryImage'])."', '', '')");
INSERT INTO reportsv2
(ReporterID, TorrentID, Type, UserComment, Status, ReportedTime, Track, Image, ExtraID, Link)
VALUES
(0, $TorrentID, 'library', '".db_string(($Properties['MultiDisc'] ? 'Multi-disc' : ''))."', 'New', '".sqltime()."', '', '".db_string($Properties['LibraryImage'])."', '', '')");
}
//******************************************************************************//
@ -778,7 +783,7 @@
$Announce .= ' ['.$ReleaseTypes[$Properties['ReleaseType']].']';
}
$Announce .= ' - ';
$Announce .= trim($Properties['Format'])." / ".trim($Properties['Bitrate']);
$Announce .= trim($Properties['Format']).' / '.trim($Properties['Bitrate']);
if ($HasLog == 1) {
$Announce .= ' / Log';
}
@ -798,7 +803,7 @@
}
$Title = $Announce;
$AnnounceSSL = $Announce . " - https://".SSL_SITE_URL."/torrents.php?id=$GroupID / https://".SSL_SITE_URL."/torrents.php?action=download&id=$TorrentID";
$AnnounceSSL = "$Announce - https://".SSL_SITE_URL."/torrents.php?id=$GroupID / https://".SSL_SITE_URL."/torrents.php?action=download&id=$TorrentID";
$Announce .= " - https://".SSL_SITE_URL."/torrents.php?id=$GroupID / https://".SSL_SITE_URL."/torrents.php?action=download&id=$TorrentID";
$AnnounceSSL .= ' - '.trim($Properties['TagList']);
@ -844,8 +849,8 @@
$SQL = "
SELECT unf.ID, unf.UserID, torrent_pass
FROM users_notify_filters AS unf
JOIN users_main AS um ON um.ID=unf.UserID
WHERE um.Enabled='1'";
JOIN users_main AS um ON um.ID = unf.UserID
WHERE um.Enabled = '1'";
if (empty($ArtistsUnescaped)) {
$ArtistsUnescaped = $ArtistForm;
}
@ -855,50 +860,49 @@
foreach ($ArtistsUnescaped as $Importance => $Artists) {
foreach ($Artists as $Artist) {
if ($Importance == 1 || $Importance == 4 || $Importance == 5 || $Importance == 6) {
$ArtistNameList[] = "Artists LIKE '%|".db_string(str_replace('\\','\\\\',$Artist['name']), true)."|%'";
$ArtistNameList[] = "Artists LIKE '%|".db_string(str_replace('\\', '\\\\', $Artist['name']), true)."|%'";
} else {
$GuestArtistNameList[] = "Artists LIKE '%|".db_string(str_replace('\\','\\\\',$Artist['name']), true)."|%'";
$GuestArtistNameList[] = "Artists LIKE '%|".db_string(str_replace('\\', '\\\\', $Artist['name']), true)."|%'";
}
}
}
// Don't add notification if >2 main artists or if tracked artist isn't a main artist
if (count($ArtistNameList) > 2 || $Artist['name'] == 'Various Artists') {
$SQL.= " AND (ExcludeVA='0' AND (";
$SQL.= implode(" OR ", array_merge($ArtistNameList,$GuestArtistNameList));
$SQL.= " OR Artists='')) AND (";
$SQL .= " AND (ExcludeVA = '0' AND (";
$SQL .= implode(' OR ', array_merge($ArtistNameList, $GuestArtistNameList));
$SQL .= " OR Artists = '')) AND (";
} else {
$SQL.= " AND (";
$SQL .= " AND (";
if (!empty($GuestArtistNameList)) {
$SQL.= "(ExcludeVA='0' AND (";
$SQL.= implode(" OR ", $GuestArtistNameList);
$SQL.= ")) OR ";
$SQL .= "(ExcludeVA = '0' AND (";
$SQL .= implode(' OR ', $GuestArtistNameList);
$SQL .= ')) OR ';
}
$SQL.= implode(" OR ", $ArtistNameList);
$SQL.= " OR Artists='') AND (";
$SQL .= implode(' OR ', $ArtistNameList);
$SQL .= " OR Artists = '') AND (";
}
} else {
$SQL.="AND (Artists='') AND (";
$SQL .= "AND (Artists = '') AND (";
}
reset($Tags);
$TagSQL = array();
$NotTagSQL = array();
foreach ($Tags as $Tag) {
$TagSQL[]=" Tags LIKE '%|".db_string(trim($Tag))."|%' ";
$NotTagSQL[]=" NotTags LIKE '%|".db_string(trim($Tag))."|%' ";
$TagSQL[] = " Tags LIKE '%|".db_string(trim($Tag))."|%' ";
$NotTagSQL[] = " NotTags LIKE '%|".db_string(trim($Tag))."|%' ";
}
$TagSQL[]="Tags=''";
$SQL.=implode(' OR ', $TagSQL);
$TagSQL[] = "Tags = ''";
$SQL .= implode(' OR ', $TagSQL);
$SQL.= ") AND !(".implode(' OR ', $NotTagSQL).")";
$SQL .= ") AND !(".implode(' OR ', $NotTagSQL).')';
$SQL.=" AND (Categories LIKE '%|".db_string(trim($Type))."|%' OR Categories='') ";
$SQL .= " AND (Categories LIKE '%|".db_string(trim($Type))."|%' OR Categories = '') ";
if ($Properties['ReleaseType']) {
$SQL.=" AND (ReleaseTypes LIKE '%|".db_string(trim($ReleaseTypes[$Properties['ReleaseType']]))."|%' OR ReleaseTypes='') ";
$SQL .= " AND (ReleaseTypes LIKE '%|".db_string(trim($ReleaseTypes[$Properties['ReleaseType']]))."|%' OR ReleaseTypes = '') ";
} else {
$SQL.=" AND (ReleaseTypes='') ";
$SQL .= " AND (ReleaseTypes = '') ";
}
/*
@ -909,21 +913,21 @@
if ($Properties['Format']) {
$SQL.=" AND (Formats LIKE '%|".db_string(trim($Properties['Format']))."|%' OR Formats='') ";
$SQL .= " AND (Formats LIKE '%|".db_string(trim($Properties['Format']))."|%' OR Formats = '') ";
} else {
$SQL.=" AND (Formats='') ";
$SQL .= " AND (Formats = '') ";
}
if ($_POST['bitrate']) {
$SQL.=" AND (Encodings LIKE '%|".db_string(trim($_POST['bitrate']))."|%' OR Encodings='') ";
$SQL .= " AND (Encodings LIKE '%|".db_string(trim($_POST['bitrate']))."|%' OR Encodings = '') ";
} else {
$SQL.=" AND (Encodings='') ";
$SQL .= " AND (Encodings = '') ";
}
if ($Properties['Media']) {
$SQL.=" AND (Media LIKE '%|".db_string(trim($Properties['Media']))."|%' OR Media='') ";
$SQL .= " AND (Media LIKE '%|".db_string(trim($Properties['Media']))."|%' OR Media = '') ";
} else {
$SQL.=" AND (Media='') ";
$SQL .= " AND (Media = '') ";
}
// Either they aren't using NewGroupsOnly
@ -941,28 +945,31 @@
if ($Properties['Year'] && $Properties['RemasterYear']) {
$SQL.=" AND (('".db_string(trim($Properties['Year']))."' BETWEEN FromYear AND ToYear)
$SQL .= " AND (('".db_string(trim($Properties['Year']))."' BETWEEN FromYear AND ToYear)
OR ('".db_string(trim($Properties['RemasterYear']))."' BETWEEN FromYear AND ToYear)
OR (FromYear=0 AND ToYear=0)) ";
OR (FromYear = 0 AND ToYear = 0)) ";
} elseif ($Properties['Year'] || $Properties['RemasterYear']) {
$SQL.=" AND (('".db_string(trim(Max($Properties['Year'],$Properties['RemasterYear'])))."' BETWEEN FromYear AND ToYear)
OR (FromYear=0 AND ToYear=0)) ";
$SQL .= " AND (('".db_string(trim(Max($Properties['Year'],$Properties['RemasterYear'])))."' BETWEEN FromYear AND ToYear)
OR (FromYear = 0 AND ToYear = 0)) ";
} else {
$SQL.=" AND (FromYear=0 AND ToYear=0) ";
$SQL .= " AND (FromYear = 0 AND ToYear = 0) ";
}
$SQL.=" AND UserID != '".$LoggedUser['ID']."' ";
$SQL .= " AND UserID != '".$LoggedUser['ID']."' ";
$DB->query("SELECT Paranoia FROM users_main WHERE ID = $LoggedUser[ID]");
$DB->query("
SELECT Paranoia
FROM users_main
WHERE ID = $LoggedUser[ID]");
list($Paranoia) = $DB->next_record();
$Paranoia = unserialize($Paranoia);
if (!is_array($Paranoia)) {
$Paranoia = array();
}
if (!in_array('notifications', $Paranoia)) {
$SQL.=" AND (Users LIKE '%|".$LoggedUser['ID']."|%' OR Users = '') ";
$SQL .= " AND (Users LIKE '%|".$LoggedUser['ID']."|%' OR Users = '') ";
}
$SQL.=" AND UserID != '".$LoggedUser['ID']."' ";
$SQL .= " AND UserID != '".$LoggedUser['ID']."' ";
$DB->query($SQL);
$Debug->set_flag('upload: notification query finished');
@ -976,17 +983,17 @@
$Rows = array();
foreach ($UserArray as $User) {
list($FilterID, $UserID, $Passkey) = $User;
$Rows[]="('$UserID', '$GroupID', '$TorrentID', '$FilterID')";
$Feed->populate('torrents_notify_'.$Passkey,$Item);
$Cache->delete_value('notifications_new_'.$UserID);
$Rows[] = "('$UserID', '$GroupID', '$TorrentID', '$FilterID')";
$Feed->populate("torrents_notify_$Passkey", $Item);
$Cache->delete_value("notifications_new_$UserID");
}
$InsertSQL.=implode(',', $Rows);
$InsertSQL .= implode(',', $Rows);
$DB->query($InsertSQL);
$Debug->set_flag('upload: notification inserts finished');
foreach ($FilterArray as $Filter) {
list($FilterID, $UserID, $Passkey) = $Filter;
$Feed->populate('torrents_notify_'.$FilterID.'_'.$Passkey,$Item);
$Feed->populate("torrents_notify_{$FilterID}_$Passkey", $Item);
}
}
@ -997,50 +1004,50 @@
JOIN bookmarks_torrents AS b ON b.UserID = u.ID
WHERE b.GroupID = $GroupID");
while (list($UserID, $Passkey) = $DB->next_record()) {
$Feed->populate('torrents_bookmarks_t_'.$Passkey, $Item);
$Feed->populate("torrents_bookmarks_t_$Passkey", $Item);
}
$Feed->populate('torrents_all',$Item);
$Feed->populate('torrents_all', $Item);
$Debug->set_flag('upload: notifications handled');
if ($Type == 'Music') {
$Feed->populate('torrents_music',$Item);
$Feed->populate('torrents_music', $Item);
if ($Properties['Media'] == 'Vinyl') {
$Feed->populate('torrents_vinyl',$Item);
$Feed->populate('torrents_vinyl', $Item);
}
if ($Properties['Bitrate'] == 'Lossless') {
$Feed->populate('torrents_lossless',$Item);
$Feed->populate('torrents_lossless', $Item);
}
if ($Properties['Bitrate'] == '24bit Lossless') {
$Feed->populate('torrents_lossless24',$Item);
$Feed->populate('torrents_lossless24', $Item);
}
if ($Properties['Format'] == 'MP3') {
$Feed->populate('torrents_mp3',$Item);
$Feed->populate('torrents_mp3', $Item);
}
if ($Properties['Format'] == 'FLAC') {
$Feed->populate('torrents_flac',$Item);
$Feed->populate('torrents_flac', $Item);
}
}
if ($Type == 'Applications') {
$Feed->populate('torrents_apps',$Item);
$Feed->populate('torrents_apps', $Item);
}
if ($Type == 'E-Books') {
$Feed->populate('torrents_ebooks',$Item);
$Feed->populate('torrents_ebooks', $Item);
}
if ($Type == 'Audiobooks') {
$Feed->populate('torrents_abooks',$Item);
$Feed->populate('torrents_abooks', $Item);
}
if ($Type == 'E-Learning Videos') {
$Feed->populate('torrents_evids',$Item);
$Feed->populate('torrents_evids', $Item);
}
if ($Type == 'Comedy') {
$Feed->populate('torrents_comedy',$Item);
$Feed->populate('torrents_comedy', $Item);
}
if ($Type == 'Comics') {
$Feed->populate('torrents_comics',$Item);
$Feed->populate('torrents_comics', $Item);
}
// Clear Cache
$Cache->delete_value('torrents_details_'.$GroupID);
// Clear cache
$Cache->delete_value("torrents_details_$GroupID");
// Allow deletion of this torrent now
$Cache->delete_value('torrent_'.$TorrentID.'_lock');
$Cache->delete_value("torrent_{$TorrentID}_lock");

View File

@ -201,11 +201,11 @@ function checked($Checked) {
<div id="sortable_container" style="display: none;">
<a href="#" id="reset_sortable" class="brackets">Reset to default</a>
<ul class="sortable_list" id="sortable">
<?Users::release_order()?>
<?Users::release_order($SiteOptions)?>
</ul>
<p><small>Note: Checked items will be hidden.</small></p>
<script type="text/javascript" id="sortable_default">//<![CDATA[
var sortable_list_default = <?=Users::release_order_default_js()?>;
var sortable_list_default = <?=Users::release_order_default_js($SiteOptions)?>;
//]]>
</script>
</div>
@ -255,37 +255,37 @@ function checked($Checked) {
<td>
<ul class="options_list nobullet">
<li>
<input type="checkbox" name="showtfilter" id="showtfilter"<?=(!isset($SiteOptions['ShowTorFilter']) || $SiteOptions['ShowTorFilter'] ? ' checked="checked"' : '')?>/>
<input type="checkbox" name="showtfilter" id="showtfilter"<?=(!isset($SiteOptions['ShowTorFilter']) || $SiteOptions['ShowTorFilter'] ? ' checked="checked"' : '')?> />
<label for="showtfilter">Show filter controls</label>
</li>
<li>
<input type="checkbox" name="showtags" id="showtags"<?Format::selected('ShowTags', 1, 'checked', $SiteOptions);?>/>
<input type="checkbox" name="showtags" id="showtags"<? Format::selected('ShowTags', 1, 'checked', $SiteOptions); ?>/>
<label for="showtags">Show filters for official tags</label>
</li>
</ul>
</td>
</tr>
<tr>
<td class="label"><strong>Auto Complete</strong></td>
<td class="label"><strong>Auto completion</strong></td>
<td>
<select name="autocomplete">
<option value="0" <? if (empty($SiteOptions['AutoComplete'])) { ?> selected="selected" <? } ?>>Everywhere</option>
<option value="2" <? if ($SiteOptions['AutoComplete'] === 2) { ?>selected="selected" <? } ?>>Searches Only</option>
<option value="1" <? if ($SiteOptions['AutoComplete'] === 1) { ?>selected="selected" <? } ?>>Disable</option>
<option value="0"<? if (empty($SiteOptions['AutoComplete'])) { ?> selected="selected"<? } ?>>Everywhere</option>
<option value="2"<? if ($SiteOptions['AutoComplete'] === 2) { ?> selected="selected"<? } ?>>Searches only</option>
<option value="1"<? if ($SiteOptions['AutoComplete'] === 1) { ?> selected="selected"<? } ?>>Disable</option>
</select>
</td>
</tr>
<tr>
<td class="label"><strong>Voting links</strong></td>
<td>
<input type="checkbox" name="novotelinks" id="novotelinks" <? if (!empty($SiteOptions['NoVoteLinks'])) { ?>checked="checked" <? } ?>/>
<input type="checkbox" name="novotelinks" id="novotelinks"<? if (!empty($SiteOptions['NoVoteLinks'])) { ?> checked="checked"<? } ?> />
<label for="novotelinks">Disable voting links on artist pages, collages, and snatched lists</label>
</td>
</tr>
<tr>
<td class="label"><strong>Download torrents as text files</strong></td>
<td>
<input type="checkbox" name="downloadalt" id="downloadalt" <? if ($DownloadAlt) { ?>checked="checked" <? } ?>/>
<input type="checkbox" name="downloadalt" id="downloadalt"<? if ($DownloadAlt) { ?> checked="checked"<? } ?> />
<label for="downloadalt">For users whose ISP blocks the downloading of torrent files</label>
</td>
</tr>
@ -348,7 +348,7 @@ function checked($Checked) {
<tr>
<td class="label"><strong>Auto-save text</strong></td>
<td>
<input type="checkbox" name="disableautosave" id="disableautosave" <? if (!empty($SiteOptions['DisableAutoSave'])) { ?>checked="checked" <? } ?>/>
<input type="checkbox" name="disableautosave" id="disableautosave"<? if (!empty($SiteOptions['DisableAutoSave'])) { ?> checked="checked"<? } ?> />
<label for="disableautosave">Disable reply text from being saved automatically when changing pages in a thread</label>
</td>
</tr>

View File

@ -218,7 +218,7 @@
$Options['NoVoteLinks'] = (!empty($_POST['novotelinks']) ? 1 : 0);
$Options['CoverArt'] = (int) !empty($_POST['coverart']);
$Options['ShowExtraCovers'] = (int) !empty($_POST['show_extra_covers']);
$Options['AutoComplete'] = (int) $_POST['autocomplete'];
$Options['AutoComplete'] = (int) $_POST['autocomplete'];
if (isset($LoggedUser['DisableFreeTorrentTop10'])) {
$Options['DisableFreeTorrentTop10'] = $LoggedUser['DisableFreeTorrentTop10'];

View File

@ -1,17 +1,21 @@
<?
authorize();
if (($UserSubscriptions = $Cache->get_value('subscriptions_user_'.$LoggedUser['ID'])) === false) {
$DB->query('SELECT TopicID FROM users_subscriptions WHERE UserID = '.db_string($LoggedUser['ID']));
$DB->query('
SELECT TopicID
FROM users_subscriptions
WHERE UserID = '.db_string($LoggedUser['ID']));
if ($UserSubscriptions = $DB->collect(0)) {
$Cache->cache_value('subscriptions_user_'.$LoggedUser['ID'],$UserSubscriptions,0);
$Cache->cache_value('subscriptions_user_'.$LoggedUser['ID'], $UserSubscriptions, 0);
}
}
if (!empty($UserSubscriptions)) {
$DB->query("INSERT INTO forums_last_read_topics (UserID, TopicID, PostID)
SELECT '$LoggedUser[ID]', ID, LastPostID FROM
forums_topics
WHERE ID IN (".implode(',',$UserSubscriptions).")
ON DUPLICATE KEY UPDATE PostID=LastPostID");
$DB->query("
INSERT INTO forums_last_read_topics (UserID, TopicID, PostID)
SELECT '$LoggedUser[ID]', ID, LastPostID
FROM forums_topics
WHERE ID IN (".implode(',', $UserSubscriptions).')
ON DUPLICATE KEY UPDATE PostID = LastPostID');
}
$Cache->delete_value('subscriptions_user_new_'.$LoggedUser['ID']);
header('Location: userhistory.php?action=subscriptions');

View File

@ -9,20 +9,30 @@
$CollageID = (int) $_GET['collageid'];
if (!$UserSubscriptions = $Cache->get_value('collage_subs_user_'.$LoggedUser['ID'])) {
$DB->query('SELECT CollageID FROM users_collage_subs WHERE UserID = '.db_string($LoggedUser['ID']));
$DB->query('
SELECT CollageID
FROM users_collage_subs
WHERE UserID = '.db_string($LoggedUser['ID']));
$UserSubscriptions = $DB->collect(0);
$Cache->cache_value('collage_subs_user_'.$LoggedUser['ID'],$UserSubscriptions,0);
$Cache->cache_value('collage_subs_user_'.$LoggedUser['ID'], $UserSubscriptions, 0);
}
if (($Key = array_search($CollageID, $UserSubscriptions)) !== false) {
$DB->query('DELETE FROM users_collage_subs WHERE UserID = '.db_string($LoggedUser['ID']).' AND CollageID = '.$CollageID);
$DB->query('
DELETE FROM users_collage_subs
WHERE UserID = '.db_string($LoggedUser['ID'])."
AND CollageID = $CollageID");
unset($UserSubscriptions[$Key]);
Collages::decrease_subscriptions($CollageID);
} else {
$DB->query("INSERT IGNORE INTO users_collage_subs (UserID, CollageID, LastVisit) VALUES ($LoggedUser[ID], ".$CollageID.", NOW())");
$DB->query("
INSERT IGNORE INTO users_collage_subs
(UserID, CollageID, LastVisit)
VALUES
($LoggedUser[ID], $CollageID, NOW())");
array_push($UserSubscriptions, $CollageID);
Collages::increase_subscriptions($CollageID);
}
$Cache->replace_value('collage_subs_user_'.$LoggedUser['ID'], $UserSubscriptions, 0);
$Cache->delete_value('collage_subs_user_new_'.$LoggedUser['ID']);
$Cache->delete_value('collage_'.$CollageID);
$Cache->delete_value("collage_$CollageID");

View File

@ -19,8 +19,8 @@
$DB->query("
SELECT ui.JoinDate, p.Level AS Class
FROM users_main AS um
JOIN users_info AS ui ON um.ID=ui.UserID
JOIN permissions AS p ON p.ID=um.PermissionID
JOIN users_info AS ui ON um.ID = ui.UserID
JOIN permissions AS p ON p.ID = um.PermissionID
WHERE um.ID = $UserID");
list($Joined, $Class) = $DB->next_record();
@ -30,7 +30,10 @@
$UsersOnly = $_GET['usersonly'];
$DB->query("SELECT Username FROM users_main WHERE ID = ".$UserID);
$DB->query("
SELECT Username
FROM users_main
WHERE ID = $UserID");
list($Username)= $DB->next_record();
View::show_header("Email history for $Username");
@ -44,7 +47,8 @@
FROM users_main AS u
LEFT JOIN users_main AS u2 ON u2.Email = u.Email AND u2.ID != '$UserID'
LEFT JOIN geoip_country AS c ON INET_ATON(u.IP) BETWEEN c.StartIP AND c.EndIP
WHERE u.ID='$UserID' AND u2.ID > 0
WHERE u.ID = '$UserID'
AND u2.ID > 0
UNION
SELECT
h.Email,
@ -52,9 +56,11 @@
h.IP,
c.Code
FROM users_history_emails AS h
LEFT JOIN users_history_emails AS h2 ON h2.email=h.email and h2.UserID != '$UserID'
LEFT JOIN users_history_emails AS h2 ON h2.email = h.email and h2.UserID != '$UserID'
LEFT JOIN geoip_country AS c ON INET_ATON(h.IP) BETWEEN c.StartIP AND c.EndIP
WHERE h.UserID='$UserID' AND h2.UserID>0"/*AND Time != '0000-00-00 00:00:00'*/."
WHERE h.UserID = '$UserID'
AND h2.UserID > 0"
/*AND Time != '0000-00-00 00:00:00'*/."
ORDER BY Time DESC");
} else {
$DB->query("
@ -65,7 +71,7 @@
c.Code
FROM users_main AS u
LEFT JOIN geoip_country AS c ON INET_ATON(u.IP) BETWEEN c.StartIP AND c.EndIP
WHERE u.ID='$UserID'
WHERE u.ID = '$UserID'
UNION
SELECT
h.Email,
@ -74,7 +80,8 @@
c.Code
FROM users_history_emails AS h
LEFT JOIN geoip_country AS c ON INET_ATON(h.IP) BETWEEN c.StartIP AND c.EndIP
WHERE UserID='$UserID' "/*AND Time != '0000-00-00 00:00:00'*/."
WHERE UserID = '$UserID' "
/*AND Time != '0000-00-00 00:00:00'*/."
ORDER BY Time DESC");
}
$History = $DB->to_array();
@ -124,8 +131,12 @@
<td />
<td><?=time_diff($Time)?></td>
<td><?=display_str($IP)?></td>
<? $UserURL = "https://".SSL_SITE_URL."/user.php?id=$UserID2";
$DB->query("SELECT Enabled FROM users_main WHERE ID = ".$UserID2);
<?
$UserURL = 'https://'.SSL_SITE_URL."/user.php?id=$UserID2";
$DB->query("
SELECT Enabled
FROM users_main
WHERE ID = $UserID2");
list($Enabled) = $DB->next_record();
$DB->set_query_id($ueQuery);
?>

View File

@ -20,8 +20,8 @@
ui.JoinDate,
p.Level AS Class
FROM users_main AS um
JOIN users_info AS ui ON um.ID=ui.UserID
JOIN permissions AS p ON p.ID=um.PermissionID
JOIN users_info AS ui ON um.ID = ui.UserID
JOIN permissions AS p ON p.ID = um.PermissionID
WHERE um.ID = $UserID");
list($Joined, $Class) = $DB->next_record();
@ -31,7 +31,10 @@
$UsersOnly = $_GET['usersonly'];
$DB->query("SELECT Username FROM users_main WHERE ID = ".$UserID);
$DB->query("
SELECT Username
FROM users_main
WHERE ID = $UserID");
list($Username)= $DB->next_record();
View::show_header("Email history for $Username");
@ -49,10 +52,11 @@
GROUP_CONCAT(i.Donor SEPARATOR '|') AS UsersDonor,
GROUP_CONCAT(i.Warned SEPARATOR '|') AS UsersWarned
FROM users_main AS m
LEFT JOIN users_history_emails AS h ON h.Email=m.Email AND h.UserID != m.ID
LEFT JOIN users_main AS m2 ON m2.ID=h.UserID
LEFT JOIN users_info AS i ON i.UserID=h.UserID
WHERE m.ID='$UserID'"
LEFT JOIN users_history_emails AS h ON h.Email = m.Email
AND h.UserID != m.ID
LEFT JOIN users_main AS m2 ON m2.ID = h.UserID
LEFT JOIN users_info AS i ON i.UserID = h.UserID
WHERE m.ID = '$UserID'"
);
$CurrentEmail = array_shift($DB->to_array());
@ -70,10 +74,11 @@
i2.Donor AS UsersDonor,
i2.Warned AS UsersWarned
FROM users_history_emails AS h2
LEFT JOIN users_history_emails AS h3 ON h3.Email=h2.Email AND h3.UserID != h2.UserID
LEFT JOIN users_main AS m3 ON m3.ID=h3.UserID
LEFT JOIN users_info AS i2 ON i2.UserID=h3.UserID
WHERE h2.UserID='$UserID'
LEFT JOIN users_history_emails AS h3 ON h3.Email = h2.Email
AND h3.UserID != h2.UserID
LEFT JOIN users_main AS m3 ON m3.ID = h3.UserID
LEFT JOIN users_info AS i2 ON i2.UserID = h3.UserID
WHERE h2.UserID = '$UserID'
ORDER BY Time DESC"
);
$History = $DB->to_array();
@ -107,7 +112,9 @@
$Invite['EndTime'] = $Joined;
$Invite['AccountAge'] = date(time() + time() - strtotime($Joined)); // Same as EndTime but without ' ago'
$Invite['IP'] = $History[0]['IP'];
if ($Current['StartTime'] == '0000-00-00 00:00:00') { $Current['StartTime'] = $Joined; }
if ($Current['StartTime'] == '0000-00-00 00:00:00') {
$Current['StartTime'] = $Joined;
}
} else {
foreach ($History as $Key => $Val) {
if ($History[$Key + 1]['Time'] == '0000-00-00 00:00:00' && $Val['Time'] != '0000-00-00 00:00:00') {
@ -281,12 +288,12 @@
<td>Start</td>
<td>End</td>
<td>Age of account</td>
<td>Signup IP</td>
<td>Registration IP address</td>
</tr>
<?
// Matches on invite email
if ($OldMatches) {
$i=0;
$i = 0;
ob_start();
foreach ($OldMatches as $Match) {
if ($Match['Email'] == $Invite['Email']) {

View File

@ -22,8 +22,8 @@
um.Username,
p.Level AS Class
FROM users_main AS um
LEFT JOIN permissions AS p ON p.ID=um.PermissionID
WHERE um.ID = ".$UserID);
LEFT JOIN permissions AS p ON p.ID = um.PermissionID
WHERE um.ID = $UserID");
list($Username, $Class) = $DB->next_record();
if (!check_perms('users_view_ips', $Class)) {
@ -41,7 +41,7 @@
?>
<script type="text/javascript">//<![CDATA[
function ShowIPs(rowname) {
$('tr[name="'+rowname+'"]').gtoggle();
$('tr[name="' + rowname + '"]').gtoggle();
}
function Ban(ip, id, elemID) {
@ -49,16 +49,16 @@ function Ban(ip, id, elemID) {
if (notes != null && notes.length > 0) {
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById(elemID).innerHTML = "<strong>[Banned]</strong>";
}
}
xmlhttp.open("GET","tools.php?action=quick_ban&perform=create&ip=" + ip + "&notes=" + notes,true);
xmlhttp.open("GET", "tools.php?action=quick_ban&perform=create&ip=" + ip + "&notes=" + notes, true);
xmlhttp.send();
}
@ -67,17 +67,17 @@ function Ban(ip, id, elemID) {
function UnBan(ip, id, elemID) {
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById(elemID).innerHTML = "Ban";
document.getElementById(elemID).onclick = function() { Ban(ip, id, elemID); return false; };
}
}
xmlhttp.open("GET","tools.php?action=quick_ban&perform=delete&id=" + id + "&ip=" + ip,true);
xmlhttp.open("GET","tools.php?action=quick_ban&perform=delete&id=" + id + "&ip=" + ip, true);
xmlhttp.send();
}
*/
@ -101,11 +101,11 @@ function UnBan(ip, id, elemID) {
GROUP_CONCAT(ui2.Donor SEPARATOR '|'),
GROUP_CONCAT(ui2.Warned SEPARATOR '|')
FROM users_history_ips AS h1
LEFT JOIN users_history_ips AS h2 ON h2.IP=h1.IP AND h2.UserID!=$UserID
LEFT JOIN users_main AS um2 ON um2.ID=h2.UserID
LEFT JOIN users_info AS ui2 ON ui2.UserID=h2.UserID
WHERE h1.UserID='$UserID'
AND h2.UserID>0 $SearchIPQuery
LEFT JOIN users_history_ips AS h2 ON h2.IP = h1.IP AND h2.UserID != $UserID
LEFT JOIN users_main AS um2 ON um2.ID = h2.UserID
LEFT JOIN users_info AS ui2 ON ui2.UserID = h2.UserID
WHERE h1.UserID = '$UserID'
AND h2.UserID > 0 $SearchIPQuery
GROUP BY h1.IP, h1.StartTime
ORDER BY h1.StartTime DESC
LIMIT $Limit");
@ -124,15 +124,15 @@ function UnBan(ip, id, elemID) {
GROUP_CONCAT(ui2.Donor SEPARATOR '|'),
GROUP_CONCAT(ui2.Warned SEPARATOR '|')
FROM users_history_ips AS h1
LEFT JOIN users_history_ips AS h2 ON h2.IP=h1.IP AND h2.UserID!=$UserID
LEFT JOIN users_main AS um2 ON um2.ID=h2.UserID
LEFT JOIN users_info AS ui2 ON ui2.UserID=h2.UserID
WHERE h1.UserID='$UserID' $SearchIPQuery
LEFT JOIN users_history_ips AS h2 ON h2.IP = h1.IP AND h2.UserID != $UserID
LEFT JOIN users_main AS um2 ON um2.ID = h2.UserID
LEFT JOIN users_info AS ui2 ON ui2.UserID = h2.UserID
WHERE h1.UserID = '$UserID' $SearchIPQuery
GROUP BY h1.IP, h1.StartTime
ORDER BY h1.StartTime DESC
LIMIT $Limit");
}
$DB->query("SELECT FOUND_ROWS()");
$DB->query('SELECT FOUND_ROWS()');
list($NumResults) = $DB->next_record();
$DB->set_query_id($RS);
@ -204,7 +204,11 @@ function UnBan(ip, id, elemID) {
<?=$IP?> (<?=Tools::get_country_code_by_ajax($IP)?>)<?
if ($CanManageIPBans) {
if (!isset($IPs[$IP])) {
$sql = "SELECT ID, FromIP, ToIP FROM ip_bans WHERE '".Tools::ip_to_unsigned($IP)."' BETWEEN FromIP AND ToIP LIMIT 1";
$sql = "
SELECT ID, FromIP, ToIP
FROM ip_bans
WHERE '".Tools::ip_to_unsigned($IP)."' BETWEEN FromIP AND ToIP
LIMIT 1";
$DB->query($sql);
if ($DB->record_count() > 0) {
@ -215,7 +219,7 @@ function UnBan(ip, id, elemID) {
} else {
$IPs[$IP] = false;
?>
<a id="<?=$counter?>" href="#" onclick="Ban('<?=$IP?>', '<?=$ID?>', '<?=$counter?>'); this.onclick=null;return false;" class="brackets">Ban</a>
<a id="<?=$counter?>" href="#" onclick="Ban('<?=$IP?>', '<?=$ID?>', '<?=$counter?>'); this.onclick = null; return false;" class="brackets">Ban</a>
<?
}
$counter++;

View File

@ -25,8 +25,8 @@
SELECT um.Username,
p.Level AS Class
FROM users_main AS um
LEFT JOIN permissions AS p ON p.ID=um.PermissionID
WHERE um.ID = ".$UserID);
LEFT JOIN permissions AS p ON p.ID = um.PermissionID
WHERE um.ID = $UserID");
list($Username, $Class) = $DB->next_record();
if (!check_perms('users_view_ips', $Class)) {
@ -35,7 +35,7 @@
$UsersOnly = $_GET['usersonly'];
View::show_header("Tracker IP history for $Username");
View::show_header("Tracker IP address history for $Username");
?>
<script type="text/javascript">
function ShowIPs(rowname) {
@ -53,7 +53,7 @@ function ShowIPs(rowname) {
ORDER BY tstamp DESC
LIMIT $Limit");
$DB->query("SELECT FOUND_ROWS()");
$DB->query('SELECT FOUND_ROWS()');
list($NumResults) = $DB->next_record();
$DB->set_query_id($TrackerIps);

View File

@ -26,7 +26,7 @@
$UserInfo = Users::user_info($UserID);
extract(array_intersect_key($UserInfo, array_flip(array('Username', 'Enabled', 'Title', 'Avatar', 'Donor', 'Warned'))));
View::show_header('Post history for '.$Username,'subscriptions,comments,bbcode');
View::show_header("Post history for $Username", 'subscriptions,comments,bbcode');
if ($LoggedUser['CustomForums']) {
unset($LoggedUser['CustomForums']['']);
@ -44,40 +44,40 @@
FROM forums_posts AS p
LEFT JOIN forums_topics AS t ON t.ID = p.TopicID';
if ($ShowUnread) {
$sql.='
$sql .= '
LEFT JOIN forums_last_read_topics AS l ON l.TopicID = t.ID AND l.UserID = '.$LoggedUser['ID'];
}
$sql .= '
$sql .= "
LEFT JOIN forums AS f ON f.ID = t.ForumID
WHERE p.AuthorID = '.$UserID.'
AND ((f.MinClassRead <= '.$LoggedUser['Class'];
WHERE p.AuthorID = $UserID
AND ((f.MinClassRead <= ".$LoggedUser['Class'];
if (!empty($RestrictedForums)) {
$sql.='
AND f.ID NOT IN (\''.$RestrictedForums.'\')';
$sql .= "
AND f.ID NOT IN ('$RestrictedForums')";
}
$sql .= ')';
if (!empty($PermittedForums)) {
$sql.='
OR f.ID IN (\''.$PermittedForums.'\')';
$sql .= "
OR f.ID IN ('$PermittedForums')";
}
$sql .= ')';
if ($ShowUnread) {
$sql .= '
AND ((t.IsLocked=\'0\' OR t.IsSticky=\'1\')
AND (l.PostID<t.LastPostID OR l.PostID IS NULL))';
AND ((t.IsLocked = \'0\' OR t.IsSticky = \'1\')
AND (l.PostID < t.LastPostID OR l.PostID IS NULL))';
}
$sql .= '
$sql .= "
GROUP BY t.ID
ORDER BY p.ID DESC
LIMIT '.$Limit;
LIMIT $Limit";
$PostIDs = $DB->query($sql);
$DB->query("SELECT FOUND_ROWS()");
$DB->query('SELECT FOUND_ROWS()');
list($Results) = $DB->next_record();
if ($Results > $PerPage * ($Page - 1)) {
$DB->set_query_id($PostIDs);
$PostIDs = $DB->collect('ID');
$sql = '
$sql = "
SELECT
p.ID,
p.AddedTime,
@ -97,16 +97,21 @@
LEFT JOIN users_main AS ed ON ed.ID = p.EditedUserID
JOIN forums_topics AS t ON t.ID = p.TopicID
JOIN forums AS f ON f.ID = t.ForumID
LEFT JOIN forums_last_read_topics AS l ON l.UserID = '.$UserID.' AND l.TopicID = t.ID
WHERE p.ID IN ('.implode(',',$PostIDs).')
LEFT JOIN forums_last_read_topics AS l ON l.UserID = $UserID
AND l.TopicID = t.ID
WHERE p.ID IN (".implode(',', $PostIDs).')
ORDER BY p.ID DESC';
$Posts = $DB->query($sql);
}
} else {
$sql = '
SELECT SQL_CALC_FOUND_ROWS';
SELECT
SQL_CALC_FOUND_ROWS';
if ($ShowGrouped) {
$sql.=' * FROM (SELECT';
$sql .= '
*
FROM (
SELECT';
}
$sql .= '
p.ID,
@ -122,7 +127,7 @@
$sql .= '
l.PostID AS LastRead,';
}
$sql .= '
$sql .= "
t.IsLocked,
t.IsSticky
FROM forums_posts as p
@ -131,26 +136,27 @@
LEFT JOIN users_main AS ed ON ed.ID = p.EditedUserID
JOIN forums_topics AS t ON t.ID = p.TopicID
JOIN forums AS f ON f.ID = t.ForumID
LEFT JOIN forums_last_read_topics AS l ON l.UserID = '.$UserID.' AND l.TopicID = t.ID
WHERE p.AuthorID = '.$UserID.'
AND ((f.MinClassRead <= '.$LoggedUser['Class'];
LEFT JOIN forums_last_read_topics AS l ON l.UserID = $UserID
AND l.TopicID = t.ID
WHERE p.AuthorID = $UserID
AND ((f.MinClassRead <= ".$LoggedUser['Class'];
if (!empty($RestrictedForums)) {
$sql.='
AND f.ID NOT IN (\''.$RestrictedForums.'\')';
$sql .= "
AND f.ID NOT IN ('$RestrictedForums')";
}
$sql .= ')';
if (!empty($PermittedForums)) {
$sql.='
OR f.ID IN (\''.$PermittedForums.'\')';
$sql .= "
OR f.ID IN ('$PermittedForums')";
}
$sql .= ')';
if ($ShowUnread) {
$sql.='
AND ( (t.IsLocked=\'0\' OR t.IsSticky=\'1\')
AND (l.PostID<t.LastPostID OR l.PostID IS NULL)
$sql .= '
AND ( (t.IsLocked = \'0\' OR t.IsSticky = \'1\')
AND (l.PostID < t.LastPostID OR l.PostID IS NULL)
) ';
}
@ -158,16 +164,16 @@
ORDER BY p.ID DESC';
if ($ShowGrouped) {
$sql.='
) AS sub
$sql .= '
) AS sub
GROUP BY TopicID
ORDER BY ID DESC';
}
$sql.=' LIMIT '.$Limit;
$sql .= " LIMIT $Limit";
$Posts = $DB->query($sql);
$DB->query("SELECT FOUND_ROWS()");
$DB->query('SELECT FOUND_ROWS()');
list($Results) = $DB->next_record();
$DB->set_query_id($Posts);
@ -194,9 +200,12 @@
<?
if ($ViewingOwn) {
if (($UserSubscriptions = $Cache->get_value('subscriptions_user_'.$LoggedUser['ID'])) === false) {
$DB->query("SELECT TopicID FROM users_subscriptions WHERE UserID = '$LoggedUser[ID]'");
$DB->query("
SELECT TopicID
FROM users_subscriptions
WHERE UserID = '$LoggedUser[ID]'");
$UserSubscriptions = $DB->collect(0);
$Cache->cache_value('subscriptions_user_'.$LoggedUser['ID'],$UserSubscriptions,0);
$Cache->cache_value('subscriptions_user_'.$LoggedUser['ID'], $UserSubscriptions, 0);
$DB->set_query_id($Posts);
}

View File

@ -23,8 +23,8 @@
FROM collages AS c
JOIN users_collage_subs AS s ON s.CollageID = c.ID
JOIN collages_torrents AS ct ON ct.CollageID = c.ID
WHERE s.UserID=$LoggedUser[ID] AND c.Deleted='0'
AND ct.AddedOn>s.LastVisit
WHERE s.UserID = $LoggedUser[ID] AND c.Deleted = '0'
AND ct.AddedOn > s.LastVisit
GROUP BY c.ID";
} else {
$sql = "
@ -36,7 +36,7 @@
FROM collages AS c
JOIN users_collage_subs AS s ON s.CollageID = c.ID
LEFT JOIN collages_torrents AS ct ON ct.CollageID = c.ID
WHERE s.UserID=$LoggedUser[ID] AND c.Deleted='0'
WHERE s.UserID = $LoggedUser[ID] AND c.Deleted = '0'
GROUP BY c.ID";
}
@ -82,10 +82,12 @@
unset($TorrentTable);
list($CollageID, $CollageName, $CollageSize, $LastVisit) = $Collage;
$RS = $DB->query("SELECT GroupID FROM collages_torrents
WHERE CollageID=$CollageID
AND AddedOn>'" . db_string($LastVisit) . "'
ORDER BY AddedOn");
$RS = $DB->query("
SELECT GroupID
FROM collages_torrents
WHERE CollageID = $CollageID
AND AddedOn > '" . db_string($LastVisit) . "'
ORDER BY AddedOn");
$NewTorrentCount = $DB->record_count();
//$NewTorrents = $DB->to_array();
//$Artists = Artists::get_artists($GroupID);
@ -104,7 +106,7 @@
// foreach ($NewTorrents as $TorrentGroup) {
// list($GroupID, $GroupName, $GroupYear, $ReleaseType, $RecordLabel, $CatalogueNumber, $WikiImage) = $TorrentGroup;
// $DisplayName = Artists::display_artists($Artists[$GroupID]);
// $AltName=$GroupName;
// $AltName = $GroupName;
foreach ($TorrentList as $GroupID => $Group) {
extract(Torrents::array_group($Group));
@ -117,11 +119,11 @@
unset($ExtendedArtists[3]);
$DisplayName .= Artists::display_artists($ExtendedArtists);
} elseif (count($Artists) > 0) {
$DisplayName .= Artists::display_artists(array('1'=>$Artists));
$DisplayName .= Artists::display_artists(array('1' => $Artists));
}
$DisplayName .= '<a href="torrents.php?id='.$GroupID.'" title="View Torrent">'.$GroupName.'</a>';
$DisplayName .= "<a href=\"torrents.php?id=$GroupID\" title=\"View Torrent\">$GroupName</a>";
if ($GroupYear > 0) {
$DisplayName = $DisplayName. " [$GroupYear]";
$DisplayName = "$DisplayName [$GroupYear]";
}
if ($GroupVanityHouse) {
$DisplayName .= ' [<abbr title="This is a Vanity House release">VH</abbr>]';
@ -168,8 +170,13 @@
}
$SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
if ($Torrent['RemasterTitle'] != $LastRemasterTitle || $Torrent['RemasterYear'] != $LastRemasterYear ||
$Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel || $Torrent['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber || $FirstUnknown || $Torrent['Media'] != $LastMedia) {
if ($Torrent['RemasterTitle'] != $LastRemasterTitle
|| $Torrent['RemasterYear'] != $LastRemasterYear
|| $Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel
|| $Torrent['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber
|| $FirstUnknown
|| $Torrent['Media'] != $LastMedia
) {
$EditionID++;
?>
<tr class="group_torrent groupid_<?=$CollageID . $GroupID?> edition<?=$SnatchedGroupClass?> hidden">
@ -202,13 +209,13 @@
list($TorrentID, $Torrent) = each($Torrents);
$DisplayName = '<a href="torrents.php?id='.$GroupID.'" title="View Torrent">'.$GroupName.'</a>';
$DisplayName = "<a href=\"torrents.php?id=$GroupID\" title=\"View Torrent\">$GroupName</a>";
if ($Torrent['IsSnatched']) {
$DisplayName .=' ' . Format::torrent_label('Snatched!');
$DisplayName .= ' ' . Format::torrent_label('Snatched!');
}
if (!empty($Torrent['FreeTorrent'])) {
$DisplayName .=' ' . Format::torrent_label('Freeleech!');
$DisplayName .= ' ' . Format::torrent_label('Freeleech!');
}
$SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
?>
@ -257,20 +264,21 @@
</tr>
</table>
<!--</div>-->
<table class="torrent_table<?=$ShowAll?' hidden':''?>" id="discog_table_<?=$CollageID?>">
<tr class="colhead">
<td width="1%"><!-- expand/collapse --></td>
<td width="70%"><strong>Torrents</strong></td>
<td>Size</td>
<td class="sign"><img src="static/styles/<?=$LoggedUser['StyleName'] ?>/images/snatched.png" alt="Snatches" title="Snatches" /></td>
<td class="sign"><img src="static/styles/<?=$LoggedUser['StyleName'] ?>/images/seeders.png" alt="Seeders" title="Seeders" /></td>
<td class="sign"><img src="static/styles/<?=$LoggedUser['StyleName'] ?>/images/leechers.png" alt="Leechers" title="Leechers" /></td>
</tr>
<table class="torrent_table<?=$ShowAll ? ' hidden' : ''?>" id="discog_table_<?=$CollageID?>">
<tr class="colhead">
<td width="1%"><!-- expand/collapse --></td>
<td width="70%"><strong>Torrents</strong></td>
<td>Size</td>
<td class="sign"><img src="static/styles/<?=$LoggedUser['StyleName'] ?>/images/snatched.png" alt="Snatches" title="Snatches" /></td>
<td class="sign"><img src="static/styles/<?=$LoggedUser['StyleName'] ?>/images/seeders.png" alt="Seeders" title="Seeders" /></td>
<td class="sign"><img src="static/styles/<?=$LoggedUser['StyleName'] ?>/images/leechers.png" alt="Leechers" title="Leechers" /></td>
</tr>
<?=$TorrentTable?>
</table>
<? } // foreach () ?>
</table>
<?
} // else -- if (empty($NumResults)) ?>
} // foreach ()
} // else -- if (empty($NumResults))
?>
</div>
<?

View File

@ -11,23 +11,39 @@
}
require(SERVER_ROOT.'/sections/forums/index.php');
$DB->query('SELECT ID FROM forums WHERE forums.ID = (SELECT ForumID FROM forums_topics WHERE ID = '.db_string($_GET['topicid']).')');
$DB->query('
SELECT ID
FROM forums
WHERE forums.ID =
(
SELECT ForumID
FROM forums_topics
WHERE ID = '.db_string($_GET['topicid']).'
)');
list($ForumID) = $DB->next_record();
if (!check_forumperm($ForumID)) {
die();
}
if (!$UserSubscriptions = $Cache->get_value('subscriptions_user_'.$LoggedUser['ID'])) {
$DB->query('SELECT TopicID FROM users_subscriptions WHERE UserID = '.db_string($LoggedUser['ID']));
$DB->query('
SELECT TopicID
FROM users_subscriptions
WHERE UserID = '.db_string($LoggedUser['ID']));
$UserSubscriptions = $DB->collect(0);
$Cache->cache_value('subscriptions_user_'.$LoggedUser['ID'],$UserSubscriptions,0);
$Cache->cache_value('subscriptions_user_'.$LoggedUser['ID'], $UserSubscriptions, 0);
}
if (($Key = array_search($_GET['topicid'],$UserSubscriptions)) !== false) {
$DB->query('DELETE FROM users_subscriptions WHERE UserID = '.db_string($LoggedUser['ID']).' AND TopicID = '.db_string($_GET['topicid']));
if (($Key = array_search($_GET['topicid'], $UserSubscriptions)) !== false) {
$DB->query('
DELETE FROM users_subscriptions
WHERE UserID = '.db_string($LoggedUser['ID']).'
AND TopicID = '.db_string($_GET['topicid']));
unset($UserSubscriptions[$Key]);
} else {
$DB->query("INSERT IGNORE INTO users_subscriptions (UserID, TopicID) VALUES ($LoggedUser[ID], ".db_string($_GET['topicid']).")");
$DB->query("
INSERT IGNORE INTO users_subscriptions (UserID, TopicID)
VALUES ($LoggedUser[ID], ".db_string($_GET['topicid']).")");
array_push($UserSubscriptions, $_GET['topicid']);
}
$Cache->replace_value('subscriptions_user_'.$LoggedUser['ID'], $UserSubscriptions, 0);

View File

@ -37,14 +37,17 @@
if (!is_number($UserID) || !is_number($TorrentID)) {
error(403);
}
$DB->query("SELECT info_hash FROM torrents where ID = $TorrentID");
$DB->query("
SELECT info_hash
FROM torrents
WHERE ID = $TorrentID");
if (list($InfoHash) = $DB->next_record(MYSQLI_NUM, FALSE)) {
$DB->query("
UPDATE users_freeleeches
SET Expired=TRUE
WHERE UserID=$UserID
AND TorrentID=$TorrentID");
$Cache->delete_value('users_tokens_'.$UserID);
SET Expired = TRUE
WHERE UserID = $UserID
AND TorrentID = $TorrentID");
$Cache->delete_value("users_tokens_$UserID");
Tracker::update_tracker('remove_token', array('info_hash' => rawurlencode($InfoHash), 'userid' => $UserID));
}
header("Location: userhistory.php?action=token_history&userid=$UserID");
@ -74,7 +77,7 @@
LIMIT $Limit");
$Tokens = $DB->to_array();
$DB->query("SELECT FOUND_ROWS()");
$DB->query('SELECT FOUND_ROWS()');
list($NumResults) = $DB->next_record();
$Pages = Format::get_pages($Page, $NumResults, 25);
@ -90,7 +93,7 @@
<td>Expired</td>
<? if (check_perms('users_mod')) { ?>
<td>Downloaded</td>
<td>Tokens Used</td>
<td>Tokens used</td>
<? } ?>
</tr>
<?
@ -109,20 +112,21 @@
$Name = $ArtistName.$Name;
}
if ($Format && $Encoding) {
$Name.=" [$Format / $Encoding]";
$Name .= " [$Format / $Encoding]";
}
?>
<tr class="<?=($i ? 'rowa' : 'rowb')?>">
<td><?=$Name?></td>
<td><?=time_diff($Time)?></td>
<td><?=($Expired ? 'Yes' : 'No')?><?=(check_perms('users_mod') && !$Expired)?" <a href=\"userhistory.php?action=token_history&amp;expire=1&amp;userid=$UserID&amp;torrentid=$TorrentID\">(expire)</a>":''?>
<td><?=($Expired ? 'Yes' : 'No')?><?=(check_perms('users_mod') && !$Expired) ? " <a href=\"userhistory.php?action=token_history&amp;expire=1&amp;userid=$UserID&amp;torrentid=$TorrentID\">(expire)</a>" : ''; ?>
</td>
<? if (check_perms('users_mod')) { ?>
<td><?=Format::get_size($Downloaded)?></td>
<td><?=$Uses?></td>
<? } ?>
</tr>
<? }
<?
}
?>
</table>
<div class="linkbox"><?=$Pages?></div>

View File

@ -0,0 +1,14 @@
$(document).ready(function() {
$("#sandbox").keyup(function() {
$.ajax({
type : "POST",
dataType : "html",
url : "ajax.php?action=preview",
data : {
"body" : $(this).val()
}
}).done(function(response) {
$("#preview").html(response);
});
});
});

File diff suppressed because one or more lines are too long