From ba33634e1940376502985e193b89f34d7f80cc63 Mon Sep 17 00:00:00 2001 From: Git Date: Fri, 19 Apr 2013 08:00:55 +0000 Subject: [PATCH] Empty commit --- api.php | 57 +++-- classes/class_irc.php | 4 +- classes/class_mysql.php | 34 +-- classes/class_tools.php | 64 +++--- classes/class_users.php | 44 ++-- classes/permissions_form.php | 16 +- classes/sphinxapi.php | 14 +- design/privateheader.php | 2 +- sections/ajax/artist.php | 90 ++++---- sections/ajax/browse.php | 38 ++-- sections/ajax/index.php | 7 +- sections/ajax/info.php | 25 +-- sections/ajax/request.php | 9 +- sections/ajax/send_recommendation.php | 51 +++-- sections/ajax/top10/torrents.php | 30 +-- sections/ajax/torrentgroup.php | 18 +- sections/artist/artist.php | 5 +- sections/better/single.php | 27 ++- sections/blog/index.php | 75 +++---- sections/collages/add_torrent.php | 2 +- sections/collages/browse.php | 117 +++++----- sections/collages/collage.php | 55 +++-- sections/collages/index.php | 60 +++-- sections/collages/new.php | 38 ++-- sections/collages/new_handle.php | 22 +- sections/comments/artistcomments.php | 53 ++--- sections/comments/post.php | 44 ++-- sections/comments/torrentcomments.php | 97 ++++---- sections/donate/donate.php | 12 +- sections/donate/donate_gpal.php | 8 +- sections/donate/ipn.php | 2 +- sections/feeds/index.php | 4 +- sections/forums/forum.php | 138 ++++++------ sections/forums/index.php | 77 +++---- sections/forums/mod_thread.php | 275 ++++++++++++----------- sections/forums/newthread.php | 44 ++-- sections/forums/search.php | 140 ++++++------ sections/forums/take_new_thread.php | 90 ++++---- sections/friends/add.php | 8 +- sections/friends/comment.php | 9 +- sections/friends/friends.php | 41 ++-- sections/friends/index.php | 8 +- sections/friends/remove.php | 8 +- sections/image/index.php | 8 +- sections/index/private.php | 141 ++++++------ sections/login/index.php | 2 +- sections/reports/report.php | 62 +++--- sections/reportsv2/array.php | 142 ++++++------ sections/reportsv2/header.php | 4 +- sections/reportsv2/report.php | 130 ++++++----- sections/reportsv2/takereport.php | 54 ++--- sections/reportsv2/takeresolve.php | 8 +- sections/requests/new_edit.php | 99 +++++---- sections/requests/request.php | 4 +- sections/requests/takenew_edit.php | 256 +++++++++++----------- sections/schedule/index.php | 2 +- sections/tools/index.php | 12 +- sections/tools/managers/tag_aliases.php | 4 +- sections/tools/misc/tags.php | 265 ++++++++++++++++++++++ sections/tools/tools.php | 4 +- sections/top10/torrents.php | 61 ++++-- sections/top10/votes.php | 8 +- sections/torrents/browse.php | 6 +- sections/torrents/browse2.php | 55 ++++- sections/torrents/details.php | 4 +- sections/torrents/functions.php | 248 +++++++++++---------- sections/torrents/nonwikiedit.php | 2 +- sections/torrents/reseed.php | 20 +- sections/torrents/user.php | 280 +++++++++++++----------- sections/user/edit.php | 2 +- sections/user/takeinvite.php | 4 +- sections/user/takemoderate.php | 16 +- sections/userhistory/email_history.php | 44 ++-- static/functions/artist_cloud.js | 88 ++++---- static/functions/detect_mobile.js | 109 +++++---- static/functions/global.js | 70 +++--- static/functions/torrent.js | 38 ++-- 77 files changed, 2361 insertions(+), 1853 deletions(-) create mode 100644 sections/tools/misc/tags.php diff --git a/api.php b/api.php index 45985bca..cc262a96 100644 --- a/api.php +++ b/api.php @@ -1,10 +1,10 @@ ", '€','‚','ƒ','„','…','†','‡','ˆ','‰','Š','‹','Œ','Ž','‘','’','“','”','•','–','—','˜','™','š','›','œ','ž','Ÿ' ); - $With=array( + $With = array( ''','"','<','>', '€','‚','ƒ','„','…','†','‡','ˆ','‰','Š','‹','Œ','Ž','‘','’','“','”','•','–','—','˜','™','š','›','œ','ž','Ÿ' ); - $Str=str_replace($Replace,$With,$Str); + $Str = str_replace($Replace,$With,$Str); } return $Str; } function make_utf8($Str) { - if ($Str!="") { - if (is_utf8($Str)) { $Encoding="UTF-8"; } - if (empty($Encoding)) { $Encoding=mb_detect_encoding($Str,'UTF-8, ISO-8859-1'); } - if (empty($Encoding)) { $Encoding="ISO-8859-1"; } - if ($Encoding=="UTF-8") { return $Str; } - else { return @mb_convert_encoding($Str,"UTF-8",$Encoding); } + if ($Str != '') { + if (is_utf8($Str)) { + $Encoding = 'UTF-8'; + } + if (empty($Encoding)) { + $Encoding = mb_detect_encoding($Str,'UTF-8, ISO-8859-1'); + } + if (empty($Encoding)) { + $Encoding = 'ISO-8859-1'; + } + if ($Encoding == 'UTF-8') { + return $Str; + } else { + return @mb_convert_encoding($Str,'UTF-8',$Encoding); + } } } @@ -101,7 +112,7 @@ function is_utf8($Str) { function display_array($Array, $Escape = array()) { foreach ($Array as $Key => $Val) { - if((!is_array($Escape) && $Escape == true) || !in_array($Key, $Escape)) { + if ((!is_array($Escape) && $Escape == true) || !in_array($Key, $Escape)) { $Array[$Key] = display_str($Val); } } @@ -113,4 +124,4 @@ function display_array($Array, $Escape = array()) { header('Content-type: text/xml'); echo ''; require(SERVER_ROOT.'/sections/api/index.php'); -?> \ No newline at end of file +?> diff --git a/classes/class_irc.php b/classes/class_irc.php index 9aaa506e..dc57705f 100644 --- a/classes/class_irc.php +++ b/classes/class_irc.php @@ -3,7 +3,7 @@ class IRC_DB extends DB_MYSQL { function halt($Msg) { global $Bot; global $DB; - $Bot->send_to($Bot->get_channel(),'The database is currently unavailable try again later'); + $Bot->send_to($Bot->get_channel(),'The database is currently unavailable; try again later.'); } } @@ -69,7 +69,7 @@ public function post_connect() { $this->listen(); } - public function disconnect() { + public function disconnect() { socket_close($this->ListenSocket); $this->State = 0; //Drones dead } diff --git a/classes/class_mysql.php b/classes/class_mysql.php index 4d2a2abf..ac330b5d 100644 --- a/classes/class_mysql.php +++ b/classes/class_mysql.php @@ -113,7 +113,7 @@ } //Handles escaping -function db_string($String,$DisableWildcards=false) { +function db_string($String, $DisableWildcards = false) { global $DB; //Escape $String = $DB->escape_str($String); @@ -167,12 +167,12 @@ function __construct($Database = SQLDB, $User = SQLLOGIN, $Pass = SQLPASS, $Serv function halt($Msg) { global $LoggedUser, $Cache, $Debug, $argv; - $DBError='MySQL: '.strval($Msg).' SQL error: '.strval($this->Errno).' ('.strval($this->Error).')'; + $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) { preg_match("Table '(\S+)' is marked as crashed and should be repaired", $this->Error, $Matches); } */ - $Debug->analysis('!dev DB Error',$DBError,3600*24); + $Debug->analysis('!dev DB Error', $DBError, 3600 * 24); if (DEBUG_MODE || check_perms('site_debug') || isset($argv[1])) { echo '
'.display_str($DBError).'
'; if (DEBUG_MODE || check_perms('site_debug')) { @@ -195,24 +195,24 @@ function connect() { } } - function query($Query,$AutoHandle=1) { - global $LoggedUser, $Debug; - $QueryStartTime=microtime(true); + function query($Query, $AutoHandle = 1) { + global $LoggedUser, $Debug; + $QueryStartTime = microtime(true); $this->connect(); - //In the event of a mysql deadlock, we sleep allowing mysql time to unlock then attempt again for a maximum of 5 tries - for($i = 1; $i < 6; $i++) { - $this->QueryID = mysqli_query($this->LinkID,$Query); + // In the event of a MySQL deadlock, we sleep allowing MySQL time to unlock, then attempt again for a maximum of 5 tries + for ($i = 1; $i < 6; $i++) { + $this->QueryID = mysqli_query($this->LinkID, $Query); if (!in_array(mysqli_errno($this->LinkID), array(1213, 1205))) { break; } - $Debug->analysis('Non-Fatal Deadlock:',$Query,3600*24); + $Debug->analysis('Non-Fatal Deadlock:', $Query, 3600 * 24); trigger_error("Database deadlock, attempt $i"); - sleep($i*rand(2, 5)); // Wait longer as attempts increase + sleep($i * rand(2, 5)); // Wait longer as attempts increase } - $QueryEndTime=microtime(true); - $this->Queries[]=array(display_str($Query),($QueryEndTime-$QueryStartTime)*1000); - $this->Time+=($QueryEndTime-$QueryStartTime)*1000; + $QueryEndTime = microtime(true); + $this->Queries[] = array(display_str($Query), ($QueryEndTime - $QueryStartTime) * 1000); + $this->Time += ($QueryEndTime-$QueryStartTime) * 1000; if (!$this->QueryID) { $this->Errno = mysqli_errno($this->LinkID); @@ -229,12 +229,14 @@ function query($Query,$AutoHandle=1) { /* if ($QueryType == 'DELETE' || $QueryType == 'UPDATE') { if ($this->affected_rows() > 50) { - $Debug->analysis($this->affected_rows().' rows altered:',$Query,3600*24); + $Debug->analysis($this->affected_rows().' rows altered:', $Query, 3600 * 24); } } */ $this->Row = 0; - if ($AutoHandle) { return $this->QueryID; } + if ($AutoHandle) { + return $this->QueryID; + } } function query_unb($Query) { diff --git a/classes/class_tools.php b/classes/class_tools.php index 4800a832..e4e75900 100644 --- a/classes/class_tools.php +++ b/classes/class_tools.php @@ -5,27 +5,27 @@ class Tools { * * @param string $IP */ - public static function site_ban_ip($IP) { - global $DB, $Cache, $Debug; - $A = substr($IP, 0, strcspn($IP, '.')); - $IPNum = Tools::ip_to_unsigned($IP); - $IPBans = $Cache->get_value('ip_bans_'.$A); - if (!is_array($IPBans)) { - $SQL = sprintf("SELECT ID, FromIP, ToIP FROM ip_bans WHERE FromIP BETWEEN %d << 24 AND (%d << 24) - 1", $A, $A+1); - $DB->query($SQL); - $IPBans = $DB->to_array(0, MYSQLI_NUM); - $Cache->cache_value('ip_bans_'.$A, $IPBans, 0); - } - $Debug->log_var($IPBans, 'IP bans for class '.$A); - foreach ($IPBans as $Index => $IPBan) { - list ($ID, $FromIP, $ToIP) = $IPBan; - if ($IPNum >= $FromIP && $IPNum <= $ToIP) { - return true; + public static function site_ban_ip($IP) { + global $DB, $Cache, $Debug; + $A = substr($IP, 0, strcspn($IP, '.')); + $IPNum = Tools::ip_to_unsigned($IP); + $IPBans = $Cache->get_value('ip_bans_'.$A); + if (!is_array($IPBans)) { + $SQL = sprintf("SELECT ID, FromIP, ToIP FROM ip_bans WHERE FromIP BETWEEN %d << 24 AND (%d << 24) - 1", $A, $A+1); + $DB->query($SQL); + $IPBans = $DB->to_array(0, MYSQLI_NUM); + $Cache->cache_value('ip_bans_'.$A, $IPBans, 0); } + $Debug->log_var($IPBans, 'IP bans for class '.$A); + foreach ($IPBans as $Index => $IPBan) { + list ($ID, $FromIP, $ToIP) = $IPBan; + if ($IPNum >= $FromIP && $IPNum <= $ToIP) { + return true; + } + } + + return false; } - - return false; - } /** * Returns the unsigned form of an IP address. @@ -34,7 +34,7 @@ public static function site_ban_ip($IP) { * @return string the long it represents. */ public static function ip_to_unsigned($IP) { - return sprintf("%u", ip2long($IP)); + return sprintf('%u', ip2long($IP)); } /** @@ -71,13 +71,12 @@ public static function geoip($IP) { * @param $IP the IP to get the hostname for * @return hostname fetched */ - public static function get_host_by_ip($IP) - { + public static function get_host_by_ip($IP) { $testar = explode('.',$IP); - if (count($testar)!=4) { + if (count($testar) != 4) { return $IP; } - for ($i=0;$i<4;++$i) { + for ($i = 0; $i < 4; ++$i) { if (!is_numeric($testar[$i])) { return $IP; } @@ -206,19 +205,21 @@ public static function disable_users($UserIDs, $AdminComment, $BanReason = 1) { public static function warn_user($UserID, $Duration, $Reason) { global $LoggedUser, $DB, $Cache, $Time; - $DB->query("SELECT Warned FROM users_info - WHERE UserID=".$UserID." - AND Warned <> '0000-00-00 00:00:00'"); + $DB->query(" + SELECT Warned + FROM users_info + WHERE UserID=".$UserID." + AND Warned <> '0000-00-00 00:00:00'"); if ($DB->record_count() > 0) { //User was already warned, appending new warning to old. list($OldDate) = $DB->next_record(); $NewExpDate = date('Y-m-d H:i:s', strtotime($OldDate) + $Duration); Misc::send_pm($UserID, 0, - "You have received multiple warnings.", - "When you received your latest warning (Set to expire on ".date("Y-m-d", (time() + $Duration))."), you already had a different warning (Set to expire on ".date("Y-m-d", strtotime($OldDate)).").\n\n Due to this collision, your warning status will now expire at ".$NewExpDate."."); + 'You have received multiple warnings.', + "When you received your latest warning (set to expire on ".date('Y-m-d', (time() + $Duration)).'), you already had a different warning (set to expire on '.date('Y-m-d', strtotime($OldDate)).").\n\n Due to this collision, your warning status will now expire at ".$NewExpDate.'.'); - $AdminComment = date("Y-m-d").' - Warning (Clash) extended to expire at '.$NewExpDate.' by '.$LoggedUser['Username']."\nReason: $Reason\n\n"; + $AdminComment = date('Y-m-d').' - Warning (Clash) extended to expire at '.$NewExpDate.' by '.$LoggedUser['Username']."\nReason: $Reason\n\n"; $DB->query('UPDATE users_info SET Warned=\''.db_string($NewExpDate).'\', @@ -233,7 +234,7 @@ public static function warn_user($UserID, $Duration, $Reason) { $Cache->update_row(false, array('Warned' => $WarnTime)); $Cache->commit_transaction(0); - $AdminComment = date("Y-m-d").' - Warned until '.$WarnTime.' by '.$LoggedUser['Username']."\nReason: $Reason\n\n"; + $AdminComment = date('Y-m-d').' - Warned until '.$WarnTime.' by '.$LoggedUser['Username']."\nReason: $Reason\n\n"; $DB->query('UPDATE users_info SET Warned=\''.db_string($WarnTime).'\', @@ -254,6 +255,5 @@ public static function update_user_notes($UserID, $AdminComment) { AdminComment=CONCAT(\''.db_string($AdminComment).'\',AdminComment) WHERE UserID=\''.db_string($UserID).'\''); } - } ?> diff --git a/classes/class_users.php b/classes/class_users.php index 700a172e..340e66df 100644 --- a/classes/class_users.php +++ b/classes/class_users.php @@ -534,7 +534,7 @@ public static function get_bookmarks ($UserID) } /** - * Generate HTML for a user's avatar or just return the avatar url + * Generate HTML for a user's avatar or just return the avatar URL * @param unknown $Avatar * @param unknown $Username * @param unknown $Setting @@ -544,62 +544,62 @@ public static function get_bookmarks ($UserID) */ public static function show_avatar($Avatar, $Username, $Setting, $Size=150, $ReturnHTML = True) { global $LoggedUser; - //case 1 is avatars disabled - switch($Setting) { + // case 1 is avatars disabled + switch ($Setting) { case 0: if (!empty($Avatar)) { - $ToReturn = $ReturnHTML ? "$Username avatar" : $Avatar; + $ToReturn = $ReturnHTML ? "\"$Username" : $Avatar; } else { - $URL = STATIC_SERVER."common/avatars/default.png"; - $ToReturn = $ReturnHTML ? "Default Avatar" : $URL; + $URL = STATIC_SERVER.'common/avatars/default.png'; + $ToReturn = $ReturnHTML ? "\"Default" : $URL; } break; case 2: $ShowAvatar = True; case 3: - switch($LoggedUser['Identicons']) { + switch ($LoggedUser['Identicons']) { case 0: - $Type = "identicon"; + $Type = 'identicon'; break; case 1: - $Type = "monsterid"; + $Type = 'monsterid'; break; case 2: - $Type = "wavatar"; + $Type = 'wavatar'; break; case 3: - $Type = "retro"; + $Type = 'retro'; break; case 4: - $Type = "1"; + $Type = '1'; $Robot = True; break; case 5: - $Type = "2"; + $Type = '2'; $Robot = True; break; case 6: - $Type = "3"; + $Type = '3'; $Robot = True; break; default: - $Type = "identicon"; + $Type = 'identicon'; } - $Rating = "pg"; + $Rating = 'pg'; if (!$Robot) { - $URL = "https://secure.gravatar.com/avatar/".md5(strtolower(trim($Username)))."?s=$Size&d=$Type&r=$Rating"; + $URL = 'https://secure.gravatar.com/avatar/'.md5(strtolower(trim($Username)))."?s=$Size&d=$Type&r=$Rating"; } else { - $URL = "https://static1.robohash.org/".md5($Username)."?set=set".$Type."&size=".$Size."x".$Size; + $URL = 'https://robohash.org/'.md5($Username).'?set=set'.$Type.'&size='.$Size.'x'.$Size; } if ($ShowAvatar == True && !empty($Avatar)) { - $ToReturn = $ReturnHTML ? "$Username avatar" : $Avatar; + $ToReturn = $ReturnHTML ? "\"$Username" : $Avatar; } else { - $ToReturn = $ReturnHTML ? "Default Avatar" : $URL; + $ToReturn = $ReturnHTML ? "\"Default" : $URL; } break; default: - $URL = STATIC_SERVER."common/avatars/default.png"; - $ToReturn = $ReturnHTML ? "Default Avatar" : $URL; + $URL = STATIC_SERVER.'common/avatars/default.png'; + $ToReturn = $ReturnHTML ? "\"Default" : $URL; } return $ToReturn; } diff --git a/classes/permissions_form.php b/classes/permissions_form.php index 5159b8c5..5a6e545d 100644 --- a/classes/permissions_form.php +++ b/classes/permissions_form.php @@ -7,7 +7,7 @@ ** user custom permissions form. ** ********************************************************************************/ - $PermissionsArray = array( +$PermissionsArray = array( 'site_leech' => 'Can leech (Does this work?).', 'site_upload' => 'Upload torrent access.', 'site_vote' => 'Request vote access.', @@ -55,7 +55,7 @@ 'users_edit_watch_hours' => 'Can edit contrib watch hours.', 'users_edit_reset_keys' => 'Can reset passkey/authkey.', 'users_edit_profiles' => 'Can edit anyone\'s profile.', - 'users_view_friends' => 'Can view anyone\'s friends.', + 'users_view_friends' => 'Can view anyone\'s friends.', 'users_reset_own_keys' => 'Can reset own passkey/authkey.', 'users_edit_password' => 'Can change passwords.', 'users_promote_below' => 'Can promote users to below current level.', @@ -103,17 +103,17 @@ 'admin_login_watch' => 'Can manage login watch.', 'admin_manage_wiki' => 'Can manage wiki access.', 'admin_update_geoip' => 'Can update geoIP data.', - 'site_collages_recover' => 'Can recover \'deleted\' collages.', - 'torrents_add_artist' => 'Can add artists to any group.', - 'edit_unknowns' => 'Can edit unknown release information.', - 'forums_polls_create' => 'Can create polls in the forums.', - 'forums_polls_moderate' => 'Can feature and close polls.', + 'site_collages_recover' => 'Can recover \'deleted\' collages.', + 'torrents_add_artist' => 'Can add artists to any group.', + 'edit_unknowns' => 'Can edit unknown release information.', + 'forums_polls_create' => 'Can create polls in the forums.', + 'forums_polls_moderate' => 'Can feature and close polls.', 'project_team' => 'Is part of the project team.', 'torrents_edit_vanityhouse' => 'Can mark groups as part of Vanity House.', 'artist_edit_vanityhouse' => 'Can mark artists as part of Vanity House.', 'site_tag_aliases_read' => 'Can view the list of tag aliases.' - ); +); function permissions_form(){ ?>
diff --git a/classes/sphinxapi.php b/classes/sphinxapi.php index a9b5063e..60da68a0 100644 --- a/classes/sphinxapi.php +++ b/classes/sphinxapi.php @@ -539,13 +539,13 @@ function _Send ( $handle, $data, $length ) /// enter mbstring workaround mode function _MBPush () { - $this->_mbenc = ""; + $this->_mbenc = ''; if ( ini_get ( "mbstring.func_overload" ) & 2 ) { $this->_mbenc = mb_internal_encoding(); mb_internal_encoding ( "latin1" ); } - } + } /// leave mbstring workaround mode function _MBPop () @@ -931,17 +931,17 @@ function ResetFilters () /// clear groupby settings (for multi-queries) function ResetGroupBy () { - $this->_groupby = ""; + $this->_groupby = ''; $this->_groupfunc = SPH_GROUPBY_DAY; $this->_groupsort = "@group desc"; - $this->_groupdistinct= ""; + $this->_groupdistinct= ''; } /// clear all attribute value overrides (for multi-queries) function ResetOverrides () - { - $this->_overrides = array (); - } + { + $this->_overrides = array (); + } ////////////////////////////////////////////////////////////////////////////// diff --git a/design/privateheader.php b/design/privateheader.php index 9457b017..3d92778c 100644 --- a/design/privateheader.php +++ b/design/privateheader.php @@ -79,7 +79,7 @@ ?> + if ($Script == 'jquery') { ?> diff --git a/sections/ajax/artist.php b/sections/ajax/artist.php index 1d89b4be..3ff9ed88 100644 --- a/sections/ajax/artist.php +++ b/sections/ajax/artist.php @@ -4,14 +4,14 @@ function compare($X, $Y){ return($Y['count'] - $X['count']); } - // Bookmarks::has_bookmarked() +// Bookmarks::has_bookmarked() include(SERVER_ROOT.'/sections/requests/functions.php'); include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class $Text = new TEXT; $ArtistID = $_GET['id']; -if(!is_number($ArtistID)) { +if (!is_number($ArtistID)) { print json_encode(array('status' => 'failure')); die(); } @@ -29,7 +29,7 @@ function compare($X, $Y){ } } -if(!empty($_GET['revisionid'])) { // if they're viewing an old revision +if (!empty($_GET['revisionid'])) { // if they're viewing an old revision $RevisionID=$_GET['revisionid']; if (!is_number($RevisionID)) { error(0); @@ -39,7 +39,7 @@ function compare($X, $Y){ $Data = $Cache->get_value('artist_'.$ArtistID); $RevisionID = false; } -if($Data) { +if ($Data) { if (!is_array($Data)) { $Data = unserialize($Data); } @@ -47,28 +47,30 @@ function compare($X, $Y){ } else { if ($RevisionID) { - $sql = "SELECT - a.Name, - wiki.Image, - wiki.body, - a.VanityHouse + $sql = " + SELECT + a.Name, + wiki.Image, + wiki.body, + a.VanityHouse FROM wiki_artists AS wiki - LEFT JOIN artists_group AS a ON wiki.RevisionID=a.RevisionID + LEFT JOIN artists_group AS a ON wiki.RevisionID=a.RevisionID WHERE wiki.RevisionID='$RevisionID' "; } else { - $sql = "SELECT - a.Name, - wiki.Image, - wiki.body, - a.VanityHouse + $sql = " + SELECT + a.Name, + wiki.Image, + wiki.body, + a.VanityHouse FROM artists_group AS a - LEFT JOIN wiki_artists AS wiki ON wiki.RevisionID=a.RevisionID + LEFT JOIN wiki_artists AS wiki ON wiki.RevisionID=a.RevisionID WHERE a.ArtistID='$ArtistID' "; } $sql .= " GROUP BY a.ArtistID"; $DB->query($sql); - if($DB->record_count() == 0) { + if ($DB->record_count() == 0) { print json_encode(array('status' => 'failure')); } @@ -78,7 +80,8 @@ function compare($X, $Y){ // Requests $Requests = $Cache->get_value('artists_requests_'.$ArtistID); if (!is_array($Requests)) { - $DB->query("SELECT + $DB->query(" + SELECT r.ID, r.CategoryID, r.Title, @@ -94,7 +97,7 @@ function compare($X, $Y){ GROUP BY r.ID ORDER BY Votes DESC"); - if($DB->record_count() > 0) { + if ($DB->record_count() > 0) { $Requests = $DB->to_array(); } else { $Requests = array(); @@ -104,12 +107,13 @@ function compare($X, $Y){ $NumRequests = count($Requests); if (($Importances = $Cache->get_value('artist_groups_'.$ArtistID)) === false) { - $DB->query("SELECT + $DB->query(" + SELECT DISTINCTROW ta.GroupID, ta.Importance, tg.VanityHouse, tg.Year - FROM torrents_artists AS ta + FROM torrents_artists AS ta JOIN torrents_group AS tg ON tg.ID=ta.GroupID - WHERE ta.ArtistID='$ArtistID' - ORDER BY tg.Year DESC, tg.Name DESC"); + WHERE ta.ArtistID='$ArtistID' + ORDER BY tg.Year DESC, tg.Name DESC"); $GroupIDs = $DB->collect('GroupID'); $Importances = $DB->to_array(false, MYSQLI_BOTH, false); $Cache->cache_value('artist_groups_'.$ArtistID, $Importances, 0); @@ -129,38 +133,38 @@ function compare($X, $Y){ //Get list of used release types $UsedReleases = array(); -foreach($TorrentList as $GroupID=>$Group) { - if($Importances[$GroupID]['Importance'] == '2') { +foreach ($TorrentList as $GroupID=>$Group) { + if ($Importances[$GroupID]['Importance'] == '2') { $TorrentList[$GroupID]['ReleaseType'] = 1024; $GuestAlbums = true; } - if($Importances[$GroupID]['Importance'] == '3') { + if ($Importances[$GroupID]['Importance'] == '3') { $TorrentList[$GroupID]['ReleaseType'] = 1023; $RemixerAlbums = true; } - if($Importances[$GroupID]['Importance'] == '4') { + if ($Importances[$GroupID]['Importance'] == '4') { $TorrentList[$GroupID]['ReleaseType'] = 1022; $ComposerAlbums = true; } - if($Importances[$GroupID]['Importance'] == '7') { + if ($Importances[$GroupID]['Importance'] == '7') { $TorrentList[$GroupID]['ReleaseType'] = 1021; $ProducerAlbums = true; } - if(!in_array($TorrentList[$GroupID]['ReleaseType'], $UsedReleases)) { + if (!in_array($TorrentList[$GroupID]['ReleaseType'], $UsedReleases)) { $UsedReleases[] = $TorrentList[$GroupID]['ReleaseType']; } } -if(!empty($GuestAlbums)) { +if (!empty($GuestAlbums)) { $ReleaseTypes[1024] = "Guest Appearance"; } -if(!empty($RemixerAlbums)) { +if (!empty($RemixerAlbums)) { $ReleaseTypes[1023] = "Remixed By"; } -if(!empty($ComposerAlbums)) { +if (!empty($ComposerAlbums)) { $ReleaseTypes[1022] = "Composition"; } -if(!empty($ProducerAlbums)) { +if (!empty($ProducerAlbums)) { $ReleaseTypes[1021] = "Produced By"; } @@ -176,8 +180,8 @@ function compare($X, $Y){ $TagList = explode(' ',str_replace('_','.',$TagList)); // $Tags array is for the sidebar on the right - foreach($TagList as $Tag) { - if(!isset($Tags[$Tag])) { + foreach ($TagList as $Tag) { + if (!isset($Tags[$Tag])) { $Tags[$Tag] = array('name'=>$Tag, 'count'=>1); } else { $Tags[$Tag]['count']++; @@ -231,17 +235,17 @@ function compare($X, $Y){ } $JsonSimilar = array(); -if(empty($SimilarArray)) { +if (empty($SimilarArray)) { $DB->query(" SELECT - s2.ArtistID, - a.Name, - ass.Score, - ass.SimilarID + s2.ArtistID, + a.Name, + ass.Score, + ass.SimilarID FROM artists_similar AS s1 - JOIN artists_similar AS s2 ON s1.SimilarID=s2.SimilarID AND s1.ArtistID!=s2.ArtistID - JOIN artists_similar_scores AS ass ON ass.SimilarID=s1.SimilarID - JOIN artists_group AS a ON a.ArtistID=s2.ArtistID + JOIN artists_similar AS s2 ON s1.SimilarID=s2.SimilarID AND s1.ArtistID!=s2.ArtistID + JOIN artists_similar_scores AS ass ON ass.SimilarID=s1.SimilarID + JOIN artists_group AS a ON a.ArtistID=s2.ArtistID WHERE s1.ArtistID='$ArtistID' ORDER BY ass.Score DESC LIMIT 30 diff --git a/sections/ajax/browse.php b/sections/ajax/browse.php index d4dacb04..45a64c5c 100644 --- a/sections/ajax/browse.php +++ b/sections/ajax/browse.php @@ -351,7 +351,7 @@ function header_link($SortKey,$DefaultWay = 'desc') { $SphQL->where('logscore', 100); $SphQLTor->where('logscore', 100); $Filtered = true; - } elseif ($_GET['haslog'] < 0) { + } elseif ($_GET['haslog'] < 0) { // Exclude torrents with log score equal to 100 $SphQL->where('logscore', 100, true); $SphQL->where('haslog', 1); @@ -561,31 +561,31 @@ function header_link($SortKey,$DefaultWay = 'desc') { } $TagList = explode(' ',str_replace('_','.',$GroupInfo['TagList'])); - $JsonArtists = array(); + $JsonArtists = array(); if (!empty($ExtendedArtists[1]) || !empty($ExtendedArtists[4]) || !empty($ExtendedArtists[5]) || !empty($ExtendedArtists[6])) { unset($ExtendedArtists[2]); unset($ExtendedArtists[3]); $DisplayName = Artists::display_artists($ExtendedArtists, false, false, true); - foreach ($ExtendedArtists[1] as $Artist) { - $JsonArtists[] = array( - 'id' => (int) $Artist['id'], - 'name' => $Artist['name'], - 'aliasid' => (int) $Artist['id'] - ); - } + foreach ($ExtendedArtists[1] as $Artist) { + $JsonArtists[] = array( + 'id' => (int) $Artist['id'], + 'name' => $Artist['name'], + 'aliasid' => (int) $Artist['id'] + ); + } } elseif (!empty($Artists)) { $DisplayName = Artists::display_artists(array(1=>$Artists), false, false, true); - foreach ($Artists as $Artist) { - $JsonArtists[] = array( - 'id' => (int) $Artist['id'], - 'name' => $Artist['name'], - 'aliasid' => (int) $Artist['id'] - ); - } + foreach ($Artists as $Artist) { + $JsonArtists[] = array( + 'id' => (int) $Artist['id'], + 'name' => $Artist['name'], + 'aliasid' => (int) $Artist['id'] + ); + } } else { - $DisplayName=''; + $DisplayName = ''; } - if ($GroupResults && (count($Torrents)>1 || isset($GroupedCategories[$CategoryID-1]))) { + if ($GroupResults && (count($Torrents) > 1 || isset($GroupedCategories[$CategoryID-1]))) { // These torrents are in a group $LastRemasterYear = '-'; $LastRemasterTitle = ''; @@ -702,7 +702,7 @@ function header_link($SortKey,$DefaultWay = 'desc') { 'status' => 'success', 'response' => array( 'currentPage' => intval($Page), - 'pages' => ceil($TorrentCount/TORRENTS_PER_PAGE), + 'pages' => ceil($TorrentCount / TORRENTS_PER_PAGE), 'results' => $JsonGroups ) ) diff --git a/sections/ajax/index.php b/sections/ajax/index.php index dcf0334d..e9ca5722 100644 --- a/sections/ajax/index.php +++ b/sections/ajax/index.php @@ -29,8 +29,8 @@ 'status' => 'failure', 'response' => 'Rate limit exceeded.' ) - ); - + ); + die(); } else { $Cache->increment_value('ajax_requests_'.$UserID); @@ -146,8 +146,7 @@ print json_encode(array('status' => 'failure')); } -function pullmediainfo($Array) -{ +function pullmediainfo($Array) { $NewArray = array(); foreach ($Array as $Item) { $NewArray[] = array( diff --git a/sections/ajax/info.php b/sections/ajax/info.php index 45a4d78c..1db211bc 100644 --- a/sections/ajax/info.php +++ b/sections/ajax/info.php @@ -1,7 +1,6 @@ cache_value('news_latest_id', $CurrentNews, 0); } - $NewMessages = $Cache->get_value('inbox_new_' . $LoggedUser['ID']); if ($NewMessages === false) { $DB->query("SELECT COUNT(UnRead) FROM pm_conversations_users WHERE UserID='" . $LoggedUser['ID'] . "' AND UnRead = '1' AND InInbox = '1'"); @@ -36,7 +34,7 @@ if ($NewNotifications === false) { $DB->query("SELECT COUNT(UserID) FROM users_notify_torrents WHERE UserID='$LoggedUser[ID]' AND UnRead='1'"); list($NewNotifications) = $DB->next_record(); - /* if($NewNotifications && !check_perms('site_torrents_notify')) { + /* if ($NewNotifications && !check_perms('site_torrents_notify')) { $DB->query("DELETE FROM users_notify_torrents WHERE UserID='$LoggedUser[ID]'"); $DB->query("DELETE FROM users_notify_filters WHERE UserID='$LoggedUser[ID]'"); } */ @@ -78,16 +76,17 @@ $RestrictedForums = implode("','", array_keys($LoggedUser['CustomForums'], 0)); $PermittedForums = implode("','", array_keys($LoggedUser['CustomForums'], 1)); } - $DB->query("SELECT COUNT(s.TopicID) - FROM users_subscriptions AS s - JOIN forums_last_read_topics AS l ON s.UserID = l.UserID AND s.TopicID = l.TopicID - JOIN forums_topics AS t ON l.TopicID = t.ID - JOIN forums AS f ON t.ForumID = f.ID - WHERE (f.MinClassRead <= " . $LoggedUser['Class'] . " OR f.ID IN ('$PermittedForums')) - AND l.PostID < t.LastPostID - AND s.UserID = " . $LoggedUser['ID'] . + $DB->query(" + SELECT COUNT(s.TopicID) + FROM users_subscriptions AS s + JOIN forums_last_read_topics AS l ON s.UserID = l.UserID AND s.TopicID = l.TopicID + JOIN forums_topics AS t ON l.TopicID = t.ID + JOIN forums AS f ON t.ForumID = f.ID + WHERE (f.MinClassRead <= " . $LoggedUser['Class'] . " OR f.ID IN ('$PermittedForums')) + AND l.PostID < t.LastPostID + AND s.UserID = " . $LoggedUser['ID'] . (!empty($RestrictedForums) ? " - AND f.ID NOT IN ('" . $RestrictedForums . "')" : "")); + AND f.ID NOT IN ('" . $RestrictedForums . "')" : '')); list($NewSubscriptions) = $DB->next_record(); $Cache->cache_value('subscriptions_user_new_' . $LoggedUser['ID'], $NewSubscriptions, 0); } diff --git a/sections/ajax/request.php b/sections/ajax/request.php index 5199196f..17dbd88c 100644 --- a/sections/ajax/request.php +++ b/sections/ajax/request.php @@ -1,11 +1,10 @@ (int) $User['UserID'], diff --git a/sections/ajax/send_recommendation.php b/sections/ajax/send_recommendation.php index edfab92f..2ad3d609 100644 --- a/sections/ajax/send_recommendation.php +++ b/sections/ajax/send_recommendation.php @@ -4,50 +4,53 @@ $ID = (int) $_POST['id']; $Note = $_POST['note']; -if(empty($FriendID) || empty($Type) || empty($ID)) { +if (empty($FriendID) || empty($Type) || empty($ID)) { echo json_encode(array("status" => "error", "response" => "Error.")); die(); } // Make sure the recipient is on your friends list and not some random dude. -$DB->query("SELECT - f.FriendID, u.Username - FROM friends AS f - RIGHT JOIN users_enable_recommendations AS r - ON r.ID = f.FriendID AND r.Enable = 1 - RIGHT JOIN users_main AS u - ON u.ID = f.FriendID - WHERE f.UserID = '$LoggedUser[ID]' AND f.FriendID = '$FriendID'"); +$DB->query(" + SELECT + f.FriendID, + u.Username + FROM friends AS f + RIGHT JOIN users_enable_recommendations AS r + ON r.ID = f.FriendID AND r.Enable = 1 + RIGHT JOIN users_main AS u + ON u.ID = f.FriendID + WHERE f.UserID = '$LoggedUser[ID]' + AND f.FriendID = '$FriendID'"); -if($DB->record_count() == 0) { +if ($DB->record_count() == 0) { echo json_encode(array("status" => "error", "response" => "Not on friend list.")); die(); } $Type = strtolower($Type); -$Link = ""; +$Link = ''; // "a" vs "an", english language is so confusing. // http://en.wikipedia.org/wiki/English_articles#Distinction_between_a_and_an -$Article = "a"; -switch($Type) { +$Article = 'a'; +switch ($Type) { case 'torrent': - $Link = "torrents.php?id=".$ID; - $DB->query("SELECT Name FROM torrents_group WHERE ID = '$ID'"); + $Link = "torrents.php?id=".$ID; + $DB->query("SELECT Name FROM torrents_group WHERE ID = '$ID'"); break; case 'artist': $Article = "an"; $Link = "artist.php?id=".$ID; - $DB->query("SELECT Name FROM artists_group WHERE ArtistID = '$ID'"); - break; - case 'collage': - $Link = "collages.php?id=".$ID; - $DB->query("SELECT Name FROM collages WHERE ID = '$ID'"); - break; + $DB->query("SELECT Name FROM artists_group WHERE ArtistID = '$ID'"); + break; + case 'collage': + $Link = "collages.php?id=".$ID; + $DB->query("SELECT Name FROM collages WHERE ID = '$ID'"); + break; } list($Name) = $DB->next_record(); $Subject = $LoggedUser['Username'] . " recommended you $Article " . $Type . "!"; -$Body = $LoggedUser['Username'] . " recommended you the ".$Type." [url=https://".NONSSL_SITE_URL."/".$Link."]".$Name."[/url]."; -if(!empty($Note)) { - $Body = $Body . "\n\n". $Note; +$Body = $LoggedUser['Username'] . " recommended you the ".$Type." [url=https://".SSL_SITE_URL."/$Link]$Name".'[/url].'; +if (!empty($Note)) { + $Body = $Body . "\n\n". $Note; } Misc::send_pm($FriendID, $LoggedUser['ID'], $Subject, $Body); diff --git a/sections/ajax/top10/torrents.php b/sections/ajax/top10/torrents.php index 4812f590..f2f4b4fc 100644 --- a/sections/ajax/top10/torrents.php +++ b/sections/ajax/top10/torrents.php @@ -1,8 +1,8 @@ 'failure')); @@ -45,7 +45,7 @@ $OuterResults = array(); -if($Details == 'all' || $Details == 'day') { +if ($Details == 'all' || $Details == 'day') { if (!$TopTorrentsActiveLastDay = $Cache->get_value('top10tor_day_'.$Limit.$WhereSum)) { if ($Cache->get_query_lock('top10')) { $DayAgo = time_minus(86400); @@ -65,7 +65,7 @@ } $OuterResults[] = generate_torrent_json('Most Active Torrents Uploaded in the Past Day', 'day', $TopTorrentsActiveLastDay, $Limit); } -if($Details == 'all' || $Details == 'week') { +if ($Details == 'all' || $Details == 'week') { if (!$TopTorrentsActiveLastWeek = $Cache->get_value('top10tor_week_'.$Limit.$WhereSum)) { if ($Cache->get_query_lock('top10')) { $WeekAgo = time_minus(604800); @@ -86,7 +86,7 @@ $OuterResults[] = generate_torrent_json('Most Active Torrents Uploaded in the Past Week', 'week', $TopTorrentsActiveLastWeek, $Limit); } -if($Details == 'all' || $Details == 'overall') { +if ($Details == 'all' || $Details == 'overall') { if (!$TopTorrentsActiveAllTime = $Cache->get_value('top10tor_overall_'.$Limit.$WhereSum)) { if ($Cache->get_query_lock('top10')) { // IMPORTANT NOTE - we use WHERE t.Seeders>500 in order to speed up this query. You should remove it! @@ -107,7 +107,7 @@ $OuterResults[] = generate_torrent_json('Most Active Torrents of All Time', 'overall', $TopTorrentsActiveAllTime, $Limit); } -if(($Details == 'all' || $Details == 'snatched') && empty($Where)) { +if (($Details == 'all' || $Details == 'snatched') && empty($Where)) { if (!$TopTorrentsSnatched = $Cache->get_value('top10tor_snatched_'.$Limit.$WhereSum)) { if ($Cache->get_query_lock('top10')) { $Query = $BaseQuery; @@ -125,7 +125,7 @@ $OuterResults[] = generate_torrent_json('Most Snatched Torrents', 'snatched', $TopTorrentsSnatched, $Limit); } -if(($Details == 'all' || $Details == 'data') && empty($Where)) { +if (($Details == 'all' || $Details == 'data') && empty($Where)) { if (!$TopTorrentsTransferred = $Cache->get_value('top10tor_data_'.$Limit.$WhereSum)) { if ($Cache->get_query_lock('top10')) { // IMPORTANT NOTE - we use WHERE t.Snatched>100 in order to speed up this query. You should remove it! @@ -145,7 +145,7 @@ $OuterResults[] = generate_torrent_json('Most Data Transferred Torrents', 'data', $TopTorrentsTransferred, $Limit); } -if(($Details == 'all' || $Details == 'seeded') && empty($Where)) { +if (($Details == 'all' || $Details == 'seeded') && empty($Where)) { if (!$TopTorrentsSeeded = $Cache->get_value('top10tor_seeded_'.$Limit.$WhereSum)) { if ($Cache->get_query_lock('top10')) { $Query = $BaseQuery." @@ -166,9 +166,9 @@ json_encode( array( 'status' => 'success', - 'response' => $OuterResults - ) - ); + 'response' => $OuterResults + ) + ); function generate_torrent_json($Caption, $Tag, $Details, $Limit) { @@ -191,13 +191,13 @@ function generate_torrent_json($Caption, $Tag, $Details, $Limit) { $Artist = Artists::display_artists(Artists::get_artist($GroupID), false, true); $TruncArtist = substr($Artist, 0, strlen($Artist)-3); - $TagList=array(); + $TagList = array(); - if($TorrentTags!='') { - $TorrentTags=explode(' ',$TorrentTags); + if ($TorrentTags != '') { + $TorrentTags = explode(' ',$TorrentTags); foreach ($TorrentTags as $TagKey => $TagName) { $TagName = str_replace('_','.',$TagName); - $TagList[]=$TagName; + $TagList[] = $TagName; } } diff --git a/sections/ajax/torrentgroup.php b/sections/ajax/torrentgroup.php index 95be7ccd..f825ebfe 100644 --- a/sections/ajax/torrentgroup.php +++ b/sections/ajax/torrentgroup.php @@ -1,6 +1,5 @@ $ArtistForm[4] == null ? array() : pullmediainfo($ArtistForm[4]), 'dj' => $ArtistForm[6] == null ? array() : pullmediainfo($ArtistForm[6]), @@ -33,8 +34,7 @@ 'remixedBy' => $ArtistForm[3] == null ? array() : pullmediainfo($ArtistForm[3]), 'producer' => $ArtistForm[7] == null ? array() : pullmediainfo($ArtistForm[7]) ); -} -else { +} else { $JsonMusicInfo = NULL; } @@ -51,7 +51,7 @@ 'categoryName' => $CategoryName, 'time' => $TorrentDetails['Time'], 'vanityHouse' => $TorrentDetails['VanityHouse'] == 1, - 'isBookmarked' => Bookmarks::has_bookmarked('torrent', $GroupID), + 'isBookmarked' => Bookmarks::has_bookmarked('torrent', $GroupID), 'musicInfo' => $JsonMusicInfo ); @@ -86,7 +86,7 @@ 'snatched' => (int) $Torrent['Snatched'], 'freeTorrent' => $Torrent['FreeTorrent'] == 1, 'time' => $Torrent['Time'], - 'description' => $Torrent['Description'], + 'description' => $Torrent['Description'], 'fileList' => $FileList, 'filePath' => $Torrent['FilePath'], 'userId' => (int) $Torrent['UserID'], diff --git a/sections/artist/artist.php b/sections/artist/artist.php index f30c3df7..05ecd4c7 100644 --- a/sections/artist/artist.php +++ b/sections/artist/artist.php @@ -6,7 +6,7 @@ function compare($X, $Y) { return($Y['count'] - $X['count']); } - // Bookmarks::has_bookmarked() +// Bookmarks::has_bookmarked() include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class $Text = new TEXT; @@ -501,8 +501,7 @@ function compare($X, $Y) { - + diff --git a/sections/better/single.php b/sections/better/single.php index d89dc495..4d1842c6 100644 --- a/sections/better/single.php +++ b/sections/better/single.php @@ -1,13 +1,14 @@ get_value('better_single_groupids')) === false) { +if (($GroupIDs = $Cache->get_value('better_single_groupids')) === false) { $DB->query("SELECT t.ID AS TorrentID, - t.GroupID AS GroupID - FROM xbt_files_users AS x - JOIN torrents AS t ON t.ID=x.fid - WHERE t.Format='FLAC' - GROUP BY x.fid - HAVING COUNT(x.uid) = 1 - ORDER BY t.LogScore DESC, t.Time ASC LIMIT 30"); + t.GroupID AS GroupID + FROM xbt_files_users AS x + JOIN torrents AS t ON t.ID=x.fid + WHERE t.Format='FLAC' + GROUP BY x.fid + HAVING COUNT(x.uid) = 1 + ORDER BY t.LogScore DESC, t.Time ASC + LIMIT 30"); $GroupIDs = $DB->to_array('GroupID'); $Cache->cache_value('better_single_groupids', $GroupIDs, 30*60); @@ -41,11 +42,15 @@ $FlacID = $GroupIDs[$GroupID]['TorrentID']; $DisplayName.=''.$GroupName.''; - if($GroupYear>0) { $DisplayName.=" [".$GroupYear."]"; } - if($ReleaseType>0) { $DisplayName.=" [".$ReleaseTypes[$ReleaseType]."]"; } + if ($GroupYear > 0) { + $DisplayName.=" [$GroupYear]"; + } + if ($ReleaseType > 0) { + $DisplayName.=" [".$ReleaseTypes[$ReleaseType]."]"; + } $ExtraInfo = Torrents::torrent_info($Torrents[$FlacID]); - if($ExtraInfo) { + if ($ExtraInfo) { $DisplayName.=' - '.$ExtraInfo; } ?> diff --git a/sections/blog/index.php b/sections/blog/index.php index abd75b96..01e58296 100644 --- a/sections/blog/index.php +++ b/sections/blog/index.php @@ -6,11 +6,11 @@ require(SERVER_ROOT.'/classes/class_text.php'); $Text = new TEXT; -if(check_perms('admin_manage_blog')) { - if(!empty($_REQUEST['action'])) { - switch($_REQUEST['action']) { +if (check_perms('admin_manage_blog')) { + if (!empty($_REQUEST['action'])) { + switch ($_REQUEST['action']) { case 'deadthread' : - if(is_number($_GET['id'])){ + if (is_number($_GET['id'])){ $DB->query("UPDATE blog SET ThreadID=NULL WHERE ID=".$_GET['id']); $Cache->delete_value('blog'); $Cache->delete_value('feed_blog'); @@ -19,7 +19,7 @@ break; case 'takeeditblog': authorize(); - if(is_number($_POST['blogid']) && is_number($_POST['thread'])){ + if (is_number($_POST['blogid']) && is_number($_POST['thread'])){ $DB->query("UPDATE blog SET Title='".db_string($_POST['title'])."', Body='".db_string($_POST['body'])."', ThreadID=".$_POST['thread']." WHERE ID='".db_string($_POST['blogid'])."'"); $Cache->delete_value('blog'); $Cache->delete_value('feed_blog'); @@ -27,14 +27,14 @@ header('Location: blog.php'); break; case 'editblog': - if(is_number($_GET['id'])){ + if (is_number($_GET['id'])){ $BlogID = $_GET['id']; $DB->query("SELECT Title, Body, ThreadID FROM blog WHERE ID=$BlogID"); list($Title, $Body, $ThreadID) = $DB->next_record(); } break; case 'deleteblog': - if(is_number($_GET['id'])){ + if (is_number($_GET['id'])){ authorize(); $DB->query("DELETE FROM blog WHERE ID='".db_string($_GET['id'])."'"); $Cache->delete_value('blog'); @@ -48,31 +48,31 @@ $Title = db_string($_POST['title']); $Body = db_string($_POST['body']); $ThreadID = $_POST['thread']; - if($ThreadID && is_number($ThreadID)) { + if ($ThreadID && is_number($ThreadID)) { $DB->query("SELECT ForumID FROM forums_topics WHERE ID=".$ThreadID); - if($DB->record_count() < 1) { + if ($DB->record_count() < 1) { error("No such thread exists!"); header('Location: blog.php'); } } else { $ThreadID = Misc::create_thread(ANNOUNCEMENT_FORUM_ID, $LoggedUser[ID], $Title, $Body); - if($ThreadID < 1) { + if ($ThreadID < 1) { error(0); } } $DB->query("INSERT INTO blog (UserID, Title, Body, Time, ThreadID, Important) - VALUES ('".$LoggedUser['ID']."', - '".db_string($_POST['title'])."', - '".db_string($_POST['body'])."', - '".sqltime()."', - ".$ThreadID.", - '".(($_POST['important']=='1')?'1':'0')."')"); + VALUES ('".$LoggedUser['ID']."', + '".db_string($_POST['title'])."', + '".db_string($_POST['body'])."', + '".sqltime()."', + $ThreadID, + '".(($_POST['important'] == '1') ? '1' : '0')."')"); $Cache->delete_value('blog'); - if ($_POST['important']=='1') { + if ($_POST['important'] == '1') { $Cache->delete_value('blog_latest_id'); } - if(isset($_POST['subscribe'])) { + if (isset($_POST['subscribe'])) { $DB->query("INSERT IGNORE INTO users_subscriptions VALUES ('$LoggedUser[ID]', $ThreadID)"); $Cache->delete_value('subscriptions_user_'.$LoggedUser['ID']); } @@ -91,19 +91,19 @@
- + - +

Title

- />
+ />

Body

-
- />
+
+ />

Thread ID

- /> + /> (Leave blank to create thread automatically)

- tabindex="2" /> + tabindex="2" />
@@ -120,13 +120,14 @@ get_value('blog')) { $DB->query("SELECT - b.ID, - um.Username, - b.Title, - b.Body, - b.Time, - b.ThreadID - FROM blog AS b LEFT JOIN users_main AS um ON b.UserID=um.ID + b.ID, + um.Username, + b.Title, + b.Body, + b.Time, + b.ThreadID + FROM blog AS b + LEFT JOIN users_main AS um ON b.UserID=um.ID ORDER BY Time DESC LIMIT 20"); $Blog = $DB->to_array(); @@ -147,19 +148,19 @@
- posted by - + - Edit Delete - +
full_format($Body)?> - +

Discuss this post here - + Remove link -
diff --git a/sections/collages/add_torrent.php b/sections/collages/add_torrent.php index 2189f996..3d9a72ac 100644 --- a/sections/collages/add_torrent.php +++ b/sections/collages/add_torrent.php @@ -117,7 +117,7 @@ function AddTorrent($CollageID, $GroupID) { $Matches = array(); if (preg_match($URLRegex, $URL, $Matches)) { $GroupIDs[] = $Matches[3]; - $GroupID = $Matches[3]; + $GroupID = $Matches[3]; } else { $Err = "One of the entered URLs ($URL) does not correspond to a torrent on the site."; break; diff --git a/sections/collages/browse.php b/sections/collages/browse.php index e07942d3..356eb68a 100644 --- a/sections/collages/browse.php +++ b/sections/collages/browse.php @@ -13,33 +13,35 @@ $WayTable = array('Ascending'=>'ASC', 'Descending'=>'DESC'); // Are we searching in bodies, or just names? -if(!empty($_GET['type'])) { +if (!empty($_GET['type'])) { $Type = $_GET['type']; - if(!in_array($Type, array('c.name', 'description'))) { + if (!in_array($Type, array('c.name', 'description'))) { $Type = 'c.name'; } } else { $Type = 'c.name'; } -if(!empty($_GET['search'])) { +if (!empty($_GET['search'])) { // What are we looking for? Let's make sure it isn't dangerous. $Search = db_string(trim($_GET['search'])); // Break search string down into individual words $Words = explode(' ', $Search); } -if(!empty($_GET['tags'])) { +if (!empty($_GET['tags'])) { $Tags = explode(',',db_string(trim($_GET['tags']))); - foreach($Tags as $ID=>$Tag) { + foreach ($Tags as $ID=>$Tag) { $Tags[$ID] = Misc::sanitize_tag($Tag); } } -if(!empty($_GET['cats'])) { +if (!empty($_GET['cats'])) { $Categories = $_GET['cats']; - foreach($Categories as $Cat=>$Accept) { - if(empty($CollageCats[$Cat]) || !$Accept) { unset($Categories[$Cat]); } + foreach ($Categories as $Cat=>$Accept) { + if (empty($CollageCats[$Cat]) || !$Accept) { + unset($Categories[$Cat]); + } } $Categories = array_keys($Categories); } else { @@ -47,13 +49,13 @@ } // Ordering -if(!empty($_GET['order_by']) && !empty($OrderTable[$_GET['order_by']])) { +if (!empty($_GET['order_by']) && !empty($OrderTable[$_GET['order_by']])) { $Order = $OrderTable[$_GET['order_by']]; } else { $Order = 'ID'; } -if(!empty($_GET['order_way']) && !empty($WayTable[$_GET['order_way']])) { +if (!empty($_GET['order_way']) && !empty($WayTable[$_GET['order_way']])) { $Way = $WayTable[$_GET['order_way']]; } else { $Way = 'DESC'; @@ -85,7 +87,7 @@ -if(!empty($Search)) { +if (!empty($Search)) { $SQL .= " AND $Type LIKE '%"; $SQL .= implode("%' AND $Type LIKE '%", $Words); $SQL .= "%'"; @@ -97,7 +99,7 @@ $_GET['tags_type'] = 1; } -if(!empty($Tags)) { +if (!empty($Tags)) { $SQL.= " AND (TagList LIKE '%"; if ($_GET['tags_type'] == 0) { $SQL .= implode("%' OR TagList LIKE '%", $Tags); @@ -107,9 +109,9 @@ $SQL .= "%')"; } -if(!empty($_GET['userid'])) { +if (!empty($_GET['userid'])) { $UserID = $_GET['userid']; - if(!is_number($UserID)) { + if (!is_number($UserID)) { error(404); } $User = Users::user_info($UserID); @@ -117,11 +119,13 @@ $UserClass = $Perms['Class']; $UserLink = ''.$User['Username'].''; - if(!empty($_GET['contrib'])) { - if (!check_paranoia('collagecontribs', $User['Paranoia'], $UserClass, $UserID)) { error(403); } + if (!empty($_GET['contrib'])) { + if (!check_paranoia('collagecontribs', $User['Paranoia'], $UserClass, $UserID)) { + error(403); + } $DB->query("SELECT DISTINCT CollageID FROM collages_torrents WHERE UserID = $UserID"); $CollageIDs = $DB->collect('CollageID'); - if(empty($CollageIDs)) { + if (empty($CollageIDs)) { $SQL .= " AND 0"; } else { $SQL .= " AND c.ID IN(".db_string(implode(',', $CollageIDs)).")"; @@ -133,7 +137,7 @@ $Categories[] = 0; } -if(!empty($Categories)) { +if (!empty($Categories)) { $SQL.=" AND CategoryID IN(".db_string(implode(',',$Categories)).")"; } @@ -180,8 +184,8 @@ Categories: -$Cat) { ?> - /> +$Cat) { ?> + />    @@ -189,21 +193,21 @@ Search in: - /> Names   - /> Descriptions + /> Names   + /> Descriptions Order by: @@ -218,64 +222,62 @@
- +
- +

You have not bookmarked any collages.

- +

Your search did not match anything.

Make sure all names are spelled correctly, or try making your search less specific.

- +
- + @@ -299,7 +301,7 @@ - +
Category - + Remove bookmark @@ -308,7 +310,8 @@
diff --git a/sections/collages/collage.php b/sections/collages/collage.php index aa8f95fa..efe3ad63 100644 --- a/sections/collages/collage.php +++ b/sections/collages/collage.php @@ -7,7 +7,7 @@ function compare($X, $Y){ return($Y['count'] - $X['count']); } - // Bookmarks::has_bookmarked() +// Bookmarks::has_bookmarked() include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class $Text = new TEXT; @@ -30,8 +30,8 @@ function compare($X, $Y){ $DB->query("SELECT Name, Description, UserID, Deleted, CategoryID, Locked, MaxGroups, MaxGroupsPerUser FROM collages WHERE ID='$CollageID'"); if ($DB->record_count() > 0) { list($Name, $Description, $CreatorID, $Deleted, $CollageCategoryID, $Locked, $MaxGroups, $MaxGroupsPerUser) = $DB->next_record(); - $TorrentList=''; - $CollageList=''; + $TorrentList = ''; + $CollageList = ''; } else { $Deleted = '1'; } @@ -258,7 +258,7 @@ function compare($X, $Y){ - > + > 0) { - $DisplayName = $DisplayName. ' ['. $GroupYear .']'; + $DisplayName = $DisplayName. " [$GroupYear]"; } ?>
  • @@ -296,7 +296,7 @@ function compare($X, $Y){
  • 0 && $NumGroups >= $MaxGroups) || ($MaxGroupsPerUser > 0 && $NumGroupsByUser >= $MaxGroupsPerUser))) { @@ -331,18 +331,18 @@ function compare($X, $Y){

    - + - next_record()) { + $permalink = "torrents.php?id=$GroupID&postid=$PostID#post$PostID"; + $postheader = ' on ' . Artists::display_artists($Artists[$GroupID]) . " $Title"; -while(list($UserID, $TorrentID, $GroupID, $Title, $PostID, $Body, $AddedTime, $EditedTime, $EditorID) = $DB->next_record()) { - $permalink = "torrents.php?id=$GroupID&postid=$PostID#post$PostID"; - $postheader = " on " . Artists::display_artists($Artists[$GroupID]) . " $Title"; - - comment_body($UserID, $PostID, $postheader, $permalink, $Body, $EditorID, $AddedTime, $EditedTime); + comment_body($UserID, $PostID, $postheader, $permalink, $Body, $EditorID, $AddedTime, $EditedTime); } /* end while loop*/ ?>

    Donate

    -
    +

    We accept donations to cover the costs associated with running the site and tracker. These costs come from the rental and purchase of the hardware the site runs on (servers, components, etc.), in addition to operating expenses (bandwidth, power, etc.).

    Because we do not have any advertisements or sponsorships and this service is provided free of charge, we are entirely reliant upon user donations. If you are financially able, please consider making a donation to help us pay the bills!

    We currently only accept one payment method: PayPal. Because of the fees they charge, there is a minimum donation amount of (Please note, this is only a minimum amount and we greatly appreciate any extra you can afford.).

    @@ -55,9 +55,9 @@ - - - + + + @@ -71,7 +71,7 @@

    What you will receive for a 5€ or 0.5 BTC minimum donation

    -
    +
      @@ -92,7 +92,7 @@

      Please be aware that by making a donation you aren't purchasing donor status or invites. You are helping us pay the bills and cover the costs of running the site. We are doing our best to give our love back to donors, but sometimes it might take more than 48 hours. Feel free to contact us by sending us a Staff PM regarding any matter. We will answer as quickly as possible.

    What you will not receive

    -
    +
    • 2 more invitations; these are one time only.
    • diff --git a/sections/donate/donate_gpal.php b/sections/donate/donate_gpal.php index f6a17ac5..456d8246 100644 --- a/sections/donate/donate_gpal.php +++ b/sections/donate/donate_gpal.php @@ -47,7 +47,7 @@

      Donate

      -
      +

      We accept donations to cover the costs associated with running the site and tracker. These costs come from the rental and purchase of the hardware the site runs on (servers, components, etc.), in addition to operating expenses (bandwidth, power, etc.).

      Because we do not have any advertisements or sponsorships and this service is provided free of charge, we are entirely reliant upon user donations. If you are financially able, please consider making a donation to help us pay the bills!

      We currently only accept one payment method: PayPal. Because of the fees they charge, there is a minimum donation amount of (Please note, this is only a minimum amount and we greatly appreciate any extra you can afford.).

      @@ -56,9 +56,9 @@ - - - + + + diff --git a/sections/donate/ipn.php b/sections/donate/ipn.php index 9d03a8db..101f98b3 100644 --- a/sections/donate/ipn.php +++ b/sections/donate/ipn.php @@ -63,7 +63,7 @@ Misc::send_pm($_POST['custom'], 0, 'Thank you for your donation', 'Your donation from '.$_POST['payer_email'].' of '.$_POST['mc_gross'].' '.PAYPAL_CURRENCY.' has been successfully processed. Unfortunately however this donation was less than the specified minimum donation of '.PAYPAL_MINIMUM.' '.PAYPAL_CURRENCY.' and while we are grateful, no special privileges have been awarded to you.'); } else { //Failed pending donation - $Message = "User http://".NONSSL_SITE_URL."/user.php?id=".$_POST['custom']." had donation of ".$TotalDonated." ".PAYPAL_CURRENCY." at ".$DonationTime." UTC from ".$_POST['payer_email']." returned."; + $Message = "User https://".SSL_SITE_URL."/user.php?id=".$_POST['custom']." had donation of ".$TotalDonated." ".PAYPAL_CURRENCY." at ".$DonationTime." UTC from ".$_POST['payer_email']." returned."; $DB->query('SELECT SUM(Amount), MIN(Time) FROM donations WHERE UserID=\''.$_POST['custom'].'\';'); list($TotalDonated,$DonationTime) = $DB->next_record(); if ($TotalDonated+$_POST['mc_gross'] == 0) { diff --git a/sections/feeds/index.php b/sections/feeds/index.php index c84ff8b3..495ac56a 100644 --- a/sections/feeds/index.php +++ b/sections/feeds/index.php @@ -22,7 +22,7 @@ $User = (int)$_GET['user']; -if(!$Enabled = $Cache->get_value('enabled_'.$User)){ +if (!$Enabled = $Cache->get_value('enabled_'.$User)) { require(SERVER_ROOT.'/classes/class_mysql.php'); $DB=NEW DB_MYSQL; //Load the database wrapper $DB->query("SELECT Enabled FROM users_main WHERE ID='$User'"); @@ -40,7 +40,7 @@ } $Feed->open_feed(); -switch($_GET['feed']) { +switch ($_GET['feed']) { case 'feed_news': include(SERVER_ROOT.'/classes/class_text.php'); $Text = new TEXT; diff --git a/sections/forums/forum.php b/sections/forums/forum.php index bfae7bfb..aed8f128 100644 --- a/sections/forums/forum.php +++ b/sections/forums/forum.php @@ -12,7 +12,7 @@ // Check for lame SQL injection attempts $ForumID = $_GET['forumid']; -if(!is_number($ForumID)) { +if (!is_number($ForumID)) { error(0); } @@ -28,27 +28,28 @@ // Caching anything beyond the first page of any given forum is just wasting ram // users are more likely to search then to browse to page 2 -if($Page==1) { +if ($Page == 1) { list($Forum,,,$Stickies) = $Cache->get_value('forums_'.$ForumID); } -if(!isset($Forum) || !is_array($Forum)) { - $DB->query("SELECT - t.ID, - t.Title, - t.AuthorID, - t.IsLocked, - t.IsSticky, - t.NumPosts, - t.LastPostID, - t.LastPostTime, - t.LastPostAuthorID +if (!isset($Forum) || !is_array($Forum)) { + $DB->query(" + SELECT + t.ID, + t.Title, + t.AuthorID, + t.IsLocked, + t.IsSticky, + t.NumPosts, + t.LastPostID, + t.LastPostTime, + t.LastPostAuthorID FROM forums_topics AS t WHERE t.ForumID = '$ForumID' ORDER BY t.IsSticky DESC, t.LastPostTime DESC LIMIT $Limit"); // Can be cached until someone makes a new post $Forum = $DB->to_array('ID',MYSQLI_ASSOC, false); - if($Page==1) { + if ($Page == 1) { $DB->query("SELECT COUNT(ID) FROM forums_topics WHERE ForumID='$ForumID' AND IsSticky='1'"); list($Stickies) = $DB->next_record(); $Cache->cache_value('forums_'.$ForumID, array($Forum,'',0,$Stickies), 0); @@ -56,16 +57,22 @@ } -if(!isset($Forums[$ForumID])) { error(404); } +if (!isset($Forums[$ForumID])) { + error(404); +} // Make sure they're allowed to look at the page if (!check_perms('site_moderate_forums')) { - if (isset($LoggedUser['CustomForums'][$ForumID]) && $LoggedUser['CustomForums'][$ForumID] === 0) { error(403); } + if (isset($LoggedUser['CustomForums'][$ForumID]) && $LoggedUser['CustomForums'][$ForumID] === 0) { + error(403); + } } $ForumName = display_str($Forums[$ForumID]['Name']); -if($LoggedUser['CustomForums'][$ForumID] != 1 && $Forums[$ForumID]['MinClassRead'] > $LoggedUser['Class']) { error(403); } +if ($LoggedUser['CustomForums'][$ForumID] != 1 && $Forums[$ForumID]['MinClassRead'] > $LoggedUser['Class']) { + error(403); +} // Start printing View::show_header('Forums > '. $Forums[$ForumID]['Name']); @@ -73,10 +80,10 @@

      Forums >