From c2746069c183484bf0f3eff54d8a27db1b738509 Mon Sep 17 00:00:00 2001 From: Git Date: Fri, 22 Feb 2013 08:00:24 +0000 Subject: [PATCH] Empty commit --- COPYING.txt | 6 +- INSTALL.txt | 12 +- cheaters.php | 2 +- classes/class_alias.php | 4 +- classes/class_cache.php | 2 +- classes/class_charts.php | 32 +-- classes/class_cookie.php | 10 +- classes/class_file_checker.php | 2 +- classes/class_format.php | 6 +- classes/class_image.php | 16 +- classes/class_image_tools.php | 8 +- classes/class_invite_tree.php | 42 ++-- .../class_mass_user_torrents_table_view.php | 2 +- classes/class_misc.php | 2 +- classes/class_mysql.php | 22 +- classes/class_paranoia.php | 14 +- classes/class_proxies.php | 6 +- classes/class_search.php | 58 ++--- classes/class_time.php | 8 +- classes/class_torrent.php | 92 ++++---- classes/class_torrent_32bit.php | 74 +++---- classes/class_torrents.php | 4 +- classes/class_torrentsdl.php | 7 +- classes/class_user_rank.php | 30 +-- classes/class_useragent.php | 10 +- classes/class_users.php | 6 +- classes/class_view.php | 2 +- classes/class_wiki.php | 22 +- classes/class_zip.php | 38 ++-- classes/permissions_form.php | 10 +- classes/sphinxapi.php | 40 ++-- delays.php | 2 +- design/privatefooter.php | 2 +- design/privateheader.php | 8 +- design/publicheader.php | 4 +- forums.php | 2 +- irc_raw.php | 4 +- opensearch.php | 14 +- sections/ajax/announcements.php | 4 +- sections/ajax/better/index.php | 4 +- sections/ajax/better/single.php | 4 +- sections/ajax/bookmarks/artists.php | 4 +- sections/ajax/bookmarks/index.php | 4 +- sections/ajax/bookmarks/torrents.php | 6 +- sections/ajax/forum/forum.php | 4 +- sections/ajax/forum/index.php | 4 +- sections/ajax/forum/main.php | 4 +- sections/ajax/forum/thread.php | 22 +- sections/ajax/index.php | 4 +- sections/ajax/notifications.php | 2 +- sections/ajax/request.php | 14 +- sections/ajax/requests.php | 34 +-- sections/ajax/takevote.php | 30 +-- sections/ajax/torrentgroup.php | 2 +- sections/ajax/upload.php | 4 +- sections/ajax/userhistory/post_history.php | 12 +- sections/ajax/usersearch.php | 4 +- sections/api/access_state.php | 2 +- sections/api/index.php | 12 +- sections/artist/add_similar.php | 12 +- sections/artist/autocomplete.php | 16 +- sections/artist/change_artistid.php | 18 +- sections/artist/delete.php | 14 +- sections/artist/delete_alias.php | 4 +- sections/artist/download.php | 2 - sections/artist/edit.php | 18 +- sections/artist/history.php | 4 +- sections/artist/index.php | 6 +- sections/artist/rename.php | 2 +- sections/artist/take_warn.php | 2 +- sections/artist/takeedit.php | 12 +- sections/better/files.php | 6 +- sections/better/folders.php | 4 +- sections/better/index.php | 4 +- sections/better/tags.php | 2 +- sections/blog/index.php | 32 +-- sections/bookmarks/functions.php | 2 +- sections/captcha/index.php | 14 +- sections/collages/add_comment.php | 4 +- sections/collages/add_torrent.php | 16 +- sections/collages/all_comments.php | 6 +- sections/collages/browse.php | 22 +- sections/collages/delete.php | 4 +- sections/collages/get_post.php | 10 +- sections/collages/index.php | 6 +- sections/collages/manage_handle.php | 2 +- sections/collages/new.php | 10 +- sections/collages/new_handle.php | 4 +- sections/collages/take_delete.php | 4 +- sections/collages/takeedit_comment.php | 2 +- sections/comments/artistcomments.php | 4 +- sections/comments/index.php | 8 +- sections/comments/post.php | 8 +- sections/donate/ipn.php | 10 +- sections/feeds/index.php | 74 +++---- sections/forums/ajax_get_edit.php | 4 +- sections/forums/change_vote.php | 2 +- sections/forums/delete.php | 2 +- sections/forums/delete_poll_option.php | 2 +- sections/forums/forum.php | 16 +- sections/forums/get_post.php | 10 +- sections/forums/index.php | 2 +- sections/forums/mod_thread.php | 98 ++++----- sections/forums/poll_mod.php | 6 +- sections/forums/poll_vote.php | 16 +- sections/forums/quote_notify.php | 2 +- sections/forums/search.php | 36 +-- sections/forums/subscribe.php | 2 +- sections/forums/take_new_thread.php | 24 +- sections/forums/take_reply.php | 34 +-- sections/forums/take_warn.php | 10 +- sections/forums/takeedit.php | 16 +- sections/friends/friends.php | 18 +- sections/inbox/compose.php | 2 +- sections/inbox/conversation.php | 2 +- sections/inbox/get_post.php | 10 +- sections/inbox/index.php | 2 +- sections/index/feat_album.php | 2 +- sections/login/index.php | 88 ++++---- sections/login/login.php | 2 +- sections/peerupdate/index.php | 4 +- sections/register/index.php | 90 ++++---- sections/reports/ajax_claim_report.php | 2 +- sections/reports/ajax_resolve_report.php | 2 +- sections/reports/report.php | 30 +-- sections/reports/reports.php | 22 +- sections/reports/takereport.php | 2 +- sections/reports/takeresolve.php | 2 +- sections/reportsv2/ajax_change_resolve.php | 2 +- sections/reportsv2/ajax_grab_report.php | 4 +- sections/reportsv2/ajax_new_report.php | 68 +++--- sections/reportsv2/ajax_report.php | 4 +- sections/reportsv2/array.php | 2 +- sections/reportsv2/index.php | 2 +- sections/reportsv2/report.php | 10 +- sections/reportsv2/static.php | 90 ++++---- sections/reportsv2/takereport.php | 6 +- sections/reportsv2/takeresolve.php | 50 ++--- sections/reportsv2/views.php | 10 +- sections/requests/functions.php | 30 +-- sections/requests/index.php | 54 ++--- sections/requests/interim.php | 8 +- sections/rules/clients.php | 6 +- sections/rules/collages.php | 4 +- sections/rules/jump.php | 12 +- sections/schedule/index.php | 206 +++++++++--------- sections/staff/index.php | 4 +- sections/staffblog/index.php | 18 +- sections/staffpm/ajax_delete_response.php | 4 +- sections/staffpm/ajax_edit_response.php | 2 +- sections/staffpm/ajax_get_response.php | 2 +- sections/staffpm/assign.php | 16 +- sections/staffpm/common_responses.php | 18 +- sections/staffpm/get_post.php | 10 +- sections/staffpm/index.php | 2 +- sections/staffpm/makedonor.php | 16 +- sections/staffpm/multiresolve.php | 8 +- sections/staffpm/resolve.php | 2 +- sections/staffpm/takepost.php | 22 +- sections/staffpm/unresolve.php | 6 +- sections/staffpm/user_inbox.php | 22 +- sections/staffpm/viewconv.php | 4 +- sections/stats/users.php | 6 +- sections/tools/data/database_specifics.php | 2 +- sections/tools/data/donation_log.php | 14 +- sections/tools/data/economic_stats.php | 2 +- sections/tools/data/invite_pool.php | 4 +- sections/tools/data/opcode_stats.php | 6 +- sections/tools/data/registration_log.php | 8 +- sections/tools/data/service_stats.php | 4 +- sections/tools/data/suggestions.php | 16 +- sections/tools/data/torrent_stats.php | 2 +- sections/tools/data/upscale_pool.php | 4 +- sections/tools/data/user_flow.php | 2 +- sections/tools/index.php | 28 +-- sections/tools/managers/bans.php | 4 +- sections/tools/managers/dnu_alter.php | 2 +- sections/tools/managers/eb.php | 4 +- sections/tools/managers/eb_alter.php | 2 +- sections/tools/managers/eb_search.php | 2 +- sections/tools/managers/forum_list.php | 18 +- sections/tools/managers/login_watch.php | 4 +- sections/tools/managers/news.php | 2 +- sections/tools/managers/ocelot.php | 4 +- sections/tools/managers/recommend_add.php | 2 +- sections/tools/managers/recommend_list.php | 8 +- sections/tools/managers/tokens.php | 10 +- sections/tools/managers/whitelist_alter.php | 8 +- sections/tools/managers/whitelist_list.php | 4 +- sections/tools/misc/create_user.php | 40 ++-- sections/tools/misc/dupe_ip.php | 4 +- sections/tools/misc/manipulate_tree.php | 28 +-- sections/tools/misc/update_geoip.php | 2 +- sections/tools/tools.php | 2 +- sections/torrents/add_alias.php | 30 +-- sections/torrents/add_tag.php | 14 +- sections/torrents/browse.php | 68 +++--- sections/torrents/delete.php | 36 +-- sections/torrents/delete_alias.php | 20 +- sections/torrents/delete_tag.php | 2 +- sections/torrents/download.php | 14 +- sections/torrents/downloadlist.php | 12 +- sections/torrents/edit.php | 34 +-- sections/torrents/editgroup.php | 30 +-- sections/torrents/editgroupid.php | 16 +- sections/torrents/functions.php | 2 +- sections/torrents/history.php | 4 +- sections/torrents/index.php | 110 +++++----- sections/torrents/merge.php | 22 +- sections/torrents/nonwikiedit.php | 4 +- sections/torrents/redownload.php | 2 +- sections/torrents/reseed.php | 12 +- sections/torrents/snatchlist.php | 10 +- sections/torrents/takedelete.php | 4 +- sections/torrents/takegroupedit.php | 10 +- sections/torrents/takemasspm.php | 4 +- sections/torrents/takenewgroup.php | 8 +- sections/torrents/vote_ranks.php | 6 +- sections/torrents/voter_picks.php | 4 +- sections/upload/insert_extra_torrents.php | 6 +- sections/upload/upload.php | 32 +-- sections/upload/upload_handle.php | 22 +- sections/user/advancedsearch.php | 42 ++-- sections/user/connchecker.php | 4 +- sections/user/index.php | 6 +- sections/user/invite.php | 14 +- sections/user/invitetree.php | 4 +- sections/user/manage_linked.php | 14 +- sections/user/notify_handle.php | 2 +- sections/user/permissions.php | 8 +- sections/user/search.php | 4 +- sections/user/subscribe.php | 2 +- sections/user/takeedit.php | 22 +- sections/user/takeinvite.php | 10 +- sections/user/takemoderate.php | 38 ++-- sections/userhistory/email_history.php | 8 +- sections/userhistory/index.php | 8 +- sections/userhistory/ip_history.php | 20 +- sections/userhistory/ip_tracker_history.php | 2 +- sections/userhistory/passkey_history.php | 8 +- sections/userhistory/password_history.php | 6 +- sections/userhistory/post_history.php | 20 +- sections/userhistory/subscriptions.php | 4 +- sections/userhistory/token_history.php | 4 +- sections/wiki/aliases.php | 2 +- sections/wiki/compare.php | 28 +-- sections/wiki/edit.php | 2 +- sections/wiki/revisions.php | 8 +- sections/wiki/search.php | 8 +- sections/wiki/takecreate.php | 2 +- sections/wiki/wiki_browse.php | 6 +- staffblog.php | 2 +- static/functions/artist_cloud.js | 8 +- static/functions/artists.js | 86 ++++---- static/functions/browse.js | 2 +- static/functions/class_ajax.js | 14 +- static/functions/class_cookie.js | 4 +- static/functions/class_countdown.js | 8 +- static/functions/class_storage.js | 4 +- static/functions/class_textareapreview.js | 4 +- static/functions/collage.js | 14 +- static/functions/comments.js | 10 +- static/functions/delays.js | 4 +- static/functions/global.js | 8 +- static/functions/iphone.js | 20 +- static/functions/musicbrainz.js | 62 +++--- static/functions/password_validate.js | 2 +- static/functions/release_sort.js | 10 +- static/functions/reportsv2.js | 6 +- static/functions/requests.js | 24 +- static/functions/script_start.js | 14 +- static/functions/staffpm.js | 4 +- static/functions/tagcanvas.js | 2 +- static/functions/torrent.js | 6 +- static/functions/transitions.js | 12 +- static/functions/upload.js | 48 ++-- static/functions/user.js | 10 +- static/functions/valid_tags.js | 2 +- static/functions/validate.js | 4 +- static/styles/global.css | 4 +- static/styles/hydro/style.css | 2 +- static/styles/layer_cake/style.css | 2 +- static/styles/public/style.css | 2 +- static/styles/shiro/style.css | 2 +- static/styles/whatlove/style.css | 2 +- torrents.php | 2 +- 286 files changed, 1982 insertions(+), 1979 deletions(-) diff --git a/COPYING.txt b/COPYING.txt index a176c22b..60dd1024 100644 --- a/COPYING.txt +++ b/COPYING.txt @@ -38,17 +38,17 @@ terms of Sections 1 and 2 above provided that you also do one of the following: 3.1: Accompany it with the complete corresponding machine-readable source -code, which must be distributed under the terms of Sections 1 and 2 above on +code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, 3.2: Accompany it with a written offer, valid for at least one year, to -give any third party, for a charge no more than your cost of physically +give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, 3.3: Accompany it with the information you received as to the offer to -distribute corresponding source code. (This alternative is allowed only for +distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the Software in object code or executable form with such an offer, in accord with Subsection 3.2 above.) diff --git a/INSTALL.txt b/INSTALL.txt index 55d5b8d6..5d3bcf26 100644 --- a/INSTALL.txt +++ b/INSTALL.txt @@ -5,16 +5,16 @@ INSTALLATION NOTES 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 For documentation, read http://www.sphinxsearch.com/docs/current.html - + After you've installed sphinx, create the indices: /usr/local/bin/indexer -c /etc/sphinx/sphinx.conf --all - -4. Move classes/config.template to classes/config.php. Edit the config.php as needed. + +4. Move classes/config.template to classes/config.php. Edit the config.php as needed. We use http://grc.com/passwords.html for our passwords - you'll be generating a lot of these. 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. +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: 0,15,30,45 * * * * /usr/local/bin/php /var/www/vhosts/what/schedule.php SCHEDULE_KEY >> /root/schedule.log diff --git a/cheaters.php b/cheaters.php index d63c1d97..172ee44a 100644 --- a/cheaters.php +++ b/cheaters.php @@ -1,2 +1,2 @@ -to_array('Alias'); $Cache->cache_value('wiki_aliases', $Aliases, 3600*24*14); } - + function to_id($Alias) { global $Cache, $DB; $Aliases = $Cache->get_value('wiki_aliases'); @@ -26,7 +26,7 @@ function to_id($Alias) { function flush() { } - + function to_id($Alias) { global $DB; $Alias = $this->convert($Alias); diff --git a/classes/class_cache.php b/classes/class_cache.php index 33375f4d..a6f14146 100644 --- a/classes/class_cache.php +++ b/classes/class_cache.php @@ -155,7 +155,7 @@ public function delete_value($Key) { } $this->Time+=(microtime(true)-$StartTime)*1000; } - + public function increment_value($Key,$Value=1) { $StartTime=microtime(true); $this->increment($Key,$Value); diff --git a/classes/class_charts.php b/classes/class_charts.php index 683f1532..10b3e4c6 100644 --- a/classes/class_charts.php +++ b/classes/class_charts.php @@ -4,7 +4,7 @@ class GOOGLE_CHARTS { protected $Labels = array(); protected $Data = array(); protected $Options = array(); - + public function __construct($Type, $Width, $Height, $Options) { if ($Width * $Height > 300000 || $Height > 1000 || $Width > 1000) { trigger_error('Tried to make chart too large.'); @@ -12,7 +12,7 @@ public function __construct($Type, $Width, $Height, $Options) { $this->URL .= '?cht='.$Type.'&chs='.$Width.'x'.$Height; $this->Options = $Options; } - + protected function encode($Number) { if ($Number == -1) { return '__'; @@ -20,15 +20,15 @@ protected function encode($Number) { $CharKey = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.'; return $CharKey[floor($Number/64)].$CharKey[floor($Number%64)]; } - + public function color($Colors) { $this->URL .= '&chco='.$Colors; } - + public function lines($Thickness, $Solid=1, $Blank=0) { $this->URL .= '&chls='.$Thickness.','.$Solid.','.$Blank; } - + public function title($Title, $Color='', $Size='') { $this->URL .= '&chtt='.str_replace(array(' ',"\n"), array('+','|'), $Title); if (!empty($Color)) { @@ -38,7 +38,7 @@ public function title($Title, $Color='', $Size='') { $this->URL .= ','.$Size; } } - + public function legend($Items, $Placement='') { $this->URL .= '&chdl='.str_replace(' ', '+', implode('|', $Items)); if (!empty($Placement)) { @@ -48,24 +48,24 @@ public function legend($Items, $Placement='') { $this->URL .= '&chdlp='.$Placement; } } - + public function add($Label, $Data) { if ($Label !== false) { $this->Labels[] = $Label; } $this->Data[] = $Data; } - + public function grid_lines($SpacingX=0, $SpacingY=-1, $Solid=1, $Blank=1) { //Can take 2 more parameters for offset, but we're not bothering with that right now $this->URL .= '&chg='.$SpacingX.','.$SpacingY.','.$Solid.','.$Blank.''; } - + public function transparent() { $this->URL .= '&chf=bg,s,FFFFFF00'; } - - + + public function url() { return $this->URL; } @@ -79,7 +79,7 @@ public function __construct ($Width, $Height, $Options=array()) { public function color ($Color) { $this->URL .= '&chco='.$Color.'&chm=B,'.$Color.'50,0,0,0'; } - + public function generate() { $Max = max($this->Data); $Min = (isset($this->Options['Break']))?$Min=min($this->Data):0; @@ -109,12 +109,12 @@ public function generate() { sort($this->Data); $this->Data = array_reverse($this->Data); } - + $Data = array(); $Labels = $this->Labels; $OtherPercentage = 0.00; $OtherData = 0; - + foreach ($this->Data as $Key => $Value) { $ThisPercentage = number_format(($Value/$Sum)*100, 2); $ThisData = ($Value/$Sum)*4095; @@ -152,7 +152,7 @@ public function __construct ($Base, $Width, $Height, $Options=array()) { public function color ($Color) { $this->URL .= '&chco='.$Color.'&chm=B,'.$Color.'50,0,0,0'; } - + public function generate() { $Max = max($this->Data); $Min = (isset($this->Options['Break']))?$Min=min($this->Data):0; @@ -175,7 +175,7 @@ public function add($Label, $Data) { } $this->Data[] = $Data; } - + public function generate() { $Count = count($this->Data); $Height = (30*$Count)+20; diff --git a/classes/class_cookie.php b/classes/class_cookie.php index 365de3e4..1fc3bf72 100644 --- a/classes/class_cookie.php +++ b/classes/class_cookie.php @@ -14,7 +14,7 @@ interface COOKIE_INTERFACE { public function get($Key); public function set($Key,$Value,$Seconds,$LimitAccess); public function del($Key); - + public function flush(); } */ @@ -22,23 +22,23 @@ public function flush(); class COOKIE /*implements COOKIE_INTERFACE*/ { const LIMIT_ACCESS = true; //If true, blocks JS cookie API access by default (can be overridden case by case) const PREFIX = ''; //In some cases you may desire to prefix your cookies - + public function get($Key) { if (!isset($_COOKIE[SELF::PREFIX.$Key])) { return false; } return $_COOKIE[SELF::PREFIX.$Key]; } - + //Pass the 4th optional param as false to allow JS access to the cookie public function set($Key,$Value,$Seconds = 86400,$LimitAccess = SELF::LIMIT_ACCESS) { setcookie(SELF::PREFIX.$Key,$Value,time()+$Seconds,'/',SITE_URL,$_SERVER['SERVER_PORT'] === '443',$LimitAccess,false); } - + public function del($Key) { setcookie(SELF::PREFIX.$Key,'',time()-24*3600); //3600 vs 1 second to account for potential clock desyncs } - + public function flush() { $Cookies = array_keys($_COOKIE); foreach ($Cookies as $Cookie) { diff --git a/classes/class_file_checker.php b/classes/class_file_checker.php index 67a4c84d..452016ea 100644 --- a/classes/class_file_checker.php +++ b/classes/class_file_checker.php @@ -17,7 +17,7 @@ function check_file($Type, $Name) { function check_name($Name) { global $keywords; - foreach ($keywords as &$value) { + foreach ($keywords as &$value) { if(preg_match('/'.$value.'/i', $Name)) { forbidden_error($Name); } diff --git a/classes/class_format.php b/classes/class_format.php index 6075c0bf..307c8e37 100644 --- a/classes/class_format.php +++ b/classes/class_format.php @@ -33,7 +33,7 @@ class Format 'lossy master approved' => 'tl_approved tl_lossy_master', 'lossy web approved' => 'tl_approved tl_lossy_web' ); - + /** * Shorten a string * @@ -499,9 +499,9 @@ public static function is_utf8($Str) { /** * Modified accessor for the $TorrentLabels array - * + * * Converts $text to lowercase and strips non-word characters - * + * * @param string $text Search string * @return string CSS class(es) */ diff --git a/classes/class_image.php b/classes/class_image.php index 24ec44d4..13b402c4 100644 --- a/classes/class_image.php +++ b/classes/class_image.php @@ -8,7 +8,7 @@ class IMAGE { var $FontSize = 10; var $Font = ''; var $TextAngle = 0; - + function create($Width, $Height) { $this->Image = imagecreate($Width, $Height); $this->Font = SERVER_ROOT.'/classes/fonts/VERDANA.TTF'; @@ -16,11 +16,11 @@ function create($Width, $Height) { imageantialias($this->Image, true); } } - + function color($Red, $Green, $Blue, $Alpha=0){ return imagecolorallocatealpha($this->Image, $Red, $Green, $Blue, $Alpha); } - + function line($x1, $y1, $x2, $y2, $Color, $Thickness = 1){ if($Thickness == 1){ return imageline($this->Image, $x1, $y1, $x2, $y2, $Color); @@ -40,19 +40,19 @@ function line($x1, $y1, $x2, $y2, $Color, $Thickness = 1){ imagefilledpolygon($this->Image, $Points, 4, $Color); return imagepolygon($this->Image, $Points, 4, $Color); } - + function ellipse($x, $y, $Width, $Height, $Color){ return imageEllipse($this->Image, $x, $y, $Width, $Height, $Color); } - + function text($x, $y, $Color, $Text){ return imagettftext ($this->Image, $this->FontSize,$this->TextAngle, $x, $y, $Color, $this->Font, $Text); } - + function make_png($FileName = NULL){ return imagepng($this->Image, $FileName); } - - + + } ?> diff --git a/classes/class_image_tools.php b/classes/class_image_tools.php index ec22e932..000a11a6 100644 --- a/classes/class_image_tools.php +++ b/classes/class_image_tools.php @@ -5,14 +5,14 @@ **/ $blacklist = array("tinypic", "dsimg"); - + /** * Checks if image host is good, otherwise displays an error. */ function check_imagehost($url) { global $blacklist; - - foreach ($blacklist as &$value) { + + foreach ($blacklist as &$value) { if(strpos(strtolower($url), $value)) { $parsed_url = parse_url($url); error($parsed_url['host'] . " is not an allowed imagehost. Please use a different imagehost."); @@ -20,7 +20,7 @@ function check_imagehost($url) { } } } - + /** * The main function, called to get the thumbnail url. */ diff --git a/classes/class_invite_tree.php b/classes/class_invite_tree.php index 1e33262e..4a8791e4 100644 --- a/classes/class_invite_tree.php +++ b/classes/class_invite_tree.php @@ -9,7 +9,7 @@ class INVITE_TREE { var $UserID = 0; var $Visible = true; - + // Set things up function INVITE_TREE($UserID, $Options = array()){ $this->UserID = $UserID; @@ -17,7 +17,7 @@ function INVITE_TREE($UserID, $Options = array()){ $this->Visible = false; } } - + function make_tree() { $UserID = $this->UserID; global $DB; @@ -39,7 +39,7 @@ function make_tree() { } else { $MaxPosition = false; } - $TreeQuery = $DB->query("SELECT + $TreeQuery = $DB->query("SELECT it.UserID, Enabled, PermissionID, @@ -57,9 +57,9 @@ function make_tree() { ($MaxPosition ? " AND TreePosition<$MaxPosition" : "")." AND TreeLevel>$TreeLevel ORDER BY TreePosition"); - + $PreviousTreeLevel = $TreeLevel; - + // Stats for the summary $MaxTreeLevel = $TreeLevel; // The deepest level (this changes) $OriginalTreeLevel = $TreeLevel; // The level of the user we're viewing @@ -73,30 +73,30 @@ function make_tree() { $TotalDownload = 0; $TopLevelUpload = 0; $TopLevelDownload = 0; - + $ClassSummary = array(); global $Classes; foreach ($Classes as $ClassID => $Val) { $ClassSummary[$ClassID] = 0; } - + // We store this in an output buffer, so we can show the summary at the top without having to loop through twice ob_start(); - while(list($ID, $Enabled, $Class, $Donor, $Uploaded, $Downloaded, $Paranoia, $TreePosition, $TreeLevel) = $DB->next_record()){ - + while(list($ID, $Enabled, $Class, $Donor, $Uploaded, $Downloaded, $Paranoia, $TreePosition, $TreeLevel) = $DB->next_record()){ + // Do stats $Count++; - + if($TreeLevel > $MaxTreeLevel){ $MaxTreeLevel = $TreeLevel; } - + if($TreeLevel == $BaseTreeLevel){ $Branches++; $TopLevelUpload += $Uploaded; $TopLevelDownload += $Downloaded; } - + $ClassSummary[$Class]++; if($Enabled == 2){ $DisabledCount++; @@ -104,7 +104,7 @@ function make_tree() { if($Donor){ $DonorCount++; } - + // Manage tree depth if($TreeLevel > $PreviousTreeLevel){ for($i = 0; $i<$TreeLevel-$PreviousTreeLevel; $i++){ echo "\n"; } if($Count){ - + ?>

This tree has entries, branches, and a depth of . It has @@ -152,15 +152,15 @@ function make_tree() { foreach ($ClassSummary as $ClassID => $ClassCount) { if($ClassCount == 0) { continue; } $LastClass = Users::make_class_string($ClassID); - if($ClassCount>1) { + if($ClassCount>1) { if($LastClass == "Torrent Celebrity") { $LastClass = 'Torrent Celebrities'; } else { - $LastClass.='s'; + $LastClass.='s'; } } $LastClass= $ClassCount.' '.$LastClass.' (' . number_format(($ClassCount/$Count)*100) . '%)'; - + $ClassStrings []= $LastClass; } if(count($ClassStrings)>1){ @@ -183,13 +183,13 @@ function make_tree() { if($DonorCount == 0) { echo '0%)'; } else { echo number_format(($DonorCount/$Count)*100) . '%)';} echo '.

'; - + echo '

'; echo 'The total amount uploaded by the entire tree was '.Format::get_size($TotalUpload); echo '; the total amount downloaded was '.Format::get_size($TotalDownload); echo '; and the total ratio is '.Format::get_ratio_html($TotalUpload, $TotalDownload).'. '; echo '

'; - + echo '

'; echo 'The total amount uploaded by direct invitees (the top level) was '.Format::get_size($TopLevelUpload); echo '; the total amount downloaded was '.Format::get_size($TopLevelDownload); @@ -211,7 +211,7 @@ function make_tree() { echo '

'; } } - + ?>
diff --git a/classes/class_mass_user_torrents_table_view.php b/classes/class_mass_user_torrents_table_view.php index 74bc6148..d289ba07 100644 --- a/classes/class_mass_user_torrents_table_view.php +++ b/classes/class_mass_user_torrents_table_view.php @@ -168,7 +168,7 @@ public function header () */ public function footer () { - if ($this->HasTorrents) : + if ($this->HasTorrents) : ?> diff --git a/classes/class_misc.php b/classes/class_misc.php index 7a78bc3d..eb5d888f 100644 --- a/classes/class_misc.php +++ b/classes/class_misc.php @@ -88,7 +88,7 @@ public static function send_pm($ToID,$FromID,$Subject,$Body,$ConvID='') { list($UnRead) = $DB->next_record(); $Cache->cache_value('inbox_new_'.$ID, $UnRead); } - + $DB->query("SELECT Username FROM users_main WHERE ID = '$FromID'"); list($SenderName) = $DB->next_record(); foreach($ToID as $ID) { diff --git a/classes/class_mysql.php b/classes/class_mysql.php index bda757d0..c547fdd7 100644 --- a/classes/class_mysql.php +++ b/classes/class_mysql.php @@ -145,17 +145,17 @@ class DB_MYSQL { protected $Row; protected $Errno = 0; protected $Error = ''; - + public $Queries = array(); public $Time = 0.0; - + protected $Database = ''; protected $Server = ''; protected $User = ''; protected $Pass = ''; protected $Port = 0; protected $Socket = ''; - + function __construct($Database = SQLDB, $User = SQLLOGIN, $Pass = SQLPASS, $Server = SQLHOST, $Port = SQLPORT, $Socket = SQLSOCK) { $this->Database = $Database; $this->Server = $Server; @@ -169,7 +169,7 @@ function halt($Msg) { global $LoggedUser, $Cache, $Debug, $argv; $DBError='MySQL: '.strval($Msg).' SQL error: '.strval($this->Errno).' ('.strval($this->Error).')'; if ($this->Errno == 1194) { send_irc('PRIVMSG '.ADMIN_CHAN.' :'.$this->Error); } - /*if ($this->Errno == 1194) { + /*if ($this->Errno == 1194) { preg_match("Table '(\S+)' is marked as crashed and should be repaired", $this->Error, $Matches); } */ $Debug->analysis('!dev DB Error',$DBError,3600*24); @@ -207,7 +207,7 @@ function query($Query,$AutoHandle=1) { } $Debug->analysis('Non-Fatal Deadlock:',$Query,3600*24); trigger_error("Database deadlock, attempt $i"); - + sleep($i*rand(2, 5)); // Wait longer as attempts increase } $QueryEndTime=microtime(true); @@ -319,10 +319,14 @@ function to_array($Key = false, $Type = MYSQLI_BOTH, $Escape = true) { function to_pair($KeyField, $ValField, $Escape = true) { $Return = array(); while ($Row = mysqli_fetch_array($this->QueryID)) { - if ($Escape !== false) { - $Row = Misc::display_array($Row[$ValField], $Escape); + if ($Escape) { + $Key = display_str($Row[$KeyField]); + $Val = display_str($Row[$ValField]); + } else { + $Key = $Row[$KeyField]; + $Val = $Row[$ValField]; } - $Return[$Row[$KeyField]] = $Row[$ValField]; + $Return[$Key] = $Val; } mysqli_data_seek($this->QueryID, 0); return $Return; @@ -342,7 +346,7 @@ function set_query_id(&$ResultSet){ $this->QueryID = $ResultSet; $this->Row = 0; } - + function get_query_id() { return $this->QueryID; } diff --git a/classes/class_paranoia.php b/classes/class_paranoia.php index 361e4b42..b68b0bb4 100644 --- a/classes/class_paranoia.php +++ b/classes/class_paranoia.php @@ -44,7 +44,7 @@ define("PARANOIA_ALLOWED", 1); define("PARANOIA_OVERRIDDEN", 2); - + function check_paranoia($Property, $Paranoia, $UserClass, $UserID = false) { global $LoggedUser, $Classes; if ($Property == false) { @@ -68,8 +68,8 @@ function check_paranoia($Property, $Paranoia, $UserClass, $UserID = false) { $May = !in_array($Property, $Paranoia) && !in_array($Property . '+', $Paranoia); if($May) return PARANOIA_ALLOWED; - - if(check_perms('users_override_paranoia', $UserClass)) + + if(check_perms('users_override_paranoia', $UserClass)) return PARANOIA_OVERRIDDEN; $Override=false; switch ($Property) { @@ -78,20 +78,20 @@ function check_paranoia($Property, $Paranoia, $UserClass, $UserID = false) { case 'uploaded': case 'lastseen': if(check_perms('users_mod', $UserClass)) - return PARANOIA_OVERRIDDEN; + return PARANOIA_OVERRIDDEN; break; case 'snatched': case 'snatched+': - if(check_perms('users_view_torrents_snatchlist', $UserClass)) + if(check_perms('users_view_torrents_snatchlist', $UserClass)) return PARANOIA_OVERRIDDEN; break; case 'uploads': case 'uploads+': case 'seeding': case 'seeding+': case 'leeching': case 'leeching+': - if(check_perms('users_view_seedleech', $UserClass)) + if(check_perms('users_view_seedleech', $UserClass)) return PARANOIA_OVERRIDDEN; break; case 'invitedcount': - if(check_perms('users_view_invites', $UserClass)) + if(check_perms('users_view_invites', $UserClass)) return PARANOIA_OVERRIDDEN; break; } diff --git a/classes/class_proxies.php b/classes/class_proxies.php index 9b4e563e..af3206b0 100644 --- a/classes/class_proxies.php +++ b/classes/class_proxies.php @@ -20,19 +20,19 @@ function proxyCheck($IP) { if (strlen($IP) < strlen($AllowedProxies[$i])) { continue; } - + //since we're matching bit for bit iterating from the start for ($j=0,$jl=strlen($IP);$j<$jl;++$j) { //completed iteration and no inequality if ($j == $jl-1 && $IP[$j] === $AllowedProxies[$i][$j]) { return true; } - + //wildcard if ($AllowedProxies[$i][$j] === '*') { return true; } - + //inequality found if ($IP[$j] !== $AllowedProxies[$i][$j]) { break; diff --git a/classes/class_search.php b/classes/class_search.php index 1404726e..1c9f1331 100644 --- a/classes/class_search.php +++ b/classes/class_search.php @@ -10,30 +10,30 @@ class SPHINX_SEARCH extends SphinxClient { public $Queries = array(); public $Time = 0.0; public $Filters = array(); - + function SPHINX_SEARCH() { parent::__construct(); $this->SetServer(SPHINX_HOST, SPHINX_PORT); $this->SetMatchMode(SPH_MATCH_EXTENDED2); } - + /**************************************************************** /--- Search function -------------------------------------------- - - This function queries sphinx for whatever is in $Query, in + + This function queries sphinx for whatever is in $Query, in extended2 mode. It then fetches the records for each primary key from memcached (by joining $CachePrefix and the primary key), and - fetches the fields needed ($ReturnData) from the memcached + fetches the fields needed ($ReturnData) from the memcached result. - - Any keys not found in memcached are then queried in MySQL, using + + Any keys not found in memcached are then queried in MySQL, using $SQL. They are then cached, and merged with the memcached matches and returned. - + $Query - sphinx query $CachePrefix - Prefix for memcache key (no underscore) $CacheLength - How long to store data in the cache, if it's found by MySQL - $ReturnData - Array of keys to the array in memcached to return. + $ReturnData - Array of keys to the array in memcached to return. If empty, return all. $SQL - SQL query to fetch results not found in memcached - Should take the format of: @@ -41,9 +41,9 @@ function SPHINX_SEARCH() { where %ids will be replaced by a list of IDs not found in memcached $IDColumn - The primary key of the SQL table - must be the same primary key returned by sphinx! - + ****************************************************************/ - + function search($Query='', $CachePrefix='', $CacheLength=0, $ReturnData=array(), $SQL = '', $IDColumn='ID') { global $Cache, $DB; $QueryStartTime=microtime(true); @@ -59,7 +59,7 @@ function search($Query='', $CachePrefix='', $CacheLength=0, $ReturnData=array(), $this->Queries[]=array('Params: '.$Query.' Filters: '.implode(", ", $Filters).' Indicies: '.$this->Index,($QueryEndTime-$QueryStartTime)*1000); $this->Time+=($QueryEndTime-$QueryStartTime)*1000; - + if($Result === false) { if($this->_connerror && !$Cache->get_value('sphinx_crash_reported')) { send_irc('PRIVMSG '.ADMIN_CHAN.' :!dev Connection to searchd failed'); @@ -67,19 +67,19 @@ function search($Query='', $CachePrefix='', $CacheLength=0, $ReturnData=array(), } send_irc('PRIVMSG '.LAB_CHAN.' :Search for "'.$Query.'" ('.str_replace("\n",'',print_r($this->Filters, true)).') failed: '.$this->GetLastError()); } - + $this->TotalResults = $Result['total_found']; $this->SearchTime = $Result['time']; - + if(empty($Result['matches'])) { return false; } $Matches = $Result['matches']; - + $MatchIDs = array_keys($Matches); - - - + + + $NotFound = array(); $Skip = array(); if(!empty($ReturnData)) { @@ -87,7 +87,7 @@ function search($Query='', $CachePrefix='', $CacheLength=0, $ReturnData=array(), } else { $AllFields = true; } - + foreach($MatchIDs as $Match) { $Matches[$Match] = $Matches[$Match]['attrs']; if(!empty($CachePrefix)) { @@ -120,7 +120,7 @@ function search($Query='', $CachePrefix='', $CacheLength=0, $ReturnData=array(), $Matches[$Match] = array_merge($Matches[$Match], $Data); } } - + if($SQL!='') { if(!empty($NotFound)) { $DB->query(str_replace('%ids', implode(',',$NotFound), $SQL)); @@ -132,21 +132,21 @@ function search($Query='', $CachePrefix='', $CacheLength=0, $ReturnData=array(), } else { $Matches = array('matches'=>$Matches,'notfound'=>$NotFound); } - + return $Matches; } - + function limit($Start, $Length) { $Start = (int)$Start; $Length = (int)$Length; $this->SetLimits($Start, $Length, $Start+$Length); } - - + + function set_index($Index) { $this->Index = $Index; } - + function set_filter($Name, $Vals, $Exclude=false) { foreach($Vals as $Val) { if($Exclude) { @@ -157,12 +157,12 @@ function set_filter($Name, $Vals, $Exclude=false) { } $this->SetFilter($Name, $Vals, $Exclude); } - + function set_filter_range($Name, $Min, $Max, $Exclude) { $this->Filters[$Name] = array($Min.'-'.$Max); $this->SetFilterRange($Name, $Min, $Max, $Exclude); } - + function escape_string($String) { return strtr($String, array( '('=>'\(', @@ -182,7 +182,7 @@ function escape_string($String) { '$'=>'\$', '='=>'\=')); } - - + + } ?> diff --git a/classes/class_time.php b/classes/class_time.php index 8032cd3a..ab43a279 100644 --- a/classes/class_time.php +++ b/classes/class_time.php @@ -23,7 +23,7 @@ function time_diff($TimeStamp, $Levels=2, $Span=true, $Lowercase=false) { } if($TimeStamp == 0) { return 'Never'; } $Time = time()-$TimeStamp; - + // If the time is negative, then it expires in the future. if($Time < 0) { $Time = -$Time; @@ -77,7 +77,7 @@ function time_diff($TimeStamp, $Levels=2, $Span=true, $Lowercase=false) { if ($Return!="") { $Return.=', '; } - if ($Weeks>1) { + if ($Weeks>1) { $Return.=$Weeks.' weeks'; } else { $Return.=$Weeks.' week'; @@ -120,7 +120,7 @@ function time_diff($TimeStamp, $Levels=2, $Span=true, $Lowercase=false) { } $Levels--; } - + if($Return == '') { $Return = 'Just now'; } elseif (!isset($HideAgo)) { @@ -130,7 +130,7 @@ function time_diff($TimeStamp, $Levels=2, $Span=true, $Lowercase=false) { if ($Lowercase) { $Return = strtolower($Return); } - + if ($Span) { return ''.$Return.''; } else { diff --git a/classes/class_torrent.php b/classes/class_torrent.php index e99f65c4..0b4ae334 100644 --- a/classes/class_torrent.php +++ b/classes/class_torrent.php @@ -11,7 +11,7 @@ There are 4 data types in bencode: * String * Int -* List - array without keys +* List - array without keys - like array('value', 'value 2', 'value 3', 'etc') * Dictionary - array with string keys - like array['key 1'] = 'value 1'; array['key 2'] = 'value 2'; @@ -25,22 +25,22 @@ - Stored as php strings. Not difficult to remember. * Integers - - Stored as php ints + - Stored as php ints - must be casted with (int) * Lists - - Stored as a BENCODE_LIST object. + - Stored as a BENCODE_LIST object. - The actual list is in BENCODE_LIST::$Val, as an array with incrementing integer indices - The list in BENCODE_LIST::$Val is populated by the BENCODE_LIST::dec() function * Dictionaries - - Stored as a BENCODE_DICT object. + - Stored as a BENCODE_DICT object. - The actual list is in BENCODE_DICT::$Val, as an array with string indices - The list in BENCODE_DICT::$Val is populated by the BENCODE_DICT::dec() function //----- BENCODE_* Objects -----// -Lists and dictionaries are stored as objects. They each have the following +Lists and dictionaries are stored as objects. They each have the following functions: * decode(Type, $Key) @@ -59,15 +59,15 @@ functions: - Relies mostly on the encode() function Finally, as all torrents are just large dictionaries, the TORRENT class extends -the BENCODE_DICT class. - +the BENCODE_DICT class. + *******************************************************************************/ class BENCODE { var $Val; // Decoded array var $Pos = 1; // Pointer that indicates our position in the string var $Str = ''; // Torrent string - + function __construct($Val, $IsParsed = false){ if(!$IsParsed) { $this->Str = $Val; @@ -76,8 +76,8 @@ function __construct($Val, $IsParsed = false){ $this->Val = $Val; } } - - // Decode an element based on the type. The type is really just an indicator. + + // Decode an element based on the type. The type is really just an indicator. function decode($Type, $Key){ if(is_number($Type)) { // Element is a string // Get length of string @@ -87,24 +87,24 @@ function decode($Type, $Key){ $StrLen.=$this->Str[$this->Pos]; } $this->Val[$Key] = substr($this->Str, $this->Pos+2, $StrLen); - + $this->Pos+=$StrLen; $this->Pos+=2; - + } elseif($Type == 'i') { // Element is an int $this->Pos++; - + // Find end of integer (first occurance of 'e' after position) - $End = strpos($this->Str, 'e', $this->Pos); - + $End = strpos($this->Str, 'e', $this->Pos); + // Get the integer, and - IMPORTANT - cast it as an int, so we know later that it's an int and not a string - $this->Val[$Key] = (int)substr($this->Str, $this->Pos, $End-$this->Pos); + $this->Val[$Key] = (int)substr($this->Str, $this->Pos, $End-$this->Pos); $this->Pos = $End+1; - + } elseif($Type == 'l') { // Element is a list $this->Val[$Key] = new BENCODE_LIST(substr($this->Str, $this->Pos)); $this->Pos += $this->Val[$Key]->Pos; - + } elseif($Type == 'd') { // Element is a dictionary $this->Val[$Key] = new BENCODE_DICT(substr($this->Str, $this->Pos)); $this->Pos += $this->Val[$Key]->Pos; @@ -112,12 +112,12 @@ function decode($Type, $Key){ if (!empty($this->Val[$Key]->Val)) { ksort($this->Val[$Key]->Val); } - + } else { die('Invalid torrent file'); } } - + function encode($Val){ if(is_int($Val)) { // Integer return 'i'.$Val.'e'; @@ -143,7 +143,7 @@ function enc(){ } return $Str.'e'; } - + // Decode a list function dec(){ $Key = 0; // Array index @@ -152,13 +152,13 @@ function dec(){ $Type = $this->Str[$this->Pos]; // $Type now indicates what type of element we're dealing with // It's either an integer (string), 'i' (an integer), 'l' (a list), 'd' (a dictionary), or 'e' (end of dictionary/list) - + if($Type == 'e') { // End of list $this->Pos += 1; unset($this->Str); // Since we're finished parsing the string, we don't need to store it anymore. Benchmarked - this makes the parser run way faster. return; } - + // Decode the bencoded element. // This function changes $this->Pos and $this->Val, so you don't have to. $this->decode($Type, $Key); @@ -180,22 +180,22 @@ function enc(){ } return $Str.'e'; } - + // Decode a dictionary function dec(){ $Length = strlen($this->Str); while($this->Pos<$Length) { - + if($this->Str[$this->Pos] == 'e') { // End of dictionary $this->Pos += 1; unset($this->Str); // Since we're finished parsing the string, we don't need to store it anymore. Benchmarked - this makes the parser run way faster. return; } - + // Get the dictionary key // Length of the key, in bytes $KeyLen = $this->Str[$this->Pos]; - + // Allow for multi-digit lengths while($this->Str[$this->Pos+1]!=':' && $this->Pos+1<$Length) { $this->Pos++; @@ -204,21 +204,21 @@ function dec(){ // $this->Pos is now on the last letter of the key length // Adding 2 brings it past that character and the ':' to the beginning of the string $this->Pos+=2; - + // Get the name of the key - $Key = substr($this->Str, $this->Pos, $KeyLen); - + $Key = substr($this->Str, $this->Pos, $KeyLen); + // Move the position past the key to the beginning of the element $this->Pos+=$KeyLen; $Type = $this->Str[$this->Pos]; // $Type now indicates what type of element we're dealing with // It's either an integer (string), 'i' (an integer), 'l' (a list), 'd' (a dictionary), or 'e' (end of dictionary/list) - + // Decode the bencoded element. // This function changes $this->Pos and $this->Val, so you don't have to. $this->decode($Type, $Key); - - + + } return true; } @@ -230,12 +230,12 @@ function dump() { // Convenience function used for testing and figuring out how we store the data print_r($this->Val); } - + function dump_data() { // Function which serializes $this->Val for storage return base64_encode(serialize($this->Val)); } - + /* To use this, please remove the announce-list unset in make_private and be sure to still set_announce_url for backwards compatibility function set_multi_announce() { @@ -249,14 +249,14 @@ function set_multi_announce() { $this->Val['announce-list'] = $AnnounceList; } */ - + function set_announce_url($Announce) { $this->Val['announce'] = $Announce; ksort($this->Val); } - + // Returns an array of: - // * the files in the torrent + // * the files in the torrent // * the total size of files described therein function file_list() { $FileList = array(); @@ -276,7 +276,7 @@ function file_list() { foreach ($Files as $File) { $FileSize = $File->Val['length']; $TotalSize += $FileSize; - + $FileName = ltrim(implode('/',$File->Val[$PathKey]->Val), '/'); $FileSizes[] = $FileSize; $FileNames[] = $FileName; @@ -296,26 +296,26 @@ function get_name() { return $this->Val['info']->Val['name']; } } - + function make_private() { //----- The following properties do not affect the infohash: - + // anounce-list is an unofficial extension to the protocol // that allows for multiple trackers per torrent unset($this->Val['announce-list']); - + // Bitcomet & Azureus cache peers in here unset($this->Val['nodes']); - + // Azureus stores the dht_backup_enable flag here unset($this->Val['azureus_properties']); - + // Remove web-seeds unset($this->Val['url-list']); - + // Remove libtorrent resume info unset($this->Val['libtorrent_resume']); - + //----- End properties that do not affect the infohash if ($this->Val['info']->Val['private']) { return true; // Torrent is private diff --git a/classes/class_torrent_32bit.php b/classes/class_torrent_32bit.php index 547a478c..e1c9a766 100644 --- a/classes/class_torrent_32bit.php +++ b/classes/class_torrent_32bit.php @@ -11,7 +11,7 @@ There are 4 data types in bencode: * String * Int -* List - array without keys +* List - array without keys - like array('value', 'value 2', 'value 3', 'etc') * Dictionary - array with string keys - like array['key 1'] = 'value 1'; array['key 2'] = 'value 2'; @@ -30,18 +30,18 @@ - If stored as an int on 32 bit boxes, it won't allow for any size over 2 gigs * Lists - - Stored as a BENCODE_LIST object. + - Stored as a BENCODE_LIST object. - The actual list is in BENCODE_LIST::$Val, as an array with incrementing integer indices - The list in BENCODE_LIST::$Val is populated by the BENCODE_LIST::dec() function * Dictionaries - - Stored as a BENCODE_DICT object. + - Stored as a BENCODE_DICT object. - The actual list is in BENCODE_DICT::$Val, as an array with incrementing integer indices - The list in BENCODE_DICT::$Val is populated by the BENCODE_DICT::dec() function //----- BENCODE_* Objects -----// -Lists and dictionaries are stored as objects. They each have the following +Lists and dictionaries are stored as objects. They each have the following functions: * decode(Type, $Key) @@ -60,15 +60,15 @@ functions: - Relies mostly on the encode() function Finally, as all torrents are just large dictionaries, the TORRENT class extends -the BENCODE_DICT class. +the BENCODE_DICT class. **Note** The version we run doesn't store ints as strings marked with [*INT*] We store them as php integers. You can do this too for added speed and reduced hackery, if you're running a 64 bit box, or if you're running a 32 bit box and -don't care about files larger than 2 gigs. The system with the [*INT*]s was -coded up in around 4 minutes for STC when we discovered this problem, then +don't care about files larger than 2 gigs. The system with the [*INT*]s was +coded up in around 4 minutes for STC when we discovered this problem, then discovered that floats aren't accurate enough to use. :( *******************************************************************************/ @@ -76,7 +76,7 @@ class BENCODE { var $Val; // Decoded array var $Pos = 1; // Pointer that indicates our position in the string var $Str = ''; // Torrent string - + function __construct($Val, $IsParsed = false){ if(!$IsParsed) { $this->Str = $Val; @@ -96,35 +96,35 @@ function decode($Type, $Key){ $StrLen.=$this->Str[$this->Pos]; } $this->Val[$Key] = substr($this->Str, $this->Pos+2, $StrLen); - + $this->Pos+=$StrLen; $this->Pos+=2; - + } elseif($Type == 'i') { // Element is an int $this->Pos++; - + // Find end of integer (first occurance of 'e' after position) - $End = strpos($this->Str, 'e', $this->Pos); - + $End = strpos($this->Str, 'e', $this->Pos); + // Get the integer, and mark it as an int (on our version 64 bit box, we cast it to an int) - $this->Val[$Key] = '[*INT*]'.substr($this->Str, $this->Pos, $End-$this->Pos); + $this->Val[$Key] = '[*INT*]'.substr($this->Str, $this->Pos, $End-$this->Pos); $this->Pos = $End+1; - + } elseif($Type == 'l') { // Element is a list $this->Val[$Key] = new BENCODE_LIST(substr($this->Str, $this->Pos)); $this->Pos += $this->Val[$Key]->Pos; - + } elseif($Type == 'd') { // Element is a dictionary $this->Val[$Key] = new BENCODE_DICT(substr($this->Str, $this->Pos)); $this->Pos += $this->Val[$Key]->Pos; // Sort by key to respect spec ksort($this->Val[$Key]->Val); - + } else { die('Invalid torrent file'); } } - + function encode($Val){ if(is_string($Val)) { if(substr($Val, 0, 7) == '[*INT*]') { @@ -149,7 +149,7 @@ function enc(){ } return $Str.'e'; } - + // Decode a list function dec(){ $Key = 0; // Array index @@ -158,13 +158,13 @@ function dec(){ $Type = $this->Str[$this->Pos]; // $Type now indicates what type of element we're dealing with // It's either an integer (string), 'i' (an integer), 'l' (a list), 'd' (a dictionary), or 'e' (end of dictionary/list) - + if($Type == 'e') { // End of list $this->Pos += 1; unset($this->Str); // Since we're finished parsing the string, we don't need to store it anymore. Benchmarked - this makes the parser run way faster. return; } - + // Decode the bencoded element. // This function changes $this->Pos and $this->Val, so you don't have to. $this->decode($Type, $Key); @@ -183,22 +183,22 @@ function enc(){ } return $Str.'e'; } - + // Decode a dictionary function dec(){ $Length = strlen($this->Str); while($this->Pos<$Length) { - + if($this->Str[$this->Pos] == 'e') { // End of dictionary $this->Pos += 1; unset($this->Str); // Since we're finished parsing the string, we don't need to store it anymore. Benchmarked - this makes the parser run way faster. return; } - + // Get the dictionary key // Length of the key, in bytes $KeyLen = $this->Str[$this->Pos]; - + // Allow for multi-digit lengths while($this->Str[$this->Pos+1]!=':' && $this->Pos+1<$Length) { $this->Pos++; @@ -207,21 +207,21 @@ function dec(){ // $this->Pos is now on the last letter of the key length // Adding 2 brings it past that character and the ':' to the beginning of the string $this->Pos+=2; - + // Get the name of the key - $Key = substr($this->Str, $this->Pos, $KeyLen); - + $Key = substr($this->Str, $this->Pos, $KeyLen); + // Move the position past the key to the beginning of the element $this->Pos+=$KeyLen; $Type = $this->Str[$this->Pos]; // $Type now indicates what type of element we're dealing with // It's either an integer (string), 'i' (an integer), 'l' (a list), 'd' (a dictionary), or 'e' (end of dictionary/list) - + // Decode the bencoded element. // This function changes $this->Pos and $this->Val, so you don't have to. $this->decode($Type, $Key); - - + + } return true; } @@ -233,19 +233,19 @@ function dump() { // Convenience function used for testing and figuring out how we store the data print_r($this->Val); } - + function dump_data() { // Function which serializes $this->Val for storage return base64_encode(serialize($this->Val)); } - + function set_announce_url($Announce) { $this->Val['announce'] = $Announce; ksort($this->Val); } - + // Returns an array of: - // * the files in the torrent + // * the files in the torrent // * the total size of files described therein function file_list() { $FileList = array(); @@ -265,7 +265,7 @@ function file_list() { foreach ($Files as $File) { $FileSize = substr($File->Val['length'], 7); $TotalSize += $FileSize; - + $FileName = ltrim(implode('/',$File->Val[$PathKey]->Val), '/'); $FileSizes[] = $FileSize; $FileNames[] = $FileName; @@ -285,7 +285,7 @@ function get_name() { return $this->Val['info']->Val['name']; } } - + function make_private() { //----- The following properties do not affect the infohash: diff --git a/classes/class_torrents.php b/classes/class_torrents.php index 0fa027fe..a6aabbca 100644 --- a/classes/class_torrents.php +++ b/classes/class_torrents.php @@ -103,7 +103,7 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true, while($Torrent = $DB->next_record(MYSQLI_ASSOC, true)) { $Found[$Torrent['GroupID']]['Torrents'][$Torrent['ID']] = $Torrent; } - + // Cache it all foreach ($Found as $GroupID=>$GroupInfo) { $Cache->cache_value('torrent_group_'.$GroupID, @@ -639,7 +639,7 @@ public static function can_use_token($Torrent) { && $LoggedUser['CanLeech'] == '1'); } - + public static function has_snatched($TorrentID) { global $DB, $Cache, $LoggedUser; if (empty($LoggedUser) || !$LoggedUser['ShowSnatched']) { diff --git a/classes/class_torrentsdl.php b/classes/class_torrentsdl.php index 1948e9ca..91dc60c6 100644 --- a/classes/class_torrentsdl.php +++ b/classes/class_torrentsdl.php @@ -21,6 +21,8 @@ class TorrentsDL { * @param string $Title name of the collection that will be created */ public function __construct(&$QueryResult, $Title) { + global $Cache; + $Cache->InternalCache = false; // The internal cache is almost completely useless for this Zip::unlimit(); // Need more memory and longer timeout $this->QueryResult = $QueryResult; $this->Title = $Title; @@ -168,6 +170,7 @@ public function errors() { * @return file name with at most 180 characters that is valid on most systems */ public static function construct_file_name($Artist, $Album, $Year, $Media, $Format, $Encoding, $TorrentID = false, $TxtExtension = false) { + $TorrentArtist = Misc::file_string($Artist); $TorrentName = Misc::file_string($Album); if ($Year > 0) { $TorrentName .= " - $Year"; @@ -190,8 +193,8 @@ public static function construct_file_name($Artist, $Album, $Year, $Media, $Form if (!$TorrentName) { $TorrentName = "No Name"; - } else if (strlen($TorrentName . $TorrentInfo) <= 197) { - $TorrentName = Misc::file_string($Artist) . $TorrentName; + } else if (strlen($Artist . $TorrentName . $TorrentInfo) <= 196) { + $TorrentName = $Artist . $TorrentName; } // Leave some room to the user in case the file system limits the path length diff --git a/classes/class_user_rank.php b/classes/class_user_rank.php index 0997744e..7b93acba 100644 --- a/classes/class_user_rank.php +++ b/classes/class_user_rank.php @@ -3,33 +3,33 @@ define('PREFIX', 'percentiles_'); // Prefix for memcache keys, to make life easier class USER_RANK { - + // Returns a 101 row array (101 percentiles - 0 - 100), with the minimum value for that percentile as the value for each row // BTW - ingenious function build_table($MemKey, $Query) { global $Cache,$DB; - + $DB->query("DROP TEMPORARY TABLE IF EXISTS temp_stats"); - + $DB->query("CREATE TEMPORARY TABLE temp_stats (ID int(10) NOT NULL PRIMARY KEY AUTO_INCREMENT, Val bigint(20) NOT NULL);"); - + $DB->query("INSERT INTO temp_stats (Val) ".$Query); - + $DB->query("SELECT COUNT(ID) FROM temp_stats"); list($UserCount) = $DB->next_record(); - + $DB->query("SELECT MIN(Val) FROM temp_stats GROUP BY CEIL(ID/(".(int)$UserCount."/100));"); - + $Table = $DB->to_array(); - + // Give a little variation to the cache length, so all the tables don't expire at the same time - $Cache->cache_value($MemKey, $Table, 3600*24*rand(800,1000)*0.001); - + $Cache->cache_value($MemKey, $Table, 3600*24*rand(800,1000)*0.001); + return $Table; } - + function table_query($TableName) { switch($TableName) { case 'uploaded': @@ -57,11 +57,11 @@ function table_query($TableName) { } return $Query; } - + function get_rank($TableName, $Value) { if($Value == 0) { return 0; } global $Cache, $DB; - + $Table = $Cache->get_value(PREFIX.$TableName); if(!$Table) { //Cache lock! @@ -84,7 +84,7 @@ function get_rank($TableName, $Value) { } return 100; // 100th percentile } - + function overall_score($Uploaded, $Downloaded, $Uploads, $Requests, $Posts, $Bounty, $Artists, $Ratio){ // We can do this all in 1 line, but it's easier to read this way if($Ratio>1) { $Ratio = 1; } @@ -103,7 +103,7 @@ function overall_score($Uploaded, $Downloaded, $Uploads, $Requests, $Posts, $Bou $TotalScore *= $Ratio; return $TotalScore; } - + } diff --git a/classes/class_useragent.php b/classes/class_useragent.php index eb7185ad..ee1ac6fe 100644 --- a/classes/class_useragent.php +++ b/classes/class_useragent.php @@ -42,7 +42,7 @@ class USER_AGENT { 'RSS' => 'RSS Downloader' */ ); - + var $OperatingSystems = array( //Mobile 'SymbianOS' => 'Symbian', @@ -105,7 +105,7 @@ class USER_AGENT { 'win' => 'Windows', 'mac' => 'Mac OS X' ); - + public function operating_system(&$UserAgentString) { if (empty($UserAgentString)) { return 'Hidden'; @@ -119,19 +119,19 @@ public function operating_system(&$UserAgentString) { } return $Return; } - + public function mobile(&$UserAgentString) { if (strpos($UserAgentString, 'iPad')) { return false; } - + //Mobi catches Mobile if (/*strpos($UserAgentString, 'Mobile') || */strpos($UserAgentString, 'Device') || strpos($UserAgentString, 'Mobi') || strpos($UserAgentString, 'Mini') || strpos($UserAgentString, 'webOS')) { return true; } return false; } - + public function browser(&$UserAgentString) { if (empty($UserAgentString)) { return 'Hidden'; diff --git a/classes/class_users.php b/classes/class_users.php index f7834f50..fc074fe4 100644 --- a/classes/class_users.php +++ b/classes/class_users.php @@ -450,9 +450,9 @@ public static function format_username($UserID, $Badges = false, $IsWarned = tru $Str .= ($UserInfo['Donor'] == 1) ? 'Donor' : ''; } - $Str .= ($IsWarned && $UserInfo['Warned'] != '0000-00-00 00:00:00') ? 'WarnedWarned' : ''; $Str .= ($IsEnabled && $UserInfo['Enabled'] == 2) ? 'Banned' : ''; diff --git a/classes/class_view.php b/classes/class_view.php index 6c238476..440316e0 100644 --- a/classes/class_view.php +++ b/classes/class_view.php @@ -104,7 +104,7 @@ public static function render_template ($TemplateName, $Args) * @example
">Data

- * + * * // The variable $id within box.phtml will be filled by $some_id * View::parse('section/box.phtml', array('id' => $some_id)); * diff --git a/classes/class_wiki.php b/classes/class_wiki.php index e732491b..590f8c2a 100644 --- a/classes/class_wiki.php +++ b/classes/class_wiki.php @@ -3,11 +3,11 @@ ## Wiki class ## ########################################################################## -Seeing as each page has to manage its wiki separately (for performance +Seeing as each page has to manage its wiki separately (for performance reasons - JOINs instead of multiple queries), this class is rather bare. -The only useful function in here is revision_history(). It creates a -table with the revision history for that particular wiki page. +The only useful function in here is revision_history(). It creates a +table with the revision history for that particular wiki page. class_wiki depends on your wiki table being structured like this: @@ -23,9 +23,9 @@ class_wiki depends on your wiki table being structured like this: | Time | datetime | NO | MUL | 0000-00-00 00:00:00 | | +------------+--------------+------+-----+----------------------+-------+ -It is also recommended that you have a field in the main table for +It is also recommended that you have a field in the main table for whatever the page is (e.g. details.php main table = torrents), so you can -do a JOIN. +do a JOIN. ########################################################################*/ @@ -39,13 +39,13 @@ function WIKI($Table, $PageID, $BaseURL = ''){ $this->PageID = $PageID; $this->BaseURL = $BaseURL; } - + function revision_history(){ global $DB; - + $BaseURL = $this->BaseURL; - $DB->query("SELECT - RevisionID, + $DB->query("SELECT + RevisionID, Summary, Time, UserID @@ -62,7 +62,7 @@ function revision_history(){ next_record()){ + while(list($RevisionID, $Summary, $Time, $UserID, $Username) = $DB->next_record()){ $Row = ($Row == 'a') ? 'b' : 'a'; //------------------------------------------------------ ?> @@ -84,7 +84,7 @@ function revision_history(){ //-------------------------------------------- ?> diff --git a/classes/class_zip.php b/classes/class_zip.php index b3c1656c..2810117a 100644 --- a/classes/class_zip.php +++ b/classes/class_zip.php @@ -4,9 +4,9 @@ |*************************************************************************| This class provides a convenient way for us to generate and serve zip -archives to our end users, both from physical files, cached +archives to our end users, both from physical files, cached or already parsed data (torrent files). It's all done on the fly, due to -the high probability that a filesystem stored archive will never be +the high probability that a filesystem stored archive will never be downloaded twice. Utilizes gzcompress, based upon RFC 1950 @@ -39,7 +39,7 @@ $Zip->add_file($TorrentData, "Bookmarks/Artist - Album [2008].torrent"); Adds the parsed torrent to the archive in the Bookmarks folder (created simply by placing it in the path). - + ----- * Then, close the archive to the user: @@ -96,12 +96,12 @@ class Zip { private $Structure = ''; // Structure saved to memory private $FileOffset = 0; // Offset to write data private $Data = ''; //An idea - + public function __construct ($ArchiveName='Archive') { header("Content-type: application/octet-stream"); //Stream download header("Content-disposition: attachment; filename=\"$ArchiveName.zip\""); //Name the archive - Should not be urlencoded } - + public static function unlimit () { ob_end_clean(); set_time_limit(3600); //Limit 1 hour @@ -121,7 +121,7 @@ public function add_file ($FileData, $ArchivePath, $TimeStamp = 0) { $ZipData = gzcompress($FileData); // Ditto. $ZipData = substr ($ZipData, 2,(strlen($ZipData) - 6)); // Checksum resolution $ZipLength = strlen($ZipData); //Ditto. - $this->Data .= pack("V",$CRC32); // CRC-32 + $this->Data .= pack("V",$CRC32); // CRC-32 $this->Data .= pack("V",$ZipLength); // Compressed filesize $this->Data .= pack("V",$DataLength); // Uncompressed filesize $this->Data .= pack("v",strlen($ArchivePath)); // Pathname length @@ -136,10 +136,10 @@ public function add_file ($FileData, $ArchivePath, $TimeStamp = 0) { /* Data descriptor Not needed (only needed when 3rd bitflag is set), causes problems with OS X archive utility $this->Data .= pack("V",$CRC32); // CRC-32 - $this->Data .= pack("V",$ZipLength); // Compressed filesize - $this->Data .= pack("V",$DataLength); // Uncompressed filesize + $this->Data .= pack("V",$ZipLength); // Compressed filesize + $this->Data .= pack("V",$DataLength); // Uncompressed filesize END data descriptor */ - + $FileDataLength = strlen($this->Data); $this->ArchiveSize = $this->ArchiveSize + $FileDataLength; // All we really need is the size $CurrentOffset = $this->ArchiveSize; // Update offsets @@ -148,14 +148,14 @@ public function add_file ($FileData, $ArchivePath, $TimeStamp = 0) { /* Central Directory Structure */ $CDS = "\x50\x4b\x01\x02"; // CDS signature $CDS .="\x14\x00"; // Constructor version - $CDS .="\x14\x00"; // Version requirements + $CDS .="\x14\x00"; // Version requirements $CDS .="\x00\x08"; // Bit flag - 0x8 = UTF-8 file names $CDS .="\x08\x00"; // Compression - $CDS .="\x00\x00\x00\x00"; // Last modified - $CDS .= pack("V",$CRC32); // CRC-32 - $CDS .= pack("V",$ZipLength); // Compressed filesize - $CDS .= pack("V",$DataLength); // Uncompressed filesize - $CDS .= pack("v",strlen($ArchivePath)); // Pathname length + $CDS .="\x00\x00\x00\x00"; // Last modified + $CDS .= pack("V",$CRC32); // CRC-32 + $CDS .= pack("V",$ZipLength); // Compressed filesize + $CDS .= pack("V",$DataLength); // Uncompressed filesize + $CDS .= pack("v",strlen($ArchivePath)); // Pathname length $CDS .="\x00\x00"; // Extra field length (0'd so we can ignore this) $CDS .="\x00\x00"; // File comment length (no comment, 0'd) $CDS .="\x00\x00"; // Disk number start (0 seems valid) @@ -171,14 +171,14 @@ public function add_file ($FileData, $ArchivePath, $TimeStamp = 0) { } public function close_stream() { - echo $this->Structure; // Structure Root + echo $this->Structure; // Structure Root echo "\x50\x4b\x05\x06"; // End of central directory signature echo "\x00\x00"; // This disk - echo "\x00\x00"; // CDS start + echo "\x00\x00"; // CDS start echo pack("v", $this->ArchiveFiles); // Handle the numebr of entries echo pack("v", $this->ArchiveFiles); // Ditto - echo pack("V", strlen($this->Structure)); //Size - echo pack("V", $this->ArchiveSize); // Offset + echo pack("V", strlen($this->Structure)); //Size + echo pack("V", $this->ArchiveSize); // Offset echo "\x00\x00"; // No comment, close it off } } diff --git a/classes/permissions_form.php b/classes/permissions_form.php index 4cd95ec2..63c2828d 100644 --- a/classes/permissions_form.php +++ b/classes/permissions_form.php @@ -6,7 +6,7 @@ ** This function is used to create both the class permissions form, and the ** ** user custom permissions form. ** ********************************************************************************/ - + $PermissionsArray = array( 'site_leech' => 'Can leech (Does this work?).', 'site_upload' => 'Upload torrent access.', @@ -31,7 +31,7 @@ 'site_moderate_requests' => 'Request moderation access.', 'site_delete_artist' => 'Can delete artists (must be able to delete torrents+requests).', 'site_moderate_forums' => 'Forum moderation access.', - + 'site_admin_forums' => 'Forum administrator access.', 'site_forums_double_post' => 'Can double post in the forums.', 'site_view_flow' => 'Can view stats and data pools.', @@ -113,7 +113,7 @@ 'artist_edit_vanityhouse' => 'Can mark artists as part of Vanity House.' ); - + function permissions_form(){ ?>
@@ -216,9 +216,9 @@ function permissions_form(){ ?> - + - + diff --git a/classes/sphinxapi.php b/classes/sphinxapi.php index aa72a811..a9b5063e 100644 --- a/classes/sphinxapi.php +++ b/classes/sphinxapi.php @@ -125,7 +125,7 @@ function sphPackI64 ( $v ) { assert ( is_numeric($v) ); - + // x64 if ( PHP_INT_SIZE>=8 ) { @@ -137,7 +137,7 @@ function sphPackI64 ( $v ) if ( is_int($v) ) return pack ( "NN", $v < 0 ? -1 : 0, $v ); - // x32, bcmath + // x32, bcmath if ( function_exists("bcmul") ) { if ( bccomp ( $v, 0 ) == -1 ) @@ -174,16 +174,16 @@ function sphPackI64 ( $v ) function sphPackU64 ( $v ) { assert ( is_numeric($v) ); - + // x64 if ( PHP_INT_SIZE>=8 ) { assert ( $v>=0 ); - + // x64, int if ( is_int($v) ) return pack ( "NN", $v>>32, $v&0xFFFFFFFF ); - + // x64, bcmath if ( function_exists("bcmul") ) { @@ -191,12 +191,12 @@ function sphPackU64 ( $v ) $l = bcmod ( $v, 4294967296 ); return pack ( "NN", $h, $l ); } - + // x64, no-bcmath $p = max ( 0, strlen($v) - 13 ); $lo = (int)substr ( $v, $p ); $hi = (int)substr ( $v, 0, $p ); - + $m = $lo + $hi*1316134912; $l = $m % 4294967296; $h = $hi*2328 + (int)($m/4294967296); @@ -207,7 +207,7 @@ function sphPackU64 ( $v ) // x32, int if ( is_int($v) ) return pack ( "NN", 0, $v ); - + // x32, bcmath if ( function_exists("bcmul") ) { @@ -220,7 +220,7 @@ function sphPackU64 ( $v ) $p = max(0, strlen($v) - 13); $lo = (float)substr($v, $p); $hi = (float)substr($v, 0, $p); - + $m = $lo + $hi*1316134912.0; $q = floor($m / 4294967296.0); $l = $m - ($q * 4294967296.0); @@ -276,11 +276,11 @@ function sphUnpackU64 ( $v ) // x32, bcmath if ( function_exists("bcmul") ) return bcadd ( $lo, bcmul ( $hi, "4294967296" ) ); - + // x32, no-bcmath $hi = (float)$hi; $lo = (float)$lo; - + $q = floor($hi/10000000.0); $r = $hi - $q*10000000.0; $m = $lo + $r*4967296.0; @@ -323,7 +323,7 @@ function sphUnpackI64 ( $v ) return $lo; return sprintf ( "%.0f", $lo - 4294967296.0 ); } - + $neg = ""; $c = 0; if ( $hi<0 ) @@ -332,7 +332,7 @@ function sphUnpackI64 ( $v ) $lo = ~$lo; $c = 1; $neg = "-"; - } + } $hi = sprintf ( "%u", $hi ); $lo = sprintf ( "%u", $lo ); @@ -344,7 +344,7 @@ function sphUnpackI64 ( $v ) // x32, no-bcmath $hi = (float)$hi; $lo = (float)$lo; - + $q = floor($hi/10000000.0); $r = $hi - $q*10000000.0; $m = $lo + $r*4967296.0; @@ -507,7 +507,7 @@ function SetServer ( $host, $port = 0 ) $this->_path = $host; return; } - + assert ( is_int($port) ); $this->_host = $host; $this->_port = $port; @@ -587,14 +587,14 @@ function _Connect () $fp = @fsockopen ( $host, $port, $errno, $errstr ); else $fp = @fsockopen ( $host, $port, $errno, $errstr, $this->_timeout ); - + if ( !$fp ) { if ( $this->_path ) $location = $this->_path; else $location = "{$this->_host}:{$this->_port}"; - + $errstr = trim ( $errstr ); $this->_error = "connection to $location failed (errno=$errno, msg=$errstr)"; $this->_connerror = true; @@ -1228,7 +1228,7 @@ function _ParseSearchResponse ( $response, $nreqs ) if ( $type==SPH_ATTR_FLOAT ) { list(,$uval) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; - list(,$fval) = unpack ( "f*", pack ( "L", $uval ) ); + list(,$fval) = unpack ( "f*", pack ( "L", $uval ) ); $attrvals[$attr] = $fval; continue; } @@ -1257,7 +1257,7 @@ function _ParseSearchResponse ( $response, $nreqs ) } else if ( $type==SPH_ATTR_STRING ) { $attrvals[$attr] = substr ( $response, $p, $val ); - $p += $val; + $p += $val; } else { $attrvals[$attr] = sphFixUint($val); @@ -1624,7 +1624,7 @@ function Close() fclose ( $this->_socket ); $this->_socket = false; - + return true; } diff --git a/delays.php b/delays.php index 663fc008..50e58b38 100644 --- a/delays.php +++ b/delays.php @@ -1,3 +1,3 @@ -

diff --git a/design/privateheader.php b/design/privateheader.php index bf1b8e99..23924c54 100644 --- a/design/privateheader.php +++ b/design/privateheader.php @@ -264,8 +264,6 @@ $Cache->cache_value('staff_blog_latest_time', $LatestSBlogTime, 1209600); } if ($SBlogReadTime < $LatestSBlogTime) { - global $Debug; - $Debug->log_var(array('b' => $SBlogReadTime, 'l' => $LatestSBlogTime), 'Times'); $Alerts[] = ''.'New Staff Blog Post!'.''; } } @@ -359,7 +357,7 @@ list($NumTorrentReports) = $DB->next_record(); $Cache->cache_value('num_torrent_reportsv2', $NumTorrentReports, 0); } - + $ModBar[] = ''.$NumTorrentReports.(($NumTorrentReports == 1) ? ' Report' : ' Reports').''; } @@ -413,7 +411,7 @@

- + functions/global.js?v=" type="text/javascript"> - @@ -39,7 +39,7 @@ diff --git a/forums.php b/forums.php index 663fc008..50e58b38 100644 --- a/forums.php +++ b/forums.php @@ -1,3 +1,3 @@ -:///artist.php?artistname={searchTerms}"> http:///torrents.php?action=advanced - http:///torrents.php - http:///requests.php - http:///forums.php?action=search - http:///user.php?action=search - http:///wiki.php?action=search - http:///log.php - diff --git a/sections/ajax/announcements.php b/sections/ajax/announcements.php index ccc280a4..1aa4d617 100644 --- a/sections/ajax/announcements.php +++ b/sections/ajax/announcements.php @@ -60,14 +60,14 @@ if (strtotime($NewsTime) > time()) { continue; } - + $JsonAnnouncements[] = array( 'newsId' => (int) $NewsID, 'title' => $Title, 'body' => $Text->full_format($Body), 'newsTime' => $NewsTime ); - + if (++$Count > 4) { break; } diff --git a/sections/ajax/better/index.php b/sections/ajax/better/index.php index ca48fcf9..ecb78a25 100644 --- a/sections/ajax/better/index.php +++ b/sections/ajax/better/index.php @@ -15,10 +15,10 @@ break; case 'artistless': include(SERVER_ROOT.'/sections/ajax/better/artistless.php'); - break; + break; case 'tags': include(SERVER_ROOT.'/sections/ajax/better/tags.php'); - break; + break; case 'folders': include(SERVER_ROOT.'/sections/ajax/better/folders.php'); break; diff --git a/sections/ajax/better/single.php b/sections/ajax/better/single.php index 70a5ebba..553aa3c9 100644 --- a/sections/ajax/better/single.php +++ b/sections/ajax/better/single.php @@ -21,7 +21,7 @@ foreach ($Results as $GroupID=>$Group) { list($GroupID, $GroupName, $GroupYear, $GroupRecordLabel, $GroupCatalogueNumber, $TagList, $ReleaseType, $GroupVanityHouse, $Torrents, $Artists) = array_values($Group); $FlacID = $GroupIDs[$GroupID]['TorrentID']; - + $JsonArtists = array(); if(count($Artists)>0) { foreach ($Artists as $Artist) { @@ -32,7 +32,7 @@ ); } } - + $JsonResults[] = array( 'torrentId' => (int) $FlacID, 'groupId' => (int) $GroupID, diff --git a/sections/ajax/bookmarks/artists.php b/sections/ajax/bookmarks/artists.php index c8b6efad..13287b95 100644 --- a/sections/ajax/bookmarks/artists.php +++ b/sections/ajax/bookmarks/artists.php @@ -2,7 +2,7 @@ if(!empty($_GET['userid'])) { if(!check_perms('users_override_paranoia')) { - print + print json_encode( array( 'status' => 'failure' @@ -13,7 +13,7 @@ $UserID = $_GET['userid']; $Sneaky = ($UserID != $LoggedUser['ID']); if(!is_number($UserID)) { - print + print json_encode( array( 'status' => 'failure' diff --git a/sections/ajax/bookmarks/index.php b/sections/ajax/bookmarks/index.php index 9d4f83ed..735428b1 100644 --- a/sections/ajax/bookmarks/index.php +++ b/sections/ajax/bookmarks/index.php @@ -1,7 +1,7 @@ 'failure' diff --git a/sections/ajax/bookmarks/torrents.php b/sections/ajax/bookmarks/torrents.php index 93443646..2b7e980a 100644 --- a/sections/ajax/bookmarks/torrents.php +++ b/sections/ajax/bookmarks/torrents.php @@ -28,8 +28,8 @@ function compare($X, $Y){ list($K, list($TorrentList, $CollageDataList)) = each($Data); } else { // Build the data for the collage and the torrent list - $DB->query("SELECT - bt.GroupID, + $DB->query("SELECT + bt.GroupID, tg.WikiImage, tg.CategoryID, bt.Time @@ -37,7 +37,7 @@ function compare($X, $Y){ JOIN torrents_group AS tg ON tg.ID=bt.GroupID WHERE bt.UserID='$UserID' ORDER BY bt.Time"); - + $GroupIDs = $DB->collect('GroupID'); $CollageDataList=$DB->to_array('GroupID', MYSQLI_ASSOC); if(count($GroupIDs)>0) { diff --git a/sections/ajax/forum/forum.php b/sections/ajax/forum/forum.php index 6cddf24d..baca2afc 100644 --- a/sections/ajax/forum/forum.php +++ b/sections/ajax/forum/forum.php @@ -107,7 +107,7 @@ // This is done here so we get the benefit of the caching, and we // don't have to make a database query for each topic on the page $LastRead = $DB->to_array('TopicID'); - + $JsonTopics = array(); foreach ($Forum as $Topic) { list($TopicID, $Title, $AuthorID, $Locked, $Sticky, $PostCount, $LastID, $LastTime, $LastAuthorID) = array_values($Topic); @@ -122,7 +122,7 @@ $AuthorName = $UserInfo['Username']; $UserInfo = Users::user_info($LastAuthorID); $LastAuthorName = $UserInfo['Username']; - + $JsonTopics[] = array( 'topicId' => (int) $TopicID, 'title' => display_str($Title), diff --git a/sections/ajax/forum/index.php b/sections/ajax/forum/index.php index 16dca4de..5249d35d 100644 --- a/sections/ajax/forum/index.php +++ b/sections/ajax/forum/index.php @@ -57,7 +57,7 @@ unset($ForumID, $Forum); $Cache->cache_value('forums_list', $Forums, 0); //Inf cache. } - + if(empty($_GET['type']) || $_GET['type'] == 'main') { include(SERVER_ROOT.'/sections/ajax/forum/main.php'); } else { @@ -96,7 +96,7 @@ function get_forum_info($ForumID) { } // Makes an array, with $Forum['Name'], etc. $Forum = $DB->next_record(MYSQLI_ASSOC); - + $Cache->cache_value('ForumInfo_'.$ForumID, $Forum, 86400); // Cache for a day } return $Forum; diff --git a/sections/ajax/forum/main.php b/sections/ajax/forum/main.php index f7e219c2..101a9334 100644 --- a/sections/ajax/forum/main.php +++ b/sections/ajax/forum/main.php @@ -56,14 +56,14 @@ ); $JsonForums = array(); } - + if((!$Locked || $Sticky) && $LastPostID != 0 && ((empty($LastRead[$LastTopicID]) || $LastRead[$LastTopicID]['PostID'] < $LastPostID) && strtotime($LastTime)>$LoggedUser['CatchupTime'])) { $Read = 'unread'; } else { $Read = 'read'; } $UserInfo = Users::user_info($LastAuthorID); - + $JsonForums[] = array( 'forumId' => (int) $ForumID, 'forumName' => $ForumName, diff --git a/sections/ajax/forum/thread.php b/sections/ajax/forum/thread.php index 46766ee3..e227b29c 100644 --- a/sections/ajax/forum/thread.php +++ b/sections/ajax/forum/thread.php @@ -141,13 +141,13 @@ $Answers = unserialize($Answers); $DB->query("SELECT Vote, COUNT(UserID) FROM forums_polls_votes WHERE TopicID='$ThreadID' GROUP BY Vote"); $VoteArray = $DB->to_array(false, MYSQLI_NUM); - + $Votes = array(); foreach ($VoteArray as $VoteSet) { - list($Key,$Value) = $VoteSet; + list($Key,$Value) = $VoteSet; $Votes[$Key] = $Value; } - + foreach(array_keys($Answers) as $i) { if (!isset($Votes[$i])) { $Votes[$i] = 0; @@ -155,7 +155,7 @@ } $Cache->cache_value('polls_'.$ThreadID, array($Question,$Answers,$Votes,$Featured,$Closed), 0); } - + if (!empty($Votes)) { $TotalVotes = array_sum($Votes); $MaxVotes = max($Votes); @@ -163,7 +163,7 @@ $TotalVotes = 0; $MaxVotes = 0; } - + $RevealVoters = in_array($ForumID, $ForumsRevealVoters); //Polls lose the you voted arrow thingy $DB->query("SELECT Vote FROM forums_polls_votes WHERE UserID='".$LoggedUser['ID']."' AND TopicID='$ThreadID'"); @@ -175,14 +175,14 @@ $Answers[$UserResponse] = '» '.$Answers[$UserResponse]; } } - + $JsonPoll['closed'] = $Closed == 1; $JsonPoll['featured'] = $Featured; $JsonPoll['question'] = $Question; $JsonPoll['maxVotes'] = (int) $MaxVotes; $JsonPoll['totalVotes'] = $TotalVotes; $JsonPollAnswers = array(); - + foreach($Answers as $i => $Answer) { if (!empty($Votes[$i]) && $TotalVotes > 0) { $Ratio = $Votes[$i]/$MaxVotes; @@ -197,13 +197,13 @@ 'percent' => $Percent ); } - + if ($UserResponse !== null || $Closed || $ThreadInfo['IsLocked'] || $LoggedUser['Class'] < $Forums[$ForumID]['MinClassWrite']) { - $JsonPoll['voted'] = True; + $JsonPoll['voted'] = True; } else { $JsonPoll['voted'] = False; } - + $JsonPoll['answers'] = $JsonPollAnswers; } @@ -241,7 +241,7 @@ 'enabled' => $Enabled == 2 ? false : true, 'userTitle' => $UserTitle ), - + ); } diff --git a/sections/ajax/index.php b/sections/ajax/index.php index 9c1e72d8..999635de 100644 --- a/sections/ajax/index.php +++ b/sections/ajax/index.php @@ -2,9 +2,9 @@ /* AJAX Switch Center -This page acts as an AJAX "switch" - it's called by scripts, and it includes the required pages. +This page acts as an AJAX "switch" - it's called by scripts, and it includes the required pages. -The required page is determined by $_GET['action']. +The required page is determined by $_GET['action']. */ diff --git a/sections/ajax/notifications.php b/sections/ajax/notifications.php index e83f04c3..dc5ee5d0 100644 --- a/sections/ajax/notifications.php +++ b/sections/ajax/notifications.php @@ -69,7 +69,7 @@ $TorrentInfo = $GroupInfo['Torrents'][$TorrentID]; if ($Result['UnRead'] == 1) $NumNew++; - + $JsonNotifications[] = array( 'torrentId' => (int) $TorrentID, 'groupId' => (int) $GroupID, diff --git a/sections/ajax/request.php b/sections/ajax/request.php index 06fb9ce9..3c5c39a9 100644 --- a/sections/ajax/request.php +++ b/sections/ajax/request.php @@ -17,7 +17,7 @@ include(SERVER_ROOT.'/classes/class_text.php'); $Text = new TEXT; -if(empty($_GET['id']) || !is_number($_GET['id'])) { +if(empty($_GET['id']) || !is_number($_GET['id'])) { print json_encode( array( @@ -31,7 +31,7 @@ //First things first, lets get the data for the request. -$Request = Requests::get_requests(array($RequestID)); +$Request = Requests::get_requests(array($RequestID)); $Request = $Request['matches'][$RequestID]; if(empty($Request)) { print @@ -61,14 +61,14 @@ $ArtistForm = get_request_artists($RequestID); $ArtistName = Artists::display_artists($ArtistForm, false, true); $ArtistLink = Artists::display_artists($ArtistForm, true, true); - + if($IsFilled) { $DisplayLink = $ArtistLink."".$Title." [".$Year."]"; } else { $DisplayLink = $ArtistLink.$Title." [".$Year."]"; } $FullName = $ArtistName.$Title." [".$Year."]"; - + if($BitrateList != "") { $BitrateString = implode(", ", explode("|", $BitrateList)); $FormatString = implode(", ", explode("|", $FormatList)); @@ -78,13 +78,13 @@ $FormatString = "Unknown, please read the description."; $MediaString = "Unknown, please read the description."; } - + if(empty($ReleaseType)) { $ReleaseName = "Unknown"; } else { $ReleaseName = $ReleaseTypes[$ReleaseType]; } - + } else if($CategoryName == "Audiobooks" || $CategoryName == "Comedy") { $FullName = $Title." [".$Year."]"; $DisplayLink = $Title." [".$Year."]"; @@ -121,7 +121,7 @@ $JsonTopContributors = array(); $VoteMax = ($VoteCount < 5 ? $VoteCount : 5); -for($i = 0; $i < $VoteMax; $i++) { +for($i = 0; $i < $VoteMax; $i++) { $User = array_shift($RequestVotes['Voters']); $JsonTopContributors[] = array( 'userId' => (int) $User['UserID'], diff --git a/sections/ajax/requests.php b/sections/ajax/requests.php index a029743d..7e4bdf0e 100644 --- a/sections/ajax/requests.php +++ b/sections/ajax/requests.php @@ -7,15 +7,15 @@ $OrderWays = array('year', 'votes', 'bounty', 'created', 'lastvote', 'filled'); list($Page,$Limit) = Format::page_limit(REQUESTS_PER_PAGE); $Submitted = !empty($_GET['submit']); - -//Paranoia + +//Paranoia $UserInfo = Users::user_info((int)$_GET['userid']); $Perms = Permissions::get_permissions($UserInfo['PermissionID']); $UserClass = $Perms['Class']; $BookmarkView = false; -if(empty($_GET['type'])) { +if(empty($_GET['type'])) { $Title = 'Requests'; if(!check_perms('site_see_old_requests') || empty($_GET['showall'])) { $SS->set_filter('visible', array(1)); @@ -137,7 +137,7 @@ unset($ReleaseArray[$Index]); } } - + if(count($ReleaseArray) >= 1) { $SS->set_filter('releasetype', $ReleaseArray); } @@ -153,7 +153,7 @@ $FormatNameArray[$Index] = '"'.strtr($Formats[$MasterIndex], '-.', ' ').'"'; } } - + if(count($FormatNameArray) >= 1) { $Queries[]='@formatlist (any | '.implode(' | ', $FormatNameArray).')'; } @@ -287,11 +287,11 @@ unset($SphinxResults['matches'][$ID]); } } - + // Merge SQL results with memcached results foreach($SQLResults['matches'] as $ID => $SQLResult) { $SphinxResults['matches'][$ID] = $SQLResult; - + //$Requests['matches'][$ID] = array_merge($Requests['matches'][$ID], $SQLResult); //We ksort because depending on the filter modes, we're given our data in an unpredictable order //ksort($Requests['matches'][$ID]); @@ -316,24 +316,24 @@ $JsonResults = array(); $TimeCompare = 1267643718; // Requests v2 was implemented 2010-03-03 20:15:18 foreach ($Requests as $RequestID => $Request) { - - //list($BitrateList, $CatalogueNumber, $CategoryID, $Description, $FillerID, $FormatList, $RequestID, $Image, $LogCue, $MediaList, $ReleaseType, - // $Tags, $TimeAdded, $TimeFilled, $Title, $TorrentID, $RequestorID, $RequestorName, $Year, $RequestID, $Categoryid, $FillerID, $LastVote, + + //list($BitrateList, $CatalogueNumber, $CategoryID, $Description, $FillerID, $FormatList, $RequestID, $Image, $LogCue, $MediaList, $ReleaseType, + // $Tags, $TimeAdded, $TimeFilled, $Title, $TorrentID, $RequestorID, $RequestorName, $Year, $RequestID, $Categoryid, $FillerID, $LastVote, // $ReleaseType, $TagIDs, $TimeAdded, $TimeFilled, $TorrentID, $RequestorID, $Voters) = array_values($Request); - - list($RequestID, $RequestorID, $RequestorName, $TimeAdded, $LastVote, $CategoryID, $Title, $Year, $Image, $Description, $CatalogueNumber, + + list($RequestID, $RequestorID, $RequestorName, $TimeAdded, $LastVote, $CategoryID, $Title, $Year, $Image, $Description, $CatalogueNumber, $ReleaseType, $BitrateList, $FormatList, $MediaList, $LogCue, $FillerID, $FillerName, $TorrentID, $TimeFilled) = $Request; - + $RequestVotes = get_votes_array($RequestID); - + $VoteCount = count($RequestVotes['Voters']); - + if($CategoryID == 0) { $CategoryName = "Unknown"; } else { $CategoryName = $Categories[$CategoryID - 1]; } - + $JsonArtists = array(); if($CategoryName == "Music") { $ArtistForm = get_request_artists($RequestID); @@ -341,7 +341,7 @@ } $Tags = $Request['Tags']; - + $JsonResults[] = array( 'requestId' => (int) $RequestID, 'requestorId' => (int) $RequestorID, diff --git a/sections/ajax/takevote.php b/sections/ajax/takevote.php index 81042302..151b7ea3 100644 --- a/sections/ajax/takevote.php +++ b/sections/ajax/takevote.php @@ -24,37 +24,37 @@ die(); } $Type = ($_REQUEST['vote'] == 'up')?"Up":"Down"; - + // Update the two votes tables if needed $DB->query("INSERT IGNORE INTO users_votes (UserID, GroupID, Type) VALUES ($UserID, $GroupID, '$Type')"); if ($DB->affected_rows() == 0) { echo 'noaction'; die(); } - + // Update the group's cache key $GroupVotes['Total'] += 1; if ($Type == "Up") { $GroupVotes['Ups'] += 1; } $Cache->cache_value('votes_'.$GroupID, $GroupVotes); - + // If the group has no votes yet, we need an insert, otherwise an update // so we can cut corners and use the magic of INSERT...ON DUPLICATE KEY UPDATE... // to accomplish both in one query $DB->query("INSERT INTO torrents_votes (GroupID, Total, Ups, Score) VALUES ($GroupID, 1, ".($Type=='Up'?1:0).", 0) - ON DUPLICATE KEY UPDATE Total = Total + 1, + ON DUPLICATE KEY UPDATE Total = Total + 1, Score = IFNULL(binomial_ci(Ups".($Type=='Up'?'+1':'').",Total),0)". ($Type=='Up'?', Ups = Ups+1':'')); - + $UserVotes[$GroupID] = array('GroupID' => $GroupID, 'Type' => $Type); - + // Update this guy's cache key $Cache->cache_value('voted_albums_'.$LoggedUser['ID'], $UserVotes); - + // Update the paired cache keys for "people who liked" - // First update this album's paired votes. If this keys is magically not set, + // First update this album's paired votes. If this keys is magically not set, // our life just got a bit easier. We're only tracking paired votes on upvotes. if ($Type == 'Up') { $VotePairs = $Cache->get_value('vote_pairs_'.$GroupID, true); @@ -108,7 +108,7 @@ } } - + echo 'success'; } elseif ($_REQUEST['do'] == 'unvote') { if (!isset($UserVotes[$GroupID])) { @@ -116,13 +116,13 @@ die(); } $Type = $UserVotes[$GroupID]['Type']; - + $DB->query("DELETE FROM users_votes WHERE UserID=$UserID AND GroupID=$GroupID"); - + // Update personal cache key unset($UserVotes[$GroupID]); $Cache->cache_value('voted_albums_'.$LoggedUser['ID'], $UserVotes); - + // Update the group's cache key $GroupVotes['Total'] -= 1; if ($Type == "Up") { @@ -135,7 +135,7 @@ ($Type=='Up'?', Ups = GREATEST(0, Ups - 1)':'')." WHERE GroupID=$GroupID"); // Update paired cache keys - // First update this album's paired votes. If this keys is magically not set, + // First update this album's paired votes. If this keys is magically not set, // our life just got a bit easier. We're only tracking paired votes on upvotes. if ($Type == 'Up') { $VotePairs = $Cache->get_value('vote_pairs_'.$GroupID, true); @@ -160,7 +160,7 @@ } $Cache->cache_value('vote_pairs_'.$GroupID, $VotePairs); } - + // Now do the paired votes keys for all of this guy's other votes foreach ($UserVotes as $VGID => $Vote) { if ($Vote['Type'] != 'Up') { @@ -190,7 +190,7 @@ } } } - + // Let the script know what happened if ($Type == 'Up') { echo 'success-up'; diff --git a/sections/ajax/torrentgroup.php b/sections/ajax/torrentgroup.php index 95385c1f..631d46d3 100644 --- a/sections/ajax/torrentgroup.php +++ b/sections/ajax/torrentgroup.php @@ -2,7 +2,7 @@ require(SERVER_ROOT.'/sections/torrents/functions.php'); -include(SERVER_ROOT.'/sections/bookmarks/functions.php'); +include(SERVER_ROOT.'/sections/bookmarks/functions.php'); include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class $Text = new TEXT; diff --git a/sections/ajax/upload.php b/sections/ajax/upload.php index d86e24a9..50db2480 100644 --- a/sections/ajax/upload.php +++ b/sections/ajax/upload.php @@ -19,12 +19,12 @@ case 'Music': $TorrentForm->music_form($GenreTags); break; - + case 'Audiobooks': case 'Comedy': $TorrentForm->audiobook_form(); break; - + case 'Applications': case 'Comics': case 'E-Books': diff --git a/sections/ajax/userhistory/post_history.php b/sections/ajax/userhistory/post_history.php index 91465f86..eea19c7d 100644 --- a/sections/ajax/userhistory/post_history.php +++ b/sections/ajax/userhistory/post_history.php @@ -45,7 +45,7 @@ function error_out($reason = "") { FROM users_main AS m JOIN users_info AS i ON i.UserID = m.ID WHERE m.ID = $UserID"); - + if($DB->record_count() == 0){ // If user doesn't exist error_out("User does not exist!"); } @@ -170,22 +170,22 @@ function error_out($reason = "") { $sql.=' AND ((t.IsLocked=\'0\' OR t.IsSticky=\'1\') AND (l.PostIDquery($sql); - + $DB->query("SELECT FOUND_ROWS()"); list($Results) = $DB->next_record(); - + $DB->set_query_id($Posts); } diff --git a/sections/ajax/usersearch.php b/sections/ajax/usersearch.php index 84c980f7..0b6b1566 100644 --- a/sections/ajax/usersearch.php +++ b/sections/ajax/usersearch.php @@ -4,10 +4,10 @@ **********************************************************************/ if (!empty($_GET['search'])) { - + $_GET['username'] = $_GET['search']; } - + define('USERS_PER_PAGE', 30); if(isset($_GET['username'])){ diff --git a/sections/api/access_state.php b/sections/api/access_state.php index b086cda6..d9dbd545 100644 --- a/sections/api/access_state.php +++ b/sections/api/access_state.php @@ -1,6 +1,6 @@ next_record(); if(!empty($Artist2ID)) { // artist was found in the database - + // Let's see if there's already a similar artists field for these two - $DB->query("SELECT - s1.SimilarID + $DB->query("SELECT + s1.SimilarID FROM artists_similar AS s1 JOIN artists_similar AS s2 ON s1.SimilarID=s2.SimilarID WHERE s1.ArtistID='$Artist1ID' AND s2.ArtistID='$Artist2ID'"); list($SimilarID) = $DB->next_record(); - + if($SimilarID){ // The similar artists field already exists, just update the score $DB->query("UPDATE artists_similar_scores SET Score=Score+200 WHERE SimilarID='$SimilarID'"); } else { // No, it doesn't exist - create it @@ -34,12 +34,12 @@ $DB->query("INSERT INTO artists_similar (ArtistID, SimilarID) VALUES ('$Artist1ID', '$SimilarID')"); $DB->query("INSERT INTO artists_similar (ArtistID, SimilarID) VALUES ('$Artist2ID', '$SimilarID')"); } - + $DB->query("SELECT SimilarID FROM artists_similar_votes WHERE SimilarID='$SimilarID' AND UserID='$UserID' AND Way='up'"); if($DB->record_count() == 0) { $DB->query("INSERT INTO artists_similar_votes (SimilarID, UserID, way) VALUES ('$SimilarID', '$UserID', 'up')"); } - + $Cache->delete('artist_'.$Artist1ID); // Delete artist cache $Cache->delete('artist_'.$Artist2ID); // Delete artist cache $Cache->delete('similar_positions_'.$Artist1ID); // Delete artist's similar map cache diff --git a/sections/artist/autocomplete.php b/sections/artist/autocomplete.php index b25a7bb7..24155278 100644 --- a/sections/artist/autocomplete.php +++ b/sections/artist/autocomplete.php @@ -20,16 +20,16 @@ $DB=NEW DB_MYSQL; //Load the database wrapper } $Limit = (($KeySize === $MaxKeySize)?250:10); - $DB->query("SELECT + $DB->query("SELECT a.ArtistID, - a.Name, - SUM(t.Snatched) AS Snatches - FROM artists_group AS a - INNER JOIN torrents_artists AS ta ON ta.ArtistID=a.ArtistID - INNER JOIN torrents AS t ON t.GroupID=ta.GroupID + a.Name, + SUM(t.Snatched) AS Snatches + FROM artists_group AS a + INNER JOIN torrents_artists AS ta ON ta.ArtistID=a.ArtistID + INNER JOIN torrents AS t ON t.GroupID=ta.GroupID WHERE a.Name LIKE '".db_string(str_replace('\\','\\\\',$Letters),true)."%' - GROUP BY ta.ArtistID - ORDER BY Snatches DESC + GROUP BY ta.ArtistID + ORDER BY Snatches DESC LIMIT $Limit"); $AutoSuggest = $DB->to_array(false,MYSQLI_NUM,false); $Cache->cache_value('autocomplete_artist_'.$KeySize.'_'.$Letters,$AutoSuggest,1800+7200*($MaxKeySize-$KeySize)); // Can't cache things for too long in case names are edited diff --git a/sections/artist/change_artistid.php b/sections/artist/change_artistid.php index 131733fe..20bc7a5d 100644 --- a/sections/artist/change_artistid.php +++ b/sections/artist/change_artistid.php @@ -24,13 +24,13 @@ if ($NewArtistID > 0) { // Make sure that's a real artist ID number, and grab the name - $DB->query("SELECT Name FROM artists_group WHERE ArtistID = $NewArtistID LIMIT 1"); + $DB->query("SELECT Name FROM artists_group WHERE ArtistID = $NewArtistID LIMIT 1"); if(!(list($NewArtistName) = $DB->next_record())) { error('Please enter a valid artist ID number.'); } } else { // Didn't give an ID, so try to grab based on the name - $DB->query("SELECT ArtistID FROM artists_alias WHERE Name = '".db_string($NewArtistName)."' LIMIT 1"); + $DB->query("SELECT ArtistID FROM artists_alias WHERE Name = '".db_string($NewArtistName)."' LIMIT 1"); if(!(list($NewArtistID) = $DB->next_record())) { error('No artist by that name was found.'); } @@ -58,23 +58,23 @@ $NewArtistGroups = $DB->collect('GroupID'); $NewArtistGroups[] = '0'; $NewArtistGroups = implode(',',$NewArtistGroups); - + $DB->query("SELECT DISTINCT RequestID FROM requests_artists WHERE ArtistID = $NewArtistID"); $NewArtistRequests = $DB->collect('RequestID'); $NewArtistRequests[] = '0'; $NewArtistRequests = implode(',',$NewArtistRequests); - + $DB->query("SELECT DISTINCT UserID from bookmarks_artists WHERE ArtistID = $NewArtistID"); $NewArtistBookmarks = $DB->collect('UserID'); $NewArtistBookmarks[] = '0'; - $NewArtistBookmarks = implode(',',$NewArtistBookmarks); - + $NewArtistBookmarks = implode(',',$NewArtistBookmarks); + // Merge all of this artist's aliases onto the new artist $DB->query("UPDATE artists_alias SET ArtistID = $NewArtistID WHERE ArtistID = $ArtistID"); - + // Update the torrent groups, requests, and bookmarks $DB->query("UPDATE IGNORE torrents_artists SET ArtistID = $NewArtistID - WHERE ArtistID = $ArtistID + WHERE ArtistID = $ArtistID AND GroupID NOT IN ($NewArtistGroups)"); $DB->query("DELETE FROM torrents_artists WHERE ArtistID = $ArtistID"); $DB->query("UPDATE IGNORE requests_artists SET ArtistID = $NewArtistID @@ -85,7 +85,7 @@ WHERE ArtistID = $ArtistID AND UserID NOT IN ($NewArtistBookmarks)"); $DB->query("DELETE FROM bookmarks_artists WHERE ArtistID = $ArtistID"); - + // Cache clearing if(!empty($Groups)) { foreach($Groups as $GroupID) { diff --git a/sections/artist/delete.php b/sections/artist/delete.php index cb428014..947dcdf5 100644 --- a/sections/artist/delete.php +++ b/sections/artist/delete.php @@ -19,10 +19,10 @@ $DB->query('SELECT Name FROM artists_group WHERE ArtistID='.$ArtistID); list($Name) = $DB->next_record(); -$DB->query('SELECT tg.Name, - tg.ID - FROM torrents_group AS tg - LEFT JOIN torrents_artists AS ta ON ta.GroupID=tg.ID +$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); $Count = $DB->record_count(); if($DB->record_count() > 0) { @@ -47,10 +47,10 @@ query('SELECT r.Title, - r.ID +$DB->query('SELECT r.Title, + r.ID FROM requests AS r - LEFT JOIN requests_artists AS ra ON ra.RequestID=r.ID + LEFT JOIN requests_artists AS ra ON ra.RequestID=r.ID WHERE ra.ArtistID='.$ArtistID); $Count += $DB->record_count(); if($DB->record_count() > 0) { diff --git a/sections/artist/delete_alias.php b/sections/artist/delete_alias.php index 21655132..87457d1c 100644 --- a/sections/artist/delete_alias.php +++ b/sections/artist/delete_alias.php @@ -9,8 +9,8 @@ } $DB->query("SELECT aa.AliasID - FROM artists_alias AS aa - JOIN artists_alias AS aa2 ON aa.ArtistID=aa2.ArtistID + FROM artists_alias AS aa + JOIN artists_alias AS aa2 ON aa.ArtistID=aa2.ArtistID WHERE aa.AliasID=".$AliasID); if($DB->record_count() == 1) { diff --git a/sections/artist/download.php b/sections/artist/download.php index 77bd2152..a4f66c25 100644 --- a/sections/artist/download.php +++ b/sections/artist/download.php @@ -135,8 +135,6 @@ $Collector = new TorrentsDL($DownloadsQ, $ArtistName); while (list($Downloads, $GroupIDs) = $Collector->get_downloads('GroupID')) { - $Debug->log_var($Downloads, '$Downloads'); - $Debug->log_var($GroupIDs, '$GroupIDs'); $Artists = Artists::get_artists($GroupIDs); $TorrentFilesQ = $DB->query("SELECT TorrentID, File FROM torrents_files WHERE TorrentID IN (".implode(',', array_keys($GroupIDs)).")", false); if (is_int($TorrentFilesQ)) { diff --git a/sections/artist/edit.php b/sections/artist/edit.php index f29be3d4..03a749fe 100644 --- a/sections/artist/edit.php +++ b/sections/artist/edit.php @@ -2,10 +2,10 @@ /************************************************************************ ||------------|| Edit artist wiki page ||------------------------------|| -This page is the page that is displayed when someone feels like editing +This page is the page that is displayed when someone feels like editing an artist's wiki page. -It is called when $_GET['action'] == 'edit'. $_GET['artistid'] is the +It is called when $_GET['action'] == 'edit'. $_GET['artistid'] is the ID of the artist, and must be set. ************************************************************************/ @@ -55,7 +55,7 @@
- +

Rename

@@ -67,11 +67,11 @@
- +
- +

Make into non-redirecting alias

@@ -90,14 +90,14 @@
- +

Aliases

    - + query("SELECT AliasID, Name, UserID, Redirect FROM artists_alias WHERE ArtistID='$ArtistID'"); - while(list($AliasID, $AliasName, $User, $Redirect) = $DB->next_record(MYSQLI_NUM, true)) { + while(list($AliasID, $AliasName, $User, $Redirect) = $DB->next_record(MYSQLI_NUM, true)) { if($AliasName == $Name) { $DefaultRedirectID = $AliasID; } ?>
  • . @@ -120,6 +120,6 @@
- + diff --git a/sections/artist/history.php b/sections/artist/history.php index 6d16bb6c..34aa6178 100644 --- a/sections/artist/history.php +++ b/sections/artist/history.php @@ -2,8 +2,8 @@ /************************************************************************ ||------------|| Artist wiki history page ||---------------------------|| -This page lists previous revisions of the artists page. It gets called -if $_GET['action'] == 'history'. +This page lists previous revisions of the artists page. It gets called +if $_GET['action'] == 'history'. It also requires $_GET['artistid']. diff --git a/sections/artist/index.php b/sections/artist/index.php index 05db0939..cc9f608e 100644 --- a/sections/artist/index.php +++ b/sections/artist/index.php @@ -2,11 +2,11 @@ /************************************************************************** Artists Switch Center -This page acts as a switch that includes the real artist pages (to keep +This page acts as a switch that includes the real artist pages (to keep the root less cluttered). -enforce_login() is run here - the entire artist pages are off limits for -non members. +enforce_login() is run here - the entire artist pages are off limits for +non members. ****************************************************************************/ // Width and height of similar artist map diff --git a/sections/artist/rename.php b/sections/artist/rename.php index a010a1ca..9cd0ada5 100644 --- a/sections/artist/rename.php +++ b/sections/artist/rename.php @@ -81,7 +81,7 @@ } else { $DB->query("UPDATE artists_group SET Name='".db_string($NewName)."' WHERE ArtistID='$ArtistID'"); } - + $DB->query("SELECT GroupID FROM torrents_artists WHERE AliasID='$OldAliasID'"); $Groups = $DB->collect('GroupID'); $DB->query("UPDATE IGNORE torrents_artists SET AliasID='$TargetAliasID',ArtistID='$TargetArtistID' WHERE AliasID='$OldAliasID'"); diff --git a/sections/artist/take_warn.php b/sections/artist/take_warn.php index 2e08c035..375805a5 100644 --- a/sections/artist/take_warn.php +++ b/sections/artist/take_warn.php @@ -23,7 +23,7 @@ $Subject = "You have received a warning"; $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; diff --git a/sections/artist/takeedit.php b/sections/artist/takeedit.php index a139e1ec..3e27572d 100644 --- a/sections/artist/takeedit.php +++ b/sections/artist/takeedit.php @@ -1,6 +1,6 @@ query("INSERT INTO wiki_artists (PageID, Body, Image, UserID, Summary, Time) VALUES ('$ArtistID', '$Body', '$Image', '$UserID', '$Summary', '".sqltime()."')"); } else { // revert - $DB->query("INSERT INTO wiki_artists (PageID, Body, Image, UserID, Summary, Time) - SELECT '$ArtistID', Body, Image, '$UserID', 'Reverted to revision $RevisionID', '".sqltime()."' + $DB->query("INSERT INTO wiki_artists (PageID, Body, Image, UserID, Summary, Time) + SELECT '$ArtistID', Body, Image, '$UserID', 'Reverted to revision $RevisionID', '".sqltime()."' FROM wiki_artists WHERE RevisionID='$RevisionID'"); } $RevisionID=$DB->inserted_id(); // Update artists table (technically, we don't need the RevisionID column, but we can use it for a join which is nice and fast) -$DB->query("UPDATE artists_group - SET +$DB->query("UPDATE artists_group + SET ". ( isset($VanityHouse) ? "VanityHouse='$VanityHouse'," : '' ) ." - RevisionID='$RevisionID' + RevisionID='$RevisionID' WHERE ArtistID='$ArtistID'"); // There we go, all done! diff --git a/sections/better/files.php b/sections/better/files.php index f26a6c37..86f9c569 100644 --- a/sections/better/files.php +++ b/sections/better/files.php @@ -1,4 +1,4 @@ -query("DELETE FROM torrents_bad_files WHERE TorrentID = ".$_GET['remove']); @@ -56,12 +56,12 @@ $DisplayName.=''.$GroupName.''; if($GroupYear>0) { $DisplayName.=" [".$GroupYear."]"; } if($ReleaseType>0) { $DisplayName.=" [".$ReleaseTypes[$ReleaseType]."]"; } - + $ExtraInfo = Torrents::torrent_info($Torrents[$TorrentID]); if($ExtraInfo) { $DisplayName.=' - '.$ExtraInfo; } - + $TagList=array(); if($TorrentTags!='') { $TorrentTags=explode(' ',$TorrentTags); diff --git a/sections/better/folders.php b/sections/better/folders.php index c6c88cf6..b069c54f 100644 --- a/sections/better/folders.php +++ b/sections/better/folders.php @@ -1,4 +1,4 @@ -query("DELETE FROM torrents_bad_folders WHERE TorrentID = ".$_GET['remove']); @@ -61,7 +61,7 @@ if($ExtraInfo) { $DisplayName.=' - '.$ExtraInfo; } - + $TagList=array(); if($TorrentTags!='') { $TorrentTags=explode(' ',$TorrentTags); diff --git a/sections/better/index.php b/sections/better/index.php index 0e021cd0..3133fc51 100644 --- a/sections/better/index.php +++ b/sections/better/index.php @@ -15,10 +15,10 @@ break; case 'artistless': include(SERVER_ROOT.'/sections/better/artistless.php'); - break; + break; case 'tags': include(SERVER_ROOT.'/sections/better/tags.php'); - break; + break; case 'folders': include(SERVER_ROOT.'/sections/better/folders.php'); break; diff --git a/sections/better/tags.php b/sections/better/tags.php index 3e4f2458..570158d2 100644 --- a/sections/better/tags.php +++ b/sections/better/tags.php @@ -62,7 +62,7 @@ if($ExtraInfo) { $DisplayName.=' - '.$ExtraInfo; } - + $TagList=array(); if($TorrentTags!='') { $TorrentTags=explode(' ',$TorrentTags); diff --git a/sections/blog/index.php b/sections/blog/index.php index e9b2ec7c..869d990b 100644 --- a/sections/blog/index.php +++ b/sections/blog/index.php @@ -42,7 +42,7 @@ } header('Location: blog.php'); break; - + case 'takenewblog': authorize(); $Title = db_string($_POST['title']); @@ -53,20 +53,20 @@ if($DB->record_count() < 1) { error("No such thread exists!"); header('Location: blog.php'); - } + } } else { $ThreadID = Misc::create_thread(ANNOUNCEMENT_FORUM_ID, $LoggedUser[ID], $Title, $Body); if($ThreadID < 1) { error(0); } } - - $DB->query("INSERT INTO blog (UserID, Title, Body, Time, ThreadID, Important) - VALUES ('".$LoggedUser['ID']."', - '".db_string($_POST['title'])."', - '".db_string($_POST['body'])."', - '".sqltime()."', - ".$ThreadID.", + + $DB->query("INSERT INTO blog (UserID, Title, Body, Time, ThreadID, Important) + VALUES ('".$LoggedUser['ID']."', + '".db_string($_POST['title'])."', + '".db_string($_POST['body'])."', + '".sqltime()."', + ".$ThreadID.", '".(($_POST['important']=='1')?'1':'0')."')"); $Cache->delete_value('blog'); if ($_POST['important']=='1') { @@ -81,7 +81,7 @@ break; } } - + ?>
@@ -91,9 +91,9 @@
- + - +

Title

/>

Body

@@ -113,7 +113,7 @@

-
@@ -147,7 +147,7 @@
- posted by - + - Edit Delete @@ -157,14 +157,14 @@

Discuss this post here - + Remove link

-
diff --git a/sections/bookmarks/functions.php b/sections/bookmarks/functions.php index 81daefb0..33d033e5 100644 --- a/sections/bookmarks/functions.php +++ b/sections/bookmarks/functions.php @@ -19,7 +19,7 @@ function bookmark_schema($Type) { break; case 'request': return array('bookmarks_requests', 'RequestID'); - break; + break; default: die('HAX'); } diff --git a/sections/captcha/index.php b/sections/captcha/index.php index 990ee639..51f9cd89 100644 --- a/sections/captcha/index.php +++ b/sections/captcha/index.php @@ -8,29 +8,29 @@ function get_font() { function make_captcha_img() { global $CaptchaBGs; - + $Length=6; $ImageHeight=75; $ImageWidth=300; - + $Chars='abcdefghjkmprstuvwxyzABCDEFGHJKLMPQRSTUVWXY23456789'; $CaptchaString=''; - + for($i=0;$i<$Length;$i++) { $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]['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); $ForeColor=imagecolorallocatealpha($Img,255,255,255,65); - + for($i=0;$iquery("INSERT INTO collages_comments - (CollageID, Body, UserID, Time) + (CollageID, Body, UserID, Time) VALUES ('$CollageID', '".db_string($_POST['body'])."', '$LoggedUser[ID]', '".sqltime()."')"); diff --git a/sections/collages/add_torrent.php b/sections/collages/add_torrent.php index 07e711a4..2189f996 100644 --- a/sections/collages/add_torrent.php +++ b/sections/collages/add_torrent.php @@ -15,17 +15,17 @@ function AddTorrent($CollageID, $GroupID) { $DB->query("SELECT GroupID FROM collages_torrents WHERE CollageID='$CollageID' AND GroupID='$GroupID'"); if ($DB->record_count() == 0) { $DB->query("INSERT IGNORE INTO collages_torrents - (CollageID, GroupID, UserID, Sort, AddedOn) + (CollageID, GroupID, UserID, Sort, AddedOn) VALUES ('$CollageID', '$GroupID', '$LoggedUser[ID]', '$Sort', NOW())"); - + $DB->query("UPDATE collages SET NumTorrents=NumTorrents+1 WHERE ID='$CollageID'"); $Cache->delete_value('collage_'.$CollageID); $Cache->delete_value('torrents_details_'.$GroupID); $Cache->delete_value('torrent_collages_'.$GroupID); $Cache->delete_value('torrent_collages_personal_'.$GroupID); - + $DB->query("SELECT UserID FROM users_collage_subs WHERE CollageID=$CollageID"); while (list($CacheUserID) = $DB->next_record()) { $Cache->delete_value('collage_subs_user_new_'.$CacheUserID); @@ -88,11 +88,11 @@ function AddTorrent($CollageID, $GroupID) { if (!$GroupID) { error('The torrent was not found in the database.'); } - + AddTorrent($CollageID, $GroupID); } else { $URLRegex = '/^https?:\/\/(www\.|ssl\.)?'.NONSSL_SITE_URL.'\/torrents\.php\?(page=[0-9]+&)?id=([0-9]+)/i'; - + $URLs = explode("\n",$_REQUEST['urls']); $GroupIDs = array(); $Err = ''; @@ -122,20 +122,20 @@ function AddTorrent($CollageID, $GroupID) { $Err = "One of the entered URLs ($URL) does not correspond to a torrent on the site."; break; } - + $DB->query("SELECT ID FROM torrents_group WHERE ID='$GroupID'"); if (!$DB->record_count()) { $Err = "One of the entered URLs ($URL) does not correspond to a torrent on the site."; break; } } - + if ($Err) { error($Err); } foreach ($GroupIDs as $GroupID) { AddTorrent($CollageID, $GroupID); - } + } } header('Location: collages.php?id='.$CollageID); diff --git a/sections/collages/all_comments.php b/sections/collages/all_comments.php index 341be520..ddcd0746 100644 --- a/sections/collages/all_comments.php +++ b/sections/collages/all_comments.php @@ -3,7 +3,7 @@ Things to expect in $_GET: ThreadID: ID of the forum curently being browsed - page: The page the user's on. + page: The page the user's on. page = 1 is the same as no page ********************************************************************************/ @@ -15,7 +15,7 @@ // Check for lame SQL injection attempts $CollageID = $_GET['collageid']; -if(!is_number($CollageID)) { +if(!is_number($CollageID)) { error(0); } @@ -105,7 +105,7 @@ - - +
@@ -222,12 +222,12 @@ New collage -query("SELECT ID FROM collages WHERE UserID='$LoggedUser[ID]' AND CategoryID='0' AND Deleted='0'"); $CollageCount = $DB->record_count(); - + if ($CollageCount == 1) { list($CollageID) = $DB->next_record(); ?> @@ -235,7 +235,7 @@ 1) { ?> Personal collages Subscribed collages @@ -296,7 +296,7 @@ $Tags[]=''.$Tag.''; } $Tags = implode(', ', $Tags); - + //Print results ?> @@ -309,7 +309,7 @@ Remove bookmark -
diff --git a/sections/collages/delete.php b/sections/collages/delete.php index 7fc6c54c..dd957c6f 100644 --- a/sections/collages/delete.php +++ b/sections/collages/delete.php @@ -1,8 +1,8 @@ query("SELECT Name, UserID FROM collages WHERE ID='$CollageID'"); diff --git a/sections/collages/get_post.php b/sections/collages/get_post.php index f1dfd7be..a250d502 100644 --- a/sections/collages/get_post.php +++ b/sections/collages/get_post.php @@ -2,10 +2,10 @@ /*********************************************************************\ //--------------Get Post--------------------------------------------// -This gets the raw BBCode of a post. It's used for editing and -quoting posts. +This gets the raw BBCode of a post. It's used for editing and +quoting posts. -It gets called if $_GET['action'] == 'get_post'. It requires +It gets called if $_GET['action'] == 'get_post'. It requires $_GET['post'], which is the ID of the post. \*********************************************************************/ @@ -18,10 +18,10 @@ // Variables for database input $PostID = $_GET['post']; -// Mainly +// Mainly $DB->query("SELECT Body FROM collages_comments WHERE ID='$PostID'"); list($Body) = $DB->next_record(MYSQLI_NUM); -// This gets sent to the browser, which echoes it wherever +// This gets sent to the browser, which echoes it wherever echo trim($Body); diff --git a/sections/collages/index.php b/sections/collages/index.php index 48f4979f..51ff1116 100644 --- a/sections/collages/index.php +++ b/sections/collages/index.php @@ -66,11 +66,11 @@ if(!check_perms('site_collages_personal')) { error(403); } - + $DB->query("SELECT COUNT(ID) FROM collages WHERE UserID='$LoggedUser[ID]' AND CategoryID='0' AND Deleted='0'"); list($CollageCount) = $DB->next_record(); - - if($CollageCount >= $LoggedUser['Permissions']['MaxCollages']) { + + if($CollageCount >= $LoggedUser['Permissions']['MaxCollages']) { list($CollageID) = $DB->next_record(); header('Location: collage.php?id='.$CollageID); die(); diff --git a/sections/collages/manage_handle.php b/sections/collages/manage_handle.php index b2aff75a..9c66716d 100644 --- a/sections/collages/manage_handle.php +++ b/sections/collages/manage_handle.php @@ -44,6 +44,6 @@ if(!is_number($Sort)) { error(404); } $DB->query("UPDATE collages_torrents SET Sort='$Sort' WHERE CollageID='$CollageID' AND GroupID='$GroupID'"); } - + $Cache->delete_value('collage_'.$CollageID); header('Location: collages.php?action=manage&collageid='.$CollageID); diff --git a/sections/collages/new.php b/sections/collages/new.php index 101e3344..80cbba90 100644 --- a/sections/collages/new.php +++ b/sections/collages/new.php @@ -38,10 +38,10 @@
    -
  • Theme - A collage containing releases that all relate to a certain theme (e.g. "Searching for the Perfect Beat", "Concept Albums", "Funky Groove", etc.).
  • +
  • Theme - A collage containing releases that all relate to a certain theme (e.g. "Searching for the Perfect Beat", "Concept Albums", "Funky Groove", etc.).
  • Genre introduction - A subjective introduction to a genre composed by our own users.
  • Discography - A collage containing all the releases of an artist. Useful for keeping track of side-projects.
  • Label - A collage containing all the releases of a particular record label.
  • @@ -58,8 +58,8 @@
  • Charts - Contains all the releases that comprise a certain type of chart (e.g. Billboard Top 100, Pitchfork Top 100, What.cd Top 10, etc.).
  • -
  • Personal - You can put whatever you want here. It's your own personal collage.
  • - +
  • Personal - You can put whatever you want here. It's your own personal collage.
  • +
diff --git a/sections/collages/new_handle.php b/sections/collages/new_handle.php index b2f945ad..a01768a3 100644 --- a/sections/collages/new_handle.php +++ b/sections/collages/new_handle.php @@ -70,8 +70,8 @@ } $TagList = implode(' ',$TagList); -$DB->query("INSERT INTO collages - (Name, Description, UserID, TagList, CategoryID) +$DB->query("INSERT INTO collages + (Name, Description, UserID, TagList, CategoryID) VALUES ('$P[name]', '$P[description]', $LoggedUser[ID], '$TagList', '$P[category]')"); diff --git a/sections/collages/take_delete.php b/sections/collages/take_delete.php index 6f5824bd..345ab93f 100644 --- a/sections/collages/take_delete.php +++ b/sections/collages/take_delete.php @@ -3,8 +3,8 @@ $CollageID = $_POST['collageid']; -if(!is_number($CollageID) || !$CollageID) { - error(404); +if(!is_number($CollageID) || !$CollageID) { + error(404); } $DB->query("SELECT Name, CategoryID, UserID FROM collages WHERE ID='$CollageID'"); diff --git a/sections/collages/takeedit_comment.php b/sections/collages/takeedit_comment.php index b0a620c7..5ac8618e 100644 --- a/sections/collages/takeedit_comment.php +++ b/sections/collages/takeedit_comment.php @@ -15,7 +15,7 @@ $Body = db_string(urldecode($_POST['body'])); $PostID = $_POST['post']; -// Mainly +// Mainly $DB->query("SELECT cc.Body, cc.UserID, cc.CollageID, (SELECT COUNT(ID) FROM collages_comments WHERE ID <= ".$PostID." AND collages_comments.CollageID = cc.CollageID) FROM collages_comments AS cc WHERE cc.ID='$PostID'"); list($OldBody, $AuthorID, $CollageID, $PostNum) = $DB->next_record(); diff --git a/sections/comments/artistcomments.php b/sections/comments/artistcomments.php index 6986c8c5..69126b32 100644 --- a/sections/comments/artistcomments.php +++ b/sections/comments/artistcomments.php @@ -47,7 +47,7 @@
-
+ @@ -62,7 +62,7 @@ } /* end while loop*/ ?> -" . Users::format_username($UserID, true, true, true, true, false) . " " + $postheader = "by " . Users::format_username($UserID, true, true, true, true, false) . " " . time_diff($AddedTime) . $postheader; ?> @@ -44,7 +44,7 @@ function comment_body($UserID, $PostID, $postheader, $permalink, $Body, $EditorI - full_format($Body) ?> + full_format($Body) ?>

Last edited by @@ -53,4 +53,4 @@ function comment_body($UserID, $PostID, $postheader, $permalink, $Body, $EditorI -update_row(false, array('Invites' => $Invites)); $Cache->commit_transaction(0); Misc::send_pm($_POST['custom'],0,db_string('Notice of donation failure'),db_string('PapPal has just notified us that the donation you sent from '.$_POST['payer_email'].' of '.$TotalDonated.' '.PAYPAL_CURRENCY.' at '.$DonationTime.' UTC has been revoked. Because of this your special privileges have been revoked, and your invites removed.'),''); - - + + send_irc("PRIVMSG ".BOT_REPORT_CHAN." :".$Message); } } } - $DB->query("UPDATE users_info - SET + $DB->query("UPDATE users_info + SET AdminComment=CONCAT('".sqltime()." - User donated ".db_string($_POST['mc_gross'])." ".db_string(PAYPAL_CURRENCY)." from ".db_string($_POST['payer_email']).".\n',AdminComment) WHERE UserID='".$_POST['custom']."'"); $DB->query("INSERT INTO donations diff --git a/sections/feeds/index.php b/sections/feeds/index.php index d194a129..c84ff8b3 100644 --- a/sections/feeds/index.php +++ b/sections/feeds/index.php @@ -1,14 +1,14 @@ open_feed(); switch($_GET['feed']) { - case 'feed_news': + case 'feed_news': include(SERVER_ROOT.'/classes/class_text.php'); $Text = new TEXT; $Feed->channel('News', 'RSS feed for site news.'); @@ -71,7 +71,7 @@ } } break; - case 'feed_blog': + case 'feed_blog': include(SERVER_ROOT.'/classes/class_text.php'); $Text = new TEXT; $Feed->channel('Blog', 'RSS feed for site blog.'); @@ -100,75 +100,75 @@ } } break; - case 'torrents_all': + case 'torrents_all': $Feed->channel('All Torrents', 'RSS feed for all new torrent uploads.'); $Feed->retrieve('torrents_all',$_GET['authkey'],$_GET['passkey']); break; - case 'torrents_music': + case 'torrents_music': $Feed->channel('Music Torrents', 'RSS feed for all new music torrents.'); - $Feed->retrieve('torrents_music',$_GET['authkey'],$_GET['passkey']); + $Feed->retrieve('torrents_music',$_GET['authkey'],$_GET['passkey']); break; - case 'torrents_apps': + case 'torrents_apps': $Feed->channel('Application Torrents', 'RSS feed for all new application torrents.'); - $Feed->retrieve('torrents_apps',$_GET['authkey'],$_GET['passkey']); + $Feed->retrieve('torrents_apps',$_GET['authkey'],$_GET['passkey']); break; - case 'torrents_ebooks': + case 'torrents_ebooks': $Feed->channel('E-Book Torrents', 'RSS feed for all new e-book torrents.'); - $Feed->retrieve('torrents_ebooks',$_GET['authkey'],$_GET['passkey']); + $Feed->retrieve('torrents_ebooks',$_GET['authkey'],$_GET['passkey']); break; - case 'torrents_abooks': + case 'torrents_abooks': $Feed->channel('Audiobook Torrents', 'RSS feed for all new audiobook torrents.'); - $Feed->retrieve('torrents_abooks',$_GET['authkey'],$_GET['passkey']); + $Feed->retrieve('torrents_abooks',$_GET['authkey'],$_GET['passkey']); break; - case 'torrents_evids': + case 'torrents_evids': $Feed->channel('E-Learning Video Torrents', 'RSS feed for all new e-learning video torrents.'); - $Feed->retrieve('torrents_evids',$_GET['authkey'],$_GET['passkey']); + $Feed->retrieve('torrents_evids',$_GET['authkey'],$_GET['passkey']); break; - case 'torrents_comedy': + case 'torrents_comedy': $Feed->channel('Comedy Torrents', 'RSS feed for all new comedy torrents.'); - $Feed->retrieve('torrents_comedy',$_GET['authkey'],$_GET['passkey']); + $Feed->retrieve('torrents_comedy',$_GET['authkey'],$_GET['passkey']); break; - case 'torrents_comics': + case 'torrents_comics': $Feed->channel('Comic Torrents', 'RSS feed for all new comic torrents.'); - $Feed->retrieve('torrents_comics',$_GET['authkey'],$_GET['passkey']); + $Feed->retrieve('torrents_comics',$_GET['authkey'],$_GET['passkey']); break; - case 'torrents_mp3': + case 'torrents_mp3': $Feed->channel('MP3 Torrents', 'RSS feed for all new mp3 torrents.'); - $Feed->retrieve('torrents_mp3',$_GET['authkey'],$_GET['passkey']); + $Feed->retrieve('torrents_mp3',$_GET['authkey'],$_GET['passkey']); break; - case 'torrents_flac': + case 'torrents_flac': $Feed->channel('FLAC Torrents', 'RSS feed for all new FLAC torrents.'); - $Feed->retrieve('torrents_flac',$_GET['authkey'],$_GET['passkey']); + $Feed->retrieve('torrents_flac',$_GET['authkey'],$_GET['passkey']); break; - case 'torrents_vinyl': + case 'torrents_vinyl': $Feed->channel('Vinyl Sourced Torrents', 'RSS feed for all new vinyl sourced torrents.'); - $Feed->retrieve('torrents_vinyl',$_GET['authkey'],$_GET['passkey']); + $Feed->retrieve('torrents_vinyl',$_GET['authkey'],$_GET['passkey']); break; - case 'torrents_lossless': + case 'torrents_lossless': $Feed->channel('Lossless Torrents', 'RSS feed for all new lossless uploads.'); - $Feed->retrieve('torrents_lossless',$_GET['authkey'],$_GET['passkey']); + $Feed->retrieve('torrents_lossless',$_GET['authkey'],$_GET['passkey']); break; - case 'torrents_lossless24': + case 'torrents_lossless24': $Feed->channel('24bit Lossless Torrents', 'RSS feed for all new 24bit uploads.'); - $Feed->retrieve('torrents_lossless24',$_GET['authkey'],$_GET['passkey']); + $Feed->retrieve('torrents_lossless24',$_GET['authkey'],$_GET['passkey']); break; default: // Personalized torrents if(empty($_GET['name']) && substr($_GET['feed'], 0, 16) == 'torrents_notify_'){ // All personalized torrent notifications $Feed->channel('Personalized torrent notifications', 'RSS feed for personalized torrent notifications.'); - $Feed->retrieve($_GET['feed'],$_GET['authkey'],$_GET['passkey']); + $Feed->retrieve($_GET['feed'],$_GET['authkey'],$_GET['passkey']); } elseif(!empty($_GET['name']) && substr($_GET['feed'], 0, 16) == 'torrents_notify_'){ // Specific personalized torrent notification channel $Feed->channel(display_str($_GET['name']), 'Personal RSS feed: '.display_str($_GET['name'])); - $Feed->retrieve($_GET['feed'],$_GET['authkey'],$_GET['passkey']); + $Feed->retrieve($_GET['feed'],$_GET['authkey'],$_GET['passkey']); } elseif(!empty($_GET['name']) && substr($_GET['feed'], 0, 21) == 'torrents_bookmarks_t_') { // Bookmarks $Feed->channel('Bookmarked torrent notifications', 'RSS feed for bookmarked torrents.'); - $Feed->retrieve($_GET['feed'],$_GET['authkey'],$_GET['passkey']); + $Feed->retrieve($_GET['feed'],$_GET['authkey'],$_GET['passkey']); } else { $Feed->channel('All Torrents', 'RSS feed for all new torrent uploads.'); - $Feed->retrieve('torrents_all',$_GET['authkey'],$_GET['passkey']); + $Feed->retrieve('torrents_all',$_GET['authkey'],$_GET['passkey']); } } $Feed->close_feed(); diff --git a/sections/forums/ajax_get_edit.php b/sections/forums/ajax_get_edit.php index 856aea61..23249268 100644 --- a/sections/forums/ajax_get_edit.php +++ b/sections/forums/ajax_get_edit.php @@ -26,13 +26,13 @@ $Edits = $Cache->get_value($Type.'_edits_'.$PostID); if(!is_array($Edits)) { $DB->query("SELECT ce.EditUser, ce.EditTime, ce.Body - FROM comments_edits AS ce + FROM comments_edits AS ce WHERE Page = '".$Type."' AND PostID = ".$PostID." ORDER BY ce.EditTime DESC"); $Edits = $DB->to_array(); $Cache->cache_value($Type.'_edits_'.$PostID, $Edits, 0); } - + list($UserID, $Time) = $Edits[$Depth]; if($Depth != 0) { list(,,$Body) = $Edits[$Depth - 1]; diff --git a/sections/forums/change_vote.php b/sections/forums/change_vote.php index 5dd8783b..1e9ee145 100644 --- a/sections/forums/change_vote.php +++ b/sections/forums/change_vote.php @@ -16,7 +16,7 @@ $DB->query("UPDATE forums_polls_votes SET Vote = ".$NewVote." WHERE TopicID = ".$ThreadID." AND UserID = ".$LoggedUser['ID']); $Cache->delete_value('polls_'.$ThreadID); header("Location: forums.php?action=viewthread&threadid=".$ThreadID); - + } else { error(404); } diff --git a/sections/forums/delete.php b/sections/forums/delete.php index 610dccd4..f2237c73 100644 --- a/sections/forums/delete.php +++ b/sections/forums/delete.php @@ -10,7 +10,7 @@ } // Get topicid, forumid, number of pages -$DB->query("SELECT +$DB->query("SELECT TopicID, ForumID, CEIL(COUNT(p.ID)/".POSTS_PER_PAGE.") AS Pages, diff --git a/sections/forums/delete_poll_option.php b/sections/forums/delete_poll_option.php index e67a971a..9edb7c11 100644 --- a/sections/forums/delete_poll_option.php +++ b/sections/forums/delete_poll_option.php @@ -29,7 +29,7 @@ $Cache->delete_value('polls_'.$ThreadID); header("Location: forums.php?action=viewthread&threadid=".$ThreadID); - + } else { error(404); } diff --git a/sections/forums/forum.php b/sections/forums/forum.php index a6095837..02a5aac7 100644 --- a/sections/forums/forum.php +++ b/sections/forums/forum.php @@ -53,7 +53,7 @@ list($Stickies) = $DB->next_record(); $Cache->cache_value('forums_'.$ForumID, array($Forum,'',0,$Stickies), 0); } -} +} if(!isset($Forums[$ForumID])) { error(404); } @@ -79,7 +79,7 @@

Search this forum:

- +
@@ -111,17 +111,17 @@
- -query("SELECT ForumID from subscribed_forums WHERE ForumID='$ForumID' AND SubscriberID='$LoggedUser[ID]'"); if($DB->record_count() == 0) { ?> Subscribe to forum - +Unsubscribe from forum - diff --git a/sections/forums/get_post.php b/sections/forums/get_post.php index 496efd44..2ab8fc18 100644 --- a/sections/forums/get_post.php +++ b/sections/forums/get_post.php @@ -3,10 +3,10 @@ /*********************************************************************\ //--------------Get Post--------------------------------------------// -This gets the raw BBCode of a post. It's used for editing and -quoting posts. +This gets the raw BBCode of a post. It's used for editing and +quoting posts. -It gets called if $_GET['action'] == 'get_post'. It requires +It gets called if $_GET['action'] == 'get_post'. It requires $_GET['post'], which is the ID of the post. \*********************************************************************/ @@ -19,7 +19,7 @@ // Variables for database input $PostID = $_GET['post']; -// Mainly +// Mainly $DB->query("SELECT p.Body, t.ForumID FROM forums_posts as p JOIN forums_topics as t on p.TopicID = t.ID @@ -31,7 +31,7 @@ error(0); } -// This gets sent to the browser, which echoes it wherever +// This gets sent to the browser, which echoes it wherever echo trim($Body); diff --git a/sections/forums/index.php b/sections/forums/index.php index 7dd4f73b..d4f57b16 100644 --- a/sections/forums/index.php +++ b/sections/forums/index.php @@ -93,7 +93,7 @@ break; case 'viewthread': case 'viewtopic': - // Page that displays threads + // Page that displays threads require(SERVER_ROOT.'/sections/forums/thread.php'); break; case 'ajax_get_edit': diff --git a/sections/forums/mod_thread.php b/sections/forums/mod_thread.php index 4c736f49..3f4549a2 100644 --- a/sections/forums/mod_thread.php +++ b/sections/forums/mod_thread.php @@ -2,11 +2,11 @@ /*********************************************************************\ //--------------Mod thread-------------------------------------------// -This page gets called if we're editing a thread. +This page gets called if we're editing a thread. Known issues: -If multiple threads are moved before forum activity occurs then -threads will linger with the 'Moved' flag until they're knocked off +If multiple threads are moved before forum activity occurs then +threads will linger with the 'Moved' flag until they're knocked off the front page. \*********************************************************************/ @@ -58,37 +58,37 @@ if(check_perms('site_admin_forums')) { $DB->query("DELETE FROM forums_posts WHERE TopicID='$TopicID'"); $DB->query("DELETE FROM forums_topics WHERE ID='$TopicID'"); - - $DB->query("SELECT + + $DB->query("SELECT t.ID, t.LastPostID, t.Title, p.AuthorID, um.Username, - p.AddedTime, + p.AddedTime, (SELECT COUNT(pp.ID) FROM forums_posts AS pp JOIN forums_topics AS tt ON pp.TopicID=tt.ID WHERE tt.ForumID='$ForumID'), t.IsLocked, t.IsSticky - FROM forums_topics AS t - JOIN forums_posts AS p ON p.ID=t.LastPostID + FROM forums_topics AS t + JOIN forums_posts AS p ON p.ID=t.LastPostID LEFT JOIN users_main AS um ON um.ID=p.AuthorID WHERE t.ForumID='$ForumID' GROUP BY t.ID ORDER BY t.LastPostID DESC LIMIT 1"); list($NewLastTopic, $NewLastPostID, $NewLastTitle, $NewLastAuthorID, $NewLastAuthorName, $NewLastAddedTime, $NumPosts, $NewLocked, $NewSticky) = $DB->next_record(MYSQLI_NUM, false); - - $DB->query("UPDATE forums SET - NumTopics=NumTopics-1, + + $DB->query("UPDATE forums SET + NumTopics=NumTopics-1, NumPosts=NumPosts-'$Posts', LastPostTopicID='$NewLastTopic', LastPostID='$NewLastPostID', LastPostAuthorID='$NewLastAuthorID', LastPostTime='$NewLastAddedTime' WHERE ID='$ForumID'"); - + $Cache->delete('thread_'.$TopicID); - - + + $Cache->begin_transaction('forums_list'); $UpdateArray = array( 'NumPosts'=>$NumPosts, @@ -101,7 +101,7 @@ 'IsLocked'=>$NewLocked, 'IsSticky'=>$NewSticky ); - + $Cache->update_row($ForumID, $UpdateArray); $Cache->commit_transaction(0); $Cache->delete_value('thread_'.$TopicID.'_info'); @@ -122,17 +122,17 @@ ); $Cache->update_row(false, $UpdateArray); $Cache->commit_transaction(0); - + $DB->query("UPDATE forums_topics SET IsSticky = '$Sticky', IsLocked = '$Locked', Title = '$Title', - ForumID ='$ForumID' + ForumID ='$ForumID' WHERE ID='$TopicID'"); - - + + if($ForumID!=$OldForumID) { // If we're moving a thread, change the forum stats - + $DB->query("SELECT MinClassRead, MinClassWrite, Name FROM forums WHERE ID='$ForumID'"); list($MinClassRead, $MinClassWrite, $ForumName) = $DB->next_record(MYSQLI_NUM, false); $Cache->begin_transaction('thread_'.$TopicID.'_info'); @@ -143,38 +143,38 @@ ); $Cache->update_row(false, $UpdateArray); $Cache->commit_transaction(3600*24*5); - + $Cache->begin_transaction('forums_list'); - - + + // Forum we're moving from - $DB->query("SELECT + $DB->query("SELECT t.ID, t.LastPostID, t.Title, p.AuthorID, um.Username, - p.AddedTime, + p.AddedTime, (SELECT COUNT(pp.ID) FROM forums_posts AS pp JOIN forums_topics AS tt ON pp.TopicID=tt.ID WHERE tt.ForumID='$OldForumID'), t.IsLocked, t.IsSticky - FROM forums_topics AS t - JOIN forums_posts AS p ON p.ID=t.LastPostID + FROM forums_topics AS t + JOIN forums_posts AS p ON p.ID=t.LastPostID LEFT JOIN users_main AS um ON um.ID=p.AuthorID WHERE t.ForumID='$OldForumID' ORDER BY t.LastPostID DESC LIMIT 1"); list($NewLastTopic, $NewLastPostID, $NewLastTitle, $NewLastAuthorID, $NewLastAuthorName, $NewLastAddedTime, $NumPosts, $NewLocked, $NewSticky) = $DB->next_record(MYSQLI_NUM, false); - - $DB->query("UPDATE forums SET - NumTopics=NumTopics-1, + + $DB->query("UPDATE forums SET + NumTopics=NumTopics-1, NumPosts=NumPosts-'$Posts', LastPostTopicID='$NewLastTopic', LastPostID='$NewLastPostID', LastPostAuthorID='$NewLastAuthorID', LastPostTime='$NewLastAddedTime' WHERE ID='$OldForumID'"); - - + + $UpdateArray = array( 'NumPosts'=>$NumPosts, 'NumTopics'=>'-1', @@ -186,37 +186,37 @@ 'IsLocked'=>$NewLocked, 'IsSticky'=>$NewSticky ); - - + + $Cache->update_row($OldForumID, $UpdateArray); // Forum we're moving to - - $DB->query("SELECT + + $DB->query("SELECT t.ID, t.LastPostID, t.Title, p.AuthorID, um.Username, - p.AddedTime, + p.AddedTime, (SELECT COUNT(pp.ID) FROM forums_posts AS pp JOIN forums_topics AS tt ON pp.TopicID=tt.ID WHERE tt.ForumID='$ForumID') - FROM forums_topics AS t - JOIN forums_posts AS p ON p.ID=t.LastPostID + FROM forums_topics AS t + JOIN forums_posts AS p ON p.ID=t.LastPostID LEFT JOIN users_main AS um ON um.ID=p.AuthorID WHERE t.ForumID='$ForumID' ORDER BY t.LastPostID DESC LIMIT 1"); list($NewLastTopic, $NewLastPostID, $NewLastTitle, $NewLastAuthorID, $NewLastAuthorName, $NewLastAddedTime, $NumPosts) = $DB->next_record(MYSQLI_NUM, false); - - $DB->query("UPDATE forums SET - NumTopics=NumTopics+1, + + $DB->query("UPDATE forums SET + NumTopics=NumTopics+1, NumPosts=NumPosts+'$Posts', LastPostTopicID='$NewLastTopic', LastPostID='$NewLastPostID', LastPostAuthorID='$NewLastAuthorID', LastPostTime='$NewLastAddedTime' WHERE ID='$ForumID'"); - - + + $UpdateArray = array( 'NumPosts'=>($NumPosts+$Posts), 'NumTopics'=>'+1', @@ -226,12 +226,12 @@ 'LastPostTime'=>$NewLastAddedTime, 'Title'=>$NewLastTitle ); - - + + $Cache->update_row($ForumID, $UpdateArray); - + $Cache->commit_transaction(0); - } else { // Editing + } else { // Editing $DB->query("SELECT LastPostTopicID FROM forums WHERE ID='$ForumID'"); list($LastTopicID) = $DB->next_record(); if($LastTopicID == $TopicID) { @@ -251,7 +251,7 @@ $Cache->expire_value('thread_'.$TopicID.'_catalogue_'.$i,3600*24*7); } $Cache->expire_value('thread_'.$TopicID.'_info',3600*24*7); - + $DB->query('UPDATE forums_polls SET Closed=\'0\' WHERE TopicID=\''.$TopicID.'\''); $Cache->delete_value('polls_'.$TopicID); } diff --git a/sections/forums/poll_mod.php b/sections/forums/poll_mod.php index df05a6e0..29358719 100644 --- a/sections/forums/poll_mod.php +++ b/sections/forums/poll_mod.php @@ -12,13 +12,13 @@ $Answers = unserialize($Answers); $DB->query("SELECT Vote, COUNT(UserID) FROM forums_polls_votes WHERE TopicID='$TopicID' AND Vote <> '0' GROUP BY Vote"); $VoteArray = $DB->to_array(false, MYSQLI_NUM); - + $Votes = array(); foreach ($VoteArray as $VoteSet) { - list($Key,$Value) = $VoteSet; + list($Key,$Value) = $VoteSet; $Votes[$Key] = $Value; } - + for ($i = 1, $il = count($Answers); $i <= $il; ++$i) { if (!isset($Votes[$i])) { $Votes[$i] = 0; diff --git a/sections/forums/poll_vote.php b/sections/forums/poll_vote.php index b5ae338b..9be170f6 100644 --- a/sections/forums/poll_vote.php +++ b/sections/forums/poll_vote.php @@ -37,13 +37,13 @@ $Answers = unserialize($Answers); $DB->query("SELECT Vote, COUNT(UserID) FROM forums_polls_votes WHERE TopicID='$TopicID' AND Vote <> '0' GROUP BY Vote"); $VoteArray = $DB->to_array(false, MYSQLI_NUM); - + $Votes = array(); foreach ($VoteArray as $VoteSet) { - list($Key,$Value) = $VoteSet; + list($Key,$Value) = $VoteSet; $Votes[$Key] = $Value; } - + for ($i = 1, $il = count($Answers); $i <= $il; ++$i) { if (!isset($Votes[$i])) { $Votes[$i] = 0; @@ -112,7 +112,7 @@ } else { $Ratio=0; $Percent=0; - } + } ?>
  • (%)
  • @@ -123,13 +123,13 @@ query("SELECT GROUP_CONCAT(um.Username SEPARATOR ', '), - fpv.Vote - FROM users_main AS um + $DB->query("SELECT GROUP_CONCAT(um.Username SEPARATOR ', '), + fpv.Vote + FROM users_main AS um JOIN forums_polls_votes AS fpv ON um.ID = fpv.UserID WHERE TopicID = ".$TopicID." GROUP BY fpv.Vote"); - + $StaffVotes = $DB->to_array(); foreach($StaffVotes as $StaffVote) { list($StaffString, $StaffVoted) = $StaffVote; diff --git a/sections/forums/quote_notify.php b/sections/forums/quote_notify.php index b617042b..8638739f 100644 --- a/sections/forums/quote_notify.php +++ b/sections/forums/quote_notify.php @@ -36,7 +36,7 @@ $ForumID = db_string($ForumID); $TopicID = db_string($TopicID); $PostID = db_string($PostID); - + $DB->query("INSERT IGNORE INTO users_notify_quoted (UserID, QuoterID, ForumID, TopicID, PostID, Date) VALUES ('$UserID', '$QuoterID', '$ForumID', '$TopicID', '$PostID', '" . sqltime() . "')"); $Cache->delete_value('forums_quotes_' . $UserID); diff --git a/sections/forums/search.php b/sections/forums/search.php index 8e5d8393..69f3cc95 100644 --- a/sections/forums/search.php +++ b/sections/forums/search.php @@ -61,7 +61,7 @@ if (!empty($_GET['threadid']) && is_number($_GET['threadid'])) { $ThreadID = $_GET['threadid']; $Type = 'body'; - $SQL = "SELECT Title FROM forums_topics AS t + $SQL = "SELECT Title FROM forums_topics AS t JOIN forums AS f ON f.ID=t.ForumID WHERE t.ID=$ThreadID AND ((f.MinClassRead <= '$LoggedUser[Class]'"; @@ -98,13 +98,13 @@ +if (empty($ThreadID)) { ?>
  • @@ -112,8 +112,8 @@
    @@ -93,9 +93,9 @@
    Search in: - + - +
    Search in: - /> + /> - /> + />
    Forums: - - + + - - -
    +
    - +
    diff --git a/sections/inbox/conversation.php b/sections/inbox/conversation.php index 32f8a0e3..210560ab 100644 --- a/sections/inbox/conversation.php +++ b/sections/inbox/conversation.php @@ -95,7 +95,7 @@
    - +
    diff --git a/sections/inbox/get_post.php b/sections/inbox/get_post.php index 2f74b74f..520619e5 100644 --- a/sections/inbox/get_post.php +++ b/sections/inbox/get_post.php @@ -3,10 +3,10 @@ /*********************************************************************\ //--------------Get Post--------------------------------------------// -This gets the raw BBCode of a post. It's used for editing and -quoting posts. +This gets the raw BBCode of a post. It's used for editing and +quoting posts. -It gets called if $_GET['action'] == 'get_post'. It requires +It gets called if $_GET['action'] == 'get_post'. It requires $_GET['post'], which is the ID of the post. \*********************************************************************/ @@ -23,12 +23,12 @@ $DB->query("SELECT m.Body FROM pm_messages as m - JOIN pm_conversations_users AS u ON m.ConvID=u.ConvID + JOIN pm_conversations_users AS u ON m.ConvID=u.ConvID WHERE m.ID='$PostID' AND u.UserID=".$LoggedUser['ID']); list($Body) = $DB->next_record(MYSQLI_NUM); -// This gets sent to the browser, which echoes it wherever +// This gets sent to the browser, which echoes it wherever echo trim($Body); diff --git a/sections/inbox/index.php b/sections/inbox/index.php index 8c6f4b90..b07e2566 100644 --- a/sections/inbox/index.php +++ b/sections/inbox/index.php @@ -33,7 +33,7 @@ break; case 'get_post': require('get_post.php'); - break; + break; case 'forward': require('forward.php'); break; diff --git a/sections/index/feat_album.php b/sections/index/feat_album.php index 63063e75..c1888b22 100644 --- a/sections/index/feat_album.php +++ b/sections/index/feat_album.php @@ -15,5 +15,5 @@ \ No newline at end of file diff --git a/sections/login/index.php b/sections/login/index.php index 0573641d..1dbc6e18 100644 --- a/sections/login/index.php +++ b/sections/login/index.php @@ -30,15 +30,15 @@ // Recover password if (!empty($_REQUEST['key'])) { // User has entered a new password, use step 2 - $DB->query("SELECT + $DB->query("SELECT m.ID, m.Email, 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'])."' - AND i.ResetKey<>'' + 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'])."' + AND i.ResetKey<>'' AND m.Enabled='1'"); list($UserID,$Email,$Country,$Expires)=$DB->next_record(); @@ -48,38 +48,38 @@ $Validate->SetFields('verifypassword','1','compare','Your passwords did not match.',array('comparefield'=>'password')); if (!empty($_REQUEST['password'])) { - // If the user has entered a password. + // If the user has entered a password. // If the user has not entered a password, $Reset is not set to 1, and the success message is not shown $Err=$Validate->ValidateForm($_REQUEST); if ($Err=='') { - // Form validates without error, set new secret and password. - $DB->query("UPDATE + // Form validates without error, set new secret and password. + $DB->query("UPDATE users_main AS m, - users_info AS i + 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)."' + 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 - + } } - + // Either a form asking for them to enter the password // Or a success message if $Reset is 1 require('recover_step2.php'); } else { // Either his key has expired, or he hasn't requested a pass change at all - + if (strtotime($Expires)query("UPDATE - users_info + $DB->query("UPDATE + users_info SET ResetKey='', - ResetExpires='0000-00-00 00:00:00' + 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 } @@ -88,7 +88,7 @@ } } // End step 2 - + // User has not clicked the link in his email, use step 1 else { $Validate->SetFields('email','1','email','You entered an invalid email address.'); @@ -99,12 +99,12 @@ if (!$Err) { // Form validates correctly - $DB->query("SELECT + $DB->query("SELECT ID, Username, - Email - FROM users_main - WHERE Email='".db_string($_REQUEST['email'])."' + Email + FROM users_main + WHERE Email='".db_string($_REQUEST['email'])."' AND Enabled='1'"); list($UserID,$Username,$Email)=$DB->next_record(); @@ -112,15 +112,15 @@ // Email exists in the database // Set ResetKey, send out email, and set $Sent to 1 to show success page $ResetKey=Users::make_secret(); - $DB->query("UPDATE users_info SET + $DB->query("UPDATE users_info SET ResetKey='".db_string($ResetKey)."', - ResetExpires='".time_plus(60*60)."' + ResetExpires='".time_plus(60*60)."' WHERE UserID='$UserID'"); - + require(SERVER_ROOT.'/classes/class_templates.php'); $TPL=NEW TEMPLATE; $TPL->open(SERVER_ROOT.'/templates/password_reset.tpl'); // Password reset template - + $TPL->set('Username',$Username); $TPL->set('ResetKey',$ResetKey); $TPL->set('IP',$_SERVER['REMOTE_ADDR']); @@ -129,7 +129,7 @@ Misc::send_email($Email,'Password reset information for '.SITE_NAME,$TPL->get(),'noreply'); $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); @@ -142,7 +142,7 @@ } $DB->query("UPDATE users_sessions SET Active = 0 WHERE UserID='$UserID' AND Active = 1"); - + } else { $Err="There is no user with that email address."; } @@ -150,12 +150,12 @@ } elseif (!empty($_SESSION['reseterr'])) { // User has not entered email address, and there is an error set in session data - // This is typically because their key has expired. + // This is typically because their key has expired. // Stick the error into $Err so recover_step1.php can take care of it $Err=$_SESSION['reseterr']; unset($_SESSION['reseterr']); } - + // Either a form for the user's email address, or a success message require('recover_step1.php'); } // End if (step 1) @@ -184,7 +184,7 @@ function log_attempt($UserID) { LastAttempt='".sqltime()."', Attempts='".db_string($Attempts)."', BannedUntil='".db_string($BannedUntil)."', - Bans=Bans+1 + Bans=Bans+1 WHERE ID='".db_string($AttemptID)."'"); if ($Bans>9) { // Automated bruteforce prevention @@ -210,17 +210,17 @@ function log_attempt($UserID) { $DB->query("UPDATE login_attempts SET LastAttempt='".sqltime()."', Attempts='".db_string($Attempts)."', - BannedUntil='0000-00-00 00:00:00' + 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->query("INSERT INTO login_attempts + (UserID,IP,LastAttempt,Attempts) VALUES ('".db_string($UserID)."','".db_string($IPStr)."','".sqltime()."',1)"); } } // end log_attempt function - + // If user has submitted form if(isset($_POST['username']) && !empty($_POST['username']) && isset($_POST['password']) && !empty($_POST['password'])) { if (strtotime($BannedUntil) > time()) { @@ -238,7 +238,7 @@ function log_attempt($UserID) { PassHash, Secret, Enabled - FROM users_main WHERE Username='".db_string($_POST['username'])."' + FROM users_main 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)query("INSERT INTO users_sessions (UserID, SessionID, KeepLogged, Browser, OperatingSystem, IP, LastUpdate) VALUES ('$UserID', '".db_string($SessionID)."', '$KeepLogged', '$Browser','$OperatingSystem', '".db_string($_SERVER['REMOTE_ADDR'])."', '".sqltime()."')"); @@ -283,9 +283,9 @@ function log_attempt($UserID) { 'LastUpdate'=>sqltime() )); $Cache->commit_transaction(0); - - $Sql = "UPDATE users_main - SET + + $Sql = "UPDATE users_main + SET LastLogin='".sqltime()."', LastAccess='".sqltime()."'"; diff --git a/sections/login/login.php b/sections/login/login.php index bfe3c74b..14bd53d5 100644 --- a/sections/login/login.php +++ b/sections/login/login.php @@ -1,6 +1,6 @@ - + diff --git a/sections/peerupdate/index.php b/sections/peerupdate/index.php index 395ac154..a4465fee 100644 --- a/sections/peerupdate/index.php +++ b/sections/peerupdate/index.php @@ -1,5 +1,5 @@ query("TRUNCATE TABLE torrents_peerlists"); $DB->query("INSERT INTO torrents_peerlists SELECT * FROM torrents_peerlists_compare"); -if (check_perms('admin_schedule')) { +if (check_perms('admin_schedule')) { echo '
    ';
     	View::show_footer();
     }
    diff --git a/sections/register/index.php b/sections/register/index.php
    index 6eb40b0b..81868d84 100644
    --- a/sections/register/index.php
    +++ b/sections/register/index.php
    @@ -17,13 +17,13 @@
     	// Confirm registration
     	$DB->query("SELECT ID FROM users_main WHERE torrent_pass='".db_string($_REQUEST['confirm'])."' AND Enabled='0'");
     	list($UserID)=$DB->next_record();
    -	
    +
     	if($UserID) {
     		$DB->query("UPDATE users_main SET Enabled='1' WHERE ID='$UserID'");
     		$Cache->increment('stats_user_count');
     		include('step2.php');
     	}
    -	
    +
     } elseif(OPEN_REGISTRATION || !empty($_REQUEST['invite'])) {
     	$Val->SetFields('username',true,'regex', 'You did not enter a valid username.',array('regex'=>'/^[a-z0-9_?]{1,20}$/iD'));
     	$Val->SetFields('email',true,'email', 'You did not enter a valid email address.');
    @@ -39,19 +39,19 @@
     		$Err=$Val->ValidateForm($_REQUEST);
     		/*
     		if(!$Err && strtolower($_SESSION['captcha'])!=strtolower($_REQUEST['captcha'])) {
    -			$Err="You did not enter the correct captcha code."; 
    +			$Err="You did not enter the correct captcha code.";
     		}
     		*/
     		if(!$Err) {
    -			
    +
     			$DB->query("SELECT COUNT(ID) FROM users_main WHERE Username LIKE '".db_string(trim($_POST['username']))."'");
     			list($UserCount)=$DB->next_record();
    -			
    +
     			if($UserCount) {
     				$Err = "There is already someone registered with that username.";
     				$_REQUEST['username']='';
     			}
    -			
    +
     			if($_POST['invite']) {
     				$DB->query("SELECT InviterID, Email FROM invites WHERE InviteKey='".db_string($_REQUEST['invite'])."'");
     				if($DB->record_count() == 0) {
    @@ -64,10 +64,10 @@
     				$InviterID=0;
     			}
     		}
    -		
    +
     		if(!$Err) {
     			$torrent_pass=Users::make_secret();
    -			
    +
     			// Previously SELECT COUNT(ID) FROM users_main, which is a lot slower.
     			$DB->query("SELECT ID FROM users_main LIMIT 1");
     			$UserCount = $DB->record_count();
    @@ -84,87 +84,87 @@
     			$ipcc = Tools::geoip($_SERVER['REMOTE_ADDR']);
     			
     			
    -			$DB->query("INSERT INTO users_main 
    +			$DB->query("INSERT INTO users_main
     				(Username,Email,PassHash,torrent_pass,IP,PermissionID,Enabled,Invites,Uploaded,ipcc) VALUES
     				('".db_string(trim($_POST['username']))."','".db_string($_POST['email'])."','".db_string(Users::make_crypt_hash($_POST['password']))."','".db_string($torrent_pass)."','".db_string($_SERVER['REMOTE_ADDR'])."','".$Class."','".$Enabled."','".STARTING_INVITES."', '524288000', '$ipcc')");
     
     			$UserID = $DB->inserted_id();
     			
    -			
    +
     			// User created, delete invite. If things break after this point, then it's better to have a broken account to fix than a 'free' invite floating around that can be reused
     			$DB->query("DELETE FROM invites WHERE InviteKey='".db_string($_REQUEST['invite'])."'");
     
     			$DB->query("SELECT ID FROM stylesheets WHERE `Default`='1'");
     			list($StyleID) = $DB->next_record();
     			$AuthKey = Users::make_secret();
    -			
    +
     			$DB->query("INSERT INTO users_info (UserID,StyleID,AuthKey, Inviter, JoinDate) VALUES ('$UserID','$StyleID','".db_string($AuthKey)."', '$InviterID', '".sqltime()."')");
    -			
    +
     			$DB->query("INSERT INTO users_history_ips
     					(UserID, IP, StartTime) VALUES
     					('$UserID', '".db_string($_SERVER['REMOTE_ADDR'])."', '".sqltime()."')");
    +
     			
    -			
    -			
    -			
    +
    +
     			$DB->query("INSERT INTO users_history_emails
    -				(UserID, Email, Time, IP) VALUES 
    +				(UserID, Email, Time, IP) VALUES
     				('$UserID', '".db_string($_REQUEST['email'])."', '0000-00-00 00:00:00', '".db_string($_SERVER['REMOTE_ADDR'])."')");
    -				
    +
     			if ($_REQUEST['email'] != $InviteEmail) {
     				$DB->query("INSERT INTO users_history_emails
    -					(UserID, Email, Time, IP) VALUES 
    +					(UserID, Email, Time, IP) VALUES
     					('$UserID', '$InviteEmail', '".sqltime()."', '".db_string($_SERVER['REMOTE_ADDR'])."')");
     			}
    +
     			
    -			
    -			
    +
     			// Manage invite trees, delete invite
    -			
    +
     			if($InviterID !== NULL) {
    -				$DB->query("SELECT 
    -					TreePosition, TreeID, TreeLevel 
    +				$DB->query("SELECT
    +					TreePosition, TreeID, TreeLevel
     					FROM invite_tree WHERE UserID='$InviterID'");
     				list($InviterTreePosition, $TreeID, $TreeLevel) = $DB->next_record();
    -				
    +
     				// If the inviter doesn't have an invite tree
     				// Note: This should never happen unless you've transferred from another database, like What.CD did
     				if($DB->record_count() == 0) {
     					$DB->query("SELECT MAX(TreeID)+1 FROM invite_tree");
     					list($TreeID) = $DB->next_record();
    -					
    +
     					$DB->query("INSERT INTO invite_tree
     						(UserID, InviterID, TreePosition, TreeID, TreeLevel)
     						VALUES ('$InviterID', '0', '1', '$TreeID', '1')");
    -					
    +
     					$TreePosition = 2;
     					$TreeLevel = 2;
     				} else {
    -					$DB->query("SELECT 
    -						TreePosition 
    -						FROM invite_tree 
    +					$DB->query("SELECT
    +						TreePosition
    +						FROM invite_tree
     						WHERE TreePosition>'$InviterTreePosition'
    -						AND TreeLevel<='$TreeLevel' 
    +						AND TreeLevel<='$TreeLevel'
     						AND TreeID='$TreeID'
    -						ORDER BY TreePosition 
    +						ORDER BY TreePosition
     						LIMIT 1");
     					list($TreePosition) = $DB->next_record();
    -					
    +
     					if($TreePosition) {
     						$DB->query("UPDATE invite_tree SET TreePosition=TreePosition+1 WHERE TreeID='$TreeID' AND TreePosition>='$TreePosition'");
     					} else {
    -						$DB->query("SELECT 
    -							TreePosition+1 
    -							FROM invite_tree 
    +						$DB->query("SELECT
    +							TreePosition+1
    +							FROM invite_tree
     							WHERE TreeID='$TreeID'
    -							ORDER BY TreePosition DESC 
    +							ORDER BY TreePosition DESC
     							LIMIT 1");
     						list($TreePosition) = $DB->next_record();
     					}
     					$TreeLevel++;
    -					
    +
     					// Create invite tree record
    -					$DB->query("INSERT INTO invite_tree 
    +					$DB->query("INSERT INTO invite_tree
     						(UserID, InviterID, TreePosition, TreeID, TreeLevel) VALUES
     						('$UserID', '$InviterID', '$TreePosition', '$TreeID', '$TreeLevel')");
     				}
    @@ -176,12 +176,12 @@
     				$TreePosition=1;
     				$TreeLevel=1;
     			}
    -	
    -			
    +
    +
     			include(SERVER_ROOT.'/classes/class_templates.php');
     			$TPL=NEW TEMPLATE;
     			$TPL->open(SERVER_ROOT.'/templates/new_registration.tpl');
    -			
    +
     			$TPL->set('Username',$_REQUEST['username']);
     			$TPL->set('TorrentKey',$torrent_pass);
     			$TPL->set('SITE_NAME',SITE_NAME);
    @@ -190,10 +190,10 @@
     			Misc::send_email($_REQUEST['email'],'New account confirmation at '.SITE_NAME,$TPL->get(),'noreply');
     			Tracker::update_tracker('add_user', array('id' => $UserID, 'passkey' => $torrent_pass));
     			$Sent=1;
    -			
    +
     			
     		}
    -		
    +
     	} elseif($_GET['invite']) {
     		// If they haven't submitted the form, check to see if their invite is good
     		$DB->query("SELECT InviteKey FROM invites WHERE InviteKey='".db_string($_GET['invite'])."'");
    @@ -201,9 +201,9 @@
     			error('Invite not found!');
     		}
     	}
    -	
    +
     	include('step1.php');
    -	
    +
     } elseif(!OPEN_REGISTRATION) {
     	if (isset($_GET['welcome'])) {
     		include('code.php');
    diff --git a/sections/reports/ajax_claim_report.php b/sections/reports/ajax_claim_report.php
    index 806bfc0e..db1063e2 100644
    --- a/sections/reports/ajax_claim_report.php
    +++ b/sections/reports/ajax_claim_report.php
    @@ -32,4 +32,4 @@
     			)
     		);
     	die();
    -}
    \ No newline at end of file
    +}
    diff --git a/sections/reports/ajax_resolve_report.php b/sections/reports/ajax_resolve_report.php
    index 184e0d2a..b79eeb5e 100644
    --- a/sections/reports/ajax_resolve_report.php
    +++ b/sections/reports/ajax_resolve_report.php
    @@ -21,7 +21,7 @@
     	}
     }
     
    -$DB->query("UPDATE reports 
    +$DB->query("UPDATE reports
     			SET Status='Resolved',
     				ResolvedTime='".sqltime()."',
     				ResolverID='".$LoggedUser['ID']."'
    diff --git a/sections/reports/report.php b/sections/reports/report.php
    index 2c8f2023..4218ab0f 100644
    --- a/sections/reports/report.php
    +++ b/sections/reports/report.php
    @@ -10,7 +10,7 @@
     	error(403);
     }
     $Short = $_GET['type'];
    -$Type = $Types[$Short]; 
    +$Type = $Types[$Short];
     
     $ID = $_GET['id'];
     
    @@ -142,7 +142,7 @@
     		
     		
     			
    -			full_format($Desc)?>	
    +			full_format($Desc)?>
     			
     		
     	
    @@ -167,10 +167,10 @@
     					
     						
    @@ -201,11 +201,11 @@
     		
     		
     			
    -			full_format($Desc)?>	
    +			full_format($Desc)?>
     			
     		
     	
    -
    @@ -216,11 +216,11 @@
     			Description
     		
     		
    -				
    +			
     			full_format($Desc)?>
     		
     	
    -
    @@ -231,11 +231,11 @@
     			Title
     		
     		
    -				
    +			
     			
     		
     	
    -
    @@ -246,11 +246,11 @@
     			Body
     		
     		
    -				
    +			
     			full_format($Body)?>
     		
     	
    -Body
     		
     		
    -				
    +			
     			full_format($Body)?>
     		
     	
    -
    diff --git a/sections/reports/reports.php b/sections/reports/reports.php
    index bf5ccae6..b797279a 100644
    --- a/sections/reports/reports.php
    +++ b/sections/reports/reports.php
    @@ -45,22 +45,22 @@
     
     }
     
    -$Reports = $DB->query("SELECT SQL_CALC_FOUND_ROWS 
    -		r.ID, 
    +$Reports = $DB->query("SELECT SQL_CALC_FOUND_ROWS
    +		r.ID,
     		r.UserID,
    -		um.Username, 
    -		r.ThingID, 
    -		r.Type, 
    -		r.ReportedTime, 
    -		r.Reason, 
    +		um.Username,
    +		r.ThingID,
    +		r.Type,
    +		r.ReportedTime,
    +		r.Reason,
     		r.Status,
     		r.ClaimerID,
             r.Notes,
             r.ResolverID
    -	FROM reports AS r 
    +	FROM reports AS r
     	JOIN users_main AS um ON r.UserID=um.ID
     	WHERE " . $Where . "
    -	ORDER BY ReportedTime 
    +	ORDER BY ReportedTime
     	DESC LIMIT " . $Limit);
     
     // Number of results (for pagination)
    @@ -219,7 +219,7 @@
     						Claim
     						
     						  
    -						Toggle Notes
    +						Toggle notes
     
     						
    ;"> @@ -238,7 +238,7 @@ - diff --git a/sections/reports/takereport.php b/sections/reports/takereport.php index 8fa5de13..54e7299d 100644 --- a/sections/reports/takereport.php +++ b/sections/reports/takereport.php @@ -11,7 +11,7 @@ error(403); } $Short = $_POST['type']; -$Type = $Types[$Short]; +$Type = $Types[$Short]; $ID = $_POST['id']; if($Short == "request_update") { if(empty($_POST['year']) || !is_number($_POST['year'])) { diff --git a/sections/reports/takeresolve.php b/sections/reports/takeresolve.php index 2fd422df..d2ed2942 100644 --- a/sections/reports/takeresolve.php +++ b/sections/reports/takeresolve.php @@ -25,7 +25,7 @@ } } -$DB->query("UPDATE reports +$DB->query("UPDATE reports SET Status='Resolved', ResolvedTime='".sqltime()."', ResolverID='".$LoggedUser['ID']."' diff --git a/sections/reportsv2/ajax_change_resolve.php b/sections/reportsv2/ajax_change_resolve.php index 7d4570d5..44ea0ef3 100644 --- a/sections/reportsv2/ajax_change_resolve.php +++ b/sections/reportsv2/ajax_change_resolve.php @@ -1,7 +1,7 @@ next_record(MYSQLI_BOTH, array("ModComment")); if(!$GroupID) { @@ -102,12 +102,12 @@
    query("UPDATE reportsv2 SET Status='InProgress', ResolverID=".$LoggedUser['ID']." WHERE ID=".$ReportID); - - + + if (array_key_exists($Type, $Types[$CategoryID])) { $ReportType = $Types[$CategoryID][$Type]; } else if(array_key_exists($Type,$Types['master'])) { @@ -129,11 +129,11 @@ $RawName = "$ArtistName - $GroupName".($Year ? " ($Year)" : "")." [$Format/$Encoding/$Media]".($Remastered ? " <$RemasterTitle - $RemasterYear>" : "").($HasCue ? " (Cue)" : '').($HasLog ? " (Log: $LogScore %)" : "")." (".number_format($Size/(1024*1024), 2)." MB)"; $LinkName = "$ArtistName - $GroupName".($Year ? " ($Year)" : "")." [$Format/$Encoding/$Media]".($Remastered ? " <$RemasterTitle - $RemasterYear>" : "")." ".($HasCue ? " (Cue)" : '').($HasLog ? " (Log: $LogScore %)" : "")." (".number_format($Size/(1024*1024), 2)." MB)"; $BBName = "[url=artist.php?id=$ArtistID]".$ArtistName."[/url] - [url=torrents.php?id=$GroupID]$GroupName".($Year ? " ($Year)" : "")."[/url] [url=torrents.php?torrentid=$TorrentID][$Format/$Encoding/$Media]".($Remastered ? " <$RemasterTitle - $RemasterYear>" : "")."[/url] ".($HasCue ? " (Cue)" : '').($HasLog ? " [url=torrents.php?action=viewlog&torrentid=$TorrentID&groupid=$GroupID'](Log: $LogScore %)[/url]" : "")." (".number_format($Size/(1024*1024), 2)." MB)"; - } - ?> + } + ?>
    - ">
    was reported by for the reason:
    - query("SELECT r.ID - FROM reportsv2 AS r - LEFT JOIN torrents AS t ON t.ID=r.TorrentID + 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) { ?> - query("SELECT t.UserID - FROM reportsv2 AS r - JOIN torrents AS t ON t.ID=r.TorrentID + 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); @@ -185,12 +185,12 @@ There 1) ? "are $UploaderOthers other reports" : "is 1 other report")?> for torrents uploaded by this user
    query("SELECT DISTINCT req.ID, req.FillerID, um.Username, req.TimeFilled - FROM requests AS req + 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 @@ -198,7 +198,7 @@ AND req.TimeFilled > '2010-03-04 02:31:49' AND req.TorrentID=$TorrentID"); $Requests = ($DB->record_count()); - if($Requests > 0) { + if($Requests > 0) { while(list($RequestID, $FillerID, $FillerName, $FilledTime) = $DB->next_record()) { ?>
    @@ -219,7 +219,7 @@ @@ -228,7 +228,7 @@ local_url($Link)) { $Link = $local_url; } @@ -241,7 +241,7 @@ @@ -253,7 +253,7 @@ foreach($Extras as $ExtraID) { - $DB->query("SELECT + $DB->query("SELECT tg.Name, tg.ID, CASE COUNT(ta.GroupID) @@ -287,11 +287,11 @@ 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, + + list($ExtraGroupName, $ExtraGroupID, $ExtraArtistID, $ExtraArtistName, $ExtraYear, $ExtraTime, $ExtraRemastered, $ExtraRemasterTitle, $ExtraRemasterYear, $ExtraMedia, $ExtraFormat, $ExtraEncoding, $ExtraSize, $ExtraHasCue, $ExtraHasLog, $ExtraLogScore, $ExtraUploaderID, $ExtraUploaderName) = Misc::display_array($DB->next_record()); - - + + if($ExtraGroupName) { if ($ArtistID == 0 && empty($ArtistName)) { $ExtraLinkName = "$ExtraGroupName".($ExtraYear ? " ($ExtraYear)" : "")." [$ExtraFormat/$ExtraEncoding/$ExtraMedia]".($ExtraRemastered ? " <$ExtraRemasterTitle - $ExtraRemasterYear>" : "")." ".($ExtraHasLog == '1' ? " (Log: $ExtraLogScore %)" : "")." (".number_format($ExtraSize/(1024*1024), 2)." MB)"; @@ -299,8 +299,8 @@ $ExtraLinkName = "Various Artists - $ExtraGroupName".($ExtraYear ? " ($ExtraYear)" : "")." [$ExtraFormat/$ExtraEncoding/$ExtraMedia]".($ExtraRemastered ? " <$ExtraRemasterTitle - $ExtraRemasterYear>" : "")." ".($ExtraHasLog == '1' ? " (Log: $ExtraLogScore %)" : "")." (".number_format($ExtraSize/(1024*1024), 2)." MB)"; } else { $ExtraLinkName = "$ExtraArtistName - $ExtraGroupName".($ExtraYear ? " ($ExtraYear)" : "")." [$ExtraFormat/$ExtraEncoding/$ExtraMedia]".($ExtraRemastered ? " <$ExtraRemasterTitle - $ExtraRemasterYear>" : "")." ".($ExtraHasLog == '1' ? " (Log: $ExtraLogScore %)" : "")." (".number_format($ExtraSize/(1024*1024), 2)." MB)"; - } - + } + ?> ")?> @@ -315,7 +315,7 @@ @@ -327,12 +327,12 @@ $Image = 'http'.($SSL?'s':'').'://'.SITE_URL.'/image.php?c=1&i='.urlencode($Image); ?> Relevant image - - @@ -412,7 +412,7 @@ - Extra Log Message: + Extra Log Message: /> - Extra Staff Notes: + Extra Staff Notes: diff --git a/sections/reportsv2/ajax_report.php b/sections/reportsv2/ajax_report.php index 91890371..ffe7170e 100644 --- a/sections/reportsv2/ajax_report.php +++ b/sections/reportsv2/ajax_report.php @@ -76,7 +76,7 @@ - + @@ -87,5 +87,5 @@ - + diff --git a/sections/reportsv2/array.php b/sections/reportsv2/array.php index 1587f63c..a34d6a00 100644 --- a/sections/reportsv2/array.php +++ b/sections/reportsv2/array.php @@ -120,7 +120,7 @@ 'report_fields' => array( 'sitelink' => '1' ), - + 'resolve_options' => array( 'upload' => '0', 'warn' => '0', diff --git a/sections/reportsv2/index.php b/sections/reportsv2/index.php index 74028cf8..575598c6 100644 --- a/sections/reportsv2/index.php +++ b/sections/reportsv2/index.php @@ -27,7 +27,7 @@ break; case 'new': include(SERVER_ROOT.'/sections/reportsv2/reports.php'); - break; + break; case 'ajax_new_report': include('ajax_new_report.php'); break; diff --git a/sections/reportsv2/report.php b/sections/reportsv2/report.php index 44799e78..f6d34e32 100644 --- a/sections/reportsv2/report.php +++ b/sections/reportsv2/report.php @@ -54,20 +54,20 @@ - +

    Reporting guidelines

    Fields that contain lists of values (for example, listing more than one track number) should be separated by a space.


    Following the below report type specific guidelines will help the moderators deal with your report in a timely fashion.


    - +
    - @@ -77,7 +77,7 @@
    - +
    diff --git a/sections/reportsv2/static.php b/sections/reportsv2/static.php index 71b5c649..7f4712db 100644 --- a/sections/reportsv2/static.php +++ b/sections/reportsv2/static.php @@ -3,9 +3,9 @@ * This page is used for viewing reports in every viewpoint except auto. * It doesn't AJAX grab a new report when you resolve each one, use auto * for that (reports.php). If you wanted to add a new view, you'd simply - * add to the case statement(s) below and add an entry to views.php to + * add to the case statement(s) below and add an entry to views.php to * explain it. - * Any changes made to this page within the foreach() should probably be + * Any changes made to this page within the foreach() should probably be * replicated on the auto page (reports.php). */ @@ -35,7 +35,7 @@ } else { $ID = ''; } - + $Order = "ORDER BY r.ReportedTime ASC"; if(!$ID) { @@ -90,7 +90,7 @@ break; case "reporter" : $DB->query("SELECT Username FROM users_main WHERE ID=".$ID); - list($Username) = $DB->next_record(); + list($Username) = $DB->next_record(); if($Username) { $Title = "All torrents reported by ".$Username; } else { @@ -101,7 +101,7 @@ break; case "uploader" : $DB->query("SELECT Username FROM users_main WHERE ID=".$ID); - list($Username) = $DB->next_record(); + list($Username) = $DB->next_record(); if($Username) { $Title = "All reports for torrents uploaded by ".$Username; } else { @@ -176,7 +176,7 @@ 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 " + GROUP BY r.ID " .$Order." LIMIT ".$Limit); @@ -223,8 +223,8 @@ foreach($Reports as $Report) { - 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, + 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")); if(!$GroupID && $Status != "Resolved") { @@ -272,11 +272,11 @@ $RawName = "$ArtistName - $GroupName".($Year ? " ($Year)" : "")." [$Format/$Encoding/$Media]".($Remastered ? " <$RemasterTitle - $RemasterYear>" : "").($HasCue ? " (Cue)" : '').($HasLog ? " (Log: $LogScore %)" : "")." (".number_format($Size/(1024*1024), 2)." MB)"; $LinkName = "$ArtistName - $GroupName".($Year ? " ($Year)" : "")." [$Format/$Encoding/$Media]".($Remastered ? " <$RemasterTitle - $RemasterYear>" : "")." ".($HasCue ? " (Cue)" : '').($HasLog ? " (Log: $LogScore %)" : "")." (".number_format($Size/(1024*1024), 2)." MB)"; $BBName = "[url=artist.php?id=$ArtistID]".$ArtistName."[/url] - [url=torrents.php?id=$GroupID]$GroupName".($Year ? " ($Year)" : "")."[/url] [url=torrents.php?torrentid=$TorrentID][$Format/$Encoding/$Media]".($Remastered ? " <$RemasterTitle - $RemasterYear>" : "")."[/url] ".($HasCue ? " (Cue)" : '').($HasLog ? " [url=torrents.php?action=viewlog&torrentid=$TorrentID&groupid=$GroupID'](Log: $LogScore %)[/url]" : "")." (".number_format($Size/(1024*1024), 2)." MB)"; - } - ?> + } + ?>
    -
    was reported by for the reason:
    query("SELECT r.ID - FROM reportsv2 AS r - LEFT JOIN torrents AS t ON t.ID=r.TorrentID + + $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) { ?> query("SELECT t.UserID - FROM reportsv2 AS r - JOIN torrents AS t ON t.ID=r.TorrentID + + $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) { ?> query("SELECT DISTINCT req.ID, req.FillerID, um.Username, req.TimeFilled - FROM requests AS req + 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 @@ -347,7 +347,7 @@ AND req.TimeFilled > '2010-03-04 02:31:49' AND req.TorrentID = $TorrentID"); $Requests = ($DB->record_count()); - if($Requests > 0) { + if($Requests > 0) { while(list($RequestID, $FillerID, $FillerName, $FilledTime) = $DB->next_record()) { ?>
    @@ -368,7 +368,7 @@ @@ -377,7 +377,7 @@ local_url($Link)) { $Link = $local_url; } @@ -390,7 +390,7 @@ @@ -402,7 +402,7 @@ foreach($Extras as $ExtraID) { - $DB->query("SELECT + $DB->query("SELECT tg.Name, tg.ID, CASE COUNT(ta.GroupID) @@ -436,10 +436,10 @@ 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, + + list($ExtraGroupName, $ExtraGroupID, $ExtraArtistID, $ExtraArtistName, $ExtraYear, $ExtraTime, $ExtraRemastered, $ExtraRemasterTitle, $ExtraRemasterYear, $ExtraMedia, $ExtraFormat, $ExtraEncoding, $ExtraSize, $ExtraHasCue, $ExtraHasLog, $ExtraLogScore, $ExtraUploaderID, $ExtraUploaderName) = Misc::display_array($DB->next_record()); - + if($ExtraGroupName) { if ($ArtistID == 0 && empty($ArtistName)) { $ExtraLinkName = "$ExtraGroupName".($ExtraYear ? " ($ExtraYear)" : "")." [$ExtraFormat/$ExtraEncoding/$ExtraMedia]".($ExtraRemastered ? " <$ExtraRemasterTitle - $ExtraRemasterYear>" : "")." ".($ExtraHasCue == '1' ? " (Cue)" : '').($ExtraHasLog == '1' ? " (Log: $ExtraLogScore %)" : "")." (".number_format($ExtraSize/(1024*1024), 2)." MB)"; @@ -447,7 +447,7 @@ $ExtraLinkName = "Various Artists - $ExtraGroupName".($ExtraYear ? " ($ExtraYear)" : "")." [$ExtraFormat/$ExtraEncoding/$ExtraMedia]".($ExtraRemastered ? " <$ExtraRemasterTitle - $ExtraRemasterYear>" : "")." ".($ExtraHasCue == '1' ? " (Cue)" : '').($ExtraHasLog == '1' ? " (Log: $ExtraLogScore %)" : "")." (".number_format($ExtraSize/(1024*1024), 2)." MB)"; } else { $ExtraLinkName = "$ExtraArtistName - $ExtraGroupName".($ExtraYear ? " ($ExtraYear)" : "")." [$ExtraFormat/$ExtraEncoding/$ExtraMedia]".($ExtraRemastered ? " <$ExtraRemasterTitle - $ExtraRemasterYear>" : "")." ".($ExtraHasCue == '1' ? " (Cue)" : '').($ExtraHasLog == '1' ? " (Log: $ExtraLogScore %)" : "")." (".number_format($ExtraSize/(1024*1024), 2)." MB)"; - } + } ?> ")?> @@ -462,7 +462,7 @@ @@ -474,12 +474,12 @@ $Image = 'http'.($SSL?'s':'').'://'.SITE_URL.'/image.php?c=1&i='.urlencode($Image); ?> Relevant image - - @@ -487,7 +487,7 @@ full_format($UserComment)?> - @@ -497,7 +497,7 @@ Report Comment: @@ -519,7 +519,7 @@ $Priorities[$Key] = $Value['priority']; } array_multisort($Priorities, SORT_ASC, $TypeList); - + foreach($TypeList as $Type => $Data) { ?> @@ -562,7 +562,7 @@ : - + @@ -571,7 +571,7 @@ - Extra Log Message: + Extra Log Message: /> - Extra Staff Notes: + Extra Staff Notes: @@ -604,25 +604,25 @@ } else { ?> - Resolver + Resolver - Resolve Time + Resolve Time - Report Comments + Report Comments - Log Message + Log Message diff --git a/sections/reportsv2/takereport.php b/sections/reportsv2/takereport.php index af3dc35c..dc2c7cf3 100644 --- a/sections/reportsv2/takereport.php +++ b/sections/reportsv2/takereport.php @@ -2,12 +2,12 @@ /* * This page handles the backend from when a user submits a report. * It checks for (in order): - * 1. The usual POST injections, then checks that things. - * 2. Things that are required by the report type are filled + * 1. The usual POST injections, then checks that things. + * 2. Things that are required by the report type are filled * ('1' in the report_fields array). * 3. Things that are filled are filled with correct things. * 4. That the torrent you're reporting still exists. - * + * * Then it just inserts the report to the DB and increments the counter. */ diff --git a/sections/reportsv2/takeresolve.php b/sections/reportsv2/takeresolve.php index 4c0eb007..578bfa8b 100644 --- a/sections/reportsv2/takeresolve.php +++ b/sections/reportsv2/takeresolve.php @@ -1,6 +1,6 @@ query("UPDATE reportsv2 SET Status='Resolved', LastChangeTime='".sqltime()."', @@ -76,7 +76,7 @@ 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); @@ -113,7 +113,7 @@ $DB->query("SELECT ID FROM torrents WHERE ID = ".$TorrentID); $TorrentExists = ($DB->record_count() > 0); if(!$TorrentExists) { - $DB->query("UPDATE reportsv2 + $DB->query("UPDATE reportsv2 SET Status='Resolved', LastChangeTime='".sqltime()."', ResolverID='".$LoggedUser['ID']."', @@ -125,7 +125,7 @@ if($Report) { //Resolve with a parallel check - $DB->query("UPDATE reportsv2 + $DB->query("UPDATE reportsv2 SET Status='Resolved', LastChangeTime='".sqltime()."', ResolverID='".$LoggedUser['ID']."' @@ -138,7 +138,7 @@ //We did, lets do all our shit if($Report) { $Cache->decrement('num_torrent_reportsv2'); } - + if(isset($Escaped['upload'])) { $Upload = true; } else { @@ -168,7 +168,7 @@ $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); @@ -181,7 +181,7 @@ $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).")"; Misc::write_log($Log); @@ -190,20 +190,20 @@ } else { $Log = "No log message (Torrent wasn't deleted)"; } - + //Warnings / remove upload if($Upload) { $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); } - + if($Warning > 0) { - $WarnLength = $Warning * (7*24*60*60); + $WarnLength = $Warning * (7*24*60*60); $Reason = "Uploader of torrent (".$TorrentID.") ".$RawName." which was resolved with the preset: ".$ResolveType['title']."."; if($Escaped['admin_message']) { $Reason .= " (".$Escaped['admin_message'].")."; @@ -227,13 +227,13 @@ } if($AdminComment) { $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)."'"); } } - + //PM if($Escaped['uploader_pm'] || $Warning > 0 || isset($Escaped['delete']) || $SendPM) { if(isset($Escaped['delete'])) { @@ -241,17 +241,17 @@ } else { $PM = "[url=http://".NONSSL_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; } - + if($Warning > 0) { - $PM .= "\nThis has resulted in a [url=http://".NONSSL_SITE_URL."/wiki.php?action=article&id=218]".$Warning." week warning.[/url]\n"; + $PM .= "\nThis has resulted in a [url=http://".NONSSL_SITE_URL."/wiki.php?action=article&id=218]".$Warning." week warning.[/url]\n"; } - + if($Upload) { $PM .= "This has ".($Warning > 0 ? 'also ' : '')."resulted in you losing your upload privileges."; } @@ -259,20 +259,20 @@ if($Log) { $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]."; - + Misc::send_pm($UploaderID, 0, db_string($Escaped['raw_name']), db_string($PM)); } $Cache->delete_value('reports_torrent_'.$TorrentID); - + //Now we've done everything, update the DB with values - if($Report) { + if($Report) { $DB->query("UPDATE reportsv2 SET Type = '".$Escaped['resolve_type']."', LogMessage='".db_string($Log)."', diff --git a/sections/reportsv2/views.php b/sections/reportsv2/views.php index 7027eb71..8b6ff483 100644 --- a/sections/reportsv2/views.php +++ b/sections/reportsv2/views.php @@ -172,7 +172,7 @@ query("SELECT r.ResolverID, - um.Username, + um.Username, COUNT(r.ID) AS Count, COUNT(tasted.Tasted) AS Tasted FROM reportsv2 AS r @@ -189,8 +189,8 @@ Current count Tasted count - - @@ -201,7 +201,7 @@ - @@ -210,7 +210,7 @@ query("SELECT r.Type, COUNT(r.ID) AS Count - FROM reportsv2 AS r + FROM reportsv2 AS r WHERE r.Status='New' GROUP BY r.Type"); $Current = $DB->to_array(); diff --git a/sections/requests/functions.php b/sections/requests/functions.php index f7938be9..4ff4e954 100644 --- a/sections/requests/functions.php +++ b/sections/requests/functions.php @@ -7,15 +7,15 @@ function get_request_artists($RequestID) { $Results = $Artists; } else { $Results = array(); - $DB->query("SELECT ra.ArtistID, - aa.Name, - ra.Importance - FROM requests_artists AS ra - JOIN artists_alias AS aa ON ra.AliasID = aa.AliasID + $DB->query("SELECT ra.ArtistID, + aa.Name, + ra.Importance + FROM requests_artists AS ra + JOIN artists_alias AS aa ON ra.AliasID = aa.AliasID WHERE ra.RequestID = ".$RequestID." ORDER BY ra.Importance ASC, aa.Name ASC;"); - + $ArtistRaw = $DB->to_array(); foreach($ArtistRaw as $ArtistRow) { list($ArtistID, $ArtistName, $ArtistImportance) = $ArtistRow; @@ -28,10 +28,10 @@ function get_request_artists($RequestID) { function get_request_tags($RequestID) { global $DB; - $DB->query("SELECT rt.TagID, - t.Name - FROM requests_tags AS rt - JOIN tags AS t ON rt.TagID=t.ID + $DB->query("SELECT rt.TagID, + t.Name + FROM requests_tags AS rt + JOIN tags AS t ON rt.TagID=t.ID WHERE rt.RequestID = ".$RequestID." ORDER BY rt.TagID ASC"); $Tags = $DB->to_array(); @@ -45,7 +45,7 @@ function get_request_tags($RequestID) { function get_votes_array($RequestID) { global $Cache, $DB; - + $RequestVotes = $Cache->get_value('request_votes_'.$RequestID); if(!is_array($RequestVotes)) { $DB->query("SELECT rv.UserID, @@ -59,18 +59,18 @@ function get_votes_array($RequestID) { error(0); } else { $Votes = $DB->to_array(); - + $RequestVotes = array(); $RequestVotes['TotalBounty'] = array_sum($DB->collect('Bounty')); - + foreach($Votes as $Vote) { list($UserID, $Bounty, $Username) = $Vote; $VoteArray = array(); - $VotesArray[] = array('UserID' => $UserID, + $VotesArray[] = array('UserID' => $UserID, 'Username' => $Username, 'Bounty' => $Bounty); } - + $RequestVotes['Voters'] = $VotesArray; $Cache->cache_value('request_votes_'.$RequestID, $RequestVotes); } diff --git a/sections/requests/index.php b/sections/requests/index.php index b73f7035..f16b5f92 100644 --- a/sections/requests/index.php +++ b/sections/requests/index.php @@ -48,23 +48,23 @@ authorize(); enforce_login(); - if (!isset($_POST['requestid']) || !is_number($_POST['requestid']) || $_POST['body']==='' || !isset($_POST['body'])) { + if (!isset($_POST['requestid']) || !is_number($_POST['requestid']) || $_POST['body']==='' || !isset($_POST['body'])) { error(0); } if($LoggedUser['DisablePosting']) { error('Your posting rights have been removed.'); } - + $RequestID = $_POST['requestid']; if(!$RequestID) { error(404); } - + $DB->query("SELECT CEIL((SELECT COUNT(ID)+1 FROM requests_comments AS rc 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'])."')"); $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); $Post = array( @@ -79,29 +79,29 @@ $Cache->insert('', $Post); $Cache->commit_transaction(0); $Cache->increment('request_comments_'.$RequestID); - + header('Location: requests.php?action=view&id='.$RequestID.'&page='.$Pages); break; - + case 'get_post': enforce_login(); if (!$_GET['post'] || !is_number($_GET['post'])) { error(0); } $DB->query("SELECT Body FROM requests_comments WHERE ID='".db_string($_GET['post'])."'"); list($Body) = $DB->next_record(MYSQLI_NUM); - + echo trim($Body); break; - + case 'takeedit_comment': enforce_login(); authorize(); include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class $Text = new TEXT; - + // Quick SQL injection check if(!$_POST['post'] || !is_number($_POST['post'])) { error(0); } - + // Mainly $DB->query("SELECT rc.Body, @@ -111,24 +111,24 @@ FROM requests_comments AS rc 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 FROM requests_comments WHERE RequestID = $RequestID AND ID <= $_POST[post]"); list($Page) = $DB->next_record(); - + if ($LoggedUser['ID']!=$AuthorID && !check_perms('site_moderate_forums')) { error(404); } if ($DB->record_count()==0) { error(404); } - + // Perform the update $DB->query("UPDATE requests_comments SET Body = '".db_string($_POST['body'])."', EditedUserID = '".db_string($LoggedUser['ID'])."', EditedTime = '".sqltime()."' WHERE ID='".db_string($_POST['post'])."'"); - + // Update the cache $CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE*$Page-TORRENT_COMMENTS_PER_PAGE)/THREAD_CATALOGUE); $Cache->begin_transaction('request_comments_'.$RequestID.'_catalogue_'.$CatalogueID); - + $Cache->update_row($_POST['key'], array( 'ID'=>$_POST['post'], 'AuthorID'=>$AuthorID, @@ -139,24 +139,24 @@ 'Username'=>$LoggedUser['Username'] )); $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)."')"); - + // This gets sent to the browser, which echoes it in place of the old body echo $Text->full_format($_POST['body']); break; - + case 'delete_comment': enforce_login(); authorize(); - + // Quick SQL injection check if (!$_GET['postid'] || !is_number($_GET['postid'])) { error(0); } - + // Make sure they are moderators if (!check_perms('site_moderate_forums')) { error(403); } - + // Get topicid, forumid, number of pages $DB->query("SELECT DISTINCT RequestID, @@ -165,24 +165,24 @@ FROM requests_comments AS rc WHERE rc.RequestID=(SELECT RequestID FROM requests_comments WHERE ID='".db_string($_GET['postid'])."')"); 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'])."'"); - + //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('request_comments_'.$RequestID.'_catalogue_'.$i); } - + // Delete thread info cache (eg. number of pages) $Cache->delete('request_comments_'.$GroupID); break; - + default: error(0); } diff --git a/sections/requests/interim.php b/sections/requests/interim.php index 7f408b1b..35222d40 100644 --- a/sections/requests/interim.php +++ b/sections/requests/interim.php @@ -10,12 +10,12 @@ list($RequestorID, $FillerID) = $DB->next_record(); if($Action == 'unfill') { - if($LoggedUser['ID'] != $RequestorID && $LoggedUser['ID'] != $FillerID && !check_perms('site_moderate_requests')) { - error(403); + if($LoggedUser['ID'] != $RequestorID && $LoggedUser['ID'] != $FillerID && !check_perms('site_moderate_requests')) { + error(403); } } elseif($Action == "delete") { - if($LoggedUser['ID'] != $RequestorID && !check_perms('site_moderate_requests')) { - error(403); + if($LoggedUser['ID'] != $RequestorID && !check_perms('site_moderate_requests')) { + error(403); } } diff --git a/sections/rules/clients.php b/sections/rules/clients.php index a3215b05..c655dd91 100644 --- a/sections/rules/clients.php +++ b/sections/rules/clients.php @@ -38,10 +38,10 @@ The modification of clients to bypass our client requirements (spoofing) is explicitly forbidden. People caught doing this will be instantly and permanently banned. This is your only warning.

    - The use of clients or proxies which have been modified to report incorrect stats to the tracker (cheating) is not allowed, and will result in a permanent ban. Additionally, your information will be passed on to representatives of other trackers, where you are liable to be banned as well. + The use of clients or proxies which have been modified to report incorrect stats to the tracker (cheating) is not allowed, and will result in a permanent ban. Additionally, your information will be passed on to representatives of other trackers, where you are liable to be banned as well.

    - The testing of unstable clients by developers is not allowed unless approved by a staff member. + The testing of unstable clients by developers is not allowed unless approved by a staff member.

    Further Details

    @@ -50,7 +50,7 @@ If someone you invited to the site breaks the above rules you will receive a 2 month warning and lose the right to invite people to this site.

    - If you were invited by someone who broke the above rules, your account will be disabled without warning. + If you were invited by someone who broke the above rules, your account will be disabled without warning.

    diff --git a/sections/rules/collages.php b/sections/rules/collages.php index 486d4b7c..e9fa2a51 100644 --- a/sections/rules/collages.php +++ b/sections/rules/collages.php @@ -9,7 +9,7 @@
    • Collages in the Discography, Staff Picks, Label, and Charts categories must be based on fact, and not opinion. If something is a published Best Of (for instance, "Pitchfork's Best Albums of the 1990's") then it should go in the Charts category.
    • - +
    • Collages in the Personal, Theme, and Genre Introductions categories may be based on opinion. You must respect others' opinions whilst creating and populating Theme and Genre Introduction collages.
    • @@ -49,7 +49,7 @@
    • Please attempt to add album art to every torrent in your collage.
    • - +
    diff --git a/sections/rules/jump.php b/sections/rules/jump.php index 86a8cbc0..25783ce6 100644 --- a/sections/rules/jump.php +++ b/sections/rules/jump.php @@ -4,14 +4,14 @@ - + @@ -51,7 +51,7 @@ Upload @@ -59,7 +59,7 @@ Chat @@ -67,11 +67,11 @@ Tagging - + @@ -122,7 +122,7 @@
    CategoryAdditional InfoAdditional information
    Golden Rules - These are the most important rules, breaking these will result in the most serious consequences. + These are the most important rules. Breaking these rules will result in the most serious consequences.
    - This is the section of the rules regarding any and all content which is allowed on this site. + This is the section of the rules regarding any and all content which is allowed on this site.
    - Read this before posting in our forums or talking on the IRC. + Read this before posting in our forums or talking on our IRC network.
    - These rules govern what tags can and can not be added. + These rules govern what tags can and cannot be added.
    Other Languages (Please note, these are community maintained and subject to error.)Other languages (Please note, these are community-maintained and are subject to error.)
    diff --git a/sections/schedule/index.php b/sections/schedule/index.php index e8d5ec2c..475712fb 100644 --- a/sections/schedule/index.php +++ b/sections/schedule/index.php @@ -71,7 +71,7 @@ function next_hour() { //------------- 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 hour, but don't tell anyone. /* $TimeMinus = time_minus(3600*7); @@ -93,8 +93,8 @@ function next_hour() { $Cache->delete_value('users_tokens_'.$UserID[0]); } -$DB->query("SELECT uf.UserID, t.info_hash - FROM users_freeleeches AS uf +$DB->query("SELECT uf.UserID, t.info_hash + FROM users_freeleeches AS uf JOIN torrents AS t ON uf.TorrentID = t.ID WHERE uf.Expired = FALSE AND uf.Time < '$sqltime' - INTERVAL 4 DAY"); while (list($UserID,$InfoHash) = $DB->next_record(MYSQLI_NUM, false)) { @@ -115,7 +115,7 @@ function next_hour() { if($Hour != next_hour() || $_GET['runhour'] || isset($argv[2])){ echo "Ran hourly functions\n"; - + //------------- Front page stats ----------------------------------------// //Love or hate, this makes things a hell of a lot faster @@ -142,23 +142,23 @@ function next_hour() { list($UserStats['Month']) = $DB->next_record(); $Cache->cache_value('stats_users',$UserStats,0); - + //------------- Record who's seeding how much, used for ratio watch - + $DB->query("TRUNCATE TABLE users_torrent_history_temp"); - $DB->query("INSERT INTO users_torrent_history_temp - (UserID, NumTorrents) - SELECT uid, - COUNT(DISTINCT fid) - FROM xbt_files_users - WHERE mtime>unix_timestamp(now()-interval 1 hour) + $DB->query("INSERT INTO users_torrent_history_temp + (UserID, NumTorrents) + SELECT uid, + COUNT(DISTINCT fid) + FROM xbt_files_users + WHERE mtime>unix_timestamp(now()-interval 1 hour) AND Remaining=0 GROUP BY uid;"); - $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' + $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;"); $DB->query("INSERT INTO users_torrent_history (UserID, NumTorrents, Date) @@ -190,7 +190,7 @@ function next_hour() { if (!empty($L['Extra'])) { $Query .= ' AND '.$L['Extra']; } - + $DB->query($Query); $UserIDs = $DB->collect('ID'); @@ -205,12 +205,12 @@ function next_hour() { $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) WHERE UserID = ".$UserID); - } + } $DB->query("UPDATE users_main SET PermissionID=".$L['To']." WHERE ID IN(".implode(',',$UserIDs).")"); } // Demote users with less than the required uploads - + $Query = "SELECT ID FROM users_main JOIN users_info ON users_main.ID = users_info.UserID WHERE PermissionID='$L[To]' AND ( Uploaded<'$L[MinUpload]' @@ -221,10 +221,10 @@ function next_hour() { $Query .= ") AND Enabled='1' AND ID NOT IN (213461)"; - + $DB->query($Query); $UserIDs = $DB->collect('ID'); - + if (count($UserIDs) > 0) { foreach($UserIDs as $UserID) { /*$Cache->begin_transaction('user_info_'.$UserID); @@ -269,7 +269,7 @@ function next_hour() { //------------- Remove dead sessions ---------------------------------------// sleep(3); - + $AgoMins = time_minus(60*30); $AgoDays = time_minus(3600*24*30); @@ -311,14 +311,14 @@ function next_hour() { $UserIDs = $DB->collect('ID' ); if(count($UserIDs) > 0) { $Subject = 'Leeching Disabled'; - $Message = 'You have downloaded more then 10 GiB while on Ratio Watch. Your leeching privileges have been disabled. Please reread the rules and refer to this guide on how to improve your ratio https://what.cd/wiki.php?action=article&id=110'; + $Message = 'You have downloaded more then 10 GiB while on Ratio Watch. Your leeching privileges have been disabled. Please reread the rules and refer to this guide on how to improve your ratio https://what.cd/wiki.php?action=article&id=110'; foreach($UserIDs as $UserID) { Misc::send_pm($UserID,0,db_string($Subject),db_string($Message)); send_irc("PRIVMSG #reports : !leechdisabled Downloaded 10 GB+ on Ratio Watch. https://".NONSSL_SITE_URL."/user.php?id=$UserID"); } - + $DB->query("UPDATE users_info AS i JOIN users_main AS m ON m.ID=i.UserID - SET + SET m.can_leech='0', i.AdminComment=CONCAT('$sqltime - Leech disabled by ratio watch system for downloading more than 10 GBs on ratio watch. - required ratio: ', m.RequiredRatio,' @@ -339,13 +339,13 @@ function next_hour() { if($Day%2 == 0) { // If we should generate the drive database (at the end) $GenerateDriveDB = true; } - + //------------- Ratio requirements - - + + $DB->query("DELETE FROM users_torrent_history WHERE Datequery("TRUNCATE TABLE users_torrent_history_temp;"); - $DB->query("INSERT INTO users_torrent_history_temp + $DB->query("INSERT INTO users_torrent_history_temp (UserID, SumTime) SELECT UserID, SUM(Time) FROM users_torrent_history GROUP BY UserID;"); @@ -356,14 +356,14 @@ function next_hour() { WHERE SumTime<259200;"); $DB->query("UPDATE users_torrent_history SET Weight=NumTorrents*Time;"); $DB->query("TRUNCATE TABLE users_torrent_history_temp;"); - $DB->query("INSERT INTO users_torrent_history_temp + $DB->query("INSERT INTO users_torrent_history_temp (UserID, SeedingAvg) SELECT UserID, SUM(Weight)/SUM(Time) FROM users_torrent_history GROUP BY UserID;"); $DB->query("DELETE FROM users_torrent_history WHERE NumTorrents='0'"); $DB->query("TRUNCATE TABLE users_torrent_history_snatch;"); - $DB->query("INSERT INTO users_torrent_history_snatch(UserID, NumSnatches) - SELECT + $DB->query("INSERT INTO users_torrent_history_snatch(UserID, NumSnatches) + SELECT xs.uid, COUNT(DISTINCT xs.fid) FROM @@ -375,7 +375,7 @@ function next_hour() { JOIN users_torrent_history_snatch AS s ON s.UserID=um.ID SET um.RequiredRatioWork=(1-(t.SeedingAvg/s.NumSnatches)) WHERE s.NumSnatches>0;"); - + $RatioRequirements = array( array(80*1024*1024*1024, 0.60, 0.50), array(60*1024*1024*1024, 0.60, 0.40), @@ -386,35 +386,35 @@ function next_hour() { array(10*1024*1024*1024, 0.20, 0.0), array(5*1024*1024*1024, 0.15, 0.0) ); - + $DB->query("UPDATE users_main SET RequiredRatio=0.60 WHERE Downloaded>100*1024*1024*1024"); - - - + + + $DownloadBarrier = 100*1024*1024*1024; foreach($RatioRequirements as $Requirement) { list($Download, $Ratio, $MinRatio) = $Requirement; - + $DB->query("UPDATE users_main SET RequiredRatio=RequiredRatioWork*$Ratio WHERE Downloaded >= '$Download' AND Downloaded < '$DownloadBarrier'"); - + $DB->query("UPDATE users_main SET RequiredRatio=$MinRatio WHERE Downloaded >= '$Download' AND Downloaded < '$DownloadBarrier' AND RequiredRatio<$MinRatio"); - + //$DB->query("UPDATE users_main SET RequiredRatio=$Ratio WHERE Downloaded >= '$Download' AND Downloaded < '$DownloadBarrier' AND can_leech='0' AND Enabled='1'"); - + $DownloadBarrier = $Download; } - + $DB->query("UPDATE users_main SET RequiredRatio=0.00 WHERE Downloaded<5*1024*1024*1024"); - + // Here is where we manage ratio watch - + $OffRatioWatch = array(); $OnRatioWatch = array(); - + // Take users off ratio watch and enable leeching $UserQuery = $DB->query("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 i.RatioWatchEnds!='0000-00-00 00:00:00' AND m.can_leech='0' AND m.Enabled='1'"); $OffRatioWatch = $DB->collect('ID'); @@ -427,7 +427,7 @@ function next_hour() { 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)); @@ -441,7 +441,7 @@ function next_hour() { Tracker::update_tracker('update_user', array('passkey' => $Passkey, 'can_leech' => '1')); } - // Take users off ratio watch + // Take users off ratio watch $UserQuery = $DB->query("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' @@ -469,7 +469,7 @@ function next_hour() { Tracker::update_tracker('update_user', array('passkey' => $Passkey, 'can_leech' => '1')); } - + // Put user on ratio watch if he doesn't meet the standards sleep(10); $DB->query("SELECT m.ID, m.Downloaded FROM users_info AS i JOIN users_main AS m ON m.ID=i.UserID @@ -478,7 +478,7 @@ function next_hour() { 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)."', @@ -486,7 +486,7 @@ function next_hour() { 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)); @@ -509,20 +509,20 @@ function next_hour() { } sleep(5); - + //------------- Disable downloading ability of users on ratio watch - - + + $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'"); - + $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 + SET m.can_leech='0', i.AdminComment=CONCAT('$sqltime - Leeching ability disabled by ratio watch system - required ratio: ', m.RequiredRatio,' @@ -532,7 +532,7 @@ function next_hour() { $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)); @@ -546,7 +546,7 @@ function next_hour() { foreach($Passkeys as $Passkey) { Tracker::update_tracker('update_user', array('passkey' => $Passkey, 'can_leech' => '0')); } - + //------------- Disable inactive user accounts --------------------------// sleep(5); // Send email @@ -567,7 +567,7 @@ function next_hour() { $DB->query("SELECT um.ID FROM users_info AS ui 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<'".time_minus(3600*24*30*4)."' AND um.LastAccess!='0000-00-00 00:00:00' AND ui.Donor='0' AND um.Enabled!='2' @@ -592,15 +592,15 @@ function next_hour() { AND um.Enabled!='2' "); $Cache->decrement('stats_user_count',$DB->affected_rows()); - + echo "disabled unconfirmed\n"; - + //------------- Demote users --------------------------------------------// sleep(10); $DB->query('SELECT um.ID FROM users_main AS um WHERE PermissionID IN('.POWER.', '.ELITE.', '.TORRENT_MASTER.') AND Uploaded/Downloaded < 0.95 OR PermissionID IN('.POWER.', '.ELITE.', '.TORRENT_MASTER.') 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)); @@ -608,7 +608,7 @@ function next_hour() { } $DB->query('UPDATE users_main SET PermissionID='.MEMBER.' WHERE PermissionID IN('.POWER.', '.ELITE.', '.TORRENT_MASTER.') AND Uploaded/Downloaded < 0.95 OR PermissionID IN('.POWER.', '.ELITE.', '.TORRENT_MASTER.') 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'); echo "demoted 3\n"; while(list($UserID) = $DB->next_record()) { @@ -628,13 +628,13 @@ function next_hour() { AND DATEDIFF(CURDATE(),DATE(t.LastPostTime))/7>f.AutoLockWeeks AND f.AutoLock = '1'"); $IDs = $DB->collect('ID'); - + if(count($IDs) > 0) { $LockIDs = implode(',', $IDs); $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)"); - + foreach($IDs as $ID) { $Cache->begin_transaction('thread_'.$ID.'_info'); $Cache->update_row(false, array('IsLocked'=>'1')); @@ -646,7 +646,7 @@ function next_hour() { echo "Old threads locked\n"; //------------- Delete dead torrents ------------------------------------// - + 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) @@ -676,9 +676,9 @@ function next_hour() { AND t.last_action = 0"); $TorrentIDs = $DB->to_array(); echo "Found ".count($TorrentIDs)." inactive torrents to be deleted.\n"; - + $LogEntries = array(); - + // Exceptions for inactivity deletion $InactivityExceptionsMade = array(//UserID => expiry time of exception @@ -687,7 +687,7 @@ function next_hour() { list($ID, $GroupID, $Name, $ArtistName, $LastAction, $Format, $Encoding, $UserID, $Media, $InfoHash) = $TorrentID; if (array_key_exists($UserID, $InactivityExceptionsMade) && (time() < $InactivityExceptionsMade[$UserID])) { // don't delete the torrent! - continue; + continue; } if($ArtistName) { $Name = $ArtistName.' - '.$Name; @@ -697,26 +697,26 @@ function next_hour() { } 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' => ''); - + $DeleteNotes[$UserID]['Msg'] .= "\n$Name"; $DeleteNotes[$UserID]['Count']++; - + ++$i; if ($i % 500 == 0) { echo "$i inactive torrents removed.\n"; } } echo "$i torrents deleted for inactivity.\n"; - + foreach($DeleteNotes as $UserID => $MessageInfo){ $Singular = ($MessageInfo['Count'] == 1) ? true : false; Misc::send_pm($UserID,0,db_string($MessageInfo['Count'].' of your torrents '.($Singular?'has':'have').' been deleted for inactivity'), db_string(($Singular?'One':'Some').' of your uploads '.($Singular?'has':'have').' been deleted for being unseeded. Since '.($Singular?'it':'they').' didn\'t break any rules (we hope), please feel free to re-upload '.($Singular?'it':'them').".\n\nThe following torrent".($Singular?' was':'s were').' deleted:'.$MessageInfo['Msg'])); - } + } unset($DeleteNotes); - + if(count($LogEntries) > 0) { $Values = "('".implode("', '".$sqltime."'), ('",$LogEntries)."', '".$sqltime."')"; $DB->query('INSERT INTO log (Message, Time) VALUES '.$Values); @@ -725,13 +725,13 @@ function next_hour() { $DB->query("SELECT SimilarID FROM artists_similar_scores WHERE Score<=0"); $SimilarIDs = implode(',',$DB->collect('SimilarID')); - - if($SimilarIDs) { + + 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)"); } - + // Daily top 10 history. @@ -777,13 +777,13 @@ function next_hour() { $RemasterTitle,$Snatched,$Seeders,$Leechers,$Data) = $Torrent; $DisplayName=''; - + $Artists = Artists::get_artist($GroupID); - + if(!empty($Artists)) { $DisplayName = Artists::display_artists($Artists, false, true); } - + $DisplayName.= $GroupName; if($GroupCategoryID==1 && $GroupYear>0) { @@ -862,13 +862,13 @@ function next_hour() { $RemasterTitle,$Snatched,$Seeders,$Leechers,$Data) = $Torrent; $DisplayName=''; - + $Artists = Artists::get_artist($GroupID); - + if(!empty($Artists)) { $DisplayName = Artists::display_artists($Artists, false, true); } - + $DisplayName.= $GroupName; if($GroupCategoryID==1 && $GroupYear>0) { @@ -901,7 +901,7 @@ function next_hour() { (".$HistoryID.", ".$i.", ".$TorrentID.", '".db_string($TitleString)."', '".db_string($TagString)."')"); $i++; } - + // Send warnings to uploaders of torrents that will be deleted this week $DB->query("SELECT t.ID, @@ -922,12 +922,12 @@ function next_hour() { $TorrentAlerts = array(); foreach ($TorrentIDs as $TorrentID) { list($ID, $GroupID, $Name, $Format, $Encoding, $UserID) = $TorrentID; - + if (array_key_exists($UserID, $InactivityExceptionsMade) && (time() < $InactivityExceptionsMade[$UserID])) { // don't notify exceptions - continue; + continue; } - + if (!array_key_exists($UserID, $TorrentAlerts)) $TorrentAlerts[$UserID] = array('Count' => 0, 'Msg' => ''); $ArtistName = Artists::display_artists(Artists::get_artist($GroupID), false, false, false); @@ -944,11 +944,11 @@ function next_hour() { Misc::send_pm($UserID, 0, db_string('Unseeded torrent notification'), db_string($MessageInfo['Count']." of your uploads will be deleted for inactivity soon. Unseeded torrents are deleted after 4 weeks. If you still have the files, you can seed your uploads by ensuring the torrents are in your client and that they aren't stopped. You can view the time that a torrent has been unseeded by clicking on the torrent description line and looking for the \"Last active\" time. For more information, please go [url=https://what.cd/wiki.php?action=article&id=663]here[/url].\n\nThe following torrent".($MessageInfo['Count']>1?'s':'')." will be removed for inactivity:".$MessageInfo['Msg']."\n\nIf you no longer wish to receive these notifications, please disable them in your profile settings.")); } } - - $DB->query("UPDATE staff_pm_conversations + + $DB->query("UPDATE staff_pm_conversations SET Status = 'Resolved', ResolverID = '0' WHERE Date < NOW() - INTERVAL 1 MONTH AND Status = 'Open' AND AssignedToUser IS NULL"); - + } /*************************************************************************\ //--------------Run twice per month -------------------------------------// @@ -991,11 +991,11 @@ function next_hour() { This cascades, so if you qualify for the last bonus group, you also qualify for the first two and will receive three bonus invites. The bonus invites cannot put a user over their cap. - + */ - $DB->query("SELECT ID - FROM users_main AS um + $DB->query("SELECT ID + FROM users_main AS um 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) OR (um.PermissionID = ".ELITE." AND um.Invites < 4))"); @@ -1013,22 +1013,22 @@ function next_hour() { array(0.75, 2*1024*1024*1024), array(2.0, 10*1024*1024*1024), array(3.0, 20*1024*1024*1024)); - + // Since MySQL doesn't like subselecting from the target table during an update, we must create a temporary table. $DB->query("CREATE TEMPORARY TABLE temp_sections_schedule_index 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 GROUP BY Inviter"); - + foreach ($BonusReqs as $BonusReq) { list($Ratio, $Upload) = $BonusReq; $DB->query("SELECT ID - FROM users_main AS um + FROM users_main AS um 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 - AND um.Enabled = '1' AND ui.DisableInvites = '0' + WHERE u.Upload>$Upload AND u.Upload/u.Download>$Ratio + AND um.Enabled = '1' AND ui.DisableInvites = '0' AND ((um.PermissionID = ".POWER." AND um.Invites < 2) OR (um.PermissionID = ".ELITE." AND um.Invites < 4))"); $UserIDs = $DB->collect('ID'); if (count($UserIDs) > 0) { @@ -1040,7 +1040,7 @@ function next_hour() { $DB->query("UPDATE users_main SET Invites=Invites+1 WHERE ID IN (".implode(',',$UserIDs).")"); } } - + if($BiWeek == 8) { $DB->query("TRUNCATE TABLE top_snatchers;"); @@ -1051,7 +1051,7 @@ function next_hour() { echo "-------------------------\n\n"; -if (check_perms('admin_schedule')) { +if (check_perms('admin_schedule')) { echo '
    ';
     	View::show_footer();
     }
    diff --git a/sections/staff/index.php b/sections/staff/index.php
    index a312ccf9..f94c2c1d 100644
    --- a/sections/staff/index.php
    +++ b/sections/staff/index.php
    @@ -105,7 +105,7 @@
     			
    - +
    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'); - + send_irc("PRIVMSG ".ADMIN_CHAN." :!blog " . $_POST['title']); - + header('Location: staffblog.php'); break; } @@ -72,12 +72,12 @@ -
    +
    - + - +

    Title

    />

    Body

    @@ -90,7 +90,7 @@

    -" class="box">
    - posted by - + - Edit Delete @@ -127,7 +127,7 @@

    - diff --git a/sections/staffpm/ajax_delete_response.php b/sections/staffpm/ajax_delete_response.php index 30653bd1..f1c1b9e1 100644 --- a/sections/staffpm/ajax_delete_response.php +++ b/sections/staffpm/ajax_delete_response.php @@ -19,9 +19,9 @@ } if ($ID = (int)$_POST['id']) { - $DB->query("DELETE FROM staff_pm_responses WHERE ID=$ID"); + $DB->query("DELETE FROM staff_pm_responses WHERE ID=$ID"); echo '1'; - + } else { // No id echo '-1'; diff --git a/sections/staffpm/ajax_edit_response.php b/sections/staffpm/ajax_edit_response.php index a37add79..7f576813 100644 --- a/sections/staffpm/ajax_edit_response.php +++ b/sections/staffpm/ajax_edit_response.php @@ -40,7 +40,7 @@ // No id echo '-2'; } - + } else { // No message/name echo '-1'; diff --git a/sections/staffpm/ajax_get_response.php b/sections/staffpm/ajax_get_response.php index b1562d7e..3f590bbc 100644 --- a/sections/staffpm/ajax_get_response.php +++ b/sections/staffpm/ajax_get_response.php @@ -28,7 +28,7 @@ $Text = new TEXT; echo $Text->full_format($Message); } - + } else { // No id echo '-1'; diff --git a/sections/staffpm/assign.php b/sections/staffpm/assign.php index b04d1c29..63a37b38 100644 --- a/sections/staffpm/assign.php +++ b/sections/staffpm/assign.php @@ -8,7 +8,7 @@ // FLS, check level of conversation $DB->query("SELECT Level FROM staff_pm_conversations WHERE ID=$ConvID"); list($Level) = $DB->next_record; - + if ($Level == 0) { // FLS conversation, assign to staff (moderator) if(!empty($_GET['to'])) { @@ -24,7 +24,7 @@ error(404); break; } - + $DB->query("UPDATE staff_pm_conversations SET Status='Unanswered', Level=".$Level." WHERE ID=$ConvID"); header('Location: staffpm.php'); } else { @@ -34,16 +34,16 @@ // FLS trying to assign non-FLS conversation error(403); } - + } elseif ($ConvID = (int)$_POST['convid']) { // Staff (via ajax), get current assign of conversation $DB->query("SELECT Level, AssignedToUser FROM staff_pm_conversations WHERE ID=$ConvID"); list($Level, $AssignedToUser) = $DB->next_record; - + if ($LoggedUser['EffectiveClass'] >= $Level || $AssignedToUser == $LoggedUser['ID']) { // Staff member is allowed to assign conversation, assign list($LevelType, $NewLevel) = explode("_", db_string($_POST['assign'])); - + if ($LevelType == 'class') { // Assign to class $DB->query("UPDATE staff_pm_conversations SET Status='Unanswered', Level=$NewLevel, AssignedToUser=NULL WHERE ID=$ConvID"); @@ -53,18 +53,18 @@ if (!$Level) { error("Assign to user not found."); } - + // Assign to user $DB->query("UPDATE staff_pm_conversations SET Status='Unanswered', AssignedToUser=$NewLevel, Level=$Level WHERE ID=$ConvID"); } echo '1'; - + } else { // Staff member is not allowed to assign conversation echo '-1'; } - + } else { // No id header('Location: staffpm.php'); diff --git a/sections/staffpm/common_responses.php b/sections/staffpm/common_responses.php index 6c7f89fb..b3813fe1 100644 --- a/sections/staffpm/common_responses.php +++ b/sections/staffpm/common_responses.php @@ -37,15 +37,15 @@
    - Name: - Name: +
    -
    @@ -63,7 +63,7 @@ // List common responses $DB->query("SELECT ID, Message, Name FROM staff_pm_responses ORDER BY ID DESC"); while(list($ID, $Message, $Name) = $DB->next_record()) { - + ?>
    @@ -71,7 +71,7 @@
    - Name: + Name:
    @@ -88,7 +88,7 @@
    diff --git a/sections/staffpm/get_post.php b/sections/staffpm/get_post.php index b29b51ca..bfc8172e 100644 --- a/sections/staffpm/get_post.php +++ b/sections/staffpm/get_post.php @@ -3,10 +3,10 @@ /*********************************************************************\ //--------------Get Post--------------------------------------------// -This gets the raw BBCode of a post. It's used for editing and -quoting posts. +This gets the raw BBCode of a post. It's used for editing and +quoting posts. -It gets called if $_GET['action'] == 'get_post'. It requires +It gets called if $_GET['action'] == 'get_post'. It requires $_GET['post'], which is the ID of the post. \*********************************************************************/ @@ -21,14 +21,14 @@ // Message is selected providing the user quoting is the guy who opened the PM or has // the right level -$DB->query("SELECT m.Message, c.Level, c.UserID +$DB->query("SELECT m.Message, c.Level, c.UserID FROM staff_pm_messages as m JOIN staff_pm_conversations AS c ON m.ConvID=c.ID WHERE m.ID='$PostID'"); list($Message, $Level, $UserID) = $DB->next_record(MYSQLI_NUM); if (($LoggedUser['ID'] == $UserID) || ($IsFLS && $LoggedUser['Class'] >= $Level)) { - // This gets sent to the browser, which echoes it wherever + // This gets sent to the browser, which echoes it wherever echo trim($Message); } else { error(403); diff --git a/sections/staffpm/index.php b/sections/staffpm/index.php index 02da29de..92d5ebc5 100644 --- a/sections/staffpm/index.php +++ b/sections/staffpm/index.php @@ -21,7 +21,7 @@ $IsFLS = ($IsStaff || $LoggedUser['ExtraClasses'][41]); switch($_REQUEST['action']) { - case 'viewconv': + case 'viewconv': require('viewconv.php'); break; case 'takepost': diff --git a/sections/staffpm/makedonor.php b/sections/staffpm/makedonor.php index 6d6cb680..1aca71f8 100644 --- a/sections/staffpm/makedonor.php +++ b/sections/staffpm/makedonor.php @@ -2,11 +2,11 @@ if (!is_number($_GET['id'])) { error(404); } - + if (!check_perms('users_give_donor')) { error(403); } - + $ConvID = (int)$_GET['id']; $DB->query("SELECT c.Subject, c.UserID, c.Level, c.AssignedToUser, c.Unread, c.Status, u.Donor FROM staff_pm_conversations AS c @@ -16,14 +16,14 @@ if ($DB->record_count() == 0) { error(404); } - + $Message = "Thank for for helping to support the site. It's users like you who make all of this possible."; - + if ((int)$Donor === 0) { $Msg = db_string(sqltime() . ' - Donated: http://'.NONSSL_SITE_URL."/staffpm.php?action=viewconv&id=$ConvID\n\n"); - $DB->query("UPDATE users_info + $DB->query("UPDATE users_info SET Donor='1', - AdminComment = CONCAT('$Msg',AdminComment) + AdminComment = CONCAT('$Msg',AdminComment) WHERE UserID = $UserID"); $DB->query("UPDATE users_main SET Invites=Invites+2 WHERE ID = $UserID"); @@ -35,8 +35,8 @@ } $DB->query("INSERT INTO staff_pm_messages (UserID, SentDate, Message, ConvID) VALUES (".$LoggedUser['ID'].", '".sqltime()."', '".db_string($Message)."', $ConvID)"); - $DB->query("UPDATE staff_pm_conversations - SET Date='".sqltime()."', Unread=true, + $DB->query("UPDATE staff_pm_conversations + SET Date='".sqltime()."', Unread=true, Status='Resolved', ResolverID=".$LoggedUser['ID']." WHERE ID=$ConvID"); header('Location: staffpm.php'); diff --git a/sections/staffpm/multiresolve.php b/sections/staffpm/multiresolve.php index 63756dd3..c559158e 100644 --- a/sections/staffpm/multiresolve.php +++ b/sections/staffpm/multiresolve.php @@ -3,11 +3,11 @@ $Queries = array(); foreach ($IDs as &$ID) { $ID = (int)$ID; - + // Check if conversation belongs to user $DB->query("SELECT UserID, AssignedToUser FROM staff_pm_conversations WHERE ID=$ID"); list($UserID, $AssignedToUser) = $DB->next_record(); - + if ($UserID == $LoggedUser['ID'] || $DisplayStaff == '1' || $UserID == $AssignedToUser) { // Conversation belongs to user or user is staff, queue query $Queries[] = "UPDATE staff_pm_conversations SET Status='Resolved', ResolverID=".$LoggedUser['ID']." WHERE ID=$ID"; @@ -16,7 +16,7 @@ error(403); } } - + // Run queries foreach ($Queries as $Query) { $DB->query($Query); @@ -27,7 +27,7 @@ // Done! Return to inbox header("Location: staffpm.php"); - + } else { // No id header("Location: staffpm.php"); diff --git a/sections/staffpm/resolve.php b/sections/staffpm/resolve.php index 3fe11535..c7eba539 100644 --- a/sections/staffpm/resolve.php +++ b/sections/staffpm/resolve.php @@ -3,7 +3,7 @@ // Check if conversation belongs to user $DB->query("SELECT UserID, AssignedToUser FROM staff_pm_conversations WHERE ID=$ID"); list($UserID, $AssignedToUser) = $DB->next_record(); - + if ($UserID == $LoggedUser['ID'] || $IsFLS || $AssignedToUser == $LoggedUser['ID']) { // Conversation belongs to user or user is staff, resolve it $DB->query("UPDATE staff_pm_conversations SET Status='Resolved', ResolverID=".$LoggedUser['ID']." WHERE ID=$ID"); diff --git a/sections/staffpm/takepost.php b/sections/staffpm/takepost.php index dc8039c4..bb6e3867 100644 --- a/sections/staffpm/takepost.php +++ b/sections/staffpm/takepost.php @@ -4,12 +4,12 @@ // New staff pm conversation $Level = db_string($_POST['level']); $DB->query(" - INSERT INTO staff_pm_conversations + INSERT INTO staff_pm_conversations (Subject, Status, Level, UserID, Date) VALUES ('$Subject', 'Unanswered', $Level, ".$LoggedUser['ID'].", '".sqltime()."')" ); - + // New message $ConvID = $DB->inserted_id(); $DB->query(" @@ -18,16 +18,16 @@ VALUES (".$LoggedUser['ID'].", '".sqltime()."', '$Message', $ConvID)" ); - + header('Location: staffpm.php'); - + } elseif ($ConvID = (int)$_POST['convid']) { // Check if conversation belongs to user $DB->query("SELECT UserID, AssignedToUser FROM staff_pm_conversations WHERE ID=$ConvID"); list($UserID, $AssignedToUser) = $DB->next_record(); - - + + if ($UserID == $LoggedUser['ID'] || $IsFLS || $UserID == $AssignedToUser) { // Response to existing conversation $DB->query(" @@ -36,7 +36,7 @@ VALUES (".$LoggedUser['ID'].", '".sqltime()."', '$Message', $ConvID)" ); - + // Update conversation if ($IsFLS) { // FLS/Staff @@ -50,22 +50,22 @@ // Clear cache for user $Cache->delete_value('staff_pm_new_'.$UserID); $Cache->delete_value('staff_pm_new_'.$LoggedUser['ID']); - + header("Location: staffpm.php?action=viewconv&id=$ConvID"); } else { // User is trying to respond to conversation that does no belong to them error(403); } - + } else { // Message but no subject or conversation id header("Location: staffpm.php?action=viewconv&id=$ConvID"); - + } } elseif ($ConvID = (int)$_POST['convid']) { // No message, but conversation id header("Location: staffpm.php?action=viewconv&id=$ConvID"); - + } else { // No message or conversation id header('Location: staffpm.php'); diff --git a/sections/staffpm/unresolve.php b/sections/staffpm/unresolve.php index d91412a6..bca816be 100644 --- a/sections/staffpm/unresolve.php +++ b/sections/staffpm/unresolve.php @@ -3,8 +3,8 @@ // Check if conversation belongs to user $DB->query("SELECT UserID, Level, AssignedToUser FROM staff_pm_conversations WHERE ID=$ID"); list($UserID, $Level, $AssignedToUser) = $DB->next_record(); - - if ($UserID == $LoggedUser['ID'] || ($IsFLS && $Level == 0) || + + if ($UserID == $LoggedUser['ID'] || ($IsFLS && $Level == 0) || $AssignedToUser == $LoggedUser['ID'] || ($IsStaff && $Level <= $LoggedUser['EffectiveClass'])) { /*if($Level != 0 && $IsStaff == false) { error(403); @@ -14,7 +14,7 @@ $DB->query("UPDATE staff_pm_conversations SET Status='Unanswered' WHERE ID=$ID"); // Clear cache for user $Cache->delete_value('num_staff_pms_'.$LoggedUser['ID']); - + header('Location: staffpm.php'); } else { // Conversation does not belong to user diff --git a/sections/staffpm/user_inbox.php b/sections/staffpm/user_inbox.php index ce0fd3dc..b1d0562d 100644 --- a/sections/staffpm/user_inbox.php +++ b/sections/staffpm/user_inbox.php @@ -7,16 +7,16 @@ // Get messages $StaffPMs = $DB->query(" SELECT - ID, - Subject, - UserID, - Status, - Level, - AssignedToUser, - Date, + ID, + Subject, + UserID, + Status, + Level, + AssignedToUser, + Date, Unread - FROM staff_pm_conversations - WHERE UserID=".$LoggedUser['ID']." + FROM staff_pm_conversations + WHERE UserID=".$LoggedUser['ID']." ORDER BY Status, Date DESC" ); @@ -73,7 +73,7 @@

    Resolved messages

    - +
    @@ -87,7 +87,7 @@ $Assigned = ($Level == 0) ? "First Line Support" : $ClassLevels[$Level]['Name']; // No + on Sysops if ($Assigned != 'Sysop') { $Assigned .= "+"; } - + // Table row ?> diff --git a/sections/staffpm/viewconv.php b/sections/staffpm/viewconv.php index f1ea5c4e..835ee207 100644 --- a/sections/staffpm/viewconv.php +++ b/sections/staffpm/viewconv.php @@ -215,9 +215,9 @@ - -
    +
    diff --git a/sections/stats/users.php b/sections/stats/users.php index f17386f6..5b28709b 100644 --- a/sections/stats/users.php +++ b/sections/stats/users.php @@ -4,13 +4,13 @@ $DB->query('SELECT Code, Users FROM users_geodistribution'); $Data = $DB->to_array(); $Count = $DB->record_count()-1; - + if($Count<30) { $CountryMinThreshold = $Count; } else { $CountryMinThreshold = 30; } - + $CountryMax = ceil(log(Max(1,$Data[0][1]))/log(2))+1; $CountryMin = floor(log(Max(1,$Data[$CountryMinThreshold][1]))/log(2)); @@ -29,7 +29,7 @@ } } reset($Rank); - + for ($i=$CountryMin;$i<=$CountryMax;$i++) { $LogIncrements[] = Format::human_format(pow(2,$i)); } diff --git a/sections/tools/data/database_specifics.php b/sections/tools/data/database_specifics.php index b23c9c46..d20de4ab 100644 --- a/sections/tools/data/database_specifics.php +++ b/sections/tools/data/database_specifics.php @@ -107,7 +107,7 @@ foreach ($Tables as $Table) { list($Name,$Engine,,,$Rows,$RowSize,$DataSize,,$IndexSize) = $Table; $Row = ($Row == 'a') ? 'b' : 'a'; - + $TotalRows += $Rows; $TotalDataSize += $DataSize; $TotalIndexSize += $IndexSize; diff --git a/sections/tools/data/donation_log.php b/sections/tools/data/donation_log.php index 02e3aa05..37bca4ef 100644 --- a/sections/tools/data/donation_log.php +++ b/sections/tools/data/donation_log.php @@ -7,13 +7,13 @@ list($Page,$Limit) = Format::page_limit(DONATIONS_PER_PAGE); -$sql = "SELECT +$sql = "SELECT SQL_CALC_FOUND_ROWS - d.UserID, - d.Amount, - d.Currency, - d.Email, - d.Time + d.UserID, + d.Amount, + d.Currency, + d.Email, + d.Time FROM donations AS d "; if(!empty($_GET['search'])) { $sql .= "WHERE d.Email LIKE '%".db_string($_GET['search'])."%' "; @@ -63,7 +63,7 @@ -
    Subject
    +

    diff --git a/sections/tools/data/economic_stats.php b/sections/tools/data/economic_stats.php index 1077ae95..6ac091c3 100644 --- a/sections/tools/data/economic_stats.php +++ b/sections/tools/data/economic_stats.php @@ -2,7 +2,7 @@ /* Tools necessary for economic management 1. Current overall stats (!economy) -2. Statistical traffic trends in a graph +2. Statistical traffic trends in a graph a. All time / 1 year (whichever is smaller) b. 1 month c. 1 week diff --git a/sections/tools/data/invite_pool.php b/sections/tools/data/invite_pool.php index 38c1f06d..b7660d29 100644 --- a/sections/tools/data/invite_pool.php +++ b/sections/tools/data/invite_pool.php @@ -16,7 +16,7 @@ $Search = ""; } -$sql = "SELECT +$sql = "SELECT SQL_CALC_FOUND_ROWS um.ID, i.InviteKey, @@ -51,7 +51,7 @@ - +


    diff --git a/sections/tools/data/registration_log.php b/sections/tools/data/registration_log.php index d970e665..b11cd85c 100644 --- a/sections/tools/data/registration_log.php +++ b/sections/tools/data/registration_log.php @@ -5,7 +5,7 @@ list($Page,$Limit) = Format::page_limit(USERS_PER_PAGE); -$RS = $DB->query("SELECT +$RS = $DB->query("SELECT SQL_CALC_FOUND_ROWS m.ID, m.IP, @@ -32,12 +32,12 @@ ii.Donor, ii.Warned, ii.JoinDate, - (SELECT COUNT(h2.UserID) FROM users_history_ips AS h2 WHERE h2.IP=im.IP) AS InviterUses - FROM users_main AS m + (SELECT COUNT(h2.UserID) FROM users_history_ips AS h2 WHERE h2.IP=im.IP) AS InviterUses + FROM users_main AS m LEFT JOIN users_info AS i ON i.UserID=m.ID LEFT JOIN users_main AS im ON i.Inviter = im.ID LEFT JOIN users_info AS ii ON i.Inviter = ii.UserID - WHERE i.JoinDate > '".time_minus(3600*24*3)."' + WHERE i.JoinDate > '".time_minus(3600*24*3)."' ORDER BY i.Joindate DESC LIMIT $Limit"); $DB->query("SELECT FOUND_ROWS()"); list($Results) = $DB->next_record(); diff --git a/sections/tools/data/service_stats.php b/sections/tools/data/service_stats.php index 1a4545d9..720278ab 100644 --- a/sections/tools/data/service_stats.php +++ b/sections/tools/data/service_stats.php @@ -1,8 +1,8 @@ flush(); + $Cache->flush(); } $DB->query('SHOW GLOBAL STATUS'); $DBStats =$DB->to_array('Variable_name'); diff --git a/sections/tools/data/suggestions.php b/sections/tools/data/suggestions.php index 01541a4c..411d8e05 100644 --- a/sections/tools/data/suggestions.php +++ b/sections/tools/data/suggestions.php @@ -34,9 +34,9 @@ Count query("SELECT - s.UserID, count(s.ThreadID) AS C - FROM marked_suggestions AS s + $DB->query("SELECT + s.UserID, count(s.ThreadID) AS C + FROM marked_suggestions AS s GROUP BY s.UserID ORDER BY c DESC LIMIT 15"); $Row = 'b'; while ( list ($UserID, $Count) = $DB->next_record() ) { @@ -57,9 +57,9 @@ Count query("SELECT - LastPostAuthorID, count(LastPostAuthorID) AS C - FROM forums_topics AS f + $DB->query("SELECT + LastPostAuthorID, count(LastPostAuthorID) AS C + FROM forums_topics AS f WHERE ForumID = 63 AND f.Title LIKE '[implemented]%' GROUP BY LastPostAuthorID ORDER BY c DESC LIMIT 15"); $Row = 'b'; @@ -82,8 +82,8 @@ query("SELECT - LastPostAuthorID, count(LastPostAuthorID) AS C - FROM forums_topics AS f + LastPostAuthorID, count(LastPostAuthorID) AS C + FROM forums_topics AS f WHERE ForumID = 63 AND f.Title LIKE '[rejected]%' GROUP BY LastPostAuthorID ORDER BY c DESC LIMIT 15"); $Row = 'b'; diff --git a/sections/tools/data/torrent_stats.php b/sections/tools/data/torrent_stats.php index 361e822f..8aa5063c 100644 --- a/sections/tools/data/torrent_stats.php +++ b/sections/tools/data/torrent_stats.php @@ -2,7 +2,7 @@ if(!check_perms('site_view_flow')) { error(403); } View::show_header('Torrents'); -if (!$TorrentStats = $Cache->get_value('new_torrent_stats')) { +if (!$TorrentStats = $Cache->get_value('new_torrent_stats')) { $DB->query("SELECT COUNT(ID), SUM(Size), SUM(FileCount) FROM torrents"); list($TorrentCount, $TotalSize, $TotalFiles) = $DB->next_record(); $DB->query("SELECT COUNT(ID) FROM users_main WHERE Enabled='1'"); diff --git a/sections/tools/data/upscale_pool.php b/sections/tools/data/upscale_pool.php index 3e301462..563db3c4 100644 --- a/sections/tools/data/upscale_pool.php +++ b/sections/tools/data/upscale_pool.php @@ -4,7 +4,7 @@ define('USERS_PER_PAGE', 50); list($Page,$Limit) = Format::page_limit(USERS_PER_PAGE); -$RS = $DB->query("SELECT +$RS = $DB->query("SELECT SQL_CALC_FOUND_ROWS m.ID, m.Username, @@ -18,7 +18,7 @@ i.RatioWatchEnds, i.RatioWatchDownload, m.RequiredRatio - FROM users_main AS m + FROM users_main AS m LEFT JOIN users_info AS i ON i.UserID=m.ID WHERE i.RatioWatchEnds != '0000-00-00 00:00:00' AND m.Enabled = '1' diff --git a/sections/tools/data/user_flow.php b/sections/tools/data/user_flow.php index 50052f42..57daf3e7 100644 --- a/sections/tools/data/user_flow.php +++ b/sections/tools/data/user_flow.php @@ -119,7 +119,7 @@ (+) Joined (-) Manual (-) Ratio - (-) Inactivity + (-) Inactivity (-) Total Net Growth diff --git a/sections/tools/index.php b/sections/tools/index.php index 9e02b573..0e72ec11 100644 --- a/sections/tools/index.php +++ b/sections/tools/index.php @@ -89,7 +89,7 @@ case 'recommend_alter': include('managers/recommend_alter.php'); break; - + case 'recommend_restore': include('managers/recommend_restore.php'); break; @@ -101,7 +101,7 @@ case 'eb_alter': include('managers/eb_alter.php'); break; - + case 'eb_search': include('managers/eb_search.php'); break; @@ -150,15 +150,15 @@ if(!check_perms('admin_manage_news')){ error(403); } $DB->query("INSERT INTO news (UserID, Title, Body, Time) VALUES ('$LoggedUser[ID]', '".db_string($_POST['title'])."', '".db_string($_POST['body'])."', '".sqltime()."')"); + - - + $Cache->cache_value('news_latest_id', $DB->inserted_id(), 0); $Cache->delete_value('news'); - + header('Location: index.php'); break; - + case 'tokens': include('managers/tokens.php'); break; @@ -189,7 +189,7 @@ error(403); } $Values = unserialize($Values); - } + } if (!empty($_POST['submit'])) { $Err = $Val->ValidateForm($_POST); @@ -365,31 +365,31 @@ case 'sandbox2': include('misc/sandbox2.php'); break; - + case 'sandbox3': include('misc/sandbox3.php'); break; - + case 'sandbox4': include('misc/sandbox4.php'); break; - + case 'sandbox5': include('misc/sandbox5.php'); break; - + case 'sandbox6': include('misc/sandbox6.php'); break; - + case 'sandbox7': include('misc/sandbox7.php'); break; - + case 'sandbox8': include('misc/sandbox8.php'); break; - + case 'public_sandbox': include('misc/public_sandbox.php'); break; diff --git a/sections/tools/managers/bans.php b/sections/tools/managers/bans.php index c1fa511d..09254c6f 100644 --- a/sections/tools/managers/bans.php +++ b/sections/tools/managers/bans.php @@ -15,7 +15,7 @@ $Val->SetFields('notes', '1','string','You must include the reason for the ban.'); $Err=$Val->ValidateForm($_POST); // Validate the form if($Err){ error($Err); } - + $Notes = db_string($_POST['notes']); $Start = Tools::ip_to_unsigned($_POST['start']); //Sanitized by Validation regex $End = Tools::ip_to_unsigned($_POST['end']); //See above @@ -89,7 +89,7 @@ - +
    diff --git a/sections/tools/managers/dnu_alter.php b/sections/tools/managers/dnu_alter.php index 1c42ca34..eef51699 100644 --- a/sections/tools/managers/dnu_alter.php +++ b/sections/tools/managers/dnu_alter.php @@ -24,7 +24,7 @@ Time='".sqltime()."' WHERE ID='$P[id]'"); } else { //Create - $DB->query("INSERT INTO do_not_upload + $DB->query("INSERT INTO do_not_upload (Name, Comment, UserID, Time) VALUES ('$P[name]','$P[comment]','$LoggedUser[ID]','".sqltime()."')"); } diff --git a/sections/tools/managers/eb.php b/sections/tools/managers/eb.php index c4b77fb0..d466f335 100644 --- a/sections/tools/managers/eb.php +++ b/sections/tools/managers/eb.php @@ -13,7 +13,7 @@ eb.Time, eb.Email, eb.Comment - FROM email_blacklist AS eb + FROM email_blacklist AS eb ORDER BY eb.Time DESC LIMIT $Limit"); $Results = $DB->to_array(false, MYSQLI_ASSOC, false); $DB->query("SELECT FOUND_ROWS()"); @@ -49,7 +49,7 @@ diff --git a/sections/tools/managers/eb_alter.php b/sections/tools/managers/eb_alter.php index 770f3f72..a399b2ed 100644 --- a/sections/tools/managers/eb_alter.php +++ b/sections/tools/managers/eb_alter.php @@ -24,7 +24,7 @@ Time='".sqltime()."' WHERE ID='$P[id]'"); } else { //Create - $DB->query("INSERT INTO email_blacklist + $DB->query("INSERT INTO email_blacklist (Email, Comment, UserID, Time) VALUES ('$P[email]','$P[comment]','$LoggedUser[ID]','".sqltime()."')"); } diff --git a/sections/tools/managers/eb_search.php b/sections/tools/managers/eb_search.php index 62ef5217..132776a1 100644 --- a/sections/tools/managers/eb_search.php +++ b/sections/tools/managers/eb_search.php @@ -29,7 +29,7 @@ if ($Count > 0) { foreach ($EmailResults as $Email) { - $Emails[] = array("id" => (int) $Email['ID'], "email" => $Email['Email'], + $Emails[] = array("id" => (int) $Email['ID'], "email" => $Email['Email'], "comment" => $Email['Comment'], "userid" => (int) $Email['UserID'], "time" => $Email['Time']); } diff --git a/sections/tools/managers/forum_list.php b/sections/tools/managers/forum_list.php index 0190abf8..80f8b7d6 100644 --- a/sections/tools/managers/forum_list.php +++ b/sections/tools/managers/forum_list.php @@ -4,7 +4,7 @@ function class_list($Selected=0){ $Return = ''; foreach ($Classes as $ID => $Class) { if ($Class['Secondary']) { continue; } - + $Name = $Class['Name']; $Level = $Class['Level']; $Return.='