From 888e8708d4500d6762b8a3010d0ad8361372c51a Mon Sep 17 00:00:00 2001 From: Git Date: Thu, 4 Jul 2013 08:00:56 +0000 Subject: [PATCH] Empty commit --- CONTRIBUTING.md | 0 classes/torrent_form.class.php | 12 +- classes/users.class.php | 25 +- design/privateheader.php | 2 +- docs/CHANGES.txt | 6 + docs/CodingStandards.txt | 238 ++++---- image.php | 184 +----- sections/ajax/collage.php | 59 ++ sections/ajax/index.php | 5 +- sections/ajax/preview.php | 1 - sections/api/index.php | 24 +- sections/artist/artist.php | 2 +- sections/collages/browse.php | 2 +- sections/donate/config.php | 5 +- sections/donate/donate.php | 5 +- sections/donate/donate_gpal.php | 7 +- sections/feeds/index.php | 74 +-- sections/image/index.php | 18 +- sections/inbox/inbox.php | 2 +- sections/register/index.php | 22 +- sections/reports/ajax_claim_report.php | 10 +- sections/reports/ajax_resolve_report.php | 26 +- sections/reports/report.php | 138 +++-- sections/reports/reports.php | 83 +-- sections/reports/stats.php | 96 +-- sections/reports/takecompose.php | 6 +- sections/reports/takereport.php | 56 +- sections/reports/takeresolve.php | 25 +- sections/requests/new_edit.php | 2 +- sections/requests/requests.php | 6 +- sections/tools/data/bitcoin_balance.php | 15 +- sections/tools/data/economic_stats.php | 46 +- sections/tools/data/special_users.php | 9 +- sections/tools/data/torrent_stats.php | 21 +- sections/tools/index.php | 3 + sections/tools/managers/forum_alter.php | 51 +- sections/tools/managers/forum_list.php | 23 +- sections/tools/managers/news.php | 12 +- sections/tools/managers/official_tags.php | 27 +- sections/tools/managers/permissions_list.php | 29 +- sections/tools/managers/recommend_alter.php | 9 +- sections/tools/managers/recommend_restore.php | 4 +- sections/tools/managers/whitelist_alter.php | 25 +- sections/tools/managers/whitelist_list.php | 5 +- sections/tools/misc/bbcode_sandbox.php | 16 + sections/tools/misc/tags.php | 76 ++- sections/tools/tools.php | 1 + sections/top10/history.php | 47 +- sections/top10/torrents.php | 2 +- sections/torrents/add_alias.php | 50 +- sections/torrents/browse.php | 546 ++++++++++-------- sections/torrents/browse2.php | 182 +++--- sections/torrents/delete_alias.php | 61 +- sections/torrents/details.php | 21 +- sections/torrents/download.php | 106 ++-- sections/torrents/editgroupid.php | 51 +- sections/torrents/functions.php | 161 +++--- sections/torrents/index.php | 132 +++-- sections/torrents/merge.php | 158 +++-- sections/torrents/nonwikiedit.php | 40 +- sections/torrents/remove_cover_art.php | 18 +- sections/torrents/take_warn.php | 51 +- sections/torrents/takedelete.php | 39 +- sections/torrents/takeedit.php | 223 ++++--- sections/torrents/takemasspm.php | 13 +- sections/torrents/takenewgroup.php | 42 +- sections/upload/generate_extra_torrents.php | 18 +- sections/upload/upload.php | 26 +- sections/upload/upload_handle.php | 169 +++--- sections/user/edit.php | 22 +- sections/user/takeedit.php | 2 +- sections/userhistory/catchup.php | 18 +- sections/userhistory/collage_subscribe.php | 20 +- sections/userhistory/email_history.php | 31 +- sections/userhistory/email_history2.php | 35 +- sections/userhistory/ip_history.php | 48 +- sections/userhistory/ip_tracker_history.php | 8 +- sections/userhistory/post_history.php | 81 +-- sections/userhistory/subscribed_collages.php | 64 +- sections/userhistory/thread_subscribe.php | 28 +- sections/userhistory/token_history.php | 24 +- static/functions/bbcode_sandbox.js | 14 + static/functions/jquery-ui.js | 8 +- 83 files changed, 2323 insertions(+), 1749 deletions(-) create mode 100644 CONTRIBUTING.md create mode 100644 sections/ajax/collage.php create mode 100644 sections/tools/misc/bbcode_sandbox.php create mode 100644 static/functions/bbcode_sandbox.js diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..e69de29b diff --git a/classes/torrent_form.class.php b/classes/torrent_form.class.php index b5de0aa3..22d57f94 100644 --- a/classes/torrent_form.class.php +++ b/classes/torrent_form.class.php @@ -199,7 +199,7 @@ function music_form($GenreTags) { foreach ($Torrent['Artists'] as $Importance => $Artists) { foreach ($Artists as $Artist) { ?> - Disabled?> /> + Disabled?> /> Disabled?> /> + Disabled?> /> - Disabled?> /> + Disabled?> />
- + @@ -694,7 +694,7 @@ function audiobook_form() { Tags: - /> + /> @@ -736,7 +736,7 @@ function simple_form($CategoryID) { Tags: - /> + /> Image (optional): diff --git a/classes/users.class.php b/classes/users.class.php index 7ed83b99..422b3d1a 100644 --- a/classes/users.class.php +++ b/classes/users.class.php @@ -269,11 +269,11 @@ public static function update_site_options($UserID, $NewOptions) { /** * Generates a check list of release types, ordered by the user or default - * @global array $SiteOptions + * @param array $SiteOptions * @param boolean $Default Returns the default list if true */ - public static function release_order ($Default = false) { - global $SiteOptions, $ReleaseTypes; + public static function release_order(&$SiteOptions, $Default = false) { + global $ReleaseTypes; $RT = $ReleaseTypes + array( 1024 => 'Guest Appearance', @@ -286,6 +286,12 @@ public static function release_order ($Default = false) { $Defaults = !empty($SiteOptions['HideTypes']); } else { $Sort =& $SiteOptions['SortHide']; + $MissingTypes = array_diff_key($ReleaseTypes, $Sort); + if (!empty($MissingTypes)) { + foreach (array_keys($MissingTypes) as $Missing) { + $Sort[$Missing] = 0; + } + } } foreach ($Sort as $Key => $Val) { @@ -312,9 +318,9 @@ public static function release_order ($Default = false) { * Returns the default order for the sort list in a JS-friendly string * @return string */ - public static function release_order_default_js () { + public static function release_order_default_js(&$SiteOptions) { ob_start(); - self::release_order(true); + self::release_order($SiteOptions, true); $HTML = ob_get_contents(); ob_end_clean(); return json_encode($HTML); @@ -627,7 +633,7 @@ public static function has_avatars_enabled() { * 0 - Enabled everywhere (default), 1 - Disabled, 2 - Searches only * * @param string $Type the type of the input. - * @param boolean $Output echo out html + * @param boolean $Output echo out HTML * @return boolean */ public static function has_autocomplete_enabled($Type, $Output = true) { @@ -635,9 +641,8 @@ public static function has_autocomplete_enabled($Type, $Output = true) { $Enabled = false; if (empty($LoggedUser['AutoComplete'])) { $Enabled = true; - } - elseif ($LoggedUser['AutoComplete'] !== 1) { - switch($Type) { + } elseif ($LoggedUser['AutoComplete'] !== 1) { + switch ($Type) { case 'search': if ($LoggedUser['AutoComplete'] == 2) { $Enabled = true; @@ -651,7 +656,7 @@ public static function has_autocomplete_enabled($Type, $Output = true) { } } if ($Enabled && $Output) { - echo 'data-gazelle-autocomplete="true"'; + echo ' data-gazelle-autocomplete="true"'; } return $Enabled; } diff --git a/design/privateheader.php b/design/privateheader.php index 23b3dfbd..2f6ccf3a 100644 --- a/design/privateheader.php +++ b/design/privateheader.php @@ -637,7 +637,7 @@ class="stat"
  • - + accesskey="a" spellcheck="false" autocomplete="off" onfocus="if (this.value == 'Artists') this.value='';" diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index dff4b40e..183ee934 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -1,5 +1,11 @@ CHANGELOG +2013-07-04 by Ajax +added collages to api + +2013-07-03 by Ajax +Option to enable/disable autocomplete in user profile settings. + 2013-07-01 by alderaan Serve Google Charts API images over HTTPS diff --git a/docs/CodingStandards.txt b/docs/CodingStandards.txt index c7dfba47..fa59a157 100644 --- a/docs/CodingStandards.txt +++ b/docs/CodingStandards.txt @@ -5,6 +5,34 @@ NOTE: The standards defined in this document will likely differ from what is actually seen in the Gazelle code. This document is the first step in properly enforcing coding standards throughout the project. +# Table of Contents + +1. FILE FORMATTING +2. CODE STYLING + 1. Code styling for PHP and JavaScript + 2. Code styling for CSS + 3. Code styling for SQL +3. NAMING CONVENTIONS + 1. Function names + 2. Variable names + 3. Class names + 4. SQL names + 5. Miscellaneous names +4. COMMENTS +5. USER INTERFACE +6. EXAMPLES + 1. PHP examples + 2. CSS examples + 3. SQL examples + + +This document contains the coding standards for Gazelle. +This document is a work-in-progress and is subject to change. + +NOTE: The standards defined in this document will likely differ from +what is actually seen in the Gazelle code. This document is the first +step in properly enforcing coding standards throughout the project. + == TABLE OF CONTENTS == @@ -27,7 +55,7 @@ step in properly enforcing coding standards throughout the project. 6.3 SQL examples - 1. FILE FORMATTING +# FILE FORMATTING Tabs shall always be used for indentation. @@ -41,22 +69,22 @@ File names for PHP, CSS, and JavaScript files shall be all lowercase and use underscores instead of spaces. - 2. CODE STYLING +# CODE STYLING - 2.1 Code styling for PHP and JavaScript +## Code styling for PHP and JavaScript All statement blocks, including functions, shall have the opening brace at the end of the same line with a space before the brace. The astute reader will note that this is K&R style with the exception of functions. -There shall be a space between a control structure statement (e.g. if, -elseif, for) and the following parenthesis. +There shall be a space between a control structure statement (e.g. `if`, +`elseif`, `for`) and the following parenthesis. There shall be a space around conditional operators. When using ternary operators, spaces shall be used around the operators. -For conditional blocks, "elseif" is to be used instead of "else if". +For conditional blocks, `elseif` is to be used instead of `else if`. In loops and conditional blocks, there shall be braces even if there is only one statement. @@ -64,7 +92,7 @@ only one statement. In loops and conditional blocks, the statement(s) shall be placed on the following lines. -When opening a PHP statement, "". +The "not equal to" operator `!=` must be used instead of the alternative +operator `<>`. - 3. NAMING CONVENTIONS +# NAMING CONVENTIONS Function, variable, and class names shall always be descriptive. - 3.1 Function names +## Function names -PHP function names shall be written in lowercase_with_underscores. +PHP function names shall be written in `lowercase_with_underscores`. -JavaScript function names shall be written in camelCase with a leading +JavaScript function names shall be written in `camelCase` with a leading lowercase letter. - 3.2 Variable names +## Variable names -PHP variable names shall be written in CamelCase with a leading +PHP variable names shall be written in `CamelCase` with a leading uppercase letter. -JavaScript global-scope variables shall be written in camelCase with a +JavaScript global-scope variables shall be written in `camelCase` with a leading lowercase letter. JavaScript local-scope variables shall be written in -lowercase_with_underscores. +`lowercase_with_underscores`. - 3.3 Class names +## Class names -PHP class names shall be written in CamelCase with a leading uppercase +PHP class names shall be written in `CamelCase` with a leading uppercase letter. -PHP class constants shall be written in CamelCase with a leading +PHP class constants shall be written in `CamelCase` with a leading uppercase letter. - 3.4 SQL names +## SQL names All SQL keywords shall be written in all UPPERCASE. -All SQL table names shall be written in lowercase_with_underscores. +All SQL table names shall be written in `lowercase_with_underscores`. -All SQL column names shall be written in CamelCase with a leading +All SQL column names shall be written in `CamelCase` with a leading uppercase letter. -All automatically-incremented ID columns shall be named "ID", while the -other columns for ID numbers shall have names like RequestID, TorrentID, +All automatically-incremented ID columns shall be named `ID`, while the +other columns for Identification numbers shall have names like `RequestID`, `TorrentID`, etc. - 3.5 Miscellaneous names +## Miscellaneous names -PHP global constants shall be written in ALL_CAPS. +PHP global constants shall be written in `ALL_CAPS`. -PHP constants true, false, and null shall be written in all lowercase. +PHP constants `true`, `false`, and `null` shall be written in all lowercase. - 4. COMMENTS +# COMMENTS -Use C89-style "/* ... */" comments for multi-line comments. +Use C89-style `/* ... */` comments for multi-line comments. -Use C99-style "// ..." comments for single-line comments. +Use C99-style `// ...` comments for single-line comments. - 5. USER INTERFACE +# USER INTERFACE All button labels shall use sentence case. All table headings shall use sentence case. -All text-based buttons shall use the "brackets" CSS class. +All text-based buttons shall use the `brackets` CSS class. Use common sense for design-related code. Microsoft's UI design guidelines explain when certain form input controls should be used over others to provide a familiar and intuitive interface. Refer to the following links for the most likely issues to encounter in web design: -http://msdn.microsoft.com/en-us/library/windows/desktop/aa511452.aspx -http://msdn.microsoft.com/en-us/library/windows/desktop/aa511453.aspx -http://msdn.microsoft.com/en-us/library/windows/desktop/aa511488.aspx -http://msdn.microsoft.com/en-us/library/windows/desktop/aa511494.aspx + +* http://msdn.microsoft.com/en-us/library/windows/desktop/aa511452.aspx +* http://msdn.microsoft.com/en-us/library/windows/desktop/aa511453.aspx +* http://msdn.microsoft.com/en-us/library/windows/desktop/aa511488.aspx +* http://msdn.microsoft.com/en-us/library/windows/desktop/aa511494.aspx - 6. EXAMPLES +# EXAMPLES - 6.1 PHP examples +## PHP examples -if ($Foo >= 0) { - $SomeString = "this is a string $DiffString with more text"; -} elseif ($Foo == 0) { - // other things happen -} else { - // more magic -} + if ($Foo >= 0) { + $SomeString = "this is a string $DiffString with more text"; + } elseif ($Foo == 0) { + // other things happen + } else { + // more magic + } -function works_magic($Foo, $Bar) { - return $Foo; -} + function works_magic($Foo, $Bar) { + return $Foo; + } -echo ($Foo == true ? 'foo is true' : 'foo is false'); + echo ($Foo == true ? 'foo is true' : 'foo is false'); -if ($Foo == true) { - // magic happens -} + if ($Foo == true) { + // magic happens + } -/* - * This is a good, multi-line comment. - * - * Please comment your code! - */ + /* + * This is a good, multi-line comment. + * + * Please comment your code! + */ -// This is a good, single-line comment. + // This is a good, single-line comment. - 6.2 CSS examples +## CSS examples -link text + link text -.spellcheck { - margin: 10px 0; - font-size: 1.25em; - font-weight: bold; -} + .spellcheck { + margin: 10px 0; + font-size: 1.25em; + font-weight: bold; + } -.linkbox .brackets:before, -.linkbox .brackets:after, -.top10_quantity_links .brackets:before, -.top10_quantity_links .brackets:after { - color: #757575; -} + .linkbox .brackets:before, + .linkbox .brackets:after, + .top10_quantity_links .brackets:before, + .top10_quantity_links .brackets:after { + color: #757575; + } - 6.3 SQL examples +# SQL examples -SELECT - r.ID, e.EditionID, r.Title, r.Year, r.CatalogueNumber, - l.Name AS Label, r.LabelID, r.Image, r.MusicBrainzID -FROM releases AS r - JOIN editions AS e ON e.ReleaseID = r.ID - LEFT JOIN labels AS l ON l.ID = r.LabelID -WHERE r.ID IN ($ReleaseIDsSQL) -ORDER BY e.EditionID, r.Year ASC + SELECT + r.ID, e.EditionID, r.Title, r.Year, r.CatalogueNumber, + l.Name AS Label, r.LabelID, r.Image, r.MusicBrainzID + FROM releases AS r + JOIN editions AS e ON e.ReleaseID = r.ID + LEFT JOIN labels AS l ON l.ID = r.LabelID + WHERE r.ID IN ($ReleaseIDsSQL) + ORDER BY e.EditionID, r.Year ASC -SELECT SQL_CALC_FOUND_ROWS c.ID, c.Subject, cu.Unread, cu.Sticky, - cu.ForwardedTo, cu2.UserID, cu.ReceivedDate AS Date -FROM pm_conversations AS c - LEFT JOIN pm_conversations_users AS cu ON cu.ConvID = c.ID - AND cu.UserID = '1' - LEFT JOIN pm_conversations_users AS cu2 ON cu2.ConvID = c.ID - AND cu2.UserID != '1' - AND cu2.ForwardedTo = 0 - LEFT JOIN users_main AS um ON um.ID = cu2.UserID -WHERE um.Username LIKE 'test' - AND cu.InInbox = '1' -GROUP BY c.ID -ORDER BY cu.Sticky, Date DESC -LIMIT 25 + SELECT SQL_CALC_FOUND_ROWS c.ID, c.Subject, cu.Unread, cu.Sticky, + cu.ForwardedTo, cu2.UserID, cu.ReceivedDate AS Date + FROM pm_conversations AS c + LEFT JOIN pm_conversations_users AS cu ON cu.ConvID = c.ID + AND cu.UserID = '1' + LEFT JOIN pm_conversations_users AS cu2 ON cu2.ConvID = c.ID + AND cu2.UserID != '1' + AND cu2.ForwardedTo = 0 + LEFT JOIN users_main AS um ON um.ID = cu2.UserID + WHERE um.Username LIKE 'test' + AND cu.InInbox = '1' + GROUP BY c.ID + ORDER BY cu.Sticky, Date DESC + LIMIT 25 -SELECT RequestID AS ID, UserID FROM bookmarks_requests - - -EOF + SELECT RequestID AS ID, UserID FROM bookmarks_requests diff --git a/image.php b/image.php index 98382ecb..43ceedbe 100644 --- a/image.php +++ b/image.php @@ -1,10 +1,5 @@ decrypt($_COOKIE['session']); -} -if (isset($LoginCookie)) { - list($SessionID, $UserID) = explode('|~|', $Enc->decrypt($LoginCookie)); - $UserID = (int)$UserID; - $UserInfo = $Cache->get_value("user_info_$UserID"); - $Permissions = $Cache->get_value('perm_'.$UserInfo['PermissionID']); -} - -function check_perms($PermissionName) { - global $Permissions; - return (isset($Permissions['Permissions'][$PermissionName])) ? true : false; -} - -function error($Type) { +function img_error($Type) { header('Content-type: image/gif'); die(file_get_contents(SERVER_ROOT.'/sections/image/'.$Type.'.gif')); } @@ -62,16 +33,6 @@ function invisible($Image) { } -function is_number($Str) { - $Return = true; - if ($Str < 0) { - $Return = false; - } - // We're converting input to a int, then string and comparing to original - $Return = ($Str == strval(intval($Str)) ? true : false); - return $Return; -} - function verysmall($Image) { return ((imagesx($Image) * imagesy($Image)) < 25) ? true : false; } @@ -136,144 +97,5 @@ function image_height($Type, $Data) { } } - -function send_pm($ToID, $FromID, $Subject, $Body, $ConvID = '') { - global $DB, $Cache; - if ($ToID == 0) { - // Don't allow users to send messages to the system - return; - } - if ($ConvID == '') { - $DB->query(" - INSERT INTO pm_conversations (Subject) - VALUES ('$Subject')"); - $ConvID = $DB->inserted_id(); - $DB->query(" - INSERT INTO pm_conversations_users - (UserID, ConvID, InInbox, InSentbox, SentDate, ReceivedDate, UnRead) - VALUES - ('$ToID', '$ConvID', '1', '0', '".sqltime()."', '".sqltime()."', '1')"); - if ($FromID != 0) { - $DB->query(" - INSERT INTO pm_conversations_users - (UserID, ConvID, InInbox, InSentbox, SentDate, ReceivedDate, UnRead) - VALUES - ('$FromID', '$ConvID', '0', '1', '".sqltime()."', '".sqltime()."', '0')"); - } - } else { - $DB->query(" - UPDATE pm_conversations_users - SET - InInbox = '1', - UnRead = '1', - ReceivedDate = '".sqltime()."' - WHERE UserID = '$ToID' - AND ConvID = '$ConvID'"); - - $DB->query(" - UPDATE pm_conversations_users - SET - InSentbox = '1', - SentDate = '".sqltime()."' - WHERE UserID = '$FromID' - AND ConvID = '$ConvID'"); - } - $DB->query(" - INSERT INTO pm_messages - (SenderID, ConvID, SentDate, Body) - VALUES - ('$FromID', '$ConvID', '".sqltime()."', '$Body')"); - - // Clear the caches of the inbox and sentbox - /*$DB->query(" - SELECT UnRead - FROM pm_conversations_users - WHERE ConvID = '$ConvID' - AND UserID = '$ToID'"); - */ - $DB->query(" - SELECT COUNT(ConvID) - FROM pm_conversations_users - WHERE UnRead = '1' - AND UserID = '$ToID' - AND InInbox = '1'"); - list($UnRead) = $DB->next_record(MYSQLI_BOTH, FALSE); - $Cache->cache_value("inbox_new_$ToID", $UnRead); - - //if ($UnRead == 0) { - // $Cache->increment("inbox_new_$ToID"); - //} - return $ConvID; -} - -function send_irc($Raw) { - $IRCSocket = fsockopen(SOCKET_LISTEN_ADDRESS, SOCKET_LISTEN_PORT); - fwrite($IRCSocket, $Raw); - fclose($IRCSocket); -} - -function display_str($Str) { - if ($Str === NULL || $Str === false || is_array($Str)) { - return ''; - } - if ($Str != '' && !is_number($Str)) { - $Str = make_utf8($Str); - $Str = mb_convert_encoding($Str, 'HTML-ENTITIES', 'UTF-8'); - $Str = preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/m", '&', $Str); - - $Replace = array( - "'",'"',"<",">", - '€','‚','ƒ','„','…','†','‡','ˆ', - '‰','Š','‹','Œ','Ž','‘','’','“', - '”','•','–','—','˜','™','š','›', - 'œ','ž','Ÿ' - ); - - $With = array( - ''','"','<','>', - '€','‚','ƒ','„','…','†','‡','ˆ', - '‰','Š','‹','Œ','Ž','‘','’','“', - '”','•','–','—','˜','™','š','›', - 'œ','ž','Ÿ' - ); - - $Str = str_replace($Replace, $With, $Str); - } - return $Str; -} - -function make_utf8($Str) { - if ($Str != '') { - if (is_utf8($Str)) { - $Encoding = 'UTF-8'; - } - if (empty($Encoding)) { - $Encoding = mb_detect_encoding($Str, 'UTF-8, ISO-8859-1'); - } - if (empty($Encoding)) { - $Encoding = 'ISO-8859-1'; - } - if ($Encoding == 'UTF-8') { - return $Str; - } else { - return @mb_convert_encoding($Str, 'UTF-8', $Encoding); - } - } -} - -function is_utf8($Str) { - return preg_match('%^(?: - [\x09\x0A\x0D\x20-\x7E] // ASCII - | [\xC2-\xDF][\x80-\xBF] // non-overlong 2-byte - | \xE0[\xA0-\xBF][\x80-\xBF] // excluding overlongs - | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} // straight 3-byte - | \xED[\x80-\x9F][\x80-\xBF] // excluding surrogates - | \xF0[\x90-\xBF][\x80-\xBF]{2} // planes 1-3 - | [\xF1-\xF3][\x80-\xBF]{3} // planes 4-15 - | \xF4[\x80-\x8F][\x80-\xBF]{2} // plane 16 - )*$%xs', $Str - ); -} - -require(SERVER_ROOT.'/sections/image/index.php'); +require('classes/script_start.php'); // script_start contains all we need and includes sections/image/index.php ?> diff --git a/sections/ajax/collage.php b/sections/ajax/collage.php new file mode 100644 index 00000000..52a2ba40 --- /dev/null +++ b/sections/ajax/collage.php @@ -0,0 +1,59 @@ +get_value($CacheKey); +if ($Data) { + list($K, list($Name, $Description, , , , $Deleted, $CollageCategoryID, $CreatorID, $Locked, $MaxGroups, $MaxGroupsPerUser)) = each($Data); +} else { + $sql = " + SELECT + Name, + Description, + UserID, + Deleted, + CategoryID, + Locked, + MaxGroups, + MaxGroupsPerUser, + Subscribers + FROM collages + WHERE ID='$CollageID'"; + $DB->query($sql); + + if ($DB->record_count() == 0) { + json_die("failure"); + } + + list($Name, $Description, $CreatorID, $Deleted, $CollageCategoryID, $Locked, $MaxGroups, $MaxGroupsPerUser) = $DB->next_record(); +} + + +$Cache->cache_value($CacheKey, array(array($Name, $Description, array(), array(), array(), $Deleted, $CollageCategoryID, $CreatorID, $Locked, $MaxGroups, $MaxGroupsPerUser)), 3600); + +json_die("success", array( + 'id' => (int) $CollageID, + 'name' => $Name, + 'description' => $Text->full_format($Description), + 'creatorID' => (int) $CreatorID, + 'deleted' => (bool) $Deleted, + 'collageCategoryID' => (int) $CollageCategoryID, + 'locked' => (bool) $Locked, + 'categoryID' => (int) $CategoryID, + 'maxGroups' => (int) $MaxGroups, + 'maxGroupsPerUser' => (int) $MaxGroupsPerUser, + 'hasBookmarked' => Bookmarks::has_bookmarked('collage', $CollageID), + 'cached' => (bool) $Cached, +)); + +?> \ No newline at end of file diff --git a/sections/ajax/index.php b/sections/ajax/index.php index b3a7a286..2e7440fd 100644 --- a/sections/ajax/index.php +++ b/sections/ajax/index.php @@ -13,7 +13,7 @@ /* AJAX_LIMIT = array(x,y) = 'x' requests every 'y' seconds. e.g. array(5,10) = 5 requests every 10 seconds */ $AJAX_LIMIT = array(5,10); -$LimitedPages = array('tcomments','user','forum','top10','browse','usersearch','requests','artist','inbox','subscriptions','bookmarks','announcements','notifications','request','better','similar_artists','userhistory','votefavorite','wiki','torrentgroup','news_ajax','user_recents'); +$LimitedPages = array('tcomments','user','forum','top10','browse','usersearch','requests','artist','inbox','subscriptions','bookmarks','announcements','notifications','request','better','similar_artists','userhistory','votefavorite','wiki','torrentgroup','news_ajax','user_recents', 'collage'); // These users aren't rate limited. // This array should contain user IDs. @@ -158,6 +158,9 @@ case 'user_recents': require(SERVER_ROOT . '/sections/ajax/user_recents.php'); break; + case 'collage': + require(SERVER_ROOT . '/sections/ajax/collage.php'); + break; default: // If they're screwing around with the query string json_die("failure"); diff --git a/sections/ajax/preview.php b/sections/ajax/preview.php index 4b251bd8..a0ab9ad1 100644 --- a/sections/ajax/preview.php +++ b/sections/ajax/preview.php @@ -3,7 +3,6 @@ include(SERVER_ROOT.'/classes/text.class.php'); // Text formatting class $Text = new TEXT(true); - if (!empty($_POST['AdminComment'])) { echo $Text->full_format($_POST['AdminComment']); } else { diff --git a/sections/api/index.php b/sections/api/index.php index ef4dac08..865c776d 100644 --- a/sections/api/index.php +++ b/sections/api/index.php @@ -14,7 +14,7 @@ empty($_GET['key']) || !is_number($_GET['uid']) || !is_number($_GET['aid']) || - !in_array($_GET['req'],$Available,true) + !in_array($_GET['req'], $Available, true) ) { error('invalid'); } @@ -23,15 +23,19 @@ $AppID = $_GET['aid']; $UserID = $_GET['uid']; -$App = $Cache->get_value('api_apps_'.$AppID); +$App = $Cache->get_value("api_apps_$AppID"); if (!is_array($App)) { if (!isset($DB)) { require(SERVER_ROOT.'/classes/mysql.class.php'); $DB = new DB_MYSQL; } - $DB->query("SELECT Token, Name FROM api_applications WHERE ID='$AppID' LIMIT 1"); - $App = $DB->to_array(false,MYSQLI_ASSOC); - $Cache->cache_value('api_apps_'.$AppID, $App, 0); + $DB->query(" + SELECT Token, Name + FROM api_applications + WHERE ID = '$AppID' + LIMIT 1"); + $App = $DB->to_array(false, MYSQLI_ASSOC); + $Cache->cache_value("api_apps_$AppID", $App, 0); } $App = $App[0]; @@ -41,7 +45,7 @@ error('invalid'); } } else { - $User = $Cache->get_value('api_users_'.$UserID); + $User = $Cache->get_value("api_users_$UserID"); if (!is_array($User)) { if (!isset($DB)) { require(SERVER_ROOT.'/classes/mysql.class.php'); @@ -50,14 +54,14 @@ $DB->query(" SELECT AppID, Token, State, Time, Access FROM api_users - WHERE UserID='$UserID' + WHERE UserID = '$UserID' LIMIT 1"); //int, no db_string - $User = $DB->to_array('AppID',MYSQLI_ASSOC); - $Cache->cache_value('api_users_'.$UserID, $User, 0); + $User = $DB->to_array('AppID', MYSQLI_ASSOC); + $Cache->cache_value("api_users_$UserID", $User, 0); } $User = $User[$AppID]; - if (md5($User['Token'].$App['Token']) !== $_GET['key']) { + if (md5($User['Token'] . $App['Token']) !== $_GET['key']) { error('invalid'); } } diff --git a/sections/artist/artist.php b/sections/artist/artist.php index cefc42d8..1cf8520b 100644 --- a/sections/artist/artist.php +++ b/sections/artist/artist.php @@ -696,7 +696,7 @@ function compare($X, $Y) { - /> + />
  • diff --git a/sections/collages/browse.php b/sections/collages/browse.php index cf481ea6..236af4fe 100644 --- a/sections/collages/browse.php +++ b/sections/collages/browse.php @@ -180,7 +180,7 @@ Tags (comma-separated): -   + />  />   /> diff --git a/sections/donate/config.php b/sections/donate/config.php index 8fd91f12..5bd17a3c 100644 --- a/sections/donate/config.php +++ b/sections/donate/config.php @@ -18,7 +18,10 @@ function btc_balance() { function btc_address($UserID, $GenAddress = false) { global $DB; $UserID = (int)$UserID; - $DB->query("SELECT BitcoinAddress FROM users_info WHERE UserID = '$UserID'"); + $DB->query(" + SELECT BitcoinAddress + FROM users_info + WHERE UserID = '$UserID'"); list($Addr) = $DB->next_record(); if (!empty($Addr)) { diff --git a/sections/donate/donate.php b/sections/donate/donate.php index c19aecae..14c3de65 100644 --- a/sections/donate/donate.php +++ b/sections/donate/donate.php @@ -4,7 +4,10 @@ //Include the header if (!$UserCount = $Cache->get_value('stats_user_count')) { - $DB->query("SELECT COUNT(ID) FROM users_main WHERE Enabled='1'"); + $DB->query(" + SELECT COUNT(ID) + FROM users_main + WHERE Enabled = '1'"); list($UserCount) = $DB->next_record(); $Cache->cache_value('stats_user_count', $UserCount, 0); //inf cache } diff --git a/sections/donate/donate_gpal.php b/sections/donate/donate_gpal.php index 21d5239b..5e336971 100644 --- a/sections/donate/donate_gpal.php +++ b/sections/donate/donate_gpal.php @@ -8,7 +8,10 @@ } if (!$UserCount = $Cache->get_value('stats_user_count')) { - $DB->query("SELECT COUNT(ID) FROM users_main WHERE Enabled='1'"); + $DB->query(" + SELECT COUNT(ID) + FROM users_main + WHERE Enabled = '1'"); list($UserCount) = $DB->next_record(); $Cache->cache_value('stats_user_count', $UserCount, 0); //inf cache } @@ -28,7 +31,7 @@