This tree has =$Count?> entries, =$Branches?> branches, and a depth of =$MaxTreeLevel - $OriginalTreeLevel?>.
It has
@@ -152,15 +152,15 @@ function make_tree() {
foreach ($ClassSummary as $ClassID => $ClassCount) {
if($ClassCount == 0) { continue; }
$LastClass = Users::make_class_string($ClassID);
- if($ClassCount>1) {
+ if($ClassCount>1) {
if($LastClass == "Torrent Celebrity") {
$LastClass = 'Torrent Celebrities';
} else {
- $LastClass.='s';
+ $LastClass.='s';
}
}
$LastClass= $ClassCount.' '.$LastClass.' (' . number_format(($ClassCount/$Count)*100) . '%)';
-
+
$ClassStrings []= $LastClass;
}
if(count($ClassStrings)>1){
@@ -183,13 +183,13 @@ function make_tree() {
if($DonorCount == 0) { echo '0%)'; }
else { echo number_format(($DonorCount/$Count)*100) . '%)';}
echo '.
';
-
+
echo '
';
echo 'The total amount uploaded by the entire tree was '.Format::get_size($TotalUpload);
echo '; the total amount downloaded was '.Format::get_size($TotalDownload);
echo '; and the total ratio is '.Format::get_ratio_html($TotalUpload, $TotalDownload).'. ';
echo '
';
-
+
echo '
';
echo 'The total amount uploaded by direct invitees (the top level) was '.Format::get_size($TopLevelUpload);
echo '; the total amount downloaded was '.Format::get_size($TopLevelDownload);
@@ -211,7 +211,7 @@ function make_tree() {
echo '
';
}
}
-
+
?>
=$Tree?>
diff --git a/classes/class_mass_user_torrents_table_view.php b/classes/class_mass_user_torrents_table_view.php
index 74bc6148..d289ba07 100644
--- a/classes/class_mass_user_torrents_table_view.php
+++ b/classes/class_mass_user_torrents_table_view.php
@@ -168,7 +168,7 @@ public function header ()
*/
public function footer ()
{
- if ($this->HasTorrents) :
+ if ($this->HasTorrents) :
?>
diff --git a/classes/class_misc.php b/classes/class_misc.php
index 7a78bc3d..eb5d888f 100644
--- a/classes/class_misc.php
+++ b/classes/class_misc.php
@@ -88,7 +88,7 @@ public static function send_pm($ToID,$FromID,$Subject,$Body,$ConvID='') {
list($UnRead) = $DB->next_record();
$Cache->cache_value('inbox_new_'.$ID, $UnRead);
}
-
+
$DB->query("SELECT Username FROM users_main WHERE ID = '$FromID'");
list($SenderName) = $DB->next_record();
foreach($ToID as $ID) {
diff --git a/classes/class_mysql.php b/classes/class_mysql.php
index bda757d0..c547fdd7 100644
--- a/classes/class_mysql.php
+++ b/classes/class_mysql.php
@@ -145,17 +145,17 @@ class DB_MYSQL {
protected $Row;
protected $Errno = 0;
protected $Error = '';
-
+
public $Queries = array();
public $Time = 0.0;
-
+
protected $Database = '';
protected $Server = '';
protected $User = '';
protected $Pass = '';
protected $Port = 0;
protected $Socket = '';
-
+
function __construct($Database = SQLDB, $User = SQLLOGIN, $Pass = SQLPASS, $Server = SQLHOST, $Port = SQLPORT, $Socket = SQLSOCK) {
$this->Database = $Database;
$this->Server = $Server;
@@ -169,7 +169,7 @@ function halt($Msg) {
global $LoggedUser, $Cache, $Debug, $argv;
$DBError='MySQL: '.strval($Msg).' SQL error: '.strval($this->Errno).' ('.strval($this->Error).')';
if ($this->Errno == 1194) { send_irc('PRIVMSG '.ADMIN_CHAN.' :'.$this->Error); }
- /*if ($this->Errno == 1194) {
+ /*if ($this->Errno == 1194) {
preg_match("Table '(\S+)' is marked as crashed and should be repaired", $this->Error, $Matches);
} */
$Debug->analysis('!dev DB Error',$DBError,3600*24);
@@ -207,7 +207,7 @@ function query($Query,$AutoHandle=1) {
}
$Debug->analysis('Non-Fatal Deadlock:',$Query,3600*24);
trigger_error("Database deadlock, attempt $i");
-
+
sleep($i*rand(2, 5)); // Wait longer as attempts increase
}
$QueryEndTime=microtime(true);
@@ -319,10 +319,14 @@ function to_array($Key = false, $Type = MYSQLI_BOTH, $Escape = true) {
function to_pair($KeyField, $ValField, $Escape = true) {
$Return = array();
while ($Row = mysqli_fetch_array($this->QueryID)) {
- if ($Escape !== false) {
- $Row = Misc::display_array($Row[$ValField], $Escape);
+ if ($Escape) {
+ $Key = display_str($Row[$KeyField]);
+ $Val = display_str($Row[$ValField]);
+ } else {
+ $Key = $Row[$KeyField];
+ $Val = $Row[$ValField];
}
- $Return[$Row[$KeyField]] = $Row[$ValField];
+ $Return[$Key] = $Val;
}
mysqli_data_seek($this->QueryID, 0);
return $Return;
@@ -342,7 +346,7 @@ function set_query_id(&$ResultSet){
$this->QueryID = $ResultSet;
$this->Row = 0;
}
-
+
function get_query_id() {
return $this->QueryID;
}
diff --git a/classes/class_paranoia.php b/classes/class_paranoia.php
index 361e4b42..b68b0bb4 100644
--- a/classes/class_paranoia.php
+++ b/classes/class_paranoia.php
@@ -44,7 +44,7 @@
define("PARANOIA_ALLOWED", 1);
define("PARANOIA_OVERRIDDEN", 2);
-
+
function check_paranoia($Property, $Paranoia, $UserClass, $UserID = false) {
global $LoggedUser, $Classes;
if ($Property == false) {
@@ -68,8 +68,8 @@ function check_paranoia($Property, $Paranoia, $UserClass, $UserID = false) {
$May = !in_array($Property, $Paranoia) && !in_array($Property . '+', $Paranoia);
if($May)
return PARANOIA_ALLOWED;
-
- if(check_perms('users_override_paranoia', $UserClass))
+
+ if(check_perms('users_override_paranoia', $UserClass))
return PARANOIA_OVERRIDDEN;
$Override=false;
switch ($Property) {
@@ -78,20 +78,20 @@ function check_paranoia($Property, $Paranoia, $UserClass, $UserID = false) {
case 'uploaded':
case 'lastseen':
if(check_perms('users_mod', $UserClass))
- return PARANOIA_OVERRIDDEN;
+ return PARANOIA_OVERRIDDEN;
break;
case 'snatched': case 'snatched+':
- if(check_perms('users_view_torrents_snatchlist', $UserClass))
+ if(check_perms('users_view_torrents_snatchlist', $UserClass))
return PARANOIA_OVERRIDDEN;
break;
case 'uploads': case 'uploads+':
case 'seeding': case 'seeding+':
case 'leeching': case 'leeching+':
- if(check_perms('users_view_seedleech', $UserClass))
+ if(check_perms('users_view_seedleech', $UserClass))
return PARANOIA_OVERRIDDEN;
break;
case 'invitedcount':
- if(check_perms('users_view_invites', $UserClass))
+ if(check_perms('users_view_invites', $UserClass))
return PARANOIA_OVERRIDDEN;
break;
}
diff --git a/classes/class_proxies.php b/classes/class_proxies.php
index 9b4e563e..af3206b0 100644
--- a/classes/class_proxies.php
+++ b/classes/class_proxies.php
@@ -20,19 +20,19 @@ function proxyCheck($IP) {
if (strlen($IP) < strlen($AllowedProxies[$i])) {
continue;
}
-
+
//since we're matching bit for bit iterating from the start
for ($j=0,$jl=strlen($IP);$j<$jl;++$j) {
//completed iteration and no inequality
if ($j == $jl-1 && $IP[$j] === $AllowedProxies[$i][$j]) {
return true;
}
-
+
//wildcard
if ($AllowedProxies[$i][$j] === '*') {
return true;
}
-
+
//inequality found
if ($IP[$j] !== $AllowedProxies[$i][$j]) {
break;
diff --git a/classes/class_search.php b/classes/class_search.php
index 1404726e..1c9f1331 100644
--- a/classes/class_search.php
+++ b/classes/class_search.php
@@ -10,30 +10,30 @@ class SPHINX_SEARCH extends SphinxClient {
public $Queries = array();
public $Time = 0.0;
public $Filters = array();
-
+
function SPHINX_SEARCH() {
parent::__construct();
$this->SetServer(SPHINX_HOST, SPHINX_PORT);
$this->SetMatchMode(SPH_MATCH_EXTENDED2);
}
-
+
/****************************************************************
/--- Search function --------------------------------------------
-
- This function queries sphinx for whatever is in $Query, in
+
+ This function queries sphinx for whatever is in $Query, in
extended2 mode. It then fetches the records for each primary key
from memcached (by joining $CachePrefix and the primary key), and
- fetches the fields needed ($ReturnData) from the memcached
+ fetches the fields needed ($ReturnData) from the memcached
result.
-
- Any keys not found in memcached are then queried in MySQL, using
+
+ Any keys not found in memcached are then queried in MySQL, using
$SQL. They are then cached, and merged with the memcached matches
and returned.
-
+
$Query - sphinx query
$CachePrefix - Prefix for memcache key (no underscore)
$CacheLength - How long to store data in the cache, if it's found by MySQL
- $ReturnData - Array of keys to the array in memcached to return.
+ $ReturnData - Array of keys to the array in memcached to return.
If empty, return all.
$SQL - SQL query to fetch results not found in memcached
- Should take the format of:
@@ -41,9 +41,9 @@ function SPHINX_SEARCH() {
where %ids will be replaced by a list of IDs not found in memcached
$IDColumn - The primary key of the SQL table - must be the
same primary key returned by sphinx!
-
+
****************************************************************/
-
+
function search($Query='', $CachePrefix='', $CacheLength=0, $ReturnData=array(), $SQL = '', $IDColumn='ID') {
global $Cache, $DB;
$QueryStartTime=microtime(true);
@@ -59,7 +59,7 @@ function search($Query='', $CachePrefix='', $CacheLength=0, $ReturnData=array(),
$this->Queries[]=array('Params: '.$Query.' Filters: '.implode(", ", $Filters).' Indicies: '.$this->Index,($QueryEndTime-$QueryStartTime)*1000);
$this->Time+=($QueryEndTime-$QueryStartTime)*1000;
-
+
if($Result === false) {
if($this->_connerror && !$Cache->get_value('sphinx_crash_reported')) {
send_irc('PRIVMSG '.ADMIN_CHAN.' :!dev Connection to searchd failed');
@@ -67,19 +67,19 @@ function search($Query='', $CachePrefix='', $CacheLength=0, $ReturnData=array(),
}
send_irc('PRIVMSG '.LAB_CHAN.' :Search for "'.$Query.'" ('.str_replace("\n",'',print_r($this->Filters, true)).') failed: '.$this->GetLastError());
}
-
+
$this->TotalResults = $Result['total_found'];
$this->SearchTime = $Result['time'];
-
+
if(empty($Result['matches'])) {
return false;
}
$Matches = $Result['matches'];
-
+
$MatchIDs = array_keys($Matches);
-
-
-
+
+
+
$NotFound = array();
$Skip = array();
if(!empty($ReturnData)) {
@@ -87,7 +87,7 @@ function search($Query='', $CachePrefix='', $CacheLength=0, $ReturnData=array(),
} else {
$AllFields = true;
}
-
+
foreach($MatchIDs as $Match) {
$Matches[$Match] = $Matches[$Match]['attrs'];
if(!empty($CachePrefix)) {
@@ -120,7 +120,7 @@ function search($Query='', $CachePrefix='', $CacheLength=0, $ReturnData=array(),
$Matches[$Match] = array_merge($Matches[$Match], $Data);
}
}
-
+
if($SQL!='') {
if(!empty($NotFound)) {
$DB->query(str_replace('%ids', implode(',',$NotFound), $SQL));
@@ -132,21 +132,21 @@ function search($Query='', $CachePrefix='', $CacheLength=0, $ReturnData=array(),
} else {
$Matches = array('matches'=>$Matches,'notfound'=>$NotFound);
}
-
+
return $Matches;
}
-
+
function limit($Start, $Length) {
$Start = (int)$Start;
$Length = (int)$Length;
$this->SetLimits($Start, $Length, $Start+$Length);
}
-
-
+
+
function set_index($Index) {
$this->Index = $Index;
}
-
+
function set_filter($Name, $Vals, $Exclude=false) {
foreach($Vals as $Val) {
if($Exclude) {
@@ -157,12 +157,12 @@ function set_filter($Name, $Vals, $Exclude=false) {
}
$this->SetFilter($Name, $Vals, $Exclude);
}
-
+
function set_filter_range($Name, $Min, $Max, $Exclude) {
$this->Filters[$Name] = array($Min.'-'.$Max);
$this->SetFilterRange($Name, $Min, $Max, $Exclude);
}
-
+
function escape_string($String) {
return strtr($String, array(
'('=>'\(',
@@ -182,7 +182,7 @@ function escape_string($String) {
'$'=>'\$',
'='=>'\='));
}
-
-
+
+
}
?>
diff --git a/classes/class_time.php b/classes/class_time.php
index 8032cd3a..ab43a279 100644
--- a/classes/class_time.php
+++ b/classes/class_time.php
@@ -23,7 +23,7 @@ function time_diff($TimeStamp, $Levels=2, $Span=true, $Lowercase=false) {
}
if($TimeStamp == 0) { return 'Never'; }
$Time = time()-$TimeStamp;
-
+
// If the time is negative, then it expires in the future.
if($Time < 0) {
$Time = -$Time;
@@ -77,7 +77,7 @@ function time_diff($TimeStamp, $Levels=2, $Span=true, $Lowercase=false) {
if ($Return!="") {
$Return.=', ';
}
- if ($Weeks>1) {
+ if ($Weeks>1) {
$Return.=$Weeks.' weeks';
} else {
$Return.=$Weeks.' week';
@@ -120,7 +120,7 @@ function time_diff($TimeStamp, $Levels=2, $Span=true, $Lowercase=false) {
}
$Levels--;
}
-
+
if($Return == '') {
$Return = 'Just now';
} elseif (!isset($HideAgo)) {
@@ -130,7 +130,7 @@ function time_diff($TimeStamp, $Levels=2, $Span=true, $Lowercase=false) {
if ($Lowercase) {
$Return = strtolower($Return);
}
-
+
if ($Span) {
return ''.$Return.'';
} else {
diff --git a/classes/class_torrent.php b/classes/class_torrent.php
index e99f65c4..0b4ae334 100644
--- a/classes/class_torrent.php
+++ b/classes/class_torrent.php
@@ -11,7 +11,7 @@
There are 4 data types in bencode:
* String
* Int
-* List - array without keys
+* List - array without keys
- like array('value', 'value 2', 'value 3', 'etc')
* Dictionary - array with string keys
- like array['key 1'] = 'value 1'; array['key 2'] = 'value 2';
@@ -25,22 +25,22 @@
- Stored as php strings. Not difficult to remember.
* Integers
- - Stored as php ints
+ - Stored as php ints
- must be casted with (int)
* Lists
- - Stored as a BENCODE_LIST object.
+ - Stored as a BENCODE_LIST object.
- The actual list is in BENCODE_LIST::$Val, as an array with incrementing integer indices
- The list in BENCODE_LIST::$Val is populated by the BENCODE_LIST::dec() function
* Dictionaries
- - Stored as a BENCODE_DICT object.
+ - Stored as a BENCODE_DICT object.
- The actual list is in BENCODE_DICT::$Val, as an array with string indices
- The list in BENCODE_DICT::$Val is populated by the BENCODE_DICT::dec() function
//----- BENCODE_* Objects -----//
-Lists and dictionaries are stored as objects. They each have the following
+Lists and dictionaries are stored as objects. They each have the following
functions:
* decode(Type, $Key)
@@ -59,15 +59,15 @@ functions:
- Relies mostly on the encode() function
Finally, as all torrents are just large dictionaries, the TORRENT class extends
-the BENCODE_DICT class.
-
+the BENCODE_DICT class.
+
*******************************************************************************/
class BENCODE {
var $Val; // Decoded array
var $Pos = 1; // Pointer that indicates our position in the string
var $Str = ''; // Torrent string
-
+
function __construct($Val, $IsParsed = false){
if(!$IsParsed) {
$this->Str = $Val;
@@ -76,8 +76,8 @@ function __construct($Val, $IsParsed = false){
$this->Val = $Val;
}
}
-
- // Decode an element based on the type. The type is really just an indicator.
+
+ // Decode an element based on the type. The type is really just an indicator.
function decode($Type, $Key){
if(is_number($Type)) { // Element is a string
// Get length of string
@@ -87,24 +87,24 @@ function decode($Type, $Key){
$StrLen.=$this->Str[$this->Pos];
}
$this->Val[$Key] = substr($this->Str, $this->Pos+2, $StrLen);
-
+
$this->Pos+=$StrLen;
$this->Pos+=2;
-
+
} elseif($Type == 'i') { // Element is an int
$this->Pos++;
-
+
// Find end of integer (first occurance of 'e' after position)
- $End = strpos($this->Str, 'e', $this->Pos);
-
+ $End = strpos($this->Str, 'e', $this->Pos);
+
// Get the integer, and - IMPORTANT - cast it as an int, so we know later that it's an int and not a string
- $this->Val[$Key] = (int)substr($this->Str, $this->Pos, $End-$this->Pos);
+ $this->Val[$Key] = (int)substr($this->Str, $this->Pos, $End-$this->Pos);
$this->Pos = $End+1;
-
+
} elseif($Type == 'l') { // Element is a list
$this->Val[$Key] = new BENCODE_LIST(substr($this->Str, $this->Pos));
$this->Pos += $this->Val[$Key]->Pos;
-
+
} elseif($Type == 'd') { // Element is a dictionary
$this->Val[$Key] = new BENCODE_DICT(substr($this->Str, $this->Pos));
$this->Pos += $this->Val[$Key]->Pos;
@@ -112,12 +112,12 @@ function decode($Type, $Key){
if (!empty($this->Val[$Key]->Val)) {
ksort($this->Val[$Key]->Val);
}
-
+
} else {
die('Invalid torrent file');
}
}
-
+
function encode($Val){
if(is_int($Val)) { // Integer
return 'i'.$Val.'e';
@@ -143,7 +143,7 @@ function enc(){
}
return $Str.'e';
}
-
+
// Decode a list
function dec(){
$Key = 0; // Array index
@@ -152,13 +152,13 @@ function dec(){
$Type = $this->Str[$this->Pos];
// $Type now indicates what type of element we're dealing with
// It's either an integer (string), 'i' (an integer), 'l' (a list), 'd' (a dictionary), or 'e' (end of dictionary/list)
-
+
if($Type == 'e') { // End of list
$this->Pos += 1;
unset($this->Str); // Since we're finished parsing the string, we don't need to store it anymore. Benchmarked - this makes the parser run way faster.
return;
}
-
+
// Decode the bencoded element.
// This function changes $this->Pos and $this->Val, so you don't have to.
$this->decode($Type, $Key);
@@ -180,22 +180,22 @@ function enc(){
}
return $Str.'e';
}
-
+
// Decode a dictionary
function dec(){
$Length = strlen($this->Str);
while($this->Pos<$Length) {
-
+
if($this->Str[$this->Pos] == 'e') { // End of dictionary
$this->Pos += 1;
unset($this->Str); // Since we're finished parsing the string, we don't need to store it anymore. Benchmarked - this makes the parser run way faster.
return;
}
-
+
// Get the dictionary key
// Length of the key, in bytes
$KeyLen = $this->Str[$this->Pos];
-
+
// Allow for multi-digit lengths
while($this->Str[$this->Pos+1]!=':' && $this->Pos+1<$Length) {
$this->Pos++;
@@ -204,21 +204,21 @@ function dec(){
// $this->Pos is now on the last letter of the key length
// Adding 2 brings it past that character and the ':' to the beginning of the string
$this->Pos+=2;
-
+
// Get the name of the key
- $Key = substr($this->Str, $this->Pos, $KeyLen);
-
+ $Key = substr($this->Str, $this->Pos, $KeyLen);
+
// Move the position past the key to the beginning of the element
$this->Pos+=$KeyLen;
$Type = $this->Str[$this->Pos];
// $Type now indicates what type of element we're dealing with
// It's either an integer (string), 'i' (an integer), 'l' (a list), 'd' (a dictionary), or 'e' (end of dictionary/list)
-
+
// Decode the bencoded element.
// This function changes $this->Pos and $this->Val, so you don't have to.
$this->decode($Type, $Key);
-
-
+
+
}
return true;
}
@@ -230,12 +230,12 @@ function dump() {
// Convenience function used for testing and figuring out how we store the data
print_r($this->Val);
}
-
+
function dump_data() {
// Function which serializes $this->Val for storage
return base64_encode(serialize($this->Val));
}
-
+
/*
To use this, please remove the announce-list unset in make_private and be sure to still set_announce_url for backwards compatibility
function set_multi_announce() {
@@ -249,14 +249,14 @@ function set_multi_announce() {
$this->Val['announce-list'] = $AnnounceList;
}
*/
-
+
function set_announce_url($Announce) {
$this->Val['announce'] = $Announce;
ksort($this->Val);
}
-
+
// Returns an array of:
- // * the files in the torrent
+ // * the files in the torrent
// * the total size of files described therein
function file_list() {
$FileList = array();
@@ -276,7 +276,7 @@ function file_list() {
foreach ($Files as $File) {
$FileSize = $File->Val['length'];
$TotalSize += $FileSize;
-
+
$FileName = ltrim(implode('/',$File->Val[$PathKey]->Val), '/');
$FileSizes[] = $FileSize;
$FileNames[] = $FileName;
@@ -296,26 +296,26 @@ function get_name() {
return $this->Val['info']->Val['name'];
}
}
-
+
function make_private() {
//----- The following properties do not affect the infohash:
-
+
// anounce-list is an unofficial extension to the protocol
// that allows for multiple trackers per torrent
unset($this->Val['announce-list']);
-
+
// Bitcomet & Azureus cache peers in here
unset($this->Val['nodes']);
-
+
// Azureus stores the dht_backup_enable flag here
unset($this->Val['azureus_properties']);
-
+
// Remove web-seeds
unset($this->Val['url-list']);
-
+
// Remove libtorrent resume info
unset($this->Val['libtorrent_resume']);
-
+
//----- End properties that do not affect the infohash
if ($this->Val['info']->Val['private']) {
return true; // Torrent is private
diff --git a/classes/class_torrent_32bit.php b/classes/class_torrent_32bit.php
index 547a478c..e1c9a766 100644
--- a/classes/class_torrent_32bit.php
+++ b/classes/class_torrent_32bit.php
@@ -11,7 +11,7 @@
There are 4 data types in bencode:
* String
* Int
-* List - array without keys
+* List - array without keys
- like array('value', 'value 2', 'value 3', 'etc')
* Dictionary - array with string keys
- like array['key 1'] = 'value 1'; array['key 2'] = 'value 2';
@@ -30,18 +30,18 @@
- If stored as an int on 32 bit boxes, it won't allow for any size over 2 gigs
* Lists
- - Stored as a BENCODE_LIST object.
+ - Stored as a BENCODE_LIST object.
- The actual list is in BENCODE_LIST::$Val, as an array with incrementing integer indices
- The list in BENCODE_LIST::$Val is populated by the BENCODE_LIST::dec() function
* Dictionaries
- - Stored as a BENCODE_DICT object.
+ - Stored as a BENCODE_DICT object.
- The actual list is in BENCODE_DICT::$Val, as an array with incrementing integer indices
- The list in BENCODE_DICT::$Val is populated by the BENCODE_DICT::dec() function
//----- BENCODE_* Objects -----//
-Lists and dictionaries are stored as objects. They each have the following
+Lists and dictionaries are stored as objects. They each have the following
functions:
* decode(Type, $Key)
@@ -60,15 +60,15 @@ functions:
- Relies mostly on the encode() function
Finally, as all torrents are just large dictionaries, the TORRENT class extends
-the BENCODE_DICT class.
+the BENCODE_DICT class.
**Note** The version we run doesn't store ints as strings marked with [*INT*]
We store them as php integers. You can do this too for added speed and reduced
hackery, if you're running a 64 bit box, or if you're running a 32 bit box and
-don't care about files larger than 2 gigs. The system with the [*INT*]s was
-coded up in around 4 minutes for STC when we discovered this problem, then
+don't care about files larger than 2 gigs. The system with the [*INT*]s was
+coded up in around 4 minutes for STC when we discovered this problem, then
discovered that floats aren't accurate enough to use. :(
*******************************************************************************/
@@ -76,7 +76,7 @@ class BENCODE {
var $Val; // Decoded array
var $Pos = 1; // Pointer that indicates our position in the string
var $Str = ''; // Torrent string
-
+
function __construct($Val, $IsParsed = false){
if(!$IsParsed) {
$this->Str = $Val;
@@ -96,35 +96,35 @@ function decode($Type, $Key){
$StrLen.=$this->Str[$this->Pos];
}
$this->Val[$Key] = substr($this->Str, $this->Pos+2, $StrLen);
-
+
$this->Pos+=$StrLen;
$this->Pos+=2;
-
+
} elseif($Type == 'i') { // Element is an int
$this->Pos++;
-
+
// Find end of integer (first occurance of 'e' after position)
- $End = strpos($this->Str, 'e', $this->Pos);
-
+ $End = strpos($this->Str, 'e', $this->Pos);
+
// Get the integer, and mark it as an int (on our version 64 bit box, we cast it to an int)
- $this->Val[$Key] = '[*INT*]'.substr($this->Str, $this->Pos, $End-$this->Pos);
+ $this->Val[$Key] = '[*INT*]'.substr($this->Str, $this->Pos, $End-$this->Pos);
$this->Pos = $End+1;
-
+
} elseif($Type == 'l') { // Element is a list
$this->Val[$Key] = new BENCODE_LIST(substr($this->Str, $this->Pos));
$this->Pos += $this->Val[$Key]->Pos;
-
+
} elseif($Type == 'd') { // Element is a dictionary
$this->Val[$Key] = new BENCODE_DICT(substr($this->Str, $this->Pos));
$this->Pos += $this->Val[$Key]->Pos;
// Sort by key to respect spec
ksort($this->Val[$Key]->Val);
-
+
} else {
die('Invalid torrent file');
}
}
-
+
function encode($Val){
if(is_string($Val)) {
if(substr($Val, 0, 7) == '[*INT*]') {
@@ -149,7 +149,7 @@ function enc(){
}
return $Str.'e';
}
-
+
// Decode a list
function dec(){
$Key = 0; // Array index
@@ -158,13 +158,13 @@ function dec(){
$Type = $this->Str[$this->Pos];
// $Type now indicates what type of element we're dealing with
// It's either an integer (string), 'i' (an integer), 'l' (a list), 'd' (a dictionary), or 'e' (end of dictionary/list)
-
+
if($Type == 'e') { // End of list
$this->Pos += 1;
unset($this->Str); // Since we're finished parsing the string, we don't need to store it anymore. Benchmarked - this makes the parser run way faster.
return;
}
-
+
// Decode the bencoded element.
// This function changes $this->Pos and $this->Val, so you don't have to.
$this->decode($Type, $Key);
@@ -183,22 +183,22 @@ function enc(){
}
return $Str.'e';
}
-
+
// Decode a dictionary
function dec(){
$Length = strlen($this->Str);
while($this->Pos<$Length) {
-
+
if($this->Str[$this->Pos] == 'e') { // End of dictionary
$this->Pos += 1;
unset($this->Str); // Since we're finished parsing the string, we don't need to store it anymore. Benchmarked - this makes the parser run way faster.
return;
}
-
+
// Get the dictionary key
// Length of the key, in bytes
$KeyLen = $this->Str[$this->Pos];
-
+
// Allow for multi-digit lengths
while($this->Str[$this->Pos+1]!=':' && $this->Pos+1<$Length) {
$this->Pos++;
@@ -207,21 +207,21 @@ function dec(){
// $this->Pos is now on the last letter of the key length
// Adding 2 brings it past that character and the ':' to the beginning of the string
$this->Pos+=2;
-
+
// Get the name of the key
- $Key = substr($this->Str, $this->Pos, $KeyLen);
-
+ $Key = substr($this->Str, $this->Pos, $KeyLen);
+
// Move the position past the key to the beginning of the element
$this->Pos+=$KeyLen;
$Type = $this->Str[$this->Pos];
// $Type now indicates what type of element we're dealing with
// It's either an integer (string), 'i' (an integer), 'l' (a list), 'd' (a dictionary), or 'e' (end of dictionary/list)
-
+
// Decode the bencoded element.
// This function changes $this->Pos and $this->Val, so you don't have to.
$this->decode($Type, $Key);
-
-
+
+
}
return true;
}
@@ -233,19 +233,19 @@ function dump() {
// Convenience function used for testing and figuring out how we store the data
print_r($this->Val);
}
-
+
function dump_data() {
// Function which serializes $this->Val for storage
return base64_encode(serialize($this->Val));
}
-
+
function set_announce_url($Announce) {
$this->Val['announce'] = $Announce;
ksort($this->Val);
}
-
+
// Returns an array of:
- // * the files in the torrent
+ // * the files in the torrent
// * the total size of files described therein
function file_list() {
$FileList = array();
@@ -265,7 +265,7 @@ function file_list() {
foreach ($Files as $File) {
$FileSize = substr($File->Val['length'], 7);
$TotalSize += $FileSize;
-
+
$FileName = ltrim(implode('/',$File->Val[$PathKey]->Val), '/');
$FileSizes[] = $FileSize;
$FileNames[] = $FileName;
@@ -285,7 +285,7 @@ function get_name() {
return $this->Val['info']->Val['name'];
}
}
-
+
function make_private() {
//----- The following properties do not affect the infohash:
diff --git a/classes/class_torrents.php b/classes/class_torrents.php
index 0fa027fe..a6aabbca 100644
--- a/classes/class_torrents.php
+++ b/classes/class_torrents.php
@@ -103,7 +103,7 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true,
while($Torrent = $DB->next_record(MYSQLI_ASSOC, true)) {
$Found[$Torrent['GroupID']]['Torrents'][$Torrent['ID']] = $Torrent;
}
-
+
// Cache it all
foreach ($Found as $GroupID=>$GroupInfo) {
$Cache->cache_value('torrent_group_'.$GroupID,
@@ -639,7 +639,7 @@ public static function can_use_token($Torrent) {
&& $LoggedUser['CanLeech'] == '1');
}
-
+
public static function has_snatched($TorrentID) {
global $DB, $Cache, $LoggedUser;
if (empty($LoggedUser) || !$LoggedUser['ShowSnatched']) {
diff --git a/classes/class_torrentsdl.php b/classes/class_torrentsdl.php
index 1948e9ca..91dc60c6 100644
--- a/classes/class_torrentsdl.php
+++ b/classes/class_torrentsdl.php
@@ -21,6 +21,8 @@ class TorrentsDL {
* @param string $Title name of the collection that will be created
*/
public function __construct(&$QueryResult, $Title) {
+ global $Cache;
+ $Cache->InternalCache = false; // The internal cache is almost completely useless for this
Zip::unlimit(); // Need more memory and longer timeout
$this->QueryResult = $QueryResult;
$this->Title = $Title;
@@ -168,6 +170,7 @@ public function errors() {
* @return file name with at most 180 characters that is valid on most systems
*/
public static function construct_file_name($Artist, $Album, $Year, $Media, $Format, $Encoding, $TorrentID = false, $TxtExtension = false) {
+ $TorrentArtist = Misc::file_string($Artist);
$TorrentName = Misc::file_string($Album);
if ($Year > 0) {
$TorrentName .= " - $Year";
@@ -190,8 +193,8 @@ public static function construct_file_name($Artist, $Album, $Year, $Media, $Form
if (!$TorrentName) {
$TorrentName = "No Name";
- } else if (strlen($TorrentName . $TorrentInfo) <= 197) {
- $TorrentName = Misc::file_string($Artist) . $TorrentName;
+ } else if (strlen($Artist . $TorrentName . $TorrentInfo) <= 196) {
+ $TorrentName = $Artist . $TorrentName;
}
// Leave some room to the user in case the file system limits the path length
diff --git a/classes/class_user_rank.php b/classes/class_user_rank.php
index 0997744e..7b93acba 100644
--- a/classes/class_user_rank.php
+++ b/classes/class_user_rank.php
@@ -3,33 +3,33 @@
define('PREFIX', 'percentiles_'); // Prefix for memcache keys, to make life easier
class USER_RANK {
-
+
// Returns a 101 row array (101 percentiles - 0 - 100), with the minimum value for that percentile as the value for each row
// BTW - ingenious
function build_table($MemKey, $Query) {
global $Cache,$DB;
-
+
$DB->query("DROP TEMPORARY TABLE IF EXISTS temp_stats");
-
+
$DB->query("CREATE TEMPORARY TABLE temp_stats
(ID int(10) NOT NULL PRIMARY KEY AUTO_INCREMENT,
Val bigint(20) NOT NULL);");
-
+
$DB->query("INSERT INTO temp_stats (Val) ".$Query);
-
+
$DB->query("SELECT COUNT(ID) FROM temp_stats");
list($UserCount) = $DB->next_record();
-
+
$DB->query("SELECT MIN(Val) FROM temp_stats GROUP BY CEIL(ID/(".(int)$UserCount."/100));");
-
+
$Table = $DB->to_array();
-
+
// Give a little variation to the cache length, so all the tables don't expire at the same time
- $Cache->cache_value($MemKey, $Table, 3600*24*rand(800,1000)*0.001);
-
+ $Cache->cache_value($MemKey, $Table, 3600*24*rand(800,1000)*0.001);
+
return $Table;
}
-
+
function table_query($TableName) {
switch($TableName) {
case 'uploaded':
@@ -57,11 +57,11 @@ function table_query($TableName) {
}
return $Query;
}
-
+
function get_rank($TableName, $Value) {
if($Value == 0) { return 0; }
global $Cache, $DB;
-
+
$Table = $Cache->get_value(PREFIX.$TableName);
if(!$Table) {
//Cache lock!
@@ -84,7 +84,7 @@ function get_rank($TableName, $Value) {
}
return 100; // 100th percentile
}
-
+
function overall_score($Uploaded, $Downloaded, $Uploads, $Requests, $Posts, $Bounty, $Artists, $Ratio){
// We can do this all in 1 line, but it's easier to read this way
if($Ratio>1) { $Ratio = 1; }
@@ -103,7 +103,7 @@ function overall_score($Uploaded, $Downloaded, $Uploads, $Requests, $Posts, $Bou
$TotalScore *= $Ratio;
return $TotalScore;
}
-
+
}
diff --git a/classes/class_useragent.php b/classes/class_useragent.php
index eb7185ad..ee1ac6fe 100644
--- a/classes/class_useragent.php
+++ b/classes/class_useragent.php
@@ -42,7 +42,7 @@ class USER_AGENT {
'RSS' => 'RSS Downloader'
*/
);
-
+
var $OperatingSystems = array(
//Mobile
'SymbianOS' => 'Symbian',
@@ -105,7 +105,7 @@ class USER_AGENT {
'win' => 'Windows',
'mac' => 'Mac OS X'
);
-
+
public function operating_system(&$UserAgentString) {
if (empty($UserAgentString)) {
return 'Hidden';
@@ -119,19 +119,19 @@ public function operating_system(&$UserAgentString) {
}
return $Return;
}
-
+
public function mobile(&$UserAgentString) {
if (strpos($UserAgentString, 'iPad')) {
return false;
}
-
+
//Mobi catches Mobile
if (/*strpos($UserAgentString, 'Mobile') || */strpos($UserAgentString, 'Device') || strpos($UserAgentString, 'Mobi') || strpos($UserAgentString, 'Mini') || strpos($UserAgentString, 'webOS')) {
return true;
}
return false;
}
-
+
public function browser(&$UserAgentString) {
if (empty($UserAgentString)) {
return 'Hidden';
diff --git a/classes/class_users.php b/classes/class_users.php
index f7834f50..fc074fe4 100644
--- a/classes/class_users.php
+++ b/classes/class_users.php
@@ -450,9 +450,9 @@ public static function format_username($UserID, $Badges = false, $IsWarned = tru
$Str .= ($UserInfo['Donor'] == 1) ? '' : '';
}
- $Str .= ($IsWarned && $UserInfo['Warned'] != '0000-00-00 00:00:00') ? '' : '';
$Str .= ($IsEnabled && $UserInfo['Enabled'] == 2) ? '' : '';
diff --git a/classes/class_view.php b/classes/class_view.php
index 6c238476..440316e0 100644
--- a/classes/class_view.php
+++ b/classes/class_view.php
@@ -104,7 +104,7 @@ public static function render_template ($TemplateName, $Args)
* @example
">Data
- *
+ *
* // The variable $id within box.phtml will be filled by $some_id
* View::parse('section/box.phtml', array('id' => $some_id));
*
diff --git a/classes/class_wiki.php b/classes/class_wiki.php
index e732491b..590f8c2a 100644
--- a/classes/class_wiki.php
+++ b/classes/class_wiki.php
@@ -3,11 +3,11 @@
## Wiki class ##
##########################################################################
-Seeing as each page has to manage its wiki separately (for performance
+Seeing as each page has to manage its wiki separately (for performance
reasons - JOINs instead of multiple queries), this class is rather bare.
-The only useful function in here is revision_history(). It creates a
-table with the revision history for that particular wiki page.
+The only useful function in here is revision_history(). It creates a
+table with the revision history for that particular wiki page.
class_wiki depends on your wiki table being structured like this:
@@ -23,9 +23,9 @@ class_wiki depends on your wiki table being structured like this:
| Time | datetime | NO | MUL | 0000-00-00 00:00:00 | |
+------------+--------------+------+-----+----------------------+-------+
-It is also recommended that you have a field in the main table for
+It is also recommended that you have a field in the main table for
whatever the page is (e.g. details.php main table = torrents), so you can
-do a JOIN.
+do a JOIN.
########################################################################*/
@@ -39,13 +39,13 @@ function WIKI($Table, $PageID, $BaseURL = ''){
$this->PageID = $PageID;
$this->BaseURL = $BaseURL;
}
-
+
function revision_history(){
global $DB;
-
+
$BaseURL = $this->BaseURL;
- $DB->query("SELECT
- RevisionID,
+ $DB->query("SELECT
+ RevisionID,
Summary,
Time,
UserID
@@ -62,7 +62,7 @@ function revision_history(){
//-----------------------------------------
$Row = 'a';
- while(list($RevisionID, $Summary, $Time, $UserID, $Username) = $DB->next_record()){
+ while(list($RevisionID, $Summary, $Time, $UserID, $Username) = $DB->next_record()){
$Row = ($Row == 'a') ? 'b' : 'a';
//------------------------------------------------------ ?>
@@ -84,7 +84,7 @@ function revision_history(){
//-------------------------------------------- ?>
-
+
}
} // class
?>
diff --git a/classes/class_zip.php b/classes/class_zip.php
index b3c1656c..2810117a 100644
--- a/classes/class_zip.php
+++ b/classes/class_zip.php
@@ -4,9 +4,9 @@
|*************************************************************************|
This class provides a convenient way for us to generate and serve zip
-archives to our end users, both from physical files, cached
+archives to our end users, both from physical files, cached
or already parsed data (torrent files). It's all done on the fly, due to
-the high probability that a filesystem stored archive will never be
+the high probability that a filesystem stored archive will never be
downloaded twice.
Utilizes gzcompress, based upon RFC 1950
@@ -39,7 +39,7 @@
$Zip->add_file($TorrentData, "Bookmarks/Artist - Album [2008].torrent");
Adds the parsed torrent to the archive in the Bookmarks folder (created simply by placing it in the path).
-
+
-----
* Then, close the archive to the user:
@@ -96,12 +96,12 @@ class Zip {
private $Structure = ''; // Structure saved to memory
private $FileOffset = 0; // Offset to write data
private $Data = ''; //An idea
-
+
public function __construct ($ArchiveName='Archive') {
header("Content-type: application/octet-stream"); //Stream download
header("Content-disposition: attachment; filename=\"$ArchiveName.zip\""); //Name the archive - Should not be urlencoded
}
-
+
public static function unlimit () {
ob_end_clean();
set_time_limit(3600); //Limit 1 hour
@@ -121,7 +121,7 @@ public function add_file ($FileData, $ArchivePath, $TimeStamp = 0) {
$ZipData = gzcompress($FileData); // Ditto.
$ZipData = substr ($ZipData, 2,(strlen($ZipData) - 6)); // Checksum resolution
$ZipLength = strlen($ZipData); //Ditto.
- $this->Data .= pack("V",$CRC32); // CRC-32
+ $this->Data .= pack("V",$CRC32); // CRC-32
$this->Data .= pack("V",$ZipLength); // Compressed filesize
$this->Data .= pack("V",$DataLength); // Uncompressed filesize
$this->Data .= pack("v",strlen($ArchivePath)); // Pathname length
@@ -136,10 +136,10 @@ public function add_file ($FileData, $ArchivePath, $TimeStamp = 0) {
/* Data descriptor
Not needed (only needed when 3rd bitflag is set), causes problems with OS X archive utility
$this->Data .= pack("V",$CRC32); // CRC-32
- $this->Data .= pack("V",$ZipLength); // Compressed filesize
- $this->Data .= pack("V",$DataLength); // Uncompressed filesize
+ $this->Data .= pack("V",$ZipLength); // Compressed filesize
+ $this->Data .= pack("V",$DataLength); // Uncompressed filesize
END data descriptor */
-
+
$FileDataLength = strlen($this->Data);
$this->ArchiveSize = $this->ArchiveSize + $FileDataLength; // All we really need is the size
$CurrentOffset = $this->ArchiveSize; // Update offsets
@@ -148,14 +148,14 @@ public function add_file ($FileData, $ArchivePath, $TimeStamp = 0) {
/* Central Directory Structure */
$CDS = "\x50\x4b\x01\x02"; // CDS signature
$CDS .="\x14\x00"; // Constructor version
- $CDS .="\x14\x00"; // Version requirements
+ $CDS .="\x14\x00"; // Version requirements
$CDS .="\x00\x08"; // Bit flag - 0x8 = UTF-8 file names
$CDS .="\x08\x00"; // Compression
- $CDS .="\x00\x00\x00\x00"; // Last modified
- $CDS .= pack("V",$CRC32); // CRC-32
- $CDS .= pack("V",$ZipLength); // Compressed filesize
- $CDS .= pack("V",$DataLength); // Uncompressed filesize
- $CDS .= pack("v",strlen($ArchivePath)); // Pathname length
+ $CDS .="\x00\x00\x00\x00"; // Last modified
+ $CDS .= pack("V",$CRC32); // CRC-32
+ $CDS .= pack("V",$ZipLength); // Compressed filesize
+ $CDS .= pack("V",$DataLength); // Uncompressed filesize
+ $CDS .= pack("v",strlen($ArchivePath)); // Pathname length
$CDS .="\x00\x00"; // Extra field length (0'd so we can ignore this)
$CDS .="\x00\x00"; // File comment length (no comment, 0'd)
$CDS .="\x00\x00"; // Disk number start (0 seems valid)
@@ -171,14 +171,14 @@ public function add_file ($FileData, $ArchivePath, $TimeStamp = 0) {
}
public function close_stream() {
- echo $this->Structure; // Structure Root
+ echo $this->Structure; // Structure Root
echo "\x50\x4b\x05\x06"; // End of central directory signature
echo "\x00\x00"; // This disk
- echo "\x00\x00"; // CDS start
+ echo "\x00\x00"; // CDS start
echo pack("v", $this->ArchiveFiles); // Handle the numebr of entries
echo pack("v", $this->ArchiveFiles); // Ditto
- echo pack("V", strlen($this->Structure)); //Size
- echo pack("V", $this->ArchiveSize); // Offset
+ echo pack("V", strlen($this->Structure)); //Size
+ echo pack("V", $this->ArchiveSize); // Offset
echo "\x00\x00"; // No comment, close it off
}
}
diff --git a/classes/permissions_form.php b/classes/permissions_form.php
index 4cd95ec2..63c2828d 100644
--- a/classes/permissions_form.php
+++ b/classes/permissions_form.php
@@ -6,7 +6,7 @@
** This function is used to create both the class permissions form, and the **
** user custom permissions form. **
********************************************************************************/
-
+
$PermissionsArray = array(
'site_leech' => 'Can leech (Does this work?).',
'site_upload' => 'Upload torrent access.',
@@ -31,7 +31,7 @@
'site_moderate_requests' => 'Request moderation access.',
'site_delete_artist' => 'Can delete artists (must be able to delete torrents+requests).',
'site_moderate_forums' => 'Forum moderation access.',
-
+
'site_admin_forums' => 'Forum administrator access.',
'site_forums_double_post' => 'Can double post in the forums.',
'site_view_flow' => 'Can view stats and data pools.',
@@ -113,7 +113,7 @@
'artist_edit_vanityhouse' => 'Can mark artists as part of Vanity House.'
);
-
+
function permissions_form(){ ?>
@@ -216,9 +216,9 @@ function permissions_form(){ ?>
diff --git a/sections/collages/delete.php b/sections/collages/delete.php
index 7fc6c54c..dd957c6f 100644
--- a/sections/collages/delete.php
+++ b/sections/collages/delete.php
@@ -1,8 +1,8 @@
$CollageID = $_GET['collageid'];
-if(!is_number($CollageID) || !$CollageID) {
- error(404);
+if(!is_number($CollageID) || !$CollageID) {
+ error(404);
}
$DB->query("SELECT Name, UserID FROM collages WHERE ID='$CollageID'");
diff --git a/sections/collages/get_post.php b/sections/collages/get_post.php
index f1dfd7be..a250d502 100644
--- a/sections/collages/get_post.php
+++ b/sections/collages/get_post.php
@@ -2,10 +2,10 @@
/*********************************************************************\
//--------------Get Post--------------------------------------------//
-This gets the raw BBCode of a post. It's used for editing and
-quoting posts.
+This gets the raw BBCode of a post. It's used for editing and
+quoting posts.
-It gets called if $_GET['action'] == 'get_post'. It requires
+It gets called if $_GET['action'] == 'get_post'. It requires
$_GET['post'], which is the ID of the post.
\*********************************************************************/
@@ -18,10 +18,10 @@
// Variables for database input
$PostID = $_GET['post'];
-// Mainly
+// Mainly
$DB->query("SELECT Body FROM collages_comments WHERE ID='$PostID'");
list($Body) = $DB->next_record(MYSQLI_NUM);
-// This gets sent to the browser, which echoes it wherever
+// This gets sent to the browser, which echoes it wherever
echo trim($Body);
diff --git a/sections/collages/index.php b/sections/collages/index.php
index 48f4979f..51ff1116 100644
--- a/sections/collages/index.php
+++ b/sections/collages/index.php
@@ -66,11 +66,11 @@
if(!check_perms('site_collages_personal')) {
error(403);
}
-
+
$DB->query("SELECT COUNT(ID) FROM collages WHERE UserID='$LoggedUser[ID]' AND CategoryID='0' AND Deleted='0'");
list($CollageCount) = $DB->next_record();
-
- if($CollageCount >= $LoggedUser['Permissions']['MaxCollages']) {
+
+ if($CollageCount >= $LoggedUser['Permissions']['MaxCollages']) {
list($CollageID) = $DB->next_record();
header('Location: collage.php?id='.$CollageID);
die();
diff --git a/sections/collages/manage_handle.php b/sections/collages/manage_handle.php
index b2aff75a..9c66716d 100644
--- a/sections/collages/manage_handle.php
+++ b/sections/collages/manage_handle.php
@@ -44,6 +44,6 @@
if(!is_number($Sort)) { error(404); }
$DB->query("UPDATE collages_torrents SET Sort='$Sort' WHERE CollageID='$CollageID' AND GroupID='$GroupID'");
}
-
+
$Cache->delete_value('collage_'.$CollageID);
header('Location: collages.php?action=manage&collageid='.$CollageID);
diff --git a/sections/collages/new.php b/sections/collages/new.php
index 101e3344..80cbba90 100644
--- a/sections/collages/new.php
+++ b/sections/collages/new.php
@@ -38,10 +38,10 @@
-
Theme - A collage containing releases that all relate to a certain theme (e.g. "Searching for the Perfect Beat", "Concept Albums", "Funky Groove", etc.).
+
Theme - A collage containing releases that all relate to a certain theme (e.g. "Searching for the Perfect Beat", "Concept Albums", "Funky Groove", etc.).
Genre introduction - A subjective introduction to a genre composed by our own users.
Discography - A collage containing all the releases of an artist. Useful for keeping track of side-projects.
Label - A collage containing all the releases of a particular record label.
@@ -58,8 +58,8 @@
Charts - Contains all the releases that comprise a certain type of chart (e.g. Billboard Top 100, Pitchfork Top 100, What.cd Top 10, etc.).
Last edited by
@@ -53,4 +53,4 @@ function comment_body($UserID, $PostID, $postheader, $permalink, $Body, $EditorI
- }
+ }
diff --git a/sections/donate/ipn.php b/sections/donate/ipn.php
index 82bd6433..d4cf3936 100644
--- a/sections/donate/ipn.php
+++ b/sections/donate/ipn.php
@@ -52,7 +52,7 @@
//Repeat donor
Misc::send_pm($_POST['custom'],0,db_string('Thank you for your donation'),db_string('Your donation from '.$_POST['payer_email'].' of '.$_POST['mc_gross'].' '.PAYPAL_CURRENCY.' has been successfully processed. Your continued support is highly appreciated and helps to make this place possible.'),'');
}
-
+
}
}
@@ -84,14 +84,14 @@
$Cache->update_row(false, array('Invites' => $Invites));
$Cache->commit_transaction(0);
Misc::send_pm($_POST['custom'],0,db_string('Notice of donation failure'),db_string('PapPal has just notified us that the donation you sent from '.$_POST['payer_email'].' of '.$TotalDonated.' '.PAYPAL_CURRENCY.' at '.$DonationTime.' UTC has been revoked. Because of this your special privileges have been revoked, and your invites removed.'),'');
-
-
+
+
send_irc("PRIVMSG ".BOT_REPORT_CHAN." :".$Message);
}
}
}
- $DB->query("UPDATE users_info
- SET
+ $DB->query("UPDATE users_info
+ SET
AdminComment=CONCAT('".sqltime()." - User donated ".db_string($_POST['mc_gross'])." ".db_string(PAYPAL_CURRENCY)." from ".db_string($_POST['payer_email']).".\n',AdminComment)
WHERE UserID='".$_POST['custom']."'");
$DB->query("INSERT INTO donations
diff --git a/sections/feeds/index.php b/sections/feeds/index.php
index d194a129..c84ff8b3 100644
--- a/sections/feeds/index.php
+++ b/sections/feeds/index.php
@@ -1,14 +1,14 @@
// Main feeds page
// The feeds don't use script_start.php, their code resides entirely in feeds.php in the document root
-// 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 (
- empty($_GET['feed']) ||
- empty($_GET['authkey']) ||
- empty($_GET['auth']) ||
- empty($_GET['passkey']) ||
- empty($_GET['user']) ||
+ empty($_GET['feed']) ||
+ empty($_GET['authkey']) ||
+ empty($_GET['auth']) ||
+ empty($_GET['passkey']) ||
+ empty($_GET['user']) ||
!is_number($_GET['user']) ||
strlen($_GET['authkey']) != 32 ||
strlen($_GET['passkey']) != 32 ||
@@ -41,7 +41,7 @@
$Feed->open_feed();
switch($_GET['feed']) {
- case 'feed_news':
+ case 'feed_news':
include(SERVER_ROOT.'/classes/class_text.php');
$Text = new TEXT;
$Feed->channel('News', 'RSS feed for site news.');
@@ -71,7 +71,7 @@
}
}
break;
- case 'feed_blog':
+ case 'feed_blog':
include(SERVER_ROOT.'/classes/class_text.php');
$Text = new TEXT;
$Feed->channel('Blog', 'RSS feed for site blog.');
@@ -100,75 +100,75 @@
}
}
break;
- case 'torrents_all':
+ case 'torrents_all':
$Feed->channel('All Torrents', 'RSS feed for all new torrent uploads.');
$Feed->retrieve('torrents_all',$_GET['authkey'],$_GET['passkey']);
break;
- case 'torrents_music':
+ case 'torrents_music':
$Feed->channel('Music Torrents', 'RSS feed for all new music torrents.');
- $Feed->retrieve('torrents_music',$_GET['authkey'],$_GET['passkey']);
+ $Feed->retrieve('torrents_music',$_GET['authkey'],$_GET['passkey']);
break;
- case 'torrents_apps':
+ case 'torrents_apps':
$Feed->channel('Application Torrents', 'RSS feed for all new application torrents.');
- $Feed->retrieve('torrents_apps',$_GET['authkey'],$_GET['passkey']);
+ $Feed->retrieve('torrents_apps',$_GET['authkey'],$_GET['passkey']);
break;
- case 'torrents_ebooks':
+ case 'torrents_ebooks':
$Feed->channel('E-Book Torrents', 'RSS feed for all new e-book torrents.');
- $Feed->retrieve('torrents_ebooks',$_GET['authkey'],$_GET['passkey']);
+ $Feed->retrieve('torrents_ebooks',$_GET['authkey'],$_GET['passkey']);
break;
- case 'torrents_abooks':
+ case 'torrents_abooks':
$Feed->channel('Audiobook Torrents', 'RSS feed for all new audiobook torrents.');
- $Feed->retrieve('torrents_abooks',$_GET['authkey'],$_GET['passkey']);
+ $Feed->retrieve('torrents_abooks',$_GET['authkey'],$_GET['passkey']);
break;
- case 'torrents_evids':
+ case 'torrents_evids':
$Feed->channel('E-Learning Video Torrents', 'RSS feed for all new e-learning video torrents.');
- $Feed->retrieve('torrents_evids',$_GET['authkey'],$_GET['passkey']);
+ $Feed->retrieve('torrents_evids',$_GET['authkey'],$_GET['passkey']);
break;
- case 'torrents_comedy':
+ case 'torrents_comedy':
$Feed->channel('Comedy Torrents', 'RSS feed for all new comedy torrents.');
- $Feed->retrieve('torrents_comedy',$_GET['authkey'],$_GET['passkey']);
+ $Feed->retrieve('torrents_comedy',$_GET['authkey'],$_GET['passkey']);
break;
- case 'torrents_comics':
+ case 'torrents_comics':
$Feed->channel('Comic Torrents', 'RSS feed for all new comic torrents.');
- $Feed->retrieve('torrents_comics',$_GET['authkey'],$_GET['passkey']);
+ $Feed->retrieve('torrents_comics',$_GET['authkey'],$_GET['passkey']);
break;
- case 'torrents_mp3':
+ case 'torrents_mp3':
$Feed->channel('MP3 Torrents', 'RSS feed for all new mp3 torrents.');
- $Feed->retrieve('torrents_mp3',$_GET['authkey'],$_GET['passkey']);
+ $Feed->retrieve('torrents_mp3',$_GET['authkey'],$_GET['passkey']);
break;
- case 'torrents_flac':
+ case 'torrents_flac':
$Feed->channel('FLAC Torrents', 'RSS feed for all new FLAC torrents.');
- $Feed->retrieve('torrents_flac',$_GET['authkey'],$_GET['passkey']);
+ $Feed->retrieve('torrents_flac',$_GET['authkey'],$_GET['passkey']);
break;
- case 'torrents_vinyl':
+ case 'torrents_vinyl':
$Feed->channel('Vinyl Sourced Torrents', 'RSS feed for all new vinyl sourced torrents.');
- $Feed->retrieve('torrents_vinyl',$_GET['authkey'],$_GET['passkey']);
+ $Feed->retrieve('torrents_vinyl',$_GET['authkey'],$_GET['passkey']);
break;
- case 'torrents_lossless':
+ case 'torrents_lossless':
$Feed->channel('Lossless Torrents', 'RSS feed for all new lossless uploads.');
- $Feed->retrieve('torrents_lossless',$_GET['authkey'],$_GET['passkey']);
+ $Feed->retrieve('torrents_lossless',$_GET['authkey'],$_GET['passkey']);
break;
- case 'torrents_lossless24':
+ case 'torrents_lossless24':
$Feed->channel('24bit Lossless Torrents', 'RSS feed for all new 24bit uploads.');
- $Feed->retrieve('torrents_lossless24',$_GET['authkey'],$_GET['passkey']);
+ $Feed->retrieve('torrents_lossless24',$_GET['authkey'],$_GET['passkey']);
break;
default:
// Personalized torrents
if(empty($_GET['name']) && substr($_GET['feed'], 0, 16) == 'torrents_notify_'){
// All personalized torrent notifications
$Feed->channel('Personalized torrent notifications', 'RSS feed for personalized torrent notifications.');
- $Feed->retrieve($_GET['feed'],$_GET['authkey'],$_GET['passkey']);
+ $Feed->retrieve($_GET['feed'],$_GET['authkey'],$_GET['passkey']);
} elseif(!empty($_GET['name']) && substr($_GET['feed'], 0, 16) == 'torrents_notify_'){
// Specific personalized torrent notification channel
$Feed->channel(display_str($_GET['name']), 'Personal RSS feed: '.display_str($_GET['name']));
- $Feed->retrieve($_GET['feed'],$_GET['authkey'],$_GET['passkey']);
+ $Feed->retrieve($_GET['feed'],$_GET['authkey'],$_GET['passkey']);
} elseif(!empty($_GET['name']) && substr($_GET['feed'], 0, 21) == 'torrents_bookmarks_t_') {
// Bookmarks
$Feed->channel('Bookmarked torrent notifications', 'RSS feed for bookmarked torrents.');
- $Feed->retrieve($_GET['feed'],$_GET['authkey'],$_GET['passkey']);
+ $Feed->retrieve($_GET['feed'],$_GET['authkey'],$_GET['passkey']);
} else {
$Feed->channel('All Torrents', 'RSS feed for all new torrent uploads.');
- $Feed->retrieve('torrents_all',$_GET['authkey'],$_GET['passkey']);
+ $Feed->retrieve('torrents_all',$_GET['authkey'],$_GET['passkey']);
}
}
$Feed->close_feed();
diff --git a/sections/forums/ajax_get_edit.php b/sections/forums/ajax_get_edit.php
index 856aea61..23249268 100644
--- a/sections/forums/ajax_get_edit.php
+++ b/sections/forums/ajax_get_edit.php
@@ -26,13 +26,13 @@
$Edits = $Cache->get_value($Type.'_edits_'.$PostID);
if(!is_array($Edits)) {
$DB->query("SELECT ce.EditUser, ce.EditTime, ce.Body
- FROM comments_edits AS ce
+ FROM comments_edits AS ce
WHERE Page = '".$Type."' AND PostID = ".$PostID."
ORDER BY ce.EditTime DESC");
$Edits = $DB->to_array();
$Cache->cache_value($Type.'_edits_'.$PostID, $Edits, 0);
}
-
+
list($UserID, $Time) = $Edits[$Depth];
if($Depth != 0) {
list(,,$Body) = $Edits[$Depth - 1];
diff --git a/sections/forums/change_vote.php b/sections/forums/change_vote.php
index 5dd8783b..1e9ee145 100644
--- a/sections/forums/change_vote.php
+++ b/sections/forums/change_vote.php
@@ -16,7 +16,7 @@
$DB->query("UPDATE forums_polls_votes SET Vote = ".$NewVote." WHERE TopicID = ".$ThreadID." AND UserID = ".$LoggedUser['ID']);
$Cache->delete_value('polls_'.$ThreadID);
header("Location: forums.php?action=viewthread&threadid=".$ThreadID);
-
+
} else {
error(404);
}
diff --git a/sections/forums/delete.php b/sections/forums/delete.php
index 610dccd4..f2237c73 100644
--- a/sections/forums/delete.php
+++ b/sections/forums/delete.php
@@ -10,7 +10,7 @@
}
// Get topicid, forumid, number of pages
-$DB->query("SELECT
+$DB->query("SELECT
TopicID,
ForumID,
CEIL(COUNT(p.ID)/".POSTS_PER_PAGE.") AS Pages,
diff --git a/sections/forums/delete_poll_option.php b/sections/forums/delete_poll_option.php
index e67a971a..9edb7c11 100644
--- a/sections/forums/delete_poll_option.php
+++ b/sections/forums/delete_poll_option.php
@@ -29,7 +29,7 @@
$Cache->delete_value('polls_'.$ThreadID);
header("Location: forums.php?action=viewthread&threadid=".$ThreadID);
-
+
} else {
error(404);
}
diff --git a/sections/forums/forum.php b/sections/forums/forum.php
index a6095837..02a5aac7 100644
--- a/sections/forums/forum.php
+++ b/sections/forums/forum.php
@@ -53,7 +53,7 @@
list($Stickies) = $DB->next_record();
$Cache->cache_value('forums_'.$ForumID, array($Forum,'',0,$Stickies), 0);
}
-}
+}
if(!isset($Forums[$ForumID])) { error(404); }
@@ -79,7 +79,7 @@
diff --git a/sections/staffpm/ajax_delete_response.php b/sections/staffpm/ajax_delete_response.php
index 30653bd1..f1c1b9e1 100644
--- a/sections/staffpm/ajax_delete_response.php
+++ b/sections/staffpm/ajax_delete_response.php
@@ -19,9 +19,9 @@
}
if ($ID = (int)$_POST['id']) {
- $DB->query("DELETE FROM staff_pm_responses WHERE ID=$ID");
+ $DB->query("DELETE FROM staff_pm_responses WHERE ID=$ID");
echo '1';
-
+
} else {
// No id
echo '-1';
diff --git a/sections/staffpm/ajax_edit_response.php b/sections/staffpm/ajax_edit_response.php
index a37add79..7f576813 100644
--- a/sections/staffpm/ajax_edit_response.php
+++ b/sections/staffpm/ajax_edit_response.php
@@ -40,7 +40,7 @@
// No id
echo '-2';
}
-
+
} else {
// No message/name
echo '-1';
diff --git a/sections/staffpm/ajax_get_response.php b/sections/staffpm/ajax_get_response.php
index b1562d7e..3f590bbc 100644
--- a/sections/staffpm/ajax_get_response.php
+++ b/sections/staffpm/ajax_get_response.php
@@ -28,7 +28,7 @@
$Text = new TEXT;
echo $Text->full_format($Message);
}
-
+
} else {
// No id
echo '-1';
diff --git a/sections/staffpm/assign.php b/sections/staffpm/assign.php
index b04d1c29..63a37b38 100644
--- a/sections/staffpm/assign.php
+++ b/sections/staffpm/assign.php
@@ -8,7 +8,7 @@
// FLS, check level of conversation
$DB->query("SELECT Level FROM staff_pm_conversations WHERE ID=$ConvID");
list($Level) = $DB->next_record;
-
+
if ($Level == 0) {
// FLS conversation, assign to staff (moderator)
if(!empty($_GET['to'])) {
@@ -24,7 +24,7 @@
error(404);
break;
}
-
+
$DB->query("UPDATE staff_pm_conversations SET Status='Unanswered', Level=".$Level." WHERE ID=$ConvID");
header('Location: staffpm.php');
} else {
@@ -34,16 +34,16 @@
// FLS trying to assign non-FLS conversation
error(403);
}
-
+
} elseif ($ConvID = (int)$_POST['convid']) {
// Staff (via ajax), get current assign of conversation
$DB->query("SELECT Level, AssignedToUser FROM staff_pm_conversations WHERE ID=$ConvID");
list($Level, $AssignedToUser) = $DB->next_record;
-
+
if ($LoggedUser['EffectiveClass'] >= $Level || $AssignedToUser == $LoggedUser['ID']) {
// Staff member is allowed to assign conversation, assign
list($LevelType, $NewLevel) = explode("_", db_string($_POST['assign']));
-
+
if ($LevelType == 'class') {
// Assign to class
$DB->query("UPDATE staff_pm_conversations SET Status='Unanswered', Level=$NewLevel, AssignedToUser=NULL WHERE ID=$ConvID");
@@ -53,18 +53,18 @@
if (!$Level) {
error("Assign to user not found.");
}
-
+
// Assign to user
$DB->query("UPDATE staff_pm_conversations SET Status='Unanswered', AssignedToUser=$NewLevel, Level=$Level WHERE ID=$ConvID");
}
echo '1';
-
+
} else {
// Staff member is not allowed to assign conversation
echo '-1';
}
-
+
} else {
// No id
header('Location: staffpm.php');
diff --git a/sections/staffpm/common_responses.php b/sections/staffpm/common_responses.php
index 6c7f89fb..b3813fe1 100644
--- a/sections/staffpm/common_responses.php
+++ b/sections/staffpm/common_responses.php
@@ -37,15 +37,15 @@
- Name:
- Name:
+
-
@@ -63,7 +63,7 @@
// List common responses
$DB->query("SELECT ID, Message, Name FROM staff_pm_responses ORDER BY ID DESC");
while(list($ID, $Message, $Name) = $DB->next_record()) {
-
+
?>
@@ -71,7 +71,7 @@
- Name:
+ Name:
@@ -88,7 +88,7 @@
-
+
}
?>
diff --git a/sections/staffpm/get_post.php b/sections/staffpm/get_post.php
index b29b51ca..bfc8172e 100644
--- a/sections/staffpm/get_post.php
+++ b/sections/staffpm/get_post.php
@@ -3,10 +3,10 @@
/*********************************************************************\
//--------------Get Post--------------------------------------------//
-This gets the raw BBCode of a post. It's used for editing and
-quoting posts.
+This gets the raw BBCode of a post. It's used for editing and
+quoting posts.
-It gets called if $_GET['action'] == 'get_post'. It requires
+It gets called if $_GET['action'] == 'get_post'. It requires
$_GET['post'], which is the ID of the post.
\*********************************************************************/
@@ -21,14 +21,14 @@
// Message is selected providing the user quoting is the guy who opened the PM or has
// the right level
-$DB->query("SELECT m.Message, c.Level, c.UserID
+$DB->query("SELECT m.Message, c.Level, c.UserID
FROM staff_pm_messages as m
JOIN staff_pm_conversations AS c ON m.ConvID=c.ID
WHERE m.ID='$PostID'");
list($Message, $Level, $UserID) = $DB->next_record(MYSQLI_NUM);
if (($LoggedUser['ID'] == $UserID) || ($IsFLS && $LoggedUser['Class'] >= $Level)) {
- // This gets sent to the browser, which echoes it wherever
+ // This gets sent to the browser, which echoes it wherever
echo trim($Message);
} else {
error(403);
diff --git a/sections/staffpm/index.php b/sections/staffpm/index.php
index 02da29de..92d5ebc5 100644
--- a/sections/staffpm/index.php
+++ b/sections/staffpm/index.php
@@ -21,7 +21,7 @@
$IsFLS = ($IsStaff || $LoggedUser['ExtraClasses'][41]);
switch($_REQUEST['action']) {
- case 'viewconv':
+ case 'viewconv':
require('viewconv.php');
break;
case 'takepost':
diff --git a/sections/staffpm/makedonor.php b/sections/staffpm/makedonor.php
index 6d6cb680..1aca71f8 100644
--- a/sections/staffpm/makedonor.php
+++ b/sections/staffpm/makedonor.php
@@ -2,11 +2,11 @@
if (!is_number($_GET['id'])) {
error(404);
}
-
+
if (!check_perms('users_give_donor')) {
error(403);
}
-
+
$ConvID = (int)$_GET['id'];
$DB->query("SELECT c.Subject, c.UserID, c.Level, c.AssignedToUser, c.Unread, c.Status, u.Donor
FROM staff_pm_conversations AS c
@@ -16,14 +16,14 @@
if ($DB->record_count() == 0) {
error(404);
}
-
+
$Message = "Thank for for helping to support the site. It's users like you who make all of this possible.";
-
+
if ((int)$Donor === 0) {
$Msg = db_string(sqltime() . ' - Donated: http://'.NONSSL_SITE_URL."/staffpm.php?action=viewconv&id=$ConvID\n\n");
- $DB->query("UPDATE users_info
+ $DB->query("UPDATE users_info
SET Donor='1',
- AdminComment = CONCAT('$Msg',AdminComment)
+ AdminComment = CONCAT('$Msg',AdminComment)
WHERE UserID = $UserID");
$DB->query("UPDATE users_main SET Invites=Invites+2 WHERE ID = $UserID");
@@ -35,8 +35,8 @@
}
$DB->query("INSERT INTO staff_pm_messages (UserID, SentDate, Message, ConvID)
VALUES (".$LoggedUser['ID'].", '".sqltime()."', '".db_string($Message)."', $ConvID)");
- $DB->query("UPDATE staff_pm_conversations
- SET Date='".sqltime()."', Unread=true,
+ $DB->query("UPDATE staff_pm_conversations
+ SET Date='".sqltime()."', Unread=true,
Status='Resolved', ResolverID=".$LoggedUser['ID']."
WHERE ID=$ConvID");
header('Location: staffpm.php');
diff --git a/sections/staffpm/multiresolve.php b/sections/staffpm/multiresolve.php
index 63756dd3..c559158e 100644
--- a/sections/staffpm/multiresolve.php
+++ b/sections/staffpm/multiresolve.php
@@ -3,11 +3,11 @@
$Queries = array();
foreach ($IDs as &$ID) {
$ID = (int)$ID;
-
+
// Check if conversation belongs to user
$DB->query("SELECT UserID, AssignedToUser FROM staff_pm_conversations WHERE ID=$ID");
list($UserID, $AssignedToUser) = $DB->next_record();
-
+
if ($UserID == $LoggedUser['ID'] || $DisplayStaff == '1' || $UserID == $AssignedToUser) {
// Conversation belongs to user or user is staff, queue query
$Queries[] = "UPDATE staff_pm_conversations SET Status='Resolved', ResolverID=".$LoggedUser['ID']." WHERE ID=$ID";
@@ -16,7 +16,7 @@
error(403);
}
}
-
+
// Run queries
foreach ($Queries as $Query) {
$DB->query($Query);
@@ -27,7 +27,7 @@
// Done! Return to inbox
header("Location: staffpm.php");
-
+
} else {
// No id
header("Location: staffpm.php");
diff --git a/sections/staffpm/resolve.php b/sections/staffpm/resolve.php
index 3fe11535..c7eba539 100644
--- a/sections/staffpm/resolve.php
+++ b/sections/staffpm/resolve.php
@@ -3,7 +3,7 @@
// Check if conversation belongs to user
$DB->query("SELECT UserID, AssignedToUser FROM staff_pm_conversations WHERE ID=$ID");
list($UserID, $AssignedToUser) = $DB->next_record();
-
+
if ($UserID == $LoggedUser['ID'] || $IsFLS || $AssignedToUser == $LoggedUser['ID']) {
// Conversation belongs to user or user is staff, resolve it
$DB->query("UPDATE staff_pm_conversations SET Status='Resolved', ResolverID=".$LoggedUser['ID']." WHERE ID=$ID");
diff --git a/sections/staffpm/takepost.php b/sections/staffpm/takepost.php
index dc8039c4..bb6e3867 100644
--- a/sections/staffpm/takepost.php
+++ b/sections/staffpm/takepost.php
@@ -4,12 +4,12 @@
// New staff pm conversation
$Level = db_string($_POST['level']);
$DB->query("
- INSERT INTO staff_pm_conversations
+ INSERT INTO staff_pm_conversations
(Subject, Status, Level, UserID, Date)
VALUES
('$Subject', 'Unanswered', $Level, ".$LoggedUser['ID'].", '".sqltime()."')"
);
-
+
// New message
$ConvID = $DB->inserted_id();
$DB->query("
@@ -18,16 +18,16 @@
VALUES
(".$LoggedUser['ID'].", '".sqltime()."', '$Message', $ConvID)"
);
-
+
header('Location: staffpm.php');
-
+
} elseif ($ConvID = (int)$_POST['convid']) {
// Check if conversation belongs to user
$DB->query("SELECT UserID, AssignedToUser FROM staff_pm_conversations WHERE ID=$ConvID");
list($UserID, $AssignedToUser) = $DB->next_record();
-
-
+
+
if ($UserID == $LoggedUser['ID'] || $IsFLS || $UserID == $AssignedToUser) {
// Response to existing conversation
$DB->query("
@@ -36,7 +36,7 @@
VALUES
(".$LoggedUser['ID'].", '".sqltime()."', '$Message', $ConvID)"
);
-
+
// Update conversation
if ($IsFLS) {
// FLS/Staff
@@ -50,22 +50,22 @@
// Clear cache for user
$Cache->delete_value('staff_pm_new_'.$UserID);
$Cache->delete_value('staff_pm_new_'.$LoggedUser['ID']);
-
+
header("Location: staffpm.php?action=viewconv&id=$ConvID");
} else {
// User is trying to respond to conversation that does no belong to them
error(403);
}
-
+
} else {
// Message but no subject or conversation id
header("Location: staffpm.php?action=viewconv&id=$ConvID");
-
+
}
} elseif ($ConvID = (int)$_POST['convid']) {
// No message, but conversation id
header("Location: staffpm.php?action=viewconv&id=$ConvID");
-
+
} else {
// No message or conversation id
header('Location: staffpm.php');
diff --git a/sections/staffpm/unresolve.php b/sections/staffpm/unresolve.php
index d91412a6..bca816be 100644
--- a/sections/staffpm/unresolve.php
+++ b/sections/staffpm/unresolve.php
@@ -3,8 +3,8 @@
// Check if conversation belongs to user
$DB->query("SELECT UserID, Level, AssignedToUser FROM staff_pm_conversations WHERE ID=$ID");
list($UserID, $Level, $AssignedToUser) = $DB->next_record();
-
- if ($UserID == $LoggedUser['ID'] || ($IsFLS && $Level == 0) ||
+
+ if ($UserID == $LoggedUser['ID'] || ($IsFLS && $Level == 0) ||
$AssignedToUser == $LoggedUser['ID'] || ($IsStaff && $Level <= $LoggedUser['EffectiveClass'])) {
/*if($Level != 0 && $IsStaff == false) {
error(403);
@@ -14,7 +14,7 @@
$DB->query("UPDATE staff_pm_conversations SET Status='Unanswered' WHERE ID=$ID");
// Clear cache for user
$Cache->delete_value('num_staff_pms_'.$LoggedUser['ID']);
-
+
header('Location: staffpm.php');
} else {
// Conversation does not belong to user
diff --git a/sections/staffpm/user_inbox.php b/sections/staffpm/user_inbox.php
index ce0fd3dc..b1d0562d 100644
--- a/sections/staffpm/user_inbox.php
+++ b/sections/staffpm/user_inbox.php
@@ -7,16 +7,16 @@
// Get messages
$StaffPMs = $DB->query("
SELECT
- ID,
- Subject,
- UserID,
- Status,
- Level,
- AssignedToUser,
- Date,
+ ID,
+ Subject,
+ UserID,
+ Status,
+ Level,
+ AssignedToUser,
+ Date,
Unread
- FROM staff_pm_conversations
- WHERE UserID=".$LoggedUser['ID']."
+ FROM staff_pm_conversations
+ WHERE UserID=".$LoggedUser['ID']."
ORDER BY Status, Date DESC"
);
@@ -73,7 +73,7 @@
Resolved messages
-
+
Subject
@@ -87,7 +87,7 @@
$Assigned = ($Level == 0) ? "First Line Support" : $ClassLevels[$Level]['Name'];
// No + on Sysops
if ($Assigned != 'Sysop') { $Assigned .= "+"; }
-
+
// Table row
?>
diff --git a/sections/tools/data/registration_log.php b/sections/tools/data/registration_log.php
index d970e665..b11cd85c 100644
--- a/sections/tools/data/registration_log.php
+++ b/sections/tools/data/registration_log.php
@@ -5,7 +5,7 @@
list($Page,$Limit) = Format::page_limit(USERS_PER_PAGE);
-$RS = $DB->query("SELECT
+$RS = $DB->query("SELECT
SQL_CALC_FOUND_ROWS
m.ID,
m.IP,
@@ -32,12 +32,12 @@
ii.Donor,
ii.Warned,
ii.JoinDate,
- (SELECT COUNT(h2.UserID) FROM users_history_ips AS h2 WHERE h2.IP=im.IP) AS InviterUses
- FROM users_main AS m
+ (SELECT COUNT(h2.UserID) FROM users_history_ips AS h2 WHERE h2.IP=im.IP) AS InviterUses
+ FROM users_main AS m
LEFT JOIN users_info AS i ON i.UserID=m.ID
LEFT JOIN users_main AS im ON i.Inviter = im.ID
LEFT JOIN users_info AS ii ON i.Inviter = ii.UserID
- WHERE i.JoinDate > '".time_minus(3600*24*3)."'
+ WHERE i.JoinDate > '".time_minus(3600*24*3)."'
ORDER BY i.Joindate DESC LIMIT $Limit");
$DB->query("SELECT FOUND_ROWS()");
list($Results) = $DB->next_record();
diff --git a/sections/tools/data/service_stats.php b/sections/tools/data/service_stats.php
index 1a4545d9..720278ab 100644
--- a/sections/tools/data/service_stats.php
+++ b/sections/tools/data/service_stats.php
@@ -1,8 +1,8 @@
if(!check_perms('site_debug')) { error(403); }
-if(isset($_POST['global_flush'])){
+if(isset($_POST['global_flush'])){
authorize();
- $Cache->flush();
+ $Cache->flush();
}
$DB->query('SHOW GLOBAL STATUS');
$DBStats =$DB->to_array('Variable_name');
diff --git a/sections/tools/data/suggestions.php b/sections/tools/data/suggestions.php
index 01541a4c..411d8e05 100644
--- a/sections/tools/data/suggestions.php
+++ b/sections/tools/data/suggestions.php
@@ -34,9 +34,9 @@
Count
- $DB->query("SELECT
- s.UserID, count(s.ThreadID) AS C
- FROM marked_suggestions AS s
+ $DB->query("SELECT
+ s.UserID, count(s.ThreadID) AS C
+ FROM marked_suggestions AS s
GROUP BY s.UserID ORDER BY c DESC LIMIT 15");
$Row = 'b';
while ( list ($UserID, $Count) = $DB->next_record() ) {
@@ -57,9 +57,9 @@
Count
- $DB->query("SELECT
- LastPostAuthorID, count(LastPostAuthorID) AS C
- FROM forums_topics AS f
+ $DB->query("SELECT
+ LastPostAuthorID, count(LastPostAuthorID) AS C
+ FROM forums_topics AS f
WHERE ForumID = 63 AND f.Title LIKE '[implemented]%'
GROUP BY LastPostAuthorID ORDER BY c DESC LIMIT 15");
$Row = 'b';
@@ -82,8 +82,8 @@
$DB->query("SELECT
- LastPostAuthorID, count(LastPostAuthorID) AS C
- FROM forums_topics AS f
+ LastPostAuthorID, count(LastPostAuthorID) AS C
+ FROM forums_topics AS f
WHERE ForumID = 63 AND f.Title LIKE '[rejected]%'
GROUP BY LastPostAuthorID ORDER BY c DESC LIMIT 15");
$Row = 'b';
diff --git a/sections/tools/data/torrent_stats.php b/sections/tools/data/torrent_stats.php
index 361e822f..8aa5063c 100644
--- a/sections/tools/data/torrent_stats.php
+++ b/sections/tools/data/torrent_stats.php
@@ -2,7 +2,7 @@
if(!check_perms('site_view_flow')) { error(403); }
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");
list($TorrentCount, $TotalSize, $TotalFiles) = $DB->next_record();
$DB->query("SELECT COUNT(ID) FROM users_main WHERE Enabled='1'");
diff --git a/sections/tools/data/upscale_pool.php b/sections/tools/data/upscale_pool.php
index 3e301462..563db3c4 100644
--- a/sections/tools/data/upscale_pool.php
+++ b/sections/tools/data/upscale_pool.php
@@ -4,7 +4,7 @@
define('USERS_PER_PAGE', 50);
list($Page,$Limit) = Format::page_limit(USERS_PER_PAGE);
-$RS = $DB->query("SELECT
+$RS = $DB->query("SELECT
SQL_CALC_FOUND_ROWS
m.ID,
m.Username,
@@ -18,7 +18,7 @@
i.RatioWatchEnds,
i.RatioWatchDownload,
m.RequiredRatio
- FROM users_main AS m
+ FROM users_main AS m
LEFT JOIN users_info AS i ON i.UserID=m.ID
WHERE i.RatioWatchEnds != '0000-00-00 00:00:00'
AND m.Enabled = '1'
diff --git a/sections/tools/data/user_flow.php b/sections/tools/data/user_flow.php
index 50052f42..57daf3e7 100644
--- a/sections/tools/data/user_flow.php
+++ b/sections/tools/data/user_flow.php
@@ -119,7 +119,7 @@
(+) Joined
(-) Manual
(-) Ratio
-
(-) Inactivity
+
(-) Inactivity
(-) Total
Net Growth
diff --git a/sections/tools/index.php b/sections/tools/index.php
index 9e02b573..0e72ec11 100644
--- a/sections/tools/index.php
+++ b/sections/tools/index.php
@@ -89,7 +89,7 @@
case 'recommend_alter':
include('managers/recommend_alter.php');
break;
-
+
case 'recommend_restore':
include('managers/recommend_restore.php');
break;
@@ -101,7 +101,7 @@
case 'eb_alter':
include('managers/eb_alter.php');
break;
-
+
case 'eb_search':
include('managers/eb_search.php');
break;
@@ -150,15 +150,15 @@
if(!check_perms('admin_manage_news')){ error(403); }
$DB->query("INSERT INTO news (UserID, Title, Body, Time) VALUES ('$LoggedUser[ID]', '".db_string($_POST['title'])."', '".db_string($_POST['body'])."', '".sqltime()."')");
+
-
-
+
$Cache->cache_value('news_latest_id', $DB->inserted_id(), 0);
$Cache->delete_value('news');
-
+
header('Location: index.php');
break;
-
+
case 'tokens':
include('managers/tokens.php');
break;
@@ -189,7 +189,7 @@
error(403);
}
$Values = unserialize($Values);
- }
+ }
if (!empty($_POST['submit'])) {
$Err = $Val->ValidateForm($_POST);
@@ -365,31 +365,31 @@
case 'sandbox2':
include('misc/sandbox2.php');
break;
-
+
case 'sandbox3':
include('misc/sandbox3.php');
break;
-
+
case 'sandbox4':
include('misc/sandbox4.php');
break;
-
+
case 'sandbox5':
include('misc/sandbox5.php');
break;
-
+
case 'sandbox6':
include('misc/sandbox6.php');
break;
-
+
case 'sandbox7':
include('misc/sandbox7.php');
break;
-
+
case 'sandbox8':
include('misc/sandbox8.php');
break;
-
+
case 'public_sandbox':
include('misc/public_sandbox.php');
break;
diff --git a/sections/tools/managers/bans.php b/sections/tools/managers/bans.php
index c1fa511d..09254c6f 100644
--- a/sections/tools/managers/bans.php
+++ b/sections/tools/managers/bans.php
@@ -15,7 +15,7 @@
$Val->SetFields('notes', '1','string','You must include the reason for the ban.');
$Err=$Val->ValidateForm($_POST); // Validate the form
if($Err){ error($Err); }
-
+
$Notes = db_string($_POST['notes']);
$Start = Tools::ip_to_unsigned($_POST['start']); //Sanitized by Validation regex
$End = Tools::ip_to_unsigned($_POST['end']); //See above
@@ -89,7 +89,7 @@
-
+
diff --git a/sections/tools/managers/dnu_alter.php b/sections/tools/managers/dnu_alter.php
index 1c42ca34..eef51699 100644
--- a/sections/tools/managers/dnu_alter.php
+++ b/sections/tools/managers/dnu_alter.php
@@ -24,7 +24,7 @@
Time='".sqltime()."'
WHERE ID='$P[id]'");
} else { //Create
- $DB->query("INSERT INTO do_not_upload
+ $DB->query("INSERT INTO do_not_upload
(Name, Comment, UserID, Time) VALUES
('$P[name]','$P[comment]','$LoggedUser[ID]','".sqltime()."')");
}
diff --git a/sections/tools/managers/eb.php b/sections/tools/managers/eb.php
index c4b77fb0..d466f335 100644
--- a/sections/tools/managers/eb.php
+++ b/sections/tools/managers/eb.php
@@ -13,7 +13,7 @@
eb.Time,
eb.Email,
eb.Comment
- FROM email_blacklist AS eb
+ FROM email_blacklist AS eb
ORDER BY eb.Time DESC LIMIT $Limit");
$Results = $DB->to_array(false, MYSQLI_ASSOC, false);
$DB->query("SELECT FOUND_ROWS()");
@@ -49,7 +49,7 @@
-
+
foreach ($Results as $Result) {
?>
} ?>
diff --git a/sections/tools/managers/tokens.php b/sections/tools/managers/tokens.php
index 1f603307..30e93dd3 100644
--- a/sections/tools/managers/tokens.php
+++ b/sections/tools/managers/tokens.php
@@ -4,7 +4,7 @@
if (isset($_REQUEST['addtokens'])) {
authorize();
$Tokens = $_REQUEST['numtokens'];
-
+
if (!is_number($Tokens) || ($Tokens < 0)) { error("Please enter a valid number of tokens."); }
$sql = "UPDATE users_main SET FLTokens = FLTokens + $Tokens WHERE Enabled = '1'";
if (!isset($_REQUEST['leechdisabled'])) {
@@ -23,9 +23,9 @@
} elseif (isset($_REQUEST['cleartokens'])) {
authorize();
$Tokens = $_REQUEST['numtokens'];
-
+
if (!is_number($Tokens) || ($Tokens < 0)) { error("Please enter a valid number of tokens."); }
-
+
if (isset($_REQUEST['onlydrop'])) {
$Where = "WHERE FLTokens > $Tokens";
} elseif (!isset($_REQUEST['leechdisabled'])) {
@@ -36,12 +36,12 @@
$DB->query("SELECT ID FROM users_main $Where");
$Users = $DB->to_array();
$DB->query("UPDATE users_main SET FLTokens = $Tokens $Where");
-
+
foreach ($Users as $UserID) {
list($UserID) = $UserID;
$Cache->delete_value('user_info_heavy_'.$UserID);
}
-
+
$where = "";
}
diff --git a/sections/tools/managers/whitelist_alter.php b/sections/tools/managers/whitelist_alter.php
index b6dbbd3b..57662bcb 100644
--- a/sections/tools/managers/whitelist_alter.php
+++ b/sections/tools/managers/whitelist_alter.php
@@ -9,18 +9,18 @@
if(!is_number($_POST['id']) || $_POST['id'] == ''){
error("1");
}
-
+
$DB->query("SELECT peer_id FROM xbt_client_whitelist WHERE id = ".$_POST['id']);
list($PeerID) = $DB->next_record();
$DB->query('DELETE FROM xbt_client_whitelist WHERE id='.$_POST['id']);
Tracker::update_tracker('remove_whitelist', array('peer_id' => $PeerID));
} else { //Edit & Create, Shared Validation
-
+
if(empty($_POST['client']) || empty($_POST['peer_id'])) {
print_r($_POST);
die();
}
-
+
$Client = db_string($_POST['client']);
$PeerID = db_string($_POST['peer_id']);
@@ -38,7 +38,7 @@
}
} else { //Create
$DB->query("INSERT INTO xbt_client_whitelist
- (vstring, peer_id)
+ (vstring, peer_id)
VALUES
('".$Client."','".$PeerID."')");
Tracker::update_tracker('add_whitelist', array('peer_id' => $PeerID));
diff --git a/sections/tools/managers/whitelist_list.php b/sections/tools/managers/whitelist_list.php
index 7f0bcb45..cc4684cd 100644
--- a/sections/tools/managers/whitelist_list.php
+++ b/sections/tools/managers/whitelist_list.php
@@ -46,8 +46,8 @@
Add Client
-
-
+
+
diff --git a/sections/tools/misc/create_user.php b/sections/tools/misc/create_user.php
index caf002d8..2fb4fb2b 100644
--- a/sections/tools/misc/create_user.php
+++ b/sections/tools/misc/create_user.php
@@ -13,7 +13,7 @@
$Username = $_POST['Username'];
$Email = $_POST['Email'];
$Password = $_POST['Password'];
-
+
//Make sure all the fields are filled in
if (!empty($Username) && !empty($Email) && !empty($Password)) {
@@ -23,53 +23,53 @@
//Create the account
$DB->query("INSERT INTO users_main (Username,Email,PassHash,torrent_pass,Enabled,PermissionID, Language) VALUES ('".db_string($Username)."','".db_string($Email)."','".db_string(Users::make_crypt_hash($Password))."','".db_string($torrent_pass)."','1','".USER."', 'en')");
-
+
//Increment site user count
$Cache->increment('stats_user_count');
-
+
//Grab the userid
$UserID=$DB->inserted_id();
-
+
Tracker::update_tracker('add_user', array('id' => $UserID, 'passkey' => $torrent_pass));
//Default stylesheet
$DB->query("SELECT ID FROM stylesheets");
list($StyleID)=$DB->next_record();
-
+
//Auth key
$AuthKey = Users::make_secret();
-
+
//Give them a row in users_info
- $DB->query("INSERT INTO users_info
- (UserID,StyleID,AuthKey,JoinDate) VALUES
+ $DB->query("INSERT INTO users_info
+ (UserID,StyleID,AuthKey,JoinDate) VALUES
('".db_string($UserID)."','".db_string($StyleID)."','".db_string($AuthKey)."', '".sqltime()."')");
-
+
//Redirect to users profile
header ("Location: user.php?id=".$UserID);
-
+
//What to do if we don't have a username, email, or password
} elseif (empty($Username)) {
-
+
//Give the Error -- We do not have a username
error("Please supply a username");
-
+
} elseif (empty($Email)) {
-
+
//Give the Error -- We do not have an email address
error("Please supply an email address");
-
+
} elseif (empty($Password)) {
-
+
//Give the Error -- We do not have a password
error("Please supply a password");
-
+
} else {
-
+
//Uh oh, something went wrong
error("Unknown error");
-
+
}
-
+
//Form wasn't sent -- Show form
} else {
@@ -77,7 +77,7 @@
Create a User
-
+
diff --git a/sections/tools/misc/dupe_ip.php b/sections/tools/misc/dupe_ip.php
index ad060752..7a177e80 100644
--- a/sections/tools/misc/dupe_ip.php
+++ b/sections/tools/misc/dupe_ip.php
@@ -6,7 +6,7 @@
list($Page,$Limit) = Format::page_limit(USERS_PER_PAGE);
-$RS = $DB->query("SELECT
+$RS = $DB->query("SELECT
SQL_CALC_FOUND_ROWS
m.ID,
m.IP,
@@ -17,7 +17,7 @@
i.Warned,
i.JoinDate,
(SELECT COUNT(DISTINCT h.UserID) FROM users_history_ips AS h WHERE h.IP=m.IP) AS Uses
- FROM users_main AS m
+ FROM users_main AS m
LEFT JOIN users_info AS i ON i.UserID=m.ID
WHERE (SELECT COUNT(DISTINCT h.UserID) FROM users_history_ips AS h WHERE h.IP=m.IP) >= ".IP_OVERLAPS."
AND m.Enabled = '1'
diff --git a/sections/tools/misc/manipulate_tree.php b/sections/tools/misc/manipulate_tree.php
index 92bf36e2..363d929b 100644
--- a/sections/tools/misc/manipulate_tree.php
+++ b/sections/tools/misc/manipulate_tree.php
@@ -1,9 +1,9 @@
//Props to Leto of StC.
if (
- !check_perms('users_view_invites') &&
- !check_perms('users_disable_users') &&
- !check_perms('users_edit_invites') &&
+ !check_perms('users_view_invites') &&
+ !check_perms('users_disable_users') &&
+ !check_perms('users_edit_invites') &&
!check_perms('users_disable_any')
) { error(404); }
View::show_header("Manipulate Invite Tree");
@@ -12,16 +12,16 @@
authorize();
if(!is_number($_POST['id'])) { error(403); }
- if(!$_POST['comment']) { error('Please enter a comment to add to the users affected.');
+ if(!$_POST['comment']) { error('Please enter a comment to add to the users affected.');
} else { $Comment = db_string($_POST['comment']); }
$UserID = $_POST['id'];
- $DB->query("SELECT
- t1.TreePosition,
- t1.TreeID,
- t1.TreeLevel,
- (SELECT
- t2.TreePosition FROM invite_tree AS t2
- WHERE TreeID=t1.TreeID AND TreeLevel=t1.TreeLevel AND t2.TreePosition>t1.TreePosition
+ $DB->query("SELECT
+ t1.TreePosition,
+ t1.TreeID,
+ t1.TreeLevel,
+ (SELECT
+ t2.TreePosition FROM invite_tree AS t2
+ WHERE TreeID=t1.TreeID AND TreeLevel=t1.TreeLevel AND t2.TreePosition>t1.TreePosition
ORDER BY TreePosition LIMIT 1
) AS MaxPosition
FROM invite_tree AS t1
@@ -30,14 +30,14 @@
if(!$MaxPosition){ $MaxPosition = 1000000; } // $MaxPermission is null if the user is the last one in that tree on that level
if(!$TreeID){ return; }
$DB->query("
- SELECT
+ SELECT
UserID
FROM invite_tree
WHERE TreeID=$TreeID
AND TreePosition>$TreePosition
AND TreePosition<$MaxPosition
AND TreeLevel>$TreeLevel
- ORDER BY TreePosition");
+ ORDER BY TreePosition");
$BanList = array();
while(list($Invitee) = $DB->next_record()) {
@@ -73,7 +73,7 @@
SET Enabled='2'
WHERE ID='".$InviteeID."'");
$Msg = "Successfully banned entire invite tree!";
- } elseif ($_POST['perform']=='inviteprivs') { //DisableInvites =1
+ } elseif ($_POST['perform']=='inviteprivs') { //DisableInvites =1
$DB->query("UPDATE
users_info
SET DisableInvites='1'
diff --git a/sections/tools/misc/update_geoip.php b/sections/tools/misc/update_geoip.php
index 6f78bab2..d1756d75 100644
--- a/sections/tools/misc/update_geoip.php
+++ b/sections/tools/misc/update_geoip.php
@@ -102,7 +102,7 @@
$Start = Tools::ip_to_unsigned($Matches[2]);
if($Start == 2147483647) { continue; }
-
+
if (!isset($Current)) {
$Current = array('StartIP' => $Start, 'EndIP' => $Start + $Matches[3],'Code' => $Matches[1]);
} elseif ($Current['Code'] == $Matches[1] && $Current['EndIP'] == $Start) {
diff --git a/sections/tools/tools.php b/sections/tools/tools.php
index 9ae07623..6c1a0f83 100644
--- a/sections/tools/tools.php
+++ b/sections/tools/tools.php
@@ -91,7 +91,7 @@
-
+
- } ?>
+ } ?>
View::show_footer(); ?>
diff --git a/sections/torrents/editgroupid.php b/sections/torrents/editgroupid.php
index 475e078d..b7a7c016 100644
--- a/sections/torrents/editgroupid.php
+++ b/sections/torrents/editgroupid.php
@@ -1,8 +1,8 @@
/***************************************************************
* This page handles the backend of the "edit group ID" function
-* (found on edit.php). It simply changes the group ID of a
-* torrent.
+* (found on edit.php). It simply changes the group ID of a
+* torrent.
****************************************************************/
if(!check_perms('torrents_edit')) { error(403); }
@@ -36,7 +36,7 @@
}
$Artists = Artists::get_artists(array($OldGroupID, $GroupID));
-
+
View::show_header();
?>
@@ -67,7 +67,7 @@
$DB->query("UPDATE torrents
SET GroupID='$GroupID'
WHERE ID=$TorrentID");
-
+
// Delete old torrent group if it's empty now
$DB->query("SELECT COUNT(ID) FROM torrents WHERE GroupID='$OldGroupID'");
list($TorrentsInGroup) = $DB->next_record();
@@ -80,14 +80,14 @@
Torrents::update_hash($OldGroupID);
}
Torrents::update_hash($GroupID);
-
+
Misc::write_log("Torrent $TorrentID was edited by " . $LoggedUser['Username']); // TODO: this is probably broken
Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "merged group ".$OldGroupID, 0);
$DB->query("UPDATE group_log SET GroupID = ".$GroupID." WHERE GroupID = ".$OldGroupID);
-
- $Cache->delete_value('torrents_details_'.$GroupID);
+
+ $Cache->delete_value('torrents_details_'.$GroupID);
$Cache->delete_value('torrent_download_'.$TorrentID);
-
+
header("Location: torrents.php?id=$GroupID");
}
?>
\ No newline at end of file
diff --git a/sections/torrents/functions.php b/sections/torrents/functions.php
index ebe1d72e..34a89e4c 100644
--- a/sections/torrents/functions.php
+++ b/sections/torrents/functions.php
@@ -166,7 +166,7 @@ function get_group_requests($GroupID) {
return array();
}
global $DB, $Cache;
-
+
$Requests = $Cache->get_value('requests_group_'.$GroupID);
if ($Requests === FALSE) {
$DB->query("SELECT ID FROM requests WHERE GroupID = $GroupID AND TimeFilled = '0000-00-00 00:00:00'");
diff --git a/sections/torrents/history.php b/sections/torrents/history.php
index d897b8f3..6a73f6be 100644
--- a/sections/torrents/history.php
+++ b/sections/torrents/history.php
@@ -2,8 +2,8 @@
/************************************************************************
||------------|| Artist wiki history page ||---------------------------||
-This page lists previous revisions of the artists page. It gets called
-if $_GET['action'] == 'history'.
+This page lists previous revisions of the artists page. It gets called
+if $_GET['action'] == 'history'.
It also requires $_GET['artistid'].
diff --git a/sections/torrents/index.php b/sections/torrents/index.php
index 35b18ba7..9edc7d05 100644
--- a/sections/torrents/index.php
+++ b/sections/torrents/index.php
@@ -23,27 +23,27 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
enforce_login();
include(SERVER_ROOT.'/sections/torrents/edit.php');
break;
-
+
case 'editgroup':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/editgroup.php');
break;
-
+
case 'editgroupid':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/editgroupid.php');
break;
-
+
case 'takeedit':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/takeedit.php');
break;
-
+
case 'newgroup':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/takenewgroup.php');
break;
-
+
case 'peerlist':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/peerlist.php');
@@ -53,97 +53,97 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
enforce_login();
include(SERVER_ROOT.'/sections/torrents/snatchlist.php');
break;
-
+
case 'downloadlist':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/downloadlist.php');
break;
-
+
case 'redownload':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/redownload.php');
break;
-
+
case 'revert':
case 'takegroupedit':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/takegroupedit.php');
break;
-
+
case 'nonwikiedit':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/nonwikiedit.php');
break;
-
+
case 'rename':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/rename.php');
break;
-
+
case 'merge':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/merge.php');
break;
-
+
case 'add_alias':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/add_alias.php');
break;
-
+
case 'delete_alias':
enforce_login();
authorize();
include(SERVER_ROOT.'/sections/torrents/delete_alias.php');
break;
-
-
+
+
case 'history':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/history.php');
break;
-
+
case 'delete':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/delete.php');
break;
-
+
case 'takedelete':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/takedelete.php');
break;
-
+
case 'masspm':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/masspm.php');
break;
-
+
case 'reseed':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/reseed.php');
break;
-
+
case 'takemasspm':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/takemasspm.php');
break;
-
+
case 'vote_tag':
enforce_login();
authorize();
include(SERVER_ROOT.'/sections/torrents/vote_tag.php');
break;
-
+
case 'add_tag':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/add_tag.php');
break;
-
+
case 'delete_tag':
enforce_login();
authorize();
include(SERVER_ROOT.'/sections/torrents/delete_tag.php');
break;
-
+
case 'notify':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/notify.php');
@@ -151,7 +151,7 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
case 'manage_artists':
enforce_login();
- require(SERVER_ROOT.'/sections/torrents/manage_artists.php');
+ require(SERVER_ROOT.'/sections/torrents/manage_artists.php');
break;
case 'notify_clear':
@@ -170,28 +170,28 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
case 'download':
require(SERVER_ROOT.'/sections/torrents/download.php');
break;
-
+
case 'reply':
enforce_login();
authorize();
- if (!isset($_POST['groupid']) || !is_number($_POST['groupid']) || trim($_POST['body'])==='' || !isset($_POST['body'])) {
+ if (!isset($_POST['groupid']) || !is_number($_POST['groupid']) || trim($_POST['body'])==='' || !isset($_POST['body'])) {
error(0);
}
if($LoggedUser['DisablePosting']) {
error('Your posting rights have been removed.');
}
-
+
$GroupID = $_POST['groupid'];
if(!$GroupID) { error(404); }
-
+
$DB->query("SELECT CEIL((SELECT COUNT(ID)+1 FROM torrents_comments AS tc WHERE tc.GroupID='".db_string($GroupID)."')/".TORRENT_COMMENTS_PER_PAGE.") AS Pages");
list($Pages) = $DB->next_record();
-
+
$DB->query("INSERT INTO torrents_comments (GroupID,AuthorID,AddedTime,Body) VALUES (
'".db_string($GroupID)."', '".db_string($LoggedUser['ID'])."','".sqltime()."','".db_string($_POST['body'])."')");
$PostID=$DB->inserted_id();
-
+
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE*$Pages-TORRENT_COMMENTS_PER_PAGE)/THREAD_CATALOGUE);
$Cache->begin_transaction('torrent_comments_'.$GroupID.'_catalogue_'.$CatalogueID);
$Post = array(
@@ -206,29 +206,29 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
$Cache->insert('', $Post);
$Cache->commit_transaction(0);
$Cache->increment('torrent_comments_'.$GroupID);
-
+
header('Location: torrents.php?id='.$GroupID.'&page='.$Pages);
break;
-
+
case 'get_post':
enforce_login();
if (!$_GET['post'] || !is_number($_GET['post'])) { error(0); }
$DB->query("SELECT Body FROM torrents_comments WHERE ID='".db_string($_GET['post'])."'");
list($Body) = $DB->next_record(MYSQLI_NUM);
-
+
echo trim($Body);
break;
-
+
case 'takeedit_post':
enforce_login();
authorize();
include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class
$Text = new TEXT;
-
+
// Quick SQL injection check
if(!$_POST['post'] || !is_number($_POST['post'])) { error(0); }
-
+
// Mainly
$DB->query("SELECT
tc.Body,
@@ -238,24 +238,24 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
FROM torrents_comments AS tc
WHERE tc.ID='".db_string($_POST['post'])."'");
list($OldBody, $AuthorID,$GroupID,$AddedTime)=$DB->next_record();
-
+
$DB->query("SELECT ceil(COUNT(ID) / ".TORRENT_COMMENTS_PER_PAGE.") AS Page FROM torrents_comments WHERE GroupID = $GroupID AND ID <= $_POST[post]");
list($Page) = $DB->next_record();
-
+
if ($LoggedUser['ID']!=$AuthorID && !check_perms('site_moderate_forums')) { error(404); }
if ($DB->record_count()==0) { error(404); }
-
+
// Perform the update
$DB->query("UPDATE torrents_comments SET
Body = '".db_string($_POST['body'])."',
EditedUserID = '".db_string($LoggedUser['ID'])."',
EditedTime = '".sqltime()."'
WHERE ID='".db_string($_POST['post'])."'");
-
+
// Update the cache
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE*$Page-TORRENT_COMMENTS_PER_PAGE)/THREAD_CATALOGUE);
$Cache->begin_transaction('torrent_comments_'.$GroupID.'_catalogue_'.$CatalogueID);
-
+
$Cache->update_row($_POST['key'], array(
'ID'=>$_POST['post'],
'AuthorID'=>$AuthorID,
@@ -266,24 +266,24 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
'Username'=>$LoggedUser['Username']
));
$Cache->commit_transaction(0);
-
+
$DB->query("INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)
VALUES ('torrents', ".db_string($_POST['post']).", ".db_string($LoggedUser['ID']).", '".sqltime()."', '".db_string($OldBody)."')");
-
+
// This gets sent to the browser, which echoes it in place of the old body
echo $Text->full_format($_POST['body']);
break;
-
+
case 'delete_post':
enforce_login();
authorize();
-
+
// Quick SQL injection check
if (!$_GET['postid'] || !is_number($_GET['postid'])) { error(0); }
-
+
// Make sure they are moderators
if (!check_perms('site_moderate_forums')) { error(403); }
-
+
// Get topicid, forumid, number of pages
$DB->query("SELECT
GroupID,
@@ -293,23 +293,23 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
WHERE tc.GroupID=(SELECT GroupID FROM torrents_comments WHERE ID=".$_GET['postid'].")
GROUP BY tc.GroupID");
list($GroupID,$Pages,$Page)=$DB->next_record();
-
+
// $Pages = number of pages in the thread
// $Page = which page the post is on
// These are set for cache clearing.
-
+
$DB->query("DELETE FROM torrents_comments WHERE ID='".db_string($_GET['postid'])."'");
-
+
//We need to clear all subsequential catalogues as they've all been bumped with the absence of this post
$ThisCatalogue = floor((TORRENT_COMMENTS_PER_PAGE*$Page-TORRENT_COMMENTS_PER_PAGE)/THREAD_CATALOGUE);
$LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE*$Pages-TORRENT_COMMENTS_PER_PAGE)/THREAD_CATALOGUE);
for($i=$ThisCatalogue;$i<=$LastCatalogue;$i++) {
$Cache->delete('torrent_comments_'.$GroupID.'_catalogue_'.$i);
}
-
+
// Delete thread info cache (eg. number of pages)
$Cache->delete('torrent_comments_'.$GroupID);
-
+
break;
case 'regen_filelist' :
if(check_perms('users_mod') && !empty($_GET['torrentid']) && is_number($_GET['torrentid'])) {
@@ -345,7 +345,7 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
break;
default:
enforce_login();
-
+
if(!empty($_GET['id'])) {
include(SERVER_ROOT.'/sections/torrents/details.php');
} elseif(isset($_GET['torrentid']) && is_number($_GET['torrentid'])) {
@@ -385,6 +385,6 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
} else {
include(SERVER_ROOT.'/sections/torrents/browse2.php');
}
-
+
}
?>
diff --git a/sections/torrents/merge.php b/sections/torrents/merge.php
index 94945198..b84e220b 100644
--- a/sections/torrents/merge.php
+++ b/sections/torrents/merge.php
@@ -25,7 +25,7 @@
//Everything is legit, let's just confim they're not retarded
if(empty($_POST['confirm'])) {
$Artists = Artists::get_artists(array($GroupID, $NewGroupID));
-
+
View::show_header();
?>
@@ -51,7 +51,7 @@
View::show_footer();
} else {
authorize();
-
+
// Votes ninjutsu. This is so annoyingly complicated.
// 1. Get a list of everybody who voted on the old group and clear their cache keys
$DB->query("SELECT UserID FROM users_votes WHERE GroupID='$GroupID'");
@@ -67,7 +67,7 @@
FROM (SELECT IFNULL(SUM(IF(Type='Up',1,0)),0) As UpVotes,
COUNT(1) AS TotalVotes,
binomial_ci(IFNULL(SUM(IF(Type='Up',1,0)),0), COUNT(1)) AS VoteScore
- FROM users_votes
+ FROM users_votes
WHERE GroupID = $NewGroupID
GROUP BY GroupID) AS a
ON DUPLICATE KEY UPDATE
@@ -75,7 +75,7 @@
Total = a.TotalVotes,
Score = a.VoteScore;");
// 3. Clear the votes_pairs keys!
- $DB->query("SELECT v2.GroupID
+ $DB->query("SELECT v2.GroupID
FROM users_votes AS v1
INNER JOIN users_votes AS v2 USING (UserID)
WHERE (v1.Type = 'Up' OR v2.Type='Up')
@@ -85,19 +85,19 @@
$Cache->delete_value('vote_pairs_'.$CacheGroupID);
}
// 4. Clear the new groups vote keys
-
+
$DB->query("UPDATE torrents SET GroupID='$NewGroupID' WHERE GroupID='$GroupID'");
$DB->query("UPDATE wiki_torrents SET PageID='$NewGroupID' WHERE PageID='$GroupID'");
$DB->query("UPDATE torrents_comments SET GroupID='$NewGroupID' WHERE GroupID='$GroupID'");
-
+
Torrents::delete_group($GroupID);
Torrents::write_group_log($NewGroupID, 0, $LoggedUser['ID'], "Merged Group ".$GroupID." (".$Name.") to ".$NewGroupID." (".$NewName.")", 0);
$DB->query("UPDATE group_log SET GroupID = ".$NewGroupID." WHERE GroupID = ".$GroupID);
-
+
$GroupID=$NewGroupID;
-
+
//Collages
$DB->query("SELECT CollageID FROM collages_torrents WHERE GroupID='$OldGroupID'"); //Select all collages that contain edited group
while(list($CollageID) = $DB->next_record()) {
@@ -105,7 +105,7 @@
$DB->query("DELETE FROM collages_torrents WHERE GroupID='$OldGroupID' AND CollageID='$CollageID'");
$Cache->delete_value('collage_'.$CollageID);
}
-
+
//Requests
$DB->query("SELECT ID FROM requests WHERE GroupID='$OldGroupID'");
$Requests = $DB->collect('ID');
@@ -113,7 +113,7 @@
foreach ($Requests as $RequestID) {
$Cache->delete_value('request_'.$RequestID);
}
-
+
$DB->query("SELECT ID FROM torrents WHERE GroupID='$OldGroupID'");
while(list($TorrentID) = $DB->next_record()) {
$Cache->delete_value('torrent_download_'.$TorrentID);
@@ -123,7 +123,7 @@
$Cache->delete_value('torrent_comments_'.$GroupID);
$Cache->delete_value('groups_artists_'.$GroupID);
Torrents::update_hash($GroupID);
-
+
header('Location: torrents.php?id='.$GroupID);
}
?>
diff --git a/sections/torrents/nonwikiedit.php b/sections/torrents/nonwikiedit.php
index 1e156ccd..b8704e9f 100644
--- a/sections/torrents/nonwikiedit.php
+++ b/sections/torrents/nonwikiedit.php
@@ -11,7 +11,7 @@
//Usual perm checks
if(!check_perms('torrents_edit')) {
$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);
}
}
@@ -46,7 +46,7 @@
-$DB->query("UPDATE torrents_group SET
+$DB->query("UPDATE torrents_group SET
Year = '$Year',
RecordLabel = '".$RecordLabel."',
CatalogueNumber = '".$CatalogueNumber."'
diff --git a/sections/torrents/redownload.php b/sections/torrents/redownload.php
index baabca7a..63261e40 100644
--- a/sections/torrents/redownload.php
+++ b/sections/torrents/redownload.php
@@ -59,7 +59,7 @@
tg.Name,
t.Size
FROM torrents as t
- JOIN torrents_group AS tg ON t.GroupID=tg.ID
+ JOIN torrents_group AS tg ON t.GroupID=tg.ID
".$SQL."
GROUP BY TorrentID");
diff --git a/sections/torrents/reseed.php b/sections/torrents/reseed.php
index a1466b05..12137516 100644
--- a/sections/torrents/reseed.php
+++ b/sections/torrents/reseed.php
@@ -25,10 +25,10 @@
$Users = $DB->to_array();
foreach($Users as $User) {
$UserID = $User['uid'];
-
+
$DB->query("SELECT UserID FROM top_snatchers WHERE UserID='$UserID'");
if($DB->record_count()>0) { continue; }
-
+
$UserInfo = Users::user_info($UserID);
$Username = $UserInfo['Username'];
$TimeStamp = $User['tstamp'];
@@ -39,14 +39,14 @@
The exact process for re-seeding a torrent is slightly different for each client, but the concept is the same. The idea is to download the .torrent file and open it in your client, and point your client to the location where the data files are, then initiate a hash check.
Thanks!";
-
+
Misc::send_pm($UserID, 0, 'Re-seed request for torrent '.db_string($Name), db_string($Request));
}
$NumUsers = count($Users);
} else {
$UserInfo = Users::user_info($UploaderID);
$Username = $UserInfo['Username'];
-
+
$Request = "Hi $Username,
The user [url=http://".SITE_URL."/user.php?id=$LoggedUser[ID]]$LoggedUser[Username][/url] has requested a re-seed for the torrent [url=http://".SITE_URL."/torrents.php?id=$GroupID&torrentid=$TorrentID]".$Name."[/url], which you uploaded on ".date('M d Y', strtotime($UploadedTime)).". The torrent is now un-seeded, and we need your help to resurrect it!
@@ -55,9 +55,9 @@
Thanks!";
Misc::send_pm($UploaderID, 0, 'Re-seed request for torrent '.db_string($Name), db_string($Request));
-
+
$NumUsers = 1;
-
+
}
View::show_header();
?>
diff --git a/sections/torrents/snatchlist.php b/sections/torrents/snatchlist.php
index ef941446..d38e3331 100644
--- a/sections/torrents/snatchlist.php
+++ b/sections/torrents/snatchlist.php
@@ -33,7 +33,7 @@