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 ($Torrent['Artists'] as $Importance => $Artists) {
foreach ($Artists as $Artist) { 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?>> <select id="importance" name="importance[]"<?=$this->Disabled?>>
<option value="1"<?=($Importance == '1' ? ' selected="selected"' : '')?>>Main</option> <option value="1"<?=($Importance == '1' ? ' selected="selected"' : '')?>>Main</option>
<option value="2"<?=($Importance == '2' ? ' selected="selected"' : '')?>>Guest</option> <option value="2"<?=($Importance == '2' ? ' selected="selected"' : '')?>>Guest</option>
@ -220,7 +220,7 @@ function music_form($GenreTags) {
} }
} else { } 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?>> <select id="importance" name="importance[]"<?=$this->Disabled?>>
<option value="1">Main</option> <option value="1">Main</option>
<option value="2">Guest</option> <option value="2">Guest</option>
@ -586,9 +586,9 @@ function show() {
<? } ?> <? } ?>
</select> </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 /> <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> </td>
</tr> </tr>
<tr> <tr>
@ -694,7 +694,7 @@ function audiobook_form() {
<tr> <tr>
<td class="label">Tags:</td> <td class="label">Tags:</td>
<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> </td>
</tr> </tr>
<tr> <tr>
@ -736,7 +736,7 @@ function simple_form($CategoryID) {
</tr> </tr>
<tr> <tr>
<td class="label">Tags:</td> <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>
<tr> <tr>
<td class="label">Image (optional):</td> <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 * 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 * @param boolean $Default Returns the default list if true
*/ */
public static function release_order ($Default = false) { public static function release_order(&$SiteOptions, $Default = false) {
global $SiteOptions, $ReleaseTypes; global $ReleaseTypes;
$RT = $ReleaseTypes + array( $RT = $ReleaseTypes + array(
1024 => 'Guest Appearance', 1024 => 'Guest Appearance',
@ -286,6 +286,12 @@ public static function release_order ($Default = false) {
$Defaults = !empty($SiteOptions['HideTypes']); $Defaults = !empty($SiteOptions['HideTypes']);
} else { } else {
$Sort =& $SiteOptions['SortHide']; $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) { 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 * Returns the default order for the sort list in a JS-friendly string
* @return string * @return string
*/ */
public static function release_order_default_js () { public static function release_order_default_js(&$SiteOptions) {
ob_start(); ob_start();
self::release_order(true); self::release_order($SiteOptions, true);
$HTML = ob_get_contents(); $HTML = ob_get_contents();
ob_end_clean(); ob_end_clean();
return json_encode($HTML); return json_encode($HTML);
@ -627,7 +633,7 @@ public static function has_avatars_enabled() {
* 0 - Enabled everywhere (default), 1 - Disabled, 2 - Searches only * 0 - Enabled everywhere (default), 1 - Disabled, 2 - Searches only
* *
* @param string $Type the type of the input. * @param string $Type the type of the input.
* @param boolean $Output echo out html * @param boolean $Output echo out HTML
* @return boolean * @return boolean
*/ */
public static function has_autocomplete_enabled($Type, $Output = true) { public static function has_autocomplete_enabled($Type, $Output = true) {
@ -635,9 +641,8 @@ public static function has_autocomplete_enabled($Type, $Output = true) {
$Enabled = false; $Enabled = false;
if (empty($LoggedUser['AutoComplete'])) { if (empty($LoggedUser['AutoComplete'])) {
$Enabled = true; $Enabled = true;
} } elseif ($LoggedUser['AutoComplete'] !== 1) {
elseif ($LoggedUser['AutoComplete'] !== 1) { switch ($Type) {
switch($Type) {
case 'search': case 'search':
if ($LoggedUser['AutoComplete'] == 2) { if ($LoggedUser['AutoComplete'] == 2) {
$Enabled = true; $Enabled = true;
@ -651,7 +656,7 @@ public static function has_autocomplete_enabled($Type, $Output = true) {
} }
} }
if ($Enabled && $Output) { if ($Enabled && $Output) {
echo 'data-gazelle-autocomplete="true"'; echo ' data-gazelle-autocomplete="true"';
} }
return $Enabled; return $Enabled;
} }

View File

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

View File

@ -1,5 +1,11 @@
CHANGELOG 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 2013-07-01 by alderaan
Serve Google Charts API images over HTTPS 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 what is actually seen in the Gazelle code. This document is the first
step in properly enforcing coding standards throughout the project. 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 == == TABLE OF CONTENTS ==
@ -27,7 +55,7 @@ step in properly enforcing coding standards throughout the project.
6.3 SQL examples 6.3 SQL examples
1. FILE FORMATTING # FILE FORMATTING
Tabs shall always be used for indentation. 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. 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 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 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. 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, There shall be a space between a control structure statement (e.g. `if`,
elseif, for) and the following parenthesis. `elseif`, `for`) and the following parenthesis.
There shall be a space around conditional operators. There shall be a space around conditional operators.
When using ternary operators, spaces shall be used around the 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 In loops and conditional blocks, there shall be braces even if there is
only one statement. only one statement.
@ -64,7 +92,7 @@ only one statement.
In loops and conditional blocks, the statement(s) shall be placed on the In loops and conditional blocks, the statement(s) shall be placed on the
following lines. 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 Switch cases in index files shall not contain substantial code. The use
of include statements is acceptable. 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 When building strings in PHP, single quotes shall be used when not
printing a variable. 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. shall be followed by a semi-colon.
Multiple, related CSS selectors with the same declarations shall appear 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 The opening brace shall be on the same line as the last related
selector with a space between the selector and the brace. 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. 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. Use indents as appropriate to aid readability.
The SQL keywords JOIN, RIGHT JOIN, LEFT JOIN must be indented once from The SQL keywords `JOIN`, `RIGHT JOIN`, `LEFT JOIN` must be indented once from
the SELECT statement. 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. statements.
The "not equal to" operator "!=" must be used instead of the alternative The "not equal to" operator `!=` must be used instead of the alternative
operator "<>". operator `<>`.
3. NAMING CONVENTIONS # NAMING CONVENTIONS
Function, variable, and class names shall always be descriptive. 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. 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. 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. leading lowercase letter.
JavaScript local-scope variables shall be written in 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. 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. uppercase letter.
3.4 SQL names ## SQL names
All SQL keywords shall be written in all UPPERCASE. 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. uppercase letter.
All automatically-incremented ID columns shall be named "ID", while the All automatically-incremented ID columns shall be named `ID`, while the
other columns for ID numbers shall have names like RequestID, TorrentID, other columns for Identification numbers shall have names like `RequestID`, `TorrentID`,
etc. 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 button labels shall use sentence case.
All table headings 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 Use common sense for design-related code. Microsoft's UI design guidelines
explain when certain form input controls should be used over others to explain when certain form input controls should be used over others to
provide a familiar and intuitive interface. Refer to the following links provide a familiar and intuitive interface. Refer to the following links
for the most likely issues to encounter in web design: 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/aa511452.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/aa511488.aspx * http://msdn.microsoft.com/en-us/library/windows/desktop/aa511453.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/aa511494.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) { if ($Foo >= 0) {
$SomeString = "this is a string $DiffString with more text"; $SomeString = "this is a string $DiffString with more text";
} elseif ($Foo == 0) { } elseif ($Foo == 0) {
// other things happen // other things happen
} else { } else {
// more magic // more magic
} }
function works_magic($Foo, $Bar) { function works_magic($Foo, $Bar) {
return $Foo; return $Foo;
} }
echo ($Foo == true ? 'foo is true' : 'foo is false'); echo ($Foo == true ? 'foo is true' : 'foo is false');
if ($Foo == true) { if ($Foo == true) {
// magic happens // magic happens
} }
/* /*
* This is a good, multi-line comment. * This is a good, multi-line comment.
* *
* Please comment your code! * 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 { .spellcheck {
margin: 10px 0; margin: 10px 0;
font-size: 1.25em; font-size: 1.25em;
font-weight: bold; font-weight: bold;
} }
.linkbox .brackets:before, .linkbox .brackets:before,
.linkbox .brackets:after, .linkbox .brackets:after,
.top10_quantity_links .brackets:before, .top10_quantity_links .brackets:before,
.top10_quantity_links .brackets:after { .top10_quantity_links .brackets:after {
color: #757575; color: #757575;
} }
6.3 SQL examples # SQL examples
SELECT SELECT
r.ID, e.EditionID, r.Title, r.Year, r.CatalogueNumber, r.ID, e.EditionID, r.Title, r.Year, r.CatalogueNumber,
l.Name AS Label, r.LabelID, r.Image, r.MusicBrainzID l.Name AS Label, r.LabelID, r.Image, r.MusicBrainzID
FROM releases AS r FROM releases AS r
JOIN editions AS e ON e.ReleaseID = r.ID JOIN editions AS e ON e.ReleaseID = r.ID
LEFT JOIN labels AS l ON l.ID = r.LabelID LEFT JOIN labels AS l ON l.ID = r.LabelID
WHERE r.ID IN ($ReleaseIDsSQL) WHERE r.ID IN ($ReleaseIDsSQL)
ORDER BY e.EditionID, r.Year ASC ORDER BY e.EditionID, r.Year ASC
SELECT SQL_CALC_FOUND_ROWS c.ID, c.Subject, cu.Unread, cu.Sticky, SELECT SQL_CALC_FOUND_ROWS c.ID, c.Subject, cu.Unread, cu.Sticky,
cu.ForwardedTo, cu2.UserID, cu.ReceivedDate AS Date cu.ForwardedTo, cu2.UserID, cu.ReceivedDate AS Date
FROM pm_conversations AS c FROM pm_conversations AS c
LEFT JOIN pm_conversations_users AS cu ON cu.ConvID = c.ID LEFT JOIN pm_conversations_users AS cu ON cu.ConvID = c.ID
AND cu.UserID = '1' AND cu.UserID = '1'
LEFT JOIN pm_conversations_users AS cu2 ON cu2.ConvID = c.ID LEFT JOIN pm_conversations_users AS cu2 ON cu2.ConvID = c.ID
AND cu2.UserID != '1' AND cu2.UserID != '1'
AND cu2.ForwardedTo = 0 AND cu2.ForwardedTo = 0
LEFT JOIN users_main AS um ON um.ID = cu2.UserID LEFT JOIN users_main AS um ON um.ID = cu2.UserID
WHERE um.Username LIKE 'test' WHERE um.Username LIKE 'test'
AND cu.InInbox = '1' AND cu.InInbox = '1'
GROUP BY c.ID GROUP BY c.ID
ORDER BY cu.Sticky, Date DESC ORDER BY cu.Sticky, Date DESC
LIMIT 25 LIMIT 25
SELECT RequestID AS ID, UserID FROM bookmarks_requests SELECT RequestID AS ID, UserID FROM bookmarks_requests
EOF

184
image.php
View File

@ -1,10 +1,5 @@
<? <?
/*-- Image Start Class ---------------------------------*/ // Functions and headers needed by the image proxy
/*------------------------------------------------------*/
/* Simplified version of script_start, used for the */
/* sitewide image proxy. */
/*------------------------------------------------------*/
/********************************************************/
error_reporting(E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR); error_reporting(E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR);
if (isset($_SERVER['http_if_modified_since'])) { 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('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())); 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')) { if (!extension_loaded('gd')) {
error('nogd'); error('nogd');
} }
require(SERVER_ROOT.'/classes/cache.class.php'); // Require the caching class function img_error($Type) {
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) {
header('Content-type: image/gif'); header('Content-type: image/gif');
die(file_get_contents(SERVER_ROOT.'/sections/image/'.$Type.'.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) { function verysmall($Image) {
return ((imagesx($Image) * imagesy($Image)) < 25) ? true : false; return ((imagesx($Image) * imagesy($Image)) < 25) ? true : false;
} }
@ -136,144 +97,5 @@ function image_height($Type, $Data) {
} }
} }
require('classes/script_start.php'); // script_start contains all we need and includes sections/image/index.php
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');
?> ?>

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. /* AJAX_LIMIT = array(x,y) = 'x' requests every 'y' seconds.
e.g. array(5,10) = 5 requests every 10 seconds */ e.g. array(5,10) = 5 requests every 10 seconds */
$AJAX_LIMIT = array(5,10); $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. // These users aren't rate limited.
// This array should contain user IDs. // This array should contain user IDs.
@ -158,6 +158,9 @@
case 'user_recents': case 'user_recents':
require(SERVER_ROOT . '/sections/ajax/user_recents.php'); require(SERVER_ROOT . '/sections/ajax/user_recents.php');
break; break;
case 'collage':
require(SERVER_ROOT . '/sections/ajax/collage.php');
break;
default: default:
// If they're screwing around with the query string // If they're screwing around with the query string
json_die("failure"); json_die("failure");

View File

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

View File

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

View File

@ -696,7 +696,7 @@ function compare($X, $Y) {
<input type="hidden" name="action" value="add_similar" /> <input type="hidden" name="action" value="add_similar" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" /> <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="artistid" value="<?=$ArtistID?>" /> <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="+" /> <input type="submit" value="+" />
</form> </form>
</li> </li>

View File

@ -180,7 +180,7 @@
<tr id="tagfilter"> <tr id="tagfilter">
<td class="label">Tags (comma-separated):</td> <td class="label">Tags (comma-separated):</td>
<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_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="radio" name="tags_type" id="tags_type1" value="1"<?Format::selected('tags_type',1,'checked')?> /><label for="tags_type1"> All</label>
</td> </td>

View File

@ -18,7 +18,10 @@ function btc_balance() {
function btc_address($UserID, $GenAddress = false) { function btc_address($UserID, $GenAddress = false) {
global $DB; global $DB;
$UserID = (int)$UserID; $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(); list($Addr) = $DB->next_record();
if (!empty($Addr)) { if (!empty($Addr)) {

View File

@ -4,7 +4,10 @@
//Include the header //Include the header
if (!$UserCount = $Cache->get_value('stats_user_count')) { 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(); list($UserCount) = $DB->next_record();
$Cache->cache_value('stats_user_count', $UserCount, 0); //inf cache $Cache->cache_value('stats_user_count', $UserCount, 0); //inf cache
} }

View File

@ -8,7 +8,10 @@
} }
if (!$UserCount = $Cache->get_value('stats_user_count')) { 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(); list($UserCount) = $DB->next_record();
$Cache->cache_value('stats_user_count', $UserCount, 0); //inf cache $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"> <form class="donate_form" name="test_paypal" method="post" action="donate.php">
<input type="hidden" name="action" value="ipn" /> <input type="hidden" name="action" value="ipn" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" /> <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="custom" value="<?=$LoggedUser['ID']?>" />
<input type="hidden" name="payment_status" value="Completed" /> <input type="hidden" name="payment_status" value="Completed" />
<input type="hidden" name="mc_fee" value="0.45" /> <input type="hidden" name="mc_fee" value="0.45" />

View File

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

View File

@ -4,16 +4,16 @@
// Bear this in mind when you try to use script_start functions. // Bear this in mind when you try to use script_start functions.
if (!check_perms('site_proxy_images')) { if (!check_perms('site_proxy_images')) {
error('forbidden'); img_error('forbidden');
} }
$URL = isset($_GET['i']) ? htmlspecialchars_decode($_GET['i']) : null; $URL = isset($_GET['i']) ? htmlspecialchars_decode($_GET['i']) : null;
if (!extension_loaded('openssl') && strtoupper($URL[4]) == 'S') { if (!extension_loaded('openssl') && strtoupper($URL[4]) == 'S') {
error('badprotocol'); img_error('badprotocol');
} }
if (!preg_match('/^'.IMAGE_REGEX.'/is',$URL,$Matches)) { if (!preg_match('/^'.IMAGE_REGEX.'/is',$URL,$Matches)) {
error('invalid'); img_error('invalid');
} }
if (isset($_GET['c'])) { if (isset($_GET['c'])) {
@ -24,16 +24,16 @@
$Cached = false; $Cached = false;
$Data = @file_get_contents($URL,0,stream_context_create(array('http'=>array('timeout'=>15)))); $Data = @file_get_contents($URL,0,stream_context_create(array('http'=>array('timeout'=>15))));
if (!$Data || empty($Data)) { if (!$Data || empty($Data)) {
error('timeout'); img_error('timeout');
} }
$Type = image_type($Data); $Type = image_type($Data);
if ($Type && function_exists('imagecreatefrom'.$Type)) { if ($Type && function_exists('imagecreatefrom'.$Type)) {
$Image = imagecreatefromstring($Data); $Image = imagecreatefromstring($Data);
if (invisible($Image)) { if (invisible($Image)) {
error('invisible'); img_error('invisible');
} }
if (verysmall($Image)) { if (verysmall($Image)) {
error('small'); img_error('small');
} }
} }
@ -60,8 +60,6 @@
if (strlen($Data2) > 256 * 1024 || image_height($Type, $Data2) > 400) { if (strlen($Data2) > 256 * 1024 || image_height($Type, $Data2) > 400) {
require_once(SERVER_ROOT.'/classes/mysql.class.php'); require_once(SERVER_ROOT.'/classes/mysql.class.php');
require_once(SERVER_ROOT.'/classes/time.class.php'); //Require the time class require_once(SERVER_ROOT.'/classes/time.class.php'); //Require the time class
$DB = new DB_MYSQL;
$DBURL = db_string($URL); $DBURL = db_string($URL);
// Reset avatar, add mod note // Reset avatar, add mod note
@ -76,7 +74,7 @@
// Send PM // 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] [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 TODO: solve this properly for photoshop output images which prepend shit to the image file. skip it or strip it
if (!isset($Type)) { if (!isset($Type)) {
error('timeout'); img_error('timeout');
} }
*/ */
if (isset($Type)) { if (isset($Type)) {

View File

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

View File

@ -18,15 +18,15 @@
$DB->query(" $DB->query("
SELECT ID SELECT ID
FROM users_main FROM users_main
WHERE torrent_pass='".db_string($_REQUEST['confirm'])."' WHERE torrent_pass = '".db_string($_REQUEST['confirm'])."'
AND Enabled='0'"); AND Enabled = '0'");
list($UserID) = $DB->next_record(); list($UserID) = $DB->next_record();
if ($UserID) { if ($UserID) {
$DB->query(" $DB->query("
UPDATE users_main UPDATE users_main
SET Enabled='1' SET Enabled = '1'
WHERE ID='$UserID'"); WHERE ID = '$UserID'");
$Cache->increment('stats_user_count'); $Cache->increment('stats_user_count');
include('step2.php'); 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('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('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('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('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('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.'); $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(" $DB->query("
SELECT InviterID, Email SELECT InviterID, Email
FROM invites FROM invites
WHERE InviteKey='".db_string($_REQUEST['invite'])."'"); WHERE InviteKey = '".db_string($_REQUEST['invite'])."'");
if ($DB->record_count() == 0) { if ($DB->record_count() == 0) {
$Err = 'Invite does not exist.'; $Err = 'Invite does not exist.';
$InviterID = 0; $InviterID = 0;
@ -107,10 +107,10 @@
INSERT INTO users_main INSERT INTO users_main
(Username, Email, PassHash, torrent_pass, IP, PermissionID, Enabled, Invites, Uploaded, ipcc) (Username, Email, PassHash, torrent_pass, IP, PermissionID, Enabled, Invites, Uploaded, ipcc)
VALUES 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(); $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 // 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(" $DB->query("
@ -165,7 +165,9 @@
// If the inviter doesn't have an invite tree // 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 // Note: This should never happen unless you've transferred from another database, like What.CD did
if ($DB->record_count() == 0) { 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(); list($TreeID) = $DB->next_record();
$DB->query(" $DB->query("
@ -230,7 +232,7 @@
$TPL->set('SITE_NAME', SITE_NAME); $TPL->set('SITE_NAME', SITE_NAME);
$TPL->set('SITE_URL', SITE_URL); $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)); Tracker::update_tracker('add_user', array('id' => $UserID, 'passkey' => $torrent_pass));
$Sent = 1; $Sent = 1;

View File

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

View File

@ -7,7 +7,10 @@
$ReportID = $_POST['reportid']; $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(); list($Type) = $DB->next_record();
if (!check_perms('admin_reports')) { if (!check_perms('admin_reports')) {
if (check_perms('site_moderate_forums')) { if (check_perms('site_moderate_forums')) {
@ -23,11 +26,10 @@
$DB->query(" $DB->query("
UPDATE reports UPDATE reports
SET Status='Resolved', SET Status = 'Resolved',
ResolvedTime='".sqltime()."', ResolvedTime = '".sqltime()."',
ResolverID='".$LoggedUser['ID']."' ResolverID = '".$LoggedUser['ID']."'
WHERE ID='".db_string($ReportID)."'"); WHERE ID = '".db_string($ReportID)."'");
$Channels = array(); $Channels = array();
@ -41,12 +43,14 @@
$Cache->decrement('num_forum_reports'); $Cache->decrement('num_forum_reports');
} }
$DB->query("
$DB->query("SELECT COUNT(ID) FROM reports WHERE Status = 'New'"); SELECT COUNT(ID)
FROM reports
WHERE Status = 'New'");
list($Remaining) = $DB->next_record(); list($Remaining) = $DB->next_record();
foreach ($Channels as $Channel) { 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'); $Cache->delete_value('num_other_reports');
@ -54,12 +58,12 @@
ajax_success(); ajax_success();
function ajax_error($Error = 'error') { function ajax_error($Error = 'error') {
echo json_encode(array('status'=>$Error)); echo json_encode(array('status' => $Error));
die(); die();
} }
function ajax_success() { function ajax_success() {
echo json_encode(array("status"=>"success")); echo json_encode(array('status' => 'success'));
die(); die();
} }
?> ?>

View File

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

View File

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

View File

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

View File

@ -20,7 +20,11 @@
$Err = 'A recipient does not exist.'; $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) { if ($DB->record_count() == 0) {
error(403); error(403);
} }

View File

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

View File

@ -11,7 +11,10 @@
$ReportID = $_POST['reportid']; $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(); list($Type) = $DB->next_record();
if (!check_perms('admin_reports')) { if (!check_perms('admin_reports')) {
if (check_perms('site_moderate_forums')) { if (check_perms('site_moderate_forums')) {
@ -25,12 +28,12 @@
} }
} }
$DB->query("UPDATE reports $DB->query("
SET Status='Resolved', UPDATE reports
ResolvedTime='".sqltime()."', SET Status = 'Resolved',
ResolverID='".$LoggedUser['ID']."' ResolvedTime = '".sqltime()."',
WHERE ID='".db_string($ReportID)."'"); ResolverID = '".$LoggedUser['ID']."'
WHERE ID = '".db_string($ReportID)."'");
$Channels = array(); $Channels = array();
@ -44,12 +47,14 @@
$Cache->decrement('num_forum_reports'); $Cache->decrement('num_forum_reports');
} }
$DB->query("
$DB->query("SELECT COUNT(ID) FROM reports WHERE Status = 'New'"); SELECT COUNT(ID)
FROM reports
WHERE Status = 'New'");
list($Remaining) = $DB->next_record(); list($Remaining) = $DB->next_record();
foreach ($Channels as $Channel) { 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'); $Cache->delete_value('num_other_reports');

View File

@ -260,7 +260,7 @@
<option value="<?=$Genre?>"><?=$Genre?></option> <option value="<?=$Genre?>"><?=$Genre?></option>
<? } ?> <? } ?>
</select> </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 /> <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>". 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 /> <br /><br />

View File

@ -389,9 +389,9 @@
<tr id="tagfilter"> <tr id="tagfilter">
<td class="label">Tags (comma-separated):</td> <td class="label">Tags (comma-separated):</td>
<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="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_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="radio" name="tags_type" id="tags_type1" value="1"<? Format::selected('tags_type', 1, 'checked')?> /><label for="tags_type1"> All</label>
</td> </td>
</tr> </tr>
<tr id="include_filled"> <tr id="include_filled">

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,15 +9,17 @@
if (!is_number($_POST['id']) || $_POST['id'] == '') { if (!is_number($_POST['id']) || $_POST['id'] == '') {
error(0); 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 } 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('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('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('sort', '1', 'number', 'Sort must be set');
$Val->SetFields('categoryid', '1','number','Category must be set'); $Val->SetFields('categoryid', '1', 'number', 'Category must be set');
$Val->SetFields('minclassread', '1','number','MinClassRead must be set'); $Val->SetFields('minclassread', '1', 'number', 'MinClassRead must be set');
$Val->SetFields('minclasswrite', '1','number','MinClassWrite must be set'); $Val->SetFields('minclasswrite', '1', 'number', 'MinClassWrite must be set');
$Val->SetFields('minclasscreate', '1','number','MinClassCreate must be set'); $Val->SetFields('minclasscreate', '1', 'number', 'MinClassCreate must be set');
$Err = $Val->ValidateForm($_POST); // Validate the form $Err = $Val->ValidateForm($_POST); // Validate the form
if ($Err) { if ($Err) {
error($Err); error($Err);
@ -32,7 +34,10 @@
if (!is_number($_POST['id']) || $_POST['id'] == '') { if (!is_number($_POST['id']) || $_POST['id'] == '') {
error(0); 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) { if ($DB->record_count() < 1) {
error(404); error(404);
} else { } else {
@ -45,20 +50,22 @@
$DB->query(" $DB->query("
UPDATE forums UPDATE forums
SET SET
Sort='$P[sort]', Sort = '$P[sort]',
CategoryID='$P[categoryid]', CategoryID = '$P[categoryid]',
Name='$P[name]', Name = '$P[name]',
Description='$P[description]', Description = '$P[description]',
MinClassRead='$P[minclassread]', MinClassRead = '$P[minclassread]',
MinClassWrite='$P[minclasswrite]', MinClassWrite = '$P[minclasswrite]',
MinClassCreate='$P[minclasscreate]', MinClassCreate = '$P[minclasscreate]',
AutoLock='$P[autolock]', AutoLock = '$P[autolock]',
AutoLockWeeks='$P[autolockweeks]' AutoLockWeeks = '$P[autolockweeks]'
WHERE ID='$P[id]'"); WHERE ID = '$P[id]'");
} else { //Create } else { //Create
$DB->query("INSERT INTO forums $DB->query("
(Sort, CategoryID, Name, Description, MinClassRead, MinClassWrite, MinClassCreate, AutoLock, AutoLockWeeks) VALUES INSERT INTO forums
('$P[sort]', '$P[categoryid]', '$P[name]','$P[description]','$P[minclassread]','$P[minclasswrite]','$P[minclasscreate]','$P[autolock]','$P[autolockweeks]')"); (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']; $Name = $Class['Name'];
$Level = $Class['Level']; $Level = $Class['Level'];
$Return.='<option value="'.$Level.'"'; $Return .= "<option value=\"$Level\"";
if ($Selected == $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); reset($Classes);
return $Return; return $Return;
@ -24,14 +24,19 @@ function class_list($Selected = 0) {
} }
View::show_header('Forum Management'); 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 $ForumArray = $DB->to_array(); // used for generating the 'parent' drop down list
// Replace the old hard-coded forum categories // Replace the old hard-coded forum categories
unset($ForumCats); unset($ForumCats);
$ForumCats = $Cache->get_value('forums_categories'); $ForumCats = $Cache->get_value('forums_categories');
if ($ForumCats === false) { if ($ForumCats === false) {
$DB->query('SELECT ID, Name FROM forums_categories'); $DB->query('
SELECT ID, Name
FROM forums_categories');
$ForumCats = array(); $ForumCats = array();
while (list($ID, $Name) = $DB->next_record()) { while (list($ID, $Name) = $DB->next_record()) {
$ForumCats[$ID] = $Name; $ForumCats[$ID] = $Name;
@ -55,7 +60,7 @@ function class_list($Selected = 0) {
ORDER BY CategoryID, Sort ASC'); ORDER BY CategoryID, Sort ASC');
?> ?>
<div class="header"> <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> <h2>Forum control panel</h2>
</div> </div>
<table width="100%"> <table width="100%">
@ -67,8 +72,8 @@ function class_list($Selected = 0) {
<td>Min class read</td> <td>Min class read</td>
<td>Min class write</td> <td>Min class write</td>
<td>Min class create</td> <td>Min class create</td>
<td>Autolock</td> <td>Auto-lock</td>
<td>Autolock weeks</td> <td>Auto-lock weeks</td>
<td>Submit</td> <td>Submit</td>
</tr> </tr>
<? <?
@ -86,7 +91,7 @@ function class_list($Selected = 0) {
<? reset($ForumCats); <? reset($ForumCats);
foreach ($ForumCats as $CurCat => $CatName) { 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> </select>
</td> </td>

View File

@ -6,7 +6,7 @@
include(SERVER_ROOT.'/classes/text.class.php'); include(SERVER_ROOT.'/classes/text.class.php');
$Text = new TEXT; $Text = new TEXT;
View::show_header('Manage news','bbcode'); View::show_header('Manage news', 'bbcode');
switch ($_GET['action']) { switch ($_GET['action']) {
case 'takeeditnews': case 'takeeditnews':
@ -16,7 +16,10 @@
if (is_number($_POST['newsid'])) { if (is_number($_POST['newsid'])) {
authorize(); 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('news');
$Cache->delete_value('feed_news'); $Cache->delete_value('feed_news');
} }
@ -25,7 +28,10 @@
case 'editnews': case 'editnews':
if (is_number($_GET['id'])) { if (is_number($_GET['id'])) {
$NewsID = $_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(); list($Title, $Body) = $DB->next_record();
} }
} }

View File

@ -15,19 +15,32 @@
} }
$OldTagIDs = implode(', ', $OldTagIDs); $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']) { if ($_POST['newtag']) {
$TagName = Misc::sanitize_tag($_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(); list($TagID) = $DB->next_record();
if ($TagID) { 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 } 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(); $TagID = $DB->inserted_id();
} }
} }
@ -62,7 +75,11 @@
</tr> </tr>
<? <?
$i = 0; $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(); $TagCount = $DB->record_count();
$Tags = $DB->to_array(); $Tags = $DB->to_array();
for ($i = 0; $i < $TagCount / 3; $i++) { for ($i = 0; $i < $TagCount / 3; $i++) {

View File

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

View File

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

View File

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

View File

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

View File

@ -4,7 +4,10 @@
} }
View::show_header('Whitelist Management'); 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"> <div class="header">
<h2>Allowed Clients</h2> <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 // validate input
$Err = $Val->ValidateForm($_GET); $Err = $Val->ValidateForm($_GET);
if ($Err) { if ($Err) {
echo ' <div class="box pad center"> echo '
<div class="box pad center">
<strong>Error:</strong> '.$Err.' <strong>Error:</strong> '.$Err.'
</div>'; </div>';
} else { } else {
@ -60,8 +61,9 @@
// trying to merge tag with itself would create big problems // trying to merge tag with itself would create big problems
if ($Tag == $Replacement) { if ($Tag == $Replacement) {
echo " <div class=\"box pad center\"> echo "
<strong>Error:</strong> Cannot merge tag $Tag with itself (doh). <div class=\"box pad center\">
<strong>Error:</strong> Cannot merge tag $Tag with itself!
</div> </div>
</div>"; </div>";
View::show_footer(); View::show_footer();
@ -75,7 +77,8 @@
WHERE Name = '$Tag' WHERE Name = '$Tag'
LIMIT 1;"); LIMIT 1;");
if ($DB->record_count() == 0) { 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 <strong>Error:</strong> No such tag found: $Tag
</div> </div>
</div>"; </div>";
@ -107,9 +110,9 @@
ag.Name, ag.Name,
tg.Name tg.Name
FROM torrents_group AS tg FROM torrents_group AS tg
LEFT JOIN artists_group AS ag ON ag.ArtistID=tg.ArtistID LEFT JOIN artists_group AS ag ON ag.ArtistID = tg.ArtistID
JOIN torrents_tags AS t ON t.GroupID=tg.ID JOIN torrents_tags AS t ON t.GroupID = tg.ID
WHERE t.TagID=$TagID;"); WHERE t.TagID = $TagID;");
while (list($TorrentID, $ArtistID, $ArtistName, $TorrentName) = $DB->next_record()) { while (list($TorrentID, $ArtistID, $ArtistName, $TorrentName) = $DB->next_record()) {
$Row = ($ArtistName ? "<a href=\"artist.php?id=$ArtistID\">$ArtistName</a> - " : ''); $Row = ($ArtistName ? "<a href=\"artist.php?id=$ArtistID\">$ArtistName</a> - " : '');
$Row.= "<a href=\"torrents.php?id=$TorrentID\">".display_str($TorrentName).'</a>'; $Row.= "<a href=\"torrents.php?id=$TorrentID\">".display_str($TorrentName).'</a>';
@ -124,10 +127,10 @@
ag.Name, ag.Name,
r.Title r.Title
FROM requests AS r FROM requests AS r
LEFT JOIN requests_artists AS ra ON r.ID=ra.RequestID LEFT JOIN requests_artists AS ra ON r.ID = ra.RequestID
LEFT JOIN artists_group AS ag ON ag.ArtistID=ra.ArtistID LEFT JOIN artists_group AS ag ON ag.ArtistID = ra.ArtistID
JOIN requests_tags AS t ON t.RequestID=r.ID JOIN requests_tags AS t ON t.RequestID = r.ID
WHERE t.TagID=$TagID;"); WHERE t.TagID = $TagID;");
while (list($RequestID, $ArtistID, $ArtistName, $RequestName) = $DB->next_record()) { while (list($RequestID, $ArtistID, $ArtistName, $RequestName) = $DB->next_record()) {
$Row = ($ArtistName ? "<a href=\"artist.php?id=$ArtistID\">$ArtistName</a> - " : ''); $Row = ($ArtistName ? "<a href=\"artist.php?id=$ArtistID\">$ArtistName</a> - " : '');
$Row.= "<a href=\"requests.php?action=viewrequest&amp;id=$RequestID\">".display_str($RequestName).'</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 // HARD! merge two tags together and update usage
// 5) remove dupe tags from torrents // 5) remove dupe tags from torrents
// (torrents that have both "old tag" and "replacement tag" set) // (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 ) { if ($DB->record_count() > 0 ) {
$Query = " $Query = "
DELETE FROM torrents_tags DELETE FROM torrents_tags
WHERE TagID=$TagID WHERE TagID = $TagID
AND GroupID IN ("; AND GroupID IN (";
while (list($GroupID) = $DB->next_record()) { while (list($GroupID) = $DB->next_record()) {
$Query.= $GroupID.','; $Query .= "$GroupID,";
} }
$Query = substr($Query, 0, -1) . ');'; $Query = substr($Query, 0, -1) . ');';
$DB->query($Query); $DB->query($Query);
@ -166,19 +172,22 @@
// 6) replace old tag in torrents // 6) replace old tag in torrents
$DB->query(" $DB->query("
UPDATE torrents_tags UPDATE torrents_tags
SET TagID=$ReplacementID SET TagID = $ReplacementID
WHERE TagID=$TagID;"); WHERE TagID = $TagID;");
$UsageChange = $DB->affected_rows(); $UsageChange = $DB->affected_rows();
// 7) remove dupe tags from artists // 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 ) { if ($DB->record_count() > 0 ) {
$Query = " $Query = "
DELETE FROM artists_tags DELETE FROM artists_tags
WHERE TagID=$TagID WHERE TagID = $TagID
AND ArtistID IN ("; AND ArtistID IN (";
while (list($ArtistID) = $DB->next_record()) { while (list($ArtistID) = $DB->next_record()) {
$Query.= $ArtistID.','; $Query .= "$ArtistID,";
} }
$Query = substr($Query, 0, -1) . ');'; $Query = substr($Query, 0, -1) . ');';
$DB->query($Query); $DB->query($Query);
@ -188,19 +197,22 @@
// 8) replace old tag in artists // 8) replace old tag in artists
$DB->query(" $DB->query("
UPDATE artists_tags UPDATE artists_tags
SET TagID=$ReplacementID SET TagID = $ReplacementID
WHERE TagID=$TagID;"); WHERE TagID = $TagID;");
$UsageChange += $DB->affected_rows(); $UsageChange += $DB->affected_rows();
// 9) remove dupe tags from requests // 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) { if ($DB->record_count() > 0) {
$Query = " $Query = "
DELETE FROM requests_tags DELETE FROM requests_tags
WHERE TagID=$TagID WHERE TagID = $TagID
AND RequestID IN ("; AND RequestID IN (";
while (list($RequestID) = $DB->next_record()) { while (list($RequestID) = $DB->next_record()) {
$Query.= $RequestID.','; $Query .= "$RequestID,";
} }
$Query = substr($Query, 0, -1) . ');'; $Query = substr($Query, 0, -1) . ');';
$DB->query($Query); $DB->query($Query);
@ -210,27 +222,27 @@
// 10) replace old tag in requests // 10) replace old tag in requests
$DB->query(" $DB->query("
UPDATE requests_tags UPDATE requests_tags
SET TagID=$ReplacementID SET TagID = $ReplacementID
WHERE TagID=$TagID;"); WHERE TagID = $TagID;");
$UsageChange += $DB->affected_rows(); $UsageChange += $DB->affected_rows();
$TotalAffected += $UsageChange; $TotalAffected += $UsageChange;
// 11) finally, remove old tag completely // 11) finally, remove old tag completely
$DB->query(" $DB->query("
DELETE FROM tags DELETE FROM tags
WHERE ID=$TagID WHERE ID = $TagID
LIMIT 1"); LIMIT 1");
// 12) update usage count for replacement tag // 12) update usage count for replacement tag
$DB->query(" $DB->query("
UPDATE tags UPDATE tags
SET Uses=Uses+$UsageChange SET Uses = Uses + $UsageChange
WHERE ID=$ReplacementID WHERE ID = $ReplacementID
LIMIT 1"); LIMIT 1");
} // if ($Mode == MODE_MERGE) } // 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']) { if ($_GET['list']) {
?> ?>
@ -244,7 +256,7 @@
<? <?
if (count($AffectedTorrents)) { if (count($AffectedTorrents)) {
foreach ($AffectedTorrents as $Row) { 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)) { if (count($AffectedRequests)) {
foreach ($AffectedRequests as $Row) { 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')) { ?> <? } 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> <tr><td><a href="tools.php?action=rerender_gallery">Rerender stylesheet gallery images</a></td></tr>
<? } if (check_perms('users_mod')) { ?> <? } 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> <tr><td><strong><a href="tools.php?action=public_sandbox">Public sandbox</a></strong></td></tr>
<? } if (check_perms('users_mod')) { ?> <? } if (check_perms('users_mod')) { ?>
<tr><td><strong><a href="tools.php?action=mod_sandbox">Mod-level sandbox</a></strong></td></tr> <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') { if (empty($_GET['datetype']) || $_GET['datetype'] == 'day') {
$Type = '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 { } else {
$Type = 'week'; $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) { if ($Details === false) {
$DB->query("SELECT $DB->query("
SELECT
tht.Rank, tht.Rank,
tht.TitleString, tht.TitleString,
tht.TagString, tht.TagString,
@ -83,12 +88,12 @@
LEFT JOIN top10_history_torrents AS tht ON tht.HistoryID = th.ID 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 AS t ON t.ID = tht.TorrentID
LEFT JOIN torrents_group AS g ON g.ID = t.GroupID LEFT JOIN torrents_group AS g ON g.ID = t.GroupID
".$Where." $Where
ORDER BY tht.Rank ASC"); ORDER BY tht.Rank ASC");
$Details = $DB->to_array(); $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> </tr>
<? <?
foreach ($Details as $Detail) : foreach ($Details as $Detail) :
list($Rank, $TitleString, $TagString, $TorrentID, $GroupID,$GroupName,$GroupCategoryID,$TorrentTags, list($Rank, $TitleString, $TagString, $TorrentID, $GroupID, $GroupName, $GroupCategoryID, $TorrentTags,
$Format,$Encoding,$Media,$Scene,$HasLog,$HasCue,$LogScore,$Year,$GroupYear, $Format, $Encoding, $Media, $Scene, $HasLog, $HasCue, $LogScore, $Year, $GroupYear,
$RemasterTitle,$Snatched,$Seeders,$Leechers,$Data) = $Detail; $RemasterTitle, $Snatched, $Seeders, $Leechers, $Data) = $Detail;
// highlight every other row // highlight every other row
$Highlight = ($Rank % 2 ? 'a' : 'b'); $Highlight = ($Rank % 2 ? 'a' : 'b');
if ($GroupID) : if ($GroupID) :
//Group still exists // Group still exists
$DisplayName=''; $DisplayName = '';
$Artists = Artists::get_artist($GroupID); $Artists = Artists::get_artist($GroupID);
@ -123,43 +128,43 @@
$DisplayName .= "<a href=\"torrents.php?id=$GroupID&amp;torrentid=$TorrentID\" title=\"View Torrent\">$GroupName</a>"; $DisplayName .= "<a href=\"torrents.php?id=$GroupID&amp;torrentid=$TorrentID\" title=\"View Torrent\">$GroupName</a>";
if ($GroupCategoryID == 1 && $GroupYear > 0) { if ($GroupCategoryID == 1 && $GroupYear > 0) {
$DisplayName.= " [$GroupYear]"; $DisplayName .= " [$GroupYear]";
} }
// append extra info to torrent title // append extra info to torrent title
$ExtraInfo = ''; $ExtraInfo = '';
$AddExtra = ''; $AddExtra = '';
if ($Format) { if ($Format) {
$ExtraInfo.= $Format; $ExtraInfo .= $Format;
$AddExtra = ' / '; $AddExtra = ' / ';
} }
if ($Encoding) { if ($Encoding) {
$ExtraInfo.= $AddExtra.$Encoding; $ExtraInfo .= $AddExtra.$Encoding;
$AddExtra = ' / '; $AddExtra = ' / ';
} }
//"FLAC / Lossless / Log (100%) / Cue / CD"; //"FLAC / Lossless / Log (100%) / Cue / CD";
if ($HasLog) { if ($HasLog) {
$ExtraInfo.= "$AddExtra Log ($LogScore".'%)'; $ExtraInfo .= "$AddExtra Log ($LogScore%)";
$AddExtra = ' / '; $AddExtra = ' / ';
} }
if ($HasCue) { if ($HasCue) {
$ExtraInfo.= $AddExtra.'Cue'; $ExtraInfo .= "{$AddExtra}Cue";
$AddExtra = ' / '; $AddExtra = ' / ';
} }
if ($Media) { if ($Media) {
$ExtraInfo.= $AddExtra.$Media; $ExtraInfo .= $AddExtra.$Media;
$AddExtra = ' / '; $AddExtra = ' / ';
} }
if ($Scene) { if ($Scene) {
$ExtraInfo.= $AddExtra.'Scene'; $ExtraInfo .= "{$AddExtra}Scene";
$AddExtra = ' / '; $AddExtra = ' / ';
} }
if ($Year > 0) { if ($Year > 0) {
$ExtraInfo.= $AddExtra.$Year; $ExtraInfo .= $AddExtra.$Year;
$AddExtra = ' '; $AddExtra = ' ';
} }
if ($RemasterTitle) { if ($RemasterTitle) {
$ExtraInfo.= $AddExtra.$RemasterTitle; $ExtraInfo .= $AddExtra.$RemasterTitle;
} }
if ($ExtraInfo != '') { if ($ExtraInfo != '') {
$ExtraInfo = "- [$ExtraInfo]"; $ExtraInfo = "- [$ExtraInfo]";
@ -168,7 +173,7 @@
$DisplayName .= $ExtraInfo; $DisplayName .= $ExtraInfo;
$TorrentTags = new Tags($TorrentTags); $TorrentTags = new Tags($TorrentTags);
else: else:
$DisplayName = $TitleString.' (Deleted)'; $DisplayName = "$TitleString (Deleted)";
$TorrentTags = new Tags($TagString); $TorrentTags = new Tags($TagString);
endif; endif;

View File

@ -68,7 +68,7 @@
<tr id="tagfilter"> <tr id="tagfilter">
<td class="label">Tags (comma-separated):</td> <td class="label">Tags (comma-separated):</td>
<td class="ft_taglist"> <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="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> <input type="radio" id="rdoAny" name="anyall" value="any"<?=($_GET['anyall']=='any'?' checked="checked"':'')?> /><label for="rdoAny"> Any</label>
</td> </td>

View File

@ -16,12 +16,15 @@
$AliasName = Artists::normalise_artist_name($AliasNames[$i]); $AliasName = Artists::normalise_artist_name($AliasNames[$i]);
$Importance = $Importances[$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; break;
} }
if (strlen($AliasName) > 0) { 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)) { while (list($AliasID, $ArtistID, $Redirect, $FoundAliasName) = $DB->next_record(MYSQLI_NUM, false)) {
if (!strcasecmp($AliasName, $FoundAliasName)) { if (!strcasecmp($AliasName, $FoundAliasName)) {
if ($Redirect) { if ($Redirect) {
@ -32,43 +35,56 @@
} }
if (!$AliasID) { if (!$AliasID) {
$AliasName = db_string($AliasName); $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(); $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(); $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); 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); list($ArtistName) = $DB->next_record(MYSQLI_NUM, false);
$DB->query("INSERT IGNORE INTO torrents_artists $DB->query("
(GroupID, ArtistID, AliasID, Importance, UserID) VALUES INSERT IGNORE INTO torrents_artists
('$GroupID', '$ArtistID', '$AliasID', '$Importance', '$UserID')"); (GroupID, ArtistID, AliasID, Importance, UserID)
VALUES
('$GroupID', '$ArtistID', '$AliasID', '$Importance', '$UserID')");
if ($DB->affected_rows()) { if ($DB->affected_rows()) {
$Changed = true; $Changed = true;
$DB->query("INSERT INTO torrents_group (ID, NumArtists) $DB->query("
INSERT INTO torrents_group (ID, NumArtists)
SELECT ta.GroupID, COUNT(ta.ArtistID) SELECT ta.GroupID, COUNT(ta.ArtistID)
FROM torrents_artists AS ta FROM torrents_artists AS ta
WHERE ta.GroupID='$GroupID' WHERE ta.GroupID = '$GroupID'
AND ta.Importance='1' AND ta.Importance = '1'
GROUP BY ta.GroupID GROUP BY ta.GroupID
ON DUPLICATE KEY UPDATE 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'].")"); 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); Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "added artist $ArtistName as ".$ArtistTypes[$Importance], 0);
} }
} }
} }
if ($Changed) { if ($Changed) {
$Cache->delete_value('torrents_details_'.$GroupID); $Cache->delete_value("torrents_details_$GroupID");
$Cache->delete_value('groups_artists_'.$GroupID); // Delete group artist cache $Cache->delete_value("groups_artists_$GroupID"); // Delete group artist cache
Torrents::update_hash($GroupID); Torrents::update_hash($GroupID);
} }

View File

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

View File

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

View File

@ -10,47 +10,60 @@
error(403); error(403);
} }
$DB->query("DELETE FROM torrents_artists WHERE GroupID='$GroupID' AND ArtistID='$ArtistID' AND Importance='$Importance'"); $DB->query("
$DB->query("SELECT Name FROM artists_group WHERE ArtistID=".$ArtistID); 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); 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); list($GroupName) = $DB->next_record(MYSQLI_NUM, false);
//Get a count of how many groups or requests use this artist ID // Get a count of how many groups or requests use this artist ID
$DB->query("SELECT ag.ArtistID $DB->query("
FROM artists_group as ag SELECT ag.ArtistID
LEFT JOIN requests_artists AS ra ON ag.ArtistID=ra.ArtistID FROM artists_group as ag
WHERE ra.ArtistID IS NOT NULL LEFT JOIN requests_artists AS ra ON ag.ArtistID = ra.ArtistID
AND ag.ArtistID = ".$ArtistID); WHERE ra.ArtistID IS NOT NULL
AND ag.ArtistID = $ArtistID");
$ReqCount = $DB->record_count(); $ReqCount = $DB->record_count();
$DB->query("SELECT ag.ArtistID $DB->query("
FROM artists_group as ag SELECT ag.ArtistID
LEFT JOIN torrents_artists AS ta ON ag.ArtistID=ta.ArtistID FROM artists_group as ag
WHERE ta.ArtistID IS NOT NULL LEFT JOIN torrents_artists AS ta ON ag.ArtistID = ta.ArtistID
AND ag.ArtistID = ".$ArtistID); WHERE ta.ArtistID IS NOT NULL
AND ag.ArtistID = $ArtistID");
$GroupCount = $DB->record_count(); $GroupCount = $DB->record_count();
if (($ReqCount + $GroupCount) == 0) { if (($ReqCount + $GroupCount) == 0) {
//The only group to use this artist // The only group to use this artist
Artists::delete_artist($ArtistID); 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) SELECT ta.GroupID, COUNT(ta.ArtistID)
FROM torrents_artists AS ta FROM torrents_artists AS ta
WHERE ta.GroupID='$GroupID' WHERE ta.GroupID = '$GroupID'
AND ta.Importance='1' AND ta.Importance = '1'
GROUP BY ta.GroupID GROUP BY ta.GroupID
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
NumArtists=VALUES(NumArtists);"); NumArtists = VALUES (NumArtists);");
$Cache->delete_value('torrents_details_'.$GroupID); // Delete torrent group cache $Cache->delete_value("torrents_details_$GroupID"); // Delete torrent group cache
$Cache->delete_value('groups_artists_'.$GroupID); // Delete group artist 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'].")"); 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::write_group_log($GroupID, 0, $LoggedUser['ID'], "removed artist $ArtistName (".$ArtistTypes[$Importance].')', 0);
Torrents::update_hash($GroupID); Torrents::update_hash($GroupID);
$Cache->delete_value('artist_groups_'.$ArtistID); $Cache->delete_value("artist_groups_$ArtistID");
header('Location: '.$_SERVER['HTTP_REFERER']); 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="action" value="add_alias" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" /> <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="groupid" value="<?=$GroupID?>" /> <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[]"> <select name="importance[]">
<option value="1">Main</option> <option value="1">Main</option>
<option value="2">Guest</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="action" value="add_tag" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" /> <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="groupid" value="<?=$GroupID?>" /> <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="+" /> <input type="submit" value="+" />
</form> </form>
<br /><br /> <br /><br />
@ -546,7 +546,8 @@ function filelist($Str) {
unset($ReportedTimes); unset($ReportedTimes);
$Reports = $Cache->get_value('reports_torrent_'.$TorrentID); $Reports = $Cache->get_value('reports_torrent_'.$TorrentID);
if ($Reports === false) { if ($Reports === false) {
$DB->query("SELECT r.ID, $DB->query("
SELECT r.ID,
r.ReporterID, r.ReporterID,
r.Type, r.Type,
r.UserComment, r.UserComment,
@ -556,12 +557,12 @@ function filelist($Str) {
AND Type != 'edited' AND Type != 'edited'
AND Status != 'Resolved'"); AND Status != 'Resolved'");
$Reports = $DB->to_array(); $Reports = $DB->to_array();
$Cache->cache_value('reports_torrent_'.$TorrentID, $Reports, 0); $Cache->cache_value("reports_torrent_$TorrentID", $Reports, 0);
} }
if (count($Reports) > 0) { if (count($Reports) > 0) {
$Reported = true; $Reported = true;
include(SERVER_ROOT.'/sections/reportsv2/array.php'); 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) { foreach ($Reports as $Report) {
list($ReportID, $ReporterID, $ReportType, $ReportReason, $ReportedTime) = $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! //There was a type but it wasn't an option!
$ReportType = $Types['master']['other']; $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 .= "\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 .= "<blockquote>".$Text->full_format($ReportReason)."</blockquote></td></tr>"; $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))); $CanEdit = (check_perms('torrents_edit') || (($UserID == $LoggedUser['ID'] && !$LoggedUser['DisableWiki']) && !($Remastered && !$RemasterYear)));
@ -589,7 +590,7 @@ function filelist($Str) {
$FileTable = ' $FileTable = '
<table class="filelist_table"> <table class="filelist_table">
<tr class="colhead_dark"><td> <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> <div class="filelist_path" style="float: right;">' . ($FilePath ? "/$FilePath/" : '') . '</div>
</td><td> </td><td>
<strong>Size</strong> <strong>Size</strong>
@ -733,7 +734,7 @@ function filelist($Str) {
<div id="reported_<?=$TorrentID?>" class="hidden"><?=$ReportInfo?></div> <div id="reported_<?=$TorrentID?>" class="hidden"><?=$ReportInfo?></div>
<? } <? }
if (!empty($Description)) { if (!empty($Description)) {
echo '<blockquote>'.$Text->full_format($Description).'</blockquote>';} echo "\n<blockquote>".$Text->full_format($Description).'</blockquote>';}
?> ?>
</td> </td>
</tr> </tr>

View File

@ -8,18 +8,17 @@
} else { } else {
$UserInfo = $Cache->get_value('user_'.$_REQUEST['torrent_pass']); $UserInfo = $Cache->get_value('user_'.$_REQUEST['torrent_pass']);
if (!is_array($UserInfo)) { if (!is_array($UserInfo)) {
$DB->query("SELECT $DB->query("
ID, SELECT ID, DownloadAlt
DownloadAlt
FROM users_main AS m FROM users_main AS m
INNER JOIN users_info AS i ON i.UserID=m.ID INNER JOIN users_info AS i ON i.UserID = m.ID
WHERE m.torrent_pass='".db_string($_REQUEST['torrent_pass'])."' WHERE m.torrent_pass = '".db_string($_REQUEST['torrent_pass'])."'
AND m.Enabled='1'"); AND m.Enabled = '1'");
$UserInfo = $DB->next_record(); $UserInfo = $DB->next_record();
$Cache->cache_value('user_'.$_REQUEST['torrent_pass'], $UserInfo, 3600); $Cache->cache_value('user_'.$_REQUEST['torrent_pass'], $UserInfo, 3600);
} }
$UserInfo = array($UserInfo); $UserInfo = array($UserInfo);
list($UserID,$DownloadAlt)=array_shift($UserInfo); list($UserID, $DownloadAlt) = array_shift($UserInfo);
if (!$UserID) { if (!$UserID) {
error(0); error(0);
} }
@ -35,47 +34,53 @@
error(0); error(0);
} }
/* uTorrent remote redownloads .torrent files every fifteen minutes /* uTorrent Remote redownloads .torrent files every fifteen minutes.
to prevent this retardation from blowing bandwidth etc., let's block it To prevent this retardation from blowing bandwidth etc., let's block it
if he's downloaded the .torrent file twice before */ if he has downloaded the .torrent file twice before */
if (strpos($_SERVER['HTTP_USER_AGENT'], 'BTWebClient') !== false) { 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) { 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(); die();
} }
} }
$Info = $Cache->get_value('torrent_download_'.$TorrentID); $Info = $Cache->get_value('torrent_download_'.$TorrentID);
if (!is_array($Info) || !array_key_exists('PlainArtists', $Info) || empty($Info[10])) { if (!is_array($Info) || !array_key_exists('PlainArtists', $Info) || empty($Info[10])) {
$DB->query("SELECT $DB->query("
t.Media, SELECT
t.Format, t.Media,
t.Encoding, t.Format,
IF(t.RemasterYear=0,tg.Year,t.RemasterYear), t.Encoding,
tg.ID AS GroupID, IF(t.RemasterYear = 0, tg.Year, t.RemasterYear),
tg.Name, tg.ID AS GroupID,
tg.WikiImage, tg.Name,
tg.CategoryID, tg.WikiImage,
t.Size, tg.CategoryID,
t.FreeTorrent, t.Size,
t.info_hash t.FreeTorrent,
t.info_hash
FROM torrents AS t FROM torrents AS t
INNER JOIN torrents_group AS tg ON tg.ID=t.GroupID INNER JOIN torrents_group AS tg ON tg.ID = t.GroupID
WHERE t.ID='".db_string($TorrentID)."'"); WHERE t.ID = '".db_string($TorrentID)."'");
if ($DB->record_count() < 1) { if ($DB->record_count() < 1) {
error(404); error(404);
} }
$Info = array($DB->next_record(MYSQLI_NUM, array(4,5,6,10))); $Info = array($DB->next_record(MYSQLI_NUM, array(4, 5, 6, 10)));
$Artists = Artists::get_artist($Info[0][4],false); $Artists = Artists::get_artist($Info[0][4], false);
$Info['Artists'] = Artists::display_artists($Artists, false, true); $Info['Artists'] = Artists::display_artists($Artists, false, true);
$Info['PlainArtists'] = Artists::display_artists($Artists, false, true, false); $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])) { if (!is_array($Info[0])) {
error(404); 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']; $Artists = $Info['Artists'];
// If he's trying use a token on this, we need to make sure he has one, // 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 (!Torrents::has_token($TorrentID)) {
if ($FLTokens <= 0) { 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) { 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 // Let the tracker know about this
if (!Tracker::update_tracker('add_token', array('info_hash' => rawurlencode($InfoHash), 'userid' => $UserID))) { 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)) { if (!Torrents::has_token($TorrentID)) {
$DB->query("INSERT INTO users_freeleeches (UserID, TorrentID, Time) VALUES ($UserID, $TorrentID, NOW()) $DB->query("
ON DUPLICATE KEY UPDATE Time=VALUES(Time), Expired=FALSE, Uses=Uses+1"); INSERT INTO users_freeleeches (UserID, TorrentID, Time)
$DB->query("UPDATE users_main SET FLTokens = FLTokens - 1 WHERE ID=$UserID"); 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 // Fix for downloadthemall messing with the cached token count
$UInfo = Users::user_heavy_info($UserID); $UInfo = Users::user_heavy_info($UserID);
$FLTokens = $UInfo['FLTokens']; $FLTokens = $UInfo['FLTokens'];
$Cache->begin_transaction('user_info_heavy_'.$UserID); $Cache->begin_transaction("user_info_heavy_$UserID");
$Cache->update_row(false, array('FLTokens'=>($FLTokens - 1))); $Cache->update_row(false, array('FLTokens' => ($FLTokens - 1)));
$Cache->commit_transaction(0); $Cache->commit_transaction(0);
$Cache->delete_value('users_tokens_'.$UserID); $Cache->delete_value("users_tokens_$UserID");
} }
} }
} }
//Stupid Recent Snatches On User Page //Stupid Recent Snatches On User Page
if ($CategoryID == '1' && $Image != '') { if ($CategoryID == '1' && $Image != '') {
$RecentSnatches = $Cache->get_value('recent_snatches_'.$UserID); $RecentSnatches = $Cache->get_value("recent_snatches_$UserID");
if (!empty($RecentSnatches)) { 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 (!in_array($Snatch, $RecentSnatches)) {
if (count($RecentSnatches) == 5) { if (count($RecentSnatches) == 5) {
array_pop($RecentSnatches); array_pop($RecentSnatches);
@ -141,7 +158,7 @@
} elseif (!is_array($RecentSnatches)) { } elseif (!is_array($RecentSnatches)) {
$RecentSnatches = array($Snatch); $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) INSERT IGNORE INTO users_downloads (UserID, TorrentID, Time)
VALUES ('$UserID', '$TorrentID', '".sqltime()."')"); 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); list($Contents) = $DB->next_record(MYSQLI_NUM, false);
$FileName = TorrentsDL::construct_file_name($Info['PlainArtists'], $Name, $Year, $Media, $Format, $Encoding, false, $DownloadAlt); $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 //Everything is legit, let's just confim they're not retarded
if (empty($_POST['confirm'])) { 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) { if ($DB->record_count() < 1) {
//Trying to move to an empty group? I think not! //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']); header('Location: '.$_SERVER['HTTP_REFERER']);
die(); die();
} }
list($Name) = $DB->next_record(); 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(); list($CategoryID, $NewName) = $DB->next_record();
if ($Categories[$CategoryID-1] != 'Music') { if ($Categories[$CategoryID - 1] != 'Music') {
error('Target must be a music group.'); error('Target must be a music group.');
} }
@ -54,9 +60,13 @@
<input type="hidden" name="oldgroupid" value="<?=$OldGroupID?>" /> <input type="hidden" name="oldgroupid" value="<?=$OldGroupID?>" />
<input type="hidden" name="groupid" value="<?=$GroupID?>" /> <input type="hidden" name="groupid" value="<?=$GroupID?>" />
<h3>You are attempting to move the torrent with ID <?=$TorrentID?> from the group:</h3> <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> <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" /> <input type="submit" value="Confirm" />
</form> </form>
</div> </div>
@ -67,16 +77,22 @@
authorize(); authorize();
$DB->query("UPDATE torrents $DB->query("UPDATE torrents
SET GroupID='$GroupID' SET GroupID = '$GroupID'
WHERE ID=$TorrentID"); WHERE ID = $TorrentID");
// Delete old torrent group if it's empty now // 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(); list($TorrentsInGroup) = $DB->next_record();
if ($TorrentsInGroup == 0) { if ($TorrentsInGroup == 0) {
$DB->query("UPDATE torrents_comments SET GroupID='$GroupID' WHERE GroupID='$OldGroupID'"); $DB->query("
$Cache->delete_value('torrent_comments_'.$GroupID.'_catalogue_0'); UPDATE torrents_comments
$Cache->delete_value('torrent_comments_'.$GroupID); SET GroupID = '$GroupID'
WHERE GroupID = '$OldGroupID'");
$Cache->delete_value("torrent_comments_{$GroupID}_catalogue_0");
$Cache->delete_value("torrent_comments_$GroupID");
Torrents::delete_group($OldGroupID); Torrents::delete_group($OldGroupID);
} else { } else {
Torrents::update_hash($OldGroupID); Torrents::update_hash($OldGroupID);
@ -84,11 +100,14 @@
Torrents::update_hash($GroupID); Torrents::update_hash($GroupID);
Misc::write_log("Torrent $TorrentID was edited by " . $LoggedUser['Username']); // TODO: this is probably broken 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); Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "merged group $OldGroupID", 0);
$DB->query("UPDATE group_log SET GroupID = ".$GroupID." WHERE GroupID = ".$OldGroupID); $DB->query("
UPDATE group_log
SET GroupID = $GroupID
WHERE GroupID = $OldGroupID");
$Cache->delete_value('torrents_details_'.$GroupID); $Cache->delete_value("torrents_details_$GroupID");
$Cache->delete_value('torrent_download_'.$TorrentID); $Cache->delete_value("torrent_download_$TorrentID");
header("Location: torrents.php?id=$GroupID"); 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)) { if ($RevisionID || !is_array($TorrentCache) || isset($OutdatedCache)) {
// Fetch the group details // Fetch the group details
$SQL = "SELECT "; $SQL = 'SELECT ';
if (!$RevisionID) { if (!$RevisionID) {
$SQL .= " $SQL .= '
g.WikiBody, g.WikiBody,
g.WikiImage, "; g.WikiImage, ';
} else { } else {
$SQL .= " $SQL .= '
w.Body, w.Body,
w.Image, "; w.Image, ';
} }
$SQL .= " $SQL .= "
@ -45,16 +45,17 @@ function get_group_info($GroupID, $Return = true, $RevisionID = 0, $PersonalProp
GROUP_CONCAT(tt.PositiveVotes SEPARATOR '|'), GROUP_CONCAT(tt.PositiveVotes SEPARATOR '|'),
GROUP_CONCAT(tt.NegativeVotes SEPARATOR '|') GROUP_CONCAT(tt.NegativeVotes SEPARATOR '|')
FROM torrents_group AS g FROM torrents_group AS g
LEFT JOIN torrents_tags AS tt ON tt.GroupID=g.ID LEFT JOIN torrents_tags AS tt ON tt.GroupID = g.ID
LEFT JOIN tags ON tags.ID=tt.TagID"; LEFT JOIN tags ON tags.ID = tt.TagID";
if ($RevisionID) { if ($RevisionID) {
$SQL .= " $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 .= " $SQL .= "
WHERE g.ID='".db_string($GroupID)."' WHERE g.ID = '".db_string($GroupID)."'
GROUP BY NULL"; GROUP BY NULL";
$DB->query($SQL); $DB->query($SQL);
@ -100,14 +101,14 @@ function get_group_info($GroupID, $Return = true, $RevisionID = 0, $PersonalProp
tln.TorrentID AS LogInDB, tln.TorrentID AS LogInDB,
t.ID AS HasFile t.ID AS HasFile
FROM torrents AS t FROM torrents AS t
LEFT JOIN torrents_bad_tags AS tbt ON tbt.TorrentID=t.ID 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_folders AS tbf on tbf.TorrentID = t.ID
LEFT JOIN torrents_bad_files AS tfi on tfi.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_cassette_approved AS ca on ca.TorrentID = t.ID
LEFT JOIN torrents_lossymaster_approved AS lma on lma.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_lossyweb_approved AS lwa on lwa.TorrentID = t.ID
LEFT JOIN torrents_logs_new AS tln ON tln.TorrentID=t.ID LEFT JOIN torrents_logs_new AS tln ON tln.TorrentID = t.ID
WHERE t.GroupID='".db_string($GroupID)."' WHERE t.GroupID = '".db_string($GroupID)."'
GROUP BY t.ID GROUP BY t.ID
ORDER BY t.Remastered ASC, ORDER BY t.Remastered ASC,
(t.RemasterYear != 0) DESC, (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); $TorrentList = $DB->to_array('ID', MYSQLI_ASSOC);
if (count($TorrentList) == 0 && $ApiCall == false) { 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(); die();
} else if (count($TorrentList) == 0 && $ApiCall == true) { } else if (count($TorrentList) == 0 && $ApiCall == true) {
return NULL; return NULL;
@ -134,7 +135,7 @@ function get_group_info($GroupID, $Return = true, $RevisionID = 0, $PersonalProp
} }
// Store it all in cache // Store it all in cache
if (!$RevisionID) { 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 } else { // If we're reading from cache
$TorrentDetails = $TorrentCache[0]; $TorrentDetails = $TorrentCache[0];
@ -188,7 +189,10 @@ function is_valid_torrenthash($Str) {
function torrenthash_to_torrentid($Str) { function torrenthash_to_torrentid($Str) {
global $Cache, $DB; 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)); $TorrentID = (int)array_pop($DB->next_record(MYSQLI_ASSOC));
if ($TorrentID) { if ($TorrentID) {
return $TorrentID; return $TorrentID;
@ -198,7 +202,10 @@ function torrenthash_to_torrentid($Str) {
function torrenthash_to_groupid($Str) { function torrenthash_to_groupid($Str) {
global $Cache, $DB; 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)); $GroupID = (int)array_pop($DB->next_record(MYSQLI_ASSOC));
if ($GroupID) { if ($GroupID) {
return $GroupID; return $GroupID;
@ -208,7 +215,10 @@ function torrenthash_to_groupid($Str) {
function torrentid_to_groupid($TorrentID) { function torrentid_to_groupid($TorrentID) {
global $Cache, $DB; 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)); $GroupID = (int)array_pop($DB->next_record(MYSQLI_ASSOC));
if ($GroupID) { if ($GroupID) {
return $GroupID; return $GroupID;
@ -219,7 +229,14 @@ function torrentid_to_groupid($TorrentID) {
//After adjusting / deleting logs, recalculate the score for the torrent. //After adjusting / deleting logs, recalculate the score for the torrent.
function set_torrent_logscore($TorrentID) { function set_torrent_logscore($TorrentID) {
global $DB; 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) { function get_group_requests($GroupID) {
@ -228,11 +245,15 @@ function get_group_requests($GroupID) {
} }
global $DB, $Cache; global $DB, $Cache;
$Requests = $Cache->get_value('requests_group_'.$GroupID); $Requests = $Cache->get_value("requests_group_$GroupID");
if ($Requests === false) { 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'); $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); $Requests = Requests::get_requests($Requests);
return $Requests['matches']; 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. //Used to get reports info on a unison cache in both browsing pages and torrent pages.
function get_reports($TorrentID) { function get_reports($TorrentID) {
global $Cache, $DB; global $Cache, $DB;
$Reports = $Cache->get_value('reports_torrent_' . $TorrentID); $Reports = $Cache->get_value("reports_torrent_$TorrentID");
if ($Reports === false) { if ($Reports === false) {
$DB->query(" $DB->query("
SELECT SELECT
@ -255,7 +276,7 @@ function get_reports($TorrentID) {
AND Type != 'edited' AND Type != 'edited'
AND Status != 'Resolved'"); AND Status != 'Resolved'");
$Reports = $DB->to_array(); $Reports = $DB->to_array();
$Cache->cache_value('reports_torrent_' . $TorrentID, $Reports, 0); $Cache->cache_value("reports_torrent_$TorrentID", $Reports, 0);
} }
return $Reports; 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 build_torrents_table($Cache, $DB, $LoggedUser, $GroupID, $GroupName, $GroupCategoryID, $ReleaseType, $TorrentList, $Types, $Text, $Username, $ReportedTimes) {
function filelist($Str) { 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 = '-'; $LastRemasterYear = '-';
@ -295,7 +316,7 @@ function filelist($Str) {
$Reported = false; $Reported = false;
unset($ReportedTimes); unset($ReportedTimes);
$Reports = $Cache->get_value('reports_torrent_' . $TorrentID); $Reports = $Cache->get_value("reports_torrent_$TorrentID");
if ($Reports === false) { if ($Reports === false) {
$DB->query(" $DB->query("
SELECT SELECT
@ -309,31 +330,31 @@ function filelist($Str) {
AND Type != 'edited' AND Type != 'edited'
AND Status != 'Resolved'"); AND Status != 'Resolved'");
$Reports = $DB->to_array(); $Reports = $DB->to_array();
$Cache->cache_value('reports_torrent_' . $TorrentID, $Reports, 0); $Cache->cache_value("reports_torrent_$TorrentID", $Reports, 0);
} }
if (count($Reports) > 0) { if (count($Reports) > 0) {
$Reported = true; $Reported = true;
include(SERVER_ROOT . '/sections/reportsv2/array.php'); 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) { foreach ($Reports as $Report) {
list($ReportID, $ReporterID, $ReportType, $ReportReason, $ReportedTime) = $Report; list($ReportID, $ReporterID, $ReportType, $ReportReason, $ReportedTime) = $Report;
$Reporter = Users::user_info($ReporterID); $Reporter = Users::user_info($ReporterID);
$ReporterName = $Reporter['Username']; $ReporterName = $Reporter['Username'];
if (array_key_exists($ReportType, $Types[$GroupCategoryID])) { if (array_key_exists($ReportType, $Types[$GroupCategoryID])) {
$ReportType = $Types[$GroupCategoryID][$ReportType]; $ReportType = $Types[$GroupCategoryID][$ReportType];
} else if (array_key_exists($ReportType, $Types['master'])) { } else if (array_key_exists($ReportType, $Types['master'])) {
$ReportType = $Types['master'][$ReportType]; $ReportType = $Types['master'][$ReportType];
} else { } else {
//There was a type but it wasn't an option! //There was a type but it wasn't an option!
$ReportType = $Types['master']['other']; $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 .= "\n</table>";
$ReportInfo .= '<blockquote>' . $Text->full_format($ReportReason) . '</blockquote></td></tr>';
}
$ReportInfo .= '</table>';
} }
$CanEdit = (check_perms('torrents_edit') || (($UserID == $LoggedUser['ID'] && !$LoggedUser['DisableWiki']) && !($Remastered && !$RemasterYear))); $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 $TorrentUploader = $Username; // Save this for "Uploaded by:" below
// similar to Torrents::torrent_info() // similar to Torrents::torrent_info()
if ($Format) { if ($Format) {
$ExtraInfo.=display_str($Format); $ExtraInfo .= display_str($Format);
$AddExtra = ' / '; $AddExtra = ' / ';
} }
if ($Encoding) { if ($Encoding) {
$ExtraInfo.=$AddExtra . display_str($Encoding); $ExtraInfo .= $AddExtra . display_str($Encoding);
$AddExtra = ' / '; $AddExtra = ' / ';
} }
if ($HasLog) { if ($HasLog) {
$ExtraInfo.=$AddExtra . 'Log'; $ExtraInfo .= "{$AddExtra}Log";
$AddExtra = ' / '; $AddExtra = ' / ';
} }
if ($HasLog && $LogInDB) { if ($HasLog && $LogInDB) {
$ExtraInfo.=' (' . (int) $LogScore . '%)'; $ExtraInfo .= ' (' . (int) $LogScore . '%)';
} }
if ($HasCue) { if ($HasCue) {
$ExtraInfo.=$AddExtra . 'Cue'; $ExtraInfo .= "{$AddExtra}Cue";
$AddExtra = ' / '; $AddExtra = ' / ';
} }
if ($Scene) { if ($Scene) {
$ExtraInfo.=$AddExtra . 'Scene'; $ExtraInfo .= "{$AddExtra}Scene";
$AddExtra = ' / '; $AddExtra = ' / ';
} }
if (!$ExtraInfo) { if (!$ExtraInfo) {
@ -404,47 +425,47 @@ function filelist($Str) {
$AddExtra = ' / '; $AddExtra = ' / ';
} }
if ($IsSnatched) { if ($IsSnatched) {
$ExtraInfo.=$AddExtra . Format::torrent_label('Snatched!'); $ExtraInfo .= $AddExtra . Format::torrent_label('Snatched!');
$AddExtra = ' / '; $AddExtra = ' / ';
} }
if ($FreeTorrent == '1') { if ($FreeTorrent == '1') {
$ExtraInfo.=$AddExtra . Format::torrent_label('Freeleech!'); $ExtraInfo .= $AddExtra . Format::torrent_label('Freeleech!');
$AddExtra = ' / '; $AddExtra = ' / ';
} }
if ($FreeTorrent == '2') { if ($FreeTorrent == '2') {
$ExtraInfo.=$AddExtra . Format::torrent_label('Neutral Leech!'); $ExtraInfo .= $AddExtra . Format::torrent_label('Neutral Leech!');
$AddExtra = ' / '; $AddExtra = ' / ';
} }
if ($PersonalFL) { if ($PersonalFL) {
$ExtraInfo.=$AddExtra . Format::torrent_label('Personal Freeleech!'); $ExtraInfo .= $AddExtra . Format::torrent_label('Personal Freeleech!');
$AddExtra = ' / '; $AddExtra = ' / ';
} }
if ($Reported) { if ($Reported) {
$ExtraInfo.=$AddExtra . Format::torrent_label('Reported'); $ExtraInfo .= $AddExtra . Format::torrent_label('Reported');
$AddExtra = ' / '; $AddExtra = ' / ';
} }
if (!empty($BadTags)) { if (!empty($BadTags)) {
$ExtraInfo.=$AddExtra . Format::torrent_label('Bad Tags'); $ExtraInfo .= $AddExtra . Format::torrent_label('Bad Tags');
$AddExtra = ' / '; $AddExtra = ' / ';
} }
if (!empty($BadFolders)) { if (!empty($BadFolders)) {
$ExtraInfo.=$AddExtra . Format::torrent_label('Bad Folders'); $ExtraInfo .= $AddExtra . Format::torrent_label('Bad Folders');
$AddExtra = ' / '; $AddExtra = ' / ';
} }
if (!empty($CassetteApproved)) { if (!empty($CassetteApproved)) {
$ExtraInfo.=$AddExtra . Format::torrent_label('Cassette Approved'); $ExtraInfo .= $AddExtra . Format::torrent_label('Cassette Approved');
$AddExtra = ' / '; $AddExtra = ' / ';
} }
if (!empty($LossymasterApproved)) { if (!empty($LossymasterApproved)) {
$ExtraInfo.=$AddExtra . Format::torrent_label('Lossy Master Approved'); $ExtraInfo .= $AddExtra . Format::torrent_label('Lossy Master Approved');
$AddExtra = ' / '; $AddExtra = ' / ';
} }
if (!empty($LossywebApproved)) { if (!empty($LossywebApproved)) {
$ExtraInfo.=$AddExtra . Format::torrent_label('Lossy WEB Approved'); $ExtraInfo .= $AddExtra . Format::torrent_label('Lossy WEB Approved');
$AddExtra = ' / '; $AddExtra = ' / ';
} }
if (!empty($BadFiles)) { if (!empty($BadFiles)) {
$ExtraInfo.=$AddExtra . Format::torrent_label('Bad File Names'); $ExtraInfo .= $AddExtra . Format::torrent_label('Bad File Names');
$AddExtra = ' / '; $AddExtra = ' / ';
} }
@ -459,7 +480,7 @@ function filelist($Str) {
$EditionID++; $EditionID++;
?> ?>
<tr class="releases_<?=($ReleaseType)?> groupid_<?=($GroupID)?> edition group_torrent"> <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> </tr>
<? <?
} }
@ -512,14 +533,14 @@ function filelist($Str) {
</div> </div>
<? } ?> <? } ?>
<div class="linkbox"> <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')) { ?> <? 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_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_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) { ?> <? 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>
<div id="peers_<?=($TorrentID)?>" class="hidden"></div> <div id="peers_<?=($TorrentID)?>" class="hidden"></div>
@ -530,7 +551,7 @@ function filelist($Str) {
<div id="reported_<?=($TorrentID)?>" class="hidden"><?=($ReportInfo)?></div> <div id="reported_<?=($TorrentID)?>" class="hidden"><?=($ReportInfo)?></div>
<? } <? }
if (!empty($Description)) { 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> </td>
</tr> </tr>

View File

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

View File

@ -16,7 +16,10 @@
if ($NewGroupID == $GroupID) { if ($NewGroupID == $GroupID) {
error('Old group ID is the same as new group ID!'); 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) { if ($DB->record_count() == 0) {
error('Target group does not exist.'); error('Target group does not exist.');
} }
@ -25,10 +28,13 @@
error('Only music groups can be merged.'); 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(); 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'])) { if (empty($_POST['confirm'])) {
$Artists = Artists::get_artists(array($GroupID, $NewGroupID)); $Artists = Artists::get_artists(array($GroupID, $NewGroupID));
@ -46,9 +52,13 @@
<input type="hidden" name="groupid" value="<?=$GroupID?>" /> <input type="hidden" name="groupid" value="<?=$GroupID?>" />
<input type="hidden" name="targetgroupid" value="<?=$NewGroupID?>" /> <input type="hidden" name="targetgroupid" value="<?=$NewGroupID?>" />
<h3>You are attempting to merge the group:</h3> <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> <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" /> <input type="submit" value="Confirm" />
</form> </form>
</div> </div>
@ -60,78 +70,122 @@
// Votes ninjutsu. This is so annoyingly complicated. // Votes ninjutsu. This is so annoyingly complicated.
// 1. Get a list of everybody who voted on the old group and clear their cache keys // 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()) { 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 // 2. Update the existing votes where possible, clear out the duplicates left by key
// conflicts, and update the torrents_votes table // conflicts, and update the torrents_votes table
$DB->query("UPDATE IGNORE users_votes SET GroupID='$NewGroupID' WHERE GroupID='$GroupID'"); $DB->query("
$DB->query("DELETE FROM users_votes WHERE GroupID='$GroupID'"); UPDATE IGNORE users_votes
$DB->query("INSERT INTO torrents_votes (GroupID, Ups, Total, Score) SET GroupID = '$NewGroupID'
SELECT $NewGroupID, UpVotes, TotalVotes, VoteScore WHERE GroupID = '$GroupID'");
FROM (SELECT IFNULL(SUM(IF(Type='Up',1,0)),0) As UpVotes, $DB->query("
COUNT(1) AS TotalVotes, DELETE FROM users_votes
binomial_ci(IFNULL(SUM(IF(Type='Up',1,0)),0), COUNT(1)) AS VoteScore WHERE GroupID = '$GroupID'");
FROM users_votes $DB->query("
WHERE GroupID = $NewGroupID INSERT INTO torrents_votes (GroupID, Ups, Total, Score)
GROUP BY GroupID) AS a SELECT $NewGroupID, UpVotes, TotalVotes, VoteScore
ON DUPLICATE KEY UPDATE FROM (
Ups = a.UpVotes, SELECT
Total = a.TotalVotes, IFNULL(SUM(IF(Type = 'Up', 1, 0)), 0) As UpVotes,
Score = a.VoteScore;"); 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! // 3. Clear the votes_pairs keys!
$DB->query("SELECT v2.GroupID $DB->query("
FROM users_votes AS v1 SELECT v2.GroupID
INNER JOIN users_votes AS v2 USING (UserID) FROM users_votes AS v1
WHERE (v1.Type = 'Up' OR v2.Type='Up') INNER JOIN users_votes AS v2 USING (UserID)
AND (v1.GroupID IN($GroupID, $NewGroupID)) WHERE (v1.Type = 'Up' OR v2.Type = 'Up')
AND (v2.GroupID NOT IN($GroupID, $NewGroupID));"); AND (v1.GroupID IN($GroupID, $NewGroupID))
AND (v2.GroupID NOT IN($GroupID, $NewGroupID));");
while (list($CacheGroupID) = $DB->next_record()) { 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 // 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("
$DB->query("UPDATE wiki_torrents SET PageID='$NewGroupID' WHERE PageID='$GroupID'"); UPDATE torrents
$DB->query("UPDATE torrents_comments SET GroupID='$NewGroupID' WHERE GroupID='$GroupID'"); 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::delete_group($GroupID);
Torrents::write_group_log($NewGroupID, 0, $LoggedUser['ID'], "Merged Group ".$GroupID." (".$Name.") to ".$NewGroupID." (".$NewName.")", 0); 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); $DB->query("
UPDATE group_log
SET GroupID = $NewGroupID
WHERE GroupID = $GroupID");
$GroupID=$NewGroupID; $GroupID = $NewGroupID;
//Collages //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()) { 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("
$DB->query("DELETE FROM collages_torrents WHERE GroupID='$OldGroupID' AND CollageID='$CollageID'"); UPDATE IGNORE collages_torrents
$Cache->delete_value('collage_'.$CollageID); 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_$NewGroupID");
$Cache->delete_value('torrent_collages_personal_'.$NewGroupID); $Cache->delete_value("torrent_collages_personal_$NewGroupID");
//Requests // Requests
$DB->query("SELECT ID FROM requests WHERE GroupID='$OldGroupID'"); $DB->query("
SELECT ID
FROM requests
WHERE GroupID = '$OldGroupID'");
$Requests = $DB->collect('ID'); $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) { 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()) { 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("torrents_details_$GroupID");
$Cache->delete_value('torrent_comments_'.$GroupID.'_catalogue_0'); $Cache->delete_value("torrent_comments_{$GroupID}_catalogue_0");
$Cache->delete_value('torrent_comments_'.$GroupID); $Cache->delete_value("torrent_comments_$GroupID");
$Cache->delete_value('groups_artists_'.$GroupID); $Cache->delete_value("groups_artists_$GroupID");
Torrents::update_hash($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 //Usual perm checks
if (!check_perms('torrents_edit')) { 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'))) { if (!in_array($LoggedUser['ID'], $DB->collect('UserID'))) {
error(403); error(403);
} }
@ -26,7 +29,7 @@
$Free = 0; $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']; $FreeType = $_POST['freeleechtype'];
} else { } else {
error(404); error(404);
@ -41,28 +44,37 @@
$CatalogueNumber = db_string($_POST['catalogue_number']); $CatalogueNumber = db_string($_POST['catalogue_number']);
// Get some info for the group log // 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(); list($OldYear) = $DB->next_record();
$DB->query("UPDATE torrents_group SET $DB->query("
Year = '$Year', UPDATE torrents_group
RecordLabel = '".$RecordLabel."', SET
CatalogueNumber = '".$CatalogueNumber."' Year = '$Year',
WHERE ID = ".$GroupID); RecordLabel = '".$RecordLabel."',
CatalogueNumber = '".$CatalogueNumber."'
WHERE ID = $GroupID");
if ($OldYear != $Year) { if ($OldYear != $Year) {
$DB->query("INSERT INTO group_log (GroupID, UserID, Time, Info) $DB->query("
VALUES ('$GroupID',".$LoggedUser['ID'].",'".sqltime()."','".db_string("Year changed from $OldYear to $Year")."')"); 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()) { while (list($TorrentID) = $DB->next_record()) {
$Cache->delete_value('torrent_download_'.$TorrentID); $Cache->delete_value("torrent_download_$TorrentID");
} }
Torrents::update_hash($GroupID); 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); 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(); 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) $DB->query("
VALUES ('$GroupID',".$LoggedUser['ID'].",'".sqltime()."','".db_string('Additional Cover "'.$Summary . ' - ' . $Image .'" removed from group')."')"); 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']); header('Location: '.$_SERVER['HTTP_REFERER']);
?> ?>

View File

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

View File

@ -6,24 +6,25 @@
error(404); 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.'); error('Torrent cannot be deleted because the upload process is not completed yet. Please try again later.');
} }
$DB->query("SELECT $DB->query("
t.UserID, SELECT
t.GroupID, t.UserID,
t.Size, t.GroupID,
t.info_hash, t.Size,
tg.Name, t.info_hash,
ag.Name, tg.Name,
t.Time, ag.Name,
COUNT(x.uid) t.Time,
COUNT(x.uid)
FROM torrents AS t FROM torrents AS t
LEFT JOIN torrents_group AS tg ON tg.ID=t.GroupID LEFT JOIN torrents_group AS tg ON tg.ID = t.GroupID
LEFT JOIN artists_group AS ag ON ag.ArtistID=tg.ArtistID LEFT JOIN artists_group AS ag ON ag.ArtistID = tg.ArtistID
LEFT JOIN xbt_snatched AS x ON x.fid=t.ID LEFT JOIN xbt_snatched AS x ON x.fid = t.ID
WHERE t.ID='$TorrentID'"); WHERE t.ID = '$TorrentID'");
list($UserID, $GroupID, $Size, $InfoHash, $Name, $ArtistName, $Time, $Snatches) = $DB->next_record(MYSQLI_NUM, false); 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')) { if (($LoggedUser['ID'] != $UserID || time_ago($Time) > 3600 * 24 * 7 || $Snatches > 4) && !check_perms('torrents_delete')) {
@ -31,22 +32,22 @@
} }
if ($ArtistName) { if ($ArtistName) {
$Name = $ArtistName.' - '.$Name; $Name = "$ArtistName - $Name";
} }
if (isset($_SESSION['logged_user']['multi_delete'])) { if (isset($_SESSION['logged_user']['multi_delete'])) {
if ($_SESSION['logged_user']['multi_delete'] >= 3 && !check_perms('torrents_delete_fast')) { 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']++; $_SESSION['logged_user']['multi_delete']++;
} else { } else {
$_SESSION['logged_user']['multi_delete'] = 1; $_SESSION['logged_user']['multi_delete'] = 1;
} }
$InfoHash = unpack("H*", $InfoHash); $InfoHash = unpack('H*', $InfoHash);
Torrents::delete_torrent($TorrentID, $GroupID); 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']); 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); 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::show_header('Torrent deleted');
?> ?>

View File

@ -61,7 +61,7 @@
} }
if (check_perms('torrents_freeleech')) { if (check_perms('torrents_freeleech')) {
$Free = (int)$_POST['freeleech']; $Free = (int)$_POST['freeleech'];
if (!in_array($Free, array(0,1,2))) { if (!in_array($Free, array(0, 1, 2))) {
error(404); error(404);
} }
$Properties['FreeLeech'] = $Free; $Properties['FreeLeech'] = $Free;
@ -70,7 +70,7 @@
$FreeType = 0; $FreeType = 0;
} else { } else {
$FreeType = (int)$_POST['freeleechtype']; $FreeType = (int)$_POST['freeleechtype'];
if (!in_array($Free, array(0,1,2,3))) { if (!in_array($Free, array(0, 1, 2, 3))) {
error(404); error(404);
} }
} }
@ -80,7 +80,10 @@
//******************************************************************************// //******************************************************************************//
//--------------- Validate data in edit form -----------------------------------// //--------------- 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) { if ($DB->record_count() == 0) {
error(404); error(404);
} }
@ -254,12 +257,15 @@
//--------------- Start database stuff -----------------------------------------// //--------------- Start database stuff -----------------------------------------//
$DBTorVals = array(); $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 = $DB->to_array(false, MYSQLI_ASSOC);
$DBTorVals = $DBTorVals[0]; $DBTorVals = $DBTorVals[0];
$LogDetails = ""; $LogDetails = '';
foreach ($DBTorVals as $Key => $Value) { foreach ($DBTorVals as $Key => $Value) {
$Value = "'".$Value."'"; $Value = "'$Value'";
if ($Value != $T[$Key]) { if ($Value != $T[$Key]) {
if (!isset($T[$Key])) { if (!isset($T[$Key])) {
continue; continue;
@ -267,166 +273,245 @@
if ((empty($Value) && empty($T[$Key])) || ($Value == "'0'" && $T[$Key] == "''")) { if ((empty($Value) && empty($T[$Key])) || ($Value == "'0'" && $T[$Key] == "''")) {
continue; continue;
} }
if ($LogDetails == "") { if ($LogDetails == '') {
$LogDetails = $Key.": ".$Value." -> ".$T[$Key]; $LogDetails = "$Key: $Value -> ".$T[$Key];
} else { } else {
$LogDetails = $LogDetails.", ".$Key.": ".$Value." -> ".$T[$Key]; $LogDetails = "$LogDetails, $Key: $Value -> ".$T[$Key];
} }
} }
} }
// Update info for the torrent // Update info for the torrent
$SQL = " $SQL = "
UPDATE torrents SET UPDATE torrents
Media=$T[Media], SET
Format=$T[Format], Media = $T[Media],
Encoding=$T[Encoding], Format = $T[Format],
RemasterYear=$T[RemasterYear], Encoding = $T[Encoding],
Remastered=$T[Remastered], RemasterYear = $T[RemasterYear],
RemasterTitle=$T[RemasterTitle], Remastered = $T[Remastered],
RemasterRecordLabel=$T[RemasterRecordLabel], RemasterTitle = $T[RemasterTitle],
RemasterCatalogueNumber=$T[RemasterCatalogueNumber], RemasterRecordLabel = $T[RemasterRecordLabel],
Scene=$T[Scene], RemasterCatalogueNumber = $T[RemasterCatalogueNumber],
Description=$T[TorrentDescription],"; Scene = $T[Scene],
Description = $T[TorrentDescription],";
if (check_perms('torrents_freeleech')) { if (check_perms('torrents_freeleech')) {
$SQL .= "FreeTorrent=$T[FreeLeech],"; $SQL .= "FreeTorrent = $T[FreeLeech],";
$SQL .= "FreeLeechType=$T[FreeLeechType],"; $SQL .= "FreeLeechType = $T[FreeLeechType],";
} }
if (check_perms('users_mod')) { if (check_perms('users_mod')) {
if ($T[Format] != "'FLAC'") { if ($T[Format] != "'FLAC'") {
$SQL .= " $SQL .= "
HasLog='0', HasLog = '0',
HasCue='0', HasCue = '0',";
";
} else { } else {
$SQL .= " $SQL .= "
HasLog=$T[HasLog], HasLog = $T[HasLog],
HasCue=$T[HasCue], 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(); list($btID) = $DB->next_record();
if (!$btID && $Properties['BadTags']) { 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']) { 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(); list($bfID) = $DB->next_record();
if (!$bfID && $Properties['BadFolders']) { 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']) { 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(); list($bfiID) = $DB->next_record();
if (!$bfiID && $Properties['BadFiles']) { 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']) { 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(); list($lbID) = $DB->next_record();
if (!$lbID && $Properties['LibraryUpload'] && $Properties['LibraryPoints'] > 0) { 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(); 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']) { 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(); list($caID) = $DB->next_record();
if (!$caID && $Properties['CassetteApproved']) { 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']) { 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(); list($lmaID) = $DB->next_record();
if (!$lmaID && $Properties['LossymasterApproved']) { 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']) { 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(); list($lwID) = $DB->next_record();
if (!$lwID && $Properties['LossywebApproved']) { 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']) { 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 .= " $SQL .= "
flags='2' flags = '2'
WHERE ID=$TorrentID WHERE ID = $TorrentID";
";
$DB->query($SQL); $DB->query($SQL);
if (check_perms('torrents_freeleech') && $Properties['FreeLeech'] != $CurFreeLeech) { if (check_perms('torrents_freeleech') && $Properties['FreeLeech'] != $CurFreeLeech) {
Torrents::freeleech_torrents($TorrentID, $Properties['FreeLeech'], $Properties['FreeLeechType']); 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(); list($GroupID, $Time) = $DB->next_record();
// Competition // Competition
if (strtotime($Time)>1241352173) { if (strtotime($Time) > 1241352173) {
if ($_POST['log_score'] == '100') { 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 // 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(); list($LogScore) = $DB->next_record();
if ($Properties['Trumpable'] == 1 && $LogScore == 100) { 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 = 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)); $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(); list($Enabled) = $DB->next_record();
if ($Properties['Trumpable'] == 0 && $LogScore == 99 && $Enabled == 1 && strtotime($Time) < 1284422400) { 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(); list($Log) = $DB->next_record();
if (strpos($Log, "EAC extraction") === 0) { if (strpos($Log, 'EAC extraction') === 0) {
$DB->query("UPDATE torrents SET LogScore = 100 WHERE ID = ".$TorrentID); $DB->query("
$DB->query("UPDATE torrents_logs_new SET Score = 100, Details = '' WHERE TorrentID = ".$TorrentID); 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); 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); Torrents::write_group_log($GroupID, $TorrentID, $LoggedUser['ID'], $LogDetails, 0);
$Cache->delete_value('torrents_details_'.$GroupID); $Cache->delete_value("torrents_details_$GroupID");
$Cache->delete_value('torrent_download_'.$TorrentID); $Cache->delete_value("torrent_download_$TorrentID");
Torrents::update_hash($GroupID); Torrents::update_hash($GroupID);
// All done! // All done!

View File

@ -26,10 +26,10 @@
error(403); 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('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('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('subject', '0', 'string', 'Invalid subject.', array('maxlength' => 1000, 'minlength' => 1));
$Validate->SetFields('message','0','string','Invalid message.',array('maxlength'=>10000, 'minlength'=>1)); $Validate->SetFields('message', '0', 'string', 'Invalid message.', array('maxlength' => 10000, 'minlength' => 1));
$Err = $Validate->ValidateForm($_POST); // Validate the form $Err = $Validate->ValidateForm($_POST); // Validate the form
if ($Err) { if ($Err) {
@ -41,7 +41,10 @@
//******************************************************************************// //******************************************************************************//
//--------------- Send PMs to users --------------------------------------------// //--------------- 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) { if ($DB->record_count() > 0) {
// Save this because send_pm uses $DB to run its own query... Oops... // Save this because send_pm uses $DB to run its own query... Oops...

View File

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

View File

@ -42,16 +42,24 @@
$ThisInsert['TotalSize'] = $ExtraTotalSize; $ThisInsert['TotalSize'] = $ExtraTotalSize;
$Debug->set_flag('upload: torrent decoded'); $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) { if ($DB->record_count() > 0) {
list($ExtraID) = $DB->next_record(); 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) { 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 { } else {
//One of the lost torrents. //One of the lost torrents.
$DB->query("INSERT INTO torrents_files (TorrentID, File) VALUES ($ExtraID, '$ThisInsert[TorEnc]')"); $DB->query("
$Err = "<a href=\"torrents.php?torrentid=$ExtraID\">Thank you for fixing this torrent</a>"; 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. // // called again. //
//**********************************************************************// //**********************************************************************//
ini_set('max_file_uploads','100'); ini_set('max_file_uploads', '100');
View::show_header('Upload','upload,validate_upload,valid_tags,musicbrainz,multiformat_uploader'); View::show_header('Upload', 'upload,validate_upload,valid_tags,musicbrainz,multiformat_uploader');
if (empty($Properties) && !empty($_GET['groupid']) && is_number($_GET['groupid'])) { if (empty($Properties) && !empty($_GET['groupid']) && is_number($_GET['groupid'])) {
$DB->query(' $DB->query('
@ -27,7 +27,7 @@
tg.VanityHouse tg.VanityHouse
FROM torrents_group AS tg FROM torrents_group AS tg
LEFT JOIN torrents AS t ON t.GroupID = tg.ID LEFT JOIN torrents AS t ON t.GroupID = tg.ID
WHERE tg.ID='.$_GET['groupid'].' WHERE tg.ID = '.$_GET['groupid'].'
GROUP BY tg.ID'); GROUP BY tg.ID');
if ($DB->record_count()) { if ($DB->record_count()) {
list($Properties) = $DB->to_array(false, MYSQLI_BOTH); list($Properties) = $DB->to_array(false, MYSQLI_BOTH);
@ -39,8 +39,8 @@
SELECT SELECT
GROUP_CONCAT(tags.Name SEPARATOR ', ') AS TagList GROUP_CONCAT(tags.Name SEPARATOR ', ') AS TagList
FROM torrents_tags AS tt FROM torrents_tags AS tt
JOIN tags ON tags.ID=tt.TagID JOIN tags ON tags.ID = tt.TagID
WHERE tt.GroupID='$_GET[groupid]'"); WHERE tt.GroupID = '$_GET[groupid]'");
list($Properties['TagList']) = $DB->next_record(); list($Properties['TagList']) = $DB->next_record();
} else { } else {
@ -61,9 +61,9 @@
r.ReleaseType, r.ReleaseType,
r.Image r.Image
FROM requests AS r 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]; $UploadForm = $Categories[$Properties['CategoryID'] - 1];
$Properties['CategoryName'] = $Categories[$Properties['CategoryID'] - 1]; $Properties['CategoryName'] = $Categories[$Properties['CategoryID'] - 1];
$Properties['Artists'] = Requests::get_artists($_GET['requestid']); $Properties['Artists'] = Requests::get_artists($_GET['requestid']);
@ -84,7 +84,11 @@
$GenreTags = $Cache->get_value('genre_tags'); $GenreTags = $Cache->get_value('genre_tags');
if (!$GenreTags) { 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'); $GenreTags = $DB->collect('Name');
$Cache->cache_value('genre_tags', $GenreTags, 3600 * 6); $Cache->cache_value('genre_tags', $GenreTags, 3600 * 6);
} }
@ -100,7 +104,7 @@
list($Name, $Comment, $Updated) = reset($DNU); list($Name, $Comment, $Updated) = reset($DNU);
reset($DNU); reset($DNU);
$DB->query(" $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 FROM torrents AS t
WHERE UserID = ".$LoggedUser['ID']); WHERE UserID = ".$LoggedUser['ID']);
list($NewDNU) = $DB->next_record(); list($NewDNU) = $DB->next_record();
@ -110,9 +114,9 @@
<h3 id="dnu_header">Do not upload</h3> <h3 id="dnu_header">Do not upload</h3>
<p><?=$NewDNU ? '<strong class="important_text">' : '' ?>Last updated: <?=time_diff($Updated)?><?=$NewDNU ? '</strong>' : '' ?></p> <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. <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> <span id="showdnu"><a href="#" onclick="$('#dnulist').gtoggle(); this.innerHTML = (this.innerHTML == 'Hide' ? 'Show' : 'Hide'); return false;" class="brackets">Show</a></span>
<? } ?> <? } ?>
</p> </p>
<table id="dnulist" class="<?=($HideDNU ? 'hidden' : '')?>"> <table id="dnulist" class="<?=($HideDNU ? 'hidden' : '')?>">
<tr class="colhead"> <tr class="colhead">

View File

@ -581,7 +581,7 @@
foreach ($Artists as $Num => $Artist) { foreach ($Artists as $Num => $Artist) {
$DB->query(" $DB->query("
INSERT IGNORE INTO torrents_artists (GroupID, ArtistID, AliasID, UserID, Importance) 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'); $Cache->increment('stats_album_count');
} }
} }
@ -591,13 +591,16 @@
} else { } else {
$DB->query(" $DB->query("
UPDATE torrents_group UPDATE torrents_group
SET Time='".sqltime()."' SET Time = '".sqltime()."'
WHERE ID=$GroupID"); WHERE ID = $GroupID");
$Cache->delete_value('torrent_group_'.$GroupID); $Cache->delete_value("torrent_group_$GroupID");
$Cache->delete_value('torrents_details_'.$GroupID); $Cache->delete_value("torrents_details_$GroupID");
$Cache->delete_value('detail_files_'.$GroupID); $Cache->delete_value("detail_files_$GroupID");
if ($Type == 'Music') { 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(); list($Properties['ReleaseType']) = $DB->next_record();
} }
} }
@ -614,8 +617,8 @@
// Revision ID // Revision ID
$DB->query(" $DB->query("
UPDATE torrents_group UPDATE torrents_group
SET RevisionID='$RevisionID' SET RevisionID = '$RevisionID'
WHERE ID=$GroupID"); WHERE ID = $GroupID");
} }
// Tags // Tags
@ -630,7 +633,7 @@
(Name, UserID) (Name, UserID)
VALUES VALUES
('$Tag', $LoggedUser[ID]) ('$Tag', $LoggedUser[ID])
ON DUPLICATE KEY UPDATE Uses=Uses+1; ON DUPLICATE KEY UPDATE Uses = Uses + 1;
"); ");
$TagID = $DB->inserted_id(); $TagID = $DB->inserted_id();
@ -639,7 +642,7 @@
(TagID, GroupID, UserID, PositiveVotes) (TagID, GroupID, UserID, PositiveVotes)
VALUES VALUES
($TagID, $GroupID, $LoggedUser[ID], 10) ($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 INSERT INTO torrents
(GroupID, UserID, Media, Format, Encoding, (GroupID, UserID, Media, Format, Encoding,
Remastered, RemasterYear, RemasterTitle, RemasterRecordLabel, RemasterCatalogueNumber, Remastered, RemasterYear, RemasterTitle, RemasterRecordLabel, RemasterCatalogueNumber,
Scene, HasLog, HasCue, info_hash, FileCount, FileList, FilePath, Size, Time, Scene, HasLog, HasCue, info_hash, FileCount, FileList, FilePath,
Description, LogScore, FreeTorrent, FreeLeechType) Size, Time, Description, LogScore, FreeTorrent, FreeLeechType)
VALUES VALUES
($GroupID, $LoggedUser[ID], $T[Media], $T[Format], $T[Encoding], " . ($GroupID, $LoggedUser[ID], $T[Media], $T[Format], $T[Encoding], " .
"$T[Remastered], $T[RemasterYear], $T[RemasterTitle], $T[RemasterRecordLabel], $T[RemasterCatalogueNumber], " . "$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 // 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) // (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 -------------------------------------------// //--------------- Write torrent file -------------------------------------------//
@ -678,7 +681,7 @@
$DB->query(" $DB->query("
INSERT INTO torrents_files (TorrentID, File) INSERT INTO torrents_files (TorrentID, File)
VALUES ($TorrentID, '$TorEnc')"); 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::write_group_log($GroupID, $TorrentID, $LoggedUser['ID'], 'uploaded ('.number_format($TotalSize / (1024 * 1024), 2).' MB)', 0);
Torrents::update_hash($GroupID); Torrents::update_hash($GroupID);
@ -722,8 +725,8 @@
if (count($RecentUploads) == 5) { if (count($RecentUploads) == 5) {
array_pop($RecentUploads); array_pop($RecentUploads);
} }
array_unshift($RecentUploads, array('ID'=>$GroupID, 'Name'=>trim($Properties['Title']), 'Artist'=>Artists::display_artists($ArtistForm, false, true), 'WikiImage'=>trim($Properties['Image']))); 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); $Cache->cache_value("recent_uploads_$UserID", $RecentUploads, 0);
} while (0); } while (0);
} }
} }
@ -732,8 +735,10 @@
//--------------- Contest ------------------------------------------------------// //--------------- Contest ------------------------------------------------------//
if ($Properties['LibraryImage'] != '') { if ($Properties['LibraryImage'] != '') {
$DB->query(" $DB->query("
INSERT INTO reportsv2 (ReporterID, TorrentID, Type, UserComment, Status, ReportedTime, Track, Image, ExtraID, Link) INSERT INTO reportsv2
VALUES (0, $TorrentID, 'library', '".db_string(($Properties['MultiDisc'] ? 'Multi-disc' : ''))."', 'New', '".sqltime()."', '', '".db_string($Properties['LibraryImage'])."', '', '')"); (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 .= ' ['.$ReleaseTypes[$Properties['ReleaseType']].']';
} }
$Announce .= ' - '; $Announce .= ' - ';
$Announce .= trim($Properties['Format'])." / ".trim($Properties['Bitrate']); $Announce .= trim($Properties['Format']).' / '.trim($Properties['Bitrate']);
if ($HasLog == 1) { if ($HasLog == 1) {
$Announce .= ' / Log'; $Announce .= ' / Log';
} }
@ -798,7 +803,7 @@
} }
$Title = $Announce; $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"; $Announce .= " - https://".SSL_SITE_URL."/torrents.php?id=$GroupID / https://".SSL_SITE_URL."/torrents.php?action=download&id=$TorrentID";
$AnnounceSSL .= ' - '.trim($Properties['TagList']); $AnnounceSSL .= ' - '.trim($Properties['TagList']);
@ -844,8 +849,8 @@
$SQL = " $SQL = "
SELECT unf.ID, unf.UserID, torrent_pass SELECT unf.ID, unf.UserID, torrent_pass
FROM users_notify_filters AS unf FROM users_notify_filters AS unf
JOIN users_main AS um ON um.ID=unf.UserID JOIN users_main AS um ON um.ID = unf.UserID
WHERE um.Enabled='1'"; WHERE um.Enabled = '1'";
if (empty($ArtistsUnescaped)) { if (empty($ArtistsUnescaped)) {
$ArtistsUnescaped = $ArtistForm; $ArtistsUnescaped = $ArtistForm;
} }
@ -855,50 +860,49 @@
foreach ($ArtistsUnescaped as $Importance => $Artists) { foreach ($ArtistsUnescaped as $Importance => $Artists) {
foreach ($Artists as $Artist) { foreach ($Artists as $Artist) {
if ($Importance == 1 || $Importance == 4 || $Importance == 5 || $Importance == 6) { 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 { } 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 // 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') { if (count($ArtistNameList) > 2 || $Artist['name'] == 'Various Artists') {
$SQL.= " AND (ExcludeVA='0' AND ("; $SQL .= " AND (ExcludeVA = '0' AND (";
$SQL.= implode(" OR ", array_merge($ArtistNameList,$GuestArtistNameList)); $SQL .= implode(' OR ', array_merge($ArtistNameList, $GuestArtistNameList));
$SQL.= " OR Artists='')) AND ("; $SQL .= " OR Artists = '')) AND (";
} else { } else {
$SQL.= " AND ("; $SQL .= " AND (";
if (!empty($GuestArtistNameList)) { if (!empty($GuestArtistNameList)) {
$SQL.= "(ExcludeVA='0' AND ("; $SQL .= "(ExcludeVA = '0' AND (";
$SQL.= implode(" OR ", $GuestArtistNameList); $SQL .= implode(' OR ', $GuestArtistNameList);
$SQL.= ")) OR "; $SQL .= ')) OR ';
} }
$SQL.= implode(" OR ", $ArtistNameList); $SQL .= implode(' OR ', $ArtistNameList);
$SQL.= " OR Artists='') AND ("; $SQL .= " OR Artists = '') AND (";
} }
} else { } else {
$SQL.="AND (Artists='') AND ("; $SQL .= "AND (Artists = '') AND (";
} }
reset($Tags); reset($Tags);
$TagSQL = array(); $TagSQL = array();
$NotTagSQL = array(); $NotTagSQL = array();
foreach ($Tags as $Tag) { foreach ($Tags as $Tag) {
$TagSQL[]=" Tags LIKE '%|".db_string(trim($Tag))."|%' "; $TagSQL[] = " Tags LIKE '%|".db_string(trim($Tag))."|%' ";
$NotTagSQL[]=" NotTags LIKE '%|".db_string(trim($Tag))."|%' "; $NotTagSQL[] = " NotTags LIKE '%|".db_string(trim($Tag))."|%' ";
} }
$TagSQL[]="Tags=''"; $TagSQL[] = "Tags = ''";
$SQL.=implode(' OR ', $TagSQL); $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']) { 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 { } else {
$SQL.=" AND (ReleaseTypes='') "; $SQL .= " AND (ReleaseTypes = '') ";
} }
/* /*
@ -909,21 +913,21 @@
if ($Properties['Format']) { 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 { } else {
$SQL.=" AND (Formats='') "; $SQL .= " AND (Formats = '') ";
} }
if ($_POST['bitrate']) { 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 { } else {
$SQL.=" AND (Encodings='') "; $SQL .= " AND (Encodings = '') ";
} }
if ($Properties['Media']) { 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 { } else {
$SQL.=" AND (Media='') "; $SQL .= " AND (Media = '') ";
} }
// Either they aren't using NewGroupsOnly // Either they aren't using NewGroupsOnly
@ -941,28 +945,31 @@
if ($Properties['Year'] && $Properties['RemasterYear']) { 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 ('".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']) { } elseif ($Properties['Year'] || $Properties['RemasterYear']) {
$SQL.=" AND (('".db_string(trim(Max($Properties['Year'],$Properties['RemasterYear'])))."' BETWEEN FromYear AND ToYear) $SQL .= " AND (('".db_string(trim(Max($Properties['Year'],$Properties['RemasterYear'])))."' BETWEEN FromYear AND ToYear)
OR (FromYear=0 AND ToYear=0)) "; OR (FromYear = 0 AND ToYear = 0)) ";
} else { } 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(); list($Paranoia) = $DB->next_record();
$Paranoia = unserialize($Paranoia); $Paranoia = unserialize($Paranoia);
if (!is_array($Paranoia)) { if (!is_array($Paranoia)) {
$Paranoia = array(); $Paranoia = array();
} }
if (!in_array('notifications', $Paranoia)) { 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); $DB->query($SQL);
$Debug->set_flag('upload: notification query finished'); $Debug->set_flag('upload: notification query finished');
@ -976,17 +983,17 @@
$Rows = array(); $Rows = array();
foreach ($UserArray as $User) { foreach ($UserArray as $User) {
list($FilterID, $UserID, $Passkey) = $User; list($FilterID, $UserID, $Passkey) = $User;
$Rows[]="('$UserID', '$GroupID', '$TorrentID', '$FilterID')"; $Rows[] = "('$UserID', '$GroupID', '$TorrentID', '$FilterID')";
$Feed->populate('torrents_notify_'.$Passkey,$Item); $Feed->populate("torrents_notify_$Passkey", $Item);
$Cache->delete_value('notifications_new_'.$UserID); $Cache->delete_value("notifications_new_$UserID");
} }
$InsertSQL.=implode(',', $Rows); $InsertSQL .= implode(',', $Rows);
$DB->query($InsertSQL); $DB->query($InsertSQL);
$Debug->set_flag('upload: notification inserts finished'); $Debug->set_flag('upload: notification inserts finished');
foreach ($FilterArray as $Filter) { foreach ($FilterArray as $Filter) {
list($FilterID, $UserID, $Passkey) = $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 JOIN bookmarks_torrents AS b ON b.UserID = u.ID
WHERE b.GroupID = $GroupID"); WHERE b.GroupID = $GroupID");
while (list($UserID, $Passkey) = $DB->next_record()) { 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'); $Debug->set_flag('upload: notifications handled');
if ($Type == 'Music') { if ($Type == 'Music') {
$Feed->populate('torrents_music',$Item); $Feed->populate('torrents_music', $Item);
if ($Properties['Media'] == 'Vinyl') { if ($Properties['Media'] == 'Vinyl') {
$Feed->populate('torrents_vinyl',$Item); $Feed->populate('torrents_vinyl', $Item);
} }
if ($Properties['Bitrate'] == 'Lossless') { if ($Properties['Bitrate'] == 'Lossless') {
$Feed->populate('torrents_lossless',$Item); $Feed->populate('torrents_lossless', $Item);
} }
if ($Properties['Bitrate'] == '24bit Lossless') { if ($Properties['Bitrate'] == '24bit Lossless') {
$Feed->populate('torrents_lossless24',$Item); $Feed->populate('torrents_lossless24', $Item);
} }
if ($Properties['Format'] == 'MP3') { if ($Properties['Format'] == 'MP3') {
$Feed->populate('torrents_mp3',$Item); $Feed->populate('torrents_mp3', $Item);
} }
if ($Properties['Format'] == 'FLAC') { if ($Properties['Format'] == 'FLAC') {
$Feed->populate('torrents_flac',$Item); $Feed->populate('torrents_flac', $Item);
} }
} }
if ($Type == 'Applications') { if ($Type == 'Applications') {
$Feed->populate('torrents_apps',$Item); $Feed->populate('torrents_apps', $Item);
} }
if ($Type == 'E-Books') { if ($Type == 'E-Books') {
$Feed->populate('torrents_ebooks',$Item); $Feed->populate('torrents_ebooks', $Item);
} }
if ($Type == 'Audiobooks') { if ($Type == 'Audiobooks') {
$Feed->populate('torrents_abooks',$Item); $Feed->populate('torrents_abooks', $Item);
} }
if ($Type == 'E-Learning Videos') { if ($Type == 'E-Learning Videos') {
$Feed->populate('torrents_evids',$Item); $Feed->populate('torrents_evids', $Item);
} }
if ($Type == 'Comedy') { if ($Type == 'Comedy') {
$Feed->populate('torrents_comedy',$Item); $Feed->populate('torrents_comedy', $Item);
} }
if ($Type == 'Comics') { if ($Type == 'Comics') {
$Feed->populate('torrents_comics',$Item); $Feed->populate('torrents_comics', $Item);
} }
// Clear Cache // Clear cache
$Cache->delete_value('torrents_details_'.$GroupID); $Cache->delete_value("torrents_details_$GroupID");
// Allow deletion of this torrent now // 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;"> <div id="sortable_container" style="display: none;">
<a href="#" id="reset_sortable" class="brackets">Reset to default</a> <a href="#" id="reset_sortable" class="brackets">Reset to default</a>
<ul class="sortable_list" id="sortable"> <ul class="sortable_list" id="sortable">
<?Users::release_order()?> <?Users::release_order($SiteOptions)?>
</ul> </ul>
<p><small>Note: Checked items will be hidden.</small></p> <p><small>Note: Checked items will be hidden.</small></p>
<script type="text/javascript" id="sortable_default">//<![CDATA[ <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> </script>
</div> </div>
@ -255,37 +255,37 @@ function checked($Checked) {
<td> <td>
<ul class="options_list nobullet"> <ul class="options_list nobullet">
<li> <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> <label for="showtfilter">Show filter controls</label>
</li> </li>
<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> <label for="showtags">Show filters for official tags</label>
</li> </li>
</ul> </ul>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="label"><strong>Auto Complete</strong></td> <td class="label"><strong>Auto completion</strong></td>
<td> <td>
<select name="autocomplete"> <select name="autocomplete">
<option value="0" <? if (empty($SiteOptions['AutoComplete'])) { ?> selected="selected" <? } ?>>Everywhere</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="2"<? if ($SiteOptions['AutoComplete'] === 2) { ?> selected="selected"<? } ?>>Searches only</option>
<option value="1" <? if ($SiteOptions['AutoComplete'] === 1) { ?>selected="selected" <? } ?>>Disable</option> <option value="1"<? if ($SiteOptions['AutoComplete'] === 1) { ?> selected="selected"<? } ?>>Disable</option>
</select> </select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="label"><strong>Voting links</strong></td> <td class="label"><strong>Voting links</strong></td>
<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> <label for="novotelinks">Disable voting links on artist pages, collages, and snatched lists</label>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="label"><strong>Download torrents as text files</strong></td> <td class="label"><strong>Download torrents as text files</strong></td>
<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> <label for="downloadalt">For users whose ISP blocks the downloading of torrent files</label>
</td> </td>
</tr> </tr>
@ -348,7 +348,7 @@ function checked($Checked) {
<tr> <tr>
<td class="label"><strong>Auto-save text</strong></td> <td class="label"><strong>Auto-save text</strong></td>
<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> <label for="disableautosave">Disable reply text from being saved automatically when changing pages in a thread</label>
</td> </td>
</tr> </tr>

View File

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

View File

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

View File

@ -9,20 +9,30 @@
$CollageID = (int) $_GET['collageid']; $CollageID = (int) $_GET['collageid'];
if (!$UserSubscriptions = $Cache->get_value('collage_subs_user_'.$LoggedUser['ID'])) { 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); $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) { 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]); unset($UserSubscriptions[$Key]);
Collages::decrease_subscriptions($CollageID); Collages::decrease_subscriptions($CollageID);
} else { } 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); array_push($UserSubscriptions, $CollageID);
Collages::increase_subscriptions($CollageID); Collages::increase_subscriptions($CollageID);
} }
$Cache->replace_value('collage_subs_user_'.$LoggedUser['ID'], $UserSubscriptions, 0); $Cache->replace_value('collage_subs_user_'.$LoggedUser['ID'], $UserSubscriptions, 0);
$Cache->delete_value('collage_subs_user_new_'.$LoggedUser['ID']); $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(" $DB->query("
SELECT ui.JoinDate, p.Level AS Class SELECT ui.JoinDate, p.Level AS Class
FROM users_main AS um FROM users_main AS um
JOIN users_info AS ui ON um.ID=ui.UserID JOIN users_info AS ui ON um.ID = ui.UserID
JOIN permissions AS p ON p.ID=um.PermissionID JOIN permissions AS p ON p.ID = um.PermissionID
WHERE um.ID = $UserID"); WHERE um.ID = $UserID");
list($Joined, $Class) = $DB->next_record(); list($Joined, $Class) = $DB->next_record();
@ -30,7 +30,10 @@
$UsersOnly = $_GET['usersonly']; $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(); list($Username)= $DB->next_record();
View::show_header("Email history for $Username"); View::show_header("Email history for $Username");
@ -44,7 +47,8 @@
FROM users_main AS u FROM users_main AS u
LEFT JOIN users_main AS u2 ON u2.Email = u.Email AND u2.ID != '$UserID' 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 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 UNION
SELECT SELECT
h.Email, h.Email,
@ -52,9 +56,11 @@
h.IP, h.IP,
c.Code c.Code
FROM users_history_emails AS h 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 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"); ORDER BY Time DESC");
} else { } else {
$DB->query(" $DB->query("
@ -65,7 +71,7 @@
c.Code c.Code
FROM users_main AS u FROM users_main AS u
LEFT JOIN geoip_country AS c ON INET_ATON(u.IP) BETWEEN c.StartIP AND c.EndIP 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 UNION
SELECT SELECT
h.Email, h.Email,
@ -74,7 +80,8 @@
c.Code c.Code
FROM users_history_emails AS h FROM users_history_emails AS h
LEFT JOIN geoip_country AS c ON INET_ATON(h.IP) BETWEEN c.StartIP AND c.EndIP 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"); ORDER BY Time DESC");
} }
$History = $DB->to_array(); $History = $DB->to_array();
@ -124,8 +131,12 @@
<td /> <td />
<td><?=time_diff($Time)?></td> <td><?=time_diff($Time)?></td>
<td><?=display_str($IP)?></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(); list($Enabled) = $DB->next_record();
$DB->set_query_id($ueQuery); $DB->set_query_id($ueQuery);
?> ?>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,23 +11,39 @@
} }
require(SERVER_ROOT.'/sections/forums/index.php'); 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(); list($ForumID) = $DB->next_record();
if (!check_forumperm($ForumID)) { if (!check_forumperm($ForumID)) {
die(); die();
} }
if (!$UserSubscriptions = $Cache->get_value('subscriptions_user_'.$LoggedUser['ID'])) { 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); $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) { 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'])); $DB->query('
DELETE FROM users_subscriptions
WHERE UserID = '.db_string($LoggedUser['ID']).'
AND TopicID = '.db_string($_GET['topicid']));
unset($UserSubscriptions[$Key]); unset($UserSubscriptions[$Key]);
} else { } 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']); array_push($UserSubscriptions, $_GET['topicid']);
} }
$Cache->replace_value('subscriptions_user_'.$LoggedUser['ID'], $UserSubscriptions, 0); $Cache->replace_value('subscriptions_user_'.$LoggedUser['ID'], $UserSubscriptions, 0);

View File

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