summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGit <git@what.cd>2013-07-10 00:08:53 +0000
committerGit <git@what.cd>2013-07-10 00:08:53 +0000
commit3b10c502d6b723932024a1797ddf01e37bd82785 (patch)
treef23267880d3017e224a501abd6d3bd90e057aa09
parent186c5ca8978766c12358a9c3f0344b74c1850ceb (diff)
downloadGazelle-3b10c502d6b723932024a1797ddf01e37bd82785.zip
Gazelle-3b10c502d6b723932024a1797ddf01e37bd82785.tar.gz
Gazelle-3b10c502d6b723932024a1797ddf01e37bd82785.tar.bz2
Empty commit
-rw-r--r--classes/alias.class.php2
-rw-r--r--classes/artists_similar.class.php2
-rw-r--r--classes/invite_tree.class.php2
-rw-r--r--classes/lastfm.class.php56
-rw-r--r--classes/misc.class.php4
-rw-r--r--classes/mysql.class.php8
-rw-r--r--classes/requests.class.php2
-rw-r--r--classes/script_start.php76
-rw-r--r--classes/search.class.php12
-rw-r--r--classes/tools.class.php2
-rw-r--r--classes/torrent_form.class.php2
-rw-r--r--classes/torrents.class.php10
-rw-r--r--classes/user_rank.class.php33
-rw-r--r--classes/users.class.php45
-rw-r--r--classes/votes.class.php26
-rw-r--r--design/privateheader.php4
-rw-r--r--docs/CHANGES.txt6
-rw-r--r--docs/INSTALL.txt16
-rw-r--r--sections/ajax/announcements.php17
-rw-r--r--sections/ajax/artist.php65
-rw-r--r--sections/ajax/browse.php138
-rw-r--r--sections/ajax/checkprivate.php4
-rw-r--r--sections/ajax/collage.php2
-rw-r--r--sections/ajax/community_stats.php14
-rw-r--r--sections/ajax/forum/forum.php10
-rw-r--r--sections/ajax/forum/index.php2
-rw-r--r--sections/ajax/inbox/viewconv.php2
-rw-r--r--sections/ajax/info.php38
-rw-r--r--sections/ajax/password_validate.php2
-rw-r--r--sections/ajax/requests.php26
-rw-r--r--sections/ajax/send_recommendation.php2
-rw-r--r--sections/ajax/user.php4
-rw-r--r--sections/artist/add_alias.php4
-rw-r--r--sections/artist/add_similar.php2
-rw-r--r--sections/artist/artist.php14
-rw-r--r--sections/artist/delete.php21
-rw-r--r--sections/artist/delete_alias.php4
-rw-r--r--sections/artist/delete_similar.php23
-rw-r--r--sections/artist/download.php2
-rw-r--r--sections/artist/edit.php2
-rw-r--r--sections/artist/index.php67
-rw-r--r--sections/artist/notify.php22
-rw-r--r--sections/artist/rename.php2
-rw-r--r--sections/artist/take_warn.php16
-rw-r--r--sections/artist/vote_similar.php2
-rw-r--r--sections/better/files.php24
-rw-r--r--sections/better/snatch.php16
-rw-r--r--sections/blog/index.php17
-rw-r--r--sections/bookmarks/add.php32
-rw-r--r--sections/captcha/index.php24
-rw-r--r--sections/chat/index.php5
-rw-r--r--sections/collages/add_artist.php4
-rw-r--r--sections/collages/add_torrent.php4
-rw-r--r--sections/collages/browse.php27
-rw-r--r--sections/collages/collage.php2
-rw-r--r--sections/collages/edit_handle.php43
-rw-r--r--sections/collages/new.php15
-rw-r--r--sections/collages/new_handle.php4
-rw-r--r--sections/collages/recover.php2
-rw-r--r--sections/collages/takeedit_comment.php2
-rw-r--r--sections/comments/post.php6
-rw-r--r--sections/donate/ipn.php60
-rw-r--r--sections/forums/add_poll_option.php18
-rw-r--r--sections/forums/delete.php65
-rw-r--r--sections/forums/delete_poll_option.php17
-rw-r--r--sections/forums/forum.php2
-rw-r--r--sections/forums/functions.php4
-rw-r--r--sections/forums/index.php9
-rw-r--r--sections/forums/main.php17
-rw-r--r--sections/forums/poll_vote.php2
-rw-r--r--sections/forums/search.php19
-rw-r--r--sections/forums/sticky_post.php2
-rw-r--r--sections/forums/take_reply.php41
-rw-r--r--sections/forums/takeedit.php2
-rw-r--r--sections/friends/add.php12
-rw-r--r--sections/friends/friends.php6
-rw-r--r--sections/inbox/conversation.php2
-rw-r--r--sections/inbox/forward.php4
-rw-r--r--sections/inbox/inbox.php18
-rw-r--r--sections/inbox/takecompose.php2
-rw-r--r--sections/inbox/takeedit.php2
-rw-r--r--sections/index/private.php90
-rw-r--r--sections/log/index.php2
-rw-r--r--sections/log/sphinx.php17
-rw-r--r--sections/login/index.php106
-rw-r--r--sections/peerupdate/index.php55
-rw-r--r--sections/register/index.php6
-rw-r--r--sections/reports/compose.php16
-rw-r--r--sections/reports/report.php14
-rw-r--r--sections/reports/reports.php18
-rw-r--r--sections/reports/takecompose.php2
-rw-r--r--sections/reportsv2/ajax_create_report.php4
-rw-r--r--sections/reportsv2/ajax_new_report.php4
-rw-r--r--sections/reportsv2/ajax_take_pm.php8
-rw-r--r--sections/reportsv2/ajax_update_comment.php10
-rw-r--r--sections/reportsv2/report.php20
-rw-r--r--sections/reportsv2/static.php189
-rw-r--r--sections/reportsv2/takereport.php37
-rw-r--r--sections/reportsv2/takeresolve.php183
-rw-r--r--sections/requests/index.php63
-rw-r--r--sections/requests/interim.php9
-rw-r--r--sections/requests/new_edit.php5
-rw-r--r--sections/requests/request.php3
-rw-r--r--sections/requests/requests.php.presphinx55
-rw-r--r--sections/requests/take_warn.php2
-rw-r--r--sections/requests/takedelete.php21
-rw-r--r--sections/requests/takefill.php13
-rw-r--r--sections/requests/takenew_edit.php100
-rw-r--r--sections/requests/takeunfill.php31
-rw-r--r--sections/requests/takevote.php21
-rw-r--r--sections/rules/clients.php12
-rw-r--r--sections/schedule/index.php669
-rw-r--r--sections/staffblog/index.php45
-rw-r--r--sections/staffpm/ajax_edit_response.php2
-rw-r--r--sections/staffpm/makedonor.php2
-rw-r--r--sections/staffpm/staff_inbox.php2
-rw-r--r--sections/staffpm/user_inbox.php2
-rw-r--r--sections/tools/data/browser_support.php6
-rw-r--r--sections/tools/data/registration_log.php4
-rw-r--r--sections/tools/data/special_users.php2
-rw-r--r--sections/tools/data/upscale_pool.php2
-rw-r--r--sections/tools/data/user_flow.php8
-rw-r--r--sections/tools/managers/email_blacklist.php2
-rw-r--r--sections/tools/managers/forum_alter.php2
-rw-r--r--sections/tools/managers/label_aliases.php2
-rw-r--r--sections/tools/managers/permissions_list.php2
-rw-r--r--sections/tools/managers/tokens.php10
-rw-r--r--sections/tools/misc/create_user.php18
-rw-r--r--sections/tools/misc/dupe_ip.php16
-rw-r--r--sections/tools/misc/tags.php10
-rw-r--r--sections/torrents/add_cover_art.php8
-rw-r--r--sections/torrents/add_tag.php25
-rw-r--r--sections/torrents/browse2.php2
-rw-r--r--sections/torrents/delete.php10
-rw-r--r--sections/torrents/details.php2
-rw-r--r--sections/torrents/download.php2
-rw-r--r--sections/torrents/editgroup.php2
-rw-r--r--sections/torrents/editgroupid.php2
-rw-r--r--sections/torrents/grouplog.php2
-rw-r--r--sections/torrents/index.php2
-rw-r--r--sections/torrents/merge.php2
-rw-r--r--sections/torrents/notify.php74
-rw-r--r--sections/torrents/peerlist.php12
-rw-r--r--sections/torrents/remove_cover_art.php2
-rw-r--r--sections/torrents/reseed.php4
-rw-r--r--sections/torrents/snatchlist.php6
-rw-r--r--sections/torrents/takechangecategory.php4
-rw-r--r--sections/torrents/takeedit.php63
-rw-r--r--sections/torrents/takegroupedit.php4
-rw-r--r--sections/torrents/takemasspm.php2
-rw-r--r--sections/torrents/takenewgroup.php4
-rw-r--r--sections/torrents/user.php125
-rw-r--r--sections/torrents/vote_tag.php2
-rw-r--r--sections/upload/generate_extra_torrents.php4
-rw-r--r--sections/upload/upload.php2
-rw-r--r--sections/upload/upload_handle.php23
-rw-r--r--sections/user/deleteinvite.php2
-rw-r--r--sections/user/lastfm.php2
-rw-r--r--sections/user/linkedfunctions.php2
-rw-r--r--sections/user/takeedit.php14
-rw-r--r--sections/user/takeinvite.php2
-rw-r--r--sections/user/takemoderate.php6
-rw-r--r--sections/user/user.php14
-rw-r--r--sections/userhistory/ip_history.php2
-rw-r--r--sections/wiki/compare.php33
-rw-r--r--sections/wiki/delete.php2
-rw-r--r--sections/wiki/takecreate.php2
-rw-r--r--static/functions/requests.js3
168 files changed, 2151 insertions, 1591 deletions
diff --git a/classes/alias.class.php b/classes/alias.class.php
index c1b90b3..f6c3af7 100644
--- a/classes/alias.class.php
+++ b/classes/alias.class.php
@@ -63,7 +63,7 @@ class ALIAS {
LEFT JOIN users_main AS u ON u.ID=w.Author
WHERE w.ID='$ArticleID'
GROUP BY w.ID");
- if (!$DB->record_count() && $Error) {
+ if (!$DB->has_results() && $Error) {
error(404);
}
$Contents = $DB->to_array();
diff --git a/classes/artists_similar.class.php b/classes/artists_similar.class.php
index 6337acd..e555cef 100644
--- a/classes/artists_similar.class.php
+++ b/classes/artists_similar.class.php
@@ -62,7 +62,7 @@ class ARTISTS_SIMILAR extends ARTIST{
ORDER BY ass.Score DESC
LIMIT 14");
- if ($DB->record_count() == 0) {
+ if (!$DB->has_results()) {
return;
}
diff --git a/classes/invite_tree.class.php b/classes/invite_tree.class.php
index 3345a7f..644c1dc 100644
--- a/classes/invite_tree.class.php
+++ b/classes/invite_tree.class.php
@@ -41,7 +41,7 @@ class INVITE_TREE {
AND TreePosition > $TreePosition
ORDER BY TreePosition ASC
LIMIT 1");
- if ($DB->record_count()) {
+ if ($DB->has_results()) {
list($MaxPosition) = $DB->next_record(MYSQLI_NUM, false);
} else {
$MaxPosition = false;
diff --git a/classes/lastfm.class.php b/classes/lastfm.class.php
index af0c853..a5d530b 100644
--- a/classes/lastfm.class.php
+++ b/classes/lastfm.class.php
@@ -5,20 +5,20 @@ class LastFM {
public static function get_artist_events($ArtistID, $Artist, $Limit = 15) {
global $Cache;
- $ArtistEvents = $Cache->get_value('artist_events_' . $ArtistID);
+ $ArtistEvents = $Cache->get_value("artist_events_$ArtistID");
if (empty($ArtistEvents)) {
$ArtistEvents = self::lastfm_request("artist.getEvents", array("artist" => $Artist, "limit" => $Limit));
- $Cache->cache_value('artist_events_' . $ArtistID, $ArtistEvents, 432000);
+ $Cache->cache_value("artist_events_$ArtistID", $ArtistEvents, 432000);
}
return $ArtistEvents;
}
public static function get_user_info($Username) {
global $Cache;
- $Response = $Cache->get_value('lastfm_user_info_' . $Username);
+ $Response = $Cache->get_value("lastfm_user_info_$Username");
if (empty($Response)) {
$Response = self::lastfm_request("user.getInfo", array("user" => $Username));
- $Cache->cache_value('lastfm_user_info_' . $Username, $Response, 86400);
+ $Cache->cache_value("lastfm_user_info_$Username", $Response, 86400);
}
return $Response;
}
@@ -28,8 +28,8 @@ class LastFM {
$DB->query("
SELECT username
FROM lastfm_users
- WHERE ID='$LoggedUser[ID]'");
- if ($DB->record_count() > 0) {
+ WHERE ID = '$LoggedUser[ID]'");
+ if ($DB->has_results()) {
list($Username2) = $DB->next_record();
//Make sure the usernames are in the correct order to avoid dupe cache keys.
if (strcasecmp($Username1, $Username2)) {
@@ -37,11 +37,11 @@ class LastFM {
$Username1 = $Username2;
$Username2 = $Temp;
}
- $Response = $Cache->get_value('lastfm_compare_' . $Username1 . '_' . $Username2);
+ $Response = $Cache->get_value("lastfm_compare_$Username1" . "_$Username2");
if (empty($Response)) {
$Response = self::lastfm_request("tasteometer.compare", array("type1" => "user", "type2" => "user", "value1" => $Username1, "value2" => $Username2, "limit" => $Limit));
$Response = json_encode($Response);
- $Cache->cache_value('lastfm_compare_' . $Username1 . '_' . $Username2, $Response, 86400);
+ $Cache->cache_value("lastfm_compare_$Username1" . "_$Username2", $Response, 86400);
}
return $Response;
}
@@ -49,69 +49,69 @@ class LastFM {
public static function get_last_played_track($Username) {
global $Cache;
- $Response = $Cache->get_value('lastfm_last_played_track_' . $Username);
+ $Response = $Cache->get_value("lastfm_last_played_track_$Username");
if (empty($Response)) {
$Response = self::lastfm_request("user.getRecentTracks", array("user" => $Username, "limit" => 1));
// Take the single last played track out of the response.
$Response = $Response['recenttracks']['track'];
$Response = json_encode($Response);
- $Cache->cache_value('lastfm_last_played_track_' . $Username, $Response, 7200);
+ $Cache->cache_value("lastfm_last_played_track_$Username", $Response, 7200);
}
return $Response;
}
public static function get_top_artists($Username, $Limit = 15) {
global $Cache;
- $Response = $Cache->get_value('lastfm_top_artists_' . $Username);
+ $Response = $Cache->get_value("lastfm_top_artists_$Username");
if (empty($Response)) {
sleep(1);
$Response = self::lastfm_request("user.getTopArtists", array("user" => $Username, "limit" => $Limit));
$Response = json_encode($Response);
- $Cache->cache_value('lastfm_top_artists_' . $Username, $Response, 86400);
+ $Cache->cache_value("lastfm_top_artists_$Username", $Response, 86400);
}
return $Response;
}
public static function get_top_albums($Username, $Limit = 15) {
global $Cache;
- $Response = $Cache->get_value('lastfm_top_albums_' . $Username);
+ $Response = $Cache->get_value("lastfm_top_albums_$Username");
if (empty($Response)) {
sleep(2);
$Response = self::lastfm_request("user.getTopAlbums", array("user" => $Username, "limit" => $Limit));
$Response = json_encode($Response);
- $Cache->cache_value('lastfm_top_albums_' . $Username, $Response, 86400);
+ $Cache->cache_value("lastfm_top_albums_$Username", $Response, 86400);
}
return $Response;
}
public static function get_top_tracks($Username, $Limit = 15) {
global $Cache;
- $Response = $Cache->get_value('lastfm_top_tracks_' . $Username);
+ $Response = $Cache->get_value("lastfm_top_tracks_$Username");
if (empty($Response)) {
sleep(3);
$Response = self::lastfm_request("user.getTopTracks", array("user" => $Username, "limit" => $Limit));
$Response = json_encode($Response);
- $Cache->cache_value('lastfm_top_tracks_' . $Username, $Response, 86400);
+ $Cache->cache_value("lastfm_top_tracks_$Username", $Response, 86400);
}
return $Response;
}
public static function clear_cache($Username, $Uid) {
global $Cache, $LoggedUser, $DB;
- $Response = $Cache->get_value('lastfm_clear_cache_' . $LoggedUser . '_' . $_GET['id']);
+ $Response = $Cache->get_value("lastfm_clear_cache_$LoggedUser" . '_' . $_GET['id']);
if (empty($Response)) {
// Prevent clearing the cache on the same uid page for the next 10 minutes.
- $Response = $Cache->cache_value('lastfm_clear_cache_' . $LoggedUser . '_' . $Uid, $Username, 600);
- $Cache->delete_value('lastfm_user_info_' . $Username);
- $Cache->delete_value('lastfm_last_played_track_' . $Username);
- $Cache->delete_value('lastfm_top_artists_' . $Username);
- $Cache->delete_value('lastfm_top_albums_' . $Username);
- $Cache->delete_value('lastfm_top_tracks_' . $Username);
+ $Response = $Cache->cache_value("lastfm_clear_cache_$LoggedUser" . "_$Uid", $Username, 600);
+ $Cache->delete_value("lastfm_user_info_$Username");
+ $Cache->delete_value("lastfm_last_played_track_$Username");
+ $Cache->delete_value("lastfm_top_artists_$Username");
+ $Cache->delete_value("lastfm_top_albums_$Username");
+ $Cache->delete_value("lastfm_top_tracks_$Username");
$DB->query("
SELECT username
FROM lastfm_users
- WHERE ID='$LoggedUser[ID]'");
- if ($DB->record_count() > 0) {
+ WHERE ID = '$LoggedUser[ID]'");
+ if ($DB->has_results()) {
list($Username2) = $DB->next_record();
//Make sure the usernames are in the correct order to avoid dupe cache keys.
if (strcasecmp($Username, $Username2)) {
@@ -119,7 +119,7 @@ class LastFM {
$Username = $Username2;
$Username2 = $Temp;
}
- $Cache->delete_value('lastfm_compare_' . $Username . '_' . $Username2);
+ $Cache->delete_value("lastfm_compare_$Username" . "_$Username2");
}
}
}
@@ -131,7 +131,7 @@ class LastFM {
$Url = LASTFM_API_URL . $Method;
if (is_array($Args)) {
foreach ($Args as $Key => $Value) {
- $Url .= "&" . $Key . "=" . urlencode($Value);
+ $Url .= "&$Key=" . urlencode($Value);
}
$Url .= "&format=json&api_key=" . LASTFM_API_KEY;
@@ -145,6 +145,4 @@ class LastFM {
return json_decode($Return, true);
}
}
-
}
-
diff --git a/classes/misc.class.php b/classes/misc.class.php
index fb5f415..38d6a4b 100644
--- a/classes/misc.class.php
+++ b/classes/misc.class.php
@@ -148,7 +148,7 @@ class Misc {
SELECT Username
FROM users_main
WHERE ID=".$AuthorID);
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
return -2;
}
list($AuthorName) = $DB->next_record();
@@ -393,7 +393,7 @@ class Misc {
FROM tag_aliases
WHERE BadTag = '$BadTag'
LIMIT 1");
- if ($DB->record_count() > 0) {
+ if ($DB->has_results()) {
list($AliasTag) = $DB->next_record();
return $AliasTag;
}
diff --git a/classes/mysql.class.php b/classes/mysql.class.php
index 850a7b8..d483292 100644
--- a/classes/mysql.class.php
+++ b/classes/mysql.class.php
@@ -298,6 +298,14 @@ class DB_MYSQL {
}
}
+ /*
+ * returns true if the query exists and there were records found
+ * returns false if the query does not exist or if there were 0 records returned
+ */
+ function has_results() {
+ return ($this->QueryID && $this->record_count() !== 0);
+ }
+
function affected_rows() {
if ($this->LinkID) {
return mysqli_affected_rows($this->LinkID);
diff --git a/classes/requests.class.php b/classes/requests.class.php
index 9d825ee..8a57e06 100644
--- a/classes/requests.class.php
+++ b/classes/requests.class.php
@@ -221,7 +221,7 @@ class Requests {
LEFT JOIN users_main AS u ON u.ID=rv.UserID
WHERE rv.RequestID = $RequestID
ORDER BY rv.Bounty DESC");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
error(0);
} else {
$Votes = $DB->to_array();
diff --git a/classes/script_start.php b/classes/script_start.php
index 3524da1..45a317e 100644
--- a/classes/script_start.php
+++ b/classes/script_start.php
@@ -1,4 +1,4 @@
-<?
+<?php
/*-- Script Start Class --------------------------------*/
/*------------------------------------------------------*/
/* This isnt really a class but a way to tie other */
@@ -194,9 +194,9 @@ spl_autoload_register(function ($ClassName) {
$FileName = 'zip.class';
break;
default:
- die("Couldn't import class " . $ClassName);
+ die("Couldn't import class $ClassName");
}
- require_once(SERVER_ROOT.'/classes/' . $FileName . '.php');
+ require_once(SERVER_ROOT . "/classes/$FileName.php");
});
@@ -227,7 +227,7 @@ if (isset($_COOKIE['session'])) {
$LoginCookie = $Enc->decrypt($_COOKIE['session']);
}
if (isset($LoginCookie)) {
- list($SessionID, $LoggedUser['ID']) = explode("|~|", $Enc->decrypt($LoginCookie));
+ list($SessionID, $LoggedUser['ID']) = explode('|~|', $Enc->decrypt($LoginCookie));
$LoggedUser['ID'] = (int)$LoggedUser['ID'];
$UserID = $LoggedUser['ID']; //TODO: UserID should not be LoggedUser
@@ -236,7 +236,7 @@ if (isset($LoginCookie)) {
logout();
}
- $UserSessions = $Cache->get_value('users_sessions_'.$UserID);
+ $UserSessions = $Cache->get_value("users_sessions_$UserID");
if (!is_array($UserSessions)) {
$DB->query("
SELECT
@@ -246,11 +246,11 @@ if (isset($LoginCookie)) {
IP,
LastUpdate
FROM users_sessions
- WHERE UserID='$UserID'
+ WHERE UserID = '$UserID'
AND Active = 1
ORDER BY LastUpdate DESC");
$UserSessions = $DB->to_array('SessionID',MYSQLI_ASSOC);
- $Cache->cache_value('users_sessions_'.$UserID, $UserSessions, 0);
+ $Cache->cache_value("users_sessions_$UserID", $UserSessions, 0);
}
if (!array_key_exists($SessionID, $UserSessions)) {
@@ -263,7 +263,7 @@ if (isset($LoginCookie)) {
$DB->query("
SELECT Enabled
FROM users_main
- WHERE ID='$LoggedUser[ID]'");
+ WHERE ID = '$LoggedUser[ID]'");
list($Enabled) = $DB->next_record();
$Cache->cache_value('enabled_'.$LoggedUser['ID'], $Enabled, 0);
}
@@ -278,7 +278,7 @@ if (isset($LoginCookie)) {
$DB->query("
SELECT Uploaded AS BytesUploaded, Downloaded AS BytesDownloaded, RequiredRatio
FROM users_main
- WHERE ID='$LoggedUser[ID]'");
+ WHERE ID = '$LoggedUser[ID]'");
$UserStats = $DB->next_record(MYSQLI_ASSOC);
$Cache->cache_value('user_stats_'.$LoggedUser['ID'], $UserStats, 3600);
}
@@ -293,13 +293,13 @@ if (isset($LoginCookie)) {
// Create LoggedUser array
$LoggedUser = array_merge($HeavyInfo, $LightInfo, $Permissions, $UserStats);
- $LoggedUser['RSS_Auth']=md5($LoggedUser['ID'].RSS_HASH.$LoggedUser['torrent_pass']);
+ $LoggedUser['RSS_Auth'] = md5($LoggedUser['ID'] . RSS_HASH . $LoggedUser['torrent_pass']);
// $LoggedUser['RatioWatch'] as a bool to disable things for users on Ratio Watch
$LoggedUser['RatioWatch'] = (
- $LoggedUser['RatioWatchEnds'] != '0000-00-00 00:00:00' &&
- time() < strtotime($LoggedUser['RatioWatchEnds']) &&
- ($LoggedUser['BytesDownloaded'] * $LoggedUser['RequiredRatio']) > $LoggedUser['BytesUploaded']
+ $LoggedUser['RatioWatchEnds'] != '0000-00-00 00:00:00'
+ && time() < strtotime($LoggedUser['RatioWatchEnds'])
+ && ($LoggedUser['BytesDownloaded'] * $LoggedUser['RequiredRatio']) > $LoggedUser['BytesUploaded']
);
if (!isset($LoggedUser['ID'])) {
$Debug->log_var($LightInfo, 'LightInfo');
@@ -315,31 +315,33 @@ if (isset($LoginCookie)) {
$Cache->CanClear = check_perms('admin_clear_cache');
// Because we <3 our staff
- if (check_perms('site_disable_ip_history')) { $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; }
+ if (check_perms('site_disable_ip_history')) {
+ $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
+ }
// Update LastUpdate every 10 minutes
if (strtotime($UserSessions[$SessionID]['LastUpdate']) + 600 < time()) {
$DB->query("
UPDATE users_main
- SET LastAccess='".sqltime()."'
- WHERE ID='$LoggedUser[ID]'");
+ SET LastAccess = '".sqltime()."'
+ WHERE ID = '$LoggedUser[ID]'");
$DB->query("
UPDATE users_sessions
SET
- IP='".$_SERVER['REMOTE_ADDR']."',
- Browser='$Browser',
- OperatingSystem='$OperatingSystem',
- LastUpdate='".sqltime()."'
- WHERE UserID='$LoggedUser[ID]'
- AND SessionID='".db_string($SessionID)."'");
- $Cache->begin_transaction('users_sessions_'.$UserID);
+ IP = '".$_SERVER['REMOTE_ADDR']."',
+ Browser = '$Browser',
+ OperatingSystem = '$OperatingSystem',
+ LastUpdate = '".sqltime()."'
+ WHERE UserID = '$LoggedUser[ID]'
+ AND SessionID = '".db_string($SessionID)."'");
+ $Cache->begin_transaction("users_sessions_$UserID");
$Cache->delete_row($SessionID);
$Cache->insert_front($SessionID,array(
- 'SessionID'=>$SessionID,
- 'Browser'=>$Browser,
- 'OperatingSystem'=>$OperatingSystem,
- 'IP'=>$_SERVER['REMOTE_ADDR'],
- 'LastUpdate'=>sqltime()
+ 'SessionID' => $SessionID,
+ 'Browser' => $Browser,
+ 'OperatingSystem' => $OperatingSystem,
+ 'IP' => $_SERVER['REMOTE_ADDR'],
+ 'LastUpdate' => sqltime()
));
$Cache->commit_transaction(0);
}
@@ -351,7 +353,7 @@ if (isset($LoginCookie)) {
$DB->query("
SELECT ID, Label
FROM users_notify_filters
- WHERE UserID='$LoggedUser[ID]'");
+ WHERE UserID = '$LoggedUser[ID]'");
$LoggedUser['Notify'] = $DB->to_array('ID');
$Cache->cache_value('notify_filters_'.$LoggedUser['ID'], $LoggedUser['Notify'], 2592000);
}
@@ -374,10 +376,10 @@ if (isset($LoginCookie)) {
$NewIP = db_string($_SERVER['REMOTE_ADDR']);
$DB->query("
UPDATE users_history_ips
- SET EndTime='".sqltime()."'
+ SET EndTime = '".sqltime()."'
WHERE EndTime IS NULL
- AND UserID='$LoggedUser[ID]'
- AND IP='$CurIP'");
+ AND UserID = '$LoggedUser[ID]'
+ AND IP = '$CurIP'");
$DB->query("
INSERT IGNORE INTO users_history_ips
(UserID, IP, StartTime)
@@ -387,8 +389,8 @@ if (isset($LoginCookie)) {
$ipcc = Tools::geoip($NewIP);
$DB->query("
UPDATE users_main
- SET IP='$NewIP', ipcc='$ipcc'
- WHERE ID='$LoggedUser[ID]'");
+ SET IP = '$NewIP', ipcc = '$ipcc'
+ WHERE ID = '$LoggedUser[ID]'");
$Cache->begin_transaction('user_info_heavy_'.$LoggedUser['ID']);
$Cache->update_row(false, array('IP' => $_SERVER['REMOTE_ADDR']));
$Cache->commit_transaction(0);
@@ -403,7 +405,7 @@ if (isset($LoginCookie)) {
$DB->query('
SELECT
ID,
- LOWER(REPLACE(Name," ","_")) AS Name,
+ LOWER(REPLACE(Name, " ", "_")) AS Name,
Name AS ProperName
FROM stylesheets');
$Stylesheets = $DB->to_array('ID', MYSQLI_BOTH);
@@ -434,8 +436,8 @@ function logout() {
$DB->query("
DELETE FROM users_sessions
- WHERE UserID='$LoggedUser[ID]'
- AND SessionID='".db_string($SessionID)."'");
+ WHERE UserID = '$LoggedUser[ID]'
+ AND SessionID = '".db_string($SessionID)."'");
$Cache->begin_transaction('users_sessions_'.$LoggedUser['ID']);
$Cache->delete_row($SessionID);
diff --git a/classes/search.class.php b/classes/search.class.php
index 304c3ec..939e3df 100644
--- a/classes/search.class.php
+++ b/classes/search.class.php
@@ -53,11 +53,11 @@ class SPHINX_SEARCH extends SphinxClient {
$Filters = array();
foreach ($this->Filters as $Name => $Values) {
foreach ($Values as $Value) {
- $Filters[] = $Name." - ".$Value;
+ $Filters[] = "$Name - $Value";
}
}
- $this->Queries[] = array('Params: '.$Query.' Filters: '.implode(", ", $Filters).' Indicies: '.$this->Index,($QueryEndTime - $QueryStartTime) * 1000);
+ $this->Queries[] = array("Params: $Query Filters: ".implode(', ', $Filters).' Indicies: '.$this->Index, ($QueryEndTime - $QueryStartTime) * 1000);
$this->Time += ($QueryEndTime - $QueryStartTime) * 1000;
if ($Result === false) {
@@ -65,7 +65,7 @@ class SPHINX_SEARCH extends SphinxClient {
send_irc('PRIVMSG '.ADMIN_CHAN.' :!dev Connection to searchd failed');
$Cache->cache_value('sphinx_crash_reported', 1, 3600);
}
- send_irc('PRIVMSG '.LAB_CHAN.' :Search for "'.$Query.'" ('.str_replace("\n",'',print_r($this->Filters, true)).') failed: '.$this->GetLastError());
+ send_irc('PRIVMSG '.LAB_CHAN." :Search for \"$Query\" (".str_replace("\n", '', print_r($this->Filters, true)).') failed: '.$this->GetLastError());
}
$this->TotalResults = $Result['total_found'];
@@ -89,7 +89,7 @@ class SPHINX_SEARCH extends SphinxClient {
foreach ($MatchIDs as $Match) {
$Matches[$Match] = $Matches[$Match]['attrs'];
if (!empty($CachePrefix)) {
- $Data = $Cache->get_value($CachePrefix.'_'.$Match);
+ $Data = $Cache->get_value($CachePrefix."_$Match");
if ($Data == false) {
$NotFound[] = $Match;
continue;
@@ -128,7 +128,7 @@ class SPHINX_SEARCH extends SphinxClient {
}
}
} else {
- $Matches = array('matches'=>$Matches,'notfound'=>$NotFound);
+ $Matches = array('matches' => $Matches, 'notfound' => $NotFound);
}
return $Matches;
@@ -157,7 +157,7 @@ class SPHINX_SEARCH extends SphinxClient {
}
function set_filter_range($Name, $Min, $Max, $Exclude) {
- $this->Filters[$Name] = array($Min.'-'.$Max);
+ $this->Filters[$Name] = array("$Min-$Max");
$this->SetFilterRange($Name, $Min, $Max, $Exclude);
}
diff --git a/classes/tools.class.php b/classes/tools.class.php
index 00e8997..99f5327 100644
--- a/classes/tools.class.php
+++ b/classes/tools.class.php
@@ -226,7 +226,7 @@ class Tools {
FROM users_info
WHERE UserID=$UserID
AND Warned != '0000-00-00 00:00:00'");
- if ($DB->record_count() > 0) {
+ if ($DB->has_results()) {
//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);
diff --git a/classes/torrent_form.class.php b/classes/torrent_form.class.php
index 22d57f9..d3c8d47 100644
--- a/classes/torrent_form.class.php
+++ b/classes/torrent_form.class.php
@@ -172,7 +172,7 @@ class TORRENT_FORM {
RemasterRecordLabel DESC,
RemasterCatalogueNumber DESC");
- if ($DB->record_count() > 0) {
+ if ($DB->has_results()) {
$GroupRemasters = $DB->to_array(false, MYSQLI_BOTH, false);
}
}
diff --git a/classes/torrents.class.php b/classes/torrents.class.php
index e7c0530..20f88b9 100644
--- a/classes/torrents.class.php
+++ b/classes/torrents.class.php
@@ -366,7 +366,7 @@ class Torrents {
SELECT CollageID
FROM collages_torrents
WHERE GroupID = '$GroupID'");
- if ($DB->record_count() > 0) {
+ if ($DB->has_results()) {
$CollageIDs = $DB->collect('CollageID');
$DB->query("
UPDATE collages
@@ -484,7 +484,7 @@ class Torrents {
SELECT Score
FROM torrents_votes
WHERE GroupID = $GroupID");
- if ($DB->record_count()) {
+ if ($DB->has_results()) {
list($VoteScore) = $DB->next_record();
} else {
$VoteScore = 0;
@@ -498,7 +498,7 @@ class Torrents {
WHERE ta.GroupID = $GroupID
AND ta.Importance IN ('1', '4', '5', '6')
GROUP BY ta.GroupID");
- if ($DB->record_count()) {
+ if ($DB->has_results()) {
list($ArtistName) = $DB->next_record(MYSQLI_NUM, false);
} else {
$ArtistName = '';
@@ -566,7 +566,7 @@ class Torrents {
JOIN torrents AS t ON t.ID = tf.TorrentID
JOIN torrents_group AS tg ON tg.ID = t.GroupID
WHERE tf.TorrentID = $TorrentID");
- if ($DB->record_count() > 0) {
+ if ($DB->has_results()) {
list($GroupID, $Contents) = $DB->next_record(MYSQLI_NUM, false);
if (Misc::is_new_torrent($Contents)) {
$Tor = new BencodeTorrent($Contents);
@@ -764,7 +764,7 @@ class Torrents {
SELECT ID
FROM torrents
WHERE GroupID IN ('.implode(', ', $GroupIDs).')');
- if ($DB->record_count()) {
+ if ($DB->has_results()) {
$TorrentIDs = $DB->collect('ID');
Torrents::freeleech_torrents($TorrentIDs, $FreeNeutral, $FreeLeechType);
}
diff --git a/classes/user_rank.class.php b/classes/user_rank.class.php
index ef20a98..bbf84c6 100644
--- a/classes/user_rank.class.php
+++ b/classes/user_rank.class.php
@@ -30,7 +30,7 @@ class UserRank {
$DB->query("
SELECT MIN(Val)
FROM temp_stats
- GROUP BY CEIL(ID/(".(int)$UserCount."/100));");
+ GROUP BY CEIL(ID / (".(int)$UserCount." / 100));");
$Table = $DB->to_array();
@@ -46,7 +46,7 @@ class UserRank {
$Query = "
SELECT Uploaded
FROM users_main
- WHERE Enabled='1'
+ WHERE Enabled = '1'
AND Uploaded > 0
ORDER BY Uploaded;";
break;
@@ -54,7 +54,7 @@ class UserRank {
$Query = "
SELECT Downloaded
FROM users_main
- WHERE Enabled='1'
+ WHERE Enabled = '1'
AND Downloaded > 0
ORDER BY Downloaded;";
break;
@@ -62,8 +62,8 @@ class UserRank {
$Query = "
SELECT COUNT(t.ID) AS Uploads
FROM users_main AS um
- JOIN torrents AS t ON t.UserID=um.ID
- WHERE um.Enabled='1'
+ JOIN torrents AS t ON t.UserID = um.ID
+ WHERE um.Enabled = '1'
GROUP BY um.ID
ORDER BY Uploads;";
break;
@@ -71,8 +71,8 @@ class UserRank {
$Query = "
SELECT COUNT(r.ID) AS Requests
FROM users_main AS um
- JOIN requests AS r ON r.FillerID=um.ID
- WHERE um.Enabled='1'
+ JOIN requests AS r ON r.FillerID = um.ID
+ WHERE um.Enabled = '1'
GROUP BY um.ID
ORDER BY Requests;";
break;
@@ -80,8 +80,8 @@ class UserRank {
$Query = "
SELECT COUNT(p.ID) AS Posts
FROM users_main AS um
- JOIN forums_posts AS p ON p.AuthorID=um.ID
- WHERE um.Enabled='1'
+ JOIN forums_posts AS p ON p.AuthorID = um.ID
+ WHERE um.Enabled = '1'
GROUP BY um.ID
ORDER BY Posts;";
break;
@@ -89,17 +89,16 @@ class UserRank {
$Query = "
SELECT SUM(rv.Bounty) AS Bounty
FROM users_main AS um
- JOIN requests_votes AS rv ON rv.UserID=um.ID
- WHERE um.Enabled='1'
- GROUP BY um.ID
+ JOIN requests_votes AS rv ON rv.UserID = um.ID
+ WHERE um.Enabled = '1' " .
+ "GROUP BY um.ID
ORDER BY Bounty;";
-
break;
case 'artists':
$Query = "
SELECT COUNT(ta.ArtistID) AS Artists
FROM torrents_artists AS ta
- JOIN torrents_group AS tg ON tg.ID=ta.GroupID
+ JOIN torrents_group AS tg ON tg.ID = ta.GroupID
JOIN torrents AS t ON t.GroupID = tg.ID
WHERE t.UserID != ta.UserID
GROUP BY tg.ID
@@ -118,13 +117,13 @@ class UserRank {
$Table = $Cache->get_value(PREFIX.$TableName);
if (!$Table) {
//Cache lock!
- $Lock = $Cache->get_value(PREFIX.$TableName."_lock");
+ $Lock = $Cache->get_value(PREFIX.$TableName.'_lock');
if ($Lock) {
return false;
} else {
- $Cache->cache_value(PREFIX.$TableName."_lock", '1', 300);
+ $Cache->cache_value(PREFIX.$TableName.'_lock', '1', 300);
$Table = self::build_table(PREFIX.$TableName, self::table_query($TableName));
- $Cache->delete_value(PREFIX.$TableName."_lock");
+ $Cache->delete_value(PREFIX.$TableName.'_lock');
}
}
$LastPercentile = 0;
diff --git a/classes/users.class.php b/classes/users.class.php
index 422b3d1..9e82aa8 100644
--- a/classes/users.class.php
+++ b/classes/users.class.php
@@ -46,7 +46,7 @@ class Users {
*/
public static function user_info($UserID) {
global $DB, $Cache, $Classes, $SSL;
- $UserInfo = $Cache->get_value('user_info_'.$UserID);
+ $UserInfo = $Cache->get_value("user_info_$UserID");
// the !isset($UserInfo['Paranoia']) can be removed after a transition period
if (empty($UserInfo) || empty($UserInfo['ID']) || !isset($UserInfo['Paranoia']) || empty($UserInfo['Class'])) {
$OldQueryID = $DB->get_query_id();
@@ -67,12 +67,23 @@ class Users {
m.Visible,
GROUP_CONCAT(ul.PermissionID SEPARATOR ',') AS Levels
FROM users_main AS m
- INNER JOIN users_info AS i ON i.UserID=m.ID
+ INNER JOIN users_info AS i ON i.UserID = m.ID
LEFT JOIN users_levels AS ul ON ul.UserID = m.ID
- WHERE m.ID='$UserID'
+ WHERE m.ID = '$UserID'
GROUP BY m.ID");
- if ($DB->record_count() == 0) { // Deleted user, maybe?
- $UserInfo = array('ID'=>'','Username'=>'','PermissionID'=>0,'Artist'=>false,'Donor'=>false,'Warned'=>'0000-00-00 00:00:00','Avatar'=>'','Enabled'=>0,'Title'=>'', 'CatchupTime'=>0, 'Visible'=>'1');
+ if (!$DB->has_results()) { // Deleted user, maybe?
+ $UserInfo = array(
+ 'ID' => '',
+ 'Username' => '',
+ 'PermissionID' => 0,
+ 'Artist' => false,
+ 'Donor' => false,
+ 'Warned' => '0000-00-00 00:00:00',
+ 'Avatar' => '',
+ 'Enabled' => 0,
+ 'Title' => '',
+ 'CatchupTime' => 0,
+ 'Visible' => '1');
} else {
$UserInfo = $DB->next_record(MYSQLI_ASSOC, array('Paranoia', 'Title'));
@@ -98,12 +109,12 @@ class Users {
}
$UserInfo['EffectiveClass'] = $EffectiveClass;
- $Cache->cache_value('user_info_'.$UserID, $UserInfo, 2592000);
+ $Cache->cache_value("user_info_$UserID", $UserInfo, 2592000);
$DB->set_query_id($OldQueryID);
}
if (strtotime($UserInfo['Warned']) < time()) {
$UserInfo['Warned'] = '0000-00-00 00:00:00';
- $Cache->cache_value('user_info_'.$UserID, $UserInfo, 2592000);
+ $Cache->cache_value("user_info_$UserID", $UserInfo, 2592000);
}
return $UserInfo;
@@ -120,7 +131,7 @@ class Users {
public static function user_heavy_info($UserID) {
global $DB, $Cache;
- $HeavyInfo = $Cache->get_value('user_info_heavy_'.$UserID);
+ $HeavyInfo = $Cache->get_value("user_info_heavy_$UserID");
if (empty($HeavyInfo)) {
$DB->query("
@@ -153,8 +164,8 @@ class Users {
m.FLTokens,
m.PermissionID
FROM users_main AS m
- INNER JOIN users_info AS i ON i.UserID=m.ID
- WHERE m.ID='$UserID'");
+ INNER JOIN users_info AS i ON i.UserID = m.ID
+ WHERE m.ID = '$UserID'");
$HeavyInfo = $DB->next_record(MYSQLI_ASSOC, array('CustomPermissions', 'SiteOptions'));
if (!empty($HeavyInfo['CustomPermissions'])) {
@@ -214,7 +225,7 @@ class Users {
}
unset($HeavyInfo['SiteOptions']);
- $Cache->cache_value('user_info_heavy_'.$UserID, $HeavyInfo, 0);
+ $Cache->cache_value("user_info_heavy_$UserID", $HeavyInfo, 0);
}
return $HeavyInfo;
}
@@ -257,7 +268,7 @@ class Users {
WHERE UserID = $UserID");
// Update cache
- $Cache->cache_value('user_info_heavy_'.$UserID, $HeavyInfo, 0);
+ $Cache->cache_value("user_info_heavy_$UserID", $HeavyInfo, 0);
// Update $LoggedUser if the options are changed for the current
if ($LoggedUser['ID'] == $UserID) {
@@ -302,7 +313,7 @@ class Users {
$Val = (isset($RT[$Key]) ? $RT[$Key] : 'Error');
}
- $ID = $Key . '_' . (int) !!$Checked;
+ $ID = "$Key_" . (int) !!$Checked;
// The HTML is indented this far for proper indentation in the generated HTML
// on user.php?action=edit
@@ -530,17 +541,17 @@ class Users {
$UserID = (int) $UserID;
- if (($Data = $Cache->get_value('bookmarks_group_ids_' . $UserID))) {
+ if (($Data = $Cache->get_value("bookmarks_group_ids_$UserID"))) {
list($GroupIDs, $BookmarkData) = $Data;
} else {
$DB->query("
SELECT GroupID, Sort, `Time`
FROM bookmarks_torrents
- WHERE UserID=$UserID
+ WHERE UserID = $UserID
ORDER BY Sort, `Time` ASC");
$GroupIDs = $DB->collect('GroupID');
$BookmarkData = $DB->to_array('GroupID', MYSQLI_ASSOC);
- $Cache->cache_value('bookmarks_group_ids_' . $UserID,
+ $Cache->cache_value("bookmarks_group_ids_$UserID",
array($GroupIDs, $BookmarkData), 3600);
}
@@ -559,7 +570,7 @@ class Users {
* @param string $ReturnHTML
* @return string
*/
- public static function show_avatar($Avatar, $Username, $Setting, $Size=150, $ReturnHTML = True) {
+ public static function show_avatar($Avatar, $Username, $Setting, $Size = 150, $ReturnHTML = True) {
global $LoggedUser;
$Avatar = ImageTools::process($Avatar);
// case 1 is avatars disabled
diff --git a/classes/votes.class.php b/classes/votes.class.php
index 31e27fd..63a064e 100644
--- a/classes/votes.class.php
+++ b/classes/votes.class.php
@@ -34,14 +34,14 @@ class Votes {
return array();
}
- $UserVotes = $Cache->get_value('voted_albums_'.$UserID);
+ $UserVotes = $Cache->get_value("voted_albums_$UserID");
if ($UserVotes === false) {
- $DB->query('
+ $DB->query("
SELECT GroupID, Type
FROM users_votes
- WHERE UserID='.$UserID);
+ WHERE UserID = $UserID");
$UserVotes = $DB->to_array('GroupID', MYSQL_ASSOC, false);
- $Cache->cache_value('voted_albums_'.$UserID, $UserVotes);
+ $Cache->cache_value("voted_albums_$UserID", $UserVotes);
}
return $UserVotes;
}
@@ -56,18 +56,18 @@ class Votes {
public static function get_group_votes($GroupID) {
global $DB, $Cache;
- $GroupVotes = $Cache->get_value('votes_'.$GroupID);
+ $GroupVotes = $Cache->get_value("votes_$GroupID");
if ($GroupVotes === false) {
$DB->query("
SELECT Ups AS Ups, Total AS Total
FROM torrents_votes
WHERE GroupID = $GroupID");
- if ($DB->record_count() == 0) {
+ if (!$DB->has_results()) {
$GroupVotes = array('Ups' => 0, 'Total' => 0);
} else {
$GroupVotes = $DB->next_record(MYSQLI_ASSOC, false);
}
- $Cache->cache_value('votes_'.$GroupID, $GroupVotes, 259200); // 3 days
+ $Cache->cache_value("votes_$GroupID", $GroupVotes, 259200); // 3 days
}
return $GroupVotes;
}
@@ -215,11 +215,11 @@ class Votes {
if ($Rankings === false) {
$Rankings = array();
$i = 0;
- $DB->query("
+ $DB->query('
SELECT GroupID
FROM torrents_votes
ORDER BY Score DESC
- LIMIT 100");
+ LIMIT 100');
while (list($GID) = $DB->next_record()) {
$Rankings[$GID] = ++$i;
}
@@ -246,7 +246,7 @@ class Votes {
return false;
}
- $Rankings = $Cache->get_value('voting_ranks_year_'.$Year);
+ $Rankings = $Cache->get_value("voting_ranks_year_$Year");
if ($Rankings === false) {
$Rankings = array();
$i = 0;
@@ -260,7 +260,7 @@ class Votes {
while (list($GID) = $DB->next_record()) {
$Rankings[$GID] = ++$i;
}
- $Cache->cache_value('voting_ranks_year_'.$Year , $Rankings, 259200); // 3 days
+ $Cache->cache_value("voting_ranks_year_$Year", $Rankings, 259200); // 3 days
}
return (isset($Rankings[$GroupID]) ? $Rankings[$GroupID] : false);
@@ -287,7 +287,7 @@ class Votes {
// First year of the decade
$Year = $Year - ($Year % 10);
- $Rankings = $Cache->get_value('voting_ranks_decade_'.$Year);
+ $Rankings = $Cache->get_value("voting_ranks_decade_$Year");
if ($Rankings === false) {
$Rankings = array();
$i = 0;
@@ -302,7 +302,7 @@ class Votes {
while (list($GID) = $DB->next_record()) {
$Rankings[$GID] = ++$i;
}
- $Cache->cache_value('voting_ranks_decade_'.$Year , $Rankings, 259200); // 3 days
+ $Cache->cache_value("voting_ranks_decade_$Year", $Rankings, 259200); // 3 days
}
return (isset($Rankings[$GroupID]) ? $Rankings[$GroupID] : false);
diff --git a/design/privateheader.php b/design/privateheader.php
index 2f6ccf3..886bc47 100644
--- a/design/privateheader.php
+++ b/design/privateheader.php
@@ -364,7 +364,7 @@ if ($CurrentNews === false) {
FROM news
ORDER BY Time DESC
LIMIT 1");
- if ($DB->record_count() == 1) {
+ if ($DB->record_count() === 1) {
list($CurrentNews) = $DB->next_record();
} else {
$CurrentNews = -1;
@@ -385,7 +385,7 @@ if ($CurrentBlog === false) {
WHERE Important = 1
ORDER BY Time DESC
LIMIT 1");
- if ($DB->record_count() == 1) {
+ if ($DB->record_count() === 1) {
list($CurrentBlog) = $DB->next_record();
} else {
$CurrentBlog = -1;
diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt
index 183ee93..c8e0ccd 100644
--- a/docs/CHANGES.txt
+++ b/docs/CHANGES.txt
@@ -1,5 +1,11 @@
CHANGELOG
+2013-07-08 by alderaan
+Add "has_results()" function for MySQL class to replace "record_count() === 0" conditional checks
+
+2013-07-06 by draculesti
+Bounty amount after tax shown on request pages
+
2013-07-04 by Ajax
added collages to api
diff --git a/docs/INSTALL.txt b/docs/INSTALL.txt
index 5d3bcf2..495c344 100644
--- a/docs/INSTALL.txt
+++ b/docs/INSTALL.txt
@@ -3,7 +3,11 @@ INSTALLATION NOTES
memcached -d -m 5120 -s /var/run/memcached.sock -a 0777 -t16 -C -u root
This gives it 5 gigs of RAM; you probably want to set that a bit lower!
2. Run gazelle.sql (preferably as root) to create the database, the table, and the default data.
-3. Install sphinx - we recommend you use the included sphinx.conf
+3. Install Sphinx - we recommend you use the included sphinx.conf. You can copy this to
+ /etc/sphinx/sphinx.conf. You need to fill in the details of the SQL server though!
+
+ You might also need to create the /var/data/sphinx folder.
+
For documentation, read http://www.sphinxsearch.com/docs/current.html
After you've installed sphinx, create the indices:
@@ -14,17 +18,17 @@ INSTALLATION NOTES
5. Sign up. The first user is made a SysOp!
6. Set up cron jobs. You need a cron job for the schedule, a cron job for
the peerupdate (all groups are cached, but the peer counts change often,
-so peerupdate is a script to update them), and the two sphinx indices.
-These are our cron jobs:
+so peerupdate is a script to update them), and the two Sphinx indices.
+These are our cron jobs. SCHEDULE_KEY is the same as in classes/config.php:
0,15,30,45 * * * * /usr/local/bin/php /var/www/vhosts/what/schedule.php SCHEDULE_KEY >> /root/schedule.log
10,25,40,55 * * * * /usr/local/bin/php /var/www/vhosts/what/peerupdate.php SCHEDULE_KEY >> /root/peerupdate.log
* * * * * /usr/local/bin/indexer -c /etc/sphinx/sphinx.conf --rotate delta
5 0,12 * * * /usr/local/bin/indexer -c /etc/sphinx/sphinx.conf --rotate --all
-7. You're probably going to want geoip information, so first you need to fill in the geoip_country tables by visiting /tools.php?action=update_geoip .
- After that finishes parsing information from maxmind, you may want to map users to countries by running:
- "INSERT INTO users_geodistribution (Code, Users) SELECT g.Code, COUNT(u.ID) AS Users FROM geoip_country AS g JOIN users_main AS u ON INET_ATON(u.IP) BETWEEN g.StartIP AND g.EndIP WHERE u.Enabled='1' GROUP BY g.Code ORDER BY Users DESC"
+7. You're probably going to want IP geolocation information, so first you need to fill in the geoip_country tables by visiting /tools.php?action=update_geoip
+ After that finishes parsing information from MaxMind, you may want to map users to countries by running:
+ "INSERT INTO users_geodistribution (Code, Users) SELECT g.Code, COUNT(u.ID) AS Users FROM geoip_country AS g JOIN users_main AS u ON INET_ATON(u.IP) BETWEEN g.StartIP AND g.EndIP WHERE u.Enabled = '1' GROUP BY g.Code ORDER BY Users DESC"
This will fill in the table needed for stats.
8. Start modifying stuff. Hopefully, everything will have gone smoothly so far and nothing will have exploded (ha ha ha)
diff --git a/sections/ajax/announcements.php b/sections/ajax/announcements.php
index 5f9d7a9..6ddba80 100644
--- a/sections/ajax/announcements.php
+++ b/sections/ajax/announcements.php
@@ -12,16 +12,19 @@ if (!$News = $Cache->get_value('news')) {
FROM news
ORDER BY Time DESC
LIMIT 5");
- $News = $DB->to_array(false,MYSQLI_NUM,false);
- $Cache->cache_value('news',$News,3600 * 24 * 30);
+ $News = $DB->to_array(false, MYSQLI_NUM, false);
+ $Cache->cache_value('news', $News, 3600 * 24 * 30);
$Cache->cache_value('news_latest_id', $News[0][0], 0);
}
if ($LoggedUser['LastReadNews'] != $News[0][0]) {
- $Cache->begin_transaction('user_info_heavy_'.$UserID);
+ $Cache->begin_transaction("user_info_heavy_$UserID");
$Cache->update_row(false, array('LastReadNews' => $News[0][0]));
$Cache->commit_transaction(0);
- $DB->query("UPDATE users_info SET LastReadNews = '".$News[0][0]."' WHERE UserID = ".$UserID);
+ $DB->query("
+ UPDATE users_info
+ SET LastReadNews = '".$News[0][0]."'
+ WHERE UserID = $UserID");
$LoggedUser['LastReadNews'] = $News[0][0];
}
@@ -35,11 +38,11 @@ if (($Blog = $Cache->get_value('blog')) === false) {
b.Time,
b.ThreadID
FROM blog AS b
- LEFT JOIN users_main AS um ON b.UserID=um.ID
+ LEFT JOIN users_main AS um ON b.UserID = um.ID
ORDER BY Time DESC
LIMIT 20");
$Blog = $DB->to_array();
- $Cache->cache_value('blog',$Blog,1209600);
+ $Cache->cache_value('blog', $Blog, 1209600);
}
$JsonBlog = array();
for ($i = 0; $i < 5; $i++) {
@@ -57,7 +60,7 @@ for ($i = 0; $i < 5; $i++) {
$JsonAnnouncements = array();
$Count = 0;
foreach ($News as $NewsItem) {
- list($NewsID,$Title,$Body,$NewsTime) = $NewsItem;
+ list($NewsID, $Title, $Body, $NewsTime) = $NewsItem;
if (strtotime($NewsTime) > time()) {
continue;
}
diff --git a/sections/ajax/artist.php b/sections/ajax/artist.php
index 65e9997..01fb12e 100644
--- a/sections/ajax/artist.php
+++ b/sections/ajax/artist.php
@@ -23,7 +23,10 @@ if ($ArtistID && !is_number($ArtistID)) {
if (empty($ArtistID)) {
if (!empty($_GET['artistname'])) {
$Name = db_string(trim($_GET['artistname']));
- $DB->query("SELECT ArtistID FROM artists_alias WHERE Name LIKE '$Name'");
+ $DB->query("
+ SELECT ArtistID
+ FROM artists_alias
+ WHERE Name LIKE '$Name'");
if (!(list($ArtistID) = $DB->next_record(MYSQLI_NUM, false))) {
json_die("failure");
}
@@ -32,13 +35,13 @@ if (empty($ArtistID)) {
}
if (!empty($_GET['revisionid'])) { // if they're viewing an old revision
- $RevisionID=$_GET['revisionid'];
+ $RevisionID = $_GET['revisionid'];
if (!is_number($RevisionID)) {
error(0);
}
$Data = $Cache->get_value("artist_$ArtistID"."_revision_$RevisionID");
} else { // viewing the live version
- $Data = $Cache->get_value('artist_'.$ArtistID);
+ $Data = $Cache->get_value("artist_$ArtistID");
$RevisionID = false;
}
if ($Data) {
@@ -52,8 +55,8 @@ if ($Data) {
wiki.body,
a.VanityHouse
FROM wiki_artists AS wiki
- LEFT JOIN artists_group AS a ON wiki.RevisionID=a.RevisionID
- WHERE wiki.RevisionID='$RevisionID' ";
+ LEFT JOIN artists_group AS a ON wiki.RevisionID = a.RevisionID
+ WHERE wiki.RevisionID = '$RevisionID' ";
} else {
$sql = "
SELECT
@@ -62,13 +65,13 @@ if ($Data) {
wiki.body,
a.VanityHouse
FROM artists_group AS a
- LEFT JOIN wiki_artists AS wiki ON wiki.RevisionID=a.RevisionID
- WHERE a.ArtistID='$ArtistID' ";
+ 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->has_results()) {
json_die("failure");
}
@@ -76,7 +79,7 @@ if ($Data) {
}
// Requests
-$Requests = $Cache->get_value('artists_requests_'.$ArtistID);
+$Requests = $Cache->get_value("artists_requests_$ArtistID");
if (!is_array($Requests)) {
$DB->query("
SELECT
@@ -88,33 +91,33 @@ if (!is_array($Requests)) {
COUNT(rv.UserID) AS Votes,
SUM(rv.Bounty) AS Bounty
FROM requests AS r
- LEFT JOIN requests_votes AS rv ON rv.RequestID=r.ID
- LEFT JOIN requests_artists AS ra ON r.ID=ra.RequestID
- WHERE ra.ArtistID = ".$ArtistID."
+ LEFT JOIN requests_votes AS rv ON rv.RequestID = r.ID
+ LEFT JOIN requests_artists AS ra ON r.ID = ra.RequestID
+ WHERE ra.ArtistID = $ArtistID
AND r.TorrentID = 0
GROUP BY r.ID
ORDER BY Votes DESC");
- if ($DB->record_count() > 0) {
+ if ($DB->has_results()) {
$Requests = $DB->to_array();
} else {
$Requests = array();
}
- $Cache->cache_value('artists_requests_'.$ArtistID, $Requests);
+ $Cache->cache_value("artists_requests_$ArtistID", $Requests);
}
$NumRequests = count($Requests);
-if (($Importances = $Cache->get_value('artist_groups_'.$ArtistID)) === false) {
+if (($Importances = $Cache->get_value("artist_groups_$ArtistID")) === false) {
$DB->query("
SELECT
DISTINCTROW ta.GroupID, ta.Importance, tg.VanityHouse, tg.Year
FROM torrents_artists AS ta
- JOIN torrents_group AS tg ON tg.ID=ta.GroupID
- WHERE ta.ArtistID='$ArtistID'
+ JOIN torrents_group AS tg ON tg.ID = ta.GroupID
+ 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);
+ $Cache->cache_value("artist_groups_$ArtistID", $Importances, 0);
} else {
$GroupIDs = array();
foreach ($Importances as $Group) {
@@ -122,7 +125,7 @@ if (($Importances = $Cache->get_value('artist_groups_'.$ArtistID)) === false) {
}
}
if (count($GroupIDs) > 0) {
- $TorrentList = Torrents::get_groups($GroupIDs, true,true);
+ $TorrentList = Torrents::get_groups($GroupIDs, true, true);
$TorrentList = $TorrentList['matches'];
} else {
$TorrentList = array();
@@ -182,7 +185,6 @@ foreach ($TorrentList as $GroupID => $Group) {
foreach ($ArtistGroup as &$Artist) {
$Artist['id'] = (int) $Artist['id'];
$Artist['aliasid'] = (int) $Artist['aliasid'];
-
}
}
@@ -193,12 +195,12 @@ foreach ($TorrentList as $GroupID => $Group) {
$GroupVanityHouse = $Importances[$GroupID]['VanityHouse'];
- $TagList = explode(' ',str_replace('_','.',$TagList));
+ $TagList = explode(' ',str_replace('_', '.', $TagList));
// $Tags array is for the sidebar on the right
foreach ($TagList as $Tag) {
if (!isset($Tags[$Tag])) {
- $Tags[$Tag] = array('name'=>$Tag, 'count'=>1);
+ $Tags[$Tag] = array('name' => $Tag, 'count' => 1);
} else {
$Tags[$Tag]['count']++;
}
@@ -262,10 +264,10 @@ if (empty($SimilarArray)) {
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
- WHERE s1.ArtistID='$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
");
@@ -309,11 +311,16 @@ foreach ($Requests as $Request) {
$notificationsEnabled = false;
if (check_perms('site_torrents_notify')) {
if (($Notify = $Cache->get_value('notify_artists_'.$LoggedUser['ID'])) === false) {
- $DB->query("SELECT ID, Artists FROM users_notify_filters WHERE UserID='$LoggedUser[ID]' AND Label='Artist notifications' LIMIT 1");
+ $DB->query("
+ SELECT ID, Artists
+ FROM users_notify_filters
+ WHERE UserID = '$LoggedUser[ID]'
+ AND Label = 'Artist notifications'
+ LIMIT 1");
$Notify = $DB->next_record(MYSQLI_ASSOC, false);
$Cache->cache_value('notify_artists_'.$LoggedUser['ID'], $Notify, 0);
}
- if (stripos($Notify['Artists'], '|'.$Name.'|') === false) {
+ if (stripos($Notify['Artists'], "|$Name|") === false) {
$notificationsEnabled = false;
} else {
$notificationsEnabled = true;
@@ -325,7 +332,7 @@ if (check_perms('site_torrents_notify')) {
if ($RevisionID) {
$Key = "artist_$ArtistID"."_revision_$RevisionID";
} else {
- $Key = 'artist_'.$ArtistID;
+ $Key = "artist_$ArtistID";
}
$Data = array(array($Name, $Image, $Body, $NumSimilar, $SimilarArray, array(), array(), $VanityHouseArtist));
diff --git a/sections/ajax/browse.php b/sections/ajax/browse.php
index 5b527ac..43da9bd 100644
--- a/sections/ajax/browse.php
+++ b/sections/ajax/browse.php
@@ -1,11 +1,9 @@
<?
-
-
include(SERVER_ROOT.'/sections/torrents/functions.php');
// The "order by x" links on columns headers
-function header_link($SortKey,$DefaultWay = 'desc') {
+function header_link($SortKey, $DefaultWay = 'desc') {
global $OrderBy,$OrderWay;
if ($SortKey == $OrderBy) {
if ($OrderWay == 'desc') {
@@ -17,48 +15,60 @@ function header_link($SortKey,$DefaultWay = 'desc') {
$NewWay = $DefaultWay;
}
- return 'torrents.php?order_way='.$NewWay.'&amp;order_by='.$SortKey.'&amp;'.Format::get_url(array('order_way','order_by'));
+ return "torrents.php?order_way=$NewWay&amp;order_by=$SortKey&amp;".Format::get_url(array('order_way', 'order_by'));
}
/** Start default parameters and validation **/
// Setting default search options
if (!empty($_GET['setdefault'])) {
- $UnsetList = array('page','setdefault');
- $UnsetRegexp = '/(&|^)('.implode('|',$UnsetList).')=.*?(&|$)/i';
-
- $DB->query("SELECT SiteOptions FROM users_info WHERE UserID='".db_string($LoggedUser['ID'])."'");
- list($SiteOptions)=$DB->next_record(MYSQLI_NUM, false);
+ $UnsetList = array('page', 'setdefault');
+ $UnsetRegexp = '/(&|^)('.implode('|', $UnsetList).')=.*?(&|$)/i';
+
+ $DB->query("
+ SELECT SiteOptions
+ FROM users_info
+ WHERE UserID = '".db_string($LoggedUser['ID'])."'");
+ list($SiteOptions) = $DB->next_record(MYSQLI_NUM, false);
if (!empty($SiteOptions)) {
$SiteOptions = unserialize($SiteOptions);
} else {
$SiteOptions = array();
}
- $SiteOptions['DefaultSearch'] = preg_replace($UnsetRegexp,'',$_SERVER['QUERY_STRING']);
- $DB->query("UPDATE users_info SET SiteOptions='".db_string(serialize($SiteOptions))."' WHERE UserID='".db_string($LoggedUser['ID'])."'");
- $Cache->begin_transaction('user_info_heavy_'.$UserID);
- $Cache->update_row(false, array('DefaultSearch'=>$SiteOptions['DefaultSearch']));
+ $SiteOptions['DefaultSearch'] = preg_replace($UnsetRegexp, '', $_SERVER['QUERY_STRING']);
+ $DB->query("
+ UPDATE users_info
+ SET SiteOptions = '".db_string(serialize($SiteOptions))."'
+ WHERE UserID = '".db_string($LoggedUser['ID'])."'");
+ $Cache->begin_transaction("user_info_heavy_$UserID");
+ $Cache->update_row(false, array('DefaultSearch' => $SiteOptions['DefaultSearch']));
$Cache->commit_transaction(0);
// Clearing default search options
} elseif (!empty($_GET['cleardefault'])) {
- $DB->query("SELECT SiteOptions FROM users_info WHERE UserID='".db_string($LoggedUser['ID'])."'");
- list($SiteOptions)=$DB->next_record(MYSQLI_NUM, false);
- $SiteOptions=unserialize($SiteOptions);
+ $DB->query("
+ SELECT SiteOptions
+ FROM users_info
+ WHERE UserID = '".db_string($LoggedUser['ID'])."'");
+ list($SiteOptions) = $DB->next_record(MYSQLI_NUM, false);
+ $SiteOptions = unserialize($SiteOptions);
$SiteOptions['DefaultSearch']='';
- $DB->query("UPDATE users_info SET SiteOptions='".db_string(serialize($SiteOptions))."' WHERE UserID='".db_string($LoggedUser['ID'])."'");
- $Cache->begin_transaction('user_info_heavy_'.$UserID);
- $Cache->update_row(false, array('DefaultSearch'=>''));
+ $DB->query("
+ UPDATE users_info
+ SET SiteOptions = '".db_string(serialize($SiteOptions))."'
+ WHERE UserID = '".db_string($LoggedUser['ID'])."'");
+ $Cache->begin_transaction("user_info_heavy_$UserID");
+ $Cache->update_row(false, array('DefaultSearch' => ''));
$Cache->commit_transaction(0);
// Use default search options
-} elseif (empty($_SERVER['QUERY_STRING']) || (count($_GET) == 1 && isset($_GET['page']))) {
+} elseif (empty($_SERVER['QUERY_STRING']) || (count($_GET) === 1 && isset($_GET['page']))) {
if (!empty($LoggedUser['DefaultSearch'])) {
if (!empty($_GET['page'])) {
$Page = $_GET['page'];
- parse_str($LoggedUser['DefaultSearch'],$_GET);
+ parse_str($LoggedUser['DefaultSearch'], $_GET);
$_GET['page'] = $Page;
} else {
- parse_str($LoggedUser['DefaultSearch'],$_GET);
+ parse_str($LoggedUser['DefaultSearch'], $_GET);
}
}
}
@@ -113,9 +123,9 @@ if (!empty($_GET['order_way']) && $_GET['order_way'] == 'asc') {
/** Start preparation of property arrays **/
array_pop($Bitrates); // remove 'other'
-$SearchBitrates = array_merge($Bitrates, array('v0','v1','v2','24bit'));
+$SearchBitrates = array_merge($Bitrates, array('v0', 'v1', 'v2', '24bit'));
-foreach ($SearchBitrates as $ID=>$Val) {
+foreach ($SearchBitrates as $ID => $Val) {
$SearchBitrates[$ID] = strtolower($Val);
}
foreach ($Formats as $ID => $Val) {
@@ -163,7 +173,7 @@ if (!empty($_GET['filelist'])) {
}
// Collect all entered search terms to find out whether to enable the NOT operator
-$GroupFields = array('artistname','groupname', 'recordlabel', 'cataloguenumber', 'taglist');
+$GroupFields = array('artistname', 'groupname', 'recordlabel', 'cataloguenumber', 'taglist');
$TorrentFields = array('remastertitle', 'remasteryear', 'remasterrecordlabel', 'remastercataloguenumber', 'encoding', 'format', 'media');
$SearchWords = array();
foreach (array('artistname', 'groupname', 'recordlabel', 'cataloguenumber',
@@ -182,7 +192,7 @@ foreach (array('artistname', 'groupname', 'recordlabel', 'cataloguenumber',
foreach ($Words as $Word) {
$Word = trim($Word);
if ($Word[0] == '!' && strlen($Word) >= 2) {
- if (strpos($Word,'!',1) === false) {
+ if (strpos($Word, '!', 1) === false) {
$SearchWords[$Search]['exclude'][] = $Word;
} else {
$SearchWords[$Search]['include'][] = $Word;
@@ -200,7 +210,7 @@ foreach (array('artistname', 'groupname', 'recordlabel', 'cataloguenumber',
//Simple search
if (!empty($_GET['searchstr'])) {
$SearchString = trim($_GET['searchstr']);
- $Words = explode(' ',strtolower($SearchString));
+ $Words = explode(' ', strtolower($SearchString));
if (!empty($Words)) {
$FilterBitrates = $FilterFormats = array();
$BasicSearch = array('include' => array(), 'exclude' => array());
@@ -209,7 +219,7 @@ if (!empty($_GET['searchstr'])) {
if ($Word[0] == '!' && strlen($Word) >= 2) {
if ($Word == '!100%') {
$_GET['haslog'] = '-1';
- } elseif (strpos($Word,'!',1) === false) {
+ } elseif (strpos($Word, '!', 1) === false) {
$BasicSearch['exclude'][] = $Word;
} else {
$BasicSearch['include'][] = $Word;
@@ -238,7 +248,7 @@ if (!empty($_GET['searchstr'])) {
}
if (!empty($BasicSearch['exclude'])) {
foreach ($BasicSearch['exclude'] as $Word) {
- $QueryParts[] = '!'.Sphinxql::escape_string(substr($Word,1));
+ $QueryParts[] = '!'.Sphinxql::escape_string(substr($Word, 1));
}
}
if (!empty($FilterBitrates)) {
@@ -274,7 +284,7 @@ if (!empty($SearchWords['taglist'])) {
}
if (!empty($Tags['exclude'])) {
foreach ($Tags['exclude'] as &$Tag) {
- $Tag = '!'.Sphinxql::escape_string(substr($Tag,1));
+ $Tag = '!'.Sphinxql::escape_string(substr($Tag, 1));
}
}
@@ -316,7 +326,7 @@ foreach ($SearchWords as $Search => $Words) {
}
if (!empty($Words['exclude'])) {
foreach ($Words['exclude'] as $Word) {
- $QueryParts[] = '!'.Sphinxql::escape_string(substr($Word,1));
+ $QueryParts[] = '!'.Sphinxql::escape_string(substr($Word, 1));
}
}
if (!empty($QueryParts)) {
@@ -330,7 +340,7 @@ foreach ($SearchWords as $Search => $Words) {
if (!empty($_GET['year'])) {
$Years = explode('-', $_GET['year']);
if (is_number($Years[0]) || (empty($Years[0]) && !empty($Years[1]) && is_number($Years[1]))) {
- if (count($Years) == 1) {
+ if (count($Years) === 1) {
$SphQL->where('year', (int)$Years[0]);
$SphQLTor->where('year', (int)$Years[0]);
} else {
@@ -346,7 +356,7 @@ if (!empty($_GET['year'])) {
}
}
-if (isset($_GET['haslog']) && $_GET['haslog']!=='') {
+if (isset($_GET['haslog']) && $_GET['haslog'] !== '') {
if ($_GET['haslog'] == 100) {
$SphQL->where('logscore', 100);
$SphQLTor->where('logscore', 100);
@@ -367,7 +377,7 @@ if (isset($_GET['haslog']) && $_GET['haslog']!=='') {
$Filtered = true;
}
}
-foreach (array('hascue','scene','vanityhouse','releasetype') as $Search) {
+foreach (array('hascue', 'scene', 'vanityhouse', 'releasetype') as $Search) {
if (isset($_GET[$Search]) && $_GET[$Search] !== '') {
$SphQL->where($Search, $_GET[$Search]);
// Release type is group specific
@@ -420,7 +430,7 @@ if (!$Filtered) {
if (isset($Random) && $GroupResults) {
// ORDER BY RAND() can't be used together with GROUP BY, so we need some special tactics
$Page = 1;
- $SphQL->limit(0, 5*TORRENTS_PER_PAGE, 5*TORRENTS_PER_PAGE);
+ $SphQL->limit(0, 5 * TORRENTS_PER_PAGE, 5 * TORRENTS_PER_PAGE);
$SphQLResult = $SphQL->query();
$TotalCount = $SphQLResult->get_meta('total_found');
$Results = $SphQLResult->to_array('groupid');
@@ -482,7 +492,7 @@ if ($TorrentCount) {
}
}
- // Get a list of all torrent ids that match the search query
+ // Get a list of all torrent IDs that match the search query
$SphQLTor->where('id', $TorrentIDs)->limit(0, count($TorrentIDs), count($TorrentIDs));
$SphQLResultTor = $SphQLTor->query();
$TorrentIDs = array_fill_keys($SphQLResultTor->collect('id'), true);
@@ -492,14 +502,15 @@ if ($TorrentCount) {
if ($TorrentCount == 0) {
-$DB->query("SELECT
- tags.Name,
- ((COUNT(tags.Name)-2)*(SUM(tt.PositiveVotes)-SUM(tt.NegativeVotes)))/(tags.Uses*0.8) AS Score
+$DB->query("
+ SELECT
+ tags.Name,
+ ((COUNT(tags.Name) - 2) * (SUM(tt.PositiveVotes) - SUM(tt.NegativeVotes))) / (tags.Uses * 0.8) AS Score
FROM xbt_snatched AS s
- INNER JOIN torrents AS t ON t.ID=s.fid
- INNER JOIN torrents_group AS g ON t.GroupID=g.ID
- INNER JOIN torrents_tags AS tt ON tt.GroupID=g.ID
- INNER JOIN tags ON tags.ID=tt.TagID
+ INNER JOIN torrents AS t ON t.ID = s.fid
+ INNER JOIN torrents_group AS g ON t.GroupID = g.ID
+ INNER JOIN torrents_tags AS tt ON tt.GroupID = g.ID
+ INNER JOIN tags ON tags.ID = tt.TagID
WHERE s.uid = '$LoggedUser[ID]'
AND tt.TagID != '13679'
AND tt.TagID != '4820'
@@ -553,7 +564,7 @@ foreach ($Results as $Result) {
$Torrents = array($Result['id'] => $GroupInfo['Torrents'][$Result['id']]);
}
- $TagList = explode(' ',str_replace('_','.',$GroupInfo['TagList']));
+ $TagList = explode(' ', str_replace('_', '.', $GroupInfo['TagList']));
$JsonArtists = array();
if (!empty($ExtendedArtists[1]) || !empty($ExtendedArtists[4]) || !empty($ExtendedArtists[5]) || !empty($ExtendedArtists[6])) {
unset($ExtendedArtists[2]);
@@ -578,7 +589,7 @@ foreach ($Results as $Result) {
} else {
$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 = '';
@@ -602,7 +613,7 @@ foreach ($Results as $Result) {
$FirstUnknown = !isset($FirstUnknown);
}
- if (isset($GroupedCategories[$CategoryID-1])
+ if (isset($GroupedCategories[$CategoryID - 1])
&& ($Data['RemasterTitle'] != $LastRemasterTitle
|| $Data['RemasterYear'] != $LastRemasterYear
|| $Data['RemasterRecordLabel'] != $LastRemasterRecordLabel
@@ -614,19 +625,34 @@ foreach ($Results as $Result) {
if ($Data['Remastered'] && $Data['RemasterYear'] != 0) {
$RemasterName = $Data['RemasterYear'];
- $AddExtra = " - ";
- if ($Data['RemasterRecordLabel']) { $RemasterName .= $AddExtra.display_str($Data['RemasterRecordLabel']); $AddExtra=' / '; }
- if ($Data['RemasterCatalogueNumber']) { $RemasterName .= $AddExtra.display_str($Data['RemasterCatalogueNumber']); $AddExtra=' / '; }
- if ($Data['RemasterTitle']) { $RemasterName .= $AddExtra.display_str($Data['RemasterTitle']); $AddExtra=' / '; }
+ $AddExtra = ' - ';
+ if ($Data['RemasterRecordLabel']) {
+ $RemasterName .= $AddExtra.display_str($Data['RemasterRecordLabel']);
+ $AddExtra = ' / ';
+ }
+ if ($Data['RemasterCatalogueNumber']) {
+ $RemasterName .= $AddExtra.display_str($Data['RemasterCatalogueNumber']);
+ $AddExtra = ' / ';
+ }
+ if ($Data['RemasterTitle']) {
+ $RemasterName .= $AddExtra.display_str($Data['RemasterTitle']);
+ $AddExtra = ' / ';
+ }
$RemasterName .= $AddExtra.display_str($Data['Media']);
} else {
- $AddExtra = " / ";
+ $AddExtra = ' / ';
if (!$Data['Remastered']) {
- $MasterName = "Original Release";
- if ($GroupRecordLabel) { $MasterName .= $AddExtra.$GroupRecordLabel; $AddExtra=' / '; }
- if ($GroupCatalogueNumber) { $MasterName .= $AddExtra.$GroupCatalogueNumber; $AddExtra=' / '; }
+ $MasterName = 'Original Release';
+ if ($GroupRecordLabel) {
+ $MasterName .= $AddExtra.$GroupRecordLabel;
+ $AddExtra = ' / ';
+ }
+ if ($GroupCatalogueNumber) {
+ $MasterName .= $AddExtra.$GroupCatalogueNumber;
+ $AddExtra = ' / ';
+ }
} else {
- $MasterName = "Unknown Release(s)";
+ $MasterName = 'Unknown Release(s)';
}
$MasterName .= $AddExtra.display_str($Data['Media']);
}
@@ -694,7 +720,7 @@ foreach ($Results as $Result) {
'groupName' => $GroupName,
'torrentId' => (int) $TorrentID,
'tags' => $TagList,
- 'category' => $Categories[$CategoryID-1],
+ 'category' => $Categories[$CategoryID - 1],
'fileCount' => (int) $Data['FileCount'],
'groupTime' => (string) strtotime($Data['Time']),
'size' => (int) $Data['Size'],
diff --git a/sections/ajax/checkprivate.php b/sections/ajax/checkprivate.php
index ef54315..806af49 100644
--- a/sections/ajax/checkprivate.php
+++ b/sections/ajax/checkprivate.php
@@ -11,8 +11,8 @@ if (!is_number($TorrentID)) {
$DB->query("
SELECT File
FROM torrents_files
- WHERE TorrentID='$TorrentID'");
-if ($DB->record_count() == 0) {
+ WHERE TorrentID = '$TorrentID'");
+if (!$DB->has_results()) {
echo('Torrent not found.');
die();
}
diff --git a/sections/ajax/collage.php b/sections/ajax/collage.php
index ff7e83d..946ec3d 100644
--- a/sections/ajax/collage.php
+++ b/sections/ajax/collage.php
@@ -31,7 +31,7 @@ if ($Data) {
WHERE ID = '$CollageID'";
$DB->query($sql);
- if ($DB->record_count() == 0) {
+ if (!$DB->has_results()) {
json_die("failure");
}
diff --git a/sections/ajax/community_stats.php b/sections/ajax/community_stats.php
index 81f5c0e..218b8ea 100644
--- a/sections/ajax/community_stats.php
+++ b/sections/ajax/community_stats.php
@@ -23,11 +23,11 @@ function check_paranoia_here($Setting) {
if (check_paranoia_here('seeding+') || check_paranoia_here('leeching+')) {
$DB->query("
- SELECT IF(remaining=0,'Seeding','Leeching') AS Type, COUNT(x.uid)
+ SELECT IF(remaining = 0, 'Seeding', 'Leeching') AS Type, COUNT(x.uid)
FROM xbt_files_users AS x
- INNER JOIN torrents AS t ON t.ID=x.fid
- WHERE x.uid='$UserID'
- AND x.active=1
+ INNER JOIN torrents AS t ON t.ID = x.fid
+ WHERE x.uid = '$UserID'
+ AND x.active = 1
GROUP BY Type");
$PeerCount = $DB->to_array(0, MYSQLI_NUM, false);
if (check_paranoia('seeding+')) {
@@ -42,7 +42,7 @@ if (check_paranoia_here('snatched+')) {
$DB->query("
SELECT COUNT(x.uid), COUNT(DISTINCT x.fid)
FROM xbt_snatched AS x
- INNER JOIN torrents AS t ON t.ID=x.fid
+ INNER JOIN torrents AS t ON t.ID = x.fid
WHERE x.uid = '$UserID'");
list($Snatched, $UniqueSnatched) = $DB->next_record(MYSQLI_NUM, false);
$CommStats['snatched'] = number_format($Snatched);
@@ -57,8 +57,8 @@ if (check_perms('site_view_torrent_snatchlist', $Class)) {
$DB->query("
SELECT COUNT(ud.UserID), COUNT(DISTINCT ud.TorrentID)
FROM users_downloads AS ud
- JOIN torrents AS t ON t.ID=ud.TorrentID
- WHERE ud.UserID='$UserID'");
+ JOIN torrents AS t ON t.ID = ud.TorrentID
+ WHERE ud.UserID = '$UserID'");
list($NumDownloads, $UniqueDownloads) = $DB->next_record(MYSQLI_NUM, false);
$CommStats['downloaded'] = number_format($NumDownloads);
$CommStats['udownloaded'] = number_format($UniqueDownloads);
diff --git a/sections/ajax/forum/forum.php b/sections/ajax/forum/forum.php
index b93b5fe..6a2ca6e 100644
--- a/sections/ajax/forum/forum.php
+++ b/sections/ajax/forum/forum.php
@@ -89,7 +89,7 @@ foreach ($Forums[$ForumID]['SpecificRules'] as $ThreadIDs) {
$Pages = Format::get_pages($Page, $Forums[$ForumID]['NumTopics'], TOPICS_PER_PAGE, 9);
-if (count($Forum) == 0) {
+if (count($Forum) === 0) {
print
json_encode(
array(
@@ -100,18 +100,18 @@ if (count($Forum) == 0) {
);
} else {
// forums_last_read_topics is a record of the last post a user read in a topic, and what page that was on
- $DB->query('
+ $DB->query("
SELECT
l.TopicID,
l.PostID,
CEIL(( SELECT COUNT(ID)
FROM forums_posts
WHERE forums_posts.TopicID = l.TopicID
- AND forums_posts.ID <= l.PostID) / '.$PerPage.'
+ AND forums_posts.ID <= l.PostID) / $PerPage
) AS Page
FROM forums_last_read_topics AS l
- WHERE TopicID IN('.implode(', ', array_keys($Forum)).')
- AND UserID=\''.$LoggedUser['ID'].'\'');
+ WHERE TopicID IN(".implode(', ', array_keys($Forum)).')
+ AND UserID = \''.$LoggedUser['ID'].'\'');
// Turns the result set into a multi-dimensional array, with
// forums_last_read_topics.TopicID as the key.
diff --git a/sections/ajax/forum/index.php b/sections/ajax/forum/index.php
index 245cdd3..01bd6ef 100644
--- a/sections/ajax/forum/index.php
+++ b/sections/ajax/forum/index.php
@@ -97,7 +97,7 @@ function get_forum_info($ForumID) {
LEFT JOIN forums_topics ON forums_topics.ForumID = forums.ID
WHERE forums.ID = '$ForumID'
GROUP BY ForumID");
- if ($DB->record_count() == 0) {
+ if (!$DB->has_results()) {
return false;
}
// Makes an array, with $Forum['Name'], etc.
diff --git a/sections/ajax/inbox/viewconv.php b/sections/ajax/inbox/viewconv.php
index aaa3073..990e05d 100644
--- a/sections/ajax/inbox/viewconv.php
+++ b/sections/ajax/inbox/viewconv.php
@@ -16,7 +16,7 @@ $DB->query("
FROM pm_conversations_users
WHERE UserID='$UserID'
AND ConvID='$ConvID'");
-if ($DB->record_count() == 0) {
+if (!$DB->has_results()) {
print json_encode(array('status' => 'failure'));
die();
}
diff --git a/sections/ajax/info.php b/sections/ajax/info.php
index efbba28..85e7a15 100644
--- a/sections/ajax/info.php
+++ b/sections/ajax/info.php
@@ -13,8 +13,12 @@ if ($LoggedUser['BytesUploaded'] == 0 && $LoggedUser['BytesDownloaded'] == 0) {
$MyNews = $LoggedUser['LastReadNews'];
$CurrentNews = $Cache->get_value('news_latest_id');
if ($CurrentNews === false) {
- $DB->query("SELECT ID FROM news ORDER BY Time DESC LIMIT 1");
- if ($DB->record_count() == 1) {
+ $DB->query("
+ SELECT ID
+ FROM news
+ ORDER BY Time DESC
+ LIMIT 1");
+ if ($DB->record_count() === 1) {
list($CurrentNews) = $DB->next_record();
} else {
$CurrentNews = -1;
@@ -24,7 +28,12 @@ if ($CurrentNews === false) {
$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'");
+ $DB->query("
+ SELECT COUNT(UnRead)
+ FROM pm_conversations_users
+ WHERE UserID = '" . $LoggedUser['ID'] . "'
+ AND UnRead = '1'
+ AND InInbox = '1'");
list($NewMessages) = $DB->next_record();
$Cache->cache_value('inbox_new_' . $LoggedUser['ID'], $NewMessages, 0);
}
@@ -32,7 +41,11 @@ if ($NewMessages === false) {
if (check_perms('site_torrents_notify')) {
$NewNotifications = $Cache->get_value('notifications_new_' . $LoggedUser['ID']);
if ($NewNotifications === false) {
- $DB->query("SELECT COUNT(UserID) FROM users_notify_torrents WHERE UserID='$LoggedUser[ID]' AND UnRead='1'");
+ $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')) {
$DB->query("DELETE FROM users_notify_torrents WHERE UserID='$LoggedUser[ID]'");
@@ -46,8 +59,12 @@ if (check_perms('site_torrents_notify')) {
$MyNews = $LoggedUser['LastReadNews'];
$CurrentNews = $Cache->get_value('news_latest_id');
if ($CurrentNews === false) {
- $DB->query("SELECT ID FROM news ORDER BY Time DESC LIMIT 1");
- if ($DB->record_count() == 1) {
+ $DB->query("
+ SELECT ID
+ FROM news
+ ORDER BY Time DESC
+ LIMIT 1");
+ if ($DB->record_count() === 1) {
list($CurrentNews) = $DB->next_record();
} else {
$CurrentNews = -1;
@@ -59,8 +76,13 @@ if ($CurrentNews === false) {
$MyBlog = $LoggedUser['LastReadBlog'];
$CurrentBlog = $Cache->get_value('blog_latest_id');
if ($CurrentBlog === false) {
- $DB->query("SELECT ID FROM blog WHERE Important = 1 ORDER BY Time DESC LIMIT 1");
- if ($DB->record_count() == 1) {
+ $DB->query("
+ SELECT ID
+ FROM blog
+ WHERE Important = 1
+ ORDER BY Time DESC
+ LIMIT 1");
+ if ($DB->record_count() === 1) {
list($CurrentBlog) = $DB->next_record();
} else {
$CurrentBlog = -1;
diff --git a/sections/ajax/password_validate.php b/sections/ajax/password_validate.php
index 2f6fb6c..c8b204d 100644
--- a/sections/ajax/password_validate.php
+++ b/sections/ajax/password_validate.php
@@ -7,7 +7,7 @@ $DB->query("
FROM bad_passwords
WHERE Password='$Password'");
-if ($DB->record_count() == 0) {
+if (!$DB->has_results()) {
$IsGoodPassword = true;
}
diff --git a/sections/ajax/requests.php b/sections/ajax/requests.php
index d7366a0..d5eee48 100644
--- a/sections/ajax/requests.php
+++ b/sections/ajax/requests.php
@@ -110,7 +110,7 @@ if (empty($_GET['tags_type']) && !empty($Tags)) {
if (!empty($_GET['filter_cat'])) {
$CategoryArray = array_keys($_GET['filter_cat']);
- if (count($CategoryArray) != count($Categories)) {
+ if (count($CategoryArray) !== count($Categories)) {
foreach ($CategoryArray as $Key => $Index) {
if (!isset($Categories[$Index - 1])) {
unset($CategoryArray[$Key]);
@@ -124,7 +124,7 @@ if (!empty($_GET['filter_cat'])) {
if (!empty($_GET['releases'])) {
$ReleaseArray = $_GET['releases'];
- if (count($ReleaseArray) != count($ReleaseTypes)) {
+ if (count($ReleaseArray) !== count($ReleaseTypes)) {
foreach ($ReleaseArray as $Index => $Value) {
if (!isset($ReleaseTypes[$Value])) {
unset($ReleaseArray[$Index]);
@@ -139,7 +139,7 @@ if (!empty($_GET['releases'])) {
if (!empty($_GET['formats'])) {
$FormatArray = $_GET['formats'];
- if (count($FormatArray) != count($Formats)) {
+ if (count($FormatArray) !== count($Formats)) {
$FormatNameArray = array();
foreach ($FormatArray as $Index => $MasterIndex) {
if (isset($Formats[$MasterIndex])) {
@@ -155,7 +155,7 @@ if (!empty($_GET['formats'])) {
if (!empty($_GET['media'])) {
$MediaArray = $_GET['media'];
- if (count($MediaArray) != count($Media)) {
+ if (count($MediaArray) !== count($Media)) {
$MediaNameArray = array();
foreach ($MediaArray as $Index => $MasterIndex) {
if (isset($Media[$MasterIndex])) {
@@ -171,7 +171,7 @@ if (!empty($_GET['media'])) {
if (!empty($_GET['bitrates'])) {
$BitrateArray = $_GET['bitrates'];
- if (count($BitrateArray) != count($Bitrates)) {
+ if (count($BitrateArray) !== count($Bitrates)) {
$BitrateNameArray = array();
foreach ($BitrateArray as $Index => $MasterIndex) {
if (isset($Bitrates[$MasterIndex])) {
@@ -230,25 +230,25 @@ if (empty($_GET['order'])) {
}
switch ($CurrentOrder) {
- case 'votes' :
+ case 'votes':
$OrderBy = 'Votes';
break;
- case 'bounty' :
+ case 'bounty':
$OrderBy = 'Bounty';
break;
- case 'created' :
+ case 'created':
$OrderBy = 'TimeAdded';
break;
- case 'lastvote' :
+ case 'lastvote':
$OrderBy = 'LastVote';
break;
- case 'filled' :
+ case 'filled':
$OrderBy = 'TimeFilled';
break;
- case 'year' :
+ case 'year':
$OrderBy = 'Year';
break;
- default :
+ default:
$OrderBy = 'TimeAdded';
break;
}
@@ -256,7 +256,7 @@ switch ($CurrentOrder) {
$SS->SetSortMode($Way, $OrderBy);
if (count($Queries) > 0) {
- $Query = implode(' ',$Queries);
+ $Query = implode(' ', $Queries);
} else {
$Query = '';
}
diff --git a/sections/ajax/send_recommendation.php b/sections/ajax/send_recommendation.php
index 7687db1..649ca43 100644
--- a/sections/ajax/send_recommendation.php
+++ b/sections/ajax/send_recommendation.php
@@ -21,7 +21,7 @@ $DB->query("
WHERE f.UserID = '$LoggedUser[ID]'
AND f.FriendID = '$FriendID'");
-if ($DB->record_count() == 0) {
+if (!$DB->has_results()) {
echo json_encode(array("status" => "error", "response" => "Not on friend list."));
die();
}
diff --git a/sections/ajax/user.php b/sections/ajax/user.php
index 801dd2a..328d182 100644
--- a/sections/ajax/user.php
+++ b/sections/ajax/user.php
@@ -50,7 +50,7 @@ $DB->query("
WHERE m.ID = $UserID
GROUP BY AuthorID");
-if ($DB->record_count() == 0) { // If user doesn't exist
+if (!$DB->has_results()) { // If user doesn't exist
json_die("failure", "no such user");
}
@@ -83,7 +83,7 @@ $DB->query("
FROM friends
WHERE UserID = '$LoggedUser[ID]'
AND FriendID = '$UserID'");
-if ($DB->record_count() != 0) {
+if ($DB->has_results()) {
$Friend = true;
}
diff --git a/sections/artist/add_alias.php b/sections/artist/add_alias.php
index 00ece71..d4c8ad8 100644
--- a/sections/artist/add_alias.php
+++ b/sections/artist/add_alias.php
@@ -32,7 +32,7 @@ $DB->query("
SELECT AliasID, ArtistID, Name, Redirect
FROM artists_alias
WHERE Name = '".$DBAliasName."'");
-if ($DB->record_count()) {
+if ($DB->has_results()) {
while (list($CloneAliasID, $CloneArtistID, $CloneAliasName, $CloneRedirect) = $DB->next_record(MYSQLI_NUM, false)) {
if (!strcasecmp($CloneAliasName, $AliasName)) {
break;
@@ -57,7 +57,7 @@ if ($DB->record_count()) {
if (!$CloneAliasID) {
if ($Redirect) {
$DB->query("SELECT ArtistID, Redirect FROM artists_alias WHERE AliasID = $Redirect");
- if (!$DB->record_count()) {
+ if (!$DB->has_results()) {
error('Cannot redirect to a nonexistent artist alias.');
}
list($FoundArtistID, $FoundRedirect) = $DB->next_record();
diff --git a/sections/artist/add_similar.php b/sections/artist/add_similar.php
index 65b3219..ee2f02c 100644
--- a/sections/artist/add_similar.php
+++ b/sections/artist/add_similar.php
@@ -36,7 +36,7 @@ if (!empty($Artist2ID)) { // artist was found in the database
}
$DB->query("SELECT SimilarID FROM artists_similar_votes WHERE SimilarID='$SimilarID' AND UserID='$UserID' AND Way='up'");
- if ($DB->record_count() == 0) {
+ if (!$DB->has_results()) {
$DB->query("INSERT INTO artists_similar_votes (SimilarID, UserID, way) VALUES ('$SimilarID', '$UserID', 'up')");
}
diff --git a/sections/artist/artist.php b/sections/artist/artist.php
index 1cf8520..2bc6c9d 100644
--- a/sections/artist/artist.php
+++ b/sections/artist/artist.php
@@ -59,7 +59,7 @@ if ($Data) {
GROUP BY a.ArtistID";
$DB->query($sql);
- if ($DB->record_count() == 0) {
+ if (!$DB->has_results()) {
error(404);
}
@@ -93,7 +93,7 @@ if (empty($LoggedUser['DisableRequests'])) {
GROUP BY r.ID
ORDER BY Votes DESC");
- if ($DB->record_count() > 0) {
+ if ($DB->has_results()) {
$Requests = $DB->to_array();
} else {
$Requests = array();
@@ -553,10 +553,10 @@ if (check_perms('site_torrents_notify')) {
if (check_perms('zip_downloader')) {
if (isset($LoggedUser['Collector'])) {
- list($ZIPList,$ZIPPrefs) = $LoggedUser['Collector'];
- $ZIPList = explode(':',$ZIPList);
+ list($ZIPList, $ZIPPrefs) = $LoggedUser['Collector'];
+ $ZIPList = explode(':', $ZIPList);
} else {
- $ZIPList = array('00','11');
+ $ZIPList = array('00', '11');
$ZIPPrefs = 1;
}
?>
@@ -572,7 +572,7 @@ if (check_perms('zip_downloader')) {
<li id="list<?=$ListItem?>">
<input type="hidden" name="list[]" value="<?=$ListItem?>" />
<span style="float: left;"><?=$ZIPOptions[$ListItem]['2']?></span>
- <span class="remove remove_collector"><a href="#" onclick="remove_selection('<?=$ListItem?>');return false;" style="float: right;" class="brackets" title="Remove format from the Collector">X</a></span>
+ <span class="remove remove_collector"><a href="#" onclick="remove_selection('<?=$ListItem?>'); return false;" style="float: right;" class="brackets" title="Remove format from the Collector">X</a></span>
<br style="clear: all;" />
</li>
<? } ?>
@@ -583,7 +583,7 @@ $OpenGroup = false;
$LastGroupID = -1;
foreach ($ZIPOptions as $Option) {
- list($GroupID,$OptionID,$OptName) = $Option;
+ list($GroupID, $OptionID, $OptName) = $Option;
if ($GroupID != $LastGroupID) {
$LastGroupID = $GroupID;
diff --git a/sections/artist/delete.php b/sections/artist/delete.php
index 4d75a37..7677edb 100644
--- a/sections/artist/delete.php
+++ b/sections/artist/delete.php
@@ -20,16 +20,19 @@ if (!check_perms('site_delete_artist') || !check_perms('torrents_delete')) {
View::show_header('Artist deleted');
-$DB->query('SELECT Name FROM artists_group WHERE ArtistID='.$ArtistID);
+$DB->query("
+ SELECT Name
+ FROM artists_group
+ WHERE ArtistID = $ArtistID");
list($Name) = $DB->next_record();
-$DB->query('
+$DB->query("
SELECT tg.Name, tg.ID
FROM torrents_group AS tg
- LEFT JOIN torrents_artists AS ta ON ta.GroupID=tg.ID
- WHERE ta.ArtistID='.$ArtistID);
+ LEFT JOIN torrents_artists AS ta ON ta.GroupID = tg.ID
+ WHERE ta.ArtistID = $ArtistID");
$Count = $DB->record_count();
-if ($DB->record_count() > 0) {
+if ($DB->has_results()) {
?>
<div class="thin">
There are still torrents that have <a href="artist.php?id=<?=$ArtistID?>" title="View Artist"><?=$Name?></a> as an artist.<br />
@@ -51,13 +54,13 @@ if ($DB->record_count() > 0) {
<?
}
-$DB->query('
+$DB->query("
SELECT r.Title, r.ID
FROM requests AS r
- LEFT JOIN requests_artists AS ra ON ra.RequestID=r.ID
- WHERE ra.ArtistID='.$ArtistID);
+ LEFT JOIN requests_artists AS ra ON ra.RequestID = r.ID
+ WHERE ra.ArtistID = $ArtistID");
$Count += $DB->record_count();
-if ($DB->record_count() > 0) {
+if ($DB->has_results()) {
?>
<div class="thin">
There are still requests that have <a href="artist.php?id=<?=$ArtistID?>" title="View Artist"><?=$Name?></a> as an artist.<br />
diff --git a/sections/artist/delete_alias.php b/sections/artist/delete_alias.php
index bfa6836..0237e6e 100644
--- a/sections/artist/delete_alias.php
+++ b/sections/artist/delete_alias.php
@@ -16,7 +16,7 @@ $DB->query("
JOIN artists_alias AS aa2 ON aa.ArtistID=aa2.ArtistID
WHERE aa.AliasID=".$AliasID);
-if ($DB->record_count() == 1) {
+if ($DB->record_count() === 1) {
//This is the last alias on the artist
error("That alias is the last alias for that artist; removing it would cause bad things to happen.");
}
@@ -25,7 +25,7 @@ $DB->query("
SELECT GroupID
FROM torrents_artists
WHERE AliasID='$AliasID'");
-if ($DB->record_count() > 0) {
+if ($DB->has_results()) {
list($GroupID) = $DB->next_record();
if ($GroupID != 0) {
error("That alias still has the group (<a href=\"torrents.php?id=$GroupID\">$GroupID</a>) attached. Fix that first.");
diff --git a/sections/artist/delete_similar.php b/sections/artist/delete_similar.php
index 6ff285b..1382916 100644
--- a/sections/artist/delete_similar.php
+++ b/sections/artist/delete_similar.php
@@ -1,4 +1,4 @@
-<?
+<?php
authorize();
$SimilarID = db_string($_GET['similarid']);
@@ -8,16 +8,25 @@ if (!is_number($SimilarID) || !$SimilarID) {
if (!check_perms('site_delete_tag')) {
error(403);
}
-$DB->query("SELECT ArtistID FROM artists_similar WHERE SimilarID='$SimilarID'");
+$DB->query("
+ SELECT ArtistID
+ FROM artists_similar
+ WHERE SimilarID = '$SimilarID'");
$ArtistIDs = $DB->to_array();
-$DB->query("DELETE FROM artists_similar WHERE SimilarID='$SimilarID'");
-$DB->query("DELETE FROM artists_similar_scores WHERE SimilarID='$SimilarID'");
-$DB->query("DELETE FROM artists_similar_votes WHERE SimilarID='$SimilarID'");
+$DB->query("
+ DELETE FROM artists_similar
+ WHERE SimilarID = '$SimilarID'");
+$DB->query("
+ DELETE FROM artists_similar_scores
+ WHERE SimilarID = '$SimilarID'");
+$DB->query("
+ DELETE FROM artists_similar_votes
+ WHERE SimilarID = '$SimilarID'");
foreach ($ArtistIDs as $ArtistID) {
list($ArtistID) = $ArtistID;
- $Cache->delete_value('artist_'.$ArtistID); // Delete artist cache
- $Cache->delete_value('similar_positions_'.$ArtistID);
+ $Cache->delete_value("artist_$ArtistID"); // Delete artist cache
+ $Cache->delete_value("similar_positions_$ArtistID");
}
header('Location: '.$_SERVER['HTTP_REFERER']);
?>
diff --git a/sections/artist/download.php b/sections/artist/download.php
index f48a7de..f3599ad 100644
--- a/sections/artist/download.php
+++ b/sections/artist/download.php
@@ -70,7 +70,7 @@ $DB->query("SELECT Name FROM artists_group WHERE ArtistID='$ArtistID'");
list($ArtistName) = $DB->next_record(MYSQLI_NUM, false);
$DB->query("SELECT GroupID, Importance FROM torrents_artists WHERE ArtistID='$ArtistID'");
-if ($DB->record_count() == 0) {
+if (!$DB->has_results()) {
error(404);
}
$Releases = $DB->to_array('GroupID', MYSQLI_ASSOC, false);
diff --git a/sections/artist/edit.php b/sections/artist/edit.php
index be41201..40cb0bd 100644
--- a/sections/artist/edit.php
+++ b/sections/artist/edit.php
@@ -26,7 +26,7 @@ $DB->query("
LEFT JOIN wiki_artists ON wiki_artists.RevisionID = a.RevisionID
WHERE a.ArtistID = '$ArtistID'");
-if ($DB->record_count() < 1) {
+if (!$DB->has_results()) {
error("Cannot find an artist with the ID {$ArtistID}: See the <a href=\"log.php?search=Artist+$ArtistID\">site log</a>.");
}
diff --git a/sections/artist/index.php b/sections/artist/index.php
index 2e0fd45..0630b2b 100644
--- a/sections/artist/index.php
+++ b/sections/artist/index.php
@@ -52,20 +52,22 @@ if (!empty($_POST['action'])) {
$DB->query("
SELECT
CEIL((
- SELECT COUNT(ID)+1
+ SELECT COUNT(ID) + 1
FROM artist_comments AS ac
- WHERE ac.ArtistID='" . db_string($ArtistID) . "'
- )/" . TORRENT_COMMENTS_PER_PAGE . "
+ WHERE ac.ArtistID = '" . db_string($ArtistID) . "'
+ ) / " . TORRENT_COMMENTS_PER_PAGE . "
) AS Pages");
list($Pages) = $DB->next_record();
$DB->query("
- INSERT INTO artist_comments (ArtistID,AuthorID,AddedTime,Body)
- VALUES ('" . db_string($ArtistID) . "', '" . db_string($LoggedUser['ID']) . "','" . sqltime() . "','" . db_string($_POST['body']) . "')");
+ INSERT INTO artist_comments
+ (ArtistID, AuthorID, AddedTime, Body)
+ VALUES
+ ('" . db_string($ArtistID) . "', '" . 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('artist_comments_' . $ArtistID . '_catalogue_' . $CatalogueID);
+ $Cache->begin_transaction("artist_comments_$ArtistID" . "_catalogue_$CatalogueID");
$Post = array(
'ID' => $PostID,
'AuthorID' => $LoggedUser['ID'],
@@ -77,9 +79,9 @@ if (!empty($_POST['action'])) {
);
$Cache->insert('', $Post);
$Cache->commit_transaction(0);
- $Cache->increment('artist_comments_' . $ArtistID);
+ $Cache->increment("artist_comments_$ArtistID");
- header('Location: artist.php?id=' . $ArtistID . '&page=' . $Pages);
+ header("Location: artist.php?id=$ArtistID&page=$Pages");
break;
case 'warn' :
include(SERVER_ROOT . '/sections/artist/warn.php');
@@ -105,7 +107,10 @@ if (!empty($_POST['action'])) {
if (!$_GET['post'] || !is_number($_GET['post'])) {
error(0);
}
- $DB->query("SELECT Body FROM artist_comments WHERE ID='" . db_string($_GET['post']) . "'");
+ $DB->query("
+ SELECT Body
+ FROM artist_comments
+ WHERE ID = '" . db_string($_GET['post']) . "'");
list($Body) = $DB->next_record(MYSQLI_NUM);
echo trim($Body);
break;
@@ -124,35 +129,37 @@ if (!empty($_POST['action'])) {
}
// Get topicid, forumid, number of pages
- $DB->query("
+ $DB->query('
SELECT
ArtistID,
- CEIL(COUNT(ac.ID)/" . TORRENT_COMMENTS_PER_PAGE . ") AS Pages,
- CEIL(SUM(IF(ac.ID<=" . $_GET['postid'] . ",1,0))/" . TORRENT_COMMENTS_PER_PAGE . ") AS Page
+ CEIL(COUNT(ac.ID) / ' . TORRENT_COMMENTS_PER_PAGE . ') AS Pages,
+ CEIL(SUM(IF(ac.ID <= ' . $_GET['postid'] . ', 1, 0)) / ' . TORRENT_COMMENTS_PER_PAGE . ') AS Page
FROM artist_comments AS ac
- WHERE ac.ArtistID=(
+ WHERE ac.ArtistID = (
SELECT ArtistID
FROM artist_comments
- WHERE ID=" . $_GET['postid'] . "
+ WHERE ID = ' . $_GET['postid'] . '
)
- GROUP BY ac.ArtistID");
+ GROUP BY ac.ArtistID');
list($ArtistID, $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 artist_comments WHERE ID='" . db_string($_GET['postid']) . "'");
+ $DB->query("
+ DELETE FROM artist_comments
+ WHERE ID = '" . db_string($_GET['postid']) . "'");
//We need to clear all subsequential catalogues as they've all been bumped with the absence of this post
$ThisCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
$LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $Pages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
for ($i = $ThisCatalogue; $i <= $LastCatalogue; $i++) {
- $Cache->delete_value('artist_comments_' . $ArtistID . '_catalogue_' . $i);
+ $Cache->delete_value("artist_comments_$ArtistID" . "_catalogue_$i");
}
// Delete thread info cache (eg. number of pages)
- $Cache->delete_value('artist_comments_' . $ArtistID);
+ $Cache->delete_value("artist_comments_$ArtistID");
break;
@@ -175,7 +182,7 @@ if (!empty($_POST['action'])) {
ac.ArtistID,
ac.AddedTime
FROM artist_comments AS ac
- WHERE ac.ID='" . db_string($_POST['post']) . "'");
+ WHERE ac.ID = '" . db_string($_POST['post']) . "'");
list($OldBody, $AuthorID, $ArtistID, $AddedTime) = $DB->next_record();
$DB->query("
@@ -188,7 +195,7 @@ if (!empty($_POST['action'])) {
if ($LoggedUser['ID'] != $AuthorID && !check_perms('site_moderate_forums')) {
error(404);
}
- if ($DB->record_count() == 0) {
+ if (!$DB->has_results()) {
error(404);
}
@@ -199,11 +206,11 @@ if (!empty($_POST['action'])) {
Body = '" . db_string($_POST['body']) . "',
EditedUserID = '" . db_string($LoggedUser['ID']) . "',
EditedTime = '" . sqltime() . "'
- WHERE ID='" . db_string($_POST['post']) . "'");
+ WHERE ID = '" . db_string($_POST['post']) . "'");
// Update the cache
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
- $Cache->begin_transaction('artist_comments_' . $ArtistID . '_catalogue_' . $CatalogueID);
+ $Cache->begin_transaction("artist_comments_$ArtistID" . "_catalogue_$CatalogueID");
$Cache->update_row($_POST['key'], array(
'ID' => $_POST['post'],
@@ -217,8 +224,10 @@ if (!empty($_POST['action'])) {
$Cache->commit_transaction(0);
$DB->query("
- INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)
- VALUES ('artist', " . db_string($_POST['post']) . ", " . db_string($LoggedUser['ID']) . ", '" . sqltime() . "', '" . db_string($OldBody) . "')");
+ INSERT INTO comments_edits
+ (Page, PostID, EditUser, EditTime, Body)
+ VALUES
+ ('artist', " . 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']);
@@ -275,7 +284,7 @@ if (!empty($_POST['action'])) {
SELECT ArtistID, Name
FROM artists_alias
WHERE Name LIKE '" . db_string($NameSearch) . "'");
- if ($DB->record_count() == 0) {
+ if (!$DB->has_results()) {
if (isset($LoggedUser['SearchType']) && $LoggedUser['SearchType']) {
header('Location: torrents.php?action=advanced&artistname=' . urlencode($_GET['artistname']));
} else {
@@ -284,17 +293,17 @@ if (!empty($_POST['action'])) {
die();
}
list($FirstID, $Name) = $DB->next_record(MYSQLI_NUM, false);
- if ($DB->record_count() == 1 || !strcasecmp($Name, $NameSearch)) {
- header('Location: artist.php?id=' . $FirstID);
+ if ($DB->record_count() === 1 || !strcasecmp($Name, $NameSearch)) {
+ header("Location: artist.php?id=$FirstID");
die();
}
while (list($ID, $Name) = $DB->next_record(MYSQLI_NUM, false)) {
if (!strcasecmp($Name, $NameSearch)) {
- header('Location: artist.php?id=' . $ID);
+ header("Location: artist.php?id=$ID");
die();
}
}
- header('Location: artist.php?id=' . $FirstID);
+ header("Location: artist.php?id=$FirstID");
die();
} else {
header('Location: torrents.php');
diff --git a/sections/artist/notify.php b/sections/artist/notify.php
index a6fe2eb..448c4d9 100644
--- a/sections/artist/notify.php
+++ b/sections/artist/notify.php
@@ -21,31 +21,33 @@ if (empty($Notify)) {
$DB->query("
SELECT ID, Artists
FROM users_notify_filters
- WHERE Label='Artist notifications'
- AND UserID='$LoggedUser[ID]'
+ WHERE Label = 'Artist notifications'
+ AND UserID = '$LoggedUser[ID]'
ORDER BY ID
LIMIT 1");
} else {
$DB->query("
SELECT ID, Artists
FROM users_notify_filters
- WHERE ID='$Notify[ID]'");
+ WHERE ID = '$Notify[ID]'");
}
-if (empty($Notify) && $DB->record_count() == 0) {
+if (empty($Notify) && !$DB->has_results()) {
$DB->query("
- INSERT INTO users_notify_filters (UserID, Label, Artists)
- VALUES ('$LoggedUser[ID]', 'Artist notifications', '|".db_string($ArtistAliases)."|')");
+ INSERT INTO users_notify_filters
+ (UserID, Label, Artists)
+ VALUES
+ ('$LoggedUser[ID]', 'Artist notifications', '|".db_string($ArtistAliases)."|')");
$FilterID = $DB->inserted_id();
$Cache->delete_value('notify_filters_'.$LoggedUser['ID']);
$Cache->delete_value('notify_artists_'.$LoggedUser['ID']);
} else {
list($ID, $ArtistNames) = $DB->next_record(MYSQLI_NUM, FALSE);
- if (stripos($ArtistNames,$ArtistAliases) === false) {
- $ArtistNames.=$ArtistAliases.'|';
+ if (stripos($ArtistNames, $ArtistAliases) === false) {
+ $ArtistNames .= "$ArtistAliases|";
$DB->query("
UPDATE users_notify_filters
- SET Artists='".db_string($ArtistNames)."'
- WHERE ID='$ID'");
+ SET Artists = '".db_string($ArtistNames)."'
+ WHERE ID = '$ID'");
$Cache->delete_value('notify_filters_'.$LoggedUser['ID']);
$Cache->delete_value('notify_artists_'.$LoggedUser['ID']);
}
diff --git a/sections/artist/rename.php b/sections/artist/rename.php
index ca3d4f7..0a252c4 100644
--- a/sections/artist/rename.php
+++ b/sections/artist/rename.php
@@ -34,7 +34,7 @@ if (!check_perms('torrents_edit')) {
}
$DB->query("SELECT Name FROM artists_group WHERE ArtistID='$ArtistID'");
-if ($DB->record_count() == 0) {
+if (!$DB->has_results()) {
error(404);
}
list($OldName) = $DB->next_record(MYSQLI_NUM, false);
diff --git a/sections/artist/take_warn.php b/sections/artist/take_warn.php
index 6f6aa98..041011b 100644
--- a/sections/artist/take_warn.php
+++ b/sections/artist/take_warn.php
@@ -20,16 +20,16 @@ if ($UserInfo['Class'] > $LoggedUser['Class']) {
$URL = "https://". SSL_SITE_URL."/artist.php?id=$ArtistID&postid=$PostID#post$PostID";
if ($Length != 'verbal') {
$Time = ((int)$Length) * (7 * 24 * 60 * 60);
- Tools::warn_user($UserID, $Time, "$URL - ". $Reason);
+ Tools::warn_user($UserID, $Time, "$URL - $Reason");
$Subject = 'You have received a warning';
- $PrivateMessage = "You have received a $Length week warning for [url=$URL]this artist comment.[/url]\n\n" . $PrivateMessage;
+ $PrivateMessage = "You have received a $Length week warning for [url=$URL]this artist comment.[/url]\n\n$PrivateMessage";
$WarnTime = time_plus($Time);
- $AdminComment = date('Y-m-d').' - Warned until '.$WarnTime.' by '.$LoggedUser['Username']."\nReason: $URL - $Reason\n\n";
+ $AdminComment = date('Y-m-d') . " - Warned until $WarnTime by " . $LoggedUser['Username'] . "\nReason: $URL - $Reason\n\n";
} else {
$Subject = 'You have received a verbal warning';
- $PrivateMessage = "You have received a verbal warning for [url=$URL]this post.[/url]\n\n" . $PrivateMessage;
+ $PrivateMessage = "You have received a verbal warning for [url=$URL]this post.[/url]\n\n$PrivateMessage";
$AdminComment = date('Y-m-d') . ' - Verbally warned by ' . $LoggedUser['Username'] . " for $URL \nReason: $Reason\n\n";
- Tools::update_user_notes($UserID,$AdminComment);
+ Tools::update_user_notes($UserID, $AdminComment);
}
$DB->query("
INSERT INTO users_warnings_forums (UserID, Comment)
@@ -45,7 +45,7 @@ $DB->query("
ac.ArtistID,
ac.AddedTime
FROM artist_comments AS ac
- WHERE ac.ID='$PostID'");
+ WHERE ac.ID = '$PostID'");
list($OldBody, $AuthorID, $ArtistID, $AddedTime) = $DB->next_record();
$DB->query("
@@ -62,11 +62,11 @@ $DB->query("
Body = '" . db_string($Body) . "',
EditedUserID = '" . db_string($LoggedUser['ID']) . "',
EditedTime = '" . sqltime() . "'
- WHERE ID='$PostID'");
+ WHERE ID = '$PostID'");
// Update the cache
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
-$Cache->begin_transaction('artist_comments_' . $ArtistID . '_catalogue_' . $CatalogueID);
+$Cache->begin_transaction("artist_comments_$ArtistID" . "_catalogue_$CatalogueID");
$Cache->update_row($_POST['key'], array('ID' => $_POST['postid'], 'AuthorID' => $AuthorID, 'AddedTime' => $AddedTime, 'Body' => $Body, 'EditedUserID' => db_string($LoggedUser['ID']), 'EditedTime' => sqltime(), 'Username' => $LoggedUser['Username']));
$Cache->commit_transaction(0);
diff --git a/sections/artist/vote_similar.php b/sections/artist/vote_similar.php
index c64d0a2..6a9642e 100644
--- a/sections/artist/vote_similar.php
+++ b/sections/artist/vote_similar.php
@@ -17,7 +17,7 @@ $DB->query("
WHERE SimilarID='$SimilarID'
AND UserID='$UserID'
AND Way='$Way'");
-if ($DB->record_count() == 0) {
+if (!$DB->has_results()) {
if ($Way == 'down') {
$Score = 'Score-100';
} elseif ($Way == 'up') {
diff --git a/sections/better/files.php b/sections/better/files.php
index b673d48..03978ad 100644
--- a/sections/better/files.php
+++ b/sections/better/files.php
@@ -1,10 +1,15 @@
<?php
if (check_perms('admin_reports') && !empty($_GET['remove']) && is_number($_GET['remove'])) {
- $DB->query("DELETE FROM torrents_bad_files WHERE TorrentID = ".$_GET['remove']);
- $DB->query("SELECT GroupID FROM torrents WHERE ID = ".$_GET['remove']);
+ $DB->query('
+ DELETE FROM torrents_bad_files
+ WHERE TorrentID = '.$_GET['remove']);
+ $DB->query('
+ SELECT GroupID
+ FROM torrents
+ WHERE ID = '.$_GET['remove']);
list($GroupID) = $DB->next_record();
- $Cache->delete_value('torrents_details_'.$GroupID);
+ $Cache->delete_value("torrents_details_$GroupID");
}
@@ -12,7 +17,7 @@ if (!empty($_GET['filter']) && $_GET['filter'] == 'all') {
$Join = '';
$All = true;
} else {
- $Join = "JOIN xbt_snatched as x ON x.fid=tfi.TorrentID AND x.uid = ".$LoggedUser['ID'];
+ $Join = 'JOIN xbt_snatched as x ON x.fid = tfi.TorrentID AND x.uid = '.$LoggedUser['ID'];
$All = false;
}
@@ -61,17 +66,17 @@ foreach ($TorrentsInfo as $TorrentID => $Info) {
} else {
$DisplayName = '';
}
- $DisplayName.='<a href="torrents.php?id='.$GroupID.'" title="View Torrent">'.$GroupName.'</a>';
+ $DisplayName .= "<a href=\"torrents.php?id=$GroupID\" title=\"View Torrent\">$GroupName</a>";
if ($GroupYear > 0) {
- $DisplayName.=" [$GroupYear]";
+ $DisplayName .= " [$GroupYear]";
}
if ($ReleaseType > 0) {
- $DisplayName.=' ['.$ReleaseTypes[$ReleaseType].']';
+ $DisplayName .= ' ['.$ReleaseTypes[$ReleaseType].']';
}
$ExtraInfo = Torrents::torrent_info($Torrents[$TorrentID]);
if ($ExtraInfo) {
- $DisplayName.=' - '.$ExtraInfo;
+ $DisplayName .= " - $ExtraInfo";
}
?>
<tr class="torrent torrent_row<?=$GroupFlags['IsSnatched'] ? ' snatched_torrent"' : ''?>">
@@ -86,7 +91,8 @@ foreach ($TorrentsInfo as $TorrentID => $Info) {
<div class="tags"><?=$TorrentTags->format()?></div>
</td>
</tr>
-<? } ?>
+<?
+} ?>
</table>
</div>
<?
diff --git a/sections/better/snatch.php b/sections/better/snatch.php
index 539ca9a..66a5a09 100644
--- a/sections/better/snatch.php
+++ b/sections/better/snatch.php
@@ -22,13 +22,13 @@ if (!empty($_GET['filter']) && $_GET['filter'] == 'seeding') {
$DB->query("
SELECT t.GroupID, x.fid
FROM ".($SeedingOnly ? 'xbt_files_users' : 'xbt_snatched')." AS x
- JOIN torrents AS t ON t.ID=x.fid
+ JOIN torrents AS t ON t.ID = x.fid
JOIN torrents_group AS tg ON tg.ID = t.GroupID
- WHERE t.Format='FLAC'
+ WHERE t.Format = 'FLAC'
AND ((t.LogScore = '100' AND t.Media = 'CD')
OR t.Media != 'CD')
AND tg.CategoryID = 1
- AND x.uid='$UserID'" .
+ AND x.uid = '$UserID'" .
($SeedingOnly ? ' AND x.active = 1 AND x.remaining = 0' : ''));
$SnatchedTorrentIDs = array_fill_keys($DB->collect('fid'), true);
@@ -57,8 +57,10 @@ $DB->query("
AND t.Format IN ('FLAC', 'MP3')
GROUP BY t.GroupID, RemIdent");
-//$DB->query('SELECT * FROM t');
-
+/*$DB->query('
+ SELECT *
+ FROM t');
+*/
$DB->query("
SELECT GroupID
FROM temp_sections_better_snatch
@@ -131,7 +133,7 @@ foreach ($TorrentGroups as $Editions) {
foreach ($Encodings as $Encoding) {
if (!isset($Edition['Formats'][$Encoding])) {
++$edition_miss;
- ++$Counter['miss_'.$Encoding];
+ ++$Counter["miss_$Encoding"];
}
}
$Counter['miss_total'] += $edition_miss;
@@ -194,7 +196,7 @@ foreach ($TorrentGroups as $GroupID => $Editions) {
$DisplayName .= " [$GroupYear]";
}
if ($ReleaseType > 0) {
- $DisplayName .= " [".$ReleaseTypes[$ReleaseType]."]";
+ $DisplayName .= ' ['.$ReleaseTypes[$ReleaseType].']';
}
$DisplayName .= ' ['.$Edition['Medium'].']';
diff --git a/sections/blog/index.php b/sections/blog/index.php
index 47258d0..4d68de5 100644
--- a/sections/blog/index.php
+++ b/sections/blog/index.php
@@ -64,7 +64,7 @@ if (check_perms('admin_manage_blog')) {
SELECT ForumID
FROM forums_topics
WHERE ID = $ThreadID");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
error('No such thread exists!');
header('Location: blog.php');
}
@@ -135,7 +135,8 @@ if (check_perms('admin_manage_blog')) {
<div class="thin">
<?
if (!$Blog = $Cache->get_value('blog')) {
- $DB->query("SELECT
+ $DB->query("
+ SELECT
b.ID,
um.Username,
b.Title,
@@ -143,18 +144,21 @@ if (!$Blog = $Cache->get_value('blog')) {
b.Time,
b.ThreadID
FROM blog AS b
- LEFT JOIN users_main AS um ON b.UserID=um.ID
+ LEFT JOIN users_main AS um ON b.UserID = um.ID
ORDER BY Time DESC
LIMIT 20");
$Blog = $DB->to_array();
- $Cache->cache_value('Blog',$Blog,1209600);
+ $Cache->cache_value('Blog', $Blog, 1209600);
}
if ($LoggedUser['LastReadBlog'] < $Blog[0][0]) {
$Cache->begin_transaction('user_info_heavy_'.$LoggedUser['ID']);
$Cache->update_row(false, array('LastReadBlog' => $Blog[0][0]));
$Cache->commit_transaction(0);
- $DB->query("UPDATE users_info SET LastReadBlog = '".$Blog[0][0]."' WHERE UserID = ".$LoggedUser['ID']);
+ $DB->query("
+ UPDATE users_info
+ SET LastReadBlog = '".$Blog[0][0]."'
+ WHERE UserID = ".$LoggedUser['ID']);
$LoggedUser['LastReadBlog'] = $Blog[0][0];
}
@@ -176,7 +180,8 @@ foreach ($Blog as $BlogItem) {
<em><a href="forums.php?action=viewthread&amp;threadid=<?=$ThreadID?>">Discuss this post here</a></em>
<? if (check_perms('admin_manage_blog')) { ?>
<a href="blog.php?action=deadthread&amp;id=<?=$BlogID?>&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets">Remove link</a>
-<? }
+<?
+ }
} ?>
</div>
</div>
diff --git a/sections/bookmarks/add.php b/sections/bookmarks/add.php
index 23e3736..488c311 100644
--- a/sections/bookmarks/add.php
+++ b/sections/bookmarks/add.php
@@ -23,9 +23,12 @@ $DB->query("
FROM $Table
WHERE UserID='$LoggedUser[ID]'
AND $Col='".db_string($_GET['id'])."'");
-if ($DB->record_count() == 0) {
+if (!$DB->has_results()) {
if ($Type === 'torrent') {
- $DB->query('SELECT MAX(Sort) FROM `bookmarks_torrents` WHERE UserID =' . $LoggedUser['ID']);
+ $DB->query('
+ SELECT MAX(Sort)
+ FROM `bookmarks_torrents`
+ WHERE UserID = ' . $LoggedUser['ID']);
list($Sort) = $DB->next_record();
if (!$Sort) $Sort = 0;
$Sort += 1;
@@ -47,7 +50,7 @@ if ($DB->record_count() == 0) {
FROM torrents_group
WHERE ID = '$GroupID'");
list($GroupTitle, $Year, $Body, $TagList) = $DB->next_record();
- $TagList = str_replace('_','.',$TagList);
+ $TagList = str_replace('_', '.', $TagList);
$DB->query("
SELECT ID, Format, Encoding, HasLog, HasCue, LogScore, Media, Scene, FreeTorrent, UserID
@@ -58,25 +61,25 @@ if ($DB->record_count() == 0) {
$Title = $GroupTitle;
list($TorrentID, $Format, $Bitrate, $HasLog, $HasCue, $LogScore, $Media, $Scene, $Freeleech, $UploaderID) = $Torrent;
$Title .= " [$Year] - ";
- $Title .= $Format." / ".$Bitrate;
+ $Title .= "$Format / $Bitrate";
if ($HasLog == "'1'") {
- $Title .= " / Log";
+ $Title .= ' / Log';
}
if ($HasLog) {
- $Title .= " / ".$LogScore.'%';
+ $Title .= " / $LogScore%";
}
if ($HasCue == "'1'") {
- $Title .= " / Cue";
+ $Title .= ' / Cue';
}
- $Title .= " / ".trim($Media);
+ $Title .= ' / '.trim($Media);
if ($Scene == '1') {
- $Title .= " / Scene";
+ $Title .= ' / Scene';
}
if ($Freeleech == '1') {
- $Title .= " / Freeleech!";
+ $Title .= ' / Freeleech!';
}
if ($Freeleech == '2') {
- $Title .= " / Neutral leech!";
+ $Title .= ' / Neutral leech!';
}
$UploaderInfo = Users::user_info($UploaderID);
@@ -84,12 +87,15 @@ if ($DB->record_count() == 0) {
$Text->strip_bbcode($Body),
'torrents.php?action=download&amp;authkey=[[AUTHKEY]]&amp;torrent_pass=[[PASSKEY]]&amp;id='.$TorrentID,
$UploaderInfo['Username'],
- 'torrents.php?id='.$GroupID,
+ "torrents.php?id=$GroupID",
trim($TagList));
$Feed->populate('torrents_bookmarks_t_'.$LoggedUser['torrent_pass'], $Item);
}
} elseif ($Type == 'request') {
- $DB->query("SELECT UserID FROM $Table WHERE $Col='".db_string($_GET['id'])."'");
+ $DB->query("
+ SELECT UserID
+ FROM $Table
+ WHERE $Col = '".db_string($_GET['id'])."'");
$Bookmarkers = $DB->collect('UserID');
$SS->UpdateAttributes('requests requests_delta', array('bookmarker'), array($_GET['id'] => array($Bookmarkers)), true);
}
diff --git a/sections/captcha/index.php b/sections/captcha/index.php
index a0256d0..aea86c9 100644
--- a/sections/captcha/index.php
+++ b/sections/captcha/index.php
@@ -5,7 +5,7 @@ if (!function_exists('imagettftext')) {
function get_font() {
global $CaptchaFonts;
- return SERVER_ROOT.'/classes/fonts/'.$CaptchaFonts[mt_rand(0,count($CaptchaFonts)-1)];
+ return SERVER_ROOT.'/classes/fonts/'.$CaptchaFonts[mt_rand(0, count($CaptchaFonts) - 1)];
}
function make_captcha_img() {
@@ -19,27 +19,27 @@ function make_captcha_img() {
$CaptchaString = '';
for ($i = 0; $i < $Length; $i++) {
- $CaptchaString.=$Chars[mt_rand(0,strlen($Chars) - 1)];
+ $CaptchaString .= $Chars[mt_rand(0,strlen($Chars) - 1)];
}
for ($x = 0; $x < $Length; $x++) {
- $FontDisplay[$x]['size'] = mt_rand(24,32);
- $FontDisplay[$x]['top'] = mt_rand($FontDisplay[$x]['size'] + 5,$ImageHeight - ($FontDisplay[$x]['size'] / 2));
- $FontDisplay[$x]['angle'] = mt_rand(-30,30);
+ $FontDisplay[$x]['size'] = mt_rand(24, 32);
+ $FontDisplay[$x]['top'] = mt_rand($FontDisplay[$x]['size'] + 5, $ImageHeight - ($FontDisplay[$x]['size'] / 2));
+ $FontDisplay[$x]['angle'] = mt_rand(-30, 30);
$FontDisplay[$x]['font'] = get_font();
}
- $Img = imagecreatetruecolor($ImageWidth,$ImageHeight);
- $BGImg = imagecreatefrompng(SERVER_ROOT.'/captcha/'.$CaptchaBGs[mt_rand(0,count($CaptchaBGs) - 1)]);
- imagecopymerge($Img,$BGImg,0,0,0,0,300,75,50);
+ $Img = imagecreatetruecolor($ImageWidth, $ImageHeight);
+ $BGImg = imagecreatefrompng(SERVER_ROOT.'/captcha/'.$CaptchaBGs[mt_rand(0, count($CaptchaBGs) - 1)]);
+ imagecopymerge($Img, $BGImg, 0, 0, 0, 0, 300, 75, 50);
- $ForeColor = imagecolorallocatealpha($Img,255,255,255,65);
+ $ForeColor = imagecolorallocatealpha($Img, 255, 255, 255, 65);
for ($i = 0; $i < strlen($CaptchaString); $i++) {
$CharX = (($ImageWidth / $Length) * ($i + 1)) - (($ImageWidth / $Length) * 0.75);
- imagettftext($Img,$FontDisplay[$i]['size'],$FontDisplay[$i]['angle'],$CharX,
- $FontDisplay[$i]['top'],$ForeColor,
- $FontDisplay[$i]['font'],$CaptchaString[$i]
+ imagettftext($Img,$FontDisplay[$i]['size'], $FontDisplay[$i]['angle'], $CharX,
+ $FontDisplay[$i]['top'], $ForeColor,
+ $FontDisplay[$i]['font'], $CaptchaString[$i]
);
}
diff --git a/sections/chat/index.php b/sections/chat/index.php
index c5c24ea..d254f26 100644
--- a/sections/chat/index.php
+++ b/sections/chat/index.php
@@ -2,7 +2,10 @@
enforce_login();
View::show_header('IRC');
-$DB->query("SELECT IRCKey FROM users_main WHERE ID = $LoggedUser[ID]");
+$DB->query("
+ SELECT IRCKey
+ FROM users_main
+ WHERE ID = $LoggedUser[ID]");
list($IRCKey) = $DB->next_record();
if (empty($IRCKey)) {
diff --git a/sections/collages/add_artist.php b/sections/collages/add_artist.php
index 5568935..d84a403 100644
--- a/sections/collages/add_artist.php
+++ b/sections/collages/add_artist.php
@@ -21,7 +21,7 @@ function add_artist($CollageID, $ArtistID) {
FROM collages_artists
WHERE CollageID = '$CollageID'
AND ArtistID = '$ArtistID'");
- if ($DB->record_count() == 0) {
+ if (!$DB->has_results()) {
$DB->query("
INSERT IGNORE INTO collages_artists
(CollageID, ArtistID, UserID, Sort, AddedOn)
@@ -147,7 +147,7 @@ if ($_REQUEST['action'] == 'add_artist') {
SELECT ArtistID
FROM artists_group
WHERE ArtistID = '$ArtistID'");
- if (!$DB->record_count()) {
+ if (!$DB->has_results()) {
$Err = "One of the entered URLs ($URL) does not correspond to an artist on the site.";
break;
}
diff --git a/sections/collages/add_torrent.php b/sections/collages/add_torrent.php
index f051eec..c5e7228 100644
--- a/sections/collages/add_torrent.php
+++ b/sections/collages/add_torrent.php
@@ -20,7 +20,7 @@ function add_torrent($CollageID, $GroupID) {
FROM collages_torrents
WHERE CollageID = '$CollageID'
AND GroupID = '$GroupID'");
- if ($DB->record_count() == 0) {
+ if (!$DB->has_results()) {
$DB->query("
INSERT IGNORE INTO collages_torrents
(CollageID, GroupID, UserID, Sort, AddedOn)
@@ -147,7 +147,7 @@ if ($_REQUEST['action'] == 'add_torrent') {
SELECT ID
FROM torrents_group
WHERE ID = '$GroupID'");
- if (!$DB->record_count()) {
+ if (!$DB->has_results()) {
$Err = "One of the entered URLs ($URL) does not correspond to a torrent group on the site.";
break;
}
diff --git a/sections/collages/browse.php b/sections/collages/browse.php
index 236af4f..6beb7c6 100644
--- a/sections/collages/browse.php
+++ b/sections/collages/browse.php
@@ -142,28 +142,32 @@ if (!empty($_GET['userid'])) {
}
if (!empty($Categories)) {
- $SQL.=" AND CategoryID IN(".db_string(implode(',',$Categories)).")";
+ $SQL .= " AND CategoryID IN(".db_string(implode(',', $Categories)).')';
}
if ($_GET['action'] == 'mine') {
$SQL = $BaseSQL;
- $SQL .= " AND c.UserID='".$LoggedUser['ID']."' AND c.CategoryID=0";
+ $SQL .= "
+ AND c.UserID = '".$LoggedUser['ID']."'
+ AND c.CategoryID = 0";
}
-$SQL.=" ORDER BY $Order $Way LIMIT $Limit ";
+$SQL .= "
+ ORDER BY $Order $Way
+ LIMIT $Limit";
$DB->query($SQL);
$Collages = $DB->to_array();
-$DB->query("SELECT FOUND_ROWS()");
+$DB->query('SELECT FOUND_ROWS()');
list($NumResults) = $DB->next_record();
-View::show_header(($BookmarkView)?'Your bookmarked collages':'Browse collages');
+View::show_header(($BookmarkView) ? 'Your bookmarked collages' : 'Browse collages');
?>
<div class="thin">
<div class="header">
<? if ($BookmarkView) { ?>
<h2>Your bookmarked collages</h2>
<? } else { ?>
- <h2>Browse collages<?=(!empty($UserLink) ? (isset($CollageIDs) ? ' with contributions by '.$UserLink : ' started by '.$UserLink) : '')?></h2>
+ <h2>Browse collages<?=(!empty($UserLink) ? (isset($CollageIDs) ? " with contributions by $UserLink" : " started by $UserLink") : '')?></h2>
<? } ?>
</div>
<? if (!$BookmarkView) { ?>
@@ -232,7 +236,12 @@ View::show_header(($BookmarkView)?'Your bookmarked collages':'Browse collages');
<? }
if (check_perms('site_collages_personal')) {
- $DB->query("SELECT ID FROM collages WHERE UserID='$LoggedUser[ID]' AND CategoryID='0' AND Deleted='0'");
+ $DB->query("
+ SELECT ID
+ FROM collages
+ WHERE UserID = '$LoggedUser[ID]'
+ AND CategoryID = '0'
+ AND Deleted = '0'");
$CollageCount = $DB->record_count();
if ($CollageCount == 1) {
@@ -300,7 +309,7 @@ foreach ($Collages as $Collage) {
//Print results
?>
- <tr class="row<?=$Row?><?=($BookmarkView) ? ' bookmark_'.$ID : ''?>">
+ <tr class="row<?=$Row?><?=($BookmarkView) ? " bookmark_$ID" : ''; ?>">
<td>
<a href="collages.php?action=search&amp;cats[<?=(int)$CategoryID?>]=1"><?=$CollageCats[(int)$CategoryID]?></a>
</td>
@@ -308,7 +317,7 @@ foreach ($Collages as $Collage) {
<a href="collages.php?id=<?=$ID?>"><?=$Name?></a>
<? if ($BookmarkView) { ?>
<span style="float: right;">
- <a href="#" onclick="Unbookmark('collage', <?=$ID?>,'');return false;" class="brackets">Remove bookmark</a>
+ <a href="#" onclick="Unbookmark('collage', <?=$ID?>, ''); return false;" class="brackets">Remove bookmark</a>
</span>
<? } ?>
<div class="tags"><?=$TorrentTags->format('collages.php?action=search&amp;tags=')?></div>
diff --git a/sections/collages/collage.php b/sections/collages/collage.php
index b348d2f..2450d6b 100644
--- a/sections/collages/collage.php
+++ b/sections/collages/collage.php
@@ -24,7 +24,7 @@ if ($Data) {
list($K, list($Name, $Description, , , $CommentList, $Deleted, $CollageCategoryID, $CreatorID, $Locked, $MaxGroups, $MaxGroupsPerUser, $Updated, $Subscribers)) = each($Data);
} else {
$DB->query("SELECT Name, Description, UserID, Deleted, CategoryID, Locked, MaxGroups, MaxGroupsPerUser, Updated, Subscribers FROM collages WHERE ID='$CollageID'");
- if ($DB->record_count() > 0) {
+ if ($DB->has_results()) {
list($Name, $Description, $CreatorID, $Deleted, $CollageCategoryID, $Locked, $MaxGroups, $MaxGroupsPerUser, $Updated, $Subscribers) = $DB->next_record();
$TorrentList = '';
$CollageList = '';
diff --git a/sections/collages/edit_handle.php b/sections/collages/edit_handle.php
index cc5c41e..108c321 100644
--- a/sections/collages/edit_handle.php
+++ b/sections/collages/edit_handle.php
@@ -6,14 +6,22 @@ if (!is_number($CollageID)) {
error(0);
}
-$DB->query("SELECT UserID, CategoryID, Locked, MaxGroups, MaxGroupsPerUser FROM collages WHERE ID='$CollageID'");
+$DB->query("
+ SELECT UserID, CategoryID, Locked, MaxGroups, MaxGroupsPerUser
+ FROM collages
+ WHERE ID = '$CollageID'");
list($UserID, $CategoryID, $Locked, $MaxGroups, $MaxGroupsPerUser) = $DB->next_record();
if ($CategoryID == 0 && $UserID != $LoggedUser['ID'] && !check_perms('site_collages_delete')) {
error(403);
}
-$DB->query("SELECT ID,Deleted FROM collages WHERE Name='".db_string($_POST['name'])."' AND ID!='$CollageID' LIMIT 1");
-if ($DB->record_count()) {
+$DB->query("
+ SELECT ID, Deleted
+ FROM collages
+ WHERE Name = '".db_string($_POST['name'])."'
+ AND ID != '$CollageID'
+ LIMIT 1");
+if ($DB->has_results()) {
list($ID, $Deleted) = $DB->next_record();
if ($Deleted) {
$Err = 'A collage with that name already exists but needs to be recovered, please <a href="staffpm.php">contact</a> the staff team!';
@@ -25,11 +33,11 @@ if ($DB->record_count()) {
die();
}
-$TagList = explode(',',$_POST['tags']);
-foreach ($TagList as $ID=>$Tag) {
+$TagList = explode(',', $_POST['tags']);
+foreach ($TagList as $ID => $Tag) {
$TagList[$ID] = Misc::sanitize_tag($Tag);
}
-$TagList = implode(' ',$TagList);
+$TagList = implode(' ', $TagList);
$Updates = array("Description='".db_string($_POST['description'])."', TagList='".db_string($TagList)."'");
@@ -40,32 +48,39 @@ if (!check_perms('site_collages_delete') && ($CategoryID == 0 && $UserID == $Log
}
if (isset($_POST['featured']) && $CategoryID == 0 && (($LoggedUser['ID'] == $UserID && check_perms('site_collages_personal')) || check_perms('site_collages_delete'))) {
- $DB->query("UPDATE collages SET Featured=0 WHERE CategoryID=0 and UserID=$UserID");
- $Updates[] = 'Featured=1';
+ $DB->query("
+ UPDATE collages
+ SET Featured = 0
+ WHERE CategoryID = 0 \
+ AND UserID = $UserID");
+ $Updates[] = 'Featured = 1';
}
if (check_perms('site_collages_delete') || ($CategoryID == 0 && $UserID == $LoggedUser['ID'] && check_perms('site_collages_renamepersonal'))) {
- $Updates[] = "Name='".db_string($_POST['name'])."'";
+ $Updates[] = "Name = '".db_string($_POST['name'])."'";
}
if (isset($_POST['category']) && !empty($CollageCats[$_POST['category']]) && $_POST['category'] != $CategoryID && ($_POST['category'] != 0 || check_perms('site_collages_delete'))) {
- $Updates[] = 'CategoryID='.$_POST['category'];
+ $Updates[] = 'CategoryID = '.$_POST['category'];
}
if (check_perms('site_collages_delete')) {
if (isset($_POST['locked']) != $Locked) {
- $Updates[] = 'Locked=' . ($Locked ? "'0'" : "'1'");
+ $Updates[] = 'Locked = ' . ($Locked ? "'0'" : "'1'");
}
if (isset($_POST['maxgroups']) && ($_POST['maxgroups'] == 0 || is_number($_POST['maxgroups'])) && $_POST['maxgroups'] != $MaxGroups) {
- $Updates[] = 'MaxGroups=' . $_POST['maxgroups'];
+ $Updates[] = 'MaxGroups = ' . $_POST['maxgroups'];
}
if (isset($_POST['maxgroups']) && ($_POST['maxgroupsperuser'] == 0 || is_number($_POST['maxgroupsperuser'])) && $_POST['maxgroupsperuser'] != $MaxGroupsPerUser) {
- $Updates[] = 'MaxGroupsPerUser=' . $_POST['maxgroupsperuser'];
+ $Updates[] = 'MaxGroupsPerUser = ' . $_POST['maxgroupsperuser'];
}
}
if (!empty($Updates)) {
- $DB->query("UPDATE collages SET ".implode(', ', $Updates)." WHERE ID=$CollageID");
+ $DB->query('
+ UPDATE collages
+ SET '.implode(', ', $Updates)."
+ WHERE ID = $CollageID");
}
$Cache->delete_value('collage_'.$CollageID);
header('Location: collages.php?id='.$CollageID);
diff --git a/sections/collages/new.php b/sections/collages/new.php
index 69db176..a75a015 100644
--- a/sections/collages/new.php
+++ b/sections/collages/new.php
@@ -29,8 +29,8 @@ if (!empty($Error)) { ?>
<tr id="collagename">
<td class="label"><strong>Name</strong></td>
<td>
- <input type="text"<?=$NoName ? ' class="hidden"' : '' ?> name="name" size="60" id="namebox" value="<?=display_str($Name)?>" />
- <span id="personal"<?=$NoName ? '' : ' class="hidden"' ?> style="font-style: oblique;"><strong><?=$LoggedUser['Username']?>'s personal collage</strong></span>
+ <input type="text"<?=$NoName ? ' class="hidden"' : ''; ?> name="name" size="60" id="namebox" value="<?=display_str($Name)?>" />
+ <span id="personal"<?=$NoName ? '' : ' class="hidden"'; ?> style="font-style: oblique;"><strong><?=$LoggedUser['Username']?>'s personal collage</strong></span>
</td>
</tr>
<tr>
@@ -40,12 +40,17 @@ if (!empty($Error)) { ?>
<?
array_shift($CollageCats);
-foreach ($CollageCats as $CatID=>$CatName) : ?>
+foreach ($CollageCats as $CatID=>$CatName) { ?>
<option value="<?=$CatID + 1 ?>"<?=(($CatID + 1 == $Category) ? ' selected="selected"' : '')?>><?=$CatName?></option>
<?
-endforeach;
+}
-$DB->query("SELECT COUNT(ID) FROM collages WHERE UserID='$LoggedUser[ID]' AND CategoryID='0' AND Deleted='0'");
+$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']) && check_perms('site_collages_personal')) { ?>
<option value="0"<?=(($Category === '0') ? ' selected="selected"' : '')?>>Personal</option>
diff --git a/sections/collages/new_handle.php b/sections/collages/new_handle.php
index 4737619..022d986 100644
--- a/sections/collages/new_handle.php
+++ b/sections/collages/new_handle.php
@@ -15,7 +15,7 @@ if ($P['category'] > 0 || check_perms('site_collages_renamepersonal')) {
$P['name'] = db_string($name);
$DB->query("SELECT ID FROM collages WHERE Name='".$P['name']."'");
$i = 2;
- while ($DB->record_count() != 0) {
+ while ($DB->has_results()) {
$P['name'] = db_string($name." no. $i");
$DB->query("SELECT ID FROM collages WHERE Name='".$P['name']."'");
$i++;
@@ -37,7 +37,7 @@ if ($P['category'] == '0') {
if (!$Err) {
$DB->query("SELECT ID,Deleted FROM collages WHERE Name='$P[name]'");
- if ($DB->record_count()) {
+ if ($DB->has_results()) {
list($ID, $Deleted) = $DB->next_record();
if ($Deleted) {
$Err = "That collection already exists but needs to be recovered; please <a href=\"staffpm.php\">contact</a> the staff team!";
diff --git a/sections/collages/recover.php b/sections/collages/recover.php
index 04fba9e..53ee4d1 100644
--- a/sections/collages/recover.php
+++ b/sections/collages/recover.php
@@ -11,7 +11,7 @@ if ($_POST['collage_id'] && is_number($_POST['collage_id'])) {
SELECT Name
FROM collages
WHERE ID = $CollageID");
- if ($DB->record_count() == 0) {
+ if (!$DB->has_results()) {
error('Collage is completely deleted');
} else {
$DB->query("
diff --git a/sections/collages/takeedit_comment.php b/sections/collages/takeedit_comment.php
index 31d5395..ba83281 100644
--- a/sections/collages/takeedit_comment.php
+++ b/sections/collages/takeedit_comment.php
@@ -36,7 +36,7 @@ list($OldBody, $AuthorID, $CollageID, $PostNum) = $DB->next_record();
if ($UserID != $AuthorID && !check_perms('site_moderate_forums')) {
die('Permission denied');
}
-if ($DB->record_count() == 0) {
+if (!$DB->has_results()) {
die('Post not found!');
}
diff --git a/sections/comments/post.php b/sections/comments/post.php
index 30145ce..7c780f8 100644
--- a/sections/comments/post.php
+++ b/sections/comments/post.php
@@ -13,13 +13,13 @@
* @returns void, prints output
*/
function comment_body($UserID, $PostID, $postheader, $permalink, $Body, $EditorID, $AddedTime, $EditedTime) {
- global $Text,$HeavyInfo;
+ global $Text, $HeavyInfo;
$UserInfo = Users::user_info($UserID);
$postheader = 'by <strong>' . Users::format_username($UserID, true, true, true, true, false) . '</strong> '
. time_diff($AddedTime) . $postheader;
?>
- <table class="forum_post box vertical_margin<?=$noavatar ? ' noavatar' : '' ?>" id="post<?=$PostID?>">
+ <table class="forum_post box vertical_margin<?=$noavatar ? ' noavatar' : ''; ?>" id="post<?=$PostID?>">
<colgroup>
<? if (Users::has_avatars_enabled()) { ?>
<col class="col_avatar" />
@@ -27,7 +27,7 @@ function comment_body($UserID, $PostID, $postheader, $permalink, $Body, $EditorI
<col class="col_post_body" />
</colgroup>
<tr class="colhead_dark">
- <td colspan="<?=Users::has_avatars_enabled() ? 2 : 1 ?>">
+ <td colspan="<?=Users::has_avatars_enabled() ? 2 : 1; ?>">
<span style="float: left;"><a href="<?=$permalink ?>">#<?=$PostID?></a>
<?=$postheader ?>
</span>
diff --git a/sections/donate/ipn.php b/sections/donate/ipn.php
index dfb9c12..5be4193 100644
--- a/sections/donate/ipn.php
+++ b/sections/donate/ipn.php
@@ -30,18 +30,30 @@ while (!feof($Socket)) {
$Result .= fgets ($Socket, 1024);
}
-if (strpos($Result,'VERIFIED') !== false || check_perms('site_debug')) {
+if (strpos($Result, 'VERIFIED') !== false || check_perms('site_debug')) {
if ($_POST['mc_gross'] >= PAYPAL_MINIMUM) {
if ($_POST['mc_currency'] == PAYPAL_CURRENCY) {
if ($_POST['business'] == PAYPAL_ADDRESS) {
- if (($_POST['payment_status'] == "Completed") || ($_POST['payment_status'] == "Pending")) {
- $DB->query('SELECT Donor FROM users_info WHERE UserID=\''.$_POST['custom'].'\'');
+ if (($_POST['payment_status'] == 'Completed') || ($_POST['payment_status'] == 'Pending')) {
+ $DB->query('
+ SELECT Donor
+ FROM users_info
+ WHERE UserID = \''.$_POST['custom'].'\'');
list($Donor) = $DB->next_record();
if ($Donor == 0) {
//First time donor
- $DB->query('UPDATE users_main SET Invites = Invites + \''.DONOR_INVITES.'\' WHERE ID=\''.$_POST['custom'].'\'');
- $DB->query('UPDATE users_info SET Donor = \'1\' WHERE UserID=\''.$_POST['custom'].'\'');
- $DB->query('SELECT Invites FROM users_main WHERE ID=\''.$_POST['custom'].'\'');
+ $DB->query('
+ UPDATE users_main
+ SET Invites = Invites + \''.DONOR_INVITES.'\'
+ WHERE ID = \''.$_POST['custom'].'\'');
+ $DB->query('
+ UPDATE users_info
+ SET Donor = \'1\'
+ WHERE UserID = \''.$_POST['custom'].'\'');
+ $DB->query('
+ SELECT Invites
+ FROM users_main
+ WHERE ID = \''.$_POST['custom'].'\'');
list($Invites) = $DB->next_record();
$Cache->begin_transaction('user_info_'.$_POST['custom']);
$Cache->update_row(false, array('Donor' => 1));
@@ -65,23 +77,32 @@ if (strpos($Result,'VERIFIED') !== false || check_perms('site_debug')) {
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 https://".SSL_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) {
- $DB->query("SELECT Invites FROM users_main WHERE ID='".$_POST['custom']."'");
+ WHERE UserID = \''.$_POST['custom'].'\';');
+ list($TotalDonated, $DonationTime) = $DB->next_record();
+ if ($TotalDonated + $_POST['mc_gross'] == 0) {
+ $DB->query("
+ SELECT Invites
+ FROM users_main
+ WHERE ID = '".$_POST['custom']."'");
list($Invites) = $DB->next_record();
if (($Invites - DONOR_INVITES) >= 0) {
$NewInvites = $Invites - DONOR_INVITES;
} else {
$NewInvites = 0;
- $Message .= " They had already used at least one of their donation gained invites.";
+ $Message .= ' They had already used at least one of their donation gained invites.';
}
- $DB->query("UPDATE users_main SET Invites = ".$NewInvites." WHERE ID='".$_POST['custom']."'");
- $DB->query('UPDATE users_info SET Donor = \'0\' WHERE UserID=\''.$_POST['custom'].'\'');
+ $DB->query("
+ UPDATE users_main
+ SET Invites = $NewInvites
+ WHERE ID = '".$_POST['custom']."'");
+ $DB->query('
+ UPDATE users_info
+ SET Donor = \'0\'
+ WHERE UserID = \''.$_POST['custom'].'\'');
$Cache->begin_transaction('user_info_'.$_POST['custom']);
$Cache->update_row(false, array('Donor' => 0));
$Cache->commit_transaction(0);
@@ -91,15 +112,14 @@ if (strpos($Result,'VERIFIED') !== false || check_perms('site_debug')) {
Misc::send_pm($_POST['custom'], 0, 'Notice of donation failure', '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);
+ send_irc("PRIVMSG ".BOT_REPORT_CHAN." :$Message");
}
}
}
$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']."'");
+ 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
(UserID, Amount, Email, Time)
@@ -110,11 +130,11 @@ if (strpos($Result,'VERIFIED') !== false || check_perms('site_debug')) {
INSERT INTO ip_bans
(FromIP, ToIP, Reason)
VALUES
- ('".Tools::ip_to_unsigned($_SERVER['REMOTE_ADDR'])."','".ip2long($_SERVER['REMOTE_ADDR'])."', 'Attempted to exploit donation system.')");
+ ('".Tools::ip_to_unsigned($_SERVER['REMOTE_ADDR'])."', '".ip2long($_SERVER['REMOTE_ADDR'])."', 'Attempted to exploit donation system.')");
}
fclose ($Socket);
if (check_perms('site_debug')) {
include(SERVER_ROOT.'/sections/donate/donate.php');
}
-$Cache->cache_value('debug_donate',array($Result,$_POST),0);
+$Cache->cache_value('debug_donate', array($Result, $_POST), 0);
?>
diff --git a/sections/forums/add_poll_option.php b/sections/forums/add_poll_option.php
index aeb45a6..ea442c7 100644
--- a/sections/forums/add_poll_option.php
+++ b/sections/forums/add_poll_option.php
@@ -8,14 +8,20 @@ if (!is_number($ThreadID)) {
error(404);
}
if (!check_perms('site_moderate_forums')) {
- $DB->query("SELECT ForumID FROM forums_topics WHERE ID = $ThreadID");
+ $DB->query("
+ SELECT ForumID
+ FROM forums_topics
+ WHERE ID = $ThreadID");
list($ForumID) = $DB->next_record();
if (!in_array($ForumID, $ForumsRevealVoters)) {
error(403);
}
}
-$DB->query("SELECT Answers FROM forums_polls WHERE TopicID = ".$ThreadID);
-if ($DB->record_count() < 1) {
+$DB->query("
+ SELECT Answers
+ FROM forums_polls
+ WHERE TopicID = $ThreadID");
+if (!$DB->has_results()) {
error(404);
}
@@ -27,7 +33,7 @@ $Answers = serialize($Answers);
$DB->query("
UPDATE forums_polls
SET Answers = '".db_string($Answers)."'
- WHERE TopicID = ".$ThreadID);
-$Cache->delete_value('polls_'.$ThreadID);
+ WHERE TopicID = $ThreadID");
+$Cache->delete_value("polls_$ThreadID");
-header("Location: forums.php?action=viewthread&threadid=".$ThreadID);
+header("Location: forums.php?action=viewthread&threadid=$ThreadID");
diff --git a/sections/forums/delete.php b/sections/forums/delete.php
index d3d9d8f..79be5fb 100644
--- a/sections/forums/delete.php
+++ b/sections/forums/delete.php
@@ -16,15 +16,15 @@ $DB->query("
SELECT
TopicID,
ForumID,
- CEIL(COUNT(p.ID)/".POSTS_PER_PAGE.") AS Pages,
- CEIL(SUM(IF(p.ID<='$PostID',1,0))/".POSTS_PER_PAGE.") AS Page,
+ CEIL(COUNT(p.ID) / ".POSTS_PER_PAGE.") AS Pages,
+ CEIL(SUM(IF(p.ID <= '$PostID', 1, 0)) / ".POSTS_PER_PAGE.") AS Page,
StickyPostID
FROM forums_posts AS p
- JOIN forums_topics AS t ON t.ID=p.TopicID
- WHERE p.TopicID=(
+ JOIN forums_topics AS t ON t.ID = p.TopicID
+ WHERE p.TopicID = (
SELECT TopicID
FROM forums_posts
- WHERE ID='$PostID'
+ WHERE ID = '$PostID'
)
GROUP BY t.ID");
list($TopicID, $ForumID, $Pages, $Page, $StickyPostID) = $DB->next_record();
@@ -33,30 +33,35 @@ list($TopicID, $ForumID, $Pages, $Page, $StickyPostID) = $DB->next_record();
// $Page = which page the post is on
// These are set for cache clearing.
-$DB->query("DELETE FROM forums_posts WHERE ID='$PostID'");
+$DB->query("
+ DELETE FROM forums_posts
+ WHERE ID = '$PostID'");
-$DB->query("SELECT MAX(ID) FROM forums_posts WHERE TopicID='$TopicID'");
+$DB->query("
+ SELECT MAX(ID)
+ FROM forums_posts
+ WHERE TopicID = '$TopicID'");
list($LastID) = $DB->next_record();
$DB->query("
UPDATE forums AS f, forums_topics AS t
- SET f.NumPosts=f.NumPosts-1, t.NumPosts=t.NumPosts-1
- WHERE f.ID='$ForumID'
- AND t.ID='$TopicID'");
+ SET f.NumPosts = f.NumPosts - 1, t.NumPosts = t.NumPosts - 1
+ WHERE f.ID = '$ForumID'
+ AND t.ID = '$TopicID'");
if ($LastID < $PostID) { // Last post in a topic was removed
$DB->query("
SELECT p.AuthorID, u.Username, p.AddedTime
FROM forums_posts AS p
LEFT JOIN users_main AS u ON u.ID = p.AuthorID
- WHERE p.ID='$LastID'");
+ WHERE p.ID = '$LastID'");
list($LastAuthorID, $LastAuthorName, $LastTime) = $DB->next_record();
$DB->query("
UPDATE forums_topics
SET
- LastPostID='$LastID',
- LastPostAuthorID='$LastAuthorID',
- LastPostTime='$LastTime'
- WHERE ID='$TopicID'");
+ LastPostID = '$LastID',
+ LastPostAuthorID = '$LastAuthorID',
+ LastPostTime = '$LastTime'
+ WHERE ID = '$TopicID'");
$DB->query("
SELECT
t.ID,
@@ -67,7 +72,7 @@ if ($LastID < $PostID) { // Last post in a topic was removed
u.Username
FROM forums_topics AS t
LEFT JOIN users_main AS u ON u.ID = t.LastPostAuthorID
- WHERE ForumID='$ForumID'
+ WHERE ForumID = '$ForumID'
AND t.ID != '$TopicID'
ORDER BY LastPostID DESC
LIMIT 1");
@@ -77,12 +82,12 @@ if ($LastID < $PostID) { // Last post in a topic was removed
$DB->query("
UPDATE forums
SET
- LastPostTopicID='$LastTopicID',
- LastPostID='$LastTopicPostID',
- LastPostAuthorID='$LastTopicAuthorID',
- LastPostTime='$LastTopicPostTime'
- WHERE ID='$ForumID'
- AND LastPostTopicID='$TopicID'");
+ LastPostTopicID = '$LastTopicID',
+ LastPostID = '$LastTopicPostID',
+ LastPostAuthorID = '$LastTopicAuthorID',
+ LastPostTime = '$LastTopicPostTime'
+ WHERE ID = '$ForumID'
+ AND LastPostTopicID = '$TopicID'");
$UpdateArrayForums = array(
'NumPosts' => '-1',
'LastPostID' => $LastTopicPostID,
@@ -94,11 +99,11 @@ if ($LastID < $PostID) { // Last post in a topic was removed
$DB->query("
UPDATE forums
SET
- LastPostID='$LastID',
- LastPostAuthorID='$LastAuthorID',
- LastPostTime='$LastTime'
- WHERE ID='$ForumID'
- AND LastPostTopicID='$TopicID'");
+ LastPostID = '$LastID',
+ LastPostAuthorID = '$LastAuthorID',
+ LastPostTime = '$LastTime'
+ WHERE ID = '$ForumID'
+ AND LastPostTopicID = '$TopicID'");
$UpdateArrayForums = array(
'NumPosts' => '-1',
'LastPostID' => $LastID,
@@ -122,10 +127,10 @@ if ($StickyPostID == $PostID) {
$ThisCatalogue = floor((POSTS_PER_PAGE * $Page - POSTS_PER_PAGE) / THREAD_CATALOGUE);
$LastCatalogue = floor((POSTS_PER_PAGE * $Pages - POSTS_PER_PAGE) / THREAD_CATALOGUE);
for ($i = $ThisCatalogue; $i <= $LastCatalogue; $i++) {
- $Cache->delete_value('thread_'.$TopicID.'_catalogue_'.$i);
+ $Cache->delete_value("thread_$TopicID"."_catalogue_$i");
}
-$Cache->begin_transaction('thread_'.$TopicID.'_info');
+$Cache->begin_transaction("thread_$TopicID".'_info');
$Cache->update_row(false, $UpdateArrayThread);
$Cache->commit_transaction();
@@ -133,5 +138,5 @@ $Cache->begin_transaction('forums_list');
$Cache->update_row($ForumID, $UpdateArrayForums);
$Cache->commit_transaction();
-$Cache->delete_value('forums_'.$ForumID);
+$Cache->delete_value("forums_$ForumID");
?>
diff --git a/sections/forums/delete_poll_option.php b/sections/forums/delete_poll_option.php
index d06d55f..51259bd 100644
--- a/sections/forums/delete_poll_option.php
+++ b/sections/forums/delete_poll_option.php
@@ -8,14 +8,20 @@ $ThreadID = $_GET['threadid'];
$PollOption = $_GET['vote'];
if (is_number($ThreadID) && is_number($PollOption)) {
- $DB->query("SELECT ForumID FROM forums_topics WHERE ID = $ThreadID");
+ $DB->query("
+ SELECT ForumID
+ FROM forums_topics
+ WHERE ID = $ThreadID");
list($ForumID) = $DB->next_record();
if (!in_array($ForumID, $ForumsRevealVoters)) {
error(403);
}
- $DB->query("SELECT Answers FROM forums_polls WHERE TopicID = $ThreadID");
- if ($DB->record_count() < 1) {
+ $DB->query("
+ SELECT Answers
+ FROM forums_polls
+ WHERE TopicID = $ThreadID");
+ if (!$DB->has_results()) {
error(404);
}
@@ -33,9 +39,8 @@ if (is_number($ThreadID) && is_number($PollOption)) {
WHERE Vote = $PollOption
AND TopicID = $ThreadID");
- $Cache->delete_value('polls_'.$ThreadID);
- header('Location: forums.php?action=viewthread&threadid='.$ThreadID);
-
+ $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 a964cf9..3b8f6c0 100644
--- a/sections/forums/forum.php
+++ b/sections/forums/forum.php
@@ -132,7 +132,7 @@ View::show_header('Forums &gt; '. $Forums[$ForumID]['Name']);
FROM subscribed_forums
WHERE ForumID='$ForumID'
AND SubscriberID='$LoggedUser[ID]'");
- if ($DB->record_count() == 0) { ?>
+ if (!$DB->has_results()) { ?>
<a href="forums.php?action=forum_subscribe&amp;perform=add&amp;forumid=<?=$ForumID?>&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets">Subscribe to forum</a>
<? } else { ?>
<a href="forums.php?action=forum_subscribe&amp;perform=remove&amp;forumid=<?=$ForumID?>&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets">Unsubscribe from forum</a>
diff --git a/sections/forums/functions.php b/sections/forums/functions.php
index 66cce60..db6dbe3 100644
--- a/sections/forums/functions.php
+++ b/sections/forums/functions.php
@@ -19,7 +19,7 @@ function get_thread_info($ThreadID, $Return = true, $SelectiveCache = false, $Ap
LEFT JOIN forums_polls AS p ON p.TopicID=t.ID
WHERE t.ID = '$ThreadID'
GROUP BY fp.TopicID");
- if ($DB->record_count() == 0) {
+ if (!$DB->has_results()) {
if (!$ApiCall) {
error(404);
} else {
@@ -84,7 +84,7 @@ function get_forum_info($ForumID) {
LEFT JOIN forums_topics ON forums_topics.ForumID=forums.ID
WHERE forums.ID='$ForumID'
GROUP BY ForumID");
- if ($DB->record_count() == 0) {
+ if (!$DB->has_results()) {
return false;
}
// Makes an array, with $Forum['Name'], etc.
diff --git a/sections/forums/index.php b/sections/forums/index.php
index 472862b..a62c7f6 100644
--- a/sections/forums/index.php
+++ b/sections/forums/index.php
@@ -12,7 +12,9 @@ include(SERVER_ROOT.'/sections/forums/functions.php');
unset($ForumCats);
$ForumCats = $Cache->get_value('forums_categories');
if ($ForumCats === false) {
- $DB->query('SELECT ID, Name FROM forums_categories');
+ $DB->query('
+ SELECT ID, Name
+ FROM forums_categories');
$ForumCats = array();
while (list($ID, $Name) = $DB->next_record()) {
$ForumCats[$ID] = $Name;
@@ -50,7 +52,10 @@ if (!$Forums = $Cache->get_value('forums_list')) {
$Forums = $DB->to_array('ID', MYSQLI_ASSOC, false);
foreach ($Forums as $ForumID => $Forum) {
if (count($Forum['SpecificRules'])) {
- $DB->query('SELECT ThreadID FROM forums_specific_rules WHERE ForumID = '.$ForumID);
+ $DB->query("
+ SELECT ThreadID
+ FROM forums_specific_rules
+ WHERE ForumID = $ForumID");
$ThreadIDs = $DB->collect('ThreadID');
$Forums[$ForumID]['SpecificRules'] = $ThreadIDs;
}
diff --git a/sections/forums/main.php b/sections/forums/main.php
index a48aad0..2420242 100644
--- a/sections/forums/main.php
+++ b/sections/forums/main.php
@@ -9,7 +9,7 @@ if (isset($LoggedUser['PostsPerPage'])) {
$TopicIDs = array();
foreach ($Forums as $Forum) {
if (!empty($Forum['LastPostTopicID'])) {
- $TopicIDs[]=$Forum['LastPostTopicID'];
+ $TopicIDs[] = $Forum['LastPostTopicID'];
}
}
@@ -23,11 +23,11 @@ if (!empty($TopicIDs)) {
SELECT COUNT(ID)
FROM forums_posts
WHERE forums_posts.TopicID = l.TopicID
- AND forums_posts.ID<=l.PostID
- )/$PerPage) AS Page
+ AND forums_posts.ID <= l.PostID
+ ) / $PerPage) AS Page
FROM forums_last_read_topics AS l
- WHERE TopicID IN(".implode(',',$TopicIDs).")
- AND UserID='$LoggedUser[ID]'");
+ WHERE TopicID IN(".implode(',', $TopicIDs).")
+ AND UserID = '$LoggedUser[ID]'");
$LastRead = $DB->to_array('TopicID', MYSQLI_ASSOC);
} else {
$LastRead = array();
@@ -43,7 +43,10 @@ View::show_header('Forums');
$Row = 'a';
$LastCategoryID = 0;
$OpenTable = false;
-$DB->query("SELECT RestrictedForums FROM users_info WHERE UserID = ".$LoggedUser['ID']);
+$DB->query('
+ SELECT RestrictedForums
+ FROM users_info
+ WHERE UserID = '.$LoggedUser['ID']);
list($RestrictedForums) = $DB->next_record();
$RestrictedForums = explode(',', $RestrictedForums);
$PermittedForums = array_keys($LoggedUser['PermittedForums']);
@@ -52,7 +55,7 @@ foreach ($Forums as $Forum) {
if ($LoggedUser['CustomForums'][$ForumID] != 1 && ($MinRead > $LoggedUser['Class'] || array_search($ForumID, $RestrictedForums) !== false)) {
continue;
}
- $Row = (($Row == 'a') ? 'b' : 'a');
+ $Row = (($Row === 'a') ? 'b' : 'a');
$ForumDescription = display_str($ForumDescription);
if ($CategoryID != $LastCategoryID) {
diff --git a/sections/forums/poll_vote.php b/sections/forums/poll_vote.php
index d0e6032..b1cfa44 100644
--- a/sections/forums/poll_vote.php
+++ b/sections/forums/poll_vote.php
@@ -26,7 +26,7 @@ if (!$ThreadInfo = $Cache->get_value('thread_'.$TopicID.'_info')) {
LEFT JOIN forums_polls AS p ON p.TopicID=t.ID
WHERE t.ID = '$TopicID'
GROUP BY fp.TopicID");
- if ($DB->record_count() == 0) {
+ if (!$DB->has_results()) {
die();
}
$ThreadInfo = $DB->next_record(MYSQLI_ASSOC);
diff --git a/sections/forums/search.php b/sections/forums/search.php
index ecbfa14..7893678 100644
--- a/sections/forums/search.php
+++ b/sections/forums/search.php
@@ -32,7 +32,10 @@ if (isset($_GET['search'])) {
// Searching for posts by a specific user
if (!empty($_GET['user'])) {
$User = trim($_GET['user']);
- $DB->query("SELECT ID FROM users_main WHERE Username='".db_string($User)."'");
+ $DB->query("
+ SELECT ID
+ FROM users_main
+ WHERE Username = '".db_string($User)."'");
list($AuthorID) = $DB->next_record();
if ($AuthorID === null) {
$AuthorID = 0;
@@ -254,21 +257,21 @@ if ($Type == 'body') {
JOIN forums AS f ON f.ID=t.ForumID
WHERE ((f.MinClassRead<='$LoggedUser[Class]'";
if (!empty($RestrictedForums)) {
- $sql.=" AND f.ID NOT IN ('".$RestrictedForums."')";
+ $sql .= " AND f.ID NOT IN ('$RestrictedForums')";
}
$sql .= ')';
if (!empty($PermittedForums)) {
- $sql.=' OR f.ID IN (\''.$PermittedForums.'\')';
+ $sql .= " OR f.ID IN ('$PermittedForums')";
}
$sql .= ') AND ';
$sql .= "t.Title LIKE '%";
$sql .= implode("%' AND t.Title LIKE '%", $Words);
$sql .= "%' ";
if (isset($SearchForums)) {
- $sql.=" AND f.ID IN ($SearchForums)";
+ $sql .= " AND f.ID IN ($SearchForums)";
}
if (isset($AuthorID)) {
- $sql.=" AND t.AuthorID='$AuthorID' ";
+ $sql .= " AND t.AuthorID = '$AuthorID' ";
}
$sql .= "
ORDER BY t.LastPostTime DESC
@@ -291,13 +294,13 @@ echo $Pages;
<td><?=((!empty($ThreadID)) ? 'Post begins' : 'Topic')?></td>
<td>Time</td>
</tr>
-<? if ($DB->record_count() == 0) { ?>
+<? if (!$DB->has_results()) { ?>
<tr><td colspan="3">Nothing found<?=((isset($AuthorID) && $AuthorID == 0) ? ' (unknown username)' : '')?>!</td></tr>
<? }
$Row = 'a'; // For the pretty colours
while (list($ID, $Title, $ForumID, $ForumName, $LastTime, $PostID, $Body) = $DB->next_record()) {
- $Row = (($Row == 'a') ? 'b' : 'a');
+ $Row = (($Row === 'a') ? 'b' : 'a');
// Print results
?>
<tr class="row<?=$Row?>">
@@ -311,7 +314,7 @@ while (list($ID, $Title, $ForumID, $ForumName, $LastTime, $PostID, $Body) = $DB-
<?=Format::cut_string($Title, 80); ?>
<? }
if ($Type == 'body') { ?>
- <a href="#" onclick="$('#post_<?=$PostID?>_text').gtoggle(); return false;">(show)</a> <span style="float: right;" class="last_read" title="Jump to post"><a href="forums.php?action=viewthread&amp;threadid=<?=$ID?><? if (!empty($PostID)) { echo '&amp;postid='.$PostID.'#post'.$PostID; } ?>"></a></span>
+ <a href="#" onclick="$('#post_<?=$PostID?>_text').gtoggle(); return false;">(show)</a> <span style="float: right;" class="last_read" title="Jump to post"><a href="forums.php?action=viewthread&amp;threadid=<?=$ID?><? if (!empty($PostID)) { echo "&amp;postid=$PostID#post$PostID"; } ?>"></a></span>
<? } ?>
</td>
<td>
diff --git a/sections/forums/sticky_post.php b/sections/forums/sticky_post.php
index 9e133b4..fef725e 100644
--- a/sections/forums/sticky_post.php
+++ b/sections/forums/sticky_post.php
@@ -21,7 +21,7 @@ $DB->query("
WHERE TopicID=$ThreadID
GROUP BY TopicID");
-if ($DB->record_count()) {
+if ($DB->has_results()) {
list($Pages,$Page) = $DB->next_record();
if ($Delete) {
$DB->query("
diff --git a/sections/forums/take_reply.php b/sections/forums/take_reply.php
index ddf7473..e82bbcc 100644
--- a/sections/forums/take_reply.php
+++ b/sections/forums/take_reply.php
@@ -142,33 +142,33 @@ if ($ThreadInfo['LastPostAuthorID'] == $LoggedUser['ID'] && ((!check_perms('site
$DB->query("
UPDATE forums_topics
SET
- NumPosts = NumPosts+1,
+ NumPosts = NumPosts + 1,
LastPostID = '$PostID',
LastPostAuthorID = '".$LoggedUser['ID']."',
LastPostTime = '$SQLTime'
WHERE ID = '$TopicID'");
- //if cache exists modify it, if not, then it will be correct when selected next, and we can skip this block
+ // if cache exists modify it, if not, then it will be correct when selected next, and we can skip this block
if ($Forum = $Cache->get_value('forums_'.$ForumID)) {
list($Forum,,,$Stickies) = $Forum;
- //if the topic is already on this page
+ // if the topic is already on this page
if (array_key_exists($TopicID, $Forum)) {
$Thread = $Forum[$TopicID];
unset($Forum[$TopicID]);
- $Thread['NumPosts'] = $Thread['NumPosts'] + 1; //Increment post count
- $Thread['LastPostID'] = $PostID; //Set postid for read/unread
- $Thread['LastPostTime'] = $SQLTime; //Time of last post
- $Thread['LastPostAuthorID'] = $LoggedUser['ID']; //Last poster id
- $Part2 = array($TopicID=>$Thread); //Bumped thread
+ $Thread['NumPosts'] = $Thread['NumPosts'] + 1; // Increment post count
+ $Thread['LastPostID'] = $PostID; // Set post ID for read/unread
+ $Thread['LastPostTime'] = $SQLTime; // Time of last post
+ $Thread['LastPostAuthorID'] = $LoggedUser['ID']; // Last poster ID
+ $Part2 = array($TopicID => $Thread); // Bumped thread
- //if we're bumping from an older page
+ // if we're bumping from an older page
} else {
- //Remove the last thread from the index
+ // Remove the last thread from the index
if (count($Forum) == TOPICS_PER_PAGE && $Stickies < TOPICS_PER_PAGE) {
array_pop($Forum);
}
- //Never know if we get a page full of stickies...
+ // Never know if we get a page full of stickies...
if ($Stickies < TOPICS_PER_PAGE || $ThreadInfo['IsSticky'] == 1) {
//Pull the data for the thread we're bumping
$DB->query("
@@ -216,7 +216,7 @@ if ($ThreadInfo['LastPostAuthorID'] == $LoggedUser['ID'] && ((!check_perms('site
} else {
$Forum = $Part1 + $Part2 + $Part3; //Merge it
}
- $Cache->cache_value('forums_'.$ForumID, array($Forum,'',0,$Stickies), 0);
+ $Cache->cache_value("forums_$ForumID", array($Forum, '', 0, $Stickies), 0);
//Update the forum root
$Cache->begin_transaction('forums_list');
@@ -241,7 +241,7 @@ if ($ThreadInfo['LastPostAuthorID'] == $LoggedUser['ID'] && ((!check_perms('site
$CatalogueID = floor((POSTS_PER_PAGE * ceil($ThreadInfo['Posts'] / POSTS_PER_PAGE) - POSTS_PER_PAGE) / THREAD_CATALOGUE);
//Insert the post into the thread catalogue (block of 500 posts)
- $Cache->begin_transaction('thread_'.$TopicID.'_catalogue_'.$CatalogueID);
+ $Cache->begin_transaction("thread_$TopicID"."_catalogue_$CatalogueID");
$Cache->insert('', array(
'ID'=>$PostID,
'AuthorID'=>$LoggedUser['ID'],
@@ -254,22 +254,25 @@ if ($ThreadInfo['LastPostAuthorID'] == $LoggedUser['ID'] && ((!check_perms('site
$Cache->commit_transaction(0);
//Update the thread info
- $Cache->begin_transaction('thread_'.$TopicID.'_info');
- $Cache->update_row(false, array('Posts'=>'+1', 'LastPostAuthorID'=>$LoggedUser['ID']));
+ $Cache->begin_transaction("thread_$TopicID".'_info');
+ $Cache->update_row(false, array('Posts' => '+1', 'LastPostAuthorID' => $LoggedUser['ID']));
$Cache->commit_transaction(0);
//Increment this now to make sure we redirect to the correct page
$ThreadInfo['Posts']++;
}
-$DB->query("SELECT UserID FROM users_subscriptions WHERE TopicID = ".$TopicID);
-if ($DB->record_count() > 0) {
+$DB->query("
+ SELECT UserID
+ FROM users_subscriptions
+ WHERE TopicID = $TopicID");
+if ($DB->has_results()) {
$Subscribers = $DB->collect('UserID');
foreach ($Subscribers as $Subscriber) {
- $Cache->delete_value('subscriptions_user_new_'.$Subscriber);
+ $Cache->delete_value("subscriptions_user_new_$Subscriber");
}
}
Forums::quote_notify($Body, $PostID, 'forums', $TopicID);
-header('Location: forums.php?action=viewthread&threadid='.$TopicID.'&page='.ceil($ThreadInfo['Posts'] / $PerPage));
+header("Location: forums.php?action=viewthread&threadid=$TopicID&page=".ceil($ThreadInfo['Posts'] / $PerPage));
die();
diff --git a/sections/forums/takeedit.php b/sections/forums/takeedit.php
index c3ed7eb..b4397b4 100644
--- a/sections/forums/takeedit.php
+++ b/sections/forums/takeedit.php
@@ -64,7 +64,7 @@ if ($UserID != $AuthorID && !check_perms('site_moderate_forums')) {
if ($LoggedUser['DisablePosting']) {
error('Your posting privileges have been removed.', true);
}
-if ($DB->record_count() == 0) {
+if (!$DB->has_results()) {
error(404,true);
}
diff --git a/sections/friends/add.php b/sections/friends/add.php
index 76d6850..9453845 100644
--- a/sections/friends/add.php
+++ b/sections/friends/add.php
@@ -1,4 +1,4 @@
-<?
+<?php
authorize();
if (!is_number($_GET['friendid'])) {
error(404);
@@ -6,14 +6,18 @@ if (!is_number($_GET['friendid'])) {
$FriendID = db_string($_GET['friendid']);
// Check if the user $FriendID exists
-$DB->query("SELECT 1 FROM users_main WHERE ID = '$FriendID'");
-if ($DB->record_count() == 0) {
+$DB->query("
+ SELECT 1
+ FROM users_main
+ WHERE ID = '$FriendID'");
+if (!$DB->has_results()) {
error(404);
}
$DB->query("
INSERT IGNORE INTO friends
(UserID, FriendID)
- VALUES ('$LoggedUser[ID]', '$FriendID')");
+ VALUES
+ ('$LoggedUser[ID]', '$FriendID')");
header('Location: friends.php');
diff --git a/sections/friends/friends.php b/sections/friends/friends.php
index 3409a6f..e5f543d 100644
--- a/sections/friends/friends.php
+++ b/sections/friends/friends.php
@@ -35,9 +35,9 @@ $DB->query("
m.LastAccess,
i.Avatar
FROM friends AS f
- JOIN users_main AS m ON f.FriendID=m.ID
- JOIN users_info AS i ON f.FriendID=i.UserID
- WHERE f.UserID='$UserID'
+ JOIN users_main AS m ON f.FriendID = m.ID
+ JOIN users_info AS i ON f.FriendID = i.UserID
+ WHERE f.UserID = '$UserID'
ORDER BY Username
LIMIT $Limit");
$Friends = $DB->to_array(false, MYSQLI_BOTH, array(6, 'Paranoia'));
diff --git a/sections/inbox/conversation.php b/sections/inbox/conversation.php
index 638b440..7b8337d 100644
--- a/sections/inbox/conversation.php
+++ b/sections/inbox/conversation.php
@@ -14,7 +14,7 @@ $DB->query("
FROM pm_conversations_users
WHERE UserID='$UserID'
AND ConvID='$ConvID'");
-if ($DB->record_count() == 0) {
+if (!$DB->has_results()) {
error(403);
}
list($InInbox, $InSentbox) = $DB->next_record();
diff --git a/sections/inbox/forward.php b/sections/inbox/forward.php
index 1dd0800..cd6cc8f 100644
--- a/sections/inbox/forward.php
+++ b/sections/inbox/forward.php
@@ -17,7 +17,7 @@ $DB->query("
AND InInbox='1'
AND (ForwardedTo=0 OR ForwardedTo=UserID)
AND ConvID='$ConvID'");
-if ($DB->record_count() == 0) {
+if (!$DB->has_results()) {
error(403);
}
@@ -28,7 +28,7 @@ $DB->query("
AND (ForwardedTo = 0 OR ForwardedTo = UserID)
AND InInbox='1'
AND ConvID='$ConvID'");
-if ($DB->record_count() == 0) {
+if (!$DB->has_results()) {
$DB->query("
INSERT IGNORE INTO pm_conversations_users
(UserID, ConvID, InInbox, InSentbox, ReceivedDate)
diff --git a/sections/inbox/inbox.php b/sections/inbox/inbox.php
index f09a8a6..8da7e9f 100644
--- a/sections/inbox/inbox.php
+++ b/sections/inbox/inbox.php
@@ -44,12 +44,12 @@ $sql = "
$sql .= (($Section == 'sentbox') ? ' cu.SentDate ' : ' cu.ReceivedDate ');
$sql .= "AS Date
FROM pm_conversations AS c
- LEFT JOIN pm_conversations_users AS cu ON cu.ConvID=c.ID AND cu.UserID='$UserID'
- LEFT JOIN pm_conversations_users AS cu2 ON cu2.ConvID=c.ID AND cu2.UserID!='$UserID' AND cu2.ForwardedTo=0
- LEFT JOIN users_main AS um ON um.ID=cu2.UserID";
+ LEFT JOIN pm_conversations_users AS cu ON cu.ConvID = c.ID AND cu.UserID = '$UserID'
+ LEFT JOIN pm_conversations_users AS cu2 ON cu2.ConvID = c.ID AND cu2.UserID != '$UserID' AND cu2.ForwardedTo = 0
+ LEFT JOIN users_main AS um ON um.ID = cu2.UserID";
if (!empty($_GET['search']) && $_GET['searchtype'] == 'message') {
- $sql .= ' JOIN pm_messages AS m ON c.ID=m.ConvID';
+ $sql .= ' JOIN pm_messages AS m ON c.ID = m.ConvID';
}
$sql .= ' WHERE ';
if (!empty($_GET['search'])) {
@@ -65,9 +65,9 @@ if (!empty($_GET['search'])) {
}
}
$sql .= (($Section == 'sentbox') ? ' cu.InSentbox' : ' cu.InInbox');
-$sql .= "='1'";
+$sql .= " = '1'";
-$sql .="
+$sql .= "
GROUP BY c.ID
ORDER BY cu.Sticky, $Sort
LIMIT $Limit";
@@ -105,8 +105,8 @@ echo "\t\t$Pages\n";
</span>
<br />
<input type="text" name="search" value="<?=(!empty($_GET['search']) ? display_str($_GET['search']) : 'Search '.($Section == 'sentbox' ? 'Sentbox' : 'Inbox'))?>" style="width: 98%;"
- onfocus="if (this.value == 'Search <?=(($Section == 'sentbox') ? 'Sentbox' : 'Inbox')?>') this.value='';"
- onblur="if (this.value == '') this.value='Search <?=(($Section == 'sentbox') ? 'Sentbox' : 'Inbox')?>';"
+ onfocus="if (this.value == 'Search <?=(($Section == 'sentbox') ? 'Sentbox' : 'Inbox')?>') { this.value = ''; }"
+ onblur="if (this.value == '') { this.value = 'Search <?=(($Section == 'sentbox') ? 'Sentbox' : 'Inbox')?>'; }"
/>
</div>
</form>
@@ -119,7 +119,7 @@ echo "\t\t$Pages\n";
<table class="message_table checkboxes">
<tr class="colhead">
- <td width="10"><input type="checkbox" onclick="toggleChecks('messageform',this)" /></td>
+ <td width="10"><input type="checkbox" onclick="toggleChecks('messageform', this);" /></td>
<td width="50%">Subject</td>
<td><?=(($Section == 'sentbox') ? 'Receiver' : 'Sender')?></td>
<td>Date</td>
diff --git a/sections/inbox/takecompose.php b/sections/inbox/takecompose.php
index 24ec64c..245d0e0 100644
--- a/sections/inbox/takecompose.php
+++ b/sections/inbox/takecompose.php
@@ -23,7 +23,7 @@ if (isset($_POST['convid']) && is_number($_POST['convid'])) {
FROM pm_conversations_users
WHERE UserID = '$LoggedUser[ID]'
AND ConvID = '$ConvID'");
- if ($DB->record_count() == 0) {
+ if (!$DB->has_results()) {
error(403);
}
} else {
diff --git a/sections/inbox/takeedit.php b/sections/inbox/takeedit.php
index a94cdd2..290b802 100644
--- a/sections/inbox/takeedit.php
+++ b/sections/inbox/takeedit.php
@@ -10,7 +10,7 @@ $DB->query("
SELECT UserID
FROM pm_conversations_users
WHERE UserID='$UserID' AND ConvID='$ConvID'");
-if ($DB->record_count() == 0) {
+if (!$DB->has_results()) {
error(403);
}
diff --git a/sections/index/private.php b/sections/index/private.php
index 3e1ca79..f39015f 100644
--- a/sections/index/private.php
+++ b/sections/index/private.php
@@ -1,4 +1,4 @@
-<?
+<?php
include(SERVER_ROOT.'/classes/text.class.php');
$Text = new TEXT(true);
@@ -12,14 +12,14 @@ if (!$News = $Cache->get_value('news')) {
Time
FROM news
ORDER BY Time DESC
- LIMIT " . $NewsCount);
+ LIMIT $NewsCount");
$News = $DB->to_array(false, MYSQLI_NUM, false);
$Cache->cache_value('news', $News, 3600 * 24 * 30);
$Cache->cache_value('news_latest_id', $News[0][0], 0);
}
if ($LoggedUser['LastReadNews'] != $News[0][0]) {
- $Cache->begin_transaction('user_info_heavy_'.$UserID);
+ $Cache->begin_transaction("user_info_heavy_$UserID");
$Cache->update_row(false, array('LastReadNews' => $News[0][0]));
$Cache->commit_transaction(0);
$DB->query("
@@ -29,7 +29,7 @@ if ($LoggedUser['LastReadNews'] != $News[0][0]) {
$LoggedUser['LastReadNews'] = $News[0][0];
}
-View::show_header('News','bbcode,news_ajax');
+View::show_header('News', 'bbcode,news_ajax');
?>
<div class="thin">
<div class="sidebar">
@@ -39,7 +39,6 @@ include('feat_album.php');
if (check_perms('users_mod')) {
?>
-
<div class="box">
<div class="head colhead_dark">
<strong><a href="staffblog.php">Latest staff blog posts</a></strong>
@@ -54,7 +53,7 @@ if (($Blog = $Cache->get_value('staff_blog')) === false) {
b.Body,
b.Time
FROM staff_blog AS b
- LEFT JOIN users_main AS um ON b.UserID=um.ID
+ LEFT JOIN users_main AS um ON b.UserID = um.ID
ORDER BY Time DESC");
$Blog = $DB->to_array(false, MYSQLI_NUM);
$Cache->cache_value('staff_blog', $Blog, 1209600);
@@ -141,7 +140,10 @@ for ($i = 0; $i < $Limit; $i++) {
}
if (($UserCount = $Cache->get_value('stats_user_count')) === false) {
- $DB->query("SELECT COUNT(ID) FROM users_main WHERE Enabled='1'");
+ $DB->query("
+ SELECT COUNT(ID)
+ FROM users_main
+ WHERE Enabled = '1'");
list($UserCount) = $DB->next_record();
$Cache->cache_value('stats_user_count', $UserCount, 0); //inf cache
}
@@ -151,37 +153,56 @@ $UserCount = (int)$UserCount;
<?
if (($UserStats = $Cache->get_value('stats_users')) === false) {
- $DB->query("SELECT COUNT(ID) FROM users_main WHERE Enabled='1' AND LastAccess>'".time_minus(3600 * 24)."'");
+ $DB->query("
+ SELECT COUNT(ID)
+ FROM users_main
+ WHERE Enabled = '1'
+ AND LastAccess > '".time_minus(3600 * 24)."'");
list($UserStats['Day']) = $DB->next_record();
- $DB->query("SELECT COUNT(ID) FROM users_main WHERE Enabled='1' AND LastAccess>'".time_minus(3600 * 24 * 7)."'");
+ $DB->query("
+ SELECT COUNT(ID)
+ FROM users_main
+ WHERE Enabled = '1'
+ AND LastAccess > '".time_minus(3600 * 24 * 7)."'");
list($UserStats['Week']) = $DB->next_record();
- $DB->query("SELECT COUNT(ID) FROM users_main WHERE Enabled='1' AND LastAccess>'".time_minus(3600 * 24 * 30)."'");
+ $DB->query("
+ SELECT COUNT(ID)
+ FROM users_main
+ WHERE Enabled = '1'
+ AND LastAccess > '".time_minus(3600 * 24 * 30)."'");
list($UserStats['Month']) = $DB->next_record();
- $Cache->cache_value('stats_users',$UserStats,0);
+ $Cache->cache_value('stats_users', $UserStats, 0);
}
?>
- <li>Users active today: <?=number_format($UserStats['Day'])?> (<?=number_format($UserStats['Day'] / $UserCount * 100,2)?>%)</li>
- <li>Users active this week: <?=number_format($UserStats['Week'])?> (<?=number_format($UserStats['Week'] / $UserCount * 100,2)?>%)</li>
- <li>Users active this month: <?=number_format($UserStats['Month'])?> (<?=number_format($UserStats['Month'] / $UserCount * 100,2)?>%)</li>
+ <li>Users active today: <?=number_format($UserStats['Day'])?> (<?=number_format($UserStats['Day'] / $UserCount * 100, 2)?>%)</li>
+ <li>Users active this week: <?=number_format($UserStats['Week'])?> (<?=number_format($UserStats['Week'] / $UserCount * 100, 2)?>%)</li>
+ <li>Users active this month: <?=number_format($UserStats['Month'])?> (<?=number_format($UserStats['Month'] / $UserCount * 100, 2)?>%)</li>
<?
if (($TorrentCount = $Cache->get_value('stats_torrent_count')) === false) {
- $DB->query("SELECT COUNT(ID) FROM torrents");
+ $DB->query("
+ SELECT COUNT(ID)
+ FROM torrents");
list($TorrentCount) = $DB->next_record();
$Cache->cache_value('stats_torrent_count', $TorrentCount, 0); //inf cache
}
if (($AlbumCount = $Cache->get_value('stats_album_count')) === false) {
- $DB->query("SELECT COUNT(ID) FROM torrents_group WHERE CategoryID='1'");
+ $DB->query("
+ SELECT COUNT(ID)
+ FROM torrents_group
+ WHERE CategoryID = '1'");
list($AlbumCount) = $DB->next_record();
$Cache->cache_value('stats_album_count', $AlbumCount, 0); //inf cache
}
if (($ArtistCount = $Cache->get_value('stats_artist_count')) === false) {
- $DB->query("SELECT COUNT(ArtistID) FROM artists_group");
+ $DB->query("
+ SELECT COUNT(ArtistID)
+ FROM artists_group");
list($ArtistCount) = $DB->next_record();
$Cache->cache_value('stats_artist_count', $ArtistCount, 0); //inf cache
}
@@ -219,7 +240,7 @@ if (($RequestStats = $Cache->get_value('stats_requests')) === false) {
list($FilledCount) = $DB->next_record();
$Cache->cache_value('stats_requests', array($RequestCount, $FilledCount), 11280);
} else {
- list($RequestCount,$FilledCount) = $RequestStats;
+ list($RequestCount, $FilledCount) = $RequestStats;
}
?>
@@ -240,17 +261,17 @@ if (($PeerStats = $Cache->get_value('stats_peers')) === false) {
$DB->query("
SELECT IF(remaining=0,'Seeding','Leeching') AS Type, COUNT(uid)
FROM xbt_files_users
- WHERE active=1
+ WHERE active = 1
GROUP BY Type");
$PeerCount = $DB->to_array(0, MYSQLI_NUM, false);
$SeederCount = $PeerCount['Seeding'][1] ?: 0;
$LeecherCount = $PeerCount['Leeching'][1] ?: 0;
- $Cache->cache_value('stats_peers', array($LeecherCount,$SeederCount), 0);
+ $Cache->cache_value('stats_peers', array($LeecherCount, $SeederCount), 0);
$Cache->delete_value('stats_peers_lock');
}
} else {
$PeerStatsLocked = false;
- list($LeecherCount,$SeederCount) = $PeerStats;
+ list($LeecherCount, $SeederCount) = $PeerStats;
}
if (!$PeerStatsLocked) {
@@ -305,7 +326,7 @@ if ($TopicID) {
$Votes[$i] = 0;
}
}
- $Cache->cache_value('polls_'.$TopicID, array($Question, $Answers, $Votes, $Featured, $Closed), 0);
+ $Cache->cache_value("polls_$TopicID", array($Question, $Answers, $Votes, $Featured, $Closed), 0);
} else {
list($Question, $Answers, $Votes, $Featured, $Closed) = $Poll;
}
@@ -321,8 +342,8 @@ if ($TopicID) {
$DB->query("
SELECT Vote
FROM forums_polls_votes
- WHERE UserID='".$LoggedUser['ID']."'
- AND TopicID='$TopicID'");
+ WHERE UserID = '".$LoggedUser['ID']."'
+ AND TopicID = '$TopicID'");
list($UserResponse) = $DB->next_record();
if (!empty($UserResponse) && $UserResponse != 0) {
$Answers[$UserResponse] = '&raquo; '.$Answers[$UserResponse];
@@ -364,7 +385,7 @@ if ($TopicID) {
<label for="answer_<?=$i?>"><?=display_str($Answers[$i])?></label><br />
<? } ?>
<br /><input type="radio" name="vote" id="answer_0" value="0" /> <label for="answer_0">Blank&#8202;&mdash;&#8202;Show the results!</label><br /><br />
- <input type="button" onclick="ajax.post('index.php','poll',function(response) {$('#poll_container').raw().innerHTML = response});" value="Vote" />
+ <input type="button" onclick="ajax.post('index.php', 'poll', function(response) { $('#poll_container').raw().innerHTML = response } );" value="Vote" />
</form>
</div>
<? } ?>
@@ -391,8 +412,8 @@ if (!is_array($Recommend) || !is_array($Recommend_artists)) {
tg.Name,
tg.TagList
FROM torrents_recommended AS tr
- JOIN torrents_group AS tg ON tg.ID=tr.GroupID
- LEFT JOIN users_main AS u ON u.ID=tr.UserID
+ JOIN torrents_group AS tg ON tg.ID = tr.GroupID
+ LEFT JOIN users_main AS u ON u.ID = tr.UserID
ORDER BY tr.Time DESC
LIMIT 10");
$Recommend = $DB->to_array();
@@ -444,7 +465,7 @@ $Cache->increment('usage_index');
}
$Count = 0;
foreach ($News as $NewsItem) {
- list($NewsID,$Title,$Body,$NewsTime) = $NewsItem;
+ list($NewsID, $Title, $Body, $NewsTime) = $NewsItem;
if (strtotime($NewsTime) > time()) {
continue;
}
@@ -487,16 +508,18 @@ function contest() {
SUM(Points),
Username
FROM users_points AS up
- JOIN users_main AS um ON um.ID=up.UserID
+ JOIN users_main AS um ON um.ID = up.UserID
GROUP BY UserID
ORDER BY SUM(Points) DESC
LIMIT 20");
$Contest = $DB->to_array();
- $DB->query("SELECT SUM(Points) FROM users_points");
+ $DB->query("
+ SELECT SUM(Points)
+ FROM users_points");
list($TotalPoints) = $DB->next_record();
- $Cache->cache_value('contest', array($Contest,$TotalPoints), 600);
+ $Cache->cache_value('contest', array($Contest, $TotalPoints), 600);
}
?>
@@ -510,9 +533,7 @@ function contest() {
list($UserID, $Points, $Username) = $User;
?>
<li><?=Users::format_username($UserID, false, false, false)?> (<?=number_format($Points)?>)</li>
-<?
- }
-?>
+<? } ?>
</ol>
Total uploads: <?=$TotalPoints?><br />
<a href="index.php?action=scoreboard">Full scoreboard</a>
@@ -520,5 +541,4 @@ function contest() {
</div>
<!-- END contest Section -->
<? } // contest()
-
?>
diff --git a/sections/log/index.php b/sections/log/index.php
index e21a849..f322ad4 100644
--- a/sections/log/index.php
+++ b/sections/log/index.php
@@ -40,7 +40,7 @@ include(SERVER_ROOT.'/sections/log/sphinx.php');
</tr>
<? if ($QueryStatus) { ?>
<tr class="nobr"><td colspan="2">Search request failed (<?=$QueryError?>).</td></tr>
-<? } elseif ($DB->record_count() == 0) { ?>
+<? } elseif (!$DB->has_results()) { ?>
<tr class="nobr"><td colspan="2">Nothing found!</td></tr>
<?
}
diff --git a/sections/log/sphinx.php b/sections/log/sphinx.php
index 7f75432..ae0ca6b 100644
--- a/sections/log/sphinx.php
+++ b/sections/log/sphinx.php
@@ -1,4 +1,4 @@
-<?
+<?php
if (!empty($_GET['page']) && is_number($_GET['page'])) {
$Page = min(SPHINX_MAX_MATCHES / LOG_ENTRIES_PER_PAGE, $_GET['page']);
$Offset = ($Page - 1) * LOG_ENTRIES_PER_PAGE;
@@ -7,7 +7,11 @@ if (!empty($_GET['page']) && is_number($_GET['page'])) {
$Offset = 0;
}
if (empty($_GET['search']) || trim($_GET['search']) == '') {
- $Log = $DB->query("SELECT ID, Message, Time FROM log ORDER BY ID DESC LIMIT $Offset, ".LOG_ENTRIES_PER_PAGE);
+ $Log = $DB->query("
+ SELECT ID, Message, Time
+ FROM log
+ ORDER BY ID DESC
+ LIMIT $Offset, ".LOG_ENTRIES_PER_PAGE);
$NumResults = $DB->record_count();
if (!$NumResults) {
$TotalMatches = 0;
@@ -40,8 +44,13 @@ if (empty($_GET['search']) || trim($_GET['search']) == '') {
$TotalMatches = min(SPHINX_MAX_MATCHES, $Result->get_meta('total_found'));
if ($NumResults > 0) {
$LogIDs = $Result->collect('id');
- $Log = $DB->query("SELECT ID, Message, Time FROM log WHERE ID IN (".implode(',', $LogIDs).") ORDER BY ID DESC");
+ $Log = $DB->query('
+ SELECT ID, Message, Time
+ FROM log
+ WHERE ID IN ('.implode(',', $LogIDs).')
+ ORDER BY ID DESC');
} else {
- $Log = $DB->query("SET @nothing = 0");
+ $Log = $DB->query('
+ SET @nothing = 0');
}
}
diff --git a/sections/login/index.php b/sections/login/index.php
index 2d51ed7..e455530 100644
--- a/sections/login/index.php
+++ b/sections/login/index.php
@@ -1,4 +1,4 @@
-<?
+<?php
/*-- TODO ---------------------------//
Add the JavaScript validation into the display page using the class
@@ -37,10 +37,10 @@ if (isset($_REQUEST['act']) && $_REQUEST['act'] == 'recover') {
m.ipcc,
i.ResetExpires
FROM users_main AS m
- INNER JOIN users_info AS i ON i.UserID=m.ID
- WHERE i.ResetKey='".db_string($_REQUEST['key'])."'
+ INNER JOIN users_info AS i ON i.UserID = m.ID
+ WHERE i.ResetKey = '".db_string($_REQUEST['key'])."'
AND i.ResetKey != ''
- AND m.Enabled='1'");
+ AND m.Enabled = '1'");
list($UserID, $Email, $Country, $Expires) = $DB->next_record();
if ($UserID && strtotime($Expires) > time()) {
@@ -59,11 +59,11 @@ if (isset($_REQUEST['act']) && $_REQUEST['act'] == 'recover') {
users_main AS m,
users_info AS i
SET
- m.PassHash='".db_string(Users::make_crypt_hash($_REQUEST['password']))."',
- i.ResetKey='',
- i.ResetExpires='0000-00-00 00:00:00'
- WHERE m.ID='".db_string($UserID)."'
- AND i.UserID=m.ID");
+ m.PassHash = '".db_string(Users::make_crypt_hash($_REQUEST['password']))."',
+ i.ResetKey = '',
+ i.ResetExpires = '0000-00-00 00:00:00'
+ WHERE m.ID = '".db_string($UserID)."'
+ AND i.UserID = m.ID");
$Reset = true; // Past tense form of "to reset", meaning that password has now been reset
@@ -81,9 +81,9 @@ if (isset($_REQUEST['act']) && $_REQUEST['act'] == 'recover') {
// If his key has expired, clear all the reset information
$DB->query("
UPDATE users_info
- SET ResetKey='',
- ResetExpires='0000-00-00 00:00:00'
- WHERE UserID='$UserID'");
+ SET ResetKey = '',
+ ResetExpires = '0000-00-00 00:00:00'
+ WHERE UserID = '$UserID'");
$_SESSION['reseterr'] = 'The link you were given has expired.'; // Error message to display on form
}
// Show him the first form (enter email address)
@@ -137,17 +137,17 @@ if (isset($_REQUEST['act']) && $_REQUEST['act'] == 'recover') {
$Sent = 1; // If $Sent is 1, recover_step1.php displays a success message
//Log out all of the users current sessions
- $Cache->delete_value('user_info_'.$UserID);
- $Cache->delete_value('user_info_heavy_'.$UserID);
- $Cache->delete_value('user_stats_'.$UserID);
- $Cache->delete_value('enabled_'.$UserID);
+ $Cache->delete_value("user_info_$UserID");
+ $Cache->delete_value("user_info_heavy_$UserID");
+ $Cache->delete_value("user_stats_$UserID");
+ $Cache->delete_value("enabled_$UserID");
$DB->query("
SELECT SessionID
FROM users_sessions
- WHERE UserID='$UserID'");
+ WHERE UserID = '$UserID'");
while (list($SessionID) = $DB->next_record()) {
- $Cache->delete_value('session_'.$UserID.'_'.$SessionID);
+ $Cache->delete_value("session_$UserID"."_$SessionID");
}
$DB->query("
UPDATE users_sessions
@@ -199,29 +199,35 @@ else {
$DB->query("
UPDATE login_attempts
SET
- LastAttempt='".sqltime()."',
- Attempts='".db_string($Attempts)."',
- BannedUntil='".db_string($BannedUntil)."',
- Bans=Bans+1
- WHERE ID='".db_string($AttemptID)."'");
+ LastAttempt = '".sqltime()."',
+ Attempts = '".db_string($Attempts)."',
+ BannedUntil = '".db_string($BannedUntil)."',
+ Bans = Bans + 1
+ WHERE ID = '".db_string($AttemptID)."'");
if ($Bans > 9) { // Automated bruteforce prevention
- $DB->query("SELECT Reason FROM ip_bans WHERE ".$IP." BETWEEN FromIP AND ToIP");
- if ($DB->record_count() > 0) {
+ $DB->query("
+ SELECT Reason
+ FROM ip_bans
+ WHERE $IP BETWEEN FromIP AND ToIP");
+ if ($DB->has_results()) {
//Ban exists already, only add new entry if not for same reason
list($Reason) = $DB->next_record(MYSQLI_BOTH, false);
if ($Reason != 'Automated ban per >60 failed login attempts') {
$DB->query("
UPDATE ip_bans
SET Reason = CONCAT('Automated ban per >60 failed login attempts AND ', Reason)
- WHERE FromIP = $IP AND ToIP = $IP");
+ WHERE FromIP = $IP
+ AND ToIP = $IP");
}
} else {
//No ban
$DB->query("
- INSERT IGNORE INTO ip_bans (FromIP, ToIP, Reason)
- VALUES ('$IP','$IP', 'Automated ban per >60 failed login attempts')");
- $Cache->delete_value('ip_bans_'.$IPA);
+ INSERT IGNORE INTO ip_bans
+ (FromIP, ToIP, Reason)
+ VALUES
+ ('$IP','$IP', 'Automated ban per >60 failed login attempts')");
+ $Cache->delete_value("ip_bans_$IPA");
}
}
} else {
@@ -229,16 +235,18 @@ else {
$DB->query("
UPDATE login_attempts
SET
- LastAttempt='".sqltime()."',
- Attempts='".db_string($Attempts)."',
- BannedUntil='0000-00-00 00:00:00'
- WHERE ID='".db_string($AttemptID)."'");
+ LastAttempt = '".sqltime()."',
+ Attempts = '".db_string($Attempts)."',
+ BannedUntil = '0000-00-00 00:00:00'
+ WHERE ID = '".db_string($AttemptID)."'");
}
} else { // User has not attempted to log in recently
$Attempts = 1;
$DB->query("
- INSERT INTO login_attempts (UserID,IP,LastAttempt,Attempts)
- VALUES ('".db_string($UserID)."','".db_string($IPStr)."','".sqltime()."',1)");
+ INSERT INTO login_attempts
+ (UserID, IP, LastAttempt, Attempts)
+ VALUES
+ ('".db_string($UserID)."', '".db_string($IPStr)."', '".sqltime()."', 1)");
}
} // end log_attempt function
@@ -261,7 +269,7 @@ else {
Secret,
Enabled
FROM users_main
- WHERE Username='".db_string($_POST['username'])."'
+ WHERE Username = '".db_string($_POST['username'])."'
AND Username != ''");
list($UserID, $PermissionID, $CustomPermissions, $PassHash, $Secret, $Enabled) = $DB->next_record(MYSQLI_NUM, array(2));
if (strtotime($BannedUntil) < time()) {
@@ -300,33 +308,33 @@ else {
INSERT INTO users_sessions
(UserID, SessionID, KeepLogged, Browser, OperatingSystem, IP, LastUpdate, FullUA)
VALUES
- ('$UserID', '".db_string($SessionID)."', '$KeepLogged', '$Browser','$OperatingSystem', '".db_string($_SERVER['REMOTE_ADDR'])."', '".sqltime()."', '".db_string($_SERVER['HTTP_USER_AGENT'])."')");
-
- $Cache->begin_transaction('users_sessions_'.$UserID);
- $Cache->insert_front($SessionID,array(
- 'SessionID'=>$SessionID,
- 'Browser'=>$Browser,
- 'OperatingSystem'=>$OperatingSystem,
- 'IP'=>$_SERVER['REMOTE_ADDR'],
- 'LastUpdate'=>sqltime()
+ ('$UserID', '".db_string($SessionID)."', '$KeepLogged', '$Browser', '$OperatingSystem', '".db_string($_SERVER['REMOTE_ADDR'])."', '".sqltime()."', '".db_string($_SERVER['HTTP_USER_AGENT'])."')");
+
+ $Cache->begin_transaction("users_sessions_$UserID");
+ $Cache->insert_front($SessionID, array(
+ 'SessionID' => $SessionID,
+ 'Browser' => $Browser,
+ 'OperatingSystem' => $OperatingSystem,
+ 'IP' => $_SERVER['REMOTE_ADDR'],
+ 'LastUpdate' => sqltime()
));
$Cache->commit_transaction(0);
$Sql = "
UPDATE users_main
SET
- LastLogin='".sqltime()."',
- LastAccess='".sqltime()."'";
+ LastLogin = '".sqltime()."',
+ LastAccess = '".sqltime()."'";
$Sql .= "
- WHERE ID='".db_string($UserID)."'";
+ WHERE ID = '".db_string($UserID)."'";
$DB->query($Sql);
if (!empty($_COOKIE['redirect'])) {
$URL = $_COOKIE['redirect'];
setcookie('redirect', '', time() - 60 * 60 * 24, '/', '', false);
- header('Location: '.$URL);
+ header("Location: $URL");
die();
} else {
header('Location: index.php');
diff --git a/sections/peerupdate/index.php b/sections/peerupdate/index.php
index 84118b8..dbfbb2b 100644
--- a/sections/peerupdate/index.php
+++ b/sections/peerupdate/index.php
@@ -17,17 +17,34 @@ gc_enable();
$Cache->InternalCache = false; // We don't want PHP to cache all results internally
$DB->query("TRUNCATE TABLE torrents_peerlists_compare");
-$DB->query("INSERT INTO torrents_peerlists_compare
- SELECT ID, GroupID, Seeders, Leechers, Snatched FROM torrents
- ON DUPLICATE KEY UPDATE Seeders=VALUES(Seeders), Leechers=VALUES(Leechers), Snatches=VALUES(Snatches)");
-$DB->query("CREATE TEMPORARY TABLE tpc_temp
- (TorrentID int, GroupID int, Seeders int, Leechers int, Snatched int,
- PRIMARY KEY (GroupID,TorrentID))");
-$DB->query("INSERT INTO tpc_temp SELECT t2.* FROM torrents_peerlists t1 JOIN torrents_peerlists_compare t2 USING(TorrentID)
- WHERE t1.Seeders != t2.Seeders OR t1.Leechers != t2.Leechers OR t1.Snatches != t2.Snatches");
+$DB->query("
+ INSERT INTO torrents_peerlists_compare
+ SELECT ID, GroupID, Seeders, Leechers, Snatched
+ FROM torrents
+ ON DUPLICATE KEY UPDATE
+ Seeders = VALUES(Seeders),
+ Leechers = VALUES(Leechers),
+ Snatches = VALUES(Snatches)");
+$DB->query("
+ CREATE TEMPORARY TABLE tpc_temp
+ (TorrentID int, GroupID int, Seeders int, Leechers int, Snatched int,
+ PRIMARY KEY (GroupID, TorrentID))");
+$DB->query("
+ INSERT INTO tpc_temp
+ SELECT t2.*
+ FROM torrents_peerlists t1
+ JOIN torrents_peerlists_compare t2
+ USING(TorrentID)
+ WHERE t1.Seeders != t2.Seeders
+ OR t1.Leechers != t2.Leechers
+ OR t1.Snatches != t2.Snatches");
$StepSize = 30000;
-$DB->query("SELECT * FROM tpc_temp ORDER BY GroupID ASC, TorrentID ASC LIMIT $StepSize");
+$DB->query("
+ SELECT *
+ FROM tpc_temp
+ ORDER BY GroupID ASC, TorrentID ASC
+ LIMIT $StepSize");
$RowNum = 0;
$LastGroupID = 0;
@@ -35,7 +52,7 @@ $UpdatedKeys = $UncachedGroups = 0;
list($TorrentID, $GroupID, $Seeders, $Leechers, $Snatches) = $DB->next_record(MYSQLI_NUM, false);
while ($TorrentID) {
if ($LastGroupID != $GroupID) {
- $CachedData = $Cache->get_value('torrent_group_'.$GroupID);
+ $CachedData = $Cache->get_value("torrent_group_$GroupID");
if ($CachedData !== false) {
if (isset($CachedData['ver']) && $CachedData['ver'] == CACHE::GROUP_VERSION) {
$CachedStats = &$CachedData['d']['Torrents'];
@@ -56,23 +73,31 @@ while ($TorrentID) {
unset($OldValues);
}
if (!($RowNum % $StepSize)) {
- $DB->query("SELECT * FROM tpc_temp WHERE GroupID > $GroupID OR (GroupID = $GroupID AND TorrentID > $TorrentID)
- ORDER BY GroupID ASC, TorrentID ASC LIMIT $StepSize");
+ $DB->query("
+ SELECT *
+ FROM tpc_temp
+ WHERE GroupID > $GroupID
+ OR (GroupID = $GroupID AND TorrentID > $TorrentID)
+ ORDER BY GroupID ASC, TorrentID ASC
+ LIMIT $StepSize");
}
$LastGroupID = $GroupID;
list($TorrentID, $GroupID, $Seeders, $Leechers, $Snatches) = $DB->next_record(MYSQLI_NUM, false);
}
if ($Changed) {
- $Cache->cache_value('torrent_group_'.$LastGroupID, $CachedData, 0);
+ $Cache->cache_value("torrent_group_$LastGroupID", $CachedData, 0);
unset($CachedStats);
$UpdatedKeys++;
$Changed = false;
}
}
-printf("Updated %d keys, skipped %d keys in %.6fs (%d kB memory)\n", $UpdatedKeys, $UncachedGroups, microtime(true)-$ScriptStartTime, memory_get_usage(true)>>10);
+printf("Updated %d keys, skipped %d keys in %.6fs (%d kB memory)\n", $UpdatedKeys, $UncachedGroups, microtime(true) - $ScriptStartTime, memory_get_usage(true) >> 10);
$DB->query("TRUNCATE TABLE torrents_peerlists");
-$DB->query("INSERT INTO torrents_peerlists SELECT * FROM torrents_peerlists_compare");
+$DB->query("
+ INSERT INTO torrents_peerlists
+ SELECT *
+ FROM torrents_peerlists_compare");
if (check_perms('admin_schedule')) {
echo '<pre>';
diff --git a/sections/register/index.php b/sections/register/index.php
index e002a66..0a0f400 100644
--- a/sections/register/index.php
+++ b/sections/register/index.php
@@ -71,7 +71,7 @@ if (!empty($_REQUEST['confirm'])) {
SELECT InviterID, Email
FROM invites
WHERE InviteKey = '".db_string($_REQUEST['invite'])."'");
- if ($DB->record_count() == 0) {
+ if (!$DB->has_results()) {
$Err = 'Invite does not exist.';
$InviterID = 0;
} else {
@@ -164,7 +164,7 @@ if (!empty($_REQUEST['confirm'])) {
// If the inviter doesn't have an invite tree
// Note: This should never happen unless you've transferred from another database, like What.CD did
- if ($DB->record_count() == 0) {
+ if (!$DB->has_results()) {
$DB->query("
SELECT MAX(TreeID) + 1
FROM invite_tree");
@@ -244,7 +244,7 @@ if (!empty($_REQUEST['confirm'])) {
SELECT InviteKey
FROM invites
WHERE InviteKey = '".db_string($_GET['invite'])."'");
- if ($DB->record_count() == 0) {
+ if (!$DB->has_results()) {
error('Invite not found!');
}
}
diff --git a/sections/reports/compose.php b/sections/reports/compose.php
index 39964e7..270d999 100644
--- a/sections/reports/compose.php
+++ b/sections/reports/compose.php
@@ -44,7 +44,7 @@ switch ($Type) {
SELECT Username
FROM users_main
WHERE ID=$ThingID");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
$Error = 'No user with the reported ID found';
} else {
list($Username) = $DB->next_record();
@@ -58,7 +58,7 @@ switch ($Type) {
SELECT Title
FROM requests
WHERE ID=$ThingID");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
$Error = 'No request with the reported ID found';
} else {
list($Name) = $DB->next_record();
@@ -71,7 +71,7 @@ switch ($Type) {
SELECT Name
FROM collages
WHERE ID=$ThingID");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
$Error = 'No collage with the reported ID found';
} else {
list($Name) = $DB->next_record();
@@ -84,7 +84,7 @@ switch ($Type) {
SELECT Title
FROM forums_topics
WHERE ID=$ThingID");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
$Error = 'No forum thread with the reported ID found';
} else {
list($Title) = $DB->next_record();
@@ -110,7 +110,7 @@ switch ($Type) {
) AS PostNum
FROM forums_posts AS p
WHERE ID=$ThingID");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
$Error = 'No forum post with the reported ID found';
} else {
list($PostID, $Body, $TopicID, $PostNum) = $DB->next_record();
@@ -130,7 +130,7 @@ switch ($Type) {
) AS CommentNum
FROM requests_comments AS rc
WHERE ID=$ThingID");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
$Error = 'No request comment with the reported ID found';
} else {
list($RequestID, $Body, $PostNum) = $DB->next_record();
@@ -151,7 +151,7 @@ switch ($Type) {
) AS CommentNum
FROM torrents_comments AS tc
WHERE ID=$ThingID");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
$Error = 'No torrent comment with the reported ID found';
} else {
list($GroupID, $Body, $PostNum) = $DB->next_record();
@@ -172,7 +172,7 @@ switch ($Type) {
) AS CommentNum
FROM collages_comments AS cc
WHERE ID=$ThingID");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
$Error = 'No collage comment with the reported ID found';
} else {
list($CollageID, $Body, $PostNum) = $DB->next_record();
diff --git a/sections/reports/report.php b/sections/reports/report.php
index 04677cf..234cbb0 100644
--- a/sections/reports/report.php
+++ b/sections/reports/report.php
@@ -20,7 +20,7 @@ switch ($Short) {
SELECT Username
FROM users_main
WHERE ID = $ID");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
error(404);
}
list($Username) = $DB->next_record();
@@ -32,7 +32,7 @@ switch ($Short) {
SELECT Title, Description, TorrentID, CategoryID, Year
FROM requests
WHERE ID = $ID");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
error(404);
}
list($Name, $Desc, $Filled, $CategoryID, $Year) = $DB->next_record();
@@ -46,7 +46,7 @@ switch ($Short) {
SELECT Title, Description, TorrentID
FROM requests
WHERE ID = $ID");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
error(404);
}
list($Name, $Desc, $Filled) = $DB->next_record();
@@ -57,7 +57,7 @@ switch ($Short) {
SELECT Name, Description
FROM collages
WHERE ID = $ID");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
error(404);
}
list($Name, $Desc) = $DB->next_record();
@@ -69,7 +69,7 @@ switch ($Short) {
FROM forums_topics AS ft
JOIN users_main AS um ON um.ID = ft.AuthorID
WHERE ft.ID = $ID");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
error(404);
}
list($Title, $ForumID, $Username) = $DB->next_record();
@@ -91,7 +91,7 @@ switch ($Short) {
FROM forums_posts AS fp
JOIN users_main AS um ON um.ID = fp.AuthorID
WHERE fp.ID = $ID");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
error(404);
}
list($Body, $TopicID, $Username) = $DB->next_record();
@@ -127,7 +127,7 @@ switch ($Short) {
FROM $Table AS $Short
JOIN users_main AS um ON um.ID = $Short.$Column
WHERE $Short.ID = $ID");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
error(404);
}
list($Body, $Username) = $DB->next_record();
diff --git a/sections/reports/reports.php b/sections/reports/reports.php
index 23889a3..3c5970a 100644
--- a/sections/reports/reports.php
+++ b/sections/reports/reports.php
@@ -113,7 +113,7 @@ $DB->set_query_id($Reports);
SELECT Username
FROM users_main
WHERE ID = $ThingID");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
echo 'No user with the reported ID found';
} else {
list($Username) = $DB->next_record();
@@ -126,7 +126,7 @@ $DB->set_query_id($Reports);
SELECT Title
FROM requests
WHERE ID = $ThingID");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
echo 'No request with the reported ID found';
} else {
list($Name) = $DB->next_record();
@@ -138,7 +138,7 @@ $DB->set_query_id($Reports);
SELECT Name
FROM collages
WHERE ID = $ThingID");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
echo 'No collage with the reported ID found';
} else {
list($Name) = $DB->next_record();
@@ -150,7 +150,7 @@ $DB->set_query_id($Reports);
SELECT Title
FROM forums_topics
WHERE ID = $ThingID");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
echo 'No forum thread with the reported ID found';
} else {
list($Title) = $DB->next_record();
@@ -175,7 +175,7 @@ $DB->set_query_id($Reports);
) AS PostNum
FROM forums_posts AS p
WHERE ID = $ThingID");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
echo 'No forum post with the reported ID found';
} else {
list($PostID, $Body, $TopicID, $PostNum) = $DB->next_record();
@@ -194,7 +194,7 @@ $DB->set_query_id($Reports);
) AS CommentNum
FROM requests_comments AS rc
WHERE ID = $ThingID");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
echo 'No request comment with the reported ID found';
} else {
list($RequestID, $Body, $PostNum) = $DB->next_record();
@@ -214,7 +214,7 @@ $DB->set_query_id($Reports);
) AS CommentNum
FROM torrents_comments AS tc
WHERE ID = $ThingID");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
echo 'No torrent comment with the reported ID found';
} else {
list($GroupID, $Body, $PostNum) = $DB->next_record();
@@ -234,7 +234,7 @@ $DB->set_query_id($Reports);
) AS CommentNum
FROM artist_comments AS ac
WHERE ID = $ThingID");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
echo 'No comment with the reported ID found';
} else {
list($ArtistID, $Body, $PostNum) = $DB->next_record();
@@ -255,7 +255,7 @@ $DB->set_query_id($Reports);
) AS CommentNum
FROM collages_comments AS cc
WHERE ID = $ThingID");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
echo 'No collage comment with the reported ID found';
} else {
list($CollageID, $Body, $PostNum) = $DB->next_record();
diff --git a/sections/reports/takecompose.php b/sections/reports/takecompose.php
index a285858..3e72a1e 100644
--- a/sections/reports/takecompose.php
+++ b/sections/reports/takecompose.php
@@ -25,7 +25,7 @@ if (isset($_POST['convid']) && is_number($_POST['convid'])) {
FROM pm_conversations_users
WHERE UserID = '$LoggedUser[ID]'
AND ConvID = '$ConvID'");
- if ($DB->record_count() == 0) {
+ if (!$DB->has_results()) {
error(403);
}
} else {
diff --git a/sections/reportsv2/ajax_create_report.php b/sections/reportsv2/ajax_create_report.php
index 4a659d3..abe6298 100644
--- a/sections/reportsv2/ajax_create_report.php
+++ b/sections/reportsv2/ajax_create_report.php
@@ -28,7 +28,7 @@ $DB->query("
FROM torrents_group AS tg
JOIN torrents AS t ON t.GroupID=tg.ID
WHERE t.ID = ".$TorrentID);
-if ($DB->record_count() < 1) {
+if (!$DB->has_results()) {
$Err = 'No torrent with that ID exists!';
} else {
list($CategoryID) = $DB->next_record();
@@ -69,7 +69,7 @@ $DB->query("
WHERE TorrentID=$TorrentID
AND ReporterID=".db_string($LoggedUser['ID'])."
AND ReportedTime > '".time_minus(3)."'");
-if ($DB->record_count() > 0) {
+if ($DB->has_results()) {
die();
}
diff --git a/sections/reportsv2/ajax_new_report.php b/sections/reportsv2/ajax_new_report.php
index 9f8284b..e5af0bf 100644
--- a/sections/reportsv2/ajax_new_report.php
+++ b/sections/reportsv2/ajax_new_report.php
@@ -72,7 +72,7 @@ $DB->query("
ORDER BY ReportedTime ASC
LIMIT 1");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
die();
}
@@ -202,7 +202,7 @@ $DB->query("
WHERE rep.Status != 'Resolved'
AND req.TimeFilled > '2010-03-04 02:31:49'
AND req.TorrentID=$TorrentID");
- $Requests = ($DB->record_count());
+ $Requests = ($DB->has_results());
if ($Requests > 0) {
while (list($RequestID, $FillerID, $FillerName, $FilledTime) = $DB->next_record()) {
?>
diff --git a/sections/reportsv2/ajax_take_pm.php b/sections/reportsv2/ajax_take_pm.php
index 0ec7fbe..e02d38a 100644
--- a/sections/reportsv2/ajax_take_pm.php
+++ b/sections/reportsv2/ajax_take_pm.php
@@ -29,7 +29,7 @@ if (!is_number($_POST['categoryid']) || !is_number($TorrentID)) {
if (array_key_exists($_POST['type'], $Types[$CategoryID])) {
$ReportType = $Types[$CategoryID][$_POST['type']];
-} else if (array_key_exists($_POST['type'],$Types['master'])) {
+} else if (array_key_exists($_POST['type'], $Types['master'])) {
$ReportType = $Types['master'][$_POST['type']];
} else {
//There was a type but it wasn't an option!
@@ -46,13 +46,13 @@ if (!isset($_POST['from_delete'])) {
if ($Recipient == 'Uploader') {
$ToID = $_POST['uploaderid'];
if ($Report) {
- $Message = "You uploaded [url=https://".SSL_SITE_URL."/torrents.php?torrentid=".$TorrentID."]the above torrent[/url]. It has been reported for the reason: ".$ReportType['title']."\n\n".$Message;
+ $Message = "You uploaded [url=https://".SSL_SITE_URL."/torrents.php?torrentid=$TorrentID]the above torrent[/url]. It has been reported for the reason: ".$ReportType['title']."\n\n$Message";
} else {
- $Message = "I am PMing you as you are the uploader of [url=https://".SSL_SITE_URL."/torrents.php?torrentid=".$TorrentID."]the above torrent[/url].\n\n".$Message;
+ $Message = "I am PMing you as you are the uploader of [url=https://".SSL_SITE_URL."/torrents.php?torrentid=$TorrentID]the above torrent[/url].\n\n$Message";
}
} else if ($Recipient == 'Reporter') {
$ToID = $_POST['reporterid'];
- $Message = "You reported [url=https://".SSL_SITE_URL."/torrents.php?torrentid=".$TorrentID."]the above torrent[/url] for the reason ".$ReportType['title'].":\n[quote]".$_POST['report_reason']."[/quote]\n".$Message;
+ $Message = "You reported [url=https://".SSL_SITE_URL."/torrents.php?torrentid=$TorrentID]the above torrent[/url] for the reason ".$ReportType['title'].":\n[quote]".$_POST['report_reason']."[/quote]\n$Message";
} else {
$Err = "Something went horribly wrong";
}
diff --git a/sections/reportsv2/ajax_update_comment.php b/sections/reportsv2/ajax_update_comment.php
index fb311f2..60f2adb 100644
--- a/sections/reportsv2/ajax_update_comment.php
+++ b/sections/reportsv2/ajax_update_comment.php
@@ -17,8 +17,14 @@ $ReportID = $_POST['reportid'];
$Message = db_string($_POST['comment']);
//Message can be blank!
-$DB->query("SELECT ModComment FROM reportsv2 WHERE ID=".$ReportID);
+$DB->query("
+ SELECT ModComment
+ FROM reportsv2
+ WHERE ID = $ReportID");
list($ModComment) = $DB->next_record();
if (isset($ModComment)) {
- $DB->query("Update reportsv2 SET ModComment='".$Message."' WHERE ID=".$ReportID);
+ $DB->query("
+ UPDATE reportsv2
+ SET ModComment = '$Message'
+ WHERE ID = $ReportID");
}
diff --git a/sections/reportsv2/report.php b/sections/reportsv2/report.php
index f778cee..46781be 100644
--- a/sections/reportsv2/report.php
+++ b/sections/reportsv2/report.php
@@ -19,8 +19,8 @@ if (!isset($_GET['id']) || !is_number($_GET['id'])) {
$DB->query("
SELECT tg.CategoryID, t.GroupID
FROM torrents_group AS tg
- LEFT JOIN torrents AS t ON t.GroupID=tg.ID
- WHERE t.ID=" . $_GET['id']);
+ LEFT JOIN torrents AS t ON t.GroupID = tg.ID
+ WHERE t.ID = " . $_GET['id']);
list($CategoryID, $GroupID) = $DB->next_record();
$Artists = Artists::get_artist($GroupID);
$TorrentCache = get_group_info($GroupID, true, $RevisionID);
@@ -46,22 +46,22 @@ if (!isset($_GET['id']) || !is_number($_GET['id'])) {
//Get the artist name, group name etc.
$Artists = Artists::get_artist($GroupID);
if ($Artists) {
- $DisplayName = '<span dir="ltr">' . Artists::display_artists($Artists, true) . '<a href="torrents.php?torrentid=' . $TorrentID . '">' .$DisplayName . '</a></span>';
+ $DisplayName = '<span dir="ltr">' . Artists::display_artists($Artists, true) . "<a href=\"torrents.php?torrentid=$TorrentID\">$DisplayName</a></span>";
$AltName = display_str(Artists::display_artists($Artists, false)) . $AltName;
$Title = $AltName;
}
if ($GroupYear > 0) {
- $DisplayName.= " [$GroupYear]";
- $AltName.= " [$GroupYear]";
- $Title.= " [$GroupYear]";
+ $DisplayName .= " [$GroupYear]";
+ $AltName .= " [$GroupYear]";
+ $Title .= " [$GroupYear]";
}
if ($GroupVanityHouse) {
- $DisplayName.=' [Vanity House]';
- $AltName.=' [Vanity House]';
+ $DisplayName .=' [Vanity House]';
+ $AltName .=' [Vanity House]';
}
if ($GroupCategoryID == 1) {
- $DisplayName.=' [' . $ReleaseTypes[$ReleaseType] . ']';
- $AltName.=' [' . $ReleaseTypes[$ReleaseType] . ']';
+ $DisplayName .=' [' . $ReleaseTypes[$ReleaseType] . ']';
+ $AltName .=' [' . $ReleaseTypes[$ReleaseType] . ']';
}
}
diff --git a/sections/reportsv2/static.php b/sections/reportsv2/static.php
index b4ca4e6..42784c8 100644
--- a/sections/reportsv2/static.php
+++ b/sections/reportsv2/static.php
@@ -37,85 +37,107 @@ if (isset($_GET['id'])) {
$ID = '';
}
-$Order = "ORDER BY r.ReportedTime ASC";
+$Order = 'ORDER BY r.ReportedTime ASC';
if (!$ID) {
switch ($View) {
- case 'resolved' :
+ case 'resolved':
$Title = 'All the old smelly reports';
$Where = "WHERE r.Status = 'Resolved'";
$Order = 'ORDER BY r.LastChangeTime DESC';
break;
- case 'unauto' :
+ case 'unauto':
$Title = 'New reports, not auto assigned!';
$Where = "WHERE r.Status = 'New'";
break;
- default :
+ default:
error(404);
break;
}
} else {
switch ($View) {
- case 'staff' :
- $DB->query("SELECT Username FROM users_main WHERE ID=".$ID);
+ case 'staff':
+ $DB->query("
+ SELECT Username
+ FROM users_main
+ WHERE ID = $ID");
list($Username) = $DB->next_record();
if ($Username) {
- $Title = $Username."'s in-progress reports";
+ $Title = "$Username's in-progress reports";
} else {
- $Title = $ID."'s in-progress reports";
+ $Title = "$ID's in-progress reports";
}
- $Where = "WHERE r.Status = 'InProgress' AND r.ResolverID = ".$ID;
+ $Where = "
+ WHERE r.Status = 'InProgress'
+ AND r.ResolverID = $ID";
break;
- case 'resolver' :
- $DB->query("SELECT Username FROM users_main WHERE ID=".$ID);
+ case 'resolver':
+ $DB->query("
+ SELECT Username
+ FROM users_main
+ WHERE ID = $ID");
list($Username) = $DB->next_record();
if ($Username) {
- $Title = $Username."'s resolved reports";
+ $Title = "$Username's resolved reports";
} else {
- $Title = $ID."'s resolved reports";
+ $Title = "$ID's resolved reports";
}
- $Where = "WHERE r.Status = 'Resolved' AND r.ResolverID = ".$ID;
+ $Where = "
+ WHERE r.Status = 'Resolved'
+ AND r.ResolverID = $ID";
$Order = 'ORDER BY r.LastChangeTime DESC';
break;
- case 'group' :
+ case 'group':
$Title = "Unresolved reports for the group $ID";
- $Where = "WHERE r.Status != 'Resolved' AND tg.ID = ".$ID;
+ $Where = "
+ WHERE r.Status != 'Resolved'
+ AND tg.ID = $ID";
break;
- case 'torrent' :
- $Title = 'All reports for the torrent '.$ID;
- $Where = 'WHERE r.TorrentID = '.$ID;
+ case 'torrent':
+ $Title = "All reports for the torrent $ID";
+ $Where = "WHERE r.TorrentID = $ID";
break;
- case 'report' :
- $Title = 'Viewing resolution of report '.$ID;
- $Where = 'WHERE r.ID = '.$ID;
+ case 'report':
+ $Title = "Viewing resolution of report $ID";
+ $Where = "WHERE r.ID = $ID";
break;
- case 'reporter' :
- $DB->query("SELECT Username FROM users_main WHERE ID=".$ID);
+ case 'reporter':
+ $DB->query("
+ SELECT Username
+ FROM users_main
+ WHERE ID = $ID");
list($Username) = $DB->next_record();
if ($Username) {
- $Title = 'All torrents reported by '.$Username;
+ $Title = "All torrents reported by $Username";
} else {
- $Title = 'All torrents reported by user '.$ID;
+ $Title = "All torrents reported by user $ID";
}
- $Where = 'WHERE r.ReporterID = '.$ID;
+ $Where = "WHERE r.ReporterID = $ID";
$Order = 'ORDER BY r.ReportedTime DESC';
break;
- case 'uploader' :
- $DB->query("SELECT Username FROM users_main WHERE ID=".$ID);
+ case 'uploader':
+ $DB->query("
+ SELECT Username
+ FROM users_main
+ WHERE ID = $ID");
list($Username) = $DB->next_record();
if ($Username) {
- $Title = 'All reports for torrents uploaded by '.$Username;
+ $Title = "All reports for torrents uploaded by $Username";
} else {
- $Title = 'All reports for torrents uploaded by user '.$ID;
+ $Title = "All reports for torrents uploaded by user $ID";
}
- $Where = "WHERE r.Status != 'Resolved' AND t.UserID = ".$ID;
+ $Where = "
+ WHERE r.Status != 'Resolved'
+ AND t.UserID = $ID";
break;
case 'type':
$Title = 'All new reports for the chosen type';
- $Where = "WHERE r.Status = 'New' AND r.Type = '".$ID."'";
+ $Where = "
+ WHERE r.Status = 'New'
+ AND r.Type = '$ID'";
break;
break;
- default :
+ default:
error(404);
break;
}
@@ -170,13 +192,13 @@ $DB->query("
t.UserID AS UploaderID,
uploader.Username
FROM reportsv2 AS r
- LEFT JOIN torrents AS t ON t.ID=r.TorrentID
- LEFT JOIN torrents_group AS tg ON tg.ID=t.GroupID
- LEFT JOIN torrents_artists AS ta ON ta.GroupID=tg.ID AND ta.Importance='1'
- LEFT JOIN artists_alias AS aa ON aa.AliasID=ta.AliasID
- LEFT JOIN users_main AS resolver ON resolver.ID=r.ResolverID
- LEFT JOIN users_main AS reporter ON reporter.ID=r.ReporterID
- LEFT JOIN users_main AS uploader ON uploader.ID=t.UserID
+ LEFT JOIN torrents AS t ON t.ID = r.TorrentID
+ LEFT JOIN torrents_group AS tg ON tg.ID = t.GroupID
+ LEFT JOIN torrents_artists AS ta ON ta.GroupID = tg.ID AND ta.Importance = '1'
+ LEFT JOIN artists_alias AS aa ON aa.AliasID = ta.AliasID
+ LEFT JOIN users_main AS resolver ON resolver.ID = r.ResolverID
+ LEFT JOIN users_main AS reporter ON reporter.ID = r.ReporterID
+ LEFT JOIN users_main AS uploader ON uploader.ID = t.UserID
$Where
GROUP BY r.ID
$Order
@@ -227,17 +249,17 @@ if (count($Reports) == 0) {
list($ReportID, $ReporterID, $ReporterName, $TorrentID, $Type, $UserComment, $ResolverID, $ResolverName, $Status, $ReportedTime, $LastChangeTime,
$ModComment, $Tracks, $Images, $ExtraIDs, $Links, $LogMessage, $GroupName, $GroupID, $ArtistID, $ArtistName, $Year, $CategoryID, $Time, $Remastered, $RemasterTitle,
- $RemasterYear, $Media, $Format, $Encoding, $Size, $HasCue, $HasLog, $LogScore, $UploaderID, $UploaderName) = Misc::display_array($Report, array("ModComment"));
+ $RemasterYear, $Media, $Format, $Encoding, $Size, $HasCue, $HasLog, $LogScore, $UploaderID, $UploaderName) = Misc::display_array($Report, array('ModComment'));
if (!$GroupID && $Status != 'Resolved') {
//Torrent already deleted
$DB->query("
UPDATE reportsv2
SET
- Status='Resolved',
- LastChangeTime='".sqltime()."',
- ModComment='Report already dealt with (torrent deleted)'
- WHERE ID=".$ReportID);
+ Status = 'Resolved',
+ LastChangeTime = '".sqltime()."',
+ ModComment = 'Report already dealt with (torrent deleted)'
+ WHERE ID = $ReportID");
$Cache->decrement('num_torrent_reportsv2');
?>
<div id="report<?=$ReportID?>">
@@ -256,7 +278,7 @@ if (count($Reports) == 0) {
} else {
if (array_key_exists($Type, $Types[$CategoryID])) {
$ReportType = $Types[$CategoryID][$Type];
- } elseif (array_key_exists($Type,$Types['master'])) {
+ } elseif (array_key_exists($Type, $Types['master'])) {
$ReportType = $Types['master'][$Type];
} else {
//There was a type but it wasn't an option!
@@ -323,11 +345,12 @@ if (count($Reports) == 0) {
<div style="text-align: right;">was reported by <a href="user.php?id=<?=$ReporterID?>"><?=$ReporterName?></a> <?=time_diff($ReportedTime)?> for the reason: <strong><?=$ReportType['title']?></strong></div>
<? if ($Status != 'Resolved') {
- $DB->query("SELECT r.ID
- FROM reportsv2 AS r
- LEFT JOIN torrents AS t ON t.ID=r.TorrentID
- WHERE r.Status != 'Resolved'
- AND t.GroupID=$GroupID");
+ $DB->query("
+ SELECT r.ID
+ FROM reportsv2 AS r
+ LEFT JOIN torrents AS t ON t.ID = r.TorrentID
+ WHERE r.Status != 'Resolved'
+ AND t.GroupID = $GroupID");
$GroupOthers = ($DB->record_count() - 1);
if ($GroupOthers > 0) { ?>
@@ -336,11 +359,12 @@ if (count($Reports) == 0) {
</div>
<? }
- $DB->query("SELECT t.UserID
- FROM reportsv2 AS r
- JOIN torrents AS t ON t.ID=r.TorrentID
- WHERE r.Status != 'Resolved'
- AND t.UserID=$UploaderID");
+ $DB->query("
+ SELECT t.UserID
+ FROM reportsv2 AS r
+ JOIN torrents AS t ON t.ID = r.TorrentID
+ WHERE r.Status != 'Resolved'
+ AND t.UserID = $UploaderID");
$UploaderOthers = ($DB->record_count() - 1);
if ($UploaderOthers > 0) { ?>
@@ -349,18 +373,19 @@ if (count($Reports) == 0) {
</div>
<? }
- $DB->query("SELECT DISTINCT req.ID,
- req.FillerID,
- um.Username,
- req.TimeFilled
- FROM requests AS req
- LEFT JOIN torrents AS t ON t.ID=req.TorrentID
- LEFT JOIN reportsv2 AS rep ON rep.TorrentID=t.ID
- JOIN users_main AS um ON um.ID=req.FillerID
- WHERE rep.Status != 'Resolved'
- AND req.TimeFilled > '2010-03-04 02:31:49'
- AND req.TorrentID = $TorrentID");
- $Requests = ($DB->record_count());
+ $DB->query("
+ SELECT DISTINCT req.ID,
+ req.FillerID,
+ um.Username,
+ req.TimeFilled
+ FROM requests AS req
+ LEFT JOIN torrents AS t ON t.ID = req.TorrentID
+ LEFT JOIN reportsv2 AS rep ON rep.TorrentID = t.ID
+ JOIN users_main AS um ON um.ID = req.FillerID
+ WHERE rep.Status != 'Resolved'
+ AND req.TimeFilled > '2010-03-04 02:31:49'
+ AND req.TorrentID = $TorrentID");
+ $Requests = ($DB->has_results());
if ($Requests > 0) {
while (list($RequestID, $FillerID, $FillerName, $FilledTime) = $DB->next_record()) {
?>
@@ -439,11 +464,11 @@ if (count($Reports) == 0) {
t.UserID AS UploaderID,
uploader.Username
FROM torrents AS t
- LEFT JOIN torrents_group AS tg ON tg.ID=t.GroupID
- LEFT JOIN torrents_artists AS ta ON ta.GroupID=tg.ID AND ta.Importance='1'
- LEFT JOIN artists_alias AS aa ON aa.AliasID=ta.AliasID
- LEFT JOIN users_main AS uploader ON uploader.ID=t.UserID
- WHERE t.ID='$ExtraID'
+ LEFT JOIN torrents_group AS tg ON tg.ID = t.GroupID
+ LEFT JOIN torrents_artists AS ta ON ta.GroupID = tg.ID AND ta.Importance = '1'
+ LEFT JOIN artists_alias AS aa ON aa.AliasID = ta.AliasID
+ LEFT JOIN users_main AS uploader ON uploader.ID = t.UserID
+ WHERE t.ID = '$ExtraID'
GROUP BY tg.ID");
list($ExtraGroupName, $ExtraGroupID, $ExtraArtistID, $ExtraArtistName, $ExtraYear, $ExtraTime, $ExtraRemastered, $ExtraRemasterTitle,
@@ -481,7 +506,7 @@ if (count($Reports) == 0) {
$Images = explode(' ', $Images);
foreach ($Images as $Image) {
?>
- <img style="max-width: 200px;" onclick="lightbox.init(this,200);" src="<?=ImageTools::process($Image)?>" alt="Relevant image" />
+ <img style="max-width: 200px;" onclick="lightbox.init(this, 200);" src="<?=ImageTools::process($Image)?>" alt="Relevant image" />
<?
} ?>
</td>
@@ -506,7 +531,7 @@ if (count($Reports) == 0) {
<td class="label">Report comment:</td>
<td colspan="3">
<input type="text" name="comment" id="comment<?=$ReportID?>" size="45" value="<?=$ModComment?>" />
- <input type="button" value="Update now" onclick="UpdateComment(<?=$ReportID?>)" />
+ <input type="button" value="Update now" onclick="UpdateComment(<?=$ReportID?>);" />
</td>
</tr>
<tr>
@@ -514,7 +539,7 @@ if (count($Reports) == 0) {
<a href="javascript:Load('<?=$ReportID?>')" title="Click here to reset the resolution options to their default values.">Resolve</a>
</td>
<td colspan="3">
- <select name="resolve_type" id="resolve_type<?=$ReportID?>" onchange="ChangeResolve(<?=$ReportID?>)">
+ <select name="resolve_type" id="resolve_type<?=$ReportID?>" onchange="ChangeResolve(<?=$ReportID?>);">
<?
$TypeList = $Types['master'] + $Types[$CategoryID];
$Priorities = array();
@@ -550,7 +575,7 @@ if (count($Reports) == 0) {
</span>
&nbsp;&nbsp;
<span title="Update resolve type">
- <input type="button" name="update_resolve" id="update_resolve<?=$ReportID?>" value="Update now" onclick="UpdateResolve(<?=$ReportID?>)" />
+ <input type="button" name="update_resolve" id="update_resolve<?=$ReportID?>" value="Update now" onclick="UpdateResolve(<?=$ReportID?>);" />
</span>
</span>
</td>
@@ -567,7 +592,7 @@ if (count($Reports) == 0) {
<span title="Uploader: Appended to the regular message unless using &quot;Send now&quot;. Reporter: Must be used with &quot;Send now&quot;.">
<textarea name="uploader_pm" id="uploader_pm<?=$ReportID?>" cols="50" rows="1"></textarea>
</span>
- <input type="button" value="Send now" onclick="SendPM(<?=$ReportID?>)" />
+ <input type="button" value="Send now" onclick="SendPM(<?=$ReportID?>);" />
</td>
</tr>
<tr>
@@ -577,7 +602,7 @@ if (count($Reports) == 0) {
$Extras = explode(' ', $ExtraIDs);
$Value = '';
foreach ($Extras as $ExtraID) {
- $Value .= 'https://'.SSL_SITE_URL.'/torrents.php?torrentid='.$ExtraID.' ';
+ $Value .= 'https://'.SSL_SITE_URL."/torrents.php?torrentid=$ExtraID ";
}
echo 'value="'.trim($Value).'"';
} ?>/>
@@ -638,10 +663,10 @@ if (count($Reports) == 0) {
<br />
</div>
<script type="text/javascript">//<![CDATA[
- Load('<?=$ReportID?>');
+ Load('<?=$ReportID?>');
//]]>
</script>
- <?
+<?
}
}
}
diff --git a/sections/reportsv2/takereport.php b/sections/reportsv2/takereport.php
index d1ed8d8..ade624d 100644
--- a/sections/reportsv2/takereport.php
+++ b/sections/reportsv2/takereport.php
@@ -42,7 +42,7 @@ if (!isset($_POST['type'])) {
foreach ($ReportType['report_fields'] as $Field => $Value) {
if ($Value == '1') {
if (empty($_POST[$Field])) {
- $Err = "You are missing a required field (".$Field.") for a ".$ReportType['title']." report.";
+ $Err = "You are missing a required field ($Field) for a ".$ReportType['title'].' report.';
}
}
}
@@ -54,7 +54,7 @@ if (!empty($_POST['sitelink'])) {
$Err = "The extra permalinks you gave included the link to the torrent you're reporting!";
}
} else {
- $Err = "The permalink was incorrect. It should look like https://".SSL_SITE_URL."/torrents.php?torrentid=12345";
+ $Err = 'The permalink was incorrect. It should look like https://'.SSL_SITE_URL.'/torrents.php?torrentid=12345';
}
} else {
$ExtraIDs = '';
@@ -86,7 +86,7 @@ if (!empty($_POST['track'])) {
if (preg_match('/([0-9]+( [0-9]+)*)|All/is', $_POST['track'], $Matches)) {
$Tracks = $Matches[0];
} else {
- $Err = 'Tracks should be given in a space separated list of numbers (no other characters)';
+ $Err = 'Tracks should be given in a space-separated list of numbers with no other characters.';
}
} else {
$Tracks = '';
@@ -98,8 +98,11 @@ if (!empty($_POST['extra'])) {
$Err = 'As useful as blank reports are, could you be a tiny bit more helpful? (Leave a comment)';
}
-$DB->query("SELECT ID FROM torrents WHERE ID=".$TorrentID);
-if ($DB->record_count() < 1) {
+$DB->query("
+ SELECT ID
+ FROM torrents
+ WHERE ID = $TorrentID");
+if (!$DB->has_results()) {
$Err = "A torrent with that ID doesn't exist!";
}
@@ -109,22 +112,28 @@ if (!empty($Err)) {
die();
}
-$DB->query("SELECT ID FROM reportsv2 WHERE TorrentID=".$TorrentID." AND ReporterID=".db_string($LoggedUser['ID'])." AND ReportedTime > '".time_minus(3)."'");
-if ($DB->record_count() > 0) {
- header('Location: torrents.php?torrentid='.$TorrentID);
+$DB->query("
+ SELECT ID
+ FROM reportsv2
+ WHERE TorrentID = $TorrentID
+ AND ReporterID = ".db_string($LoggedUser['ID'])."
+ AND ReportedTime > '".time_minus(3)."'");
+if ($DB->has_results()) {
+ header("Location: torrents.php?torrentid=$TorrentID");
die();
}
-$DB->query("INSERT INTO reportsv2
- (ReporterID, TorrentID, Type, UserComment, Status, ReportedTime, Track, Image, ExtraID, Link)
- VALUES
- (".db_string($LoggedUser['ID']).", $TorrentID, '".db_string($Type)."', '$Extra', 'New', '".sqltime()."', '".db_string($Tracks)."', '".db_string($Images)."', '".db_string($ExtraIDs)."', '".db_string($Links)."')");
+$DB->query("
+ INSERT INTO reportsv2
+ (ReporterID, TorrentID, Type, UserComment, Status, ReportedTime, Track, Image, ExtraID, Link)
+ VALUES
+ (".db_string($LoggedUser['ID']).", $TorrentID, '".db_string($Type)."', '$Extra', 'New', '".sqltime()."', '".db_string($Tracks)."', '".db_string($Images)."', '".db_string($ExtraIDs)."', '".db_string($Links)."')");
$ReportID = $DB->inserted_id();
-$Cache->delete_value('reports_torrent_'.$TorrentID);
+$Cache->delete_value("reports_torrent_$TorrentID");
$Cache->increment('num_torrent_reportsv2');
-header('Location: torrents.php?torrentid='.$TorrentID);
+header("Location: torrents.php?torrentid=$TorrentID");
?>
diff --git a/sections/reportsv2/takeresolve.php b/sections/reportsv2/takeresolve.php
index 1df3eee..f7bee1f 100644
--- a/sections/reportsv2/takeresolve.php
+++ b/sections/reportsv2/takeresolve.php
@@ -1,7 +1,7 @@
<?
/*
* This is the backend of the AJAXy reports resolve (When you press the shiny submit button).
- * This page shouldn't output anything except in error, if you do want output, it will be put
+ * This page shouldn't output anything except in error. If you do want output, it will be put
* straight into the table where the report used to be. Currently output is only given when
* a collision occurs or a POST attack is detected.
*/
@@ -13,7 +13,7 @@ authorize();
//Don't escape: Log message, Admin message
-$Escaped = db_array($_POST, array('log_message','admin_message', 'raw_name'));
+$Escaped = db_array($_POST, array('log_message', 'admin_message', 'raw_name'));
//If we're here from the delete torrent page instead of the reports page.
if (!isset($Escaped['from_delete'])) {
@@ -58,35 +58,35 @@ if (!isset($CategoryID)) {
$TorrentID = $Escaped['torrentid'];
$RawName = $Escaped['raw_name'];
-if (isset($Escaped['delete']) && $Cache->get_value('torrent_'.$TorrentID.'_lock')) {
- echo 'You requested to delete the torrent '.$TorrentID.', but this is currently not possible because the upload process is still running. Please try again later.';
+if (isset($Escaped['delete']) && $Cache->get_value("torrent_$TorrentID".'_lock')) {
+ echo "You requested to delete the torrent $TorrentID, but this is currently not possible because the upload process is still running. Please try again later.";
die();
}
-if (($Escaped['resolve_type'] == "manual" || $Escaped['resolve_type'] == "dismiss" ) && $Report) {
+if (($Escaped['resolve_type'] == 'manual' || $Escaped['resolve_type'] == 'dismiss') && $Report) {
if ($Escaped['comment']) {
$Comment = $Escaped['comment'];
} else {
- if ($Escaped['resolve_type'] == "manual") {
- $Comment = "Report was resolved manually";
- } elseif ($Escaped['resolve_type'] == "dismiss") {
- $Comment = "Report was dismissed as invalid";
+ if ($Escaped['resolve_type'] == 'manual') {
+ $Comment = 'Report was resolved manually.';
+ } elseif ($Escaped['resolve_type'] == 'dismiss') {
+ $Comment = 'Report was dismissed as invalid.';
}
}
$DB->query("
UPDATE reportsv2
SET
- Status='Resolved',
- LastChangeTime='".sqltime()."',
+ Status = 'Resolved',
+ LastChangeTime = '".sqltime()."',
ModComment = '$Comment',
- ResolverID='".$LoggedUser['ID']."'
- WHERE ID='$ReportID'
+ ResolverID = '".$LoggedUser['ID']."'
+ WHERE ID = '$ReportID'
AND Status != 'Resolved'");
if ($DB->affected_rows() > 0) {
$Cache->delete_value('num_torrent_reportsv2');
- $Cache->delete_value('reports_torrent_'.$TorrentID);
+ $Cache->delete_value("reports_torrent_$TorrentID");
} else {
//Someone beat us to it. Inform the staffer.
?>
@@ -108,7 +108,7 @@ if (!isset($Escaped['resolve_type'])) {
die();
} elseif (array_key_exists($_POST['resolve_type'], $Types[$CategoryID])) {
$ResolveType = $Types[$CategoryID][$_POST['resolve_type']];
-} elseif (array_key_exists($_POST['resolve_type'],$Types['master'])) {
+} elseif (array_key_exists($_POST['resolve_type'], $Types['master'])) {
$ResolveType = $Types['master'][$_POST['resolve_type']];
} else {
//There was a type but it wasn't an option!
@@ -116,17 +116,19 @@ if (!isset($Escaped['resolve_type'])) {
die();
}
-
-$DB->query("SELECT ID FROM torrents WHERE ID = ".$TorrentID);
-$TorrentExists = ($DB->record_count() > 0);
+$DB->query("
+ SELECT ID
+ FROM torrents
+ WHERE ID = $TorrentID");
+$TorrentExists = ($DB->has_results());
if (!$TorrentExists) {
$DB->query("
UPDATE reportsv2
- SET Status='Resolved',
- LastChangeTime='".sqltime()."',
- ResolverID='".$LoggedUser['ID']."',
- ModComment='Report already dealt with (Torrent deleted)'
- WHERE ID=".$ReportID);
+ SET Status = 'Resolved',
+ LastChangeTime = '".sqltime()."',
+ ResolverID = '".$LoggedUser['ID']."',
+ ModComment = 'Report already dealt with (torrent deleted).'
+ WHERE ID = $ReportID");
$Cache->decrement('num_torrent_reportsv2');
}
@@ -135,10 +137,10 @@ if ($Report) {
//Resolve with a parallel check
$DB->query("
UPDATE reportsv2
- SET Status='Resolved',
- LastChangeTime='".sqltime()."',
- ResolverID='".$LoggedUser['ID']."'
- WHERE ID=$ReportID
+ SET Status = 'Resolved',
+ LastChangeTime = '".sqltime()."',
+ ResolverID = '".$LoggedUser['ID']."'
+ WHERE ID = $ReportID
AND Status != 'Resolved'");
}
@@ -156,72 +158,98 @@ if ($DB->affected_rows() > 0 || !$Report) {
$Upload = false;
}
-
- if ($_POST['resolve_type'] == "tags_lots") {
- $DB->query("INSERT IGNORE INTO torrents_bad_tags (TorrentID, UserID, TimeAdded) VALUES (".$TorrentID.", ".$LoggedUser['ID']." , '".sqltime()."')");
- $DB->query("SELECT GroupID FROM torrents WHERE ID = ".$TorrentID);
+ if ($_POST['resolve_type'] == 'tags_lots') {
+ $DB->query("
+ INSERT IGNORE INTO torrents_bad_tags
+ (TorrentID, UserID, TimeAdded)
+ VALUES
+ ($TorrentID, ".$LoggedUser['ID']." , '".sqltime()."')");
+ $DB->query("
+ SELECT GroupID
+ FROM torrents
+ WHERE ID = $TorrentID");
list($GroupID) = $DB->next_record();
- $Cache->delete_value('torrents_details_'.$GroupID);
+ $Cache->delete_value("torrents_details_$GroupID");
$SendPM = true;
}
- if ($_POST['resolve_type'] == "folders_bad") {
- $DB->query("INSERT IGNORE INTO torrents_bad_folders (TorrentID, UserID, TimeAdded) VALUES (".$TorrentID.", ".$LoggedUser['ID'].", '".sqltime()."')");
- $DB->query("SELECT GroupID FROM torrents WHERE ID = ".$TorrentID);
+ if ($_POST['resolve_type'] == 'folders_bad') {
+ $DB->query("
+ INSERT IGNORE INTO torrents_bad_folders
+ (TorrentID, UserID, TimeAdded)
+ VALUES
+ ($TorrentID, ".$LoggedUser['ID'].", '".sqltime()."')");
+ $DB->query("
+ SELECT GroupID
+ FROM torrents
+ WHERE ID = $TorrentID");
list($GroupID) = $DB->next_record();
- $Cache->delete_value('torrents_details_'.$GroupID);
+ $Cache->delete_value("torrents_details_$GroupID");
$SendPM = true;
}
- if ($_POST['resolve_type'] == "filename") {
- $DB->query("INSERT IGNORE INTO torrents_bad_files (TorrentID, UserID, TimeAdded) VALUES (".$TorrentID.", ".$LoggedUser['ID'].", '".sqltime()."')");
- $DB->query("SELECT GroupID FROM torrents WHERE ID = ".$TorrentID);
+ if ($_POST['resolve_type'] == 'filename') {
+ $DB->query("
+ INSERT IGNORE INTO torrents_bad_files
+ (TorrentID, UserID, TimeAdded)
+ VALUES
+ ($TorrentID, ".$LoggedUser['ID'].", '".sqltime()."')");
+ $DB->query("
+ SELECT GroupID
+ FROM torrents
+ WHERE ID = $TorrentID");
list($GroupID) = $DB->next_record();
- $Cache->delete_value('torrents_details_'.$GroupID);
+ $Cache->delete_value("torrents_details_$GroupID");
$SendPM = true;
}
//Log and delete
if (isset($Escaped['delete']) && check_perms('users_mod')) {
- $DB->query("SELECT Username FROM users_main WHERE ID = ".$UploaderID);
+ $DB->query("
+ SELECT Username
+ FROM users_main
+ WHERE ID = $UploaderID");
list($UpUsername) = $DB->next_record();
- $Log = "Torrent ".$TorrentID." (".$RawName.") uploaded by ".$UpUsername." was deleted by ".$LoggedUser['Username'];
- $Log .= ($Escaped['resolve_type'] == 'custom' ? "" : " for the reason: ".$ResolveType['title'].".");
- if (isset($Escaped['log_message']) && $Escaped['log_message'] != "") {
- $Log .= " ( ".$Escaped['log_message']." )";
+ $Log = "Torrent $TorrentID ($RawName) uploaded by $UpUsername was deleted by ".$LoggedUser['Username'];
+ $Log .= ($Escaped['resolve_type'] == 'custom' ? '' : ' for the reason: '.$ResolveType['title'].".");
+ if (isset($Escaped['log_message']) && $Escaped['log_message'] != '') {
+ $Log .= ' ( '.$Escaped['log_message'].' )';
}
- $DB->query("SELECT GroupID, hex(info_hash) FROM torrents WHERE ID = ".$TorrentID);
+ $DB->query("
+ SELECT GroupID, hex(info_hash)
+ FROM torrents
+ WHERE ID = $TorrentID");
list($GroupID, $InfoHash) = $DB->next_record();
Torrents::delete_torrent($TorrentID, 0, $ResolveType['reason']);
//$InfoHash = unpack("H*", $InfoHash);
- $Log .= " (".strtoupper($InfoHash).")";
+ $Log .= ' ('.strtoupper($InfoHash).')';
Misc::write_log($Log);
- $Log = "deleted torrent for the reason: ".$ResolveType['title'].". ( ".$Escaped['log_message']." )";
+ $Log = 'deleted torrent for the reason: '.$ResolveType['title'].'. ( '.$Escaped['log_message'].' )';
Torrents::write_group_log($GroupID, $TorrentID, $LoggedUser['ID'], $Log, 0);
} else {
- $Log = "No log message (Torrent wasn't deleted)";
+ $Log = "No log message (torrent wasn't deleted).";
}
//Warnings / remove upload
if ($Upload) {
- $Cache->begin_transaction('user_info_heavy_'.$UploaderID);
+ $Cache->begin_transaction("user_info_heavy_$UploaderID");
$Cache->update_row(false, array('DisableUpload' => '1'));
$Cache->commit_transaction(0);
$DB->query("
UPDATE users_info
- SET DisableUpload='1'
- WHERE UserID=".$UploaderID);
+ SET DisableUpload = '1'
+ WHERE UserID = $UploaderID");
}
if ($Warning > 0) {
$WarnLength = $Warning * (7 * 24 * 60 * 60);
- $Reason = "Uploader of torrent (".$TorrentID.") ".$RawName." which was resolved with the preset: ".$ResolveType['title'].".";
+ $Reason = "Uploader of torrent ($TorrentID) $RawName which was resolved with the preset: ".$ResolveType['title'].'.';
if ($Escaped['admin_message']) {
- $Reason .= " (".$Escaped['admin_message'].").";
+ $Reason .= ' ('.$Escaped['admin_message'].').';
}
if ($Upload) {
- $Reason .= " (Upload privileges Removed).";
+ $Reason .= ' (Upload privileges removed).';
}
Tools::warn_user($UploaderID, $WarnLength, $Reason);
@@ -230,66 +258,69 @@ if ($DB->affected_rows() > 0 || !$Report) {
$AdminComment = '';
if ($Upload) {
//They removed upload
- $AdminComment .= "Upload privileges removed by ".$LoggedUser['Username'];
- $AdminComment .= "\nReason: Uploader of torrent (".$TorrentID.") ".db_string($RawName)." which was resolved with the preset: ".$ResolveType['title'].". (Report ID: $ReportID)";
+ $AdminComment .= 'Upload privileges removed by '.$LoggedUser['Username'];
+ $AdminComment .= "\nReason: Uploader of torrent ($TorrentID) ".db_string($RawName).' which was resolved with the preset: '.$ResolveType['title'].". (Report ID: $ReportID)";
}
if ($Escaped['admin_message']) {
//They did nothing of note, but still want to mark it (Or upload and mark)
- $AdminComment .= " (".$Escaped['admin_message'].")";
+ $AdminComment .= ' ('.$Escaped['admin_message'].')';
}
if ($AdminComment) {
- $AdminComment = date("Y-m-d").' - '.$AdminComment."\n\n";
+ $AdminComment = date('Y-m-d') . " - $AdminComment\n\n";
- $DB->query("UPDATE users_info SET
- AdminComment=CONCAT('".db_string($AdminComment)."',AdminComment)
- WHERE UserID='".db_string($UploaderID)."'");
+ $DB->query("
+ UPDATE users_info
+ SET AdminComment = CONCAT('".db_string($AdminComment)."', AdminComment)
+ WHERE UserID = '".db_string($UploaderID)."'");
}
}
//PM
if ($Escaped['uploader_pm'] || $Warning > 0 || isset($Escaped['delete']) || $SendPM) {
if (isset($Escaped['delete'])) {
- $PM = '[url=https://'.SSL_SITE_URL."/torrents.php?torrentid=".$TorrentID."]Your above torrent[/url] was reported and has been deleted.\n\n";
+ $PM = '[url=https://'.SSL_SITE_URL."/torrents.php?torrentid=$TorrentID]Your above torrent[/url] was reported and has been deleted.\n\n";
} else {
- $PM = '[url=https://'.SSL_SITE_URL."/torrents.php?torrentid=".$TorrentID."]Your above torrent[/url] was reported but not deleted.\n\n";
+ $PM = '[url=https://'.SSL_SITE_URL."/torrents.php?torrentid=$TorrentID]Your above torrent[/url] was reported but not deleted.\n\n";
}
$Preset = $ResolveType['resolve_options']['pm'];
if ($Preset != '') {
- $PM .= "Reason: ".$Preset;
+ $PM .= "Reason: $Preset";
}
if ($Warning > 0) {
- $PM .= "\nThis has resulted in a [url=https://".SSL_SITE_URL."/wiki.php?action=article&amp;id=218]".$Warning." week warning.[/url]\n";
+ $PM .= "\nThis has resulted in a [url=https://".SSL_SITE_URL."/wiki.php?action=article&amp;id=218]$Warning week warning.[/url]\n";
}
if ($Upload) {
- $PM .= "This has ".($Warning > 0 ? 'also ' : '')."resulted in you losing your upload privileges.";
+ $PM .= 'This has '.($Warning > 0 ? 'also ' : '').'resulted in you losing your upload privileges.';
}
if ($Log) {
- $PM = $PM."\nLog Message: ".$Log."\n";
+ $PM = "$PM\nLog Message: $Log\n";
}
if ($Escaped['uploader_pm']) {
- $PM .= "\nMessage from ".$LoggedUser['Username'].": ".$PMMessage;
+ $PM .= "\nMessage from ".$LoggedUser['Username'].": $PMMessage";
}
- $PM .= "\n\nReport was handled by [user]".$LoggedUser['Username']."[/user].";
+ $PM .= "\n\nReport was handled by [user]".$LoggedUser['Username'].'[/user].';
Misc::send_pm($UploaderID, 0, $Escaped['raw_name'], $PM);
}
- $Cache->delete_value('reports_torrent_'.$TorrentID);
+ $Cache->delete_value("reports_torrent_$TorrentID");
//Now we've done everything, update the DB with values
if ($Report) {
- $DB->query("UPDATE reportsv2 SET
- Type = '".$Escaped['resolve_type']."',
- LogMessage='".db_string($Log)."',
- ModComment='".$Escaped['comment']."'
- WHERE ID=".$ReportID);
+ $DB->query("
+ UPDATE reportsv2
+ SET
+ Type = '".$Escaped['resolve_type']."',
+ LogMessage = '".db_string($Log)."',
+ ModComment = '".$Escaped['comment']."'
+ WHERE ID = $ReportID");
}
} else {
//Someone beat us to it. Inform the staffer.
diff --git a/sections/requests/index.php b/sections/requests/index.php
index 4f4a41b..d245f6b 100644
--- a/sections/requests/index.php
+++ b/sections/requests/index.php
@@ -62,20 +62,22 @@ if (!isset($_REQUEST['action'])) {
$DB->query("
SELECT
CEIL((
- SELECT COUNT(ID)+1
+ SELECT COUNT(ID) + 1
FROM requests_comments AS rc
- WHERE rc.RequestID='".$RequestID."'
- )/".TORRENT_COMMENTS_PER_PAGE."
+ WHERE rc.RequestID = '$RequestID'
+ ) / ".TORRENT_COMMENTS_PER_PAGE."
) AS Pages");
list($Pages) = $DB->next_record();
$DB->query("
- INSERT INTO requests_comments (RequestID,AuthorID,AddedTime,Body)
- VALUES ('$RequestID', '".db_string($LoggedUser['ID'])."','".sqltime()."','".db_string($_POST['body'])."')");
+ INSERT INTO requests_comments
+ (RequestID, AuthorID, AddedTime, Body)
+ VALUES
+ ('$RequestID', '".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('request_comments_'.$RequestID.'_catalogue_'.$CatalogueID);
+ $Cache->begin_transaction("request_comments_$RequestID"."_catalogue_$CatalogueID");
$Post = array(
'ID'=>$PostID,
'AuthorID'=>$LoggedUser['ID'],
@@ -87,9 +89,9 @@ if (!isset($_REQUEST['action'])) {
);
$Cache->insert('', $Post);
$Cache->commit_transaction(0);
- $Cache->increment('request_comments_'.$RequestID);
+ $Cache->increment("request_comments_$RequestID");
- header('Location: requests.php?action=view&id='.$RequestID.'&page='.$Pages);
+ header("Location: requests.php?action=view&id=$RequestID&page=$Pages");
break;
case 'get_post':
@@ -97,7 +99,10 @@ if (!isset($_REQUEST['action'])) {
if (!$_GET['post'] || !is_number($_GET['post'])) {
error(0);
}
- $DB->query("SELECT Body FROM requests_comments WHERE ID='".db_string($_GET['post'])."'");
+ $DB->query("
+ SELECT Body
+ FROM requests_comments
+ WHERE ID = '".db_string($_GET['post'])."'");
list($Body) = $DB->next_record(MYSQLI_NUM);
echo trim($Body);
@@ -123,8 +128,8 @@ if (!isset($_REQUEST['action'])) {
rc.RequestID,
rc.AddedTime
FROM requests_comments AS rc
- WHERE rc.ID='".db_string($_POST['post'])."'");
- list($OldBody, $AuthorID,$RequestID,$AddedTime)=$DB->next_record();
+ WHERE rc.ID = '".db_string($_POST['post'])."'");
+ list($OldBody, $AuthorID, $RequestID, $AddedTime) = $DB->next_record();
$DB->query("
SELECT ceil(COUNT(ID) / ".POSTS_PER_PAGE.") AS Page
@@ -136,7 +141,7 @@ if (!isset($_REQUEST['action'])) {
if ($LoggedUser['ID'] != $AuthorID && !check_perms('site_moderate_forums')) {
error(404);
}
- if ($DB->record_count() == 0) {
+ if (!$DB->has_results()) {
error(404);
}
@@ -147,11 +152,11 @@ if (!isset($_REQUEST['action'])) {
Body = '".db_string($_POST['body'])."',
EditedUserID = '".db_string($LoggedUser['ID'])."',
EditedTime = '".sqltime()."'
- WHERE ID='".db_string($_POST['post'])."'");
+ WHERE ID = '".db_string($_POST['post'])."'");
// Update the cache
- $CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE*$Page-TORRENT_COMMENTS_PER_PAGE)/THREAD_CATALOGUE);
- $Cache->begin_transaction('request_comments_'.$RequestID.'_catalogue_'.$CatalogueID);
+ $CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
+ $Cache->begin_transaction("request_comments_$RequestID"."_catalogue_$CatalogueID");
$Cache->update_row($_POST['key'], array(
'ID'=>$_POST['post'],
@@ -165,8 +170,10 @@ if (!isset($_REQUEST['action'])) {
$Cache->commit_transaction(0);
$DB->query("
- INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)
- VALUES ('requests', ".db_string($_POST['post']).", ".db_string($LoggedUser['ID']).", '".sqltime()."', '".db_string($OldBody)."')");
+ INSERT INTO comments_edits
+ (Page, PostID, EditUser, EditTime, Body)
+ VALUES
+ ('requests', ".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']);
@@ -190,36 +197,38 @@ if (!isset($_REQUEST['action'])) {
$DB->query("
SELECT DISTINCT
RequestID,
- CEIL(COUNT(rc.ID)/".TORRENT_COMMENTS_PER_PAGE.") AS Pages,
- CEIL(SUM(IF(rc.ID<=".$_GET['postid'].",1,0))/".TORRENT_COMMENTS_PER_PAGE.") AS Page
+ CEIL(COUNT(rc.ID) / ".TORRENT_COMMENTS_PER_PAGE.") AS Pages,
+ CEIL(SUM(IF(rc.ID <= ".$_GET['postid'].", 1, 0)) / ".TORRENT_COMMENTS_PER_PAGE.") AS Page
FROM requests_comments AS rc
- WHERE rc.RequestID=(
+ WHERE rc.RequestID = (
SELECT RequestID
FROM requests_comments
- WHERE ID='".db_string($_GET['postid'])."'
+ WHERE ID = '".db_string($_GET['postid'])."'
)");
- list($RequestID,$Pages,$Page) = $DB->next_record();
+ list($RequestID, $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 requests_comments WHERE ID='".db_string($_GET['postid'])."'");
+ $DB->query("
+ DELETE FROM requests_comments
+ WHERE ID = '".db_string($_GET['postid'])."'");
//We need to clear all subsequential catalogues as they've all been bumped with the absence of this post
$ThisCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
$LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $Pages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
for ($i = $ThisCatalogue; $i <= $LastCatalogue; $i++) {
- $Cache->delete_value('request_comments_'.$RequestID.'_catalogue_'.$i);
+ $Cache->delete_value("request_comments_$RequestID" . "_catalogue_$i");
}
// Delete thread info cache (eg. number of pages)
- $Cache->delete_value('request_comments_'.$GroupID);
+ $Cache->delete_value("request_comments_$GroupID");
break;
- case 'warn' :
+ case 'warn':
include(SERVER_ROOT.'/sections/requests/warn.php');
break;
- case 'take_warn' :
+ case 'take_warn':
include(SERVER_ROOT.'/sections/requests/take_warn.php');
break;
default:
diff --git a/sections/requests/interim.php b/sections/requests/interim.php
index b9be053..eedd046 100644
--- a/sections/requests/interim.php
+++ b/sections/requests/interim.php
@@ -1,4 +1,4 @@
-<?
+<?php
if (!isset($_GET['id']) || !is_number($_GET['id'])) {
error(404);
}
@@ -8,14 +8,17 @@ if ($Action != 'unfill' && $Action != 'delete') {
error(404);
}
-$DB->query("SELECT UserID, FillerID FROM requests WHERE ID = ".$_GET['id']);
+$DB->query("
+ SELECT UserID, FillerID
+ FROM requests
+ WHERE ID = ".$_GET['id']);
list($RequestorID, $FillerID) = $DB->next_record();
if ($Action == 'unfill') {
if ($LoggedUser['ID'] != $RequestorID && $LoggedUser['ID'] != $FillerID && !check_perms('site_moderate_requests')) {
error(403);
}
-} elseif ($Action == "delete") {
+} elseif ($Action == 'delete') {
if ($LoggedUser['ID'] != $RequestorID && !check_perms('site_moderate_requests')) {
error(403);
}
diff --git a/sections/requests/new_edit.php b/sections/requests/new_edit.php
index 686de9d..1bf9bbe 100644
--- a/sections/requests/new_edit.php
+++ b/sections/requests/new_edit.php
@@ -383,8 +383,9 @@ View::show_header(($NewRequest ? 'Create a request' : 'Edit a request'), 'reques
<input type="hidden" id="amount" name="amount" value="<?=(!empty($Bounty) ? $Bounty : '100')?>" />
<input type="hidden" id="current_uploaded" value="<?=$LoggedUser['BytesUploaded']?>" />
<input type="hidden" id="current_downloaded" value="<?=$LoggedUser['BytesDownloaded']?>" />
+ Bounty after tax: <strong><span id="bounty_after_tax">90.00 MB</span></strong><br />
If you add the entered <strong><span id="new_bounty">100.00 MB</span></strong> of bounty, your new stats will be: <br />
- Uploaded: <span id="new_uploaded"><?=Format::get_size($LoggedUser['BytesUploaded'])?></span>
+ Uploaded: <span id="new_uploaded"><?=Format::get_size($LoggedUser['BytesUploaded'])?></span><br />
Ratio: <span id="new_ratio"><?=Format::get_ratio_html($LoggedUser['BytesUploaded'], $LoggedUser['BytesDownloaded'])?></span>
</td>
</tr>
@@ -402,7 +403,7 @@ View::show_header(($NewRequest ? 'Create a request' : 'Edit a request'), 'reques
<? } ?>
</table>
</form>
- <script type="text/javascript">ToggleLogCue(); <?=$NewRequest ? "Calculate();" : '' ?></script>
+ <script type="text/javascript">ToggleLogCue();<?=$NewRequest ? " Calculate();" : '' ?></script>
<script type="text/javascript">Categories();</script>
</div>
</div>
diff --git a/sections/requests/request.php b/sections/requests/request.php
index d4de092..0b7e24d 100644
--- a/sections/requests/request.php
+++ b/sections/requests/request.php
@@ -402,8 +402,9 @@ $google_url = 'https://www.google.com/search?tbm=shop&amp;q=' . "$encoded_artist
<input type="hidden" id="current_downloaded" value="<?=$LoggedUser['BytesDownloaded']?>" />
<input type="hidden" id="current_rr" value="<?=(float)$LoggedUser['RequiredRatio']?>" />
<input id="total_bounty" type="hidden" value="<?=$RequestVotes['TotalBounty']?>" />
+ Bounty after tax: <strong><span id="bounty_after_tax">0.00 MB</span></strong><br />
If you add the entered <strong><span id="new_bounty">0.00 MB</span></strong> of bounty, your new stats will be: <br />
- Uploaded: <span id="new_uploaded"><?=Format::get_size($LoggedUser['BytesUploaded'])?></span>
+ Uploaded: <span id="new_uploaded"><?=Format::get_size($LoggedUser['BytesUploaded'])?></span><br />
Ratio: <span id="new_ratio"><?=Format::get_ratio_html($LoggedUser['BytesUploaded'],$LoggedUser['BytesDownloaded'])?></span>
<input type="button" id="button" value="Vote!" disabled="disabled" onclick="Vote();" />
</form>
diff --git a/sections/requests/requests.php.presphinx b/sections/requests/requests.php.presphinx
index c1624fc..e8ba052 100644
--- a/sections/requests/requests.php.presphinx
+++ b/sections/requests/requests.php.presphinx
@@ -190,11 +190,11 @@ switch ($CurrentOrder) {
$OrderBy = "r.ID";
break;
}
-$OrderBy = $OrderBy." ".$CurrentSort;
+$OrderBy = "$OrderBy $CurrentSort";
$Matcher = 'AND';
if (count($Wheres)) {
- $Where = 'WHERE ('.implode(") ".$Matcher." (", $Wheres).")";
+ $Where = 'WHERE ('.implode(") $Matcher (", $Wheres).')';
} else {
$Where = '';
}
@@ -206,31 +206,32 @@ if (count($ExtraJoins)) {
}
// Build SQL query
-$DB->query("SELECT
- SQL_CALC_FOUND_ROWS
- r.ID,
- r.CategoryID,
- r.Title,
- r.Year,
- SUM(rv.Bounty) AS Bounty,
- COUNT(rv.UserID) AS Votes,
- r.FillerID,
- filler.Username,
- r.TorrentID,
- r.TimeFilled,
- r.UserID,
- u.Username,
- r.TimeAdded,
- r.LastVote
- FROM requests AS r
- LEFT JOIN users_main AS u ON u.ID=r.UserID
- LEFT JOIN users_main AS filler ON filler.ID = FillerID
- LEFT JOIN requests_votes AS rv ON rv.RequestID=r.ID "
- .$ExtraJoin." "
- .$Where."
- GROUP BY r.ID
- ORDER BY ".$OrderBy."
- LIMIT ".$Limit);
+$DB->query("
+ SELECT
+ SQL_CALC_FOUND_ROWS
+ r.ID,
+ r.CategoryID,
+ r.Title,
+ r.Year,
+ SUM(rv.Bounty) AS Bounty,
+ COUNT(rv.UserID) AS Votes,
+ r.FillerID,
+ filler.Username,
+ r.TorrentID,
+ r.TimeFilled,
+ r.UserID,
+ u.Username,
+ r.TimeAdded,
+ r.LastVote
+ FROM requests AS r
+ LEFT JOIN users_main AS u ON u.ID = r.UserID
+ LEFT JOIN users_main AS filler ON filler.ID = FillerID
+ LEFT JOIN requests_votes AS rv ON rv.RequestID = r.ID
+ $ExtraJoin
+ $Where
+ GROUP BY r.ID
+ ORDER BY $OrderBy
+ LIMIT $Limit");
$Requests = $DB->to_array();
diff --git a/sections/requests/take_warn.php b/sections/requests/take_warn.php
index fe6719e..174e7d8 100644
--- a/sections/requests/take_warn.php
+++ b/sections/requests/take_warn.php
@@ -55,7 +55,7 @@ list($Page) = $DB->next_record();
if ($LoggedUser['ID'] != $AuthorID && !check_perms('site_moderate_forums')) {
error(404);
}
-if ($DB->record_count() == 0) {
+if (!$DB->has_results()) {
error(404);
}
diff --git a/sections/requests/takedelete.php b/sections/requests/takedelete.php
index 1223d58..5fc24ce 100644
--- a/sections/requests/takedelete.php
+++ b/sections/requests/takedelete.php
@@ -16,7 +16,7 @@ $DB->query("
CategoryID,
GroupID
FROM requests
- WHERE ID = ".$RequestID);
+ WHERE ID = $RequestID");
list($UserID, $Title, $CategoryID, $GroupID) = $DB->next_record();
if ($LoggedUser['ID'] != $UserID && !check_perms('site_moderate_requests')) {
@@ -40,23 +40,28 @@ if ($CategoryName == 'Music') {
$DB->query("DELETE FROM requests WHERE ID='$RequestID'");
$DB->query("DELETE FROM requests_votes WHERE RequestID='$RequestID'");
$DB->query("DELETE FROM requests_tags WHERE RequestID='$RequestID'");
-$DB->query("SELECT ArtistID FROM requests_artists WHERE RequestID = ".$RequestID);
+$DB->query("
+ SELECT ArtistID
+ FROM requests_artists
+ WHERE RequestID = $RequestID");
$RequestArtists = $DB->to_array();
foreach ($RequestArtists as $RequestArtist) {
- $Cache->delete_value('artists_requests_'.$RequestArtist);
+ $Cache->delete_value("artists_requests_$RequestArtist");
}
-$DB->query("DELETE FROM requests_artists WHERE RequestID='$RequestID'");
+$DB->query("
+ DELETE FROM requests_artists
+ WHERE RequestID = '$RequestID'");
if ($UserID != $LoggedUser['ID']) {
- Misc::send_pm($UserID, 0, 'A request you created has been deleted', "The request '$FullName' was deleted by [url=https://".SSL_SITE_URL."/user.php?id=".$LoggedUser['ID'].']'.$LoggedUser['Username']."[/url] for the reason: ".$_POST['reason']);
+ Misc::send_pm($UserID, 0, 'A request you created has been deleted', "The request \"$FullName\" was deleted by [url=https://".SSL_SITE_URL.'/user.php?id='.$LoggedUser['ID'].']'.$LoggedUser['Username'].'[/url] for the reason: '.$_POST['reason']);
}
Misc::write_log("Request $RequestID ($FullName) was deleted by user ".$LoggedUser['ID'].' ('.$LoggedUser['Username'].') for the reason: '.$_POST['reason']);
-$Cache->delete_value('request_'.$RequestID);
-$Cache->delete_value('request_votes_'.$RequestID);
+$Cache->delete_value("request_$RequestID");
+$Cache->delete_value("request_votes_$RequestID");
if ($GroupID) {
- $Cache->delete_value('requests_group_'.$GroupID);
+ $Cache->delete_value("requests_group_$GroupID");
}
Requests::update_sphinx_requests($RequestID);
diff --git a/sections/requests/takefill.php b/sections/requests/takefill.php
index d3f17df..b7b8c70 100644
--- a/sections/requests/takefill.php
+++ b/sections/requests/takefill.php
@@ -43,11 +43,11 @@ $DB->query("
tg.CategoryID,
IF(t.Remastered = '1', t.RemasterCatalogueNumber, tg.CatalogueNumber)
FROM torrents AS t
- LEFT JOIN torrents_group AS tg ON t.GroupID=tg.ID
+ LEFT JOIN torrents_group AS tg ON t.GroupID = tg.ID
WHERE t.ID = $TorrentID
LIMIT 1");
-if ($DB->record_count() < 1) {
+if (!$DB->has_results()) {
error(404);
}
list($UploaderID, $UploadTime, $TorrentReleaseType, $Bitrate, $Format, $Media, $HasLog, $HasCue, $LogScore, $TorrentCategoryID, $TorrentCatalogueNumber) = $DB->next_record();
@@ -57,8 +57,11 @@ $FillerUsername = $LoggedUser['Username'];
if (!empty($_POST['user']) && check_perms('site_moderate_requests')) {
$FillerUsername = $_POST['user'];
- $DB->query("SELECT ID FROM users_main WHERE Username LIKE '".db_string($FillerUsername)."'");
- if ($DB->record_count() < 1) {
+ $DB->query("
+ SELECT ID
+ FROM users_main
+ WHERE Username LIKE '".db_string($FillerUsername)."'");
+ if (!$DB->has_results()) {
$Err = 'No such user to fill for!';
} else {
list($FillerID) = $DB->next_record();
@@ -83,7 +86,7 @@ $DB->query("
MediaList,
LogCue
FROM requests
- WHERE ID = ".$RequestID);
+ WHERE ID = $RequestID");
list($Title, $RequesterID, $OldTorrentID, $RequestCategoryID, $RequestReleaseType, $RequestCatalogueNumber, $BitrateList, $FormatList, $MediaList, $LogCue) = $DB->next_record();
diff --git a/sections/requests/takenew_edit.php b/sections/requests/takenew_edit.php
index 4b63c68..086c733 100644
--- a/sections/requests/takenew_edit.php
+++ b/sections/requests/takenew_edit.php
@@ -164,7 +164,7 @@ if ($CategoryName == "Music") {
}
if (($NeedCue || $NeedLog)) {
- if (empty($_POST['all_media']) && !(in_array('0',$MediaArray))) {
+ if (empty($_POST['all_media']) && !(in_array('0', $MediaArray))) {
$Err = 'Only CD is allowed as media for FLAC + log/cue requests.';
}
}
@@ -181,8 +181,12 @@ if ($CategoryName == "Music") {
$GroupID = $Matches[4];
}
if (is_number($GroupID)) {
- $DB->query("SELECT 1 FROM torrents_group WHERE ID = '$GroupID' AND CategoryID = 1");
- if ($DB->record_count() == 0) {
+ $DB->query("
+ SELECT 1
+ FROM torrents_group
+ WHERE ID = '$GroupID'
+ AND CategoryID = 1");
+ if (!$DB->has_results()) {
$Err = 'The torrent group, if entered, must correspond to a music torrent group on the site.';
}
} else {
@@ -361,18 +365,23 @@ if ($CategoryName == 'Music') {
OCLC = '".db_string($OCLC)."'
WHERE ID = ".$RequestID);
- //I almost didn't think of this, we need to be able to delete artists / tags
- $DB->query("SELECT ArtistID FROM requests_artists WHERE RequestID = ".$RequestID);
+ // We need to be able to delete artists / tags
+ $DB->query("
+ SELECT ArtistID
+ FROM requests_artists
+ WHERE RequestID = $RequestID");
$RequestArtists = $DB->to_array();
foreach ($RequestArtists as $RequestArtist) {
- $Cache->delete_value('artists_requests_'.$RequestArtist);
+ $Cache->delete_value("artists_requests_$RequestArtist");
}
- $DB->query("DELETE FROM requests_artists WHERE RequestID = ".$RequestID);
- $Cache->delete_value('request_artists_'.$RequestID);
+ $DB->query("
+ DELETE FROM requests_artists
+ WHERE RequestID = $RequestID");
+ $Cache->delete_value("request_artists_$RequestID");
}
if ($GroupID) {
- $Cache->delete_value('requests_group_'.$GroupID);
+ $Cache->delete_value("requests_group_$GroupID");
}
/*
@@ -429,8 +438,10 @@ if ($CategoryName == 'Music') {
foreach ($ArtistForm as $Importance => $Artists) {
foreach ($Artists as $Num => $Artist) {
$DB->query("
- INSERT IGNORE INTO requests_artists (RequestID, ArtistID, AliasID, Importance)
- VALUES ($RequestID, ".$Artist['id'].", ".$Artist['aliasid'].", '$Importance')");
+ INSERT IGNORE INTO requests_artists
+ (RequestID, ArtistID, AliasID, Importance)
+ VALUES
+ ($RequestID, ".$Artist['id'].', '.$Artist['aliasid'].", '$Importance')");
$Cache->increment('stats_album_count');
$Cache->delete_value('artists_requests_'.$Artist['id']);
}
@@ -441,7 +452,10 @@ if ($CategoryName == 'Music') {
} else {
//Not a music request anymore, delete music only fields.
if (!$NewRequest) {
- $DB->query("SELECT ArtistID FROM requests_artists WHERE RequestID = ".$RequestID);
+ $DB->query("
+ SELECT ArtistID
+ FROM requests_artists
+ WHERE RequestID = $RequestID");
$OldArtists = $DB->collect('ArtistID');
foreach ($OldArtists as $ArtistID) {
if (empty($ArtistID)) {
@@ -451,14 +465,14 @@ if ($CategoryName == 'Music') {
$DB->query("
SELECT COUNT(ag.ArtistID)
FROM artists_group as ag
- LEFT JOIN requests_artists AS ra ON ag.ArtistID=ra.ArtistID
+ LEFT JOIN requests_artists AS ra ON ag.ArtistID = ra.ArtistID
WHERE ra.ArtistID IS NOT NULL
AND ag.ArtistID = '$ArtistID'");
list($ReqCount) = $DB->next_record();
$DB->query("
SELECT COUNT(ag.ArtistID)
FROM artists_group as ag
- LEFT JOIN torrents_artists AS ta ON ag.ArtistID=ta.ArtistID
+ LEFT JOIN torrents_artists AS ta ON ag.ArtistID = ta.ArtistID
WHERE ta.ArtistID IS NOT NULL
AND ag.ArtistID = '$ArtistID'");
list($GroupCount) = $DB->next_record();
@@ -467,10 +481,12 @@ if ($CategoryName == 'Music') {
Artists::delete_artist($ArtistID);
} else {
//Not the only group, still need to clear cache
- $Cache->delete_value('artists_requests_'.$ArtistID);
+ $Cache->delete_value("artists_requests_$ArtistID");
}
}
- $DB->query("DELETE FROM requests_artists WHERE RequestID = ".$RequestID);
+ $DB->query("
+ DELETE FROM requests_artists
+ WHERE RequestID = $RequestID");
}
if ($CategoryName == 'Audiobooks' || $CategoryName == 'Comedy') {
@@ -492,7 +508,7 @@ if ($CategoryName == 'Music') {
Image = '".db_string($Image)."',
Description = '".db_string($Description)."',
OCLC = '".db_string($OCLC)."'
- WHERE ID = ".$RequestID);
+ WHERE ID = $RequestID");
}
} else {
if ($NewRequest) {
@@ -512,14 +528,16 @@ if ($CategoryName == 'Music') {
Image = '".db_string($Image)."',
Description = '".db_string($Description)."',
OCLC = '".db_string($OCLC)."'
- WHERE ID = ".$RequestID);
+ WHERE ID = $RequestID");
}
}
}
//Tags
if (!$NewRequest) {
- $DB->query("DELETE FROM requests_tags WHERE RequestID = ".$RequestID);
+ $DB->query("
+ DELETE FROM requests_tags
+ WHERE RequestID = $RequestID");
}
$Tags = array_unique(explode(',', $Tags));
@@ -527,28 +545,34 @@ foreach ($Tags as $Index => $Tag) {
$Tag = Misc::sanitize_tag($Tag);
$Tag = Misc::get_alias_tag($Tag);
$Tags[$Index] = $Tag; //For announce
- $DB->query("INSERT INTO tags
- (Name, UserID)
- VALUES
- ('$Tag', ".$LoggedUser['ID'].")
- ON DUPLICATE KEY UPDATE Uses=Uses+1");
+ $DB->query("
+ INSERT INTO tags
+ (Name, UserID)
+ VALUES
+ ('$Tag', ".$LoggedUser['ID'].")
+ ON DUPLICATE KEY UPDATE Uses = Uses + 1");
$TagID = $DB->inserted_id();
- $DB->query("INSERT IGNORE INTO requests_tags
- (TagID, RequestID)
- VALUES
- ($TagID, $RequestID)");
+ $DB->query("
+ INSERT IGNORE INTO requests_tags
+ (TagID, RequestID)
+ VALUES
+ ($TagID, $RequestID)");
}
if ($NewRequest) {
//Remove the bounty and create the vote
- $DB->query("INSERT INTO requests_votes
- (RequestID, UserID, Bounty)
- VALUES
- ($RequestID, ".$LoggedUser['ID'].', '.($Bytes * (1 - $RequestTax)).')');
-
- $DB->query("UPDATE users_main SET Uploaded = (Uploaded - $Bytes) WHERE ID = ".$LoggedUser['ID']);
+ $DB->query("
+ INSERT INTO requests_votes
+ (RequestID, UserID, Bounty)
+ VALUES
+ ($RequestID, ".$LoggedUser['ID'].', '.($Bytes * (1 - $RequestTax)).')');
+
+ $DB->query("
+ UPDATE users_main
+ SET Uploaded = (Uploaded - $Bytes)
+ WHERE ID = ".$LoggedUser['ID']);
$Cache->delete_value('user_stats_'.$LoggedUser['ID']);
@@ -558,14 +582,14 @@ if ($NewRequest) {
} else {
$Announce = "\"$Title\" - https://".SSL_SITE_URL."/requests.php?action=view&id=$RequestID - ".implode(' ', $Tags);
}
- send_irc('PRIVMSG #'.SSL_SITE_URL.'-requests :'.$Announce);
+ send_irc('PRIVMSG #'.SSL_SITE_URL."-requests :$Announce");
} else {
- $Cache->delete_value('request_'.$RequestID);
- $Cache->delete_value('request_artists_'.$RequestID);
+ $Cache->delete_value("request_$RequestID");
+ $Cache->delete_value("request_artists_$RequestID");
}
Requests::update_sphinx_requests($RequestID);
-header('Location: requests.php?action=view&id='.$RequestID);
+header("Location: requests.php?action=view&id=$RequestID");
?>
diff --git a/sections/requests/takeunfill.php b/sections/requests/takeunfill.php
index ae1bbf0..33546ca 100644
--- a/sections/requests/takeunfill.php
+++ b/sections/requests/takeunfill.php
@@ -18,8 +18,8 @@ $DB->query("
u.Uploaded,
r.GroupID
FROM requests AS r
- LEFT JOIN users_main AS u ON u.ID=FillerID
- WHERE r.ID= ".$RequestID);
+ LEFT JOIN users_main AS u ON u.ID = FillerID
+ WHERE r.ID = $RequestID");
list($CategoryID, $UserID, $FillerID, $Title, $Uploaded, $GroupID) = $DB->next_record();
if ((($LoggedUser['ID'] != $UserID && $LoggedUser['ID'] != $FillerID) && !check_perms('site_moderate_requests')) || $FillerID == 0) {
@@ -33,7 +33,7 @@ $DB->query("
FillerID = 0,
TimeFilled = '0000-00-00 00:00:00',
Visible = 1
- WHERE ID = ".$RequestID);
+ WHERE ID = $RequestID");
$CategoryName = $Categories[$CategoryID - 1];
@@ -49,14 +49,23 @@ $RequestVotes = Requests::get_votes_array($RequestID);
if ($RequestVotes['TotalBounty'] > $Uploaded) {
// If we can't take it all out of upload, zero that out and add whatever is left as download.
- $DB->query('UPDATE users_main SET Uploaded = 0 WHERE ID = '.$FillerID);
- $DB->query('UPDATE users_main SET Downloaded = Downloaded + '.($RequestVotes['TotalBounty'] - $Uploaded).' WHERE ID = '.$FillerID);
+ $DB->query("
+ UPDATE users_main
+ SET Uploaded = 0
+ WHERE ID = $FillerID");
+ $DB->query('
+ UPDATE users_main
+ SET Downloaded = Downloaded + '.($RequestVotes['TotalBounty'] - $Uploaded)."
+ WHERE ID = $FillerID");
} else {
- $DB->query('UPDATE users_main SET Uploaded = Uploaded - '.$RequestVotes['TotalBounty'].' WHERE ID = '.$FillerID);
+ $DB->query('
+ UPDATE users_main
+ SET Uploaded = Uploaded - '.$RequestVotes['TotalBounty']."
+ WHERE ID = $FillerID");
}
Misc::send_pm($FillerID, 0, 'A request you filled has been unfilled', "The request \"[url=https://".SSL_SITE_URL."/requests.php?action=view&amp;id=$RequestID]".$FullName."[/url]\" was unfilled by [url=https://".SSL_SITE_URL.'/user.php?id='.$LoggedUser['ID'].']'.$LoggedUser['Username'].'[/url] for the reason: '.$_POST['reason']."\n\nIf you feel like this request was unjustly unfilled, please [url=https://".SSL_SITE_URL."/reports.php?action=report&amp;type=request&amp;id=$RequestID]report the request[/url] and explain why this request should not have been unfilled.");
-$Cache->delete_value('user_stats_'.$FillerID);
+$Cache->delete_value("user_stats_$FillerID");
if ($UserID != $LoggedUser['ID']) {
Misc::send_pm($UserID, 0, 'A request you created has been unfilled', "The request \"[url=https://".SSL_SITE_URL."/requests.php?action=view&amp;id=$RequestID]".$FullName."[/url]\" was unfilled by [url=https://".SSL_SITE_URL.'/user.php?id='.$LoggedUser['ID'].']'.$LoggedUser['Username']."[/url] for the reason: ".$_POST['reason']);
@@ -64,10 +73,10 @@ if ($UserID != $LoggedUser['ID']) {
Misc::write_log("Request $RequestID ($FullName), with a ".Format::get_size($RequestVotes['TotalBounty']).' bounty, was unfilled by user '.$LoggedUser['ID'].' ('.$LoggedUser['Username'].') for the reason: '.$_POST['reason']);
-$Cache->delete_value('request_'.$RequestID);
-$Cache->delete_value('request_artists_'.$RequestID);
+$Cache->delete_value("request_$RequestID");
+$Cache->delete_value("request_artists_$RequestID");
if ($GroupID) {
- $Cache->delete_value('requests_group_'.$GroupID);
+ $Cache->delete_value("requests_group_$GroupID");
}
Requests::update_sphinx_requests($RequestID);
@@ -81,5 +90,5 @@ if (!empty($ArtistForm)) {
}
-header('Location: requests.php?action=view&id='.$RequestID);
+header("Location: requests.php?action=view&id=$RequestID");
?>
diff --git a/sections/requests/takevote.php b/sections/requests/takevote.php
index 12eb687..a239401 100644
--- a/sections/requests/takevote.php
+++ b/sections/requests/takevote.php
@@ -23,7 +23,10 @@ if (empty($_GET['amount']) || !is_number($_GET['amount']) || $_GET['amount'] < $
$Bounty = ($Amount * (1 - $RequestTax));
-$DB->query('SELECT TorrentID FROM requests WHERE ID='.$RequestID);
+$DB->query("
+ SELECT TorrentID
+ FROM requests
+ WHERE ID = $RequestID");
list($Filled) = $DB->next_record();
if ($LoggedUser['BytesUploaded'] >= $Amount && $Filled == 0) {
@@ -41,16 +44,19 @@ if ($LoggedUser['BytesUploaded'] >= $Amount && $Filled == 0) {
UPDATE requests_votes
SET Bounty = (Bounty + $Bounty)
WHERE UserID = ".$LoggedUser['ID']."
- AND RequestID = ".$RequestID);
+ AND RequestID = $RequestID");
echo 'dupe';
}
- $DB->query("UPDATE requests SET LastVote = NOW() WHERE ID = ".$RequestID);
+ $DB->query("
+ UPDATE requests
+ SET LastVote = NOW()
+ WHERE ID = $RequestID");
- $Cache->delete_value('request_'.$RequestID);
- $Cache->delete_value('request_votes_'.$RequestID);
+ $Cache->delete_value("request_$RequestID");
+ $Cache->delete_value("request_votes_$RequestID");
$ArtistForm = Requests::get_artists($RequestID);
foreach ($ArtistForm as $Importance) {
@@ -60,7 +66,10 @@ if ($LoggedUser['BytesUploaded'] >= $Amount && $Filled == 0) {
}
// Subtract amount from user
- $DB->query("UPDATE users_main SET Uploaded = (Uploaded - $Amount) WHERE ID = ".$LoggedUser['ID']);
+ $DB->query("
+ UPDATE users_main
+ SET Uploaded = (Uploaded - $Amount)
+ WHERE ID = ".$LoggedUser['ID']);
$Cache->delete_value('user_stats_'.$LoggedUser['ID']);
Requests::update_sphinx_requests($RequestID);
diff --git a/sections/rules/clients.php b/sections/rules/clients.php
index dfed307..6b9ded3 100644
--- a/sections/rules/clients.php
+++ b/sections/rules/clients.php
@@ -2,9 +2,13 @@
View::show_header('Client Rules');
if (!$WhitelistedClients = $Cache->get_value('whitelisted_clients')) {
- $DB->query('SELECT vstring FROM xbt_client_whitelist WHERE vstring NOT LIKE \'//%\' ORDER BY vstring ASC');
- $WhitelistedClients = $DB->to_array(false,MYSQLI_NUM,false);
- $Cache->cache_value('whitelisted_clients',$WhitelistedClients,604800);
+ $DB->query('
+ SELECT vstring
+ FROM xbt_client_whitelist
+ WHERE vstring NOT LIKE \'//%\'
+ ORDER BY vstring ASC');
+ $WhitelistedClients = $DB->to_array(false, MYSQLI_NUM, false);
+ $Cache->cache_value('whitelisted_clients', $WhitelistedClients, 604800);
}
?>
<div class="thin">
@@ -21,7 +25,7 @@ if (!$WhitelistedClients = $Cache->get_value('whitelisted_clients')) {
<?
$Row = 'a';
foreach ($WhitelistedClients as $Client) {
- //list($ClientName,$Notes) = $Client;
+ //list($ClientName, $Notes) = $Client;
list($ClientName) = $Client;
$Row = ($Row == 'a') ? 'b' : 'a';
?>
diff --git a/sections/schedule/index.php b/sections/schedule/index.php
index 2b47103..ccf4d9a 100644
--- a/sections/schedule/index.php
+++ b/sections/schedule/index.php
@@ -15,7 +15,7 @@ INSERT INTO users_geodistribution
SELECT g.Code, COUNT(u.ID) AS Users
FROM geoip_country AS g
JOIN users_main AS u ON INET_ATON(u.IP) BETWEEN g.StartIP AND g.EndIP
-WHERE u.Enabled='1'
+WHERE u.Enabled = '1'
GROUP BY g.Code
ORDER BY Users DESC
*/
@@ -57,9 +57,16 @@ if (check_perms('admin_schedule')) {
echo '<pre>';
}
-$DB->query("SELECT NextHour, NextDay, NextBiWeekly FROM schedule");
+$DB->query("
+ SELECT NextHour, NextDay, NextBiWeekly
+ FROM schedule");
list($Hour, $Day, $BiWeek) = $DB->next_record();
-$DB->query("UPDATE schedule SET NextHour = ".next_hour().", NextDay = ".next_day().", NextBiWeekly = ".next_biweek());
+$DB->query("
+ UPDATE schedule
+ SET
+ NextHour = ".next_hour().",
+ NextDay = ".next_day().",
+ NextBiWeekly = ".next_biweek());
$NoDaily = isset($argv[2]) && $argv[2] == 'nodaily';
@@ -80,32 +87,34 @@ echo "Ran every-time functions\n";
//------------- Freeleech -----------------------------------------------//
-//We use this to control 6 hour freeleeches. They're actually 7 hour, but don't tell anyone.
+//We use this to control 6 hour freeleeches. They're actually 7 hours, but don't tell anyone.
/*
$TimeMinus = time_minus(3600 * 7);
$DB->query("
SELECT DISTINCT GroupID
FROM torrents
- WHERE FreeTorrent='1'
- AND FreeLeechType='3'
- AND Time<'$TimeMinus'");
+ WHERE FreeTorrent = '1'
+ AND FreeLeechType = '3'
+ AND Time < '$TimeMinus'");
while (list($GroupID) = $DB->next_record()) {
- $Cache->delete_value('torrents_details_'.$GroupID);
- $Cache->delete_value('torrent_group_'.$GroupID);
+ $Cache->delete_value("torrents_details_$GroupID");
+ $Cache->delete_value("torrent_group_$GroupID");
}
$DB->query("
UPDATE torrents
- SET FreeTorrent='0',
- FreeLeechType='0',
- flags='2'
- WHERE FreeTorrent='1'
- AND FreeLeechType='3'
- AND Time<'$TimeMinus'");
+ SET FreeTorrent = '0',
+ FreeLeechType = '0',
+ flags = '2'
+ WHERE FreeTorrent = '1'
+ AND FreeLeechType = '3'
+ AND Time < '$TimeMinus'");
*/
sleep(5);
//------------- Delete unpopular tags -----------------------------------//
-$DB->query("DELETE FROM torrents_tags WHERE NegativeVotes>PositiveVotes");
+$DB->query("
+ DELETE FROM torrents_tags
+ WHERE NegativeVotes > PositiveVotes");
//------------- Expire old FL Tokens and clear cache where needed ------//
$sqltime = sqltime();
@@ -151,32 +160,46 @@ if ($Hour != next_hour() || $_GET['runhour'] || isset($argv[2])) {
//Love or hate, this makes things a hell of a lot faster
if ($Hour % 2 == 0) {
- $DB->query("SELECT COUNT(uid) AS Snatches FROM xbt_snatched");
+ $DB->query("
+ SELECT COUNT(uid) AS Snatches
+ FROM xbt_snatched");
list($SnatchStats) = $DB->next_record();
$Cache->cache_value('stats_snatches', $SnatchStats, 0);
}
$DB->query("
- SELECT IF(remaining=0,'Seeding','Leeching') AS Type,
+ SELECT IF(remaining = 0, 'Seeding', 'Leeching') AS Type,
COUNT(uid)
FROM xbt_files_users
- WHERE active=1
+ WHERE active = 1
GROUP BY Type");
$PeerCount = $DB->to_array(0, MYSQLI_NUM, false);
$SeederCount = isset($PeerCount['Seeding'][1]) ? $PeerCount['Seeding'][1] : 0;
$LeecherCount = isset($PeerCount['Leeching'][1]) ? $PeerCount['Leeching'][1] : 0;
$Cache->cache_value('stats_peers', array($LeecherCount, $SeederCount), 0);
- $DB->query("SELECT COUNT(ID) FROM users_main WHERE Enabled='1' AND LastAccess>'".time_minus(3600 * 24)."'");
+ $DB->query("
+ SELECT COUNT(ID)
+ FROM users_main
+ WHERE Enabled = '1'
+ AND LastAccess > '".time_minus(3600 * 24)."'");
list($UserStats['Day']) = $DB->next_record();
- $DB->query("SELECT COUNT(ID) FROM users_main WHERE Enabled='1' AND LastAccess>'".time_minus(3600 * 24 * 7)."'");
+ $DB->query("
+ SELECT COUNT(ID)
+ FROM users_main
+ WHERE Enabled = '1'
+ AND LastAccess > '".time_minus(3600 * 24 * 7)."'");
list($UserStats['Week']) = $DB->next_record();
- $DB->query("SELECT COUNT(ID) FROM users_main WHERE Enabled='1' AND LastAccess>'".time_minus(3600 * 24 * 30)."'");
+ $DB->query("
+ SELECT COUNT(ID)
+ FROM users_main
+ WHERE Enabled = '1'
+ AND LastAccess > '".time_minus(3600 * 24 * 30)."'");
list($UserStats['Month']) = $DB->next_record();
- $Cache->cache_value('stats_users',$UserStats,0);
+ $Cache->cache_value('stats_users', $UserStats, 0);
//------------- Record who's seeding how much, used for ratio watch
@@ -186,11 +209,10 @@ if ($Hour != next_hour() || $_GET['runhour'] || isset($argv[2])) {
$DB->query("
INSERT INTO users_torrent_history_temp
(UserID, NumTorrents)
- SELECT uid,
- COUNT(DISTINCT fid)
+ SELECT uid, COUNT(DISTINCT fid)
FROM xbt_files_users
- WHERE mtime>unix_timestamp(NOW()-INTERVAL 1 HOUR)
- AND Remaining=0
+ WHERE mtime > unix_timestamp(NOW() - INTERVAL 1 HOUR)
+ AND Remaining = 0
GROUP BY uid");
// Mark new records as "checked" and set the current time as the time
@@ -199,12 +221,12 @@ if ($Hour != next_hour() || $_GET['runhour'] || isset($argv[2])) {
// This query will only do something if the next one inserted new rows last hour.
$DB->query("
UPDATE users_torrent_history AS h
- JOIN users_torrent_history_temp AS t ON t.UserID=h.UserID
- AND t.NumTorrents=h.NumTorrents
- SET h.Finished='0',
- h.LastTime=UNIX_TIMESTAMP(NOW())
- WHERE h.Finished='1'
- AND h.Date=UTC_DATE()+0");
+ JOIN users_torrent_history_temp AS t ON t.UserID = h.UserID
+ AND t.NumTorrents = h.NumTorrents
+ SET h.Finished = '0',
+ h.LastTime = UNIX_TIMESTAMP(NOW())
+ WHERE h.Finished = '1'
+ AND h.Date = UTC_DATE() + 0");
// Insert new rows for users who haven't been seeding exactly <NumTorrents> torrents earlier today
// and update the time spent seeding <NumTorrents> torrents for the others.
@@ -212,68 +234,72 @@ if ($Hour != next_hour() || $_GET['runhour'] || isset($argv[2])) {
$DB->query("
INSERT INTO users_torrent_history
(UserID, NumTorrents, Date)
- SELECT UserID, NumTorrents, UTC_DATE()+0
+ SELECT UserID, NumTorrents, UTC_DATE() + 0
FROM users_torrent_history_temp
ON DUPLICATE KEY UPDATE
- Time=Time+UNIX_TIMESTAMP(NOW())-LastTime,
- LastTime=UNIX_TIMESTAMP(NOW())");
+ Time = Time + UNIX_TIMESTAMP(NOW()) - LastTime,
+ LastTime = UNIX_TIMESTAMP(NOW())");
//------------- Promote users -------------------------------------------//
sleep(5);
$Criteria = array();
- $Criteria[] = array('From'=>USER, 'To'=>MEMBER, 'MinUpload'=>10 * 1024 * 1024 * 1024, 'MinRatio'=>0.7, 'MinUploads'=>0, 'MaxTime'=>time_minus(3600 * 24 * 7));
- $Criteria[] = array('From'=>MEMBER, 'To'=>POWER, 'MinUpload'=>25 * 1024 * 1024 * 1024, 'MinRatio'=>1.05, 'MinUploads'=>5, 'MaxTime'=>time_minus(3600 * 24 * 7 * 2));
- $Criteria[] = array('From'=>POWER, 'To'=>ELITE, 'MinUpload'=>100 * 1024 * 1024 * 1024, 'MinRatio'=>1.05, 'MinUploads'=>50, 'MaxTime'=>time_minus(3600 * 24 * 7 * 4));
- $Criteria[] = array('From'=>ELITE, 'To'=>TORRENT_MASTER, 'MinUpload'=>500 * 1024 * 1024 * 1024, 'MinRatio'=>1.05, 'MinUploads'=>500, 'MaxTime'=>time_minus(3600 * 24 * 7 * 8));
+ $Criteria[] = array('From' => USER, 'To' => MEMBER, 'MinUpload' => 10 * 1024 * 1024 * 1024, 'MinRatio' => 0.7, 'MinUploads' => 0, 'MaxTime' => time_minus(3600 * 24 * 7));
+ $Criteria[] = array('From' => MEMBER, 'To' => POWER, 'MinUpload' => 25 * 1024 * 1024 * 1024, 'MinRatio' => 1.05, 'MinUploads' => 5, 'MaxTime' => time_minus(3600 * 24 * 7 * 2));
+ $Criteria[] = array('From' => POWER, 'To' => ELITE, 'MinUpload' => 100 * 1024 * 1024 * 1024, 'MinRatio' => 1.05, 'MinUploads' => 50, 'MaxTime' => time_minus(3600 * 24 * 7 * 4));
+ $Criteria[] = array('From' => ELITE, 'To' => TORRENT_MASTER, 'MinUpload' => 500 * 1024 * 1024 * 1024, 'MinRatio' => 1.05, 'MinUploads' => 500, 'MaxTime' => time_minus(3600 * 24 * 7 * 8));
$Criteria[] = array(
- 'From'=>TORRENT_MASTER,
- 'To'=>POWER_TM,
- 'MinUpload'=>500 * 1024 * 1024 * 1024,
- 'MinRatio'=>1.05,
- 'MinUploads'=>500,
- 'MaxTime'=>time_minus(3600 * 24 * 7 * 8),
- 'Extra'=>'( SELECT COUNT(DISTINCT GroupID)
- FROM torrents
- WHERE UserID=users_main.ID
- ) >= 500');
+ 'From' => TORRENT_MASTER,
+ 'To' => POWER_TM,
+ 'MinUpload' => 500 * 1024 * 1024 * 1024,
+ 'MinRatio' => 1.05,
+ 'MinUploads' => 500,
+ 'MaxTime' => time_minus(3600 * 24 * 7 * 8),
+ 'Extra' => '
+ (
+ SELECT COUNT(DISTINCT GroupID)
+ FROM torrents
+ WHERE UserID = users_main.ID
+ ) >= 500');
$Criteria[] = array(
- 'From'=>POWER_TM,
- 'To'=>ELITE_TM,
- 'MinUpload'=>500 * 1024 * 1024 * 1024,
- 'MinRatio'=>1.05,
- 'MinUploads'=>500,
- 'MaxTime'=>time_minus(3600 * 24 * 7 * 8),
- 'Extra'=>"( SELECT COUNT(ID)
- FROM torrents
- WHERE ((LogScore = 100 AND Format = 'FLAC')
- OR (Media = 'Vinyl' AND Format = 'FLAC')
- OR (Media = 'WEB' AND Format = 'FLAC')
- OR (Media = 'DVD' AND Format = 'FLAC')
- OR (Media = 'Soundboard' AND Format = 'FLAC')
- OR (Media = 'Cassette' AND Format = 'FLAC')
- OR (Media = 'SACD' AND Format = 'FLAC')
- OR (Media = 'Blu-ray' AND Format = 'FLAC')
- OR (Media = 'DAT' AND Format = 'FLAC')
- )
- AND UserID = users_main.ID
- ) >= 500");
+ 'From' => POWER_TM,
+ 'To' => ELITE_TM,
+ 'MinUpload' => 500 * 1024 * 1024 * 1024,
+ 'MinRatio' => 1.05,
+ 'MinUploads' => 500,
+ 'MaxTime' => time_minus(3600 * 24 * 7 * 8),
+ 'Extra' => "
+ (
+ SELECT COUNT(ID)
+ FROM torrents
+ WHERE ((LogScore = 100 AND Format = 'FLAC')
+ OR (Media = 'Vinyl' AND Format = 'FLAC')
+ OR (Media = 'WEB' AND Format = 'FLAC')
+ OR (Media = 'DVD' AND Format = 'FLAC')
+ OR (Media = 'Soundboard' AND Format = 'FLAC')
+ OR (Media = 'Cassette' AND Format = 'FLAC')
+ OR (Media = 'SACD' AND Format = 'FLAC')
+ OR (Media = 'Blu-ray' AND Format = 'FLAC')
+ OR (Media = 'DAT' AND Format = 'FLAC')
+ )
+ AND UserID = users_main.ID
+ ) >= 500");
foreach ($Criteria as $L) { // $L = Level
$Query = "
SELECT ID
FROM users_main
JOIN users_info ON users_main.ID = users_info.UserID
- WHERE PermissionID=".$L['From']."
- AND Warned= '0000-00-00 00:00:00'
- AND Uploaded>='$L[MinUpload]'
- AND (Uploaded/Downloaded >='$L[MinRatio]' OR (Uploaded/Downloaded IS NULL))
- AND JoinDate<'$L[MaxTime]'
+ WHERE PermissionID = ".$L['From']."
+ AND Warned = '0000-00-00 00:00:00'
+ AND Uploaded >= '$L[MinUpload]'
+ AND (Uploaded / Downloaded >='$L[MinRatio]' OR (Uploaded / Downloaded IS NULL))
+ AND JoinDate < '$L[MaxTime]'
AND (
SELECT COUNT(ID)
FROM torrents
- WHERE UserID=users_main.ID
+ WHERE UserID = users_main.ID
) >= '$L[MinUploads]'
- AND Enabled='1'";
+ AND Enabled = '1'";
if (!empty($L['Extra'])) {
$Query .= ' AND '.$L['Extra'];
}
@@ -284,13 +310,13 @@ if ($Hour != next_hour() || $_GET['runhour'] || isset($argv[2])) {
if (count($UserIDs) > 0) {
foreach ($UserIDs as $UserID) {
- /*$Cache->begin_transaction('user_info_'.$UserID);
- $Cache->update_row(false, array('PermissionID'=>$L['To']));
+ /*$Cache->begin_transaction("user_info_$UserID");
+ $Cache->update_row(false, array('PermissionID' => $L['To']));
$Cache->commit_transaction(0);*/
- $Cache->delete_value('user_info_'.$UserID);
- $Cache->delete_value('user_info_heavy_'.$UserID);
- $Cache->delete_value('user_stats_'.$UserID);
- $Cache->delete_value('enabled_'.$UserID);
+ $Cache->delete_value("user_info_$UserID");
+ $Cache->delete_value("user_info_heavy_$UserID");
+ $Cache->delete_value("user_stats_$UserID");
+ $Cache->delete_value("enabled_$UserID");
$DB->query("
UPDATE users_info
SET AdminComment = CONCAT('".sqltime()." - Class changed to ".Users::make_class_string($L['To'])." by System\n\n', AdminComment)
@@ -298,7 +324,7 @@ if ($Hour != next_hour() || $_GET['runhour'] || isset($argv[2])) {
}
$DB->query("
UPDATE users_main
- SET PermissionID=".$L['To']."
+ SET PermissionID = ".$L['To']."
WHERE ID IN(".implode(',', $UserIDs).')');
}
@@ -308,32 +334,32 @@ if ($Hour != next_hour() || $_GET['runhour'] || isset($argv[2])) {
SELECT ID
FROM users_main
JOIN users_info ON users_main.ID = users_info.UserID
- WHERE PermissionID='$L[To]'
- AND ( Uploaded<'$L[MinUpload]'
+ WHERE PermissionID = '$L[To]'
+ AND ( Uploaded < '$L[MinUpload]'
OR (
SELECT COUNT(ID)
FROM torrents
- WHERE UserID=users_main.ID
+ WHERE UserID = users_main.ID
) < '$L[MinUploads]'";
if (!empty($L['Extra'])) {
- $Query .= " OR NOT ".$L['Extra'];
+ $Query .= ' OR NOT '.$L['Extra'];
}
$Query .= "
)
- AND Enabled='1'";
+ AND Enabled = '1'";
$DB->query($Query);
$UserIDs = $DB->collect('ID');
if (count($UserIDs) > 0) {
foreach ($UserIDs as $UserID) {
- /*$Cache->begin_transaction('user_info_'.$UserID);
- $Cache->update_row(false, array('PermissionID'=>$L['From']));
+ /*$Cache->begin_transaction("user_info_$UserID");
+ $Cache->update_row(false, array('PermissionID' => $L['From']));
$Cache->commit_transaction(0);*/
- $Cache->delete_value('user_info_'.$UserID);
- $Cache->delete_value('user_info_heavy_'.$UserID);
- $Cache->delete_value('user_stats_'.$UserID);
- $Cache->delete_value('enabled_'.$UserID);
+ $Cache->delete_value("user_info_$UserID");
+ $Cache->delete_value("user_info_heavy_$UserID");
+ $Cache->delete_value("user_stats_$UserID");
+ $Cache->delete_value("enabled_$UserID");
$DB->query("
UPDATE users_info
SET AdminComment = CONCAT('".sqltime()." - Class changed to ".Users::make_class_string($L['From'])." by System\n\n', AdminComment)
@@ -341,7 +367,7 @@ if ($Hour != next_hour() || $_GET['runhour'] || isset($argv[2])) {
}
$DB->query("
UPDATE users_main
- SET PermissionID=".$L['From']."
+ SET PermissionID = ".$L['From']."
WHERE ID IN(".implode(',', $UserIDs).')');
}
}
@@ -349,20 +375,31 @@ if ($Hour != next_hour() || $_GET['runhour'] || isset($argv[2])) {
//------------- Expire invites ------------------------------------------//
sleep(3);
- $DB->query("SELECT InviterID FROM invites WHERE Expires<'$sqltime'");
+ $DB->query("
+ SELECT InviterID
+ FROM invites
+ WHERE Expires < '$sqltime'");
$Users = $DB->to_array();
foreach ($Users as $UserID) {
list($UserID) = $UserID;
- $DB->query("SELECT Invites, PermissionID FROM users_main WHERE ID=$UserID");
+ $DB->query("
+ SELECT Invites, PermissionID
+ FROM users_main
+ WHERE ID = $UserID");
list($Invites, $PermID) = $DB->next_record();
if (($Invites < 2 && $Classes[$PermID]['Level'] <= $Classes[POWER]['Level']) || ($Invites < 4 && $PermID == ELITE)) {
- $DB->query("UPDATE users_main SET Invites=Invites+1 WHERE ID=$UserID");
- $Cache->begin_transaction('user_info_heavy_'.$UserID);
+ $DB->query("
+ UPDATE users_main
+ SET Invites = Invites + 1
+ WHERE ID = $UserID");
+ $Cache->begin_transaction("user_info_heavy_$UserID");
$Cache->update_row(false, array('Invites' => '+1'));
$Cache->commit_transaction(0);
}
}
- $DB->query("DELETE FROM invites WHERE Expires<'$sqltime'");
+ $DB->query("
+ DELETE FROM invites
+ WHERE Expires < '$sqltime'");
//------------- Hide old requests ---------------------------------------//
@@ -375,7 +412,9 @@ if ($Hour != next_hour() || $_GET['runhour'] || isset($argv[2])) {
//------------- Remove dead peers ---------------------------------------//
sleep(3);
- $DB->query("DELETE FROM xbt_files_users WHERE mtime<unix_timestamp(now()-interval 6 hour)");
+ $DB->query("
+ DELETE FROM xbt_files_users
+ WHERE mtime < unix_timestamp(NOW() - INTERVAL 6 HOUR)");
//------------- Remove dead sessions ---------------------------------------//
sleep(3);
@@ -386,45 +425,56 @@ if ($Hour != next_hour() || $_GET['runhour'] || isset($argv[2])) {
$SessionQuery = $DB->query("
SELECT UserID, SessionID
FROM users_sessions
- WHERE (LastUpdate<'$AgoDays' AND KeepLogged='1')
- OR (LastUpdate<'$AgoMins' AND KeepLogged='0')");
+ WHERE (LastUpdate < '$AgoDays' AND KeepLogged = '1')
+ OR (LastUpdate < '$AgoMins' AND KeepLogged = '0')");
$DB->query("
DELETE FROM users_sessions
- WHERE (LastUpdate<'$AgoDays' AND KeepLogged='1')
- OR (LastUpdate<'$AgoMins' AND KeepLogged='0')");
-
+ WHERE (LastUpdate < '$AgoDays' AND KeepLogged = '1')
+ OR (LastUpdate < '$AgoMins' AND KeepLogged = '0')");
+
$DB->set_query_id($SessionQuery);
while (list($UserID, $SessionID) = $DB->next_record()) {
- $Cache->begin_transaction('users_sessions_'.$UserID);
+ $Cache->begin_transaction("users_sessions_$UserID");
$Cache->delete_row($SessionID);
$Cache->commit_transaction(0);
}
//------------- Lower Login Attempts ------------------------------------//
- $DB->query("UPDATE login_attempts SET Attempts=Attempts-1 WHERE Attempts>0");
- $DB->query("DELETE FROM login_attempts WHERE LastAttempt<'".time_minus(3600 * 24 * 90)."'");
+ $DB->query("
+ UPDATE login_attempts
+ SET Attempts = Attempts - 1
+ WHERE Attempts > 0");
+ $DB->query("
+ DELETE FROM login_attempts
+ WHERE LastAttempt < '".time_minus(3600 * 24 * 90)."'");
//------------- Remove expired warnings ---------------------------------//
- $DB->query("SELECT UserID FROM users_info WHERE Warned<'$sqltime'");
+ $DB->query("
+ SELECT UserID
+ FROM users_info
+ WHERE Warned < '$sqltime'");
while (list($UserID) = $DB->next_record()) {
- $Cache->begin_transaction('user_info_'.$UserID);
- $Cache->update_row(false, array('Warned'=>'0000-00-00 00:00:00'));
+ $Cache->begin_transaction("user_info_$UserID");
+ $Cache->update_row(false, array('Warned' => '0000-00-00 00:00:00'));
$Cache->commit_transaction(2592000);
}
- $DB->query("UPDATE users_info SET Warned='0000-00-00 00:00:00' WHERE Warned<'$sqltime'");
+ $DB->query("
+ UPDATE users_info
+ SET Warned = '0000-00-00 00:00:00'
+ WHERE Warned < '$sqltime'");
- // If a user has downloaded more than 10 GiBs while on ratio watch, disable leeching privileges and send the user a message
+ // If a user has downloaded more than 10 GiBs while on ratio watch, disable leeching privileges, and send the user a message
$DB->query("
SELECT ID
FROM users_info AS i
- JOIN users_main AS m ON m.ID=i.UserID
- WHERE i.RatioWatchEnds!='0000-00-00 00:00:00'
- AND i.RatioWatchDownload+10*1024*1024*1024<m.Downloaded
- AND m.Enabled='1'
- AND m.can_leech='1'");
+ JOIN users_main AS m ON m.ID = i.UserID
+ WHERE i.RatioWatchEnds != '0000-00-00 00:00:00'
+ AND i.RatioWatchDownload + 10 * 1024 * 1024 * 1024 < m.Downloaded
+ AND m.Enabled = '1'
+ AND m.can_leech = '1'");
$UserIDs = $DB->collect('ID');
if (count($UserIDs) > 0) {
@@ -437,10 +487,10 @@ if ($Hour != next_hour() || $_GET['runhour'] || isset($argv[2])) {
$DB->query("
UPDATE users_info AS i
- JOIN users_main AS m ON m.ID=i.UserID
- SET m.can_leech='0',
- i.AdminComment=CONCAT('$sqltime - Leeching privileges disabled by ratio watch system for downloading more than 10 GBs on ratio watch. - required ratio: ', m.RequiredRatio, '\n\n', i.AdminComment)
- WHERE m.ID IN(".implode(',',$UserIDs).')');
+ JOIN users_main AS m ON m.ID = i.UserID
+ SET m.can_leech = '0',
+ i.AdminComment = CONCAT('$sqltime - Leeching privileges disabled by ratio watch system for downloading more than 10 GBs on ratio watch. - required ratio: ', m.RequiredRatio, '\n\n', i.AdminComment)
+ WHERE m.ID IN(".implode(',', $UserIDs).')');
}
}
@@ -462,7 +512,7 @@ if (!$NoDaily && $Day != next_day() || $_GET['runday']) {
// Clear old seed time history
$DB->query("
DELETE FROM users_torrent_history
- WHERE Date<DATE('".sqltime()."'-INTERVAL 7 DAY)+0");
+ WHERE Date < DATE('".sqltime()."' - INTERVAL 7 DAY) + 0");
// Store total seeded time for each user in a temp table
$DB->query("TRUNCATE TABLE users_torrent_history_temp");
@@ -478,14 +528,14 @@ if (!$NoDaily && $Day != next_day() || $_GET['runday']) {
$DB->query("
INSERT INTO users_torrent_history
(UserID, NumTorrents, Date, Time)
- SELECT UserID, 0, UTC_DATE()+0, 259200-SumTime
+ SELECT UserID, 0, UTC_DATE() + 0, 259200 - SumTime
FROM users_torrent_history_temp
- WHERE SumTime<259200");
+ WHERE SumTime < 259200");
// Set <Weight> to the time seeding <NumTorrents> torrents
$DB->query("
UPDATE users_torrent_history
- SET Weight=NumTorrents*Time");
+ SET Weight = NumTorrents * Time");
// Calculate average time spent seeding each of the currently active torrents.
// This rounds the results to the nearest integer because SeedingAvg is an int column.
@@ -493,30 +543,29 @@ if (!$NoDaily && $Day != next_day() || $_GET['runday']) {
$DB->query("
INSERT INTO users_torrent_history_temp
(UserID, SeedingAvg)
- SELECT UserID, SUM(Weight)/SUM(Time)
+ SELECT UserID, SUM(Weight) / SUM(Time)
FROM users_torrent_history
GROUP BY UserID");
// Remove dummy entry for torrents seeded less than 72 hours
- $DB->query("DELETE FROM users_torrent_history WHERE NumTorrents='0'");
+ $DB->query("
+ DELETE FROM users_torrent_history
+ WHERE NumTorrents = '0'");
// Get each user's amount of snatches of existing torrents
$DB->query("
- INSERT INTO users_torrent_history_snatch
- (UserID, NumSnatches)
- SELECT
- xs.uid,
- COUNT(DISTINCT xs.fid)
+ INSERT INTO users_torrent_history_snatch (UserID, NumSnatches)
+ SELECT xs.uid, COUNT(DISTINCT xs.fid)
FROM xbt_snatched AS xs
- JOIN torrents on torrents.ID=xs.fid
+ JOIN torrents on torrents.ID = xs.fid
GROUP BY xs.uid");
// Get the fraction of snatched torrents seeded for at least 72 hours this week
- // Essentially take the total number of hours seeded this week and divide that by 72 hours*<NumSnatches>
+ // Essentially take the total number of hours seeded this week and divide that by 72 hours * <NumSnatches>
$DB->query("
UPDATE users_main AS um
- JOIN users_torrent_history_temp AS t ON t.UserID=um.ID
- JOIN users_torrent_history_snatch AS s ON s.UserID=um.ID
+ JOIN users_torrent_history_temp AS t ON t.UserID = um.ID
+ JOIN users_torrent_history_snatch AS s ON s.UserID = um.ID
SET um.RequiredRatioWork = (1 - (t.SeedingAvg / s.NumSnatches))
WHERE s.NumSnatches > 0");
@@ -556,19 +605,19 @@ if (!$NoDaily && $Day != next_day() || $_GET['runday']) {
/*$DB->query("
UPDATE users_main
- SET RequiredRatio=$Ratio
+ SET RequiredRatio = $Ratio
WHERE Downloaded >= '$Download'
AND Downloaded < '$DownloadBarrier'
- AND can_leech='0'
- AND Enabled='1'");
+ AND can_leech = '0'
+ AND Enabled = '1'");
*/
$DownloadBarrier = $Download;
}
$DB->query("
UPDATE users_main
- SET RequiredRatio=0.00
- WHERE Downloaded < 5*1024*1024*1024");
+ SET RequiredRatio = 0.00
+ WHERE Downloaded < 5 * 1024 * 1024 * 1024");
// Here is where we manage ratio watch
@@ -581,26 +630,26 @@ if (!$NoDaily && $Day != next_day() || $_GET['runday']) {
m.ID,
torrent_pass
FROM users_info AS i
- JOIN users_main AS m ON m.ID=i.UserID
+ JOIN users_main AS m ON m.ID = i.UserID
WHERE m.Uploaded/m.Downloaded >= m.RequiredRatio
- AND i.RatioWatchEnds!='0000-00-00 00:00:00'
- AND m.can_leech='0'
- AND m.Enabled='1'");
+ AND i.RatioWatchEnds != '0000-00-00 00:00:00'
+ AND m.can_leech = '0'
+ AND m.Enabled = '1'");
$OffRatioWatch = $DB->collect('ID');
if (count($OffRatioWatch) > 0) {
$DB->query("
UPDATE users_info AS ui
JOIN users_main AS um ON um.ID = ui.UserID
- SET ui.RatioWatchEnds='0000-00-00 00:00:00',
- ui.RatioWatchDownload='0',
- um.can_leech='1',
+ SET ui.RatioWatchEnds = '0000-00-00 00:00:00',
+ ui.RatioWatchDownload = '0',
+ um.can_leech = '1',
ui.AdminComment = CONCAT('$sqltime - Leeching re-enabled by adequate ratio.\n\n', ui.AdminComment)
WHERE ui.UserID IN(".implode(',', $OffRatioWatch).')');
}
foreach ($OffRatioWatch as $UserID) {
- $Cache->begin_transaction('user_info_heavy_'.$UserID);
- $Cache->update_row(false, array('RatioWatchEnds'=>'0000-00-00 00:00:00','RatioWatchDownload'=>'0','CanLeech'=>1));
+ $Cache->begin_transaction("user_info_heavy_$UserID");
+ $Cache->update_row(false, array('RatioWatchEnds' => '0000-00-00 00:00:00', 'RatioWatchDownload' => '0', 'CanLeech' => 1));
$Cache->commit_transaction(0);
Misc::send_pm($UserID, 0, 'You have been taken off Ratio Watch', "Congratulations! Feel free to begin downloading again.\n To ensure that you do not get put on ratio watch again, please read the rules located [url=https://".SSL_SITE_URL."/rules.php?p=ratio]here[/url].\n");
echo "Ratio watch off: $UserID\n";
@@ -613,28 +662,26 @@ if (!$NoDaily && $Day != next_day() || $_GET['runday']) {
// Take users off ratio watch
$UserQuery = $DB->query("
- SELECT
- m.ID,
- torrent_pass
+ SELECT m.ID, torrent_pass
FROM users_info AS i
- JOIN users_main AS m ON m.ID=i.UserID
- WHERE m.Uploaded/m.Downloaded >= m.RequiredRatio
- AND i.RatioWatchEnds!='0000-00-00 00:00:00'
- AND m.Enabled='1'");
+ JOIN users_main AS m ON m.ID = i.UserID
+ WHERE m.Uploaded / m.Downloaded >= m.RequiredRatio
+ AND i.RatioWatchEnds != '0000-00-00 00:00:00'
+ AND m.Enabled = '1'");
$OffRatioWatch = $DB->collect('ID');
if (count($OffRatioWatch) > 0) {
$DB->query("
UPDATE users_info AS ui
JOIN users_main AS um ON um.ID = ui.UserID
- SET ui.RatioWatchEnds='0000-00-00 00:00:00',
- ui.RatioWatchDownload='0',
- um.can_leech='1'
+ SET ui.RatioWatchEnds = '0000-00-00 00:00:00',
+ ui.RatioWatchDownload = '0',
+ um.can_leech = '1'
WHERE ui.UserID IN(".implode(',', $OffRatioWatch).')');
}
foreach ($OffRatioWatch as $UserID) {
- $Cache->begin_transaction('user_info_heavy_'.$UserID);
- $Cache->update_row(false, array('RatioWatchEnds'=>'0000-00-00 00:00:00','RatioWatchDownload'=>'0','CanLeech'=>1));
+ $Cache->begin_transaction("user_info_heavy_$UserID");
+ $Cache->update_row(false, array('RatioWatchEnds' => '0000-00-00 00:00:00', 'RatioWatchDownload' => '0', 'CanLeech' => 1));
$Cache->commit_transaction(0);
Misc::send_pm($UserID, 0, "You have been taken off Ratio Watch", "Congratulations! Feel free to begin downloading again.\n To ensure that you do not get put on ratio watch again, please read the rules located [url=https://".SSL_SITE_URL."/rules.php?p=ratio]here[/url].\n");
echo "Ratio watch off: $UserID\n";
@@ -648,29 +695,28 @@ if (!$NoDaily && $Day != next_day() || $_GET['runday']) {
// Put user on ratio watch if he doesn't meet the standards
sleep(10);
$DB->query("
- SELECT m.ID,
- m.Downloaded
+ SELECT m.ID, m.Downloaded
FROM users_info AS i
- JOIN users_main AS m ON m.ID=i.UserID
- WHERE m.Uploaded/m.Downloaded < m.RequiredRatio
- AND i.RatioWatchEnds='0000-00-00 00:00:00'
- AND m.Enabled='1'
- AND m.can_leech='1'");
+ JOIN users_main AS m ON m.ID = i.UserID
+ WHERE m.Uploaded / m.Downloaded < m.RequiredRatio
+ AND i.RatioWatchEnds = '0000-00-00 00:00:00'
+ AND m.Enabled = '1'
+ AND m.can_leech = '1'");
$OnRatioWatch = $DB->collect('ID');
if (count($OnRatioWatch) > 0) {
$DB->query("
UPDATE users_info AS i
- JOIN users_main AS m ON m.ID=i.UserID
- SET i.RatioWatchEnds='".time_plus(60 * 60 * 24 * 14)."',
- i.RatioWatchTimes = i.RatioWatchTimes+1,
+ JOIN users_main AS m ON m.ID = i.UserID
+ SET i.RatioWatchEnds = '".time_plus(60 * 60 * 24 * 14)."',
+ i.RatioWatchTimes = i.RatioWatchTimes + 1,
i.RatioWatchDownload = m.Downloaded
WHERE m.ID IN(".implode(',', $OnRatioWatch).')');
}
foreach ($OnRatioWatch as $UserID) {
- $Cache->begin_transaction('user_info_heavy_'.$UserID);
- $Cache->update_row(false, array('RatioWatchEnds'=>time_plus(60 * 60 * 24 * 14),'RatioWatchDownload'=>0));
+ $Cache->begin_transaction("user_info_heavy_$UserID");
+ $Cache->update_row(false, array('RatioWatchEnds' => time_plus(60 * 60 * 24 * 14), 'RatioWatchDownload' => 0));
$Cache->commit_transaction(0);
Misc::send_pm($UserID, 0, 'You have been put on Ratio Watch', "This happens when your ratio falls below the requirements we have outlined in the rules located [url=https://".SSL_SITE_URL."/rules.php?p=ratio]here[/url].\n For information about ratio watch, click the link above.");
echo "Ratio watch on: $UserID\n";
@@ -711,28 +757,30 @@ if (!$NoDaily && $Day != next_day() || $_GET['runday']) {
$UserQuery = $DB->query("
SELECT ID, torrent_pass
FROM users_info AS i
- JOIN users_main AS m ON m.ID=i.UserID
- WHERE i.RatioWatchEnds!='0000-00-00 00:00:00'
- AND i.RatioWatchEnds<'$sqltime'
- AND m.Enabled='1'
- AND m.can_leech!='0'");
+ JOIN users_main AS m ON m.ID = i.UserID
+ WHERE i.RatioWatchEnds != '0000-00-00 00:00:00'
+ AND i.RatioWatchEnds < '$sqltime'
+ AND m.Enabled = '1'
+ AND m.can_leech != '0'");
$UserIDs = $DB->collect('ID');
if (count($UserIDs) > 0) {
$DB->query("
UPDATE users_info AS i
- JOIN users_main AS m ON m.ID=i.UserID
- SET m.can_leech='0',
- i.AdminComment=CONCAT('$sqltime - Leeching ability disabled by ratio watch system - required ratio: ', m.RequiredRatio,'', i.AdminComment)
+ JOIN users_main AS m ON m.ID = i.UserID
+ SET m.can_leech = '0',
+ i.AdminComment = CONCAT('$sqltime - Leeching ability disabled by ratio watch system - required ratio: ', m.RequiredRatio,'', i.AdminComment)
WHERE m.ID IN(".implode(',', $UserIDs).')');
- $DB->query("DELETE FROM users_torrent_history WHERE UserID IN (".implode(',', $UserIDs).')');
+ $DB->query("
+ DELETE FROM users_torrent_history
+ WHERE UserID IN (".implode(',', $UserIDs).')');
}
foreach ($UserIDs as $UserID) {
- $Cache->begin_transaction('user_info_heavy_'.$UserID);
- $Cache->update_row(false, array('RatioWatchDownload'=>0, 'CanLeech'=>0));
+ $Cache->begin_transaction("user_info_heavy_$UserID");
+ $Cache->update_row(false, array('RatioWatchDownload' => 0, 'CanLeech' => 0));
$Cache->commit_transaction(0);
Misc::send_pm($UserID, 0, 'Your downloading rights have been disabled', "As you did not raise your ratio in time, your downloading rights have been revoked. You will not be able to download any torrents until your ratio is above your new required ratio.");
echo "Ratio watch disabled: $UserID\n";
@@ -750,14 +798,14 @@ if (!$NoDaily && $Day != next_day() || $_GET['runday']) {
$DB->query("
SELECT um.Username, um.Email
FROM users_info AS ui
- JOIN users_main AS um ON um.ID=ui.UserID
+ JOIN users_main AS um ON um.ID = ui.UserID
LEFT JOIN users_levels AS ul ON ul.UserID = um.ID AND ul.PermissionID = '".CELEB."'
WHERE um.PermissionID IN ('".USER."', '".MEMBER ."')
- AND um.LastAccess<'".time_minus(3600 * 24 * 110, true)."'
- AND um.LastAccess>'".time_minus(3600 * 24 * 111, true)."'
- AND um.LastAccess!='0000-00-00 00:00:00'
- AND ui.Donor='0'
- AND um.Enabled!='2'
+ AND um.LastAccess < '".time_minus(3600 * 24 * 110, true)."'
+ AND um.LastAccess > '".time_minus(3600 * 24 * 111, true)."'
+ AND um.LastAccess != '0000-00-00 00:00:00'
+ AND ui.Donor = '0'
+ AND um.Enabled != '2'
AND ul.UserID IS NULL
GROUP BY um.ID");
while (list($Username, $Email) = $DB->next_record()) {
@@ -767,17 +815,17 @@ if (!$NoDaily && $Day != next_day() || $_GET['runday']) {
$DB->query("
SELECT um.ID
FROM users_info AS ui
- JOIN users_main AS um ON um.ID=ui.UserID
+ JOIN users_main AS um ON um.ID = ui.UserID
LEFT JOIN users_levels AS ul ON ul.UserID = um.ID AND ul.PermissionID = '".CELEB."'
WHERE um.PermissionID IN ('".USER."', '".MEMBER ."')
- AND um.LastAccess<'".time_minus(3600 * 24 * 30 * 4)."'
- AND um.LastAccess!='0000-00-00 00:00:00'
- AND ui.Donor='0'
- AND um.Enabled!='2'
+ AND um.LastAccess < '".time_minus(3600 * 24 * 30 * 4)."'
+ AND um.LastAccess != '0000-00-00 00:00:00'
+ AND ui.Donor = '0'
+ AND um.Enabled != '2'
AND ul.UserID IS NULL
GROUP BY um.ID");
- if ($DB->record_count() > 0) {
+ if ($DB->has_results()) {
Tools::disable_users($DB->collect('ID'), 'Disabled for inactivity.', 3);
}
@@ -785,16 +833,16 @@ if (!$NoDaily && $Day != next_day() || $_GET['runday']) {
sleep(10);
$DB->query("
UPDATE users_info AS ui
- JOIN users_main AS um ON um.ID=ui.UserID
- SET um.Enabled='2',
- ui.BanDate='$sqltime',
- ui.BanReason='3',
- ui.AdminComment=CONCAT('$sqltime - Disabled for inactivity (never logged in)', ui.AdminComment)
- WHERE um.LastAccess='0000-00-00 00:00:00'
- AND ui.JoinDate<'".time_minus(60 * 60 * 24 * 7)."'
- AND um.Enabled!='2'
+ JOIN users_main AS um ON um.ID = ui.UserID
+ SET um.Enabled = '2',
+ ui.BanDate = '$sqltime',
+ ui.BanReason = '3',
+ ui.AdminComment = CONCAT('$sqltime - Disabled for inactivity (never logged in)', ui.AdminComment)
+ WHERE um.LastAccess = '0000-00-00 00:00:00'
+ AND ui.JoinDate < '".time_minus(60 * 60 * 24 * 7)."'
+ AND um.Enabled != '2'
");
- $Cache->decrement('stats_user_count',$DB->affected_rows());
+ $Cache->decrement('stats_user_count', $DB->affected_rows());
echo "disabled unconfirmed\n";
@@ -804,42 +852,42 @@ if (!$NoDaily && $Day != next_day() || $_GET['runday']) {
SELECT um.ID
FROM users_main AS um
WHERE PermissionID IN('.POWER.', '.ELITE.', '.TORRENT_MASTER.')
- AND Uploaded/Downloaded < 0.95
+ AND Uploaded / Downloaded < 0.95
OR PermissionID IN('.POWER.', '.ELITE.', '.TORRENT_MASTER.')
- AND Uploaded < 25*1024*1024*1024');
+ AND Uploaded < 25 * 1024 * 1024 * 1024');
echo "demoted 1\n";
while (list($UserID) = $DB->next_record()) {
- $Cache->begin_transaction('user_info_'.$UserID);
- $Cache->update_row(false, array('PermissionID'=>MEMBER));
+ $Cache->begin_transaction("user_info_$UserID");
+ $Cache->update_row(false, array('PermissionID' => MEMBER));
$Cache->commit_transaction(2592000);
}
$DB->query('
UPDATE users_main
- SET PermissionID='.MEMBER.'
+ SET PermissionID = '.MEMBER.'
WHERE PermissionID IN('.POWER.', '.ELITE.', '.TORRENT_MASTER.')
- AND Uploaded/Downloaded < 0.95
+ AND Uploaded / Downloaded < 0.95
OR PermissionID IN('.POWER.', '.ELITE.', '.TORRENT_MASTER.')
- AND Uploaded < 25*1024*1024*1024');
+ AND Uploaded < 25 * 1024 * 1024 * 1024');
echo "demoted 2\n";
$DB->query('
SELECT um.ID
FROM users_main AS um
WHERE PermissionID IN('.MEMBER.', '.POWER.', '.ELITE.', '.TORRENT_MASTER.')
- AND Uploaded/Downloaded < 0.65');
+ AND Uploaded / Downloaded < 0.65');
echo "demoted 3\n";
while (list($UserID) = $DB->next_record()) {
- $Cache->begin_transaction('user_info_'.$UserID);
- $Cache->update_row(false, array('PermissionID'=>USER));
+ $Cache->begin_transaction("user_info_$UserID");
+ $Cache->update_row(false, array('PermissionID' => USER));
$Cache->commit_transaction(2592000);
}
$DB->query('
UPDATE users_main
- SET PermissionID='.USER.'
+ SET PermissionID = '.USER.'
WHERE PermissionID IN('.MEMBER.', '.POWER.', '.ELITE.', '.TORRENT_MASTER.')
- AND Uploaded/Downloaded < 0.65');
+ AND Uploaded / Downloaded < 0.65');
echo "demoted 4\n";
//------------- Lock old threads ----------------------------------------//
@@ -848,30 +896,34 @@ if (!$NoDaily && $Day != next_day() || $_GET['runday']) {
SELECT t.ID, t.ForumID
FROM forums_topics AS t
JOIN forums AS f ON t.ForumID = f.ID
- WHERE t.IsLocked='0'
- AND t.IsSticky='0'
- AND DATEDIFF(CURDATE(),DATE(t.LastPostTime)) / 7 > f.AutoLockWeeks
+ WHERE t.IsLocked = '0'
+ AND t.IsSticky = '0'
+ AND DATEDIFF(CURDATE(), DATE(t.LastPostTime)) / 7 > f.AutoLockWeeks
AND f.AutoLock = '1'");
$IDs = $DB->collect('ID');
$ForumIDs = $DB->collect('ForumID');
if (count($IDs) > 0) {
$LockIDs = implode(',', $IDs);
- $DB->query("UPDATE forums_topics SET IsLocked='1' WHERE ID IN($LockIDs)");
+ $DB->query("
+ UPDATE forums_topics
+ SET IsLocked = '1' WHERE ID IN($LockIDs)");
sleep(2);
- $DB->query("DELETE FROM forums_last_read_topics WHERE TopicID IN($LockIDs)");
+ $DB->query("
+ DELETE FROM forums_last_read_topics
+ WHERE TopicID IN($LockIDs)");
foreach ($IDs as $ID) {
- $Cache->begin_transaction('thread_'.$ID.'_info');
- $Cache->update_row(false, array('IsLocked'=>'1'));
+ $Cache->begin_transaction("thread_$ID".'_info');
+ $Cache->update_row(false, array('IsLocked' => '1'));
$Cache->commit_transaction(3600 * 24 * 30);
- $Cache->expire_value('thread_'.$ID.'_catalogue_0',3600 * 24 * 30);
- $Cache->expire_value('thread_'.$ID.'_info',3600 * 24 * 30);
+ $Cache->expire_value("thread_$ID".'_catalogue_0', 3600 * 24 * 30);
+ $Cache->expire_value("thread_$ID".'_info', 3600 * 24 * 30);
}
$ForumIDs = array_flip(array_flip($ForumIDs));
foreach ($ForumIDs as $ForumID) {
- $Cache->delete_value('forums_'.$ForumID);
+ $Cache->delete_value("forums_$ForumID");
}
}
echo "Old threads locked\n";
@@ -881,7 +933,10 @@ if (!$NoDaily && $Day != next_day() || $_GET['runday']) {
sleep(10);
//remove dead torrents that were never announced to -- XBTT will not delete those with a pid of 0, only those that belong to them (valid pids)
- $DB->query("DELETE FROM torrents WHERE flags = 1 AND pid = 0");
+ $DB->query("
+ DELETE FROM torrents
+ WHERE flags = 1
+ AND pid = 0");
sleep(10);
@@ -922,16 +977,17 @@ if (!$NoDaily && $Day != next_day() || $_GET['runday']) {
continue;
}
if ($ArtistName) {
- $Name = $ArtistName.' - '.$Name;
+ $Name = "$ArtistName - $Name";
}
if ($Format && $Encoding) {
- $Name.= ' ['.(empty($Media) ? '' : "$Media / ").$Format.' / '.$Encoding.']';
+ $Name .= ' ['.(empty($Media) ? '' : "$Media / ") . "$Format / $Encoding]";
}
Torrents::delete_torrent($ID, $GroupID);
$LogEntries[] = "Torrent $ID ($Name) (".strtoupper($InfoHash).") was deleted for inactivity (unseeded)";
- if (!array_key_exists($UserID, $DeleteNotes))
- $DeleteNotes[$UserID] = array('Count' => 0, 'Msg' => '');
+ if (!array_key_exists($UserID, $DeleteNotes)) {
+ $DeleteNotes[$UserID] = array('Count' => 0, 'Msg' => '');
+ }
$DeleteNotes[$UserID]['Msg'] .= "\n$Name";
$DeleteNotes[$UserID]['Count']++;
@@ -950,18 +1006,29 @@ if (!$NoDaily && $Day != next_day() || $_GET['runday']) {
unset($DeleteNotes);
if (count($LogEntries) > 0) {
- $Values = "('".implode("', '".$sqltime."'), ('",$LogEntries)."', '$sqltime')";
- $DB->query('INSERT INTO log (Message, Time) VALUES '.$Values);
+ $Values = "('".implode("', '$sqltime'), ('", $LogEntries) . "', '$sqltime')";
+ $DB->query("
+ INSERT INTO log (Message, Time)
+ VALUES $Values");
echo "\nDeleted $i torrents for inactivity\n";
}
- $DB->query("SELECT SimilarID FROM artists_similar_scores WHERE Score<=0");
- $SimilarIDs = implode(',',$DB->collect('SimilarID'));
+ $DB->query("
+ SELECT SimilarID
+ FROM artists_similar_scores
+ WHERE Score <= 0");
+ $SimilarIDs = implode(',', $DB->collect('SimilarID'));
if ($SimilarIDs) {
- $DB->query("DELETE FROM artists_similar WHERE SimilarID IN($SimilarIDs)");
- $DB->query("DELETE FROM artists_similar_scores WHERE SimilarID IN($SimilarIDs)");
- $DB->query("DELETE FROM artists_similar_votes WHERE SimilarID IN($SimilarIDs)");
+ $DB->query("
+ DELETE FROM artists_similar
+ WHERE SimilarID IN($SimilarIDs)");
+ $DB->query("
+ DELETE FROM artists_similar_scores
+ WHERE SimilarID IN($SimilarIDs)");
+ $DB->query("
+ DELETE FROM artists_similar_votes
+ WHERE SimilarID IN($SimilarIDs)");
}
@@ -997,10 +1064,10 @@ if (!$NoDaily && $Day != next_day() || $_GET['runday']) {
((t.Size * t.Snatched) + (t.Size * 0.5 * t.Leechers)) AS Data
FROM torrents AS t
LEFT JOIN torrents_group AS g ON g.ID = t.GroupID
- WHERE t.Seeders>0
+ WHERE t.Seeders > 0
AND t.Time > ('$sqltime' - INTERVAL 1 DAY)
ORDER BY (t.Seeders + t.Leechers) DESC
- LIMIT 10;");
+ LIMIT 10;");
$Top10 = $DB->to_array();
}
@@ -1019,29 +1086,52 @@ if (!$NoDaily && $Day != next_day() || $_GET['runday']) {
$DisplayName = Artists::display_artists($Artists, false, true);
}
- $DisplayName.= $GroupName;
+ $DisplayName .= $GroupName;
if ($GroupCategoryID == 1 && $GroupYear > 0) {
- $DisplayName.= " [$GroupYear]";
+ $DisplayName .= " [$GroupYear]";
}
// append extra info to torrent title
$ExtraInfo = '';
$AddExtra = '';
- if ($Format) { $ExtraInfo.=$Format; $AddExtra=' / '; }
- if ($Encoding) { $ExtraInfo.=$AddExtra.$Encoding; $AddExtra=' / '; }
+ if ($Format) {
+ $ExtraInfo .= $Format;
+ $AddExtra = ' / ';
+ }
+ if ($Encoding) {
+ $ExtraInfo .= $AddExtra.$Encoding;
+ $AddExtra = ' / ';
+ }
// "FLAC / Lossless / Log (100%) / Cue / CD";
- if ($HasLog) { $ExtraInfo.=$AddExtra."Log (".$LogScore."%)"; $AddExtra=' / '; }
- if ($HasCue) { $ExtraInfo.=$AddExtra."Cue"; $AddExtra=' / '; }
- if ($Media) { $ExtraInfo.=$AddExtra.$Media; $AddExtra=' / '; }
- if ($Scene) { $ExtraInfo.=$AddExtra.'Scene'; $AddExtra=' / '; }
- if ($Year > 0) { $ExtraInfo.=$AddExtra.$Year; $AddExtra=' '; }
- if ($RemasterTitle) { $ExtraInfo.=$AddExtra.$RemasterTitle; }
+ if ($HasLog) {
+ $ExtraInfo .= "{$AddExtra}Log ($LogScore%)";
+ $AddExtra = ' / ';
+ }
+ if ($HasCue) {
+ $ExtraInfo .= "{$AddExtra}Cue";
+ $AddExtra = ' / ';
+ }
+ if ($Media) {
+ $ExtraInfo .= $AddExtra.$Media;
+ $AddExtra = ' / ';
+ }
+ if ($Scene) {
+ $ExtraInfo .= "{$AddExtra}Scene";
+ $AddExtra = ' / ';
+ }
+ if ($Year > 0) {
+ $ExtraInfo .= $AddExtra.$Year;
+ $AddExtra = ' ';
+ }
+ if ($RemasterTitle) {
+ $ExtraInfo .= $AddExtra.$RemasterTitle;
+ }
if ($ExtraInfo != '') {
$ExtraInfo = "- [$ExtraInfo]";
}
- $TitleString = $DisplayName.' '.$ExtraInfo;
+ $TitleString = "$DisplayName $ExtraInfo";
$TagString = str_replace('|', ' ', $TorrentTags);
@@ -1086,10 +1176,10 @@ if (!$NoDaily && $Day != next_day() || $_GET['runday']) {
((t.Size * t.Snatched) + (t.Size * 0.5 * t.Leechers)) AS Data
FROM torrents AS t
LEFT JOIN torrents_group AS g ON g.ID = t.GroupID
- WHERE t.Seeders>0
+ WHERE t.Seeders > 0
AND t.Time > ('$sqltime' - INTERVAL 1 WEEK)
ORDER BY (t.Seeders + t.Leechers) DESC
- LIMIT 10;");
+ LIMIT 10;");
$Top10 = $DB->to_array();
}
@@ -1108,7 +1198,7 @@ if (!$NoDaily && $Day != next_day() || $_GET['runday']) {
$DisplayName = Artists::display_artists($Artists, false, true);
}
- $DisplayName.= $GroupName;
+ $DisplayName .= $GroupName;
if ($GroupCategoryID == 1 && $GroupYear > 0) {
$DisplayName.= " [$GroupYear]";
@@ -1118,42 +1208,42 @@ if (!$NoDaily && $Day != next_day() || $_GET['runday']) {
$ExtraInfo = '';
$AddExtra = '';
if ($Format) {
- $ExtraInfo.= $Format;
+ $ExtraInfo .= $Format;
$AddExtra = ' / ';
}
if ($Encoding) {
- $ExtraInfo.= $AddExtra.$Encoding;
+ $ExtraInfo .= $AddExtra.$Encoding;
$AddExtra = ' / ';
}
// "FLAC / Lossless / Log (100%) / Cue / CD";
if ($HasLog) {
- $ExtraInfo.= $AddExtra.'Log ('.$LogScore.'%)';
+ $ExtraInfo .= "{$AddExtra}Log ($LogScore%)";
$AddExtra = ' / ';
}
if ($HasCue) {
- $ExtraInfo.= $AddExtra.'Cue';
+ $ExtraInfo .= "{$AddExtra}Cue";
$AddExtra = ' / ';
}
if ($Media) {
- $ExtraInfo.= $AddExtra.$Media;
+ $ExtraInfo .= $AddExtra.$Media;
$AddExtra = ' / ';
}
if ($Scene) {
- $ExtraInfo.= $AddExtra.'Scene';
+ $ExtraInfo .= "{$AddExtra}Scene";
$AddExtra = ' / ';
}
if ($Year > 0) {
- $ExtraInfo.= $AddExtra.$Year;
+ $ExtraInfo .= $AddExtra.$Year;
$AddExtra = ' ';
}
if ($RemasterTitle) {
- $ExtraInfo.= $AddExtra.$RemasterTitle;
+ $ExtraInfo .= $AddExtra.$RemasterTitle;
}
if ($ExtraInfo != '') {
$ExtraInfo = "- [$ExtraInfo]";
}
- $TitleString = $DisplayName.' '.$ExtraInfo;
+ $TitleString = "$DisplayName $ExtraInfo";
$TagString = str_replace('|', ' ', $TorrentTags);
@@ -1196,10 +1286,10 @@ if (!$NoDaily && $Day != next_day() || $_GET['runday']) {
$TorrentAlerts[$UserID] = array('Count' => 0, 'Msg' => '');
$ArtistName = Artists::display_artists(Artists::get_artist($GroupID), false, false, false);
if ($ArtistName) {
- $Name = $ArtistName.' - '.$Name;
+ $Name = "$ArtistName - $Name";
}
if ($Format && $Encoding) {
- $Name.=' ['.$Format.' / '.$Encoding.']';
+ $Name .= " [$Format / $Encoding]";
}
$TorrentAlerts[$UserID]['Msg'] .= "\n[url=https://".SSL_SITE_URL."/torrents.php?torrentid=$ID]".$Name."[/url]";
$TorrentAlerts[$UserID]['Count']++;
@@ -1247,14 +1337,14 @@ if ($BiWeek != next_biweek() || $_GET['runbiweek']) {
//------------- Give out invites! ---------------------------------------//
/*
- PUs have a cap of 2 invites. Elites have a cap of 4.
- Every month, on the 8th and the 22nd, each PU/Elite User gets one invite up to their max.
+ Power Users have a cap of 2 invites. Elites have a cap of 4.
+ Every month, on the 8th and the 22nd, each PU/Elite user gets one invite up to their max.
Then, every month, on the 8th and the 22nd, we give out bonus invites like this:
- Every Power User or Elite whose total invitee ratio is above 0.75 and total invitee upload is over 2 gigs gets one invite.
- Every Elite whose total invitee ratio is above 2.0 and total invitee upload is over 10 gigs gets one more invite.
- Every Elite whose total invitee ratio is above 3.0 and total invitee upload is over 20 gigs gets yet one more invite.
+ Every Power User or Elite whose total invitee ratio is above 0.75 and total invitee upload is over 2 GBs gets one invite.
+ Every Elite whose total invitee ratio is above 2.0 and total invitee upload is over 10 GBs gets one more invite.
+ Every Elite whose total invitee ratio is above 3.0 and total invitee upload is over 20 GBs gets yet one more invite.
This cascades, so if you qualify for the last bonus group, you also qualify for the first two and will receive three bonus invites.
@@ -1265,8 +1355,8 @@ if ($BiWeek != next_biweek() || $_GET['runbiweek']) {
$DB->query("
SELECT ID
FROM users_main AS um
- JOIN users_info AS ui on ui.UserID=um.ID
- WHERE um.Enabled='1'
+ JOIN users_info AS ui on ui.UserID = um.ID
+ WHERE um.Enabled = '1'
AND ui.DisableInvites = '0'
AND ((um.PermissionID = ".POWER."
AND um.Invites < 2
@@ -1276,13 +1366,13 @@ if ($BiWeek != next_biweek() || $_GET['runbiweek']) {
$UserIDs = $DB->collect('ID');
if (count($UserIDs) > 0) {
foreach ($UserIDs as $UserID) {
- $Cache->begin_transaction('user_info_heavy_'.$UserID);
+ $Cache->begin_transaction("user_info_heavy_$UserID");
$Cache->update_row(false, array('Invites' => '+1'));
$Cache->commit_transaction(0);
}
$DB->query('
UPDATE users_main
- SET Invites=Invites+1
+ SET Invites = Invites + 1
WHERE ID IN ('.implode(',', $UserIDs).')');
}
@@ -1295,9 +1385,9 @@ if ($BiWeek != next_biweek() || $_GET['runbiweek']) {
$DB->query("
CREATE TEMPORARY TABLE temp_sections_schedule_index
- SELECT SUM(Uploaded) AS Upload,SUM(Downloaded) AS Download,Inviter
+ SELECT SUM(Uploaded) AS Upload, SUM(Downloaded) AS Download, Inviter
FROM users_main AS um
- JOIN users_info AS ui ON ui.UserID=um.ID
+ JOIN users_info AS ui ON ui.UserID = um.ID
GROUP BY Inviter");
foreach ($BonusReqs as $BonusReq) {
@@ -1305,26 +1395,27 @@ if ($BiWeek != next_biweek() || $_GET['runbiweek']) {
$DB->query("
SELECT ID
FROM users_main AS um
- JOIN users_info AS ui ON ui.UserID=um.ID
+ JOIN users_info AS ui ON ui.UserID = um.ID
JOIN temp_sections_schedule_index AS u ON u.Inviter = um.ID
- WHERE u.Upload>$Upload AND u.Upload/u.Download>$Ratio
+ WHERE u.Upload > $Upload
+ AND u.Upload / u.Download > $Ratio
AND um.Enabled = '1'
AND ui.DisableInvites = '0'
- AND ((um.PermissionID = ".POWER."
+ AND ((um.PermissionID = ".POWER.'
AND um.Invites < 2
- ) OR (um.PermissionID = ".ELITE."
+ ) OR (um.PermissionID = '.ELITE.'
AND um.Invites < 4)
- )");
+ )');
$UserIDs = $DB->collect('ID');
if (count($UserIDs) > 0) {
foreach ($UserIDs as $UserID) {
- $Cache->begin_transaction('user_info_heavy_'.$UserID);
+ $Cache->begin_transaction("user_info_heavy_$UserID");
$Cache->update_row(false, array('Invites' => '+1'));
$Cache->commit_transaction(0);
}
$DB->query('
UPDATE users_main
- SET Invites=Invites+1
+ SET Invites = Invites + 1
WHERE ID IN ('.implode(',', $UserIDs).')');
}
}
@@ -1338,7 +1429,7 @@ if ($BiWeek != next_biweek() || $_GET['runbiweek']) {
GROUP BY uid
ORDER BY COUNT(uid) DESC
LIMIT 100;");
-
+
}
}
diff --git a/sections/staffblog/index.php b/sections/staffblog/index.php
index c8fdfdb..64c2ca2 100644
--- a/sections/staffblog/index.php
+++ b/sections/staffblog/index.php
@@ -5,7 +5,12 @@ if (!check_perms('users_mod')) {
error(403);
}
-$DB->query("INSERT INTO staff_blog_visits (UserID, Time) VALUES (".$LoggedUser['ID'].", NOW()) ON DUPLICATE KEY UPDATE Time=NOW()");
+$DB->query("
+ INSERT INTO staff_blog_visits
+ (UserID, Time)
+ VALUES
+ (".$LoggedUser['ID'].", NOW())
+ ON DUPLICATE KEY UPDATE Time = NOW()");
$Cache->delete_value('staff_blog_read_'.$LoggedUser['ID']);
define('ANNOUNCEMENT_FORUM_ID', 19);
@@ -21,7 +26,10 @@ if (check_perms('admin_manage_blog')) {
error("Please enter a title.");
}
if (is_number($_POST['blogid'])) {
- $DB->query("UPDATE staff_blog SET Title='".db_string($_POST['title'])."', Body='".db_string($_POST['body'])."' WHERE ID='".db_string($_POST['blogid'])."'");
+ $DB->query("
+ UPDATE staff_blog
+ SET Title = '".db_string($_POST['title'])."', Body = '".db_string($_POST['body'])."'
+ WHERE ID = '".db_string($_POST['blogid'])."'");
$Cache->delete_value('staff_blog');
$Cache->delete_value('staff_feed_blog');
}
@@ -30,14 +38,19 @@ if (check_perms('admin_manage_blog')) {
case 'editblog':
if (is_number($_GET['id'])) {
$BlogID = $_GET['id'];
- $DB->query("SELECT Title, Body FROM staff_blog WHERE ID=$BlogID");
+ $DB->query("
+ SELECT Title, Body
+ FROM staff_blog
+ WHERE ID = $BlogID");
list($Title, $Body, $ThreadID) = $DB->next_record();
}
break;
case 'deleteblog':
if (is_number($_GET['id'])) {
authorize();
- $DB->query("DELETE FROM staff_blog WHERE ID='".db_string($_GET['id'])."'");
+ $DB->query("
+ DELETE FROM staff_blog
+ WHERE ID = '".db_string($_GET['id'])."'");
$Cache->delete_value('staff_blog');
$Cache->delete_value('staff_feed_blog');
}
@@ -52,7 +65,11 @@ if (check_perms('admin_manage_blog')) {
$Title = db_string($_POST['title']);
$Body = db_string($_POST['body']);
- $DB->query("INSERT INTO staff_blog (UserID, Title, Body, Time) VALUES ('$LoggedUser[ID]', '".db_string($_POST['title'])."', '".db_string($_POST['body'])."', NOW())");
+ $DB->query("
+ INSERT INTO staff_blog
+ (UserID, Title, Body, Time)
+ VALUES
+ ('$LoggedUser[ID]', '".db_string($_POST['title'])."', '".db_string($_POST['body'])."', NOW())");
$Cache->delete_value('staff_blog');
$Cache->delete_value('staff_blog_latest_time');
@@ -98,13 +115,15 @@ if (check_perms('admin_manage_blog')) {
<div class="thin">
<?
if (($Blog = $Cache->get_value('staff_blog')) === false) {
- $DB->query("SELECT
- b.ID,
- um.Username,
- b.Title,
- b.Body,
- b.Time
- FROM staff_blog AS b LEFT JOIN users_main AS um ON b.UserID=um.ID
+ $DB->query("
+ SELECT
+ b.ID,
+ um.Username,
+ b.Title,
+ b.Body,
+ b.Time
+ FROM staff_blog AS b
+ LEFT JOIN users_main AS um ON b.UserID = um.ID
ORDER BY Time DESC");
$Blog = $DB->to_array(false, MYSQLI_NUM);
$Cache->cache_value('staff_blog', $Blog, 1209600);
@@ -119,7 +138,7 @@ foreach ($Blog as $BlogItem) {
<strong><?=$Title?></strong> - posted <?=time_diff($BlogTime);?> by <?=$Author?>
<? if (check_perms('admin_manage_blog')) { ?>
- <a href="staffblog.php?action=editblog&amp;id=<?=$BlogID?>" class="brackets">Edit</a>
- <a href="staffblog.php?action=deleteblog&amp;id=<?=$BlogID?>&amp;auth=<?=$LoggedUser['AuthKey']?>" onclick="return confirm('Do you want to delete this?')" class="brackets">Delete</a>
+ <a href="staffblog.php?action=deleteblog&amp;id=<?=$BlogID?>&amp;auth=<?=$LoggedUser['AuthKey']?>" onclick="return confirm('Do you want to delete this?');" class="brackets">Delete</a>
<? } ?>
</div>
<div class="pad">
diff --git a/sections/staffpm/ajax_edit_response.php b/sections/staffpm/ajax_edit_response.php
index f2ffe86..1df04f7 100644
--- a/sections/staffpm/ajax_edit_response.php
+++ b/sections/staffpm/ajax_edit_response.php
@@ -31,7 +31,7 @@ if (($Message = db_string($_POST['message'])) && ($Name = db_string($_POST['name
SELECT *
FROM staff_pm_responses
WHERE ID = $ID");
- if ($DB->record_count() != 0) {
+ if ($DB->has_results()) {
// Edit response
$DB->query("
UPDATE staff_pm_responses
diff --git a/sections/staffpm/makedonor.php b/sections/staffpm/makedonor.php
index ee82a29..aed8282 100644
--- a/sections/staffpm/makedonor.php
+++ b/sections/staffpm/makedonor.php
@@ -14,7 +14,7 @@
JOIN users_info AS u ON u.UserID = c.UserID
WHERE ID = $ConvID");
list($Subject, $UserID, $Level, $AssignedToUser, $Unread, $Status, $Donor) = $DB->next_record();
- if ($DB->record_count() == 0) {
+ if (!$DB->has_results()) {
error(404);
}
diff --git a/sections/staffpm/staff_inbox.php b/sections/staffpm/staff_inbox.php
index a4fdb6c..b2d2178 100644
--- a/sections/staffpm/staff_inbox.php
+++ b/sections/staffpm/staff_inbox.php
@@ -118,7 +118,7 @@ $Row = 'a';
<div class="box pad" id="inbox">
<?
-if ($DB->record_count() == 0) :
+if (!$DB->has_results()) :
// No messages
?>
<h2>No messages</h2>
diff --git a/sections/staffpm/user_inbox.php b/sections/staffpm/user_inbox.php
index 893382f..ae1c9f6 100644
--- a/sections/staffpm/user_inbox.php
+++ b/sections/staffpm/user_inbox.php
@@ -35,7 +35,7 @@ $StaffPMs = $DB->query("
<div class="box pad" id="inbox">
<?
-if ($DB->record_count() == 0) {
+if (!$DB->has_results()) {
// No messages
?>
<h2>No messages</h2>
diff --git a/sections/tools/data/browser_support.php b/sections/tools/data/browser_support.php
index 944713d..437182d 100644
--- a/sections/tools/data/browser_support.php
+++ b/sections/tools/data/browser_support.php
@@ -1,6 +1,6 @@
<?
$Campaign = 'forumaudio';
-if (!$Votes = $Cache->get_value('support_'.$Campaign)) {
+if (!$Votes = $Cache->get_value("support_$Campaign")) {
$Votes = array(0,0);
}
if (!isset($_GET['support'])) {
@@ -9,7 +9,7 @@ if (!isset($_GET['support'])) {
<ul>
<li><?=number_format($Votes[0])?> +</li>
<li><?=number_format($Votes[1])?> -</li>
- <li><?=number_format(($Votes[0] / ($Votes[0] + $Votes[1])) * 100,3)?> %</li>
+ <li><?=number_format(($Votes[0] / ($Votes[0] + $Votes[1])) * 100, 3)?> %</li>
</ul>
<?
} elseif ($_GET['support'] === 'true') {
@@ -17,6 +17,6 @@ if (!isset($_GET['support'])) {
} elseif ($_GET['support'] === 'false') {
$Votes[1]++;
}
-$Cache->cache_value('support_'.$Campaign,$Votes,0);
+$Cache->cache_value("support_$Campaign", $Votes, 0);
?>
diff --git a/sections/tools/data/registration_log.php b/sections/tools/data/registration_log.php
index b7f3036..9ecf077 100644
--- a/sections/tools/data/registration_log.php
+++ b/sections/tools/data/registration_log.php
@@ -83,7 +83,7 @@ $DB->set_query_id($QueryID);
</form>
<?
-if ($DB->record_count()) {
+if ($DB->has_results()) {
?>
<div class="linkbox">
<?
@@ -108,7 +108,7 @@ if ($DB->record_count()) {
?>
<tr class="row<?=$Row?>">
<td><?=Users::format_username($UserID, true, true, true, true)?><br /><?=Users::format_username($InviterID, true, true, true, true)?></td>
- <td><?=Format::get_ratio_html($Uploaded,$Downloaded)?><br /><?=Format::get_ratio_html($InviterUploaded,$InviterDownloaded)?></td>
+ <td><?=Format::get_ratio_html($Uploaded, $Downloaded)?><br /><?=Format::get_ratio_html($InviterUploaded, $InviterDownloaded)?></td>
<td>
<span style="float: left;"><?=display_str($Email)?></span>
<span style="float: right;"><a href="userhistory.php?action=email&amp;userid=<?=$UserID?>" title="History" class="brackets">H</a> <a href="/user.php?action=search&amp;email_history=on&amp;email=<?=display_str($Email)?>" title="Search" class="brackets">S</a></span><br />
diff --git a/sections/tools/data/special_users.php b/sections/tools/data/special_users.php
index 21c2222..9980434 100644
--- a/sections/tools/data/special_users.php
+++ b/sections/tools/data/special_users.php
@@ -11,7 +11,7 @@ $DB->query("
FROM users_main AS m
WHERE m.CustomPermissions != ''
AND m.CustomPermissions != 'a:0:{}'");
-if ($DB->record_count()) {
+if ($DB->has_results()) {
?>
<table width="100%">
<tr class="colhead">
diff --git a/sections/tools/data/upscale_pool.php b/sections/tools/data/upscale_pool.php
index 9fcc177..6447b01 100644
--- a/sections/tools/data/upscale_pool.php
+++ b/sections/tools/data/upscale_pool.php
@@ -37,7 +37,7 @@ $DB->query("
list($TotalDisabled) = $DB->next_record();
$DB->set_query_id($RS);
-if ($DB->record_count()) {
+if ($DB->has_results()) {
?>
<div class="box pad">
<p>There are currently <?=number_format($Results)?> users queued by the system and <?=number_format($TotalDisabled)?> already disabled.</p>
diff --git a/sections/tools/data/user_flow.php b/sections/tools/data/user_flow.php
index 1254a87..12b76c0 100644
--- a/sections/tools/data/user_flow.php
+++ b/sections/tools/data/user_flow.php
@@ -21,24 +21,24 @@ if (!isset($_GET['page'])) {
LIMIT 1, 12");
$TimelineOut = array_reverse($DB->to_array());
foreach ($TimelineIn as $Month) {
- list($Label,$Amount) = $Month;
+ list($Label, $Amount) = $Month;
if ($Amount > $Max) {
$Max = $Amount;
}
}
foreach ($TimelineOut as $Month) {
- list($Label,$Amount) = $Month;
+ list($Label, $Amount) = $Month;
if ($Amount > $Max) {
$Max = $Amount;
}
}
foreach ($TimelineIn as $Month) {
- list($Label,$Amount) = $Month;
+ list($Label, $Amount) = $Month;
$Labels[] = $Label;
$InFlow[] = number_format(($Amount / $Max) * 100, 4);
}
foreach ($TimelineOut as $Month) {
- list($Label,$Amount) = $Month;
+ list($Label, $Amount) = $Month;
$OutFlow[] = number_format(($Amount / $Max) * 100, 4);
}
$Cache->cache_value('users_timeline', array($Labels, $InFlow, $OutFlow, $Max), mktime(0, 0, 0, date('n') + 1, 2));
diff --git a/sections/tools/managers/email_blacklist.php b/sections/tools/managers/email_blacklist.php
index dfc9cbd..82d0d02 100644
--- a/sections/tools/managers/email_blacklist.php
+++ b/sections/tools/managers/email_blacklist.php
@@ -18,7 +18,7 @@ $DB->query("
ORDER BY eb.Time DESC
LIMIT $Limit");
$Results = $DB->to_array(false, MYSQLI_ASSOC, false);
-$DB->query("SELECT FOUND_ROWS()");
+$DB->query('SELECT FOUND_ROWS()');
list ($NumResults) = $DB->next_record();
?>
<div class="header">
diff --git a/sections/tools/managers/forum_alter.php b/sections/tools/managers/forum_alter.php
index 26b0e7e..21c0a09 100644
--- a/sections/tools/managers/forum_alter.php
+++ b/sections/tools/managers/forum_alter.php
@@ -38,7 +38,7 @@ if ($_POST['submit'] == 'Delete') { //Delete
SELECT MinClassRead
FROM forums
WHERE ID = ' . $P['id']);
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
error(404);
} else {
list($MinClassRead) = $DB->next_record();
diff --git a/sections/tools/managers/label_aliases.php b/sections/tools/managers/label_aliases.php
index ab4cb92..a3bcc50 100644
--- a/sections/tools/managers/label_aliases.php
+++ b/sections/tools/managers/label_aliases.php
@@ -21,7 +21,7 @@ if (!empty($LabelID)) {
SELECT name
FROM labels
WHERE ID = '$LabelID'");
- if ($DB->record_count()) {
+ if ($DB->has_results()) {
list($LabelName) = $DB->next_record();
}
$LabelNameSQL = " WHERE AliasLabel = '$LabelName'";
diff --git a/sections/tools/managers/permissions_list.php b/sections/tools/managers/permissions_list.php
index c0cea0d..bfebd41 100644
--- a/sections/tools/managers/permissions_list.php
+++ b/sections/tools/managers/permissions_list.php
@@ -30,7 +30,7 @@ $DB->query("
LEFT JOIN users_levels AS l ON l.PermissionID = p.ID
GROUP BY p.ID
ORDER BY p.Secondary ASC, p.Level ASC");
-if ($DB->record_count()) {
+if ($DB->has_results()) {
?>
<table width="100%">
<tr class="colhead">
diff --git a/sections/tools/managers/tokens.php b/sections/tools/managers/tokens.php
index dc2420f..17f04a5 100644
--- a/sections/tools/managers/tokens.php
+++ b/sections/tools/managers/tokens.php
@@ -15,7 +15,8 @@ if (isset($_REQUEST['addtokens'])) {
SET FLTokens = FLTokens + $Tokens
WHERE Enabled = '1'";
if (!isset($_REQUEST['leechdisabled'])) {
- $sql .= " AND can_leech = 1";
+ $sql .= "
+ AND can_leech = 1";
}
$DB->query($sql);
$sql = "
@@ -23,11 +24,12 @@ if (isset($_REQUEST['addtokens'])) {
FROM users_main
WHERE Enabled = '1'";
if (!isset($_REQUEST['leechdisabled'])) {
- $sql .= " AND can_leech = 1";
+ $sql .= "
+ AND can_leech = 1";
}
$DB->query($sql);
while (list($UserID) = $DB->next_record()) {
- $Cache->delete_value('user_info_heavy_'.$UserID);
+ $Cache->delete_value("user_info_heavy_$UserID");
}
$message = '<strong>' . number_format($Tokens) . 'freeleech tokens added to all enabled users' . (!isset($_REQUEST['leechdisabled']) ? ' with enabled leeching privs' : '') . '.</strong><br /><br />';
} elseif (isset($_REQUEST['cleartokens'])) {
@@ -57,7 +59,7 @@ if (isset($_REQUEST['addtokens'])) {
foreach ($Users as $UserID) {
list($UserID) = $UserID;
- $Cache->delete_value('user_info_heavy_'.$UserID);
+ $Cache->delete_value("user_info_heavy_$UserID");
}
$where = '';
diff --git a/sections/tools/misc/create_user.php b/sections/tools/misc/create_user.php
index 8bbce89..d41e818 100644
--- a/sections/tools/misc/create_user.php
+++ b/sections/tools/misc/create_user.php
@@ -29,7 +29,7 @@ if (isset($_POST['Username'])) {
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')");
+ ('".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');
@@ -40,7 +40,9 @@ if (isset($_POST['Username'])) {
Tracker::update_tracker('add_user', array('id' => $UserID, 'passkey' => $torrent_pass));
//Default stylesheet
- $DB->query("SELECT ID FROM stylesheets");
+ $DB->query("
+ SELECT ID
+ FROM stylesheets");
list($StyleID) = $DB->next_record();
//Auth key
@@ -51,31 +53,31 @@ if (isset($_POST['Username'])) {
INSERT INTO users_info
(UserID, StyleID, AuthKey, JoinDate)
VALUES
- ('".db_string($UserID)."','".db_string($StyleID)."','".db_string($AuthKey)."', '".sqltime()."')");
+ ('".db_string($UserID)."', '".db_string($StyleID)."', '".db_string($AuthKey)."', '".sqltime()."')");
//Redirect to users profile
- header ("Location: user.php?id=".$UserID);
+ 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");
+ error('Please supply a username');
} elseif (empty($Email)) {
//Give the Error -- We do not have an email address
- error("Please supply 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");
+ error('Please supply a password');
} else {
//Uh oh, something went wrong
- error("Unknown error");
+ error('Unknown error');
}
diff --git a/sections/tools/misc/dupe_ip.php b/sections/tools/misc/dupe_ip.php
index 1842269..934f835 100644
--- a/sections/tools/misc/dupe_ip.php
+++ b/sections/tools/misc/dupe_ip.php
@@ -19,28 +19,26 @@ $RS = $DB->query("
i.Donor,
i.Warned,
i.JoinDate,
- ( SELECT
- COUNT(DISTINCT h.UserID)
+ ( SELECT COUNT(DISTINCT h.UserID)
FROM users_history_ips AS h
- WHERE h.IP=m.IP
+ WHERE h.IP = m.IP
) AS Uses
FROM users_main AS m
- LEFT JOIN users_info AS i ON i.UserID=m.ID
+ LEFT JOIN users_info AS i ON i.UserID = m.ID
WHERE
- ( SELECT
- COUNT(DISTINCT h.UserID)
+ ( SELECT COUNT(DISTINCT h.UserID)
FROM users_history_ips AS h
- WHERE h.IP=m.IP
+ WHERE h.IP = m.IP
) >= ".IP_OVERLAPS."
AND m.Enabled = '1'
AND m.IP != '127.0.0.1'
ORDER BY Uses DESC
LIMIT $Limit");
-$DB->query("SELECT FOUND_ROWS()");
+$DB->query('SELECT FOUND_ROWS()');
list($Results) = $DB->next_record();
$DB->set_query_id($RS);
-if ($DB->record_count()) {
+if ($DB->has_results()) {
?>
<div class="linkbox">
<?
diff --git a/sections/tools/misc/tags.php b/sections/tools/misc/tags.php
index b0e1a1d..aa6eabe 100644
--- a/sections/tools/misc/tags.php
+++ b/sections/tools/misc/tags.php
@@ -76,7 +76,7 @@ if (isset($_GET['tag']) || isset($_GET['replace'])) {
FROM tags
WHERE Name = '$Tag'
LIMIT 1;");
- if ($DB->record_count() == 0) {
+ if (!$DB->has_results()) {
echo "
<div class=\"box pad center\">
<strong>Error:</strong> No such tag found: $Tag
@@ -93,7 +93,7 @@ if (isset($_GET['tag']) || isset($_GET['replace'])) {
FROM tags
WHERE Name = '$Replacement'
LIMIT 1;");
- if ($DB->record_count() == 0 ) {
+ if (!$DB->has_results() ) {
$Mode = MODE_RENAME;
} else {
$Mode = MODE_MERGE;
@@ -156,7 +156,7 @@ if (isset($_GET['tag']) || isset($_GET['replace'])) {
SELECT GroupID
FROM torrents_tags
WHERE TagID = $ReplacementID;");
- if ($DB->record_count() > 0 ) {
+ if ($DB->has_results() ) {
$Query = "
DELETE FROM torrents_tags
WHERE TagID = $TagID
@@ -181,7 +181,7 @@ if (isset($_GET['tag']) || isset($_GET['replace'])) {
SELECT ArtistID
FROM artists_tags
WHERE TagID = $ReplacementID;");
- if ($DB->record_count() > 0 ) {
+ if ($DB->has_results() ) {
$Query = "
DELETE FROM artists_tags
WHERE TagID = $TagID
@@ -206,7 +206,7 @@ if (isset($_GET['tag']) || isset($_GET['replace'])) {
SELECT RequestID
FROM requests_tags
WHERE TagID = $ReplacementID;");
- if ($DB->record_count() > 0) {
+ if ($DB->has_results()) {
$Query = "
DELETE FROM requests_tags
WHERE TagID = $TagID
diff --git a/sections/torrents/add_cover_art.php b/sections/torrents/add_cover_art.php
index 4a84334..115b522 100644
--- a/sections/torrents/add_cover_art.php
+++ b/sections/torrents/add_cover_art.php
@@ -32,8 +32,10 @@ for ($i = 0; $i < count($Images); $i++) {
$Image = db_string($Image);
$Summary = db_string($Summary);
$DB->query("
- INSERT IGNORE INTO cover_art (GroupID, Image, Summary, UserID, Time)
- VALUES ('$GroupID', '$Image', '$Summary', '$UserID', '$Time')");
+ INSERT IGNORE INTO cover_art
+ (GroupID, Image, Summary, UserID, Time)
+ VALUES
+ ('$GroupID', '$Image', '$Summary', '$UserID', '$Time')");
if ($DB->affected_rows()) {
$Changed = true;
@@ -41,7 +43,7 @@ for ($i = 0; $i < count($Images); $i++) {
}
if ($Changed) {
- $Cache->delete_value('torrents_cover_art_' . $GroupID);
+ $Cache->delete_value("torrents_cover_art_$GroupID");
}
header('Location: '.$_SERVER['HTTP_REFERER']);
diff --git a/sections/torrents/add_tag.php b/sections/torrents/add_tag.php
index f947475..240c7c0 100644
--- a/sections/torrents/add_tag.php
+++ b/sections/torrents/add_tag.php
@@ -13,7 +13,7 @@ if (!is_number($GroupID) || !$GroupID) {
//Delete cached tag used for undos
if (isset($_POST['undo'])) {
- $Cache->delete_value('deleted_tags_'.$GroupID.'_'.$LoggedUser['ID']);
+ $Cache->delete_value("deleted_tags_$GroupID".'_'.$LoggedUser['ID']);
}
$Tags = explode(',', $_POST['tagname']);
@@ -38,10 +38,10 @@ foreach ($Tags as $TagName) {
$DB->query("
SELECT TagID
FROM torrents_tags_votes
- WHERE GroupID='$GroupID'
- AND TagID='$TagID'
- AND UserID='$UserID'");
- if ($DB->record_count() != 0) { // User has already voted on this tag, and is trying hax to make the rating go up
+ WHERE GroupID = '$GroupID'
+ AND TagID = '$TagID'
+ AND UserID = '$UserID'");
+ if ($DB->has_results()) { // User has already voted on this tag, and is trying hax to make the rating go up
header('Location: '.$_SERVER['HTTP_REFERER']);
die();
}
@@ -52,19 +52,22 @@ foreach ($Tags as $TagName) {
(TagID, GroupID, PositiveVotes, UserID)
VALUES
('$TagID', '$GroupID', '3', '$UserID')
- ON DUPLICATE KEY UPDATE PositiveVotes=PositiveVotes+2");
+ ON DUPLICATE KEY UPDATE PositiveVotes = PositiveVotes + 2");
$DB->query("
- INSERT INTO torrents_tags_votes (GroupID, TagID, UserID, Way)
- VALUES ('$GroupID', '$TagID', '$UserID', 'up')");
+ INSERT INTO torrents_tags_votes
+ (GroupID, TagID, UserID, Way)
+ VALUES
+ ('$GroupID', '$TagID', '$UserID', 'up')");
$DB->query("
- INSERT INTO group_log (GroupID, UserID, Time, Info)
- VALUES ('$GroupID',".$LoggedUser['ID'].",'".sqltime()."','".db_string('Tag "'.$TagName.'" added to group')."')");
+ INSERT INTO group_log
+ (GroupID, UserID, Time, Info)
+ VALUES
+ ('$GroupID', ".$LoggedUser['ID'].", '".sqltime()."', '".db_string("Tag \"$TagName\" added to group")."')");
}
}
-
Torrents::update_hash($GroupID); // Delete torrent group cache
header('Location: '.$_SERVER['HTTP_REFERER']);
?>
diff --git a/sections/torrents/browse2.php b/sections/torrents/browse2.php
index 02275de..f1393ab 100644
--- a/sections/torrents/browse2.php
+++ b/sections/torrents/browse2.php
@@ -54,7 +54,7 @@ if (!empty($_GET['searchstr']) || !empty($_GET['groupname'])) {
SELECT ID, GroupID
FROM torrents
WHERE info_hash = '$InfoHash'");
- if ($DB->record_count() > 0) {
+ if ($DB->has_results()) {
list($ID, $GroupID) = $DB->next_record();
header("Location: torrents.php?id=$GroupID&torrentid=$ID");
die();
diff --git a/sections/torrents/delete.php b/sections/torrents/delete.php
index a5da7bd..886b111 100644
--- a/sections/torrents/delete.php
+++ b/sections/torrents/delete.php
@@ -15,7 +15,7 @@ $DB->query("
WHERE t.ID=$TorrentID
GROUP BY t.UserID");
-if ($DB->record_count() < 1) {
+if (!$DB->has_results()) {
error('Torrent already deleted.');
}
@@ -118,7 +118,7 @@ if (check_perms('admin_reports')) {
LEFT JOIN users_main AS uploader ON uploader.ID=t.UserID
WHERE t.ID=".$TorrentID);
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
die();
}
list($GroupName, $GroupID, $ArtistID, $ArtistName, $Year, $CategoryID, $Time, $Remastered, $RemasterTitle,
@@ -189,7 +189,7 @@ if (check_perms('admin_reports')) {
LEFT JOIN torrents AS t ON t.ID=r.TorrentID
WHERE r.Status != 'Resolved'
AND t.GroupID=$GroupID");
- $GroupOthers = ($DB->record_count());
+ $GroupOthers = ($DB->has_results());
if ($GroupOthers > 0) { ?>
<div style="text-align: right;">
@@ -203,7 +203,7 @@ if (check_perms('admin_reports')) {
JOIN torrents AS t ON t.ID=r.TorrentID
WHERE r.Status != 'Resolved'
AND t.UserID=$UploaderID");
- $UploaderOthers = ($DB->record_count());
+ $UploaderOthers = ($DB->has_results());
if ($UploaderOthers > 0) { ?>
<div style="text-align: right;">
@@ -219,7 +219,7 @@ if (check_perms('admin_reports')) {
FROM requests AS req
JOIN users_main AS um ON um.ID=req.FillerID
AND req.TorrentID=$TorrentID");
- $Requests = ($DB->record_count());
+ $Requests = ($DB->has_results());
if ($Requests > 0) {
while (list($RequestID, $FillerID, $FillerName, $FilledTime) = $DB->next_record()) {
?>
diff --git a/sections/torrents/details.php b/sections/torrents/details.php
index 2e09416..47e66f3 100644
--- a/sections/torrents/details.php
+++ b/sections/torrents/details.php
@@ -89,7 +89,7 @@ if (!$CoverArt) {
ORDER BY Time ASC");
$CoverArt = array();
$CoverArt = $DB->to_array();
- if ($DB->record_count() > 0) {
+ if ($DB->has_results()) {
$Cache->cache_value('torrents_cover_art_' . $GroupID, $CoverArt, 0);
}
}
diff --git a/sections/torrents/download.php b/sections/torrents/download.php
index bf39b98..b93cb00 100644
--- a/sections/torrents/download.php
+++ b/sections/torrents/download.php
@@ -68,7 +68,7 @@ if (!is_array($Info) || !array_key_exists('PlainArtists', $Info) || empty($Info[
FROM torrents AS t
INNER JOIN torrents_group AS tg ON tg.ID = t.GroupID
WHERE t.ID = '".db_string($TorrentID)."'");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
error(404);
}
$Info = array($DB->next_record(MYSQLI_NUM, array(4, 5, 6, 10)));
diff --git a/sections/torrents/editgroup.php b/sections/torrents/editgroup.php
index 739e6af..37c4b51 100644
--- a/sections/torrents/editgroup.php
+++ b/sections/torrents/editgroup.php
@@ -35,7 +35,7 @@ $DB->query("
FROM torrents_group AS tg
LEFT JOIN wiki_torrents AS wt ON wt.RevisionID = tg.RevisionID
WHERE tg.ID = '$GroupID'");
-if ($DB->record_count() == 0) {
+if (!$DB->has_results()) {
error(404);
}
list($Name, $Image, $Body, $WikiImage, $WikiBody, $Year, $RecordLabel, $CatalogueNumber, $ReleaseType, $CategoryID, $VanityHouse) = $DB->next_record();
diff --git a/sections/torrents/editgroupid.php b/sections/torrents/editgroupid.php
index be2c26b..9b2e6de 100644
--- a/sections/torrents/editgroupid.php
+++ b/sections/torrents/editgroupid.php
@@ -27,7 +27,7 @@ if (empty($_POST['confirm'])) {
SELECT Name
FROM torrents_group
WHERE ID = $OldGroupID");
- if ($DB->record_count() < 1) {
+ if (!$DB->has_results()) {
//Trying to move to an empty group? I think not!
set_message('That group does not exist!');
header('Location: '.$_SERVER['HTTP_REFERER']);
diff --git a/sections/torrents/grouplog.php b/sections/torrents/grouplog.php
index b6a862f..abe82a0 100644
--- a/sections/torrents/grouplog.php
+++ b/sections/torrents/grouplog.php
@@ -45,7 +45,7 @@ if (!empty($Groups['matches'][$GroupID])) {
FROM torrents
WHERE ID = $TorrentID");
list($Media, $Format, $Encoding) = $DB->next_record();
- if ($DB->record_count() == 0) { ?>
+ if (!$DB->has_results()) { ?>
<td><a href="torrents.php?torrentid=<?=$TorrentID?>"><?=$TorrentID?></a> (Deleted)</td><?
} elseif ($Media == '') { ?>
<td><a href="torrents.php?torrentid=<?=$TorrentID?>"><?=$TorrentID?></a></td><?
diff --git a/sections/torrents/index.php b/sections/torrents/index.php
index 472f06d..b90e732 100644
--- a/sections/torrents/index.php
+++ b/sections/torrents/index.php
@@ -273,7 +273,7 @@ if (!empty($_REQUEST['action'])) {
if ($LoggedUser['ID'] != $AuthorID && !check_perms('site_moderate_forums')) {
error(404);
}
- if ($DB->record_count() == 0) {
+ if (!$DB->has_results()) {
error(404);
}
diff --git a/sections/torrents/merge.php b/sections/torrents/merge.php
index 18b2be8..b59d9eb 100644
--- a/sections/torrents/merge.php
+++ b/sections/torrents/merge.php
@@ -20,7 +20,7 @@ $DB->query("
SELECT CategoryID, Name
FROM torrents_group
WHERE ID = '$NewGroupID'");
-if ($DB->record_count() == 0) {
+if (!$DB->has_results()) {
error('Target group does not exist.');
}
list($CategoryID, $NewName) = $DB->next_record();
diff --git a/sections/torrents/notify.php b/sections/torrents/notify.php
index c9ba015..c8a04bc 100644
--- a/sections/torrents/notify.php
+++ b/sections/torrents/notify.php
@@ -47,7 +47,14 @@ function header_link($SortKey, $DefaultWay = 'desc') {
}
return "?action=notify&amp;order_way=$NewWay&amp;order_by=$SortKey&amp;".Format::get_url(array('page', 'order_way', 'order_by'));
}
-$UserID = $LoggedUser['ID'];
+//Perhaps this should be a feature at some point
+if (check_perms('users_mod') && !empty($_GET['userid']) && is_number($_GET['userid']) && $_GET['userid'] != $LoggedUser['ID']) {
+ $UserID = $_GET['userid'];
+ $Sneaky = true;
+} else {
+ $Sneaky = false;
+ $UserID = $LoggedUser['ID'];
+}
// Sorting by release year requires joining torrents_group, which is slow. Using a temporary table
// makes it speedy enough as long as there aren't too many records to create
@@ -80,8 +87,8 @@ if ($OrderTbl == 'tg') {
: ''));
$DB->query("
UPDATE temp_notify_torrents AS tnt
- JOIN torrents_group AS tg ON tnt.GroupID=tg.ID
- SET tnt.Year=tg.Year");
+ JOIN torrents_group AS tg ON tnt.GroupID = tg.ID
+ SET tnt.Year = tg.Year");
$DB->query("
SELECT TorrentID, GroupID, UnRead, FilterID
@@ -99,14 +106,14 @@ if ($OrderTbl == 'tg') {
t.GroupID
FROM users_notify_torrents AS unt
JOIN torrents AS t ON t.ID = unt.TorrentID
- WHERE unt.UserID=$UserID".
+ WHERE unt.UserID = $UserID".
($FilterID
- ? " AND unt.FilterID=$FilterID"
+ ? " AND unt.FilterID = $FilterID"
: '')."
ORDER BY $OrderCol $OrderWay
LIMIT $Limit");
$Results = $DB->to_array(false, MYSQLI_ASSOC, false);
- $DB->query("SELECT FOUND_ROWS()");
+ $DB->query('SELECT FOUND_ROWS()');
list($TorrentCount) = $DB->next_record();
}
@@ -145,29 +152,31 @@ if (!empty($GroupIDs)) {
//Clear before header but after query so as to not have the alert bar on this page load
$DB->query("
UPDATE users_notify_torrents
- SET UnRead='0'
- WHERE UserID=".$LoggedUser['ID'].'
+ SET UnRead = '0'
+ WHERE UserID = ".$LoggedUser['ID'].'
AND TorrentID IN ('.implode(',', $UnReadIDs).')');
$Cache->delete_value('notifications_new_'.$LoggedUser['ID']);
}
}
-View::show_header('My notifications', 'notifications');
-
+if ($Sneaky) {
+ $UserInfo = Users::user_info($UserID);
+ View::show_header($UserInfo['Username'].'\'s notifications', 'notifications');
+} else {
+ View::show_header('My notifications', 'notifications');
+}
?>
<div class="thin widethin">
<div class="header">
<h2>Latest notifications</h2>
</div>
<div class="linkbox">
-<? if ($FilterID) { ?>
- <a href="torrents.php?action=notify" class="brackets">View all</a>&nbsp;&nbsp;&nbsp;
-<? } else { ?>
- <a href="torrents.php?action=notify_clear&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets">Clear all</a>&nbsp;&nbsp;&nbsp;
- <a href="javascript:SuperGroupClear()" class="brackets">Clear selected</a>&nbsp;&nbsp;&nbsp;
+<? if ($FilterID) { ?>
+ <a href="torrents.php?action=notify<?=($Sneaky ? "&amp;userid=$UserID" : '')?>" class="brackets">View all</a>&nbsp;&nbsp;&nbsp;
+<? } elseif (!$Sneaky) { ?>
+ <a href="torrents.php?action=notify_clear&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets">Clear all old</a>&nbsp;&nbsp;&nbsp;
+ <a href="#" onclick="clearSelected(); return false;" class="brackets">Clear selected</a>&nbsp;&nbsp;&nbsp;
<a href="torrents.php?action=notify_catchup&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets">Catch up</a>&nbsp;&nbsp;&nbsp;
-<? }
-
-?>
+<? } ?>
<a href="user.php?action=notify" class="brackets">Edit filters</a>&nbsp;&nbsp;&nbsp;
</div>
<? if ($TorrentCount > NOTIFICATIONS_PER_PAGE) { ?>
@@ -202,15 +211,19 @@ if (empty($Results)) {
?>
<div class="header">
<h3>
- Matches for <?=$FilterResults['FilterLabel'] !== false
- ? '<a href="torrents.php?action=notify&amp;filterid='.$FilterID.'">'.$FilterResults['FilterLabel'].'</a>'
- : 'unknown filter['.$FilterID.']'?>
+<? if ($FilterResults['FilterLabel'] !== false) { ?>
+ Matches for <a href="torrents.php?action=notify&amp;filterid=<?=$FilterID.($Sneaky ? "&amp;userid=$UserID" : '')?>"><?=$FilterResults['FilterLabel']?></a>
+<? } else { ?>
+ Matches for unknown filter[<?=$FilterID?>]
+<? } ?>
</h3>
</div>
<div class="linkbox notify_filter_links">
- <a href="javascript:GroupClear($('#notificationform_<?=$FilterID?>').raw())" class="brackets">Clear selected in filter</a>
+<? if (!$Sneaky) { ?>
+ <a href="#" onclick="clearSelected(<?=$FilterID?>); return false;" class="brackets">Clear selected in filter</a>
<a href="torrents.php?action=notify_clear_filter&amp;filterid=<?=$FilterID?>&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets">Clear all old in filter</a>
<a href="torrents.php?action=notify_catchup_filter&amp;filterid=<?=$FilterID?>&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets">Mark all in filter as read</a>
+<? } ?>
</div>
<form class="manage_form" name="torrents" id="notificationform_<?=$FilterID?>" action="">
<table class="torrent_table cats checkboxes border">
@@ -286,8 +299,11 @@ if (empty($Results)) {
[ <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download">DL</a>
<? if (Torrents::can_use_token($TorrentInfo)) { ?>
| <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&amp;usetoken=1" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
-<? } ?>
- | <a href="#" onclick="clearItem(<?=$TorrentID?>);return false;" title="Remove from notifications list">CL</a>
+<?
+ }
+ if (!$Sneaky) { ?>
+ | <a href="#" onclick="clearItem(<?=$TorrentID?>); return false;" title="Remove from notifications list">CL</a>
+<? } ?> ]
</span>
<strong><?=$DisplayName?></strong>
<div class="torrent_info">
@@ -295,13 +311,13 @@ if (empty($Results)) {
<? if ($Result['UnRead']) {
echo '<strong class="new">New!</strong>';
} ?>
- <span class="bookmark" style="float: right;">
-<? if (Bookmarks::has_bookmarked("torrent", $GroupID)) { ?>
- <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="remove_bookmark" title="Remove bookmark" onclick="Unbookmark('torrent',<?=$GroupID?>,'Bookmark');return false;">Unbookmark</a>
+ <span class="bookmark" style="float: right;">
+<? if (Bookmarks::has_bookmarked('torrent', $GroupID)) { ?>
+ <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="remove_bookmark" title="Remove bookmark" onclick="Unbookmark('torrent',<?=$GroupID?>,'Bookmark');return false;">Unbookmark</a>
<? } else { ?>
- <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="add_bookmark" title="Add bookmark" onclick="Bookmark('torrent',<?=$GroupID?>,'Unbookmark');return false;">Bookmark</a>
+ <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="add_bookmark" title="Add bookmark" onclick="Bookmark('torrent',<?=$GroupID?>,'Unbookmark');return false;">Bookmark</a>
<? } ?>
- </span>
+ </span>
</div>
<div class="tags"><?=$TorrentTags->format()?></div>
</div>
diff --git a/sections/torrents/peerlist.php b/sections/torrents/peerlist.php
index 7527dc9..c695ba4 100644
--- a/sections/torrents/peerlist.php
+++ b/sections/torrents/peerlist.php
@@ -1,4 +1,4 @@
-<?
+<?php
if (!isset($_GET['torrentid']) || !is_number($_GET['torrentid'])) {
error(404);
}
@@ -23,13 +23,13 @@ $Result = $DB->query("
xu.remaining,
xu.useragent
FROM xbt_files_users AS xu
- LEFT JOIN users_main AS um ON um.ID=xu.uid
- JOIN torrents AS t ON t.ID=xu.fid
- WHERE xu.fid='$TorrentID'
- AND um.Visible='1'
+ LEFT JOIN users_main AS um ON um.ID = xu.uid
+ JOIN torrents AS t ON t.ID = xu.fid
+ WHERE xu.fid = '$TorrentID'
+ AND um.Visible = '1'
ORDER BY xu.uid = '$LoggedUser[ID]' DESC, xu.uploaded DESC
LIMIT $Limit");
-$DB->query("SELECT FOUND_ROWS()");
+$DB->query('SELECT FOUND_ROWS()');
list($NumResults) = $DB->next_record();
$DB->set_query_id($Result);
diff --git a/sections/torrents/remove_cover_art.php b/sections/torrents/remove_cover_art.php
index 4a1c76c..4613521 100644
--- a/sections/torrents/remove_cover_art.php
+++ b/sections/torrents/remove_cover_art.php
@@ -26,7 +26,7 @@ $DB->query("
INSERT INTO group_log
(GroupID, UserID, Time, Info)
VALUES
- ('$GroupID', ".$LoggedUser['ID'].", '".sqltime()."', '".db_string("Additional Cover \"$Summary - $Image\" removed from group")."')");
+ ('$GroupID', ".$LoggedUser['ID'].", '".sqltime()."', '".db_string("Additional cover \"$Summary - $Image\" removed from group")."')");
$Cache->delete_value("torrents_cover_art_$GroupID");
header('Location: '.$_SERVER['HTTP_REFERER']);
diff --git a/sections/torrents/reseed.php b/sections/torrents/reseed.php
index b50d584..0b3d740 100644
--- a/sections/torrents/reseed.php
+++ b/sections/torrents/reseed.php
@@ -41,7 +41,7 @@ $DB->query("
GROUP BY uid
ORDER BY tstamp DESC
LIMIT 10");
-if ($DB->record_count() > 0) {
+if ($DB->has_results()) {
$Users = $DB->to_array();
foreach ($Users as $User) {
$UserID = $User['uid'];
@@ -50,7 +50,7 @@ if ($DB->record_count() > 0) {
SELECT UserID
FROM top_snatchers
WHERE UserID='$UserID'");
- if ($DB->record_count() > 0) {
+ if ($DB->has_results()) {
continue;
}
diff --git a/sections/torrents/snatchlist.php b/sections/torrents/snatchlist.php
index d616fa8..6e14cec 100644
--- a/sections/torrents/snatchlist.php
+++ b/sections/torrents/snatchlist.php
@@ -1,4 +1,4 @@
-<?
+<?php
if (!isset($_GET['torrentid']) || !is_number($_GET['torrentid']) || !check_perms('site_view_torrent_snatchlist')) {
error(404);
}
@@ -18,12 +18,12 @@ $Result = $DB->query("
xs.uid,
xs.tstamp
FROM xbt_snatched AS xs
- WHERE xs.fid='$TorrentID'
+ WHERE xs.fid = '$TorrentID'
ORDER BY xs.tstamp DESC
LIMIT $Limit");
$Results = $DB->to_array('uid', MYSQLI_ASSOC);
-$DB->query("SELECT FOUND_ROWS()");
+$DB->query('SELECT FOUND_ROWS()');
list($NumResults) = $DB->next_record();
?>
diff --git a/sections/torrents/takechangecategory.php b/sections/torrents/takechangecategory.php
index 100f72e..8369ea5 100644
--- a/sections/torrents/takechangecategory.php
+++ b/sections/torrents/takechangecategory.php
@@ -30,7 +30,7 @@ switch ($Categories[$NewCategoryID-1]) {
SELECT ArtistID, AliasID, Redirect, Name
FROM artists_alias
WHERE Name LIKE '$ArtistName'");
- if ($DB->record_count() == 0) {
+ if (!$DB->has_results()) {
$Redirect = 0;
$DB->query("
INSERT INTO artists_group (Name)
@@ -98,7 +98,7 @@ $DB->query("
SELECT ID
FROM torrents
WHERE GroupID = '$OldGroupID'");
-if ($DB->record_count() == 0) {
+if (!$DB->has_results()) {
$DB->query("
UPDATE torrents_comments
SET GroupID = '$GroupID'
diff --git a/sections/torrents/takeedit.php b/sections/torrents/takeedit.php
index 03cee3d..fbcd495 100644
--- a/sections/torrents/takeedit.php
+++ b/sections/torrents/takeedit.php
@@ -84,7 +84,7 @@ $DB->query("
SELECT UserID, Remastered, RemasterYear, FreeTorrent
FROM torrents
WHERE ID = $TorrentID");
-if ($DB->record_count() == 0) {
+if (!$DB->has_results()) {
error(404);
}
list($UserID, $Remastered, $RemasterYear, $CurFreeLeech) = $DB->next_record(MYSQLI_BOTH, false);
@@ -105,7 +105,7 @@ if ($Properties['UnknownRelease'] && !($Remastered == '1' && !$RemasterYear) &&
}
}
-$Validate->SetFields('type','1','number','Not a valid type.',array('maxlength'=>count($Categories), 'minlength'=>1));
+$Validate->SetFields('type', '1', 'number', 'Not a valid type.', array('maxlength' => count($Categories), 'minlength' => 1));
switch ($Type) {
case 'Music':
if (!empty($Properties['Remastered']) && !$Properties['UnknownRelease']) {
@@ -115,13 +115,12 @@ switch ($Type) {
}
if (!empty($Properties['Remastered']) && !$Properties['UnknownRelease'] && $Properties['RemasterYear'] < 1982 && $Properties['Media'] == 'CD') {
- error("You have selected a year for an album that predates the media you say it was created on.");
+ error('You have selected a year for an album that predates the medium you say it was created on.');
header("Location: torrents.php?action=edit&id=$TorrentID");
die();
}
- $Validate->SetFields('remaster_title',
- '0','string','Remaster title must be between 2 and 80 characters.',array('maxlength'=>80, 'minlength'=>2));
+ $Validate->SetFields('remaster_title', '0', 'string', 'Remaster title must be between 2 and 80 characters.', array('maxlength' => 80, 'minlength' => 2));
if ($Properties['RemasterTitle'] == 'Original Release') {
error('"Original Release" is not a valid remaster title.');
@@ -129,77 +128,62 @@ switch ($Type) {
die();
}
- $Validate->SetFields('remaster_record_label',
- '0','string','Remaster record label must be between 2 and 80 characters.',array('maxlength'=>80, 'minlength'=>2));
+ $Validate->SetFields('remaster_record_label', '0', 'string', 'Remaster record label must be between 2 and 80 characters.', array('maxlength' => 80, 'minlength' => 2));
- $Validate->SetFields('remaster_catalogue_number',
- '0','string','Remaster catalogue number must be between 2 and 80 characters.',array('maxlength'=>80, 'minlength'=>2));
+ $Validate->SetFields('remaster_catalogue_number', '0', 'string', 'Remaster catalogue number must be between 2 and 80 characters.', array('maxlength' => 80, 'minlength' => 2));
- $Validate->SetFields('format',
- '1','inarray','Not a valid format.',array('inarray'=>$Formats));
+ $Validate->SetFields('format', '1', 'inarray', 'Not a valid format.', array('inarray' => $Formats));
- $Validate->SetFields('bitrate',
- '1','inarray','You must choose a bitrate.', array('inarray'=>$Bitrates));
+ $Validate->SetFields('bitrate', '1', 'inarray', 'You must choose a bitrate.', array('inarray' => $Bitrates));
// Handle 'other' bitrates
if ($Properties['Encoding'] == 'Other') {
- $Validate->SetFields('other_bitrate',
- '1','text','You must enter the other bitrate (max length: 9 characters).', array('maxlength'=>9));
+ $Validate->SetFields('other_bitrate', '1', 'text', 'You must enter the other bitrate (max length: 9 characters).', array('maxlength' => 9));
$enc = trim($_POST['other_bitrate']);
if (isset($_POST['vbr'])) {
- $enc.=' (VBR)';
+ $enc .= ' (VBR)';
}
$Properties['Encoding'] = $enc;
$Properties['Bitrate'] = $enc;
} else {
- $Validate->SetFields('bitrate',
- '1','inarray','You must choose a bitrate.', array('inarray'=>$Bitrates));
+ $Validate->SetFields('bitrate', '1', 'inarray', 'You must choose a bitrate.', array('inarray' => $Bitrates));
}
- $Validate->SetFields('media',
- '1','inarray','Not a valid media.',array('inarray'=>$Media));
+ $Validate->SetFields('media', '1', 'inarray', 'Not a valid media.', array('inarray' => $Media));
- $Validate->SetFields('release_desc',
- '0','string','Invalid release description.',array('maxlength'=>1000000, 'minlength'=>0));
+ $Validate->SetFields('release_desc', '0', 'string', 'Invalid release description.', array('maxlength' => 1000000, 'minlength' => 0));
break;
case 'Audiobooks':
case 'Comedy':
- /*$Validate->SetFields('title',
- '1','string','Title must be between 2 and 300 characters.',array('maxlength'=>300, 'minlength'=>2));
+ /*$Validate->SetFields('title', '1', 'string', 'Title must be between 2 and 300 characters.', array('maxlength' => 300, 'minlength' => 2));
^ this is commented out because there is no title field on these pages*/
- $Validate->SetFields('year',
- '1','number','The year of the release must be entered.');
+ $Validate->SetFields('year', '1', 'number', 'The year of the release must be entered.');
- $Validate->SetFields('format',
- '1','inarray','Not a valid format.',array('inarray'=>$Formats));
+ $Validate->SetFields('format', '1', 'inarray', 'Not a valid format.', array('inarray' => $Formats));
- $Validate->SetFields('bitrate',
- '1','inarray','You must choose a bitrate.', array('inarray'=>$Bitrates));
+ $Validate->SetFields('bitrate', '1', 'inarray', 'You must choose a bitrate.', array('inarray' => $Bitrates));
// Handle 'other' bitrates
if ($Properties['Encoding'] == 'Other') {
- $Validate->SetFields('other_bitrate',
- '1','text','You must enter the other bitrate (max length: 9 characters).', array('maxlength'=>9));
+ $Validate->SetFields('other_bitrate', '1', 'text', 'You must enter the other bitrate (max length: 9 characters).', array('maxlength' => 9));
$enc = trim($_POST['other_bitrate']);
if (isset($_POST['vbr'])) {
- $enc.=' (VBR)';
+ $enc .= ' (VBR)';
}
$Properties['Encoding'] = $enc;
$Properties['Bitrate'] = $enc;
} else {
- $Validate->SetFields('bitrate',
- '1','inarray','You must choose a bitrate.', array('inarray'=>$Bitrates));
+ $Validate->SetFields('bitrate', '1', 'inarray', 'You must choose a bitrate.', array('inarray' => $Bitrates));
}
- $Validate->SetFields('release_desc',
- '0','string','The release description has a minimum length of 10 characters.',array('maxlength'=>1000000, 'minlength'=>10));
+ $Validate->SetFields('release_desc', '0', 'string', 'The release description has a minimum length of 10 characters.', array('maxlength' => 1000000, 'minlength' => 10));
break;
@@ -207,8 +191,7 @@ switch ($Type) {
case 'Comics':
case 'E-Books':
case 'E-Learning Videos':
- /*$Validate->SetFields('title',
- '1','string','Title must be between 2 and 300 characters.',array('maxlength'=>300, 'minlength'=>2));
+ /*$Validate->SetFields('title', '1', 'string', 'Title must be between 2 and 300 characters.', array('maxlength' => 300, 'minlength' => 2));
^ this is commented out because there is no title field on these pages*/
break;
}
@@ -220,7 +203,7 @@ if ($Properties['Remastered'] && !$Properties['RemasterYear']) {
if ($LoggedUser['ID'] == $UserID || check_perms('edit_unknowns')) {
//Fine!
} else {
- $Err = "You may not edit somebody else's upload to unknown release.";
+ $Err = "You may not edit someone else's upload to unknown release.";
}
}
diff --git a/sections/torrents/takegroupedit.php b/sections/torrents/takegroupedit.php
index 7674478..a990290 100644
--- a/sections/torrents/takegroupedit.php
+++ b/sections/torrents/takegroupedit.php
@@ -151,7 +151,7 @@ $DB->query("
SELECT CollageID
FROM collages_torrents
WHERE GroupID = '$GroupID'");
-if ($DB->record_count() > 0) {
+if ($DB->has_results()) {
while (list($CollageID) = $DB->next_record()) {
$Cache->delete_value('collage_'.$CollageID);
}
@@ -185,7 +185,7 @@ $DB->query("
SELECT ID
FROM torrents
WHERE GroupID = $GroupID");
-if ($DB->record_count()) {
+if ($DB->has_results()) {
$TorrentIDs = implode(',', $DB->collect('ID'));
$DB->query("
SELECT DISTINCT uid
diff --git a/sections/torrents/takemasspm.php b/sections/torrents/takemasspm.php
index 9402e56..d94cc5e 100644
--- a/sections/torrents/takemasspm.php
+++ b/sections/torrents/takemasspm.php
@@ -46,7 +46,7 @@ $DB->query("
FROM xbt_snatched
WHERE fid = $TorrentID");
-if ($DB->record_count() > 0) {
+if ($DB->has_results()) {
// Save this because send_pm uses $DB to run its own query... Oops...
$Snatchers = $DB->to_array();
foreach ($Snatchers as $UserID) {
diff --git a/sections/torrents/takenewgroup.php b/sections/torrents/takenewgroup.php
index 6fb8ffd..bd61e49 100644
--- a/sections/torrents/takenewgroup.php
+++ b/sections/torrents/takenewgroup.php
@@ -52,7 +52,7 @@ if (empty($_POST['confirm'])) {
SELECT ArtistID, AliasID, Redirect, Name
FROM artists_alias
WHERE Name = '$ArtistName'");
- if ($DB->record_count() == 0) {
+ if (!$DB->has_results()) {
$Redirect = 0;
$DB->query("
INSERT INTO artists_group (Name)
@@ -92,7 +92,7 @@ if (empty($_POST['confirm'])) {
SELECT ID
FROM torrents
WHERE GroupID = '$OldGroupID'");
- if ($DB->record_count() == 0) {
+ if (!$DB->has_results()) {
Torrents::delete_group($OldGroupID);
} else {
Torrents::update_hash($OldGroupID);
diff --git a/sections/torrents/user.php b/sections/torrents/user.php
index c13c07b..ae14b02 100644
--- a/sections/torrents/user.php
+++ b/sections/torrents/user.php
@@ -1,13 +1,13 @@
-<?
+<?php
$Orders = array('Time', 'Name', 'Seeders', 'Leechers', 'Snatched', 'Size');
-$Ways = array('ASC'=>'Ascending', 'DESC'=>'Descending');
+$Ways = array('ASC' => 'Ascending', 'DESC' => 'Descending');
$UserVotes = Votes::get_user_votes($LoggedUser['ID']);
// The "order by x" links on columns headers
-function header_link($SortKey,$DefaultWay="DESC") {
- global $Order,$Way;
+function header_link($SortKey, $DefaultWay = 'DESC') {
+ global $Order, $Way;
if ($SortKey == $Order) {
if ($Way == 'DESC') {
$NewWay = 'ASC';
@@ -18,7 +18,7 @@ function header_link($SortKey,$DefaultWay="DESC") {
$NewWay = $DefaultWay;
}
- return "torrents.php?way=".$NewWay."&amp;order=".$SortKey."&amp;".Format::get_url(array('way','order'));
+ return "torrents.php?way=$NewWay&amp;order=$SortKey&amp;" . Format::get_url(array('way','order'));
}
$UserID = $_GET['userid'];
@@ -49,45 +49,45 @@ if (!empty($_GET['way']) && array_key_exists($_GET['way'], $Ways)) {
$SearchWhere = array();
if (!empty($_GET['format'])) {
if (in_array($_GET['format'], $Formats)) {
- $SearchWhere[]="t.Format='".db_string($_GET['format'])."'";
+ $SearchWhere[] = "t.Format = '".db_string($_GET['format'])."'";
} elseif ($_GET['format'] == 'perfectflac') {
$_GET['filter'] = 'perfectflac';
}
}
if (!empty($_GET['bitrate']) && in_array($_GET['bitrate'], $Bitrates)) {
- $SearchWhere[]="t.Encoding='".db_string($_GET['bitrate'])."'";
+ $SearchWhere[] = "t.Encoding = '".db_string($_GET['bitrate'])."'";
}
if (!empty($_GET['media']) && in_array($_GET['media'], $Media)) {
- $SearchWhere[]="t.Media='".db_string($_GET['media'])."'";
+ $SearchWhere[] = "t.Media = '".db_string($_GET['media'])."'";
}
if (!empty($_GET['releasetype']) && array_key_exists($_GET['releasetype'], $ReleaseTypes)) {
- $SearchWhere[]="tg.ReleaseType='".db_string($_GET['releasetype'])."'";
+ $SearchWhere[] = "tg.ReleaseType = '".db_string($_GET['releasetype'])."'";
}
-if (isset($_GET['scene']) && in_array($_GET['scene'], array('1','0'))) {
- $SearchWhere[]="t.Scene='".db_string($_GET['scene'])."'";
+if (isset($_GET['scene']) && in_array($_GET['scene'], array('1', '0'))) {
+ $SearchWhere[] = "t.Scene = '".db_string($_GET['scene'])."'";
}
-if (isset($_GET['vanityhouse']) && in_array($_GET['vanityhouse'], array('1','0'))) {
- $SearchWhere[]="tg.VanityHouse='".db_string($_GET['vanityhouse'])."'";
+if (isset($_GET['vanityhouse']) && in_array($_GET['vanityhouse'], array('1', '0'))) {
+ $SearchWhere[] = "tg.VanityHouse = '".db_string($_GET['vanityhouse'])."'";
}
-if (isset($_GET['cue']) && in_array($_GET['cue'], array('1','0'))) {
- $SearchWhere[]="t.HasCue='".db_string($_GET['cue'])."'";
+if (isset($_GET['cue']) && in_array($_GET['cue'], array('1', '0'))) {
+ $SearchWhere[] = "t.HasCue = '".db_string($_GET['cue'])."'";
}
-if (isset($_GET['log']) && in_array($_GET['log'], array('1','0', '100', '-1'))) {
+if (isset($_GET['log']) && in_array($_GET['log'], array('1', '0', '100', '-1'))) {
if ($_GET['log'] == '100') {
- $SearchWhere[]="t.HasLog = '1'";
- $SearchWhere[]="t.LogScore = '100'";
+ $SearchWhere[] = "t.HasLog = '1'";
+ $SearchWhere[] = "t.LogScore = '100'";
} elseif ($_GET['log'] == '-1') {
- $SearchWhere[]="t.HasLog = '1'";
- $SearchWhere[]="t.LogScore < '100'";
+ $SearchWhere[] = "t.HasLog = '1'";
+ $SearchWhere[] = "t.LogScore < '100'";
} else {
- $SearchWhere[]="t.HasLog='".db_string($_GET['log'])."'";
+ $SearchWhere[] = "t.HasLog = '".db_string($_GET['log'])."'";
}
}
@@ -97,9 +97,9 @@ if (!empty($_GET['categories'])) {
if (!is_number($Cat)) {
error(0);
}
- $Cats[]="tg.CategoryID='".db_string($Cat)."'";
+ $Cats[] = "tg.CategoryID = '".db_string($Cat)."'";
}
- $SearchWhere[]='('.implode(' OR ', $Cats).')';
+ $SearchWhere[] = '('.implode(' OR ', $Cats).')';
}
if (!isset($_GET['tags_type'])) {
@@ -107,37 +107,37 @@ if (!isset($_GET['tags_type'])) {
}
if (!empty($_GET['tags'])) {
- $Tags = explode(',',$_GET['tags']);
+ $Tags = explode(',', $_GET['tags']);
$TagList = array();
foreach ($Tags as $Tag) {
- $Tag = trim(str_replace('.','_',$Tag));
+ $Tag = trim(str_replace('.', '_', $Tag));
if (empty($Tag)) {
continue;
}
if ($Tag[0] == '!') {
- $Tag = ltrim(substr($Tag,1));
+ $Tag = ltrim(substr($Tag, 1));
if (empty($Tag)) {
continue;
}
- $TagList[]="CONCAT(' ',tg.TagList,' ') NOT LIKE '% ".db_string($Tag)." %'";
+ $TagList[] = "CONCAT(' ', tg.TagList, ' ') NOT LIKE '% ".db_string($Tag)." %'";
} else {
- $TagList[]="CONCAT(' ',tg.TagList,' ') LIKE '% ".db_string($Tag)." %'";
+ $TagList[] = "CONCAT(' ', tg.TagList, ' ') LIKE '% ".db_string($Tag)." %'";
}
}
if (!empty($TagList)) {
if (isset($_GET['tags_type']) && $_GET['tags_type'] != 1) {
$_GET['tags_type'] = '0';
- $SearchWhere[]='('.implode(' OR ', $TagList).')';
+ $SearchWhere[] = '('.implode(' OR ', $TagList).')';
} else {
$_GET['tags_type'] = '1';
- $SearchWhere[]='('.implode(' AND ', $TagList).')';
+ $SearchWhere[] = '('.implode(' AND ', $TagList).')';
}
}
}
$SearchWhere = implode(' AND ', $SearchWhere);
if (!empty($SearchWhere)) {
- $SearchWhere = ' AND '.$SearchWhere;
+ $SearchWhere = " AND $SearchWhere";
}
$User = Users::user_info($UserID);
@@ -152,7 +152,9 @@ switch ($_GET['type']) {
$Time = 'xs.tstamp';
$UserField = 'xs.uid';
$ExtraWhere = '';
- $From = "xbt_snatched AS xs JOIN torrents AS t ON t.ID=xs.fid";
+ $From = "
+ xbt_snatched AS xs
+ JOIN torrents AS t ON t.ID = xs.fid";
break;
case 'seeding':
if (!check_paranoia('seeding', $User['Paranoia'], $UserClass, $UserID)) {
@@ -160,14 +162,23 @@ switch ($_GET['type']) {
}
$Time = '(xfu.mtime - xfu.timespent)';
$UserField = 'xfu.uid';
- $ExtraWhere = 'AND xfu.active=1 AND xfu.Remaining=0';
- $From = "xbt_files_users AS xfu JOIN torrents AS t ON t.ID=xfu.fid";
+ $ExtraWhere = '
+ AND xfu.active = 1
+ AND xfu.Remaining = 0';
+ $From = "
+ xbt_files_users AS xfu
+ JOIN torrents AS t ON t.ID = xfu.fid";
break;
case 'contest':
$Time = 'unix_timestamp(t.Time)';
$UserField = 't.UserID';
- $ExtraWhere = " AND t.ID IN (SELECT TorrentID FROM library_contest WHERE UserID = ".$UserID.")";
- $From = "torrents AS t";
+ $ExtraWhere = "
+ AND t.ID IN (
+ SELECT TorrentID
+ FROM library_contest
+ WHERE UserID = $UserID
+ )";
+ $From = 'torrents AS t';
break;
case 'leeching':
if (!check_paranoia('leeching', $User['Paranoia'], $UserClass, $UserID)) {
@@ -175,8 +186,12 @@ switch ($_GET['type']) {
}
$Time = '(xfu.mtime - xfu.timespent)';
$UserField = 'xfu.uid';
- $ExtraWhere = 'AND xfu.active=1 AND xfu.Remaining>0';
- $From = "xbt_files_users AS xfu JOIN torrents AS t ON t.ID=xfu.fid";
+ $ExtraWhere = '
+ AND xfu.active = 1
+ AND xfu.Remaining > 0';
+ $From = "
+ xbt_files_users AS xfu
+ JOIN torrents AS t ON t.ID = xfu.fid";
break;
case 'uploaded':
if ((empty($_GET['filter']) || $_GET['filter'] != 'perfectflac') && !check_paranoia('uploads', $User['Paranoia'], $UserClass, $UserID)) {
@@ -194,7 +209,9 @@ switch ($_GET['type']) {
$Time = 'unix_timestamp(ud.Time)';
$UserField = 'ud.UserID';
$ExtraWhere = '';
- $From = "users_downloads AS ud JOIN torrents AS t ON t.ID=ud.TorrentID";
+ $From = "
+ users_downloads AS ud
+ JOIN torrents AS t ON t.ID = ud.TorrentID";
break;
default:
error(404);
@@ -207,12 +224,14 @@ if (!empty($_GET['filter'])) {
}
$ExtraWhere .= " AND t.Format = 'FLAC'";
if (empty($_GET['media'])) {
- $ExtraWhere .= " AND (
- t.LogScore = 100 OR
- t.Media IN ('Vinyl','WEB','DVD','Soundboard','Cassette','SACD','Blu-ray','DAT')
- )";
+ $ExtraWhere .= "
+ AND (
+ t.LogScore = 100 OR
+ t.Media IN ('Vinyl', 'WEB', 'DVD', 'Soundboard', 'Cassette', 'SACD', 'Blu-ray', 'DAT')
+ )";
} elseif (strtoupper($_GET['media']) == 'CD' && empty($_GET['log'])) {
- $ExtraWhere .= " AND t.LogScore = 100";
+ $ExtraWhere .= "
+ AND t.LogScore = 100";
}
} elseif ($_GET['filter'] == 'uniquegroup') {
if (!check_paranoia('uniquegroups', $User['Paranoia'], $UserClass, $UserID)) {
@@ -235,8 +254,8 @@ if ((empty($_GET['search']) || trim($_GET['search']) == '') && $Order != 'Name')
$Time AS Time,
tg.CategoryID
FROM $From
- JOIN torrents_group AS tg ON tg.ID=t.GroupID
- WHERE $UserField='$UserID'
+ JOIN torrents_group AS tg ON tg.ID = t.GroupID
+ WHERE $UserField = '$UserID'
$ExtraWhere
$SearchWhere
GROUP BY $GroupBy
@@ -268,10 +287,10 @@ if ((empty($_GET['search']) || trim($_GET['search']) == '') && $Order != 'Name')
CONCAT_WS(' ', GROUP_CONCAT(aa.Name SEPARATOR ' '), ' ', tg.Name, ' ', tg.Year, ' ') AS Name,
t.Size
FROM $From
- JOIN torrents_group AS tg ON tg.ID=t.GroupID
- LEFT JOIN torrents_artists AS ta ON ta.GroupID=tg.ID
- LEFT JOIN artists_alias AS aa ON aa.AliasID=ta.AliasID
- WHERE $UserField='$UserID'
+ JOIN torrents_group AS tg ON tg.ID = t.GroupID
+ LEFT JOIN torrents_artists AS ta ON ta.GroupID = tg.ID
+ LEFT JOIN artists_alias AS aa ON aa.AliasID = ta.AliasID
+ WHERE $UserField = '$UserID'
$ExtraWhere
$SearchWhere
GROUP BY TorrentID, Time");
@@ -301,7 +320,7 @@ $DB->query($SQL);
$GroupIDs = $DB->collect('GroupID');
$TorrentsInfo = $DB->to_array('TorrentID', MYSQLI_ASSOC);
-$DB->query("SELECT FOUND_ROWS()");
+$DB->query('SELECT FOUND_ROWS()');
list($TorrentCount) = $DB->next_record();
$Results = Torrents::get_groups($GroupIDs);
@@ -309,7 +328,7 @@ $Results = Torrents::get_groups($GroupIDs);
$Action = display_str($_GET['type']);
$User = Users::user_info($UserID);
-View::show_header($User['Username'].'\'s '.$Action.' torrents','voting');
+View::show_header($User['Username']."'s $Action torrents",'voting');
$Pages = Format::get_pages($Page, $TorrentCount, TORRENTS_PER_PAGE);
@@ -317,7 +336,7 @@ $Pages = Format::get_pages($Page, $TorrentCount, TORRENTS_PER_PAGE);
?>
<div class="thin">
<div class="header">
- <h2><a href="user.php?id=<?=$UserID?>"><?=$User['Username']?></a><?='\'s '.$Action.' torrents'?></h2>
+ <h2><a href="user.php?id=<?=$UserID?>"><?=$User['Username']?></a><?="'s $Action torrents"?></h2>
</div>
<div>
<form class="search_form" name="torrents" action="" method="get">
diff --git a/sections/torrents/vote_tag.php b/sections/torrents/vote_tag.php
index a1a8059..c217442 100644
--- a/sections/torrents/vote_tag.php
+++ b/sections/torrents/vote_tag.php
@@ -18,7 +18,7 @@ $DB->query("
AND GroupID = '$GroupID'
AND UserID = '$UserID'
AND Way = '$Way'");
-if ($DB->record_count() == 0) {
+if (!$DB->has_results()) {
if ($Way == 'down') {
$Change = 'NegativeVotes = NegativeVotes + 1';
} else {
diff --git a/sections/upload/generate_extra_torrents.php b/sections/upload/generate_extra_torrents.php
index c63e0ec..9ec2597 100644
--- a/sections/upload/generate_extra_torrents.php
+++ b/sections/upload/generate_extra_torrents.php
@@ -46,13 +46,13 @@ foreach ($ExtraTorrents as $ExtraTorrent) {
SELECT ID
FROM torrents
WHERE info_hash = '" . db_string($ThisInsert['InfoHash']) . "'");
- if ($DB->record_count() > 0) {
+ if ($DB->has_results()) {
list($ExtraID) = $DB->next_record();
$DB->query("
SELECT TorrentID
FROM torrents_files
WHERE TorrentID = $ExtraID");
- if ($DB->record_count() > 0) {
+ if ($DB->has_results()) {
$Err = "<a href=\"torrents.php?torrentid=$ExtraID\">The exact same torrent file already exists on the site!</a>";
} else {
//One of the lost torrents.
diff --git a/sections/upload/upload.php b/sections/upload/upload.php
index e2c1e27..f4078d9 100644
--- a/sections/upload/upload.php
+++ b/sections/upload/upload.php
@@ -29,7 +29,7 @@ if (empty($Properties) && !empty($_GET['groupid']) && is_number($_GET['groupid']
LEFT JOIN torrents AS t ON t.GroupID = tg.ID
WHERE tg.ID = '.$_GET['groupid'].'
GROUP BY tg.ID');
- if ($DB->record_count()) {
+ if ($DB->has_results()) {
list($Properties) = $DB->to_array(false, MYSQLI_BOTH);
$UploadForm = $Categories[$Properties['CategoryID'] - 1];
$Properties['CategoryName'] = $Categories[$Properties['CategoryID'] - 1];
diff --git a/sections/upload/upload_handle.php b/sections/upload/upload_handle.php
index aa30799..26a3c6d 100644
--- a/sections/upload/upload_handle.php
+++ b/sections/upload/upload_handle.php
@@ -363,13 +363,13 @@ $DB->query("
SELECT ID
FROM torrents
WHERE info_hash = '".db_string($InfoHash)."'");
-if ($DB->record_count() > 0) {
+if ($DB->has_results()) {
list($ID) = $DB->next_record();
$DB->query("
SELECT TorrentID
FROM torrents_files
WHERE TorrentID = $ID");
- if ($DB->record_count() > 0) {
+ if ($DB->has_results()) {
$Err = '<a href="torrents.php?torrentid='.$ID.'">The exact same torrent file already exists on the site!</a>';
} else {
// A lost torrent
@@ -456,7 +456,7 @@ if ($Type == 'Music') {
tg.TagList
FROM torrents_group AS tg
WHERE tg.id = ".$Properties['GroupID']);
- if ($DB->record_count() > 0) {
+ if ($DB->has_results()) {
// Don't escape tg.Name. It's written directly to the log table
list($GroupID, $WikiImage, $WikiBody, $RevisionID, $Properties['Title'], $Properties['Year'], $Properties['ReleaseType'], $Properties['TagList']) = $DB->next_record(MYSQLI_NUM, array(4));
$Properties['TagList'] = str_replace(array(' ', '.', '_'), array(', ', '.', '.'), $Properties['TagList']);
@@ -490,7 +490,7 @@ if ($Type == 'Music') {
AND tg.ReleaseType = ".$T['ReleaseType']."
AND tg.Year = ".$T['Year']);
- if ($DB->record_count() > 0) {
+ if ($DB->has_results()) {
list($GroupID, $WikiImage, $WikiBody, $RevisionID) = $DB->next_record();
if (!$Properties['Image'] && $WikiImage) {
$Properties['Image'] = $WikiImage;
@@ -516,7 +516,7 @@ if ($Type == 'Music') {
aa.Redirect
FROM artists_alias AS aa
WHERE aa.Name = '".db_string($Artist['name'])."'");
- if ($DB->record_count() > 0) {
+ if ($DB->has_results()) {
while (list($ArtistID, $AliasID, $AliasName, $Redirect) = $DB->next_record(MYSQLI_NUM, false)) {
if (!strcasecmp($Artist['name'], $AliasName)) {
if ($Redirect) {
@@ -701,7 +701,8 @@ if ($Type == 'Music') {
if (!empty($LogScores) && $HasLog) {
$LogQuery = '
- INSERT INTO torrents_logs_new (TorrentID, Log, Details, NotEnglish, Score, Revision, Adjusted, AdjustedBy, AdjustmentReason)
+ INSERT INTO torrents_logs_new
+ (TorrentID, Log, Details, NotEnglish, Score, Revision, Adjusted, AdjustedBy, AdjustmentReason)
VALUES (';
foreach ($LogScores as $LogKey => $LogScore) {
$LogScores[$LogKey] = "$TorrentID, $LogScore, 1, 0, 0, NULL";
@@ -725,10 +726,14 @@ if (trim($Properties['Image']) != '') {
}
// Only reached if no matching GroupIDs in the cache already.
- if (count($RecentUploads) == 5) {
+ if (count($RecentUploads) === 5) {
array_pop($RecentUploads);
}
- array_unshift($RecentUploads, array('ID' => $GroupID, 'Name' => trim($Properties['Title']), 'Artist' => Artists::display_artists($ArtistForm, false, true), 'WikiImage' => trim($Properties['Image'])));
+ array_unshift($RecentUploads, array(
+ 'ID' => $GroupID,
+ 'Name' => trim($Properties['Title']),
+ 'Artist' => Artists::display_artists($ArtistForm, false, true),
+ 'WikiImage' => trim($Properties['Image'])));
$Cache->cache_value("recent_uploads_$UserID", $RecentUploads, 0);
} while (0);
}
@@ -976,7 +981,7 @@ $SQL .= " AND UserID != '".$LoggedUser['ID']."' ";
$DB->query($SQL);
$Debug->set_flag('upload: notification query finished');
-if ($DB->record_count() > 0) {
+if ($DB->has_results()) {
$UserArray = $DB->to_array('UserID');
$FilterArray = $DB->to_array('ID');
diff --git a/sections/user/deleteinvite.php b/sections/user/deleteinvite.php
index fe72370..d96bb43 100644
--- a/sections/user/deleteinvite.php
+++ b/sections/user/deleteinvite.php
@@ -7,7 +7,7 @@ $DB->query("
FROM invites
WHERE InviteKey='$InviteKey'");
list($UserID) = $DB->next_record();
-if ($DB->record_count() == 0 || $UserID != $LoggedUser['ID']) {
+if (!$DB->has_results() || $UserID != $LoggedUser['ID']) {
error(404);
}
diff --git a/sections/user/lastfm.php b/sections/user/lastfm.php
index 7e0feb8..7259797 100644
--- a/sections/user/lastfm.php
+++ b/sections/user/lastfm.php
@@ -4,7 +4,7 @@ $DB->query("
SELECT username
FROM lastfm_users
WHERE ID = '$UserID'");
-if ($DB->record_count()) {
+if ($DB->has_results()) {
list($LastFMUsername) = $DB->next_record();
$LastFMInfo = LastFM::get_user_info($LastFMUsername);
//Hand everything else over to JS (gets data via the username in an id-d div) to allow faster page loading.
diff --git a/sections/user/linkedfunctions.php b/sections/user/linkedfunctions.php
index c5829ff..4a06f5c 100644
--- a/sections/user/linkedfunctions.php
+++ b/sections/user/linkedfunctions.php
@@ -22,7 +22,7 @@ function link_users($UserID, $TargetID) {
SELECT 1
FROM users_main
WHERE ID IN ($UserID, $TargetID)");
- if ($DB->record_count() != 2) {
+ if ($DB->record_count() !== 2) {
error(403);
}
diff --git a/sections/user/takeedit.php b/sections/user/takeedit.php
index 195a093..8668e24 100644
--- a/sections/user/takeedit.php
+++ b/sections/user/takeedit.php
@@ -147,9 +147,9 @@ if ($CurEmail != $_POST['email']) {
$ChangerIP = db_string($LoggedUser['IP']);
$DB->query("
UPDATE users_history_emails
- SET Time='".sqltime()."'
- WHERE UserID='$UserID'
- AND Time='0000-00-00 00:00:00'");
+ SET Time = '".sqltime()."'
+ WHERE UserID = '$UserID'
+ AND Time = '0000-00-00 00:00:00'");
$DB->query("
INSERT INTO users_history_emails
(UserID, Email, Time, IP)
@@ -158,7 +158,7 @@ if ($CurEmail != $_POST['email']) {
} else {
error($Err);
- header('Location: user.php?action=edit&userid='.$UserID);
+ header("Location: user.php?action=edit&userid=$UserID");
die();
}
@@ -170,7 +170,7 @@ if (!$Err && ($_POST['cur_pass'] || $_POST['new_pass_1'] || $_POST['new_pass_2']
$DB->query("
SELECT PassHash, Secret
FROM users_main
- WHERE ID='".db_string($UserID)."'");
+ WHERE ID = '".db_string($UserID)."'");
list($PassHash, $Secret) = $DB->next_record();
if (Users::check_password($_POST['cur_pass'], $PassHash, $Secret)) {
@@ -188,7 +188,7 @@ if ($LoggedUser['DisableAvatar'] && $_POST['avatar'] != $U['Avatar']) {
if ($Err) {
error($Err);
- header('Location: user.php?action=edit&userid='.$UserID);
+ header("Location: user.php?action=edit&userid=$UserID");
die();
}
@@ -256,7 +256,7 @@ $DB->query("
SELECT username
FROM lastfm_users
WHERE ID = '$UserID'");
-if ($DB->record_count() > 0) {
+if ($DB->has_results()) {
list($OldLastFMUsername) = $DB->next_record();
if ($OldLastFMUsername != $LastFMUsername) {
if (empty($LastFMUsername)) {
diff --git a/sections/user/takeinvite.php b/sections/user/takeinvite.php
index f8c8d70..58df7e0 100644
--- a/sections/user/takeinvite.php
+++ b/sections/user/takeinvite.php
@@ -62,7 +62,7 @@ foreach ($Emails as $CurEmail) {
FROM invites
WHERE InviterID = ".$LoggedUser['ID']."
AND Email LIKE '$CurEmail'");
- if ($DB->record_count() > 0) {
+ if ($DB->has_results()) {
error('You already have a pending invite to that address!');
header('Location: user.php?action=invite');
die();
diff --git a/sections/user/takemoderate.php b/sections/user/takemoderate.php
index 62460b4..0ecb51d 100644
--- a/sections/user/takemoderate.php
+++ b/sections/user/takemoderate.php
@@ -135,7 +135,7 @@ $DB->query("
WHERE m.ID = $UserID
GROUP BY m.ID");
-if (!$DB->record_count()) { // If user doesn't exist
+if (!$DB->has_results()) { // If user doesn't exist
header("Location: log.php?search=User+$UserID");
}
@@ -322,7 +322,7 @@ if ($Classes[$Class]['Level'] != $Cur['Class']
FROM permissions
WHERE ID = $Class
OR ID = ".$ClassLevels[$Cur['Class']]['ID']);
- if ($DB->record_count() == 2) {
+ if ($DB->record_count() === 2) {
if ($Classes[$Class]['Level'] < $Cur['Class']) {
$SupportFor = '';
}
@@ -693,7 +693,7 @@ if ($MergeStatsFrom && check_perms('users_edit_ratio')) {
SELECT ID, Uploaded, Downloaded
FROM users_main
WHERE Username LIKE '$MergeStatsFrom'");
- if ($DB->record_count() > 0) {
+ if ($DB->has_results()) {
list($MergeID, $MergeUploaded, $MergeDownloaded) = $DB->next_record();
$DB->query("
UPDATE users_main AS um
diff --git a/sections/user/user.php b/sections/user/user.php
index fbd567c..9be798f 100644
--- a/sections/user/user.php
+++ b/sections/user/user.php
@@ -80,7 +80,7 @@ if (check_perms('users_mod')) { // Person viewing is a staff member
WHERE m.ID = '$UserID'
GROUP BY AuthorID");
- if ($DB->record_count() == 0) { // If user doesn't exist
+ if (!$DB->has_results()) { // If user doesn't exist
header("Location: log.php?search=User+".$UserID);
}
@@ -121,7 +121,7 @@ if (check_perms('users_mod')) { // Person viewing is a staff member
WHERE m.ID = $UserID
GROUP BY AuthorID");
- if ($DB->record_count() == 0) { // If user doesn't exist
+ if (!$DB->has_results()) { // If user doesn't exist
header("Location: log.php?search=User+".$UserID);
}
@@ -188,7 +188,7 @@ View::show_header($Username, 'user,bbcode,requests,lastfm');
FROM friends
WHERE UserID = '$LoggedUser[ID]'
AND FriendID = '$UserID'");
- if ($DB->record_count() == 0) { ?>
+ if (!$DB->has_results()) { ?>
<a href="friends.php?action=add&amp;friendid=<?=$UserID?>&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets">Add to friends</a>
<? } ?>
<a href="reports.php?action=report&amp;type=user&amp;id=<?=$UserID?>" class="brackets">Report user</a>
@@ -495,7 +495,7 @@ if (check_perms('users_view_invites')) {
<li>Invited by: <?=$Invited?></li>
<li>Invites: <?
$DB->query("
- SELECT count(InviterID)
+ SELECT COUNT(InviterID)
FROM invites
WHERE InviterID = '$UserID'");
list($Pending) = $DB->next_record();
@@ -747,7 +747,7 @@ if (empty($LoggedUser['DisableRequests']) && check_paranoia_here('requestsvoted_
GROUP BY r.ID
ORDER BY Votes DESC");
- if ($DB->record_count() > 0) {
+ if ($DB->has_results()) {
$Requests = $DB->to_array();
?>
<div class="box" id="requests_box">
@@ -850,7 +850,7 @@ if (check_perms('users_mod', $Class) || $IsFLS) {
WHERE UserID = $UserID
AND (Level <= $UserLevel OR AssignedToUser = '".$LoggedUser['ID']."')
ORDER BY Date DESC");
- if ($DB->record_count()) {
+ if ($DB->has_results()) {
$StaffPMs = $DB->to_array();
?>
<div class="box" id="staffpms_box">
@@ -906,7 +906,7 @@ if ($LoggedUser['Class'] == 650 && check_perms('users_warn', $Class)) {
FROM users_warnings_forums
WHERE UserID = '$UserID'");
list($ForumWarnings) = $DB->next_record();
- if ($DB->record_count() > 0) {
+ if ($DB->has_results()) {
?>
<div class="box">
<div class="head">Forum warnings</div>
diff --git a/sections/userhistory/ip_history.php b/sections/userhistory/ip_history.php
index e773b21..f1a9547 100644
--- a/sections/userhistory/ip_history.php
+++ b/sections/userhistory/ip_history.php
@@ -211,7 +211,7 @@ foreach ($Results as $Index => $Result) {
LIMIT 1";
$DB->query($sql);
- if ($DB->record_count() > 0) {
+ if ($DB->has_results()) {
$IPs[$IP] = true;
?>
<strong>[Banned]</strong>
diff --git a/sections/wiki/compare.php b/sections/wiki/compare.php
index 18eabfb..ab3a1dc 100644
--- a/sections/wiki/compare.php
+++ b/sections/wiki/compare.php
@@ -1,8 +1,8 @@
<?
//Diff function by Leto of StC.
function diff($OldText, $NewText) {
- $LineArrayOld = explode("\n",$OldText);
- $LineArrayNew = explode("\n",$NewText);
+ $LineArrayOld = explode("\n", $OldText);
+ $LineArrayNew = explode("\n", $NewText);
$LineOffset = 0;
$Result = array();
@@ -13,7 +13,7 @@ function diff($OldText, $NewText) {
}
$Found = -1;
- while ($Key<count($LineArrayNew)) {
+ while ($Key < count($LineArrayNew)) {
if ($OldString != $LineArrayNew[$Key]) {
$Key++;
} elseif ($OldString == $LineArrayNew[$Key]) {
@@ -39,7 +39,7 @@ function diff($OldText, $NewText) {
}
$Result[] = '<span class="line_moved">&rarr; '.$OldString.'</span><br />';
}
- $LineOffset = $Found-$OldLine;
+ $LineOffset = $Found - $OldLine;
}
}
if (count($LineArrayNew) > count($LineArrayOld) + $LineOffset) {
@@ -61,9 +61,9 @@ function get_body($ID, $Rev) {
$DB->query("
SELECT Body
FROM wiki_revisions
- WHERE ID='$ID'
- AND Revision='$Rev'");
- if (!$DB->record_count()) {
+ WHERE ID = '$ID'
+ AND Revision = '$Rev'");
+ if (!$DB->has_results()) {
error(404);
}
list($Str) = $DB->next_record();
@@ -71,15 +71,16 @@ function get_body($ID, $Rev) {
return $Str;
}
-if (
- !isset($_GET['old']) ||
- !isset($_GET['new']) ||
- !isset($_GET['id']) ||
- !is_number($_GET['old']) ||
- !is_number($_GET['new']) ||
- !is_number($_GET['id']) ||
- $_GET['old'] > $_GET['new']
-) { error(0); }
+if (!isset($_GET['old'])
+ || !isset($_GET['new'])
+ || !isset($_GET['id'])
+ || !is_number($_GET['old'])
+ || !is_number($_GET['new'])
+ || !is_number($_GET['id'])
+ || $_GET['old'] > $_GET['new']
+) {
+ error(0);
+}
$ArticleID = $_GET['id'];
diff --git a/sections/wiki/delete.php b/sections/wiki/delete.php
index ac4cc92..19fb3d3 100644
--- a/sections/wiki/delete.php
+++ b/sections/wiki/delete.php
@@ -9,7 +9,7 @@ $DB->query("
FROM wiki_articles
WHERE ID = $ID");
-if ($DB->record_count() < 1) {
+if (!$DB->has_results()) {
error(404);
}
diff --git a/sections/wiki/takecreate.php b/sections/wiki/takecreate.php
index 5154986..1a62ea2 100644
--- a/sections/wiki/takecreate.php
+++ b/sections/wiki/takecreate.php
@@ -16,7 +16,7 @@ if (!$Err) {
SELECT ID
FROM wiki_articles
WHERE Title='$P[title]'");
- if ($DB->record_count() > 0) {
+ if ($DB->has_results()) {
list($ID) = $DB->next_record();
$Err = 'An article with that name already exists <a href="wiki.php?action=article&amp;id='.$ID.'">here</a>.';
}
diff --git a/static/functions/requests.js b/static/functions/requests.js
index a9b0ce6..57a48cd 100644
--- a/static/functions/requests.js
+++ b/static/functions/requests.js
@@ -60,12 +60,14 @@ function Calculate() {
if (amt > $('#current_uploaded').raw().value) {
$('#new_uploaded').raw().innerHTML = "You can't afford that request!";
$('#new_bounty').raw().innerHTML = "0.00 MB";
+ $('#bounty_after_tax').raw().innerHTML = "0.00 MB";
$('#button').raw().disabled = true;
} else if (isNaN($('#amount_box').raw().value)
|| (window.location.search.indexOf('action=new') != -1 && $('#amount_box').raw().value*mul < 100*1024*1024)
|| (window.location.search.indexOf('action=view') != -1 && $('#amount_box').raw().value*mul < 20*1024*1024)) {
$('#new_uploaded').raw().innerHTML = get_size(($('#current_uploaded').raw().value));
$('#new_bounty').raw().innerHTML = "0.00 MB";
+ $('#bounty_after_tax').raw().innerHTML = "0.00 MB";
$('#button').raw().disabled = true;
} else {
$('#button').raw().disabled = false;
@@ -73,6 +75,7 @@ function Calculate() {
$('#new_uploaded').raw().innerHTML = get_size(($('#current_uploaded').raw().value) - amt);
$('#new_ratio').raw().innerHTML = ratio($('#current_uploaded').raw().value - amt, $('#current_downloaded').raw().value);
$('#new_bounty').raw().innerHTML = get_size(mul * $('#amount_box').raw().value);
+ $('#bounty_after_tax').raw().innerHTML = get_size(mul * 0.9 * $('#amount_box').raw().value);
}
}