summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTING.md0
-rw-r--r--classes/torrent_form.class.php12
-rw-r--r--classes/users.class.php25
-rw-r--r--design/privateheader.php2
-rw-r--r--docs/CHANGES.txt6
-rw-r--r--docs/CodingStandards.txt236
-rw-r--r--image.php184
-rw-r--r--sections/ajax/collage.php59
-rw-r--r--sections/ajax/index.php5
-rw-r--r--sections/ajax/preview.php1
-rw-r--r--sections/api/index.php24
-rw-r--r--sections/artist/artist.php2
-rw-r--r--sections/collages/browse.php2
-rw-r--r--sections/donate/config.php5
-rw-r--r--sections/donate/donate.php5
-rw-r--r--sections/donate/donate_gpal.php7
-rw-r--r--sections/feeds/index.php74
-rw-r--r--sections/image/index.php18
-rw-r--r--sections/inbox/inbox.php2
-rw-r--r--sections/register/index.php22
-rw-r--r--sections/reports/ajax_claim_report.php10
-rw-r--r--sections/reports/ajax_resolve_report.php26
-rw-r--r--sections/reports/report.php138
-rw-r--r--sections/reports/reports.php83
-rw-r--r--sections/reports/stats.php96
-rw-r--r--sections/reports/takecompose.php6
-rw-r--r--sections/reports/takereport.php56
-rw-r--r--sections/reports/takeresolve.php25
-rw-r--r--sections/requests/new_edit.php2
-rw-r--r--sections/requests/requests.php6
-rw-r--r--sections/tools/data/bitcoin_balance.php15
-rw-r--r--sections/tools/data/economic_stats.php46
-rw-r--r--sections/tools/data/special_users.php9
-rw-r--r--sections/tools/data/torrent_stats.php21
-rw-r--r--sections/tools/index.php3
-rw-r--r--sections/tools/managers/forum_alter.php51
-rw-r--r--sections/tools/managers/forum_list.php23
-rw-r--r--sections/tools/managers/news.php12
-rw-r--r--sections/tools/managers/official_tags.php27
-rw-r--r--sections/tools/managers/permissions_list.php29
-rw-r--r--sections/tools/managers/recommend_alter.php9
-rw-r--r--sections/tools/managers/recommend_restore.php4
-rw-r--r--sections/tools/managers/whitelist_alter.php25
-rw-r--r--sections/tools/managers/whitelist_list.php5
-rw-r--r--sections/tools/misc/bbcode_sandbox.php16
-rw-r--r--sections/tools/misc/tags.php76
-rw-r--r--sections/tools/tools.php1
-rw-r--r--sections/top10/history.php47
-rw-r--r--sections/top10/torrents.php2
-rw-r--r--sections/torrents/add_alias.php50
-rw-r--r--sections/torrents/browse.php546
-rw-r--r--sections/torrents/browse2.php182
-rw-r--r--sections/torrents/delete_alias.php61
-rw-r--r--sections/torrents/details.php21
-rw-r--r--sections/torrents/download.php106
-rw-r--r--sections/torrents/editgroupid.php51
-rw-r--r--sections/torrents/functions.php165
-rw-r--r--sections/torrents/index.php132
-rw-r--r--sections/torrents/merge.php158
-rw-r--r--sections/torrents/nonwikiedit.php40
-rw-r--r--sections/torrents/remove_cover_art.php18
-rw-r--r--sections/torrents/take_warn.php51
-rw-r--r--sections/torrents/takedelete.php39
-rw-r--r--sections/torrents/takeedit.php223
-rw-r--r--sections/torrents/takemasspm.php13
-rw-r--r--sections/torrents/takenewgroup.php42
-rw-r--r--sections/upload/generate_extra_torrents.php18
-rw-r--r--sections/upload/upload.php26
-rw-r--r--sections/upload/upload_handle.php169
-rw-r--r--sections/user/edit.php22
-rw-r--r--sections/user/takeedit.php2
-rw-r--r--sections/userhistory/catchup.php18
-rw-r--r--sections/userhistory/collage_subscribe.php20
-rw-r--r--sections/userhistory/email_history.php31
-rw-r--r--sections/userhistory/email_history2.php35
-rw-r--r--sections/userhistory/ip_history.php48
-rw-r--r--sections/userhistory/ip_tracker_history.php8
-rw-r--r--sections/userhistory/post_history.php81
-rw-r--r--sections/userhistory/subscribed_collages.php64
-rw-r--r--sections/userhistory/thread_subscribe.php28
-rw-r--r--sections/userhistory/token_history.php24
-rw-r--r--static/functions/bbcode_sandbox.js14
-rw-r--r--static/functions/jquery-ui.js8
83 files changed, 2324 insertions, 1750 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/CONTRIBUTING.md
diff --git a/classes/torrent_form.class.php b/classes/torrent_form.class.php
index b5de0aa..22d57f9 100644
--- a/classes/torrent_form.class.php
+++ b/classes/torrent_form.class.php
@@ -199,7 +199,7 @@ class TORRENT_FORM {
foreach ($Torrent['Artists'] as $Importance => $Artists) {
foreach ($Artists as $Artist) {
?>
- <input type="text" id="artist" name="artists[]" size="45" value="<?=display_str($Artist['name']) ?>" onblur="CheckVA();" <? Users::has_autocomplete_enabled('other'); ?> <?=$this->Disabled?> />
+ <input type="text" id="artist" name="artists[]" size="45" value="<?=display_str($Artist['name']) ?>" onblur="CheckVA();"<? Users::has_autocomplete_enabled('other'); ?><?=$this->Disabled?> />
<select id="importance" name="importance[]"<?=$this->Disabled?>>
<option value="1"<?=($Importance == '1' ? ' selected="selected"' : '')?>>Main</option>
<option value="2"<?=($Importance == '2' ? ' selected="selected"' : '')?>>Guest</option>
@@ -220,7 +220,7 @@ class TORRENT_FORM {
}
} else {
?>
- <input type="text" id="artist" name="artists[]" size="45" onblur="CheckVA();" <? Users::has_autocomplete_enabled('other'); ?> <?=$this->Disabled?> />
+ <input type="text" id="artist" name="artists[]" size="45" onblur="CheckVA();"<? Users::has_autocomplete_enabled('other'); ?><?=$this->Disabled?> />
<select id="importance" name="importance[]"<?=$this->Disabled?>>
<option value="1">Main</option>
<option value="2">Guest</option>
@@ -586,9 +586,9 @@ function show() {
<? } ?>
</select>
<? } ?>
- <input type="text" id="tags" name="tags" size="40" value="<?=display_str($Torrent['TagList']) ?>" <? Users::has_autocomplete_enabled('other'); ?> <?=$this->Disabled?> />
+ <input type="text" id="tags" name="tags" size="40" value="<?=display_str($Torrent['TagList']) ?>"<? Users::has_autocomplete_enabled('other'); ?><?=$this->Disabled?> />
<br />
- <? Rules::display_site_tag_rules(true) // indent the opening PHP tag with 3 tabs for proper HTML generation ?>
+<? Rules::display_site_tag_rules(true); ?>
</td>
</tr>
<tr>
@@ -694,7 +694,7 @@ function show() {
<tr>
<td class="label">Tags:</td>
<td>
- <input type="text" id="tags" name="tags" size="60" value="<?=display_str($Torrent['TagList']) ?>" <? Users::has_autocomplete_enabled('other'); ?> />
+ <input type="text" id="tags" name="tags" size="60" value="<?=display_str($Torrent['TagList']) ?>"<? Users::has_autocomplete_enabled('other'); ?> />
</td>
</tr>
<tr>
@@ -736,7 +736,7 @@ function show() {
</tr>
<tr>
<td class="label">Tags:</td>
- <td><input type="text" id="tags" name="tags" size="60" value="<?=display_str($Torrent['TagList']) ?>" <? Users::has_autocomplete_enabled('other'); ?>/></td>
+ <td><input type="text" id="tags" name="tags" size="60" value="<?=display_str($Torrent['TagList']) ?>"<? Users::has_autocomplete_enabled('other'); ?> /></td>
</tr>
<tr>
<td class="label">Image (optional):</td>
diff --git a/classes/users.class.php b/classes/users.class.php
index 7ed83b9..422b3d1 100644
--- a/classes/users.class.php
+++ b/classes/users.class.php
@@ -269,11 +269,11 @@ class Users {
/**
* 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 @@ class Users {
$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 @@ class Users {
* 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 @@ class Users {
* 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 @@ class Users {
$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 @@ class Users {
}
}
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 23b3dfb..2f6ccf3 100644
--- a/design/privateheader.php
+++ b/design/privateheader.php
@@ -637,7 +637,7 @@ if (!empty($Alerts) || !empty($ModBar)) {
<li id="searchbar_artists"><span class="hidden">Artist: </span>
<form class="search_form" name="artists" action="artist.php"
method="get">
- <input id="artistsearch" <? Users::has_autocomplete_enabled('search'); ?>
+ <input id="artistsearch"<? Users::has_autocomplete_enabled('search'); ?>
accesskey="a"
spellcheck="false" autocomplete="off"
onfocus="if (this.value == 'Artists') this.value='';"
diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt
index dff4b40..183ee93 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 c7dfba4..fa59a15 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, "<?" shall be used instead of "<?php".
+When opening a PHP statement, `<?` shall be used instead of `<?php`.
Switch cases in index files shall not contain substantial code. The use
of include statements is acceptable.
@@ -72,11 +100,11 @@ of include statements is acceptable.
When building strings in PHP, single quotes shall be used when not
printing a variable.
-When declaring JavaScript variables, "var" shall always be used.
+When declaring JavaScript variables, `var` shall always be used.
- 2.2 Code styling for CSS
+## Code styling for CSS
-"property: value;" pairs shall be separated by a space, and the value
+`property: value;` pairs shall be separated by a space, and the value
shall be followed by a semi-colon.
Multiple, related CSS selectors with the same declarations shall appear
@@ -85,7 +113,7 @@ on multiple lines to improve readability.
The opening brace shall be on the same line as the last related
selector with a space between the selector and the brace.
- 2.3 Code styling for SQL
+## Code styling for SQL
Long SQL queries shall be separated on multiple lines.
@@ -96,169 +124,167 @@ part of a JOIN or other complex statement.
Use indents as appropriate to aid readability.
-The SQL keywords JOIN, RIGHT JOIN, LEFT JOIN must be indented once from
-the SELECT statement.
+The SQL keywords `JOIN`, `RIGHT JOIN`, `LEFT JOIN` must be indented once from
+the `SELECT` statement.
-The SQL keyword AND must be indented once from the WHILE (and similar)
+The SQL keyword `AND` must be indented once from the `WHILE` (and similar)
statements.
-The "not equal to" operator "!=" must be used instead of the alternative
-operator "<>".
+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
-
- 6. EXAMPLES
+* 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.1 PHP examples
-if ($Foo >= 0) {
- $SomeString = "this is a string $DiffString with more text";
-} elseif ($Foo == 0) {
- // other things happen
-} else {
- // more magic
-}
+# EXAMPLES
-function works_magic($Foo, $Bar) {
- return $Foo;
-}
+## PHP examples
-echo ($Foo == true ? 'foo is true' : 'foo is false');
+ if ($Foo >= 0) {
+ $SomeString = "this is a string $DiffString with more text";
+ } elseif ($Foo == 0) {
+ // other things happen
+ } else {
+ // more magic
+ }
-if ($Foo == true) {
- // magic happens
-}
+ function works_magic($Foo, $Bar) {
+ return $Foo;
+ }
-/*
- * This is a good, multi-line comment.
- *
- * Please comment your code!
- */
+ echo ($Foo == true ? 'foo is true' : 'foo is false');
-// This is a good, single-line comment.
+ if ($Foo == true) {
+ // magic happens
+ }
+ /*
+ * This is a good, multi-line comment.
+ *
+ * Please comment your code!
+ */
- 6.2 CSS examples
+ // This is a good, single-line comment.
-<a href="foobar.php" style="font-weight: bold;">link text</a>
-.spellcheck {
- margin: 10px 0;
- font-size: 1.25em;
- font-weight: bold;
-}
+## CSS examples
-.linkbox .brackets:before,
-.linkbox .brackets:after,
-.top10_quantity_links .brackets:before,
-.top10_quantity_links .brackets:after {
- color: #757575;
-}
+ <a href="foobar.php" style="font-weight: bold;">link text</a>
+ .spellcheck {
+ margin: 10px 0;
+ font-size: 1.25em;
+ font-weight: bold;
+ }
- 6.3 SQL examples
+ .linkbox .brackets:before,
+ .linkbox .brackets:after,
+ .top10_quantity_links .brackets:before,
+ .top10_quantity_links .brackets:after {
+ color: #757575;
+ }
-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
+# SQL examples
-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
+ 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 RequestID AS ID, UserID FROM bookmarks_requests
+ 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
-EOF
+ SELECT RequestID AS ID, UserID FROM bookmarks_requests
diff --git a/image.php b/image.php
index 98382ec..43ceedb 100644
--- a/image.php
+++ b/image.php
@@ -1,10 +1,5 @@
<?
-/*-- Image Start Class ---------------------------------*/
-/*------------------------------------------------------*/
-/* Simplified version of script_start, used for the */
-/* sitewide image proxy. */
-/*------------------------------------------------------*/
-/********************************************************/
+// Functions and headers needed by the image proxy
error_reporting(E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR);
if (isset($_SERVER['http_if_modified_since'])) {
@@ -15,35 +10,11 @@ if (isset($_SERVER['http_if_modified_since'])) {
header('Expires: '.date('D, d-M-Y H:i:s \U\T\C', time() + 3600 * 24 * 120)); // 120 days
header('Last-Modified: '.date('D, d-M-Y H:i:s \U\T\C', time()));
-require('classes/config.php'); // The config contains all site wide configuration information as well as memcached rules
-
if (!extension_loaded('gd')) {
error('nogd');
}
-require(SERVER_ROOT.'/classes/cache.class.php'); // Require the caching class
-require(SERVER_ROOT.'/classes/encrypt.class.php'); // Require the encryption class
-require(SERVER_ROOT.'/classes/regex.php');
-
-$Cache = NEW CACHE($MemcachedServers); // Load the caching class
-$Enc = NEW CRYPT; // Load the encryption class
-
-if (isset($_COOKIE['session'])) {
- $LoginCookie = $Enc->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", '&amp;', $Str);
-
- $Replace = array(
- "'",'"',"<",">",
- '&#128;','&#130;','&#131;','&#132;','&#133;','&#134;','&#135;','&#136;',
- '&#137;','&#138;','&#139;','&#140;','&#142;','&#145;','&#146;','&#147;',
- '&#148;','&#149;','&#150;','&#151;','&#152;','&#153;','&#154;','&#155;',
- '&#156;','&#158;','&#159;'
- );
-
- $With = array(
- '&#39;','&quot;','&lt;','&gt;',
- '&#8364;','&#8218;','&#402;','&#8222;','&#8230;','&#8224;','&#8225;','&#710;',
- '&#8240;','&#352;','&#8249;','&#338;','&#381;','&#8216;','&#8217;','&#8220;',
- '&#8221;','&#8226;','&#8211;','&#8212;','&#732;','&#8482;','&#353;','&#8250;',
- '&#339;','&#382;','&#376;'
- );
-
- $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 0000000..52a2ba4
--- /dev/null
+++ b/sections/ajax/collage.php
@@ -0,0 +1,59 @@
+<?
+include(SERVER_ROOT.'/classes/text.class.php'); // Text formatting class
+$Text = new TEXT;
+
+if (empty($_GET['id'])) {
+ json_die("failure", "bad parameters");
+}
+
+$CollageID = $_GET['id'];
+if ($CollageID && !is_number($CollageID)) {
+ json_die("failure");
+}
+
+$CacheKey = "collage_$CollageID";
+$Data = $Cache->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 b3a7a28..2e7440f 100644
--- a/sections/ajax/index.php
+++ b/sections/ajax/index.php
@@ -13,7 +13,7 @@ enforce_login();
/* 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 @@ switch ($_GET['action']) {
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 4b251bd..a0ab9ad 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 ef4dac0..865c776 100644
--- a/sections/api/index.php
+++ b/sections/api/index.php
@@ -14,7 +14,7 @@ if (
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 @@ if (
$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 @@ if ($_GET['req'] === 'access_request') {
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 @@ if ($_GET['req'] === 'access_request') {
$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 cefc42d..1cf8520 100644
--- a/sections/artist/artist.php
+++ b/sections/artist/artist.php
@@ -696,7 +696,7 @@ if (empty($SimilarArray)) {
<input type="hidden" name="action" value="add_similar" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="artistid" value="<?=$ArtistID?>" />
- <input type="text" autocomplete="off" id="artistsimilar" name="artistname" size="20" <? Users::has_autocomplete_enabled('other'); ?>/>
+ <input type="text" autocomplete="off" id="artistsimilar" name="artistname" size="20"<? Users::has_autocomplete_enabled('other'); ?> />
<input type="submit" value="+" />
</form>
</li>
diff --git a/sections/collages/browse.php b/sections/collages/browse.php
index cf481ea..236af4f 100644
--- a/sections/collages/browse.php
+++ b/sections/collages/browse.php
@@ -180,7 +180,7 @@ View::show_header(($BookmarkView)?'Your bookmarked collages':'Browse collages');
<tr id="tagfilter">
<td class="label">Tags (comma-separated):</td>
<td>
- <input type="text" id="tags" name="tags" size="70" value="<?=(!empty($_GET['tags']) ? display_str($_GET['tags']) : '')?> <? Users::has_autocomplete_enabled('other'); ?>" />&nbsp;
+ <input type="text" id="tags" name="tags" size="70" value="<?=(!empty($_GET['tags']) ? display_str($_GET['tags']) : '')?>"<? Users::has_autocomplete_enabled('other'); ?> />&nbsp;
<input type="radio" name="tags_type" id="tags_type0" value="0"<?Format::selected('tags_type',0,'checked')?> /><label for="tags_type0"> Any</label>&nbsp;&nbsp;
<input type="radio" name="tags_type" id="tags_type1" value="1"<?Format::selected('tags_type',1,'checked')?> /><label for="tags_type1"> All</label>
</td>
diff --git a/sections/donate/config.php b/sections/donate/config.php
index 8fd91f1..5bd17a3 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 c19aeca..14c3de6 100644
--- a/sections/donate/donate.php
+++ b/sections/donate/donate.php
@@ -4,7 +4,10 @@ enforce_login();
//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 21d5239..5e33697 100644
--- a/sections/donate/donate_gpal.php
+++ b/sections/donate/donate_gpal.php
@@ -8,7 +8,10 @@ if ($LoggedUser['RatioWatch']) {
}
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 @@ View::show_header('Donate');
<form class="donate_form" name="test_paypal" method="post" action="donate.php">
<input type="hidden" name="action" value="ipn" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
- <?=PAYPAL_SYMBOL?> <input type="text" name="mc_gross" value="<?=number_format(PAYPAL_MINIMUM,2)?>" />
+ <?=PAYPAL_SYMBOL?> <input type="text" name="mc_gross" value="<?=number_format(PAYPAL_MINIMUM, 2)?>" />
<input type="hidden" name="custom" value="<?=$LoggedUser['ID']?>" />
<input type="hidden" name="payment_status" value="Completed" />
<input type="hidden" name="mc_fee" value="0.45" />
diff --git a/sections/feeds/index.php b/sections/feeds/index.php
index 557c032..c7fbc03 100644
--- a/sections/feeds/index.php
+++ b/sections/feeds/index.php
@@ -25,9 +25,12 @@ $User = (int)$_GET['user'];
if (!$Enabled = $Cache->get_value('enabled_'.$User)) {
require(SERVER_ROOT.'/classes/mysql.class.php');
$DB=NEW DB_MYSQL; //Load the database wrapper
- $DB->query("SELECT Enabled FROM users_main WHERE ID='$User'");
+ $DB->query("
+ SELECT Enabled
+ FROM users_main
+ WHERE ID = '$User'");
list($Enabled) = $DB->next_record();
- $Cache->cache_value('enabled_'.$User, $Enabled, 0);
+ $Cache->cache_value("enabled_$User", $Enabled, 0);
}
if (md5($User.RSS_HASH.$_GET['passkey']) != $_GET['auth'] || $Enabled != 1) {
@@ -48,16 +51,17 @@ switch ($_GET['feed']) {
if (!$News = $Cache->get_value('news')) {
require(SERVER_ROOT.'/classes/mysql.class.php'); //Require the database wrapper
$DB=NEW DB_MYSQL; //Load the database wrapper
- $DB->query("SELECT
- ID,
- Title,
- Body,
- Time
+ $DB->query("
+ SELECT
+ ID,
+ Title,
+ Body,
+ Time
FROM news
ORDER BY Time DESC
LIMIT 10");
- $News = $DB->to_array(false,MYSQLI_NUM,false);
- $Cache->cache_value('news',$News,1209600);
+ $News = $DB->to_array(false, MYSQLI_NUM, false);
+ $Cache->cache_value('news', $News, 1209600);
}
$Count = 0;
foreach ($News as $NewsItem) {
@@ -65,7 +69,7 @@ switch ($_GET['feed']) {
if (strtotime($NewsTime) >= time()) {
continue;
}
- echo $Feed->item($Title, $Text->strip_bbcode($Body), 'index.php#news'.$NewsID, SITE_NAME.' Staff','','',$NewsTime);
+ echo $Feed->item($Title, $Text->strip_bbcode($Body), "index.php#news$NewsID", SITE_NAME.' Staff', '', '', $NewsTime);
if (++$Count > 4) {
break;
}
@@ -87,18 +91,18 @@ switch ($_GET['feed']) {
b.Time,
b.ThreadID
FROM blog AS b
- LEFT JOIN users_main AS um ON b.UserID=um.ID
+ LEFT JOIN users_main AS um ON b.UserID = um.ID
ORDER BY Time DESC
LIMIT 20");
$Blog = $DB->to_array();
- $Cache->cache_value('Blog',$Blog,1209600);
+ $Cache->cache_value('Blog', $Blog, 1209600);
}
foreach ($Blog as $BlogItem) {
list($BlogID, $Author, $Title, $Body, $BlogTime, $ThreadID) = $BlogItem;
if ($ThreadID) {
- echo $Feed->item($Title, $Text->strip_bbcode($Body), 'forums.php?action=viewthread&amp;threadid='.$ThreadID, SITE_NAME.' Staff','','',$BlogTime);
+ echo $Feed->item($Title, $Text->strip_bbcode($Body), 'forums.php?action=viewthread&amp;threadid='.$ThreadID, SITE_NAME.' Staff', '', '', $BlogTime);
} else {
- echo $Feed->item($Title, $Text->strip_bbcode($Body), 'blog.php#blog'.$BlogID, SITE_NAME.' Staff','','',$BlogTime);
+ echo $Feed->item($Title, $Text->strip_bbcode($Body), "blog.php#blog$BlogID", SITE_NAME.' Staff', '', '', $BlogTime);
}
}
break;
@@ -109,84 +113,88 @@ switch ($_GET['feed']) {
require(SERVER_ROOT.'/classes/misc.class.php');
$DB = NEW DB_MYSQL;
- $DB->query("SELECT Message, Author, Date(Time) FROM changelog ORDER BY Time DESC LIMIT 20");
+ $DB->query("
+ SELECT Message, Author, Date(Time)
+ FROM changelog
+ ORDER BY Time DESC
+ LIMIT 20");
$Changelog = $DB->to_array();
$Cache->cache_value('changelog', $Changelog, 86400);
}
foreach ($Changelog as $Change) {
list($Message, $Author, $Date) = $Change;
- echo $Feed->item($Date . " by " . $Author, $Message, 'tools.php?action=change_log', SITE_NAME.' Staff','','',$Date);
+ echo $Feed->item("$Date by $Author", $Message, 'tools.php?action=change_log', SITE_NAME.' Staff', '', '', $Date);
}
break;
case 'torrents_all':
$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']);
break;
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':
$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':
$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':
$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':
$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':
$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':
$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':
$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':
$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':
$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':
$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':
$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/image/index.php b/sections/image/index.php
index 710a770..ca9d374 100644
--- a/sections/image/index.php
+++ b/sections/image/index.php
@@ -4,16 +4,16 @@
// Bear this in mind when you try to use script_start functions.
if (!check_perms('site_proxy_images')) {
- error('forbidden');
+ img_error('forbidden');
}
$URL = isset($_GET['i']) ? htmlspecialchars_decode($_GET['i']) : null;
if (!extension_loaded('openssl') && strtoupper($URL[4]) == 'S') {
- error('badprotocol');
+ img_error('badprotocol');
}
if (!preg_match('/^'.IMAGE_REGEX.'/is',$URL,$Matches)) {
- error('invalid');
+ img_error('invalid');
}
if (isset($_GET['c'])) {
@@ -24,16 +24,16 @@ if (!isset($Data) || !$Data) {
$Cached = false;
$Data = @file_get_contents($URL,0,stream_context_create(array('http'=>array('timeout'=>15))));
if (!$Data || empty($Data)) {
- error('timeout');
+ img_error('timeout');
}
$Type = image_type($Data);
if ($Type && function_exists('imagecreatefrom'.$Type)) {
$Image = imagecreatefromstring($Data);
if (invisible($Image)) {
- error('invisible');
+ img_error('invisible');
}
if (verysmall($Image)) {
- error('small');
+ img_error('small');
}
}
@@ -60,8 +60,6 @@ if (isset($_GET['avatar'])) {
if (strlen($Data2) > 256 * 1024 || image_height($Type, $Data2) > 400) {
require_once(SERVER_ROOT.'/classes/mysql.class.php');
require_once(SERVER_ROOT.'/classes/time.class.php'); //Require the time class
-
- $DB = new DB_MYSQL;
$DBURL = db_string($URL);
// Reset avatar, add mod note
@@ -76,7 +74,7 @@ if (isset($_GET['avatar'])) {
// Send PM
- send_pm($UserID,0,"Your avatar has been automatically reset","The following avatar rules have been in effect for months now:
+ Misc::send_pm($UserID,0,"Your avatar has been automatically reset","The following avatar rules have been in effect for months now:
[b]Avatars must not exceed 256 kB or be vertically longer than 400px. [/b]
@@ -90,7 +88,7 @@ Your avatar at $DBURL has been found to exceed these rules. As such, it has been
/*
TODO: solve this properly for photoshop output images which prepend shit to the image file. skip it or strip it
if (!isset($Type)) {
- error('timeout');
+ img_error('timeout');
}
*/
if (isset($Type)) {
diff --git a/sections/inbox/inbox.php b/sections/inbox/inbox.php
index 1c69bee..f09a8a6 100644
--- a/sections/inbox/inbox.php
+++ b/sections/inbox/inbox.php
@@ -84,7 +84,7 @@ echo "\t\t$Pages\n";
<div class="box pad">
<? if ($Count == 0 && empty($_GET['search'])) { ?>
- <h2>Your <?=(($Section == 'sentbox') ? 'sentbox' : 'inbox')?> is currently empty</h2>
+ <h2>Your <?=(($Section == 'sentbox') ? 'sentbox' : 'inbox')?> is empty.</h2>
<? } else { ?>
<form class="search_form" name="<?=(($Section == 'sentbox') ? 'sentbox' : 'inbox')?>" action="inbox.php" method="get" id="searchbox">
<div>
diff --git a/sections/register/index.php b/sections/register/index.php
index 0ccb000..e002a66 100644
--- a/sections/register/index.php
+++ b/sections/register/index.php
@@ -18,15 +18,15 @@ if (!empty($_REQUEST['confirm'])) {
$DB->query("
SELECT ID
FROM users_main
- WHERE torrent_pass='".db_string($_REQUEST['confirm'])."'
- AND Enabled='0'");
+ 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'");
+ SET Enabled = '1'
+ WHERE ID = '$UserID'");
$Cache->increment('stats_user_count');
include('step2.php');
}
@@ -35,7 +35,7 @@ if (!empty($_REQUEST['confirm'])) {
$Val->SetFields('username', true, 'regex', 'You did not enter a valid username.', array('regex' => USERNAME_REGEX));
$Val->SetFields('email', true, 'email', 'You did not enter a valid email address.');
$Val->SetFields('password', true, 'regex', 'A strong password is between 8 and 40 characters long, contains at least 1 lowercase and uppercase letter, and contains at least a number or symbol', array('regex'=>'/(?=^.{8,}$)(?=.*[^a-zA-Z])(?=.*[A-Z])(?=.*[a-z]).*$/'));
- $Val->SetFields('confirm_password', true, 'compare', 'Your passwords do not match.', array('comparefield'=>'password'));
+ $Val->SetFields('confirm_password', true, 'compare', 'Your passwords do not match.', array('comparefield' => 'password'));
$Val->SetFields('readrules', true, 'checkbox', 'You did not select the box that says you will read the rules.');
$Val->SetFields('readwiki', true, 'checkbox', 'You did not select the box that says you will read the wiki.');
$Val->SetFields('agereq', true, 'checkbox', 'You did not select the box that says you are 13 years of age or older.');
@@ -70,7 +70,7 @@ if (!empty($_REQUEST['confirm'])) {
$DB->query("
SELECT InviterID, Email
FROM invites
- WHERE InviteKey='".db_string($_REQUEST['invite'])."'");
+ WHERE InviteKey = '".db_string($_REQUEST['invite'])."'");
if ($DB->record_count() == 0) {
$Err = 'Invite does not exist.';
$InviterID = 0;
@@ -107,10 +107,10 @@ if (!empty($_REQUEST['confirm'])) {
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')");
+ ('".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("
@@ -165,7 +165,9 @@ if (!empty($_REQUEST['confirm'])) {
// If the inviter doesn't have an invite tree
// Note: This should never happen unless you've transferred from another database, like What.CD did
if ($DB->record_count() == 0) {
- $DB->query("SELECT MAX(TreeID)+1 FROM invite_tree");
+ $DB->query("
+ SELECT MAX(TreeID) + 1
+ FROM invite_tree");
list($TreeID) = $DB->next_record();
$DB->query("
@@ -230,7 +232,7 @@ if (!empty($_REQUEST['confirm'])) {
$TPL->set('SITE_NAME', SITE_NAME);
$TPL->set('SITE_URL', SITE_URL);
- Misc::send_email($_REQUEST['email'],'New account confirmation at '.SITE_NAME,$TPL->get(),'noreply');
+ 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;
diff --git a/sections/reports/ajax_claim_report.php b/sections/reports/ajax_claim_report.php
index ef12872..3446878 100644
--- a/sections/reports/ajax_claim_report.php
+++ b/sections/reports/ajax_claim_report.php
@@ -11,7 +11,10 @@ if (!check_perms('site_moderate_forums') || empty($_POST['id'])) {
}
$ID = (int)$_POST['id'];
-$DB->query("SELECT ClaimerID FROM reports WHERE ID = '$ID'");
+$DB->query("
+ SELECT ClaimerID
+ FROM reports
+ WHERE ID = '$ID'");
list($ClaimerID) = $DB->next_record();
if ($ClaimerID) {
print
@@ -23,7 +26,10 @@ if ($ClaimerID) {
die();
} else {
$UserID = $LoggedUser['ID'];
- $DB->query("UPDATE reports SET ClaimerID = '$UserID' WHERE ID = '$ID'");
+ $DB->query("
+ UPDATE reports
+ SET ClaimerID = '$UserID'
+ WHERE ID = '$ID'");
print
json_encode(
array(
diff --git a/sections/reports/ajax_resolve_report.php b/sections/reports/ajax_resolve_report.php
index 6b9e9b6..d3ee78e 100644
--- a/sections/reports/ajax_resolve_report.php
+++ b/sections/reports/ajax_resolve_report.php
@@ -7,7 +7,10 @@ if ((!check_perms('admin_reports') && !check_perms('project_team') && !check_per
$ReportID = $_POST['reportid'];
-$DB->query('SELECT Type FROM reports WHERE ID = '.$ReportID);
+$DB->query("
+ SELECT Type
+ FROM reports
+ WHERE ID = $ReportID");
list($Type) = $DB->next_record();
if (!check_perms('admin_reports')) {
if (check_perms('site_moderate_forums')) {
@@ -23,11 +26,10 @@ if (!check_perms('admin_reports')) {
$DB->query("
UPDATE reports
- SET Status='Resolved',
- ResolvedTime='".sqltime()."',
- ResolverID='".$LoggedUser['ID']."'
- WHERE ID='".db_string($ReportID)."'");
-
+ SET Status = 'Resolved',
+ ResolvedTime = '".sqltime()."',
+ ResolverID = '".$LoggedUser['ID']."'
+ WHERE ID = '".db_string($ReportID)."'");
$Channels = array();
@@ -41,12 +43,14 @@ if (in_array($Type, array('artist_comment', 'collages_comment', 'post', 'request
$Cache->decrement('num_forum_reports');
}
-
-$DB->query("SELECT COUNT(ID) FROM reports WHERE Status = 'New'");
+$DB->query("
+ SELECT COUNT(ID)
+ FROM reports
+ WHERE Status = 'New'");
list($Remaining) = $DB->next_record();
foreach ($Channels as $Channel) {
- send_irc("PRIVMSG $Channel :Report $ReportID resolved by ".preg_replace("/^(.{2})/", "$1·", $LoggedUser['Username']).' on site ('.(int)$Remaining.' remaining).');
+ send_irc("PRIVMSG $Channel :Report $ReportID resolved by ".preg_replace('/^(.{2})/', '$1·', $LoggedUser['Username']).' on site ('.(int)$Remaining.' remaining).');
}
$Cache->delete_value('num_other_reports');
@@ -54,12 +58,12 @@ $Cache->delete_value('num_other_reports');
ajax_success();
function ajax_error($Error = 'error') {
- echo json_encode(array('status'=>$Error));
+ echo json_encode(array('status' => $Error));
die();
}
function ajax_success() {
- echo json_encode(array("status"=>"success"));
+ echo json_encode(array('status' => 'success'));
die();
}
?>
diff --git a/sections/reports/report.php b/sections/reports/report.php
index ffad2a7..04677cf 100644
--- a/sections/reports/report.php
+++ b/sections/reports/report.php
@@ -15,97 +15,118 @@ $Type = $Types[$Short];
$ID = $_GET['id'];
switch ($Short) {
- case 'user' :
- $DB->query("SELECT Username FROM users_main WHERE ID=".$ID);
+ case 'user':
+ $DB->query("
+ SELECT Username
+ FROM users_main
+ WHERE ID = $ID");
if ($DB->record_count() < 1) {
error(404);
}
list($Username) = $DB->next_record();
break;
- case 'request_update' :
+ case 'request_update':
$NoReason = true;
- $DB->query("SELECT Title, Description, TorrentID, CategoryID, Year FROM requests WHERE ID=".$ID);
+ $DB->query("
+ SELECT Title, Description, TorrentID, CategoryID, Year
+ FROM requests
+ WHERE ID = $ID");
if ($DB->record_count() < 1) {
error(404);
}
list($Name, $Desc, $Filled, $CategoryID, $Year) = $DB->next_record();
- if ($Filled || ($CategoryID != 0 && ($Categories[$CategoryID-1] != 'Music' || $Year != 0))) {
+ if ($Filled || ($CategoryID != 0 && ($Categories[$CategoryID - 1] != 'Music' || $Year != 0))) {
error(403);
}
break;
- case 'request' :
- $DB->query("SELECT Title, Description, TorrentID FROM requests WHERE ID=".$ID);
+ case 'request':
+ $DB->query("
+ SELECT Title, Description, TorrentID
+ FROM requests
+ WHERE ID = $ID");
if ($DB->record_count() < 1) {
error(404);
}
list($Name, $Desc, $Filled) = $DB->next_record();
break;
- case 'collage' :
- $DB->query("SELECT Name, Description FROM collages WHERE ID=".$ID);
+ case 'collage':
+ $DB->query("
+ SELECT Name, Description
+ FROM collages
+ WHERE ID = $ID");
if ($DB->record_count() < 1) {
error(404);
}
list($Name, $Desc) = $DB->next_record();
break;
- case 'thread' :
+ case 'thread':
$DB->query("
SELECT ft.Title, ft.ForumID, um.Username
FROM forums_topics AS ft
- JOIN users_main AS um ON um.ID=ft.AuthorID
- WHERE ft.ID=".$ID);
+ JOIN users_main AS um ON um.ID = ft.AuthorID
+ WHERE ft.ID = $ID");
if ($DB->record_count() < 1) {
error(404);
}
list($Title, $ForumID, $Username) = $DB->next_record();
- $DB->query("SELECT MinClassRead FROM forums WHERE ID = ".$ForumID);
+ $DB->query("
+ SELECT MinClassRead
+ FROM forums
+ WHERE ID = $ForumID");
list($MinClassRead) = $DB->next_record();
- if (!empty($LoggedUser['DisableForums']) ||
- ($MinClassRead > $LoggedUser['EffectiveClass'] && (!isset($LoggedUser['CustomForums'][$ForumID]) || $LoggedUser['CustomForums'][$ForumID] == 0)) ||
- (isset($LoggedUser['CustomForums'][$ForumID]) && $LoggedUser['CustomForums'][$ForumID] == 0)) {
+ if (!empty($LoggedUser['DisableForums'])
+ || ($MinClassRead > $LoggedUser['EffectiveClass'] && (!isset($LoggedUser['CustomForums'][$ForumID]) || $LoggedUser['CustomForums'][$ForumID] == 0))
+ || (isset($LoggedUser['CustomForums'][$ForumID]) && $LoggedUser['CustomForums'][$ForumID] == 0)) {
error(403);
}
break;
- case 'post' :
- $DB->query('
+ case 'post':
+ $DB->query("
SELECT fp.Body, fp.TopicID, um.Username
FROM forums_posts AS fp
- JOIN users_main AS um ON um.ID=fp.AuthorID
- WHERE fp.ID='.$ID);
+ JOIN users_main AS um ON um.ID = fp.AuthorID
+ WHERE fp.ID = $ID");
if ($DB->record_count() < 1) {
error(404);
}
list($Body, $TopicID, $Username) = $DB->next_record();
- $DB->query('SELECT ForumID FROM forums_topics WHERE ID = '.$TopicID);
+ $DB->query("
+ SELECT ForumID
+ FROM forums_topics
+ WHERE ID = $TopicID");
list($ForumID) = $DB->next_record();
- $DB->query('SELECT MinClassRead FROM forums WHERE ID = '.$ForumID);
+ $DB->query("
+ SELECT MinClassRead
+ FROM forums
+ WHERE ID = $ForumID");
list($MinClassRead) = $DB->next_record();
- if (!empty($LoggedUser['DisableForums']) ||
- ($MinClassRead > $LoggedUser['EffectiveClass'] && (!isset($LoggedUser['CustomForums'][$ForumID]) || $LoggedUser['CustomForums'][$ForumID] == 0)) ||
- (isset($LoggedUser['CustomForums'][$ForumID]) && $LoggedUser['CustomForums'][$ForumID] == 0)) {
+ if (!empty($LoggedUser['DisableForums'])
+ || ($MinClassRead > $LoggedUser['EffectiveClass'] && (!isset($LoggedUser['CustomForums'][$ForumID]) || $LoggedUser['CustomForums'][$ForumID] == 0))
+ || (isset($LoggedUser['CustomForums'][$ForumID]) && $LoggedUser['CustomForums'][$ForumID] == 0)) {
error(403);
}
break;
- case 'requests_comment' :
- case 'torrents_comment' :
+ case 'requests_comment':
+ case 'torrents_comment':
case 'artist_comment':
- case 'collages_comment' :
- $Table = $Short.'s';
+ case 'collages_comment':
+ $Table = "{$Short}s";
if ($Short == 'collages_comment') {
$Column = 'UserID';
} else {
$Column = 'AuthorID';
}
- $DB->query('
- SELECT '.$Short.".Body, um.Username
+ $DB->query("
+ SELECT $Short.Body, um.Username
FROM $Table AS $Short
- JOIN users_main AS um ON um.ID=$Short.$Column
- WHERE $Short.ID=".$ID);
+ JOIN users_main AS um ON um.ID = $Short.$Column
+ WHERE $Short.ID = $ID");
if ($DB->record_count() < 1) {
error(404);
}
@@ -113,7 +134,7 @@ switch ($Short) {
break;
}
-View::show_header('Report a '.$Type['title'],'bbcode,jquery.validate,form_validate');
+View::show_header('Report a '.$Type['title'], 'bbcode,jquery.validate,form_validate');
?>
<div class="thin">
<div class="header">
@@ -123,11 +144,9 @@ View::show_header('Report a '.$Type['title'],'bbcode,jquery.validate,form_valida
<div class="box pad">
<p>Following these guidelines will help the moderators deal with your report in a timely fashion. </p>
<ul>
-<?
-foreach ($Type['guidelines'] as $Guideline) {
-?>
+<? foreach ($Type['guidelines'] as $Guideline) { ?>
<li><?=$Guideline?></li>
-<? } ?>
+<? } ?>
</ul>
<p>In short, please include as much detail as possible when reporting. Thank you. </p>
</div>
@@ -138,12 +157,12 @@ $Text = new TEXT;
switch ($Short) {
- case 'user' :
+ case 'user':
?>
<p>You are reporting the user <strong><?=display_str($Username)?></strong></p>
<?
break;
- case 'request_update' :
+ case 'request_update':
?>
<p>You are reporting the request:</p>
<table>
@@ -179,12 +198,9 @@ switch ($Short) {
<td>
<select id="releasetype" name="releasetype">
<option value="0">---</option>
-<?
- foreach ($ReleaseTypes as $Key => $Val) {
-?> <option value="<?=$Key?>"<?=(!empty($ReleaseType) ? ($Key == $ReleaseType ? ' selected="selected"' : '') : '')?>><?=$Val?></option>
-<?
- }
-?>
+<? foreach ($ReleaseTypes as $Key => $Val) { ?>
+ <option value="<?=$Key?>"<?=(!empty($ReleaseType) ? ($Key == $ReleaseType ? ' selected="selected"' : '') : '')?>><?=$Val?></option>
+<? } ?>
</select>
</td>
</tr>
@@ -202,7 +218,7 @@ switch ($Short) {
</div>
<?
break;
- case 'request' :
+ case 'request':
?>
<p>You are reporting the request:</p>
<table>
@@ -219,10 +235,10 @@ switch ($Short) {
</table>
<?
break;
- case 'collage' :
+ case 'collage':
?>
- <p>You are reporting the collage:</p>
- <table>
+ <p>You are reporting the collage:</p>
+ <table>
<tr class="colhead">
<td>Title</td>
<td>Description</td>
@@ -234,10 +250,10 @@ switch ($Short) {
</table>
<?
break;
- case 'thread' :
+ case 'thread':
?>
- <p>You are reporting the thread:</p>
- <table>
+ <p>You are reporting the thread:</p>
+ <table>
<tr class="colhead">
<td>Username</td>
<td>Title</td>
@@ -249,10 +265,10 @@ switch ($Short) {
</table>
<?
break;
- case 'post' :
+ case 'post':
?>
- <p>You are reporting the post:</p>
- <table>
+ <p>You are reporting the post:</p>
+ <table>
<tr class="colhead">
<td>Username</td>
<td>Body</td>
@@ -264,13 +280,13 @@ switch ($Short) {
</table>
<?
break;
- case 'requests_comment' :
- case 'torrents_comment' :
+ case 'requests_comment':
+ case 'torrents_comment':
case 'artist_comment':
- case 'collages_comment' :
+ case 'collages_comment':
?>
- <p>You are reporting the <?=$Types[$Short]['title']?>:</p>
- <table>
+ <p>You are reporting the <?=$Types[$Short]['title']?>:</p>
+ <table>
<tr class="colhead">
<td>Username</td>
<td>Body</td>
diff --git a/sections/reports/reports.php b/sections/reports/reports.php
index ec6b373..23889a3 100644
--- a/sections/reports/reports.php
+++ b/sections/reports/reports.php
@@ -18,16 +18,16 @@ include(SERVER_ROOT . '/sections/reports/array.php');
View::show_header('Reports', 'bbcode,reports');
if ($_GET['id'] && is_number($_GET['id'])) {
- $View = "Single report";
- $Where = "r.ID = " . $_GET['id'];
+ $View = 'Single report';
+ $Where = 'r.ID = ' . $_GET['id'];
} else if (empty($_GET['view'])) {
- $View = "New";
- $Where = "Status='New'";
+ $View = 'New';
+ $Where = "Status = 'New'";
} else {
$View = $_GET['view'];
switch ($_GET['view']) {
case 'old' :
- $Where = "Status='Resolved'";
+ $Where = "Status = 'Resolved'";
break;
default :
error(404);
@@ -60,7 +60,7 @@ $Reports = $DB->query("
r.Notes,
r.ResolverID
FROM reports AS r
- JOIN users_main AS um ON r.UserID=um.ID
+ JOIN users_main AS um ON r.UserID = um.ID
WHERE $Where
ORDER BY ReportedTime DESC
LIMIT $Limit");
@@ -93,7 +93,7 @@ $DB->set_query_id($Reports);
<?
while (list($ReportID, $SnitchID, $SnitchName, $ThingID, $Short, $ReportedTime, $Reason, $Status, $ClaimerID, $Notes, $ResolverID) = $DB->next_record()) {
$Type = $Types[$Short];
- $Reference = "reports.php?id=" . $ReportID . "#report" . $ReportID;
+ $Reference = "reports.php?id=$ReportID#report$ReportID";
?>
<div id="report_<?=$ReportID?>">
<table cellpadding="5" id="report_<?=$ReportID?>">
@@ -108,8 +108,11 @@ $DB->set_query_id($Reports);
<td class="center" colspan="2">
<strong>
<? switch ($Short) {
- case "user" :
- $DB->query("SELECT Username FROM users_main WHERE ID=" . $ThingID);
+ case 'user':
+ $DB->query("
+ SELECT Username
+ FROM users_main
+ WHERE ID = $ThingID");
if ($DB->record_count() < 1) {
echo 'No user with the reported ID found';
} else {
@@ -117,9 +120,12 @@ $DB->set_query_id($Reports);
echo "<a href=\"user.php?id=$ThingID\">" . display_str($Username) . '</a>';
}
break;
- case "request" :
- case "request_update" :
- $DB->query("SELECT Title FROM requests WHERE ID=" . $ThingID);
+ case 'request':
+ case 'request_update':
+ $DB->query("
+ SELECT Title
+ FROM requests
+ WHERE ID = $ThingID");
if ($DB->record_count() < 1) {
echo 'No request with the reported ID found';
} else {
@@ -127,8 +133,11 @@ $DB->set_query_id($Reports);
echo "<a href=\"requests.php?action=view&amp;id=$ThingID\">" . display_str($Name) . '</a>';
}
break;
- case "collage" :
- $DB->query("SELECT Name FROM collages WHERE ID=" . $ThingID);
+ case 'collage':
+ $DB->query("
+ SELECT Name
+ FROM collages
+ WHERE ID = $ThingID");
if ($DB->record_count() < 1) {
echo 'No collage with the reported ID found';
} else {
@@ -136,8 +145,11 @@ $DB->set_query_id($Reports);
echo "<a href=\"collages.php?id=$ThingID\">" . display_str($Name) . '</a>';
}
break;
- case "thread" :
- $DB->query("SELECT Title FROM forums_topics WHERE ID=" . $ThingID);
+ case 'thread':
+ $DB->query("
+ SELECT Title
+ FROM forums_topics
+ WHERE ID = $ThingID");
if ($DB->record_count() < 1) {
echo 'No forum thread with the reported ID found';
} else {
@@ -145,7 +157,7 @@ $DB->set_query_id($Reports);
echo "<a href=\"forums.php?action=viewthread&amp;threadid=$ThingID\">" . display_str($Title) . '</a>';
}
break;
- case "post" :
+ case 'post':
if (isset($LoggedUser['PostsPerPage'])) {
$PerPage = $LoggedUser['PostsPerPage'];
} else {
@@ -159,18 +171,18 @@ $DB->set_query_id($Reports);
( SELECT COUNT(ID)
FROM forums_posts
WHERE forums_posts.TopicID = p.TopicID
- AND forums_posts.ID<=p.ID
+ AND forums_posts.ID <= p.ID
) AS PostNum
FROM forums_posts AS p
- WHERE ID=$ThingID");
+ WHERE ID = $ThingID");
if ($DB->record_count() < 1) {
echo 'No forum post with the reported ID found';
} else {
list($PostID, $Body, $TopicID, $PostNum) = $DB->next_record();
- echo "<a href=\"forums.php?action=viewthread&amp;threadid=" . $TopicID . "&amp;post=" . $PostNum . "#post" . $PostID . "\">FORUM POST</a>";
+ echo "<a href=\"forums.php?action=viewthread&amp;threadid=$TopicID&amp;post=$PostNum#post$PostID\">FORUM POST</a>";
}
break;
- case "requests_comment" :
+ case 'requests_comment':
$DB->query("
SELECT
rc.RequestID,
@@ -181,16 +193,16 @@ $DB->set_query_id($Reports);
AND requests_comments.RequestID = rc.RequestID
) AS CommentNum
FROM requests_comments AS rc
- WHERE ID=$ThingID");
+ WHERE ID = $ThingID");
if ($DB->record_count() < 1) {
echo 'No request comment with the reported ID found';
} else {
list($RequestID, $Body, $PostNum) = $DB->next_record();
$PageNum = ceil($PostNum / TORRENT_COMMENTS_PER_PAGE);
- echo "<a href=\"requests.php?action=view&amp;id=" . $RequestID . "&amp;page=" . $PageNum . "#post" . $ThingID . "\">REQUEST COMMENT</a>";
+ echo "<a href=\"requests.php?action=view&amp;id=$RequestID&amp;page=$PageNum#post$ThingID\">REQUEST COMMENT</a>";
}
break;
- case "torrents_comment" :
+ case 'torrents_comment':
$DB->query("
SELECT
tc.GroupID,
@@ -201,16 +213,16 @@ $DB->set_query_id($Reports);
AND torrents_comments.GroupID = tc.GroupID
) AS CommentNum
FROM torrents_comments AS tc
- WHERE ID=$ThingID");
+ WHERE ID = $ThingID");
if ($DB->record_count() < 1) {
echo 'No torrent comment with the reported ID found';
} else {
list($GroupID, $Body, $PostNum) = $DB->next_record();
$PageNum = ceil($PostNum / TORRENT_COMMENTS_PER_PAGE);
- echo "<a href=\"torrents.php?id=" . $GroupID . "&amp;page=" . $PageNum . "#post" . $ThingID . "\">TORRENT COMMENT</a>";
+ echo "<a href=\"torrents.php?id=$GroupID&amp;page=$PageNum#post$ThingID\">TORRENT COMMENT</a>";
}
break;
- case "artist_comment" :
+ case 'artist_comment':
$DB->query("
SELECT
ac.ArtistID,
@@ -221,17 +233,17 @@ $DB->set_query_id($Reports);
AND artist_comments.ArtistID = ac.ArtistID
) AS CommentNum
FROM artist_comments AS ac
- WHERE ID=$ThingID");
+ WHERE ID = $ThingID");
if ($DB->record_count() < 1) {
echo 'No comment with the reported ID found';
} else {
list($ArtistID, $Body, $PostNum) = $DB->next_record();
$PageNum = ceil($PostNum / TORRENT_COMMENTS_PER_PAGE);
- echo "<a href=\"artist.php?id=" . $ArtistID . "&amp;page=" . $PageNum . "#post" . $ThingID . "\">ARTIST COMMENT</a>";
+ echo "<a href=\"artist.php?id=$ArtistID&amp;page=$PageNum#post$ThingID\">ARTIST COMMENT</a>";
}
break;
- case "collages_comment" :
+ case 'collages_comment':
$DB->query("
SELECT
cc.CollageID,
@@ -242,14 +254,14 @@ $DB->set_query_id($Reports);
AND collages_comments.CollageID = cc.CollageID
) AS CommentNum
FROM collages_comments AS cc
- WHERE ID=$ThingID");
+ WHERE ID = $ThingID");
if ($DB->record_count() < 1) {
echo 'No collage comment with the reported ID found';
} else {
list($CollageID, $Body, $PostNum) = $DB->next_record();
$PerPage = POSTS_PER_PAGE;
$PageNum = ceil($PostNum / $PerPage);
- echo "<a href=\"collage.php?action=comments&amp;collageid=" . $CollageID . "&amp;page=" . $PageNum . "#post" . $ThingID . "\">COLLAGE COMMENT</a>";
+ echo "<a href=\"collage.php?action=comments&amp;collageid=$CollageID&amp;page=$PageNum#post$ThingID\">COLLAGE COMMENT</a>";
}
break;
}
@@ -272,7 +284,7 @@ $DB->set_query_id($Reports);
&nbsp;&nbsp;
<a href="#" onclick="toggleNotes(<?=$ReportID?>); return false;" class="brackets">Toggle notes</a>
- <div id="notes_div_<?=$ReportID?>" style="display: <?=empty($Notes) ? "none" : "block"?>;">
+ <div id="notes_div_<?=$ReportID?>" style="display: <?=empty($Notes) ? 'none' : 'block'; ?>;">
<textarea cols="50" rows="3" id="notes_<?=$ReportID?>"><?=$Notes?></textarea>
<br />
<input type="submit" onclick="saveNotes(<?=$ReportID?>)" value="Save" />
@@ -289,9 +301,10 @@ $DB->set_query_id($Reports);
</form>
</td>
</tr>
-<? } else {
+<?
+ } else {
$ResolverInfo = Users::user_info($ResolverID);
- ?>
+?>
<tr>
<td colspan="2">
Resolved by <a href="users.php?id=<?=$ResolverID?>"><?=$ResolverInfo['Username']?></a>
diff --git a/sections/reports/stats.php b/sections/reports/stats.php
index 364ac7f..71a84f5 100644
--- a/sections/reports/stats.php
+++ b/sections/reports/stats.php
@@ -18,14 +18,15 @@ View::show_header('Other reports stats');
<table class="layout">
<?
if (check_perms('admin_reports')) :
-$DB->query("SELECT um.Username,
- COUNT(r.ID) AS Reports
- FROM reports AS r
- JOIN users_main AS um ON um.ID=r.ResolverID
- WHERE r.ReportedTime > '2009-08-21 22:39:41'
- AND r.ReportedTime > NOW() - INTERVAL 24 HOUR
- GROUP BY r.ResolverID
- ORDER BY Reports DESC");
+$DB->query("
+ SELECT um.Username,
+ COUNT(r.ID) AS Reports
+ FROM reports AS r
+ JOIN users_main AS um ON um.ID = r.ResolverID
+ WHERE r.ReportedTime > '2009-08-21 22:39:41'
+ AND r.ReportedTime > NOW() - INTERVAL 24 HOUR
+ GROUP BY r.ResolverID
+ ORDER BY Reports DESC");
$Results = $DB->to_array();
?>
<tr>
@@ -36,7 +37,8 @@ $Results = $DB->to_array();
<td class="head colhead_dark">Username</td>
<td class="head colhead_dark">Reports</td>
</tr>
-<? foreach ($Results as $Result) {
+<?
+ foreach ($Results as $Result) {
list($Username, $Reports) = $Result;
?>
<tr>
@@ -49,14 +51,15 @@ $Results = $DB->to_array();
</tr>
<tr>
<?
-$DB->query("SELECT um.Username,
- COUNT(r.ID) AS Reports
- FROM reports AS r
- JOIN users_main AS um ON um.ID=r.ResolverID
- WHERE r.ReportedTime > '2009-08-21 22:39:41'
- AND r.ReportedTime > NOW() - INTERVAL 1 WEEK
- GROUP BY r.ResolverID
- ORDER BY Reports DESC");
+$DB->query("
+ SELECT um.Username,
+ COUNT(r.ID) AS Reports
+ FROM reports AS r
+ JOIN users_main AS um ON um.ID = r.ResolverID
+ WHERE r.ReportedTime > '2009-08-21 22:39:41'
+ AND r.ReportedTime > NOW() - INTERVAL 1 WEEK
+ GROUP BY r.ResolverID
+ ORDER BY Reports DESC");
$Results = $DB->to_array();
?>
<td class="label"><strong>Reports resolved in the last week</strong></td>
@@ -66,7 +69,8 @@ $Results = $DB->to_array();
<td class="head colhead_dark">Username</td>
<td class="head colhead_dark">Reports</td>
</tr>
-<? foreach ($Results as $Result) {
+<?
+ foreach ($Results as $Result) {
list($Username, $Reports) = $Result;
?>
<tr>
@@ -79,14 +83,15 @@ $Results = $DB->to_array();
</tr>
<tr>
<?
-$DB->query("SELECT um.Username,
- COUNT(r.ID) AS Reports
- FROM reports AS r
- JOIN users_main AS um ON um.ID=r.ResolverID
- WHERE r.ReportedTime > '2009-08-21 22:39:41'
- AND r.ReportedTime > NOW() - INTERVAL 1 MONTH
- GROUP BY r.ResolverID
- ORDER BY Reports DESC");
+$DB->query("
+ SELECT um.Username,
+ COUNT(r.ID) AS Reports
+ FROM reports AS r
+ JOIN users_main AS um ON um.ID = r.ResolverID
+ WHERE r.ReportedTime > '2009-08-21 22:39:41'
+ AND r.ReportedTime > NOW() - INTERVAL 1 MONTH
+ GROUP BY r.ResolverID
+ ORDER BY Reports DESC");
$Results = $DB->to_array();
?>
<td class="label"><strong>Reports resolved in the last month</strong></td>
@@ -96,7 +101,8 @@ $Results = $DB->to_array();
<td class="head colhead_dark">Username</td>
<td class="head colhead_dark">Reports</td>
</tr>
-<? foreach ($Results as $Result) {
+<?
+ foreach ($Results as $Result) {
list($Username, $Reports) = $Result;
?>
<tr>
@@ -109,12 +115,13 @@ $Results = $DB->to_array();
</tr>
<tr>
<?
-$DB->query("SELECT um.Username,
- COUNT(r.ID) AS Reports
- FROM reports AS r
- JOIN users_main AS um ON um.ID=r.ResolverID
- GROUP BY r.ResolverID
- ORDER BY Reports DESC");
+$DB->query("
+ SELECT um.Username,
+ COUNT(r.ID) AS Reports
+ FROM reports AS r
+ JOIN users_main AS um ON um.ID = r.ResolverID
+ GROUP BY r.ResolverID
+ ORDER BY Reports DESC");
$Results = $DB->to_array();
?>
<td class="label"><strong>Reports resolved since "other" reports (2009-08-21)</strong></td>
@@ -124,7 +131,8 @@ $Results = $DB->to_array();
<td class="head colhead_dark">Username</td>
<td class="head colhead_dark">Reports</td>
</tr>
-<? foreach ($Results as $Result) {
+<?
+ foreach ($Results as $Result) {
list($Username, $Reports) = $Result;
?>
<tr>
@@ -138,14 +146,15 @@ $Results = $DB->to_array();
<? endif; ?>
<tr>
<?
- $DB->query("SELECT u.Username,
- count(LastPostAuthorID) as Trashed
- FROM forums_topics as f
- LEFT JOIN users_main as u on u.id = LastPostAuthorID
- WHERE ForumID = 12
- GROUP BY LastPostAuthorID
- ORDER BY Trashed DESC
- LIMIT 30;");
+ $DB->query("
+ SELECT u.Username,
+ count(LastPostAuthorID) as Trashed
+ FROM forums_topics as f
+ LEFT JOIN users_main as u on u.id = LastPostAuthorID
+ WHERE ForumID = 12
+ GROUP BY LastPostAuthorID
+ ORDER BY Trashed DESC
+ LIMIT 30");
$Results = $DB->to_array();
?>
<td class="label"><strong>Threads trashed since the beginning of time</strong></td>
@@ -166,7 +175,8 @@ $Results = $DB->to_array();
<td><?=$Username?></td>
<td><?=number_format($Trashed)?></td>
</tr>
-<? $i++;
+<?
+ $i++;
} ?>
</table>
</td>
diff --git a/sections/reports/takecompose.php b/sections/reports/takecompose.php
index b6b40f4..a285858 100644
--- a/sections/reports/takecompose.php
+++ b/sections/reports/takecompose.php
@@ -20,7 +20,11 @@ if (isset($_POST['convid']) && is_number($_POST['convid'])) {
$Err = 'A recipient does not exist.';
}
}
- $DB->query("SELECT UserID FROM pm_conversations_users WHERE UserID='$LoggedUser[ID]' AND ConvID='$ConvID'");
+ $DB->query("
+ SELECT UserID
+ FROM pm_conversations_users
+ WHERE UserID = '$LoggedUser[ID]'
+ AND ConvID = '$ConvID'");
if ($DB->record_count() == 0) {
error(403);
}
diff --git a/sections/reports/takereport.php b/sections/reports/takereport.php
index 05c727a..c03dcf0 100644
--- a/sections/reports/takereport.php
+++ b/sections/reports/takereport.php
@@ -16,7 +16,7 @@ $ID = $_POST['id'];
if ($Short == 'request_update') {
if (empty($_POST['year']) || !is_number($_POST['year'])) {
error('Year must be specified.');
- header('Location: reports.php?action=report&type=request_update&id='.$ID);
+ header("Location: reports.php?action=report&type=request_update&id=$ID");
die();
}
$Reason = '[b]Year[/b]: '.$_POST['year'].".\n\n";
@@ -28,20 +28,20 @@ if ($Short == 'request_update') {
}
switch ($Short) {
- case 'request' :
- case 'request_update' :
- $Link = 'requests.php?action=view&id='.$ID;
+ case 'request':
+ case 'request_update':
+ $Link = "requests.php?action=view&id=$ID";
break;
- case 'user' :
- $Link = 'user.php?id='.$ID;
+ case 'user':
+ $Link = "user.php?id=$ID";
break;
- case 'collage' :
- $Link = 'collages.php?id='.$ID;
+ case 'collage':
+ $Link = "collages.php?id=$ID";
break;
- case 'thread' :
- $Link = 'forums.php?action=viewthread&threadid='.$ID;
+ case 'thread':
+ $Link = "forums.php?action=viewthread&threadid=$ID";
break;
- case 'post' :
+ case 'post':
$DB->query("
SELECT
p.ID,
@@ -49,14 +49,14 @@ switch ($Short) {
( SELECT COUNT(ID)
FROM forums_posts
WHERE forums_posts.TopicID = p.TopicID
- AND forums_posts.ID<=p.ID
+ AND forums_posts.ID <= p.ID
) AS PostNum
FROM forums_posts AS p
- WHERE ID=".$ID);
- list($PostID,$TopicID,$PostNum) = $DB->next_record();
- $Link = 'forums.php?action=viewthread&threadid='.$TopicID.'&post='.$PostNum.'#post'.$PostID;
+ WHERE ID = $ID");
+ list($PostID, $TopicID, $PostNum) = $DB->next_record();
+ $Link = "forums.php?action=viewthread&threadid=$TopicID&post=$PostNum#post$PostID";
break;
- case 'requests_comment' :
+ case 'requests_comment':
$DB->query("
SELECT
rc.RequestID,
@@ -67,12 +67,12 @@ switch ($Short) {
AND requests_comments.RequestID = rc.RequestID
) AS CommentNum
FROM requests_comments AS rc
- WHERE ID=".$ID);
+ WHERE ID = $ID");
list($RequestID, $Body, $PostNum) = $DB->next_record();
$PageNum = ceil($PostNum / TORRENT_COMMENTS_PER_PAGE);
- $Link = 'requests.php?action=view&id='.$RequestID.'&page='.$PageNum.'#post'.$ID;
+ $Link = "requests.php?action=view&id=$RequestID&page=$PageNum#post$ID";
break;
- case 'torrents_comment' :
+ case 'torrents_comment':
$DB->query("
SELECT
tc.GroupID,
@@ -83,12 +83,12 @@ switch ($Short) {
AND torrents_comments.GroupID = tc.GroupID
) AS CommentNum
FROM torrents_comments AS tc
- WHERE ID=".$ID);
+ WHERE ID = $ID");
list($GroupID, $Body, $PostNum) = $DB->next_record();
$PageNum = ceil($PostNum / TORRENT_COMMENTS_PER_PAGE);
- $Link = 'torrents.php?id='.$GroupID.'&page='.$PageNum.'#post'.$ID;
+ $Link = "torrents.php?id=$GroupID&page=$PageNum#post$ID";
break;
- case 'artist_comment' :
+ case 'artist_comment':
$DB->query("
SELECT
ac.ArtistID,
@@ -99,12 +99,12 @@ switch ($Short) {
AND artist_comments.ArtistID = ac.ArtistID
) AS CommentNum
FROM artist_comments AS ac
- WHERE ID=".$ID);
+ WHERE ID = $ID");
list($ArtistID, $Body, $PostNum) = $DB->next_record();
$PageNum = ceil($PostNum / TORRENT_COMMENTS_PER_PAGE);
- $Link = 'artist.php?id='.$ArtistID.'&page='.$PageNum.'#post'.$ID;
+ $Link = "artist.php?id=$ArtistID&page=$PageNum#post$ID";
break;
- case 'collages_comment' :
+ case 'collages_comment':
$DB->query("
SELECT
cc.CollageID,
@@ -115,11 +115,11 @@ switch ($Short) {
AND collages_comments.CollageID = cc.CollageID
) AS CommentNum
FROM collages_comments AS cc
- WHERE ID=".$ID);
+ WHERE ID = $ID");
list($CollageID, $Body, $PostNum) = $DB->next_record();
$PerPage = POSTS_PER_PAGE;
$PageNum = ceil($PostNum / $PerPage);
- $Link = 'collage.php?action=comments&collageid='.$CollageID.'&page='.$PageNum.'#post'.$ID;
+ $Link = "collage.php?action=comments&collageid=$CollageID&page=$PageNum#post$ID";
break;
}
@@ -147,5 +147,5 @@ foreach ($Channels as $Channel) {
$Cache->delete_value('num_other_reports');
-header('Location: '.$Link);
+header("Location: $Link");
?>
diff --git a/sections/reports/takeresolve.php b/sections/reports/takeresolve.php
index 92d37e0..ce85c44 100644
--- a/sections/reports/takeresolve.php
+++ b/sections/reports/takeresolve.php
@@ -11,7 +11,10 @@ if (empty($_POST['reportid']) && !is_number($_POST['reportid'])) {
$ReportID = $_POST['reportid'];
-$DB->query("SELECT Type FROM reports WHERE ID = ".$ReportID);
+$DB->query("
+ SELECT Type
+ FROM reports
+ WHERE ID = $ReportID");
list($Type) = $DB->next_record();
if (!check_perms('admin_reports')) {
if (check_perms('site_moderate_forums')) {
@@ -25,12 +28,12 @@ if (!check_perms('admin_reports')) {
}
}
-$DB->query("UPDATE reports
- SET Status='Resolved',
- ResolvedTime='".sqltime()."',
- ResolverID='".$LoggedUser['ID']."'
- WHERE ID='".db_string($ReportID)."'");
-
+$DB->query("
+ UPDATE reports
+ SET Status = 'Resolved',
+ ResolvedTime = '".sqltime()."',
+ ResolverID = '".$LoggedUser['ID']."'
+ WHERE ID = '".db_string($ReportID)."'");
$Channels = array();
@@ -44,12 +47,14 @@ if (in_array($Type, array('collages_comment', 'post', 'requests_comment', 'threa
$Cache->decrement('num_forum_reports');
}
-
-$DB->query("SELECT COUNT(ID) FROM reports WHERE Status = 'New'");
+$DB->query("
+ SELECT COUNT(ID)
+ FROM reports
+ WHERE Status = 'New'");
list($Remaining) = $DB->next_record();
foreach ($Channels as $Channel) {
- send_irc("PRIVMSG ".$Channel." :Report ".$ReportID." resolved by ".preg_replace("/^(.{2})/", "$1·", $LoggedUser['Username'])." on site (".(int)$Remaining." remaining).");
+ send_irc("PRIVMSG $Channel :Report $ReportID resolved by ".preg_replace('/^(.{2})/', '$1·', $LoggedUser['Username']).' on site ('.(int)$Remaining.' remaining).');
}
$Cache->delete_value('num_other_reports');
diff --git a/sections/requests/new_edit.php b/sections/requests/new_edit.php
index e7762e9..686de9d 100644
--- a/sections/requests/new_edit.php
+++ b/sections/requests/new_edit.php
@@ -260,7 +260,7 @@ View::show_header(($NewRequest ? 'Create a request' : 'Edit a request'), 'reques
<option value="<?=$Genre?>"><?=$Genre?></option>
<? } ?>
</select>
- <input type="text" id="tags" name="tags" size="45" value="<?=(!empty($Tags) ? display_str($Tags) : '')?>" <? Users::has_autocomplete_enabled('other'); ?>/>
+ <input type="text" id="tags" name="tags" size="45" value="<?=(!empty($Tags) ? display_str($Tags) : '')?>"<? Users::has_autocomplete_enabled('other'); ?> />
<br />
Tags should be comma-separated, and you should use a period (".") to separate words inside a tag&#8202;&mdash;&#8202;e.g. "<strong class="important_text_alt">hip.hop</strong>".
<br /><br />
diff --git a/sections/requests/requests.php b/sections/requests/requests.php
index eb94a1d..93accd1 100644
--- a/sections/requests/requests.php
+++ b/sections/requests/requests.php
@@ -389,9 +389,9 @@ View::show_header($Title, 'requests');
<tr id="tagfilter">
<td class="label">Tags (comma-separated):</td>
<td>
- <input type="text" name="tags" id="tags" size="60" value="<?= (!empty($TagNames) ? display_str(implode(', ', $TagNames)) : '') ?>" <? Users::has_autocomplete_enabled('other'); ?>/>&nbsp;
- <input type="radio" name="tags_type" id="tags_type0" value="0"<? Format::selected('tags_type',0,'checked')?> /><label for="tags_type0"> Any</label>&nbsp;&nbsp;
- <input type="radio" name="tags_type" id="tags_type1" value="1"<? Format::selected('tags_type',1,'checked')?> /><label for="tags_type1"> All</label>
+ <input type="text" name="tags" id="tags" size="60" value="<?=(!empty($TagNames) ? display_str(implode(', ', $TagNames)) : '') ?>"<? Users::has_autocomplete_enabled('other'); ?> />&nbsp;
+ <input type="radio" name="tags_type" id="tags_type0" value="0"<? Format::selected('tags_type', 0, 'checked')?> /><label for="tags_type0"> Any</label>&nbsp;&nbsp;
+ <input type="radio" name="tags_type" id="tags_type1" value="1"<? Format::selected('tags_type', 1, 'checked')?> /><label for="tags_type1"> All</label>
</td>
</tr>
<tr id="include_filled">
diff --git a/sections/tools/data/bitcoin_balance.php b/sections/tools/data/bitcoin_balance.php
index e56ce2d..6f5d318 100644
--- a/sections/tools/data/bitcoin_balance.php
+++ b/sections/tools/data/bitcoin_balance.php
@@ -7,13 +7,14 @@ include(SERVER_ROOT.'/sections/donate/config.php');
View::show_header('Bitcoin donation balance');
-$Balance = btc_balance() . " BTC";
+$Balance = btc_balance() . ' BTC';
$Receiveds = btc_received();
-$DB->query("SELECT i.UserID, i.BitcoinAddress
- FROM users_info AS i
- JOIN users_main AS m ON m.ID = i.UserID
- WHERE BitcoinAddress IS NOT NULL
- ORDER BY m.Username ASC");
+$DB->query("
+ SELECT i.UserID, i.BitcoinAddress
+ FROM users_info AS i
+ JOIN users_main AS m ON m.ID = i.UserID
+ WHERE BitcoinAddress IS NOT NULL
+ ORDER BY m.Username ASC");
?>
<div class="thin">
<div class="header">
@@ -42,7 +43,7 @@ while ($row = $DB->next_record()) {
<td><tt><?=$row['BitcoinAddress']?></tt></td>
<td><?=$amount?></td>
</tr>
- <?
+<?
}
?>
</table>
diff --git a/sections/tools/data/economic_stats.php b/sections/tools/data/economic_stats.php
index f2a223c..21aeebd 100644
--- a/sections/tools/data/economic_stats.php
+++ b/sections/tools/data/economic_stats.php
@@ -35,7 +35,7 @@ if (!$EconomicStats = $Cache->get_value('new_economic_stats')) {
$DB->query("
SELECT SUM(Uploaded), SUM(Downloaded), COUNT(ID)
FROM users_main
- WHERE Enabled='1'");
+ WHERE Enabled = '1'");
list($TotalUpload, $TotalDownload, $NumUsers) = $DB->next_record();
$DB->query("
SELECT SUM(Bounty)
@@ -44,21 +44,29 @@ if (!$EconomicStats = $Cache->get_value('new_economic_stats')) {
$DB->query("
SELECT SUM(rv.Bounty)
FROM requests_votes AS rv
- JOIN requests AS r ON r.ID=rv.RequestID
- WHERE TorrentID>0");
+ JOIN requests AS r ON r.ID = rv.RequestID
+ WHERE TorrentID > 0");
list($AvailableBounty) = $DB->next_record();
$DB->query("
SELECT SUM(Snatched), COUNT(ID)
FROM torrents");
list($TotalSnatches, $TotalTorrents) = $DB->next_record(); // This is the total number of snatches for torrents that still exist
- $DB->query("SELECT COUNT(uid) FROM xbt_snatched");
+ $DB->query("
+ SELECT COUNT(uid)
+ FROM xbt_snatched");
list($TotalOverallSnatches) = $DB->next_record();
if (($PeerStats = $Cache->get_value('stats_peers')) === false) {
- $DB->query("SELECT COUNT(fid) FROM xbt_files_users WHERE remaining=0");
+ $DB->query("
+ SELECT COUNT(fid)
+ FROM xbt_files_users
+ WHERE remaining = 0");
list($TotalSeeders) = $DB->next_record();
- $DB->query("SELECT COUNT(fid) FROM xbt_files_users WHERE remaining>0");
+ $DB->query("
+ SELECT COUNT(fid)
+ FROM xbt_files_users
+ WHERE remaining > 0");
list($TotalLeechers) = $DB->next_record();
} else {
list($TotalLeechers,$TotalSeeders) = $PeerStats;
@@ -67,19 +75,21 @@ if (!$EconomicStats = $Cache->get_value('new_economic_stats')) {
$DB->query("
SELECT COUNT(ID)
FROM users_main
- WHERE ( SELECT COUNT(uid)
- FROM xbt_files_users
- WHERE uid=users_main.ID)>0");
+ WHERE (
+ SELECT COUNT(uid)
+ FROM xbt_files_users
+ WHERE uid = users_main.ID
+ ) > 0");
list($TotalPeerUsers) = $DB->next_record();
$Cache->cache_value('new_economic_stats',
- array($TotalUpload,$TotalDownload,$NumUsers,$TotalBounty,
- $AvailableBounty,$TotalSnatches,$TotalTorrents,
- $TotalOverallSnatches,$TotalSeeders,$TotalPeers,
+ array($TotalUpload, $TotalDownload, $NumUsers, $TotalBounty,
+ $AvailableBounty, $TotalSnatches, $TotalTorrents,
+ $TotalOverallSnatches, $TotalSeeders, $TotalPeers,
$TotalPeerUsers), 3600);
} else {
- list($TotalUpload,$TotalDownload,$NumUsers,$TotalBounty,$AvailableBounty,
- $TotalSnatches,$TotalTorrents,$TotalOverallSnatches,$TotalSeeders,
- $TotalPeers,$TotalPeerUsers) = $EconomicStats;
+ list($TotalUpload, $TotalDownload, $NumUsers, $TotalBounty, $AvailableBounty,
+ $TotalSnatches, $TotalTorrents, $TotalOverallSnatches, $TotalSeeders,
+ $TotalPeers, $TotalPeerUsers) = $EconomicStats;
}
$TotalLeechers = $TotalPeers - $TotalSeeders;
@@ -111,10 +121,10 @@ $TotalLeechers = $TotalPeers - $TotalSeeders;
<ul class="stats nobullet">
<li><strong>Total seeders: </strong><?=number_format($TotalSeeders)?></li>
<li><strong>Total leechers: </strong><?=number_format($TotalLeechers)?></li>
- <li><strong>Total peers: </strong><?=number_format($TotalSeeders+$TotalLeechers)?></li>
+ <li><strong>Total peers: </strong><?=number_format($TotalSeeders + $TotalLeechers)?></li>
<li><strong>Total snatches: </strong><?=number_format($TotalOverallSnatches)?></li>
- <li><strong>Seeder/leecher ratio: </strong><?=Format::get_ratio_html($TotalSeeders,$TotalLeechers)?></li>
- <li><strong>Seeder/snatch ratio: </strong><?=Format::get_ratio_html($TotalSeeders,$TotalOverallSnatches)?></li>
+ <li><strong>Seeder/leecher ratio: </strong><?=Format::get_ratio_html($TotalSeeders, $TotalLeechers)?></li>
+ <li><strong>Seeder/snatch ratio: </strong><?=Format::get_ratio_html($TotalSeeders, $TotalOverallSnatches)?></li>
<br />
<li><strong>Mean seeders per torrent: </strong><?=number_format($TotalSeeders / $TotalTorrents, 2)?></li>
<li><strong>Mean leechers per torrent: </strong><?=number_format($TotalLeechers / $TotalTorrents, 2)?></li>
diff --git a/sections/tools/data/special_users.php b/sections/tools/data/special_users.php
index 54e7761..21c2222 100644
--- a/sections/tools/data/special_users.php
+++ b/sections/tools/data/special_users.php
@@ -6,10 +6,11 @@ View::show_header('Special Users List');
?>
<div class="thin">
<?
-$DB->query("SELECT m.ID
- FROM users_main AS m
- WHERE m.CustomPermissions != ''
- AND m.CustomPermissions != 'a:0:{}'");
+$DB->query("
+ SELECT m.ID
+ FROM users_main AS m
+ WHERE m.CustomPermissions != ''
+ AND m.CustomPermissions != 'a:0:{}'");
if ($DB->record_count()) {
?>
<table width="100%">
diff --git a/sections/tools/data/torrent_stats.php b/sections/tools/data/torrent_stats.php
index c9d7236..ee57537 100644
--- a/sections/tools/data/torrent_stats.php
+++ b/sections/tools/data/torrent_stats.php
@@ -5,9 +5,14 @@ if (!check_perms('site_view_flow')) {
View::show_header('Torrents');
if (!$TorrentStats = $Cache->get_value('new_torrent_stats')) {
- $DB->query("SELECT COUNT(ID), SUM(Size), SUM(FileCount) FROM torrents");
+ $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'");
+ $DB->query("
+ SELECT COUNT(ID)
+ FROM users_main
+ WHERE Enabled = '1'");
list($NumUsers) = $DB->next_record();
$DB->query("SELECT COUNT(ID), SUM(Size), SUM(FileCount) FROM torrents WHERE Time > SUBDATE('".sqltime()."', INTERVAL 1 DAY)");
list($DayNum, $DaySize, $DayFiles) = $DB->next_record();
@@ -15,13 +20,13 @@ if (!$TorrentStats = $Cache->get_value('new_torrent_stats')) {
list($WeekNum, $WeekSize, $WeekFiles) = $DB->next_record();
$DB->query("SELECT COUNT(ID), SUM(Size), SUM(FileCount) FROM torrents WHERE Time > SUBDATE('".sqltime()."', INTERVAL 30 DAY)");
list($MonthNum, $MonthSize, $MonthFiles) = $DB->next_record();
- $Cache->cache_value('new_torrent_stats',array($TorrentCount,$TotalSize,$TotalFiles,
- $NumUsers,$DayNum,$DaySize,$DayFiles,
- $WeekNum,$WeekSize,$WeekFiles,$MonthNum,
- $MonthSize,$MonthFiles),3600);
+ $Cache->cache_value('new_torrent_stats', array($TorrentCount, $TotalSize, $TotalFiles,
+ $NumUsers, $DayNum, $DaySize, $DayFiles,
+ $WeekNum, $WeekSize, $WeekFiles, $MonthNum,
+ $MonthSize, $MonthFiles), 3600);
} else {
- list($TorrentCount,$TotalSize,$TotalFiles,$NumUsers,$DayNum,$DaySize,$DayFiles,
- $WeekNum,$WeekSize,$WeekFiles,$MonthNum,$MonthSize,$MonthFiles) = $TorrentStats;
+ list($TorrentCount, $TotalSize, $TotalFiles, $NumUsers, $DayNum, $DaySize, $DayFiles,
+ $WeekNum, $WeekSize, $WeekFiles, $MonthNum, $MonthSize, $MonthFiles) = $TorrentStats;
}
?>
diff --git a/sections/tools/index.php b/sections/tools/index.php
index f47d207..cc27396 100644
--- a/sections/tools/index.php
+++ b/sections/tools/index.php
@@ -469,6 +469,9 @@ switch ($_REQUEST['action']) {
error(403);
}
break;
+ case 'bbcode_sandbox':
+ include('misc/bbcode_sandbox.php');
+ break;
default:
include(SERVER_ROOT.'/sections/tools/tools.php');
diff --git a/sections/tools/managers/forum_alter.php b/sections/tools/managers/forum_alter.php
index c8821f0..26b0e7e 100644
--- a/sections/tools/managers/forum_alter.php
+++ b/sections/tools/managers/forum_alter.php
@@ -9,15 +9,17 @@ if ($_POST['submit'] == 'Delete') { //Delete
if (!is_number($_POST['id']) || $_POST['id'] == '') {
error(0);
}
- $DB->query('DELETE FROM forums WHERE ID='.$_POST['id']);
+ $DB->query('
+ DELETE FROM forums
+ WHERE ID = '.$_POST['id']);
} else { //Edit & Create, Shared Validation
- $Val->SetFields('name', '1','string','The name must be set, and has a max length of 40 characters', array('maxlength'=>40, 'minlength'=>1));
- $Val->SetFields('description', '0','string','The description has a max length of 255 characters', array('maxlength'=>255));
- $Val->SetFields('sort', '1','number','Sort must be set');
- $Val->SetFields('categoryid', '1','number','Category must be set');
- $Val->SetFields('minclassread', '1','number','MinClassRead must be set');
- $Val->SetFields('minclasswrite', '1','number','MinClassWrite must be set');
- $Val->SetFields('minclasscreate', '1','number','MinClassCreate must be set');
+ $Val->SetFields('name', '1', 'string', 'The name must be set, and has a max length of 40 characters', array('maxlength' => 40, 'minlength' => 1));
+ $Val->SetFields('description', '0', 'string', 'The description has a max length of 255 characters', array('maxlength' => 255));
+ $Val->SetFields('sort', '1', 'number', 'Sort must be set');
+ $Val->SetFields('categoryid', '1', 'number', 'Category must be set');
+ $Val->SetFields('minclassread', '1', 'number', 'MinClassRead must be set');
+ $Val->SetFields('minclasswrite', '1', 'number', 'MinClassWrite must be set');
+ $Val->SetFields('minclasscreate', '1', 'number', 'MinClassCreate must be set');
$Err = $Val->ValidateForm($_POST); // Validate the form
if ($Err) {
error($Err);
@@ -32,7 +34,10 @@ if ($_POST['submit'] == 'Delete') { //Delete
if (!is_number($_POST['id']) || $_POST['id'] == '') {
error(0);
}
- $DB->query('SELECT MinClassRead FROM forums WHERE ID=' . $P['id']);
+ $DB->query('
+ SELECT MinClassRead
+ FROM forums
+ WHERE ID = ' . $P['id']);
if ($DB->record_count() < 1) {
error(404);
} else {
@@ -45,20 +50,22 @@ if ($_POST['submit'] == 'Delete') { //Delete
$DB->query("
UPDATE forums
SET
- Sort='$P[sort]',
- CategoryID='$P[categoryid]',
- Name='$P[name]',
- Description='$P[description]',
- MinClassRead='$P[minclassread]',
- MinClassWrite='$P[minclasswrite]',
- MinClassCreate='$P[minclasscreate]',
- AutoLock='$P[autolock]',
- AutoLockWeeks='$P[autolockweeks]'
- WHERE ID='$P[id]'");
+ Sort = '$P[sort]',
+ CategoryID = '$P[categoryid]',
+ Name = '$P[name]',
+ Description = '$P[description]',
+ MinClassRead = '$P[minclassread]',
+ MinClassWrite = '$P[minclasswrite]',
+ MinClassCreate = '$P[minclasscreate]',
+ AutoLock = '$P[autolock]',
+ AutoLockWeeks = '$P[autolockweeks]'
+ WHERE ID = '$P[id]'");
} else { //Create
- $DB->query("INSERT INTO forums
- (Sort, CategoryID, Name, Description, MinClassRead, MinClassWrite, MinClassCreate, AutoLock, AutoLockWeeks) VALUES
- ('$P[sort]', '$P[categoryid]', '$P[name]','$P[description]','$P[minclassread]','$P[minclasswrite]','$P[minclasscreate]','$P[autolock]','$P[autolockweeks]')");
+ $DB->query("
+ INSERT INTO forums
+ (Sort, CategoryID, Name, Description, MinClassRead, MinClassWrite, MinClassCreate, AutoLock, AutoLockWeeks)
+ VALUES
+ ('$P[sort]', '$P[categoryid]', '$P[name]', '$P[description]', '$P[minclassread]', '$P[minclasswrite]', '$P[minclasscreate]', '$P[autolock]', '$P[autolockweeks]')");
}
}
diff --git a/sections/tools/managers/forum_list.php b/sections/tools/managers/forum_list.php
index 80bab90..a494c5e 100644
--- a/sections/tools/managers/forum_list.php
+++ b/sections/tools/managers/forum_list.php
@@ -9,11 +9,11 @@ function class_list($Selected = 0) {
$Name = $Class['Name'];
$Level = $Class['Level'];
- $Return.='<option value="'.$Level.'"';
+ $Return .= "<option value=\"$Level\"";
if ($Selected == $Level) {
- $Return.=' selected="selected"';
+ $Return .= ' selected="selected"';
}
- $Return.='>'.Format::cut_string($Name, 20, 1).'</option>'."\n";
+ $Return .= '>'.Format::cut_string($Name, 20, 1)."</option>\n";
}
reset($Classes);
return $Return;
@@ -24,14 +24,19 @@ if (!check_perms('admin_manage_forums')) {
}
View::show_header('Forum Management');
-$DB->query('SELECT ID, Name FROM forums ORDER BY Sort');
+$DB->query('
+ SELECT ID, Name
+ FROM forums
+ ORDER BY Sort');
$ForumArray = $DB->to_array(); // used for generating the 'parent' drop down list
// Replace the old hard-coded forum categories
unset($ForumCats);
$ForumCats = $Cache->get_value('forums_categories');
if ($ForumCats === false) {
- $DB->query('SELECT ID, Name FROM forums_categories');
+ $DB->query('
+ SELECT ID, Name
+ FROM forums_categories');
$ForumCats = array();
while (list($ID, $Name) = $DB->next_record()) {
$ForumCats[$ID] = $Name;
@@ -55,7 +60,7 @@ $DB->query('
ORDER BY CategoryID, Sort ASC');
?>
<div class="header">
- <script type="text/javacript">document.getElementByID('content').style.overflow='visible';</script>
+ <script type="text/javacript">document.getElementByID('content').style.overflow = 'visible';</script>
<h2>Forum control panel</h2>
</div>
<table width="100%">
@@ -67,8 +72,8 @@ $DB->query('
<td>Min class read</td>
<td>Min class write</td>
<td>Min class create</td>
- <td>Autolock</td>
- <td>Autolock weeks</td>
+ <td>Auto-lock</td>
+ <td>Auto-lock weeks</td>
<td>Submit</td>
</tr>
<?
@@ -86,7 +91,7 @@ while (list($ID, $CategoryID, $Sort, $Name, $Description, $MinClassRead, $MinCla
<? reset($ForumCats);
foreach ($ForumCats as $CurCat => $CatName) {
?>
- <option value="<?=$CurCat?>" <? if ($CurCat == $CategoryID) { echo ' selected="selected"'; } ?>><?=$CatName?></option>
+ <option value="<?=$CurCat?>"<? if ($CurCat == $CategoryID) { echo ' selected="selected"'; } ?>><?=$CatName?></option>
<? } ?>
</select>
</td>
diff --git a/sections/tools/managers/news.php b/sections/tools/managers/news.php
index 55c548b..38be7c9 100644
--- a/sections/tools/managers/news.php
+++ b/sections/tools/managers/news.php
@@ -6,7 +6,7 @@ if (!check_perms('admin_manage_news')) {
include(SERVER_ROOT.'/classes/text.class.php');
$Text = new TEXT;
-View::show_header('Manage news','bbcode');
+View::show_header('Manage news', 'bbcode');
switch ($_GET['action']) {
case 'takeeditnews':
@@ -16,7 +16,10 @@ switch ($_GET['action']) {
if (is_number($_POST['newsid'])) {
authorize();
- $DB->query("UPDATE news SET Title='".db_string($_POST['title'])."', Body='".db_string($_POST['body'])."' WHERE ID='".db_string($_POST['newsid'])."'");
+ $DB->query("
+ UPDATE news
+ SET Title = '".db_string($_POST['title'])."', Body = '".db_string($_POST['body'])."'
+ WHERE ID = '".db_string($_POST['newsid'])."'");
$Cache->delete_value('news');
$Cache->delete_value('feed_news');
}
@@ -25,7 +28,10 @@ switch ($_GET['action']) {
case 'editnews':
if (is_number($_GET['id'])) {
$NewsID = $_GET['id'];
- $DB->query("SELECT Title, Body FROM news WHERE ID=$NewsID");
+ $DB->query("
+ SELECT Title, Body
+ FROM news
+ WHERE ID = $NewsID");
list($Title, $Body) = $DB->next_record();
}
}
diff --git a/sections/tools/managers/official_tags.php b/sections/tools/managers/official_tags.php
index 8acbdad..f34b496 100644
--- a/sections/tools/managers/official_tags.php
+++ b/sections/tools/managers/official_tags.php
@@ -15,19 +15,32 @@ if (isset($_POST['doit'])) {
}
$OldTagIDs = implode(', ', $OldTagIDs);
- $DB->query("UPDATE tags SET TagType = 'other' WHERE ID IN ($OldTagIDs)");
+ $DB->query("
+ UPDATE tags
+ SET TagType = 'other'
+ WHERE ID IN ($OldTagIDs)");
}
if ($_POST['newtag']) {
$TagName = Misc::sanitize_tag($_POST['newtag']);
- $DB->query("SELECT t.ID FROM tags AS t WHERE t.Name LIKE '".$TagName."'");
+ $DB->query("
+ SELECT t.ID
+ FROM tags AS t
+ WHERE t.Name LIKE '$TagName'");
list($TagID) = $DB->next_record();
if ($TagID) {
- $DB->query("UPDATE tags SET TagType = 'genre' WHERE ID = $TagID");
+ $DB->query("
+ UPDATE tags
+ SET TagType = 'genre'
+ WHERE ID = $TagID");
} else { // Tag doesn't exist yet - create tag
- $DB->query("INSERT INTO tags (Name, UserID, TagType, Uses) VALUES ('".$TagName."', ".$LoggedUser['ID'].", 'genre', 0)");
+ $DB->query("
+ INSERT INTO tags
+ (Name, UserID, TagType, Uses)
+ VALUES
+ ('$TagName', ".$LoggedUser['ID'].", 'genre', 0)");
$TagID = $DB->inserted_id();
}
}
@@ -62,7 +75,11 @@ View::show_header('Official Tags Manager');
</tr>
<?
$i = 0;
-$DB->query("SELECT ID, Name, Uses FROM tags WHERE TagType='genre' ORDER BY Name ASC");
+$DB->query("
+ SELECT ID, Name, Uses
+ FROM tags
+ WHERE TagType = 'genre'
+ ORDER BY Name ASC");
$TagCount = $DB->record_count();
$Tags = $DB->to_array();
for ($i = 0; $i < $TagCount / 3; $i++) {
diff --git a/sections/tools/managers/permissions_list.php b/sections/tools/managers/permissions_list.php
index 40f2067..c0cea0d 100644
--- a/sections/tools/managers/permissions_list.php
+++ b/sections/tools/managers/permissions_list.php
@@ -4,7 +4,7 @@ View::show_header('Manage Permissions');
<script type="text/javascript">//<![CDATA[
function confirmDelete(id) {
if (confirm("Are you sure you want to remove this permission class?")) {
- location.href="tools.php?action=permissions&removeid="+id;
+ location.href = "tools.php?action=permissions&removeid=" + id;
}
return false;
}
@@ -18,17 +18,18 @@ function confirmDelete(id) {
</div>
</div>
<?
-$DB->query("SELECT
- p.ID,
- p.Name,
- p.Level,
- p.Secondary,
- COUNT(u.ID)+COUNT(DISTINCT l.UserID)
- FROM permissions AS p
- LEFT JOIN users_main AS u ON u.PermissionID=p.ID
- LEFT JOIN users_levels AS l ON l.PermissionID=p.ID
- GROUP BY p.ID
- ORDER BY p.Secondary ASC, p.Level ASC");
+$DB->query("
+ SELECT
+ p.ID,
+ p.Name,
+ p.Level,
+ p.Secondary,
+ COUNT(u.ID) + COUNT(DISTINCT l.UserID)
+ FROM permissions AS p
+ LEFT JOIN users_main AS u ON u.PermissionID = p.ID
+ LEFT JOIN users_levels AS l ON l.PermissionID = p.ID
+ GROUP BY p.ID
+ ORDER BY p.Secondary ASC, p.Level ASC");
if ($DB->record_count()) {
?>
<table width="100%">
@@ -38,14 +39,14 @@ if ($DB->record_count()) {
<td>User count</td>
<td class="center">Actions</td>
</tr>
-<? while (list($ID,$Name,$Level,$Secondary,$UserCount)=$DB->next_record()) { ?>
+<? while (list($ID, $Name, $Level, $Secondary, $UserCount) = $DB->next_record()) { ?>
<tr>
<td><?=display_str($Name); ?></td>
<td><?=($Secondary ? 'Secondary' : $Level) ?></td>
<td><?=number_format($UserCount); ?></td>
<td class="center">
<a href="tools.php?action=permissions&amp;id=<?=$ID ?>" class="brackets">Edit</a>
- <a href="#" onclick="return confirmDelete(<?=$ID?>)" class="brackets">Remove</a>
+ <a href="#" onclick="return confirmDelete(<?=$ID?>);" class="brackets">Remove</a>
</td>
</tr>
<? } ?>
diff --git a/sections/tools/managers/recommend_alter.php b/sections/tools/managers/recommend_alter.php
index 83c172d..50a2665 100644
--- a/sections/tools/managers/recommend_alter.php
+++ b/sections/tools/managers/recommend_alter.php
@@ -12,14 +12,19 @@ if (!$GroupID || !is_number($GroupID)) {
}
if (!check_perms('site_manage_recommendations')) {
- $DB->query("SELECT UserID FROM torrents_recommended WHERE GroupID='$GroupID'");
+ $DB->query("
+ SELECT UserID
+ FROM torrents_recommended
+ WHERE GroupID = '$GroupID'");
list($UserID) = $DB->next_record();
if ($UserID != $LoggedUser['ID']) {
error(403);
}
}
-$DB->query("DELETE FROM torrents_recommended WHERE GroupID='$GroupID'");
+$DB->query("
+ DELETE FROM torrents_recommended
+ WHERE GroupID = '$GroupID'");
$Cache->delete_value('recommend');
header('Location: '.$_SERVER['HTTP_REFERER']);
diff --git a/sections/tools/managers/recommend_restore.php b/sections/tools/managers/recommend_restore.php
index 8198be4..e6c2d59 100644
--- a/sections/tools/managers/recommend_restore.php
+++ b/sections/tools/managers/recommend_restore.php
@@ -8,7 +8,9 @@ if (!check_perms('site_manage_recommendations')) {
error(403);
}
-$DB->query('SELECT GroupID FROM torrents_recommended');
+$DB->query('
+ SELECT GroupID
+ FROM torrents_recommended');
$ToNL = $DB->next_record();
Torrents::freeleech_groups($ToNL, 2, 3);
?>
diff --git a/sections/tools/managers/whitelist_alter.php b/sections/tools/managers/whitelist_alter.php
index 225370e..dce54b1 100644
--- a/sections/tools/managers/whitelist_alter.php
+++ b/sections/tools/managers/whitelist_alter.php
@@ -10,9 +10,14 @@ if ($_POST['submit'] == 'Delete') {
error('1');
}
- $DB->query("SELECT peer_id FROM xbt_client_whitelist WHERE id = ".$_POST['id']);
+ $DB->query('
+ SELECT peer_id
+ FROM xbt_client_whitelist
+ WHERE id = '.$_POST['id']);
list($PeerID) = $DB->next_record();
- $DB->query('DELETE FROM xbt_client_whitelist WHERE id='.$_POST['id']);
+ $DB->query('
+ DELETE FROM xbt_client_whitelist
+ WHERE id = '.$_POST['id']);
Tracker::update_tracker('remove_whitelist', array('peer_id' => $PeerID));
} else { //Edit & Create, Shared Validation
@@ -28,21 +33,25 @@ if ($_POST['submit'] == 'Delete') {
if (empty($_POST['id']) || !is_number($_POST['id'])) {
error('3');
} else {
- $DB->query("SELECT peer_id FROM xbt_client_whitelist WHERE id = ".$_POST['id']);
+ $DB->query('
+ SELECT peer_id
+ FROM xbt_client_whitelist
+ WHERE id = '.$_POST['id']);
list($OldPeerID) = $DB->next_record();
$DB->query("
UPDATE xbt_client_whitelist
SET
- vstring='".$Client."',
- peer_id='".$PeerID."'
- WHERE ID=".$_POST['id']);
+ vstring = '$Client',
+ peer_id = '$PeerID'
+ WHERE ID = ".$_POST['id']);
Tracker::update_tracker('edit_whitelist', array('old_peer_id' => $OldPeerID, 'new_peer_id' => $PeerID));
}
} else { //Create
$DB->query("
- INSERT INTO xbt_client_whitelist (vstring, peer_id)
+ INSERT INTO xbt_client_whitelist
+ (vstring, peer_id)
VALUES
- ('$Client','$PeerID')");
+ ('$Client', '$PeerID')");
Tracker::update_tracker('add_whitelist', array('peer_id' => $PeerID));
}
}
diff --git a/sections/tools/managers/whitelist_list.php b/sections/tools/managers/whitelist_list.php
index 5ce709b..ae95696 100644
--- a/sections/tools/managers/whitelist_list.php
+++ b/sections/tools/managers/whitelist_list.php
@@ -4,7 +4,10 @@ if (!check_perms('admin_whitelist')) {
}
View::show_header('Whitelist Management');
-$DB->query('SELECT id, vstring, peer_id FROM xbt_client_whitelist ORDER BY peer_id ASC');
+$DB->query('
+ SELECT id, vstring, peer_id
+ FROM xbt_client_whitelist
+ ORDER BY peer_id ASC');
?>
<div class="header">
<h2>Allowed Clients</h2>
diff --git a/sections/tools/misc/bbcode_sandbox.php b/sections/tools/misc/bbcode_sandbox.php
new file mode 100644
index 0000000..1ad405e
--- /dev/null
+++ b/sections/tools/misc/bbcode_sandbox.php
@@ -0,0 +1,16 @@
+<?
+if (!check_perms("users_mod")) {
+ error(403);
+}
+
+View::show_header("BBCode Sandbox", 'bbcode_sandbox');
+?>
+<div class="thin">
+ <textarea id="sandbox" class="wbbarea" style="width: 98%;" onkeyup="resize('sandbox');" name="body" cols="90" rows="8"></textarea>
+ <br />
+ <br />
+ <div id="preview" class="">
+ </div>
+</div>
+<?
+View::show_footer(); \ No newline at end of file
diff --git a/sections/tools/misc/tags.php b/sections/tools/misc/tags.php
index 60bf9f0..b0e1a1d 100644
--- a/sections/tools/misc/tags.php
+++ b/sections/tools/misc/tags.php
@@ -51,7 +51,8 @@ if (isset($_GET['tag']) || isset($_GET['replace'])) {
// validate input
$Err = $Val->ValidateForm($_GET);
if ($Err) {
- echo ' <div class="box pad center">
+ echo '
+ <div class="box pad center">
<strong>Error:</strong> '.$Err.'
</div>';
} else {
@@ -60,8 +61,9 @@ if (isset($_GET['tag']) || isset($_GET['replace'])) {
// trying to merge tag with itself would create big problems
if ($Tag == $Replacement) {
- echo " <div class=\"box pad center\">
- <strong>Error:</strong> Cannot merge tag $Tag with itself (doh).
+ echo "
+ <div class=\"box pad center\">
+ <strong>Error:</strong> Cannot merge tag $Tag with itself!
</div>
</div>";
View::show_footer();
@@ -75,7 +77,8 @@ if (isset($_GET['tag']) || isset($_GET['replace'])) {
WHERE Name = '$Tag'
LIMIT 1;");
if ($DB->record_count() == 0) {
- echo " <div class=\"box pad center\">
+ echo "
+ <div class=\"box pad center\">
<strong>Error:</strong> No such tag found: $Tag
</div>
</div>";
@@ -107,9 +110,9 @@ if (isset($_GET['tag']) || isset($_GET['replace'])) {
ag.Name,
tg.Name
FROM torrents_group AS tg
- LEFT JOIN artists_group AS ag ON ag.ArtistID=tg.ArtistID
- JOIN torrents_tags AS t ON t.GroupID=tg.ID
- WHERE t.TagID=$TagID;");
+ LEFT JOIN artists_group AS ag ON ag.ArtistID = tg.ArtistID
+ JOIN torrents_tags AS t ON t.GroupID = tg.ID
+ WHERE t.TagID = $TagID;");
while (list($TorrentID, $ArtistID, $ArtistName, $TorrentName) = $DB->next_record()) {
$Row = ($ArtistName ? "<a href=\"artist.php?id=$ArtistID\">$ArtistName</a> - " : '');
$Row.= "<a href=\"torrents.php?id=$TorrentID\">".display_str($TorrentName).'</a>';
@@ -124,10 +127,10 @@ if (isset($_GET['tag']) || isset($_GET['replace'])) {
ag.Name,
r.Title
FROM requests AS r
- LEFT JOIN requests_artists AS ra ON r.ID=ra.RequestID
- LEFT JOIN artists_group AS ag ON ag.ArtistID=ra.ArtistID
- JOIN requests_tags AS t ON t.RequestID=r.ID
- WHERE t.TagID=$TagID;");
+ LEFT JOIN requests_artists AS ra ON r.ID = ra.RequestID
+ LEFT JOIN artists_group AS ag ON ag.ArtistID = ra.ArtistID
+ JOIN requests_tags AS t ON t.RequestID = r.ID
+ WHERE t.TagID = $TagID;");
while (list($RequestID, $ArtistID, $ArtistName, $RequestName) = $DB->next_record()) {
$Row = ($ArtistName ? "<a href=\"artist.php?id=$ArtistID\">$ArtistName</a> - " : '');
$Row.= "<a href=\"requests.php?action=viewrequest&amp;id=$RequestID\">".display_str($RequestName).'</a>';
@@ -149,14 +152,17 @@ if (isset($_GET['tag']) || isset($_GET['replace'])) {
// HARD! merge two tags together and update usage
// 5) remove dupe tags from torrents
// (torrents that have both "old tag" and "replacement tag" set)
- $DB->query("SELECT GroupID FROM torrents_tags WHERE TagID=$ReplacementID;");
+ $DB->query("
+ SELECT GroupID
+ FROM torrents_tags
+ WHERE TagID = $ReplacementID;");
if ($DB->record_count() > 0 ) {
$Query = "
DELETE FROM torrents_tags
- WHERE TagID=$TagID
+ WHERE TagID = $TagID
AND GroupID IN (";
while (list($GroupID) = $DB->next_record()) {
- $Query.= $GroupID.',';
+ $Query .= "$GroupID,";
}
$Query = substr($Query, 0, -1) . ');';
$DB->query($Query);
@@ -166,19 +172,22 @@ if (isset($_GET['tag']) || isset($_GET['replace'])) {
// 6) replace old tag in torrents
$DB->query("
UPDATE torrents_tags
- SET TagID=$ReplacementID
- WHERE TagID=$TagID;");
+ SET TagID = $ReplacementID
+ WHERE TagID = $TagID;");
$UsageChange = $DB->affected_rows();
// 7) remove dupe tags from artists
- $DB->query("SELECT ArtistID FROM artists_tags WHERE TagID=$ReplacementID;");
+ $DB->query("
+ SELECT ArtistID
+ FROM artists_tags
+ WHERE TagID = $ReplacementID;");
if ($DB->record_count() > 0 ) {
$Query = "
DELETE FROM artists_tags
- WHERE TagID=$TagID
+ WHERE TagID = $TagID
AND ArtistID IN (";
while (list($ArtistID) = $DB->next_record()) {
- $Query.= $ArtistID.',';
+ $Query .= "$ArtistID,";
}
$Query = substr($Query, 0, -1) . ');';
$DB->query($Query);
@@ -188,19 +197,22 @@ if (isset($_GET['tag']) || isset($_GET['replace'])) {
// 8) replace old tag in artists
$DB->query("
UPDATE artists_tags
- SET TagID=$ReplacementID
- WHERE TagID=$TagID;");
+ SET TagID = $ReplacementID
+ WHERE TagID = $TagID;");
$UsageChange += $DB->affected_rows();
// 9) remove dupe tags from requests
- $DB->query("SELECT RequestID FROM requests_tags WHERE TagID=$ReplacementID;");
+ $DB->query("
+ SELECT RequestID
+ FROM requests_tags
+ WHERE TagID = $ReplacementID;");
if ($DB->record_count() > 0) {
$Query = "
DELETE FROM requests_tags
- WHERE TagID=$TagID
+ WHERE TagID = $TagID
AND RequestID IN (";
while (list($RequestID) = $DB->next_record()) {
- $Query.= $RequestID.',';
+ $Query .= "$RequestID,";
}
$Query = substr($Query, 0, -1) . ');';
$DB->query($Query);
@@ -210,27 +222,27 @@ if (isset($_GET['tag']) || isset($_GET['replace'])) {
// 10) replace old tag in requests
$DB->query("
UPDATE requests_tags
- SET TagID=$ReplacementID
- WHERE TagID=$TagID;");
+ SET TagID = $ReplacementID
+ WHERE TagID = $TagID;");
$UsageChange += $DB->affected_rows();
$TotalAffected += $UsageChange;
// 11) finally, remove old tag completely
$DB->query("
DELETE FROM tags
- WHERE ID=$TagID
+ WHERE ID = $TagID
LIMIT 1");
// 12) update usage count for replacement tag
$DB->query("
UPDATE tags
- SET Uses=Uses+$UsageChange
- WHERE ID=$ReplacementID
+ SET Uses = Uses + $UsageChange
+ WHERE ID = $ReplacementID
LIMIT 1");
} // if ($Mode == MODE_MERGE)
- echo '<div class="box pad center"><strong>Success!</strong> Affected entries: '.number_format($TotalAffected).'</div>';
+ echo "\n".'<div class="box pad center"><strong>Success!</strong> Affected entries: '.number_format($TotalAffected).'</div>';
if ($_GET['list']) {
?>
@@ -244,7 +256,7 @@ if (isset($_GET['tag']) || isset($_GET['replace'])) {
<?
if (count($AffectedTorrents)) {
foreach ($AffectedTorrents as $Row) {
- echo "<tr><td>$Row</td></tr>";
+ echo "\n\t\t<tr><td>$Row</td></tr>";
}
}
?>
@@ -256,7 +268,7 @@ if (isset($_GET['tag']) || isset($_GET['replace'])) {
<?
if (count($AffectedRequests)) {
foreach ($AffectedRequests as $Row) {
- echo "<tr><td>$Row</td></tr>";
+ echo "\n\t\t<tr><td>$Row</td></tr>";
}
}
?>
diff --git a/sections/tools/tools.php b/sections/tools/tools.php
index a28dc62..d14c7ef 100644
--- a/sections/tools/tools.php
+++ b/sections/tools/tools.php
@@ -89,6 +89,7 @@ View::show_header('Staff Tools');
<? } if (check_perms('admin_clear_cache') || check_perms('users_mod')) { ?>
<tr><td><a href="tools.php?action=rerender_gallery">Rerender stylesheet gallery images</a></td></tr>
<? } if (check_perms('users_mod')) { ?>
+ <tr><td><a href="tools.php?action=bbcode_sandbox">BBCode Sandbox</a></td></tr>
<tr><td><strong><a href="tools.php?action=public_sandbox">Public sandbox</a></strong></td></tr>
<? } if (check_perms('users_mod')) { ?>
<tr><td><strong><a href="tools.php?action=mod_sandbox">Mod-level sandbox</a></strong></td></tr>
diff --git a/sections/top10/history.php b/sections/top10/history.php
index 7972988..f88f5dd 100644
--- a/sections/top10/history.php
+++ b/sections/top10/history.php
@@ -52,15 +52,20 @@ if (!empty($_GET['date'])) {
if (empty($_GET['datetype']) || $_GET['datetype'] == 'day') {
$Type = 'day';
- $Where = "WHERE th.Date BETWEEN '".$SQLTime."' AND '".$SQLTime."' + INTERVAL 24 HOUR AND Type='Daily'";
+ $Where = "
+ WHERE th.Date BETWEEN '$SQLTime' AND '$SQLTime' + INTERVAL 24 HOUR
+ AND Type = 'Daily'";
} else {
$Type = 'week';
- $Where = "WHERE th.Date BETWEEN '".$SQLTime."' - AND '".$SQLTime."' + INTERVAL 7 DAY' AND Type='Weekly'";
+ $Where = "
+ WHERE th.Date BETWEEN '$SQLTime' - AND '$SQLTime' + INTERVAL 7 DAY
+ AND Type = 'Weekly'";
}
- $Details = $Cache->get_value('top10_history_'.$SQLTime);
+ $Details = $Cache->get_value("top10_history_$SQLTime");
if ($Details === false) {
- $DB->query("SELECT
+ $DB->query("
+ SELECT
tht.Rank,
tht.TitleString,
tht.TagString,
@@ -83,12 +88,12 @@ if (!empty($_GET['date'])) {
LEFT JOIN top10_history_torrents AS tht ON tht.HistoryID = th.ID
LEFT JOIN torrents AS t ON t.ID = tht.TorrentID
LEFT JOIN torrents_group AS g ON g.ID = t.GroupID
- ".$Where."
+ $Where
ORDER BY tht.Rank ASC");
$Details = $DB->to_array();
- $Cache->cache_value('top10_history_'.$SQLTime, $Details, 3600*24);
+ $Cache->cache_value("top10_history_$SQLTime", $Details, 3600 * 24);
}
?>
@@ -103,16 +108,16 @@ if (!empty($_GET['date'])) {
</tr>
<?
foreach ($Details as $Detail) :
- list($Rank, $TitleString, $TagString, $TorrentID, $GroupID,$GroupName,$GroupCategoryID,$TorrentTags,
- $Format,$Encoding,$Media,$Scene,$HasLog,$HasCue,$LogScore,$Year,$GroupYear,
- $RemasterTitle,$Snatched,$Seeders,$Leechers,$Data) = $Detail;
+ list($Rank, $TitleString, $TagString, $TorrentID, $GroupID, $GroupName, $GroupCategoryID, $TorrentTags,
+ $Format, $Encoding, $Media, $Scene, $HasLog, $HasCue, $LogScore, $Year, $GroupYear,
+ $RemasterTitle, $Snatched, $Seeders, $Leechers, $Data) = $Detail;
// highlight every other row
$Highlight = ($Rank % 2 ? 'a' : 'b');
if ($GroupID) :
- //Group still exists
- $DisplayName='';
+ // Group still exists
+ $DisplayName = '';
$Artists = Artists::get_artist($GroupID);
@@ -123,43 +128,43 @@ if (!empty($_GET['date'])) {
$DisplayName .= "<a href=\"torrents.php?id=$GroupID&amp;torrentid=$TorrentID\" title=\"View Torrent\">$GroupName</a>";
if ($GroupCategoryID == 1 && $GroupYear > 0) {
- $DisplayName.= " [$GroupYear]";
+ $DisplayName .= " [$GroupYear]";
}
// append extra info to torrent title
$ExtraInfo = '';
$AddExtra = '';
if ($Format) {
- $ExtraInfo.= $Format;
+ $ExtraInfo .= $Format;
$AddExtra = ' / ';
}
if ($Encoding) {
- $ExtraInfo.= $AddExtra.$Encoding;
+ $ExtraInfo .= $AddExtra.$Encoding;
$AddExtra = ' / ';
}
//"FLAC / Lossless / Log (100%) / Cue / CD";
if ($HasLog) {
- $ExtraInfo.= "$AddExtra Log ($LogScore".'%)';
+ $ExtraInfo .= "$AddExtra Log ($LogScore%)";
$AddExtra = ' / ';
}
if ($HasCue) {
- $ExtraInfo.= $AddExtra.'Cue';
+ $ExtraInfo .= "{$AddExtra}Cue";
$AddExtra = ' / ';
}
if ($Media) {
- $ExtraInfo.= $AddExtra.$Media;
+ $ExtraInfo .= $AddExtra.$Media;
$AddExtra = ' / ';
}
if ($Scene) {
- $ExtraInfo.= $AddExtra.'Scene';
+ $ExtraInfo .= "{$AddExtra}Scene";
$AddExtra = ' / ';
}
if ($Year > 0) {
- $ExtraInfo.= $AddExtra.$Year;
+ $ExtraInfo .= $AddExtra.$Year;
$AddExtra = ' ';
}
if ($RemasterTitle) {
- $ExtraInfo.= $AddExtra.$RemasterTitle;
+ $ExtraInfo .= $AddExtra.$RemasterTitle;
}
if ($ExtraInfo != '') {
$ExtraInfo = "- [$ExtraInfo]";
@@ -168,7 +173,7 @@ if (!empty($_GET['date'])) {
$DisplayName .= $ExtraInfo;
$TorrentTags = new Tags($TorrentTags);
else:
- $DisplayName = $TitleString.' (Deleted)';
+ $DisplayName = "$TitleString (Deleted)";
$TorrentTags = new Tags($TagString);
endif;
diff --git a/sections/top10/torrents.php b/sections/top10/torrents.php
index 91523bd..34d8eba 100644
--- a/sections/top10/torrents.php
+++ b/sections/top10/torrents.php
@@ -68,7 +68,7 @@ if (check_perms('site_advanced_top10')) {
<tr id="tagfilter">
<td class="label">Tags (comma-separated):</td>
<td class="ft_taglist">
- <input type="text" name="tags" id="tags" size="75" value="<? if (!empty($_GET['tags'])) { echo display_str($_GET['tags']);} ?>" <? Users::has_autocomplete_enabled('other'); ?>/>&nbsp;
+ <input type="text" name="tags" id="tags" size="75" value="<? if (!empty($_GET['tags'])) { echo display_str($_GET['tags']);} ?>"<? Users::has_autocomplete_enabled('other'); ?> />&nbsp;
<input type="radio" id="rdoAll" name="anyall" value="all"<?=($_GET['anyall']!='any'?' checked="checked"':'')?> /><label for="rdoAll"> All</label>&nbsp;&nbsp;
<input type="radio" id="rdoAny" name="anyall" value="any"<?=($_GET['anyall']=='any'?' checked="checked"':'')?> /><label for="rdoAny"> Any</label>
</td>
diff --git a/sections/torrents/add_alias.php b/sections/torrents/add_alias.php
index eafc0cc..00e28e7 100644
--- a/sections/torrents/add_alias.php
+++ b/sections/torrents/add_alias.php
@@ -16,12 +16,15 @@ for ($i = 0; $i < count($AliasNames); $i++) {
$AliasName = Artists::normalise_artist_name($AliasNames[$i]);
$Importance = $Importances[$i];
- if ($Importance!='1' && $Importance!='2' && $Importance!='3' && $Importance!='4' && $Importance!='5' && $Importance!='6' && $Importance!='7') {
+ if ($Importance != '1' && $Importance != '2' && $Importance != '3' && $Importance != '4' && $Importance != '5' && $Importance != '6' && $Importance != '7') {
break;
}
if (strlen($AliasName) > 0) {
- $DB->query("SELECT AliasID, ArtistID, Redirect, Name FROM artists_alias WHERE Name = '".db_string($AliasName)."'");
+ $DB->query("
+ SELECT AliasID, ArtistID, Redirect, Name
+ FROM artists_alias
+ WHERE Name = '".db_string($AliasName)."'");
while (list($AliasID, $ArtistID, $Redirect, $FoundAliasName) = $DB->next_record(MYSQLI_NUM, false)) {
if (!strcasecmp($AliasName, $FoundAliasName)) {
if ($Redirect) {
@@ -32,43 +35,56 @@ for ($i = 0; $i < count($AliasNames); $i++) {
}
if (!$AliasID) {
$AliasName = db_string($AliasName);
- $DB->query("INSERT INTO artists_group (Name) VALUES ('$AliasName')");
+ $DB->query("
+ INSERT INTO artists_group (Name)
+ VALUES ('$AliasName')");
$ArtistID = $DB->inserted_id();
- $DB->query("INSERT INTO artists_alias (ArtistID, Name) VALUES ('$ArtistID', '$AliasName')");
+ $DB->query("
+ INSERT INTO artists_alias (ArtistID, Name)
+ VALUES ('$ArtistID', '$AliasName')");
$AliasID = $DB->inserted_id();
}
- $DB->query("SELECT Name FROM torrents_group WHERE ID=".$GroupID);
+ $DB->query("
+ SELECT Name
+ FROM torrents_group
+ WHERE ID = $GroupID");
list($GroupName) = $DB->next_record(MYSQLI_NUM, false);
- $DB->query("SELECT Name FROM artists_group WHERE ArtistID=".$ArtistID);
+ $DB->query("
+ SELECT Name
+ FROM artists_group
+ WHERE ArtistID = $ArtistID");
list($ArtistName) = $DB->next_record(MYSQLI_NUM, false);
- $DB->query("INSERT IGNORE INTO torrents_artists
- (GroupID, ArtistID, AliasID, Importance, UserID) VALUES
- ('$GroupID', '$ArtistID', '$AliasID', '$Importance', '$UserID')");
+ $DB->query("
+ INSERT IGNORE INTO torrents_artists
+ (GroupID, ArtistID, AliasID, Importance, UserID)
+ VALUES
+ ('$GroupID', '$ArtistID', '$AliasID', '$Importance', '$UserID')");
if ($DB->affected_rows()) {
$Changed = true;
- $DB->query("INSERT INTO torrents_group (ID, NumArtists)
+ $DB->query("
+ INSERT INTO torrents_group (ID, NumArtists)
SELECT ta.GroupID, COUNT(ta.ArtistID)
FROM torrents_artists AS ta
- WHERE ta.GroupID='$GroupID'
- AND ta.Importance='1'
+ WHERE ta.GroupID = '$GroupID'
+ AND ta.Importance = '1'
GROUP BY ta.GroupID
ON DUPLICATE KEY UPDATE
- NumArtists=VALUES(NumArtists);");
+ NumArtists = VALUES (NumArtists);");
- Misc::write_log("Artist ".$ArtistID." (".$ArtistName.") was added to the group ".$GroupID." (".$GroupName.") as ".$ArtistTypes[$Importance]." by user ".$LoggedUser['ID']." (".$LoggedUser['Username'].")");
- Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "added artist ".$ArtistName." as ".$ArtistTypes[$Importance], 0);
+ Misc::write_log("Artist $ArtistID ($ArtistName) was added to the group $GroupID ($GroupName) as ".$ArtistTypes[$Importance].' by user '.$LoggedUser['ID'].' ('.$LoggedUser['Username'].')');
+ Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "added artist $ArtistName as ".$ArtistTypes[$Importance], 0);
}
}
}
if ($Changed) {
- $Cache->delete_value('torrents_details_'.$GroupID);
- $Cache->delete_value('groups_artists_'.$GroupID); // Delete group artist cache
+ $Cache->delete_value("torrents_details_$GroupID");
+ $Cache->delete_value("groups_artists_$GroupID"); // Delete group artist cache
Torrents::update_hash($GroupID);
}
diff --git a/sections/torrents/browse.php b/sections/torrents/browse.php
index 10f2a67..e8a11d7 100644
--- a/sections/torrents/browse.php
+++ b/sections/torrents/browse.php
@@ -21,7 +21,7 @@
$ErrorPage = true;
-define('EXPLAIN_HACK',false);
+define('EXPLAIN_HACK', false);
if (EXPLAIN_HACK) {
$SCFR = '';
@@ -39,62 +39,62 @@ function build_search($SearchStr, $Field, $Exact = false, $SQLWhere = '', $FullT
}
if (!$Exact) {
- if ($FullText && preg_match('/[^a-zA-Z0-9 ]/i',$SearchStr)) {
+ if ($FullText && preg_match('/[^a-zA-Z0-9 ]/i', $SearchStr)) {
$FullText = 0;
}
$SearchLength = strlen(trim($SearchStr));
- $SearchStr = preg_replace('/\s\s+/',' ',trim($SearchStr));
- $SearchStr = preg_replace_callback('/"(([^"])*)"/','quotes',$SearchStr);
- $SearchStr = explode(' ',$SearchStr);
+ $SearchStr = preg_replace('/\s\s+/', ' ', trim($SearchStr));
+ $SearchStr = preg_replace_callback('/"(([^"])*)"/', 'quotes', $SearchStr);
+ $SearchStr = explode(' ', $SearchStr);
$FilterString = '(.+?)';
foreach ($SearchStr as $SearchVal) {
if (trim($SearchVal) != '') {
$SearchVal = trim($SearchVal);
- $SearchVal = str_replace('{{SPACE}}',' ',$SearchVal);
+ $SearchVal = str_replace('{{SPACE}}', ' ', $SearchVal);
// Choose between fulltext or LIKE based off length of the string
if ($FullText && strlen($SearchVal) > 2) {
if ($SQLWhere != '') {
- $SQLWhere.= ' AND ';
+ $SQLWhere .= ' AND ';
}
- if (substr($SearchVal,0,1) == '-') {
- $SQLWhere.="MATCH ($Field) AGAINST ('".db_string($SearchVal)."' IN BOOLEAN MODE)";
+ if (substr($SearchVal, 0, 1) == '-') {
+ $SQLWhere .= "MATCH ($Field) AGAINST ('".db_string($SearchVal)."' IN BOOLEAN MODE)";
} else {
- $SQLWhere.="MATCH ($Field) AGAINST ('".db_string($SearchVal)."')";
+ $SQLWhere .= "MATCH ($Field) AGAINST ('".db_string($SearchVal)."')";
}
} else {
if ($SQLWhere != '') {
- $SQLWhere.= ' AND ';
+ $SQLWhere .= ' AND ';
}
if (substr($SearchVal,0,1) == '-') {
- $SQLWhere.=$Field." NOT LIKE '%".db_string(substr($SearchVal,1))."%'";
+ $SQLWhere .= "$Field NOT LIKE '%".db_string(substr($SearchVal,1))."%'";
} else {
- $SQLWhere.=$Field." LIKE '%".db_string($SearchVal)."%'";
+ $SQLWhere .= "$Field LIKE '%".db_string($SearchVal)."%'";
}
}
- $FilterString.="($SearchVal)(.+?)";
+ $FilterString .= "($SearchVal)(.+?)";
}
}
} else {
if ($SQLWhere != '') {
- $SQLWhere.= ' AND ';
+ $SQLWhere .= ' AND ';
}
- $SQLWhere.= $Field." LIKE '".db_string($SearchStr)."'";
- $FilterString.= "(.+?)($SearchStr)(.+?)";
+ $SQLWhere .= "$Field LIKE '".db_string($SearchStr)."'";
+ $FilterString .= "(.+?)($SearchStr)(.+?)";
}
$Search = 1;
$FilterString = "/$FilterString/si";
if ($SQLWhere != '' && $AddWhere) {
- $SQLWhere = 'WHERE '.$SQLWhere;
+ $SQLWhere = "WHERE $SQLWhere";
}
return $SQLWhere;
}
function quotes($Str) {
$Str = str_replace(' ', '{{SPACE}}', trim($Str[1]));
- return ' '.$Str.' ';
+ return " $Str ";
}
// The "order by x" links on columns headers
@@ -110,7 +110,7 @@ function header_link($SortKey, $DefaultWay = 'DESC') {
$NewWay = $DefaultWay;
}
- return 'torrents.php?order_way='.$NewWay.'&amp;order_by='.$SortKey.'&amp;'.Format::get_url(array('order_way','order_by'));
+ return "torrents.php?order_way=$NewWay&amp;order_by=$SortKey&amp;" . Format::get_url(array('order_way', 'order_by'));
}
// Setting default search options
@@ -118,29 +118,41 @@ if ($_GET['setdefault']) {
$UnsetList[] = '/(&?page\=.+?&?)/i';
$UnsetList[] = '/(&?setdefault\=.+?&?)/i';
- $DB->query("SELECT SiteOptions FROM users_info WHERE UserID='".db_string($LoggedUser['ID'])."'");
+ $DB->query("
+ SELECT SiteOptions
+ FROM users_info
+ WHERE UserID = '".db_string($LoggedUser['ID'])."'");
list($SiteOptions) = $DB->next_record(MYSQLI_NUM, true);
$SiteOptions = unserialize($SiteOptions);
- $SiteOptions['DefaultSearch'] = preg_replace($UnsetList,'',$_SERVER['QUERY_STRING']);
- $DB->query("UPDATE users_info SET SiteOptions='".db_string(serialize($SiteOptions))."' WHERE UserID='".db_string($LoggedUser['ID'])."'");
- $Cache->begin_transaction('user_info_heavy_'.$UserID);
- $Cache->update_row(false, array('DefaultSearch'=>preg_replace($UnsetList,'',$_SERVER['QUERY_STRING'])));
+ $SiteOptions['DefaultSearch'] = preg_replace($UnsetList, '', $_SERVER['QUERY_STRING']);
+ $DB->query("
+ UPDATE users_info
+ SET SiteOptions = '".db_string(serialize($SiteOptions))."'
+ WHERE UserID = '".db_string($LoggedUser['ID'])."'");
+ $Cache->begin_transaction("user_info_heavy_$UserID");
+ $Cache->update_row(false, array('DefaultSearch' => preg_replace($UnsetList, '', $_SERVER['QUERY_STRING'])));
$Cache->commit_transaction(0);
// Clearing default search options
} elseif ($_GET['cleardefault']) {
- $DB->query("SELECT SiteOptions FROM users_info WHERE UserID='".db_string($LoggedUser['ID'])."'");
+ $DB->query("
+ SELECT SiteOptions
+ FROM users_info
+ WHERE UserID = '".db_string($LoggedUser['ID'])."'");
list($SiteOptions) = $DB->next_record(MYSQLI_NUM, true);
$SiteOptions = unserialize($SiteOptions);
$SiteOptions['DefaultSearch'] = '';
- $DB->query("UPDATE users_info SET SiteOptions='".db_string(serialize($SiteOptions))."' WHERE UserID='".db_string($LoggedUser['ID'])."'");
- $Cache->begin_transaction('user_info_heavy_'.$UserID);
- $Cache->update_row(false, array('DefaultSearch'=>''));
+ $DB->query("
+ UPDATE users_info
+ SET SiteOptions = '".db_string(serialize($SiteOptions))."'
+ WHERE UserID = '".db_string($LoggedUser['ID'])."'");
+ $Cache->begin_transaction("user_info_heavy_$UserID");
+ $Cache->update_row(false, array('DefaultSearch' => ''));
$Cache->commit_transaction(0);
// Use default search options
} elseif (!$_SERVER['QUERY_STRING'] && $LoggedUser['DefaultSearch']) {
- parse_str($LoggedUser['DefaultSearch'],$_GET);
+ parse_str($LoggedUser['DefaultSearch'], $_GET);
}
// If a user is hammering the search page (either via a <script type="text/javascript">, or just general zeal)
@@ -157,38 +169,38 @@ $OrderWay = 'DESC'; // We also order descending by default
list($Page, $Limit) = Format::page_limit(TORRENTS_PER_PAGE);
-if (preg_match('/^s[1-7]$/',$_GET['order_by'])) {
+if (preg_match('/^s[1-7]$/', $_GET['order_by'])) {
$OrderBy = strtolower($_GET['order_by']);
}
-if (in_array(strtolower($_GET['order_way']),array('desc','asc'))) {
+if (in_array(strtolower($_GET['order_way']), array('desc', 'asc'))) {
$OrderWay = strtoupper($_GET['order_way']);
}
// Uploaded, seeding, leeching, snatched lists
if ($_GET['userid'] && is_number($_GET['userid'])) {
- $UserID=ceil($_GET['userid']);
+ $UserID = ceil($_GET['userid']);
$DB->query("
SELECT m.Paranoia, p.Level
FROM users_main AS m
- JOIN permissions AS p ON p.ID=m.PermissionID
- WHERE ID='$UserID'");
+ JOIN permissions AS p ON p.ID = m.PermissionID
+ WHERE ID = '$UserID'");
list($Paranoia, $UserClass) = $DB->next_record();
- $TorrentWhere='';
- $TorrentJoin='';
+ $TorrentWhere = '';
+ $TorrentJoin = '';
if ($_GET['type'] == 'uploaded') {
if (!check_paranoia('uploads', $Paranoia, $UserClass, $UserID)) {
error(403);
}
- $TorrentWhere = "WHERE t.UserID='".$UserID."'";
+ $TorrentWhere = "WHERE t.UserID = '$UserID'";
$Title = 'Uploaded Torrents';
} elseif ($_GET['type'] == 'seeding') {
if (!check_paranoia('seeding', $Paranoia, $UserClass, $UserID)) {
error(403);
}
- $TorrentJoin = "JOIN xbt_files_users AS xfu ON xfu.fid=t.ID AND xfu.uid='$UserID' AND xfu.remaining=0";
+ $TorrentJoin = "JOIN xbt_files_users AS xfu ON xfu.fid = t.ID AND xfu.uid = '$UserID' AND xfu.remaining = 0";
$Title = 'Seeding Torrents';
$TimeField = 'xfu.mtime';
$TimeLabel = 'Seeding Time';
@@ -197,7 +209,7 @@ if ($_GET['userid'] && is_number($_GET['userid'])) {
if (!check_paranoia('leeching', $Paranoia, $UserClass, $UserID)) {
error(403);
}
- $TorrentJoin = "JOIN xbt_files_users AS xfu ON xfu.fid=t.ID AND xfu.uid='$UserID' AND xfu.remaining>0";
+ $TorrentJoin = "JOIN xbt_files_users AS xfu ON xfu.fid = t.ID AND xfu.uid = '$UserID' AND xfu.remaining > 0";
$Title = 'Leeching Torrents';
$TimeField = 'xfu.mtime';
$TimeLabel = 'Leeching Time';
@@ -206,7 +218,7 @@ if ($_GET['userid'] && is_number($_GET['userid'])) {
if (!check_paranoia('snatched', $Paranoia, $UserClass, $UserID)) {
error(403);
}
- $TorrentJoin = "JOIN xbt_snatched AS xs ON xs.fid=t.ID AND xs.uid='$UserID'";
+ $TorrentJoin = "JOIN xbt_snatched AS xs ON xs.fid = t.ID AND xs.uid = '$UserID'";
$Title = 'Snatched Torrents';
$TimeField = 'xs.tstamp';
$TimeLabel = 'Snatched Time';
@@ -232,7 +244,7 @@ if (($LoggedUser['DisableGrouping'] && !$_GET['enablegrouping']) || $_GET['disab
if ((strtolower($_GET['action']) == 'advanced' || ($LoggedUser['SearchType'] && strtolower($_GET['action']) != 'basic')) && check_perms('site_advanced_search')) {
$TorrentSpecifics = 0; // How many options are we searching by? (Disabled grouping only)
if ($DisableGrouping) {
- foreach ($_GET as $SearchType=>$SearchStr) {
+ foreach ($_GET as $SearchType => $SearchStr) {
switch ($SearchType) {
case 'bitrate':
case 'format':
@@ -259,177 +271,177 @@ if ((strtolower($_GET['action']) == 'advanced' || ($LoggedUser['SearchType'] &&
$TorrentJoin .= '
LEFT JOIN torrents_artists AS ta ON g.ID = ta.GroupID
LEFT JOIN artists AS a ON ta.ArtistID = a.ID';
- $TorrentWhere = build_search($_GET['artistname'],'a.Name',$_GET['exactartist'],$TorrentWhere);
+ $TorrentWhere = build_search($_GET['artistname'], 'a.Name', $_GET['exactartist'], $TorrentWhere);
}
if ($_GET['torrentname'] != '') {
if (!$DisableGrouping) {
- $GroupWhere = build_search($_GET['torrentname'],'GroupName',$_GET['exacttorrent'],$GroupWhere);
+ $GroupWhere = build_search($_GET['torrentname'], 'GroupName', $_GET['exacttorrent'], $GroupWhere);
} else {
- $TorrentWhere = build_search($_GET['torrentname'],'g.Name',$_GET['exacttorrent'],$TorrentWhere);
+ $TorrentWhere = build_search($_GET['torrentname'], 'g.Name', $_GET['exacttorrent'], $TorrentWhere);
}
}
if ($_GET['remastertitle'] != '') {
$RemasterTitle = $_GET['remastertitle'];
if ($_GET['exactremaster']) {
- $RemasterTitle = '%'.$RemasterTitle.'%';
+ $RemasterTitle = "%$RemasterTitle%";
}
- $GroupWhere = build_search($RemasterTitle,'RemasterTitleList',$_GET['exactremaster'],$GroupWhere,0,$RemasterRegEx);
+ $GroupWhere = build_search($RemasterTitle, 'RemasterTitleList', $_GET['exactremaster'], $GroupWhere, 0, $RemasterRegEx);
if ($TorrentSpecifics > 0) {
- $TorrentWhere = build_search($_GET['remastertitle'],'t.RemasterTitle',$_GET['exactremaster'],$TorrentWhere);
+ $TorrentWhere = build_search($_GET['remastertitle'], 't.RemasterTitle', $_GET['exactremaster'], $TorrentWhere);
}
}
if ($_GET['year'] != '' && is_numeric($_GET['year'])) {
if (!$DisableGrouping) {
if ($GroupWhere == '') {
- $GroupWhere='WHERE ';
+ $GroupWhere = 'WHERE ';
} else {
- $GroupWhere.= ' AND ';
+ $GroupWhere .= ' AND ';
}
- $GroupWhere.="GroupYear='".db_string($_GET['year'])."'";
+ $GroupWhere .= "GroupYear = '".db_string($_GET['year'])."'";
} else {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
- $TorrentWhere.= ' AND ';
+ $TorrentWhere .= ' AND ';
}
- $TorrentWhere.="g.Year='".db_string($_GET['year'])."'";
+ $TorrentWhere .= "g.Year = '".db_string($_GET['year'])."'";
}
}
if ($_GET['bitrate'] != '') {
- if (in_array($_GET['bitrate'],$Bitrates)) {
+ if (in_array($_GET['bitrate'], $Bitrates)) {
if ($_GET['bitrate'] == 'Other') {
if ($_GET['other_bitrate'] != '') {
- $GroupWhere=build_search(db_string($_GET['other_bitrate']),'EncodingList',false,$GroupWhere);
+ $GroupWhere = build_search(db_string($_GET['other_bitrate']), 'EncodingList', false, $GroupWhere);
if ($TorrentSpecifics > 0) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
- $TorrentWhere.= ' AND ';
+ $TorrentWhere .= ' AND ';
}
}
- $TorrentWhere.="t.Encoding LIKE '%".db_string($_GET['other_bitrate'])."%'";
+ $TorrentWhere .= "t.Encoding LIKE '%".db_string($_GET['other_bitrate'])."%'";
}
} else {
- $GroupWhere = build_search(db_string($_GET['bitrate']),'EncodingList',false,$GroupWhere);
+ $GroupWhere = build_search(db_string($_GET['bitrate']), 'EncodingList', false, $GroupWhere);
if ($TorrentSpecifics > 0) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
- $TorrentWhere.= ' AND ';
+ $TorrentWhere .= ' AND ';
}
- $TorrentWhere.="t.Encoding LIKE '".db_string($_GET['bitrate'])."'";
+ $TorrentWhere .= "t.Encoding LIKE '".db_string($_GET['bitrate'])."'";
}
}
}
}
- if ($_GET['format'] != '' && in_array($_GET['format'],$Formats)) {
- $GroupWhere = build_search('%'.$_GET['format'].'%','FormatList',f,$GroupWhere);
+ if ($_GET['format'] != '' && in_array($_GET['format'], $Formats)) {
+ $GroupWhere = build_search('%'.$_GET['format'].'%', 'FormatList', false, $GroupWhere);
if ($TorrentSpecifics > 0) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
- $TorrentWhere.= ' AND ';
+ $TorrentWhere .= ' AND ';
}
- $TorrentWhere.="t.Format='".db_string($_GET['format'])."'";
+ $TorrentWhere .= "t.Format = '".db_string($_GET['format'])."'";
}
}
- if ($_GET['media'] != '' && in_array($_GET['media'],$Media)) {
- $GroupWhere = build_search('%'.$_GET['media'].'%','MediaList',false,$GroupWhere);
+ if ($_GET['media'] != '' && in_array($_GET['media'], $Media)) {
+ $GroupWhere = build_search('%'.$_GET['media'].'%', 'MediaList', false, $GroupWhere);
if ($TorrentSpecifics > 0) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
- $TorrentWhere.= ' AND ';
+ $TorrentWhere .= ' AND ';
}
- $TorrentWhere.="t.Media='".db_string($_GET['media'])."'";
+ $TorrentWhere .= "t.Media = '".db_string($_GET['media'])."'";
}
}
if ($_GET['filelist'] != '') {
- $TorrentWhere = build_search('%'.$_GET['filelist'].'%','t.FileList',true,$TorrentWhere);
+ $TorrentWhere = build_search('%'.$_GET['filelist'].'%', 't.FileList', true, $TorrentWhere);
}
if ($_GET['haslog'] != '') {
$HasLog = ceil($_GET['haslog']);
if ($_GET['haslog'] == '100' || $_GET['haslog'] == '-100') {
- $GroupWhere = build_search($_GET['haslog'],'LogScoreList',false,$GroupWhere);
+ $GroupWhere = build_search($_GET['haslog'], 'LogScoreList', false, $GroupWhere);
$HasLog = 1;
}
- $GroupWhere = build_search('%'.$HasLog.'%','LogList',true,$GroupWhere);
+ $GroupWhere = build_search('%'.$HasLog.'%', 'LogList', true, $GroupWhere);
if ($TorrentSpecifics > 0) {
if ($_GET['haslog'] == '100' || $_GET['haslog'] == '-100') {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
- $TorrentWhere.= ' AND ';
+ $TorrentWhere .= ' AND ';
}
if ($_GET['haslog'] == '-100') {
- $TorrentWhere.= "t.LogScore!='100'";
+ $TorrentWhere .= "t.LogScore != '100'";
} else {
- $TorrentWhere.= "t.LogScore='100'";
+ $TorrentWhere .= "t.LogScore = '100'";
}
}
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
- $TorrentWhere.= ' AND ';
+ $TorrentWhere .= ' AND ';
}
- $TorrentWhere.= "t.HasLog='$HasLog'";
+ $TorrentWhere .= "t.HasLog = '$HasLog'";
}
}
if ($_GET['hascue'] != '') {
- $GroupWhere = build_search('%'.$_GET['hascue'].'%','CueList',true,$GroupWhere);
+ $GroupWhere = build_search('%'.$_GET['hascue'].'%', 'CueList', true, $GroupWhere);
if ($TorrentSpecifics > 0) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
- $TorrentWhere.= ' AND ';
+ $TorrentWhere .= ' AND ';
}
- $TorrentWhere.= "t.HasCue='".ceil($_GET['hascue'])."'";
+ $TorrentWhere .= "t.HasCue = '".ceil($_GET['hascue'])."'";
}
}
if ($_GET['scene'] != '') {
- $GroupWhere = build_search('%'.$_GET['scene'].'%','SceneList',true,$GroupWhere);
+ $GroupWhere = build_search('%'.$_GET['scene'].'%', 'SceneList', true, $GroupWhere);
if ($TorrentSpecifics > 0) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
- $TorrentWhere.= ' AND ';
+ $TorrentWhere .= ' AND ';
}
- $TorrentWhere.= "t.Scene='".ceil($_GET['scene'])."'";
+ $TorrentWhere .= "t.Scene = '".ceil($_GET['scene'])."'";
}
}
if ($_GET['freeleech'] != '') {
- $GroupWhere = build_search('%'.$_GET['freeleech'].'%','FreeTorrentList',true,$GroupWhere);
+ $GroupWhere = build_search('%'.$_GET['freeleech'].'%', 'FreeTorrentList', true, $GroupWhere);
if ($TorrentSpecifics > 0) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
- $TorrentWhere.= ' AND ';
+ $TorrentWhere .= ' AND ';
}
- $TorrentWhere.= "t.FreeTorrent='".ceil($_GET['freeleech'])."'";
+ $TorrentWhere .= "t.FreeTorrent = '".ceil($_GET['freeleech'])."'";
}
}
if ($_GET['remastered'] != '') {
- $GroupWhere = build_search('%'.$_GET['remastered'].'%','RemasterList',true,$GroupWhere);
+ $GroupWhere = build_search('%'.$_GET['remastered'].'%', 'RemasterList', true, $GroupWhere);
if ($TorrentSpecifics > 0) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
- $TorrentWhere.= ' AND ';
+ $TorrentWhere .= ' AND ';
}
- $TorrentWhere.= "t.Remastered='".ceil($_GET['remastered'])."'";
+ $TorrentWhere .= "t.Remastered = '".ceil($_GET['remastered'])."'";
}
}
@@ -437,12 +449,12 @@ if ((strtolower($_GET['action']) == 'advanced' || ($LoggedUser['SearchType'] &&
// Basic search
if ($_GET['searchstr'] != '') {
// Change special characters into 'normal' characters
- $SearchStr = strtr($_GET['searchstr'],$SpecialChars);
+ $SearchStr = strtr($_GET['searchstr'], $SpecialChars);
if (!$DisableGrouping) {
- $GroupWhere = build_search($SearchStr,'SearchText',false,$GroupWhere,1);
+ $GroupWhere = build_search($SearchStr, 'SearchText', false, $GroupWhere, 1);
} else {
- $TorrentWhere = build_search($SearchStr,'g.SearchText',false,$TorrentWhere);
+ $TorrentWhere = build_search($SearchStr, 'g.SearchText', false, $TorrentWhere);
}
}
}
@@ -455,26 +467,26 @@ if (isset($_GET['searchtags']) && $_GET['searchtags'] != '') {
$TagField = 'h.TagList';
}
- $Tags = explode(',',$_GET['searchtags']);
+ $Tags = explode(',', $_GET['searchtags']);
foreach ($Tags as $Key => $Tag) :
if (trim($Tag) != '') {
if ($TagSearch != '') {
if ($_GET['tags_type']) {
- $TagSearch.= ' AND ';
+ $TagSearch .= ' AND ';
} else {
- $TagSearch.= ' OR ';
+ $TagSearch .= ' OR ';
}
}
- $Tag = trim(str_replace('.','_',$Tag));
+ $Tag = trim(str_replace('.', '_', $Tag));
if (!$DisableGrouping) {
// Fulltext
- $TagSearch.= " MATCH ($TagField) AGAINST ('".db_string($Tag)."'";
- if (substr($Tag,0,1) == '-') {
- $TagSearch.=' IN BOOLEAN MODE';
+ $TagSearch .= " MATCH ($TagField) AGAINST ('".db_string($Tag)."'";
+ if (substr($Tag, 0, 1) == '-') {
+ $TagSearch .=' IN BOOLEAN MODE';
}
- $TagSearch.= ')';
+ $TagSearch .= ')';
} else {
- $TagSearch.=$TagField." LIKE '%".db_string($Tag)."%'";
+ $TagSearch .= "$TagField LIKE '%".db_string($Tag)."%'";
}
}
endforeach;
@@ -508,25 +520,25 @@ if ($_GET['filter_cat'] != '') {
foreach ($_GET['filter_cat'] as $CatKey => $CatVal) {
if ($CatFilter != '') {
- $CatFilter.= ' OR ';
+ $CatFilter .= ' OR ';
}
- $CatFilter.=$CategoryField."='".db_string(ceil($CatKey))."'";
+ $CatFilter .= "$CategoryField = '".db_string(ceil($CatKey))."'";
}
if ($DisableGrouping) {
if ($TorrentWhere == '') {
$TorrentWhere = 'WHERE ';
} else {
- $TorrentWhere.= ' AND ';
+ $TorrentWhere .= ' AND ';
}
- $TorrentWhere.= "($CatFilter)";
+ $TorrentWhere .= "($CatFilter)";
} else {
if ($GroupWhere == '') {
$GroupWhere = 'WHERE ';
} else {
- $GroupWhere.= ' AND ';
+ $GroupWhere .= ' AND ';
}
- $GroupWhere.="($CatFilter)";
+ $GroupWhere .= "($CatFilter)";
}
}
@@ -542,50 +554,66 @@ if (!is_array($TorrentCache)) {
if ($GroupWhere == '') {
$GroupWhere = 'WHERE ';
} else {
- $GroupWhere.= ' AND ';
+ $GroupWhere .= ' AND ';
}
- $GroupWhere.= "(SELECT t.GroupID FROM torrents AS t $TorrentWhere AND t.GroupID=h.GroupID LIMIT 1)";
+ $GroupWhere .= "
+ (
+ SELECT t.GroupID
+ FROM torrents AS t
+ $TorrentWhere
+ AND t.GroupID = h.GroupID
+ LIMIT 1
+ )";
}
- $DB->query("SELECT $SCFR
- h.GroupID,
- h.GroupName,
- h.GroupYear AS s2,
- h.GroupCategoryID,
- h.GroupTime AS s3,
- h.MaxTorrentSize AS s4,
- h.TotalSnatches AS s5,
- h.TotalSeeders AS s6,
- h.TotalLeechers AS s7,
- h.TorrentIDList,
- h.TagList,
- h.MediaList,
- h.FormatList,
- h.EncodingList,
- h.YearList,
- h.RemasterList,
- h.RemasterTitleList,
- h.SceneList,
- h.LogList,
- h.CueList,
- h.LogScoreList,
- h.FileCountList,
- h.FreeTorrentList,
- h.SizeList,
- h.LeechersList,
- h.SeedersList,
- h.SnatchedList,
- h.TimeList,
- h.SearchText AS s1
- FROM torrent_hash AS h
- $TorrentJoin
- $GroupWhere
- ORDER BY $OrderBy $OrderWay
- LIMIT $Limit");
+ $DB->query("
+ SELECT $SCFR
+ h.GroupID,
+ h.GroupName,
+ h.GroupYear AS s2,
+ h.GroupCategoryID,
+ h.GroupTime AS s3,
+ h.MaxTorrentSize AS s4,
+ h.TotalSnatches AS s5,
+ h.TotalSeeders AS s6,
+ h.TotalLeechers AS s7,
+ h.TorrentIDList,
+ h.TagList,
+ h.MediaList,
+ h.FormatList,
+ h.EncodingList,
+ h.YearList,
+ h.RemasterList,
+ h.RemasterTitleList,
+ h.SceneList,
+ h.LogList,
+ h.CueList,
+ h.LogScoreList,
+ h.FileCountList,
+ h.FreeTorrentList,
+ h.SizeList,
+ h.LeechersList,
+ h.SeedersList,
+ h.SnatchedList,
+ h.TimeList,
+ h.SearchText AS s1
+ FROM torrent_hash AS h
+ $TorrentJoin
+ $GroupWhere
+ ORDER BY $OrderBy $OrderWay
+ LIMIT $Limit");
$TorrentList=$DB->to_array();
if (EXPLAIN_HACK) {
- $DB->query("EXPLAIN SELECT NULL FROM (SELECT NULL FROM torrent_hash AS h $TorrentJoin $GroupWhere) AS Count");
- list($Null,$Null,$Null,$Null,$Null,$Null,$Null,$Null,$TorrentCount)=$DB->next_record();
+ $DB->query("
+ EXPLAIN
+ SELECT NULL
+ FROM (
+ SELECT NULL
+ FROM torrent_hash AS h
+ $TorrentJoin
+ $GroupWhere
+ ) AS Count");
+ list($Null, $Null, $Null, $Null, $Null, $Null, $Null, $Null, $TorrentCount) = $DB->next_record();
} else {
$DB->query('SELECT FOUND_ROWS()');
list($TorrentCount) = $DB->next_record();
@@ -595,42 +623,51 @@ if (!is_array($TorrentCache)) {
if (!$TimeField) {
$TimeField = 't.Time';
}
- $DB->query("SELECT $SCFR
- g.ID,
- g.Name,
- g.Year AS s2,
- g.CategoryID,
- $TimeField AS s3,
- t.Size AS s4,
- t.Snatched AS s5,
- t.Seeders AS s6,
- t.Leechers AS s7,
- t.ID,
- g.TagList,
- t.Media,
- t.Format,
- t.Encoding,
- t.RemasterYear,
- t.Remastered,
- t.RemasterTitle,
- t.Scene,
- t.HasLog,
- t.HasCue,
- t.LogScore,
- t.FileCount,
- t.FreeTorrent,
- g.SearchText AS s1
- FROM torrents AS t
- INNER JOIN torrents_group AS g ON g.ID=t.GroupID
- $TorrentJoin
- $TorrentWhere
- ORDER BY $OrderBy $OrderWay
- LIMIT $Limit");
+ $DB->query("
+ SELECT $SCFR
+ g.ID,
+ g.Name,
+ g.Year AS s2,
+ g.CategoryID,
+ $TimeField AS s3,
+ t.Size AS s4,
+ t.Snatched AS s5,
+ t.Seeders AS s6,
+ t.Leechers AS s7,
+ t.ID,
+ g.TagList,
+ t.Media,
+ t.Format,
+ t.Encoding,
+ t.RemasterYear,
+ t.Remastered,
+ t.RemasterTitle,
+ t.Scene,
+ t.HasLog,
+ t.HasCue,
+ t.LogScore,
+ t.FileCount,
+ t.FreeTorrent,
+ g.SearchText AS s1
+ FROM torrents AS t
+ INNER JOIN torrents_group AS g ON g.ID = t.GroupID
+ $TorrentJoin
+ $TorrentWhere
+ ORDER BY $OrderBy $OrderWay
+ LIMIT $Limit");
$TorrentList = $DB->to_array();
if (EXPLAIN_HACK) {
- $DB->query("EXPLAIN SELECT NULL FROM (SELECT NULL FROM torrent_hash AS h $TorrentJoin $GroupWhere) AS Count");
- list($Null,$Null,$Null,$Null,$Null,$Null,$Null,$Null,$TorrentCount)=$DB->next_record();
+ $DB->query("
+ EXPLAIN
+ SELECT NULL
+ FROM (
+ SELECT NULL
+ FROM torrent_hash AS h
+ $TorrentJoin
+ $GroupWhere
+ ) AS Count");
+ list($Null, $Null, $Null, $Null, $Null, $Null, $Null, $Null, $TorrentCount) = $DB->next_record();
} else {
$DB->query('SELECT FOUND_ROWS()');
list($TorrentCount) = $DB->next_record();
@@ -639,7 +676,10 @@ if (!is_array($TorrentCache)) {
if ($UserID) {
// Get the username, so we can display the title as "<user>'s snatched torrents", etc
- $DB->query("SELECT Username FROM users_main WHERE ID='".db_string($UserID)."'");
+ $DB->query("
+ SELECT Username
+ FROM users_main
+ WHERE ID = '".db_string($UserID)."'");
list($TitleUser) = $DB->next_record();
}
} else {
@@ -663,7 +703,7 @@ if ($Title) {
$Title = 'Browse Torrents';
}
-View::show_header($Title,'browse');
+View::show_header($Title, 'browse');
?>
<form name="filter" method="get" action="">
<? if ($UserID) { ?>
@@ -798,7 +838,7 @@ View::show_header($Title,'browse');
</tr>
<tr>
<td class="label">Order by:</td>
- <td colspan="<?=($AdvancedSearch) ? '3' : '1' ?>">
+ <td colspan="<?=$AdvancedSearch ? '3' : '1'; ?>">
<select name="order_by" style="width: auto;">
<option value="s1"<? if ($OrderBy == 's1') { ?> selected="selected"<? } ?>>Name</option>
<option value="s2"<? if ($OrderBy == 's2') { ?> selected="selected"<? } ?>>Year</option>
@@ -849,7 +889,11 @@ endforeach;
<?
$GenreTags = $Cache->get_value('genre_tags');
if (!$GenreTags) {
- $DB->query('SELECT Name FROM tags WHERE TagType=\'genre\' ORDER BY Name');
+ $DB->query('
+ SELECT Name
+ FROM tags
+ WHERE TagType = \'genre\'
+ ORDER BY Name');
$GenreTags = $DB->collect('Name');
$Cache->cache_value('genre_tags', $GenreTags, 3600 * 6);
}
@@ -869,7 +913,7 @@ foreach ($GenreTags as $Tag) :
endforeach;
if ($x % 7 != 0) { // Padding
?>
- <td colspan="<?=7 - ($x % 7) ?>"> </td>
+ <td colspan="<?= 7 - ($x % 7); ?>"> </td>
<?
} ?>
</tr>
@@ -930,25 +974,28 @@ if ($x % 7 != 0) { // Padding
}
$Artists = Artists::get_artists($GroupIDs);
foreach ($TorrentList as $Key => $Properties) {
- list($GroupID,$GroupName,$GroupYear,$GroupCategoryID,$GroupTime,$MaxSize,$TotalSnatched,$TotalSeeders,$TotalLeechers,$TorrentsID,$TagsList,$TorrentsMedia,$TorrentsFormat,$TorrentsEncoding,$TorrentsYear,$TorrentsRemastered,$TorrentsRemasterTitle,$TorrentsScene,$TorrentsLog,$TorrentsCue,$TorrentsLogScores,$TorrentsFileCount,$TorrentsFreeTorrent,$TorrentsSize,$TorrentsLeechers,$TorrentsSeeders,$TorrentsSnatched,$TorrentsTime) = $Properties;
- $Torrents['id'] = explode('|',$TorrentsID);
- $Torrents['media'] = explode('|',$TorrentsMedia);
- $Torrents['format'] = explode('|',$TorrentsFormat);
- $Torrents['encoding'] = explode('|',$TorrentsEncoding);
- $Torrents['year'] = explode('|',$TorrentsYear);
- $Torrents['remastered'] = explode('|',$TorrentsRemastered);
- $Torrents['remastertitle'] = explode('|',$TorrentsRemasterTitle);
- $Torrents['scene'] = explode('|',$TorrentsScene);
- $Torrents['log'] = explode('|',$TorrentsLog);
- $Torrents['cue'] = explode('|',$TorrentsCue);
- $Torrents['score'] = explode('|',$TorrentsLogScores);
- $Torrents['filecount'] = explode('|',$TorrentsFileCount);
- $Torrents['size'] = explode('|',$TorrentsSize);
- $Torrents['leechers'] = explode('|',$TorrentsLeechers);
- $Torrents['seeders'] = explode('|',$TorrentsSeeders);
- $Torrents['snatched'] = explode('|',$TorrentsSnatched);
- $Torrents['freetorrent'] = explode('|',$TorrentsFreeTorrent);
- $Torrents['time'] = explode('|',$TorrentsTime);
+ list($GroupID, $GroupName, $GroupYear, $GroupCategoryID, $GroupTime, $MaxSize, $TotalSnatched, $TotalSeeders, $TotalLeechers,
+ $TorrentsID, $TagsList, $TorrentsMedia, $TorrentsFormat, $TorrentsEncoding, $TorrentsYear, $TorrentsRemastered,
+ $TorrentsRemasterTitle, $TorrentsScene, $TorrentsLog, $TorrentsCue, $TorrentsLogScores, $TorrentsFileCount, $TorrentsFreeTorrent,
+ $TorrentsSize, $TorrentsLeechers, $TorrentsSeeders, $TorrentsSnatched, $TorrentsTime) = $Properties;
+ $Torrents['id'] = explode('|', $TorrentsID);
+ $Torrents['media'] = explode('|', $TorrentsMedia);
+ $Torrents['format'] = explode('|', $TorrentsFormat);
+ $Torrents['encoding'] = explode('|', $TorrentsEncoding);
+ $Torrents['year'] = explode('|', $TorrentsYear);
+ $Torrents['remastered'] = explode('|', $TorrentsRemastered);
+ $Torrents['remastertitle'] = explode('|', $TorrentsRemasterTitle);
+ $Torrents['scene'] = explode('|', $TorrentsScene);
+ $Torrents['log'] = explode('|', $TorrentsLog);
+ $Torrents['cue'] = explode('|', $TorrentsCue);
+ $Torrents['score'] = explode('|', $TorrentsLogScores);
+ $Torrents['filecount'] = explode('|', $TorrentsFileCount);
+ $Torrents['size'] = explode('|', $TorrentsSize);
+ $Torrents['leechers'] = explode('|', $TorrentsLeechers);
+ $Torrents['seeders'] = explode('|', $TorrentsSeeders);
+ $Torrents['snatched'] = explode('|', $TorrentsSnatched);
+ $Torrents['freetorrent'] = explode('|', $TorrentsFreeTorrent);
+ $Torrents['time'] = explode('|', $TorrentsTime);
if (!$DisableGrouping) {
// Since these fields are surrounded by |s, we get extra elements added to the arrays
@@ -985,9 +1032,9 @@ if ($x % 7 != 0) { // Padding
$DisplayName = Artists::display_artists($Artists[$GroupID]);
if ((count($Torrents['id']) > 1 || $GroupCategoryID == 1) && !$DisableGrouping) {
// These torrents are in a group
- $DisplayName.='<a href="torrents.php?id='.$GroupID.'" title="View Torrent">'.$GroupName.'</a>';
+ $DisplayName .= "<a href=\"torrents.php?id=$GroupID\" title=\"View Torrent\">$GroupName</a>";
if ($GroupYear > 0) {
- $DisplayName.=" [$GroupYear]";
+ $DisplayName .= " [$GroupYear]";
}
?>
<tr class="group">
@@ -1062,7 +1109,7 @@ if ($LoggedUser['CoverArt']) : ?>
$Continue = false;
$RemasterParts = explode(' ', $_GET['remastertitle']);
foreach ($RemasterParts as $RemasterPart) {
- if (stripos($Torrents['remastertitle'][$Key],$RemasterPart) === false) {
+ if (stripos($Torrents['remastertitle'][$Key], $RemasterPart) === false) {
$Continue = true;
}
}
@@ -1075,45 +1122,45 @@ if ($LoggedUser['CoverArt']) : ?>
$AddExtra = '';
if ($Torrents['format'][$Key]) {
- $ExtraInfo.=$Torrents['format'][$Key];
+ $ExtraInfo .= $Torrents['format'][$Key];
$AddExtra = ' / ';
}
if ($Torrents['encoding'][$Key]) {
- $ExtraInfo.=$AddExtra.$Torrents['encoding'][$Key];
+ $ExtraInfo .= $AddExtra.$Torrents['encoding'][$Key];
$AddExtra = ' / ';
}
if ($Torrents['log'][$Key] == '1') {
- $ExtraInfo.=$AddExtra.'Log';
+ $ExtraInfo .= $AddExtra.'Log';
$AddExtra = ' / ';
if ($Torrents['score'][$Key]) {
- $ExtraInfo.=' ('.$Torrents['score'][$Key].'%) ';
+ $ExtraInfo .= ' ('.$Torrents['score'][$Key].'%) ';
}
}
if ($Torrents['cue'][$Key] == '1') {
- $ExtraInfo.=$AddExtra.'Cue';
+ $ExtraInfo .= "{$AddExtra}Cue";
$AddExtra = ' / ';
}
if ($Torrents['media'][$Key]) {
- $ExtraInfo.=$AddExtra.$Torrents['media'][$Key];
+ $ExtraInfo .= $AddExtra.$Torrents['media'][$Key];
$AddExtra = ' / ';
}
if ($Torrents['scene'][$Key] == '1') {
- $ExtraInfo.=$AddExtra.'Scene';
+ $ExtraInfo .= "{$AddExtra}Scene";
$AddExtra = ' / ';
}
if (trim($Torrents['remastertitle'][$Key])) {
- $ExtraInfo.=$AddExtra.$Torrents['remastertitle'][$Key];
+ $ExtraInfo .= $AddExtra.$Torrents['remastertitle'][$Key];
$AddExtra = ' - ';
} elseif ($Torrents['remastered'][$Key] == '1') {
- $ExtraInfo.=$AddExtra.'Remastered';
+ $ExtraInfo .= "{$AddExtra}Remastered";
$AddExtra = ' - ';
}
if ($Torrents['year'][$Key] > '0') {
- $ExtraInfo.=$AddExtra.$Torrents['year'][$Key];
+ $ExtraInfo .= $AddExtra.$Torrents['year'][$Key];
$AddExtra = ' / ';
}
if ($Torrents['freetorrent'][$Key] == '1') {
- $ExtraInfo.=$AddExtra. Format::torrent_label('Freeleech!');
+ $ExtraInfo .= $AddExtra. Format::torrent_label('Freeleech!');
$AddExtra = ' / ';
}
?>
@@ -1137,61 +1184,61 @@ if ($LoggedUser['CoverArt']) : ?>
} else {
// Either grouping is disabled, or we're viewing a type that does not require grouping
if ($GroupCategoryID == 1) {
- $DisplayName.='<a href="torrents.php?id='.$GroupID.'&amp;torrentid='.$Torrents['id'][0].'" title="View Torrent">'.$GroupName.'</a>';
+ $DisplayName .= '<a href="torrents.php?id='.$GroupID.'&amp;torrentid='.$Torrents['id'][0].'" title="View Torrent">'.$GroupName.'</a>';
} else {
- $DisplayName.='<a href="torrents.php?id='.$GroupID.'" title="View Torrent">'.$GroupName.'</a>';
+ $DisplayName .= '<a href="torrents.php?id='.$GroupID.'" title="View Torrent">'.$GroupName.'</a>';
}
$ExtraInfo = '';
$AddExtra = '';
if ($Torrents['format'][0]) {
- $ExtraInfo.=$Torrents['format'][0];
- $AddExtra=' / ';
+ $ExtraInfo .= $Torrents['format'][0];
+ $AddExtra = ' / ';
}
if ($Torrents['encoding'][0]) {
- $ExtraInfo.=$AddExtra.$Torrents['encoding'][0];
- $AddExtra=' / ';
+ $ExtraInfo .= $AddExtra.$Torrents['encoding'][0];
+ $AddExtra = ' / ';
}
if ($Torrents['log'][0] == '1') {
- $ExtraInfo.=$AddExtra.'Log';
+ $ExtraInfo .= "{$AddExtra}Log";
$AddExtra = ' / ';
}
if ($Torrents['score'][0]) {
- $ExtraInfo.=' ('.$Torrents['score'][0].'%) ';
+ $ExtraInfo .= ' ('.$Torrents['score'][0].'%) ';
}
if ($Torrents['cue'][0] == '1') {
- $ExtraInfo.=$AddExtra.'Cue';
+ $ExtraInfo .= "{$AddExtra}Cue";
$AddExtra = ' / ';
}
if ($Torrents['media'][0]) {
- $ExtraInfo.=$AddExtra.$Torrents['media'][0];
+ $ExtraInfo .= $AddExtra.$Torrents['media'][0];
$AddExtra = ' / ';
}
if ($Torrents['scene'][0] == '1') {
- $ExtraInfo.=$AddExtra.'Scene';
+ $ExtraInfo .= "{$AddExtra}Scene";
$AddExtra = ' / ';
}
if (trim($Torrents['remastertitle'][0])) {
- $ExtraInfo.=$AddExtra.$Torrents['remastertitle'][0];
+ $ExtraInfo .= $AddExtra.$Torrents['remastertitle'][0];
$AddExtra = ' - ';
} elseif ($Torrents['remastered'][0] == '1') {
- $ExtraInfo.=$AddExtra.'Remastered';
+ $ExtraInfo .= "{$AddExtra}Remastered";
$AddExtra = ' - ';
}
if ($Torrents['year'][0] > '0') {
- $ExtraInfo.=$AddExtra.$Torrents['year'][0];
+ $ExtraInfo .= $AddExtra.$Torrents['year'][0];
$AddExtra = ' / ';
}
if ($Torrents['freetorrent'][0] == '1') {
- $ExtraInfo.=$AddExtra. Format::torrent_label('Freeleech!');
+ $ExtraInfo .= $AddExtra. Format::torrent_label('Freeleech!');
$AddExtra = ' / ';
}
if ($ExtraInfo != '') {
$ExtraInfo = "[$ExtraInfo]";
}
if ($GroupYear > 0) {
- $ExtraInfo.=" [$GroupYear]";
+ $ExtraInfo .= " [$GroupYear]";
}
if (!isset($TimeField) || $TimeField == 't.Time') {
@@ -1229,23 +1276,24 @@ if ($LoggedUser['CoverArt']) : ?>
?>
</table>
<? } else {
-$DB->query("SELECT
- tags.Name,
- ((COUNT(tags.Name)-2)*(SUM(tt.PositiveVotes)-SUM(tt.NegativeVotes)))/(tags.Uses*0.8) AS Score
- FROM xbt_snatched AS s
- INNER JOIN torrents AS t ON t.ID=s.fid
- INNER JOIN torrents_group AS g ON t.GroupID=g.ID
- INNER JOIN torrents_tags AS tt ON tt.GroupID=g.ID
- INNER JOIN tags ON tags.ID=tt.TagID
- WHERE s.uid='$LoggedUser[ID]'
- AND tt.TagID != '13679'
- AND tt.TagID != '4820'
- AND tt.TagID != '2838'
- AND g.CategoryID='1'
- AND tags.Uses > '10'
- GROUP BY tt.TagID
- ORDER BY Score DESC
- LIMIT 8");
+$DB->query("
+ SELECT
+ tags.Name,
+ ((COUNT(tags.Name) - 2) * (SUM(tt.PositiveVotes) - SUM(tt.NegativeVotes))) / (tags.Uses * 0.8) AS Score
+ FROM xbt_snatched AS s
+ INNER JOIN torrents AS t ON t.ID = s.fid
+ INNER JOIN torrents_group AS g ON t.GroupID = g.ID
+ INNER JOIN torrents_tags AS tt ON tt.GroupID = g.ID
+ INNER JOIN tags ON tags.ID = tt.TagID
+ WHERE s.uid = '$LoggedUser[ID]'
+ AND tt.TagID != '13679'
+ AND tt.TagID != '4820'
+ AND tt.TagID != '2838'
+ AND g.CategoryID = '1'
+ AND tags.Uses > '10'
+ GROUP BY tt.TagID
+ ORDER BY Score DESC
+ LIMIT 8");
?>
<div class="box pad" align="center">
<h2>Your search did not match anything.</h2>
diff --git a/sections/torrents/browse2.php b/sections/torrents/browse2.php
index b5eb785..02275de 100644
--- a/sections/torrents/browse2.php
+++ b/sections/torrents/browse2.php
@@ -25,13 +25,18 @@ include(SERVER_ROOT.'/sections/torrents/functions.php');
// The "order by x" links on columns headers
-function header_link($SortKey,$DefaultWay="desc") {
- global $OrderBy,$OrderWay;
- if ($SortKey==$OrderBy) {
- if ($OrderWay=="desc") { $NewWay="asc"; }
- else { $NewWay="desc"; }
- } else { $NewWay=$DefaultWay; }
- return "torrents.php?order_way=".$NewWay."&amp;order_by=".$SortKey."&amp;".Format::get_url(array('order_way','order_by'));
+function header_link($SortKey, $DefaultWay = 'desc') {
+ global $OrderBy, $OrderWay;
+ if ($SortKey == $OrderBy) {
+ if ($OrderWay == 'desc') {
+ $NewWay = 'asc';
+ } else {
+ $NewWay = 'desc';
+ }
+ } else {
+ $NewWay = $DefaultWay;
+ }
+ return "torrents.php?order_way=$NewWay&amp;order_by=$SortKey&amp;".Format::get_url(array('order_way', 'order_by'));
}
/** Start default parameters and validation **/
@@ -44,11 +49,14 @@ if (!empty($_GET['searchstr']) || !empty($_GET['groupname'])) {
// Search by infohash
if ($InfoHash = is_valid_torrenthash($InfoHash)) {
- $InfoHash = db_string(pack("H*", $InfoHash));
- $DB->query("SELECT ID,GroupID FROM torrents WHERE info_hash='$InfoHash'");
+ $InfoHash = db_string(pack('H*', $InfoHash));
+ $DB->query("
+ SELECT ID, GroupID
+ FROM torrents
+ WHERE info_hash = '$InfoHash'");
if ($DB->record_count() > 0) {
list($ID, $GroupID) = $DB->next_record();
- header('Location: torrents.php?id='.$GroupID.'&torrentid='.$ID);
+ header("Location: torrents.php?id=$GroupID&torrentid=$ID");
die();
}
}
@@ -62,7 +70,7 @@ if (!empty($_GET['setdefault'])) {
$DB->query("
SELECT SiteOptions
FROM users_info
- WHERE UserID='".db_string($LoggedUser['ID'])."'");
+ WHERE UserID = '".db_string($LoggedUser['ID'])."'");
list($SiteOptions) = $DB->next_record(MYSQLI_NUM, false);
if (!empty($SiteOptions)) {
$SiteOptions = unserialize($SiteOptions);
@@ -72,10 +80,10 @@ if (!empty($_GET['setdefault'])) {
$SiteOptions['DefaultSearch'] = preg_replace($UnsetRegexp, '', $_SERVER['QUERY_STRING']);
$DB->query("
UPDATE users_info
- SET SiteOptions='".db_string(serialize($SiteOptions))."'
- WHERE UserID='".db_string($LoggedUser['ID'])."'");
- $Cache->begin_transaction('user_info_heavy_'.$UserID);
- $Cache->update_row(false, array('DefaultSearch'=>$SiteOptions['DefaultSearch']));
+ SET SiteOptions = '".db_string(serialize($SiteOptions))."'
+ WHERE UserID = '".db_string($LoggedUser['ID'])."'");
+ $Cache->begin_transaction("user_info_heavy_$UserID");
+ $Cache->update_row(false, array('DefaultSearch' => $SiteOptions['DefaultSearch']));
$Cache->commit_transaction(0);
// Clearing default search options
@@ -83,16 +91,16 @@ if (!empty($_GET['setdefault'])) {
$DB->query("
SELECT SiteOptions
FROM users_info
- WHERE UserID='".db_string($LoggedUser['ID'])."'");
+ WHERE UserID = '".db_string($LoggedUser['ID'])."'");
list($SiteOptions) = $DB->next_record(MYSQLI_NUM, false);
$SiteOptions = unserialize($SiteOptions);
$SiteOptions['DefaultSearch'] = '';
$DB->query("
UPDATE users_info
- SET SiteOptions='".db_string(serialize($SiteOptions))."'
- WHERE UserID='".db_string($LoggedUser['ID'])."'");
- $Cache->begin_transaction('user_info_heavy_'.$UserID);
- $Cache->update_row(false, array('DefaultSearch'=>''));
+ SET SiteOptions = '".db_string(serialize($SiteOptions))."'
+ WHERE UserID = '".db_string($LoggedUser['ID'])."'");
+ $Cache->begin_transaction("user_info_heavy_$UserID");
+ $Cache->update_row(false, array('DefaultSearch' => ''));
$Cache->commit_transaction(0);
// Use default search options
@@ -100,10 +108,10 @@ if (!empty($_GET['setdefault'])) {
if (!empty($LoggedUser['DefaultSearch'])) {
if (!empty($_GET['page'])) {
$Page = $_GET['page'];
- parse_str($LoggedUser['DefaultSearch'],$_GET);
+ parse_str($LoggedUser['DefaultSearch'], $_GET);
$_GET['page'] = $Page;
} else {
- parse_str($LoggedUser['DefaultSearch'],$_GET);
+ parse_str($LoggedUser['DefaultSearch'], $_GET);
}
}
}
@@ -124,6 +132,7 @@ if (isset($_GET['group_results']) && $_GET['group_results']) {
'leechers' => array('sumleechers', 'leechers'),
'snatched' => array('sumsnatched', 'snatched'),
'random' => false);
+
$AggregateExp = array(
'maxsize' => 'MAX(size) AS maxsize',
'sumseeders' => 'SUM(seeders) AS sumseeders',
@@ -195,7 +204,7 @@ $SphQLTor->select('id, groupid')->from('torrents, delta');
$Filtered = false;
$EnableNegation = false; // Sphinx needs at least one positive search condition to support the NOT operator
-// Filelist searches makes use of the proximity operator to ensure that all keywords match the same file
+// File list searches make use of the proximity operator to ensure that all keywords match the same file
if (!empty($_GET['filelist'])) {
$SearchString = trim($_GET['filelist']);
if ($SearchString != '') {
@@ -208,7 +217,7 @@ if (!empty($_GET['filelist'])) {
}
// Collect all entered search terms to find out whether to enable the NOT operator
-$GroupFields = array('artistname','groupname', 'recordlabel', 'cataloguenumber', 'taglist');
+$GroupFields = array('artistname', 'groupname', 'recordlabel', 'cataloguenumber', 'taglist');
$TorrentFields = array('remastertitle', 'remasteryear', 'remasterrecordlabel', 'remastercataloguenumber', 'encoding', 'format', 'media');
$SearchWords = array();
foreach (array('artistname', 'groupname', 'recordlabel', 'cataloguenumber',
@@ -231,7 +240,7 @@ foreach (array('artistname', 'groupname', 'recordlabel', 'cataloguenumber',
continue;
}
if ($Word[0] == '!' && strlen($Word) >= 2) {
- if (strpos($Word,'!',1) === false) {
+ if (strpos($Word, '!', 1) === false) {
$SearchWords[$Search]['exclude'][] = $Word;
} else {
$SearchWords[$Search]['include'][] = $Word;
@@ -321,10 +330,10 @@ if (!empty($SearchWords['taglist'])) {
//Get tag aliases.
$TagAliases = $Cache->get_value('tag_aliases_search');
if (!$TagAliases) {
- $DB->query("
+ $DB->query('
SELECT ID, BadTag, AliasTag
FROM tag_aliases
- ORDER BY BadTag");
+ ORDER BY BadTag');
$TagAliases = $DB->to_array();
//Unify tag aliases to be in_this_format as tags not in.this.format
array_walk_recursive($TagAliases, create_function('&$val', '$val = preg_replace("/\./","_", $val);'));
@@ -361,7 +370,7 @@ if (!empty($SearchWords['taglist'])) {
//Only keep unique entries after unifying tag standard
$Tags['include'] = array_unique($Tags['include']);
$Tags['exclude'] = array_unique($Tags['exclude']);
- $TagListString = implode(", ", array_merge($Tags['include'], $Tags['exclude']));
+ $TagListString = implode(', ', array_merge($Tags['include'], $Tags['exclude']));
if (!$EnableNegation && !empty($Tags['exclude'])) {
$Tags['include'] = array_merge($Tags['include'], $Tags['exclude']);
unset($Tags['exclude']);
@@ -520,7 +529,7 @@ if (!$Filtered) {
if (isset($Random) && $GroupResults) {
// ORDER BY RAND() can't be used together with GROUP BY, so we need some special tactics
$Page = 1;
- $SphQL->limit(0, 5*TORRENTS_PER_PAGE, 5*TORRENTS_PER_PAGE);
+ $SphQL->limit(0, 5 * TORRENTS_PER_PAGE, 5 * TORRENTS_PER_PAGE);
$SphQLResult = $SphQL->query();
$TotalCount = $SphQLResult->get_meta('total_found');
$Results = $SphQLResult->to_array('groupid');
@@ -548,7 +557,7 @@ if (isset($Random) && $GroupResults) {
if (check_perms('site_search_many')) {
$Page = $_GET['page'];
} else {
- $Page = min(SPHINX_MAX_MATCHES/TORRENTS_PER_PAGE, $_GET['page']);
+ $Page = min(SPHINX_MAX_MATCHES / TORRENTS_PER_PAGE, $_GET['page']);
}
$Offset = ($Page - 1) * TORRENTS_PER_PAGE;
$SphQL->limit($Offset, TORRENTS_PER_PAGE, $Offset + TORRENTS_PER_PAGE);
@@ -608,7 +617,7 @@ if ($AdvancedSearch) {
}
-View::show_header('Browse Torrents','browse');
+View::show_header('Browse Torrents', 'browse');
?>
<div class="thin widethin">
@@ -660,11 +669,11 @@ View::show_header('Browse Torrents','browse');
</td>
</tr>
<tr id="edition_expand" class="ftr_advanced<?=$HideAdvanced?>">
- <td colspan="4" class="center ft_edition_expand"><a href="#" class="brackets" onclick="ToggleEditionRows();return false;">Click here to toggle searching for specific remaster information</a></td>
+ <td colspan="4" class="center ft_edition_expand"><a href="#" class="brackets" onclick="ToggleEditionRows(); return false;">Click here to toggle searching for specific remaster information</a></td>
</tr>
<?
-if (Format::form('remastertitle', true) == "" && Format::form('remasteryear', true) == "" &&
- Format::form('remasterrecordlabel', true) == "" && Format::form('remastercataloguenumber', true) == "") {
+if (Format::form('remastertitle', true) == '' && Format::form('remasteryear', true) == '' &&
+ Format::form('remasterrecordlabel', true) == '' && Format::form('remastercataloguenumber', true) == '') {
$Hidden = ' hidden';
} else {
$Hidden = '';
@@ -715,13 +724,13 @@ if (Format::form('remastertitle', true) == "" && Format::form('remasteryear', tr
<select name="media" class="ft_media fti_advanced">
<option value="">Media</option>
<? foreach ($Media as $MediaName) { ?>
- <option value="<?=display_str($MediaName); ?>"<?Format::selected('media',$MediaName)?>><?=display_str($MediaName); ?></option>
+ <option value="<?=display_str($MediaName); ?>"<?Format::selected('media', $MediaName)?>><?=display_str($MediaName); ?></option>
<? } ?>
</select>
<select name="releasetype" class="ft_releasetype fti_advanced">
<option value="">Release type</option>
<? foreach ($ReleaseTypes as $ID=>$Type) { ?>
- <option value="<?=display_str($ID); ?>"<?Format::selected('releasetype',$ID)?>><?=display_str($Type); ?></option>
+ <option value="<?=display_str($ID); ?>"<?Format::selected('releasetype', $ID)?>><?=display_str($Type); ?></option>
<? } ?>
</select>
</td>
@@ -731,32 +740,32 @@ if (Format::form('remastertitle', true) == "" && Format::form('remasteryear', tr
<td class="nobr ft_misc" colspan="3">
<select name="haslog" class="ft_haslog fti_advanced">
<option value="">Has Log</option>
- <option value="1"<?Format::selected('haslog','1')?>>Yes</option>
- <option value="0"<?Format::selected('haslog','0')?>>No</option>
- <option value="100"<?Format::selected('haslog','100')?>>100% only</option>
- <option value="-1"<?Format::selected('haslog','-1')?>>&lt;100%/Unscored</option>
+ <option value="1"<?Format::selected('haslog', '1')?>>Yes</option>
+ <option value="0"<?Format::selected('haslog', '0')?>>No</option>
+ <option value="100"<?Format::selected('haslog', '100')?>>100% only</option>
+ <option value="-1"<?Format::selected('haslog', '-1')?>>&lt;100%/Unscored</option>
</select>
<select name="hascue" class="ft_hascue fti_advanced">
<option value="">Has Cue</option>
- <option value="1"<?Format::selected('hascue',1)?>>Yes</option>
- <option value="0"<?Format::selected('hascue',0)?>>No</option>
+ <option value="1"<?Format::selected('hascue', 1)?>>Yes</option>
+ <option value="0"<?Format::selected('hascue', 0)?>>No</option>
</select>
<select name="scene" class="ft_scene fti_advanced">
<option value="">Scene</option>
- <option value="1"<?Format::selected('scene',1)?>>Yes</option>
- <option value="0"<?Format::selected('scene',0)?>>No</option>
+ <option value="1"<?Format::selected('scene', 1)?>>Yes</option>
+ <option value="0"<?Format::selected('scene', 0)?>>No</option>
</select>
<select name="vanityhouse" class="ft_vanityhouse fti_advanced">
<option value="">Vanity House</option>
- <option value="1"<?Format::selected('vanityhouse',1)?>>Yes</option>
- <option value="0"<?Format::selected('vanityhouse',0)?>>No</option>
+ <option value="1"<?Format::selected('vanityhouse', 1)?>>Yes</option>
+ <option value="0"<?Format::selected('vanityhouse', 0)?>>No</option>
</select>
<select name="freetorrent" class="ft_freetorrent fti_advanced">
<option value="">Leech Status</option>
- <option value="1"<?Format::selected('freetorrent',1)?>>Freeleech</option>
- <option value="2"<?Format::selected('freetorrent',2)?>>Neutral Leech</option>
- <option value="3"<?Format::selected('freetorrent',3)?>>Either</option>
- <option value="0"<?Format::selected('freetorrent',0)?>>Normal</option>
+ <option value="1"<?Format::selected('freetorrent', 1)?>>Freeleech</option>
+ <option value="2"<?Format::selected('freetorrent', 2)?>>Neutral Leech</option>
+ <option value="3"<?Format::selected('freetorrent', 3)?>>Either</option>
+ <option value="0"<?Format::selected('freetorrent', 0)?>>Normal</option>
</select>
</td>
</tr>
@@ -769,26 +778,26 @@ if (Format::form('remastertitle', true) == "" && Format::form('remasteryear', tr
<tr id="tagfilter">
<td class="label">Tags (comma-separated):</td>
<td colspan="3" class="ft_taglist">
- <input type="text" size="40" id="tags" name="taglist" class="inputtext smaller" title="Use !tag to exclude tag" value="<?=str_replace('_','.',display_str($TagListString)) /* Use aliased tags, not actual query string. */ ?>" />&nbsp;
- <input type="radio" name="tags_type" id="tags_type0" value="0"<?Format::selected('tags_type',0,'checked')?> /><label for="tags_type0"> Any</label>&nbsp;&nbsp;
- <input type="radio" name="tags_type" id="tags_type1" value="1"<?Format::selected('tags_type',1,'checked')?> /><label for="tags_type1"> All</label>
+ <input type="text" size="40" id="tags" name="taglist" class="inputtext smaller" title="Use !tag to exclude tag" value="<?=str_replace('_', '.', display_str($TagListString)) /* Use aliased tags, not actual query string. */ ?>" />&nbsp;
+ <input type="radio" name="tags_type" id="tags_type0" value="0"<?Format::selected('tags_type', 0, 'checked')?> /><label for="tags_type0"> Any</label>&nbsp;&nbsp;
+ <input type="radio" name="tags_type" id="tags_type1" value="1"<?Format::selected('tags_type', 1, 'checked')?> /><label for="tags_type1"> All</label>
</td>
</tr>
<tr id="order">
<td class="label">Order by:</td>
<td colspan="3" class="ft_order">
<select name="order_by" style="width: auto;" class="ft_order_by">
- <option value="time"<?Format::selected('order_by','time')?>>Time added</option>
- <option value="year"<?Format::selected('order_by','year')?>>Year</option>
- <option value="size"<?Format::selected('order_by','size')?>>Size</option>
- <option value="snatched"<?Format::selected('order_by','snatched')?>>Snatched</option>
- <option value="seeders"<?Format::selected('order_by','seeders')?>>Seeders</option>
- <option value="leechers"<?Format::selected('order_by','leechers')?>>Leechers</option>
- <option value="random"<?Format::selected('order_by','random')?>>Random</option>
+ <option value="time"<?Format::selected('order_by', 'time')?>>Time added</option>
+ <option value="year"<?Format::selected('order_by', 'year')?>>Year</option>
+ <option value="size"<?Format::selected('order_by', 'size')?>>Size</option>
+ <option value="snatched"<?Format::selected('order_by', 'snatched')?>>Snatched</option>
+ <option value="seeders"<?Format::selected('order_by', 'seeders')?>>Seeders</option>
+ <option value="leechers"<?Format::selected('order_by', 'leechers')?>>Leechers</option>
+ <option value="random"<?Format::selected('order_by', 'random')?>>Random</option>
</select>
<select name="order_way" class="ft_order_way">
- <option value="desc"<?Format::selected('order_way','desc')?>>Descending</option>
- <option value="asc"<?Format::selected('order_way','asc')?>>Ascending</option>
+ <option value="desc"<?Format::selected('order_way', 'desc')?>>Descending</option>
+ <option value="asc"<?Format::selected('order_way', 'asc')?>>Ascending</option>
</select>
</td>
</tr>
@@ -830,7 +839,11 @@ foreach ($Categories as $CatKey => $CatName) {
<?
$GenreTags = $Cache->get_value('genre_tags');
if (!$GenreTags) {
- $DB->query('SELECT Name FROM tags WHERE TagType=\'genre\' ORDER BY Name');
+ $DB->query('
+ SELECT Name
+ FROM tags
+ WHERE TagType = \'genre\'
+ ORDER BY Name');
$GenreTags = $DB->collect('Name');
$Cache->cache_value('genre_tags', $GenreTags, 3600 * 6);
}
@@ -857,7 +870,7 @@ if ($x % 7 != 0) { // Padding
<table class="layout cat_list" width="100%">
<tr>
<td class="label">
- <a class="brackets" href="#" onclick="$('#taglist').gtoggle(); if (this.innerHTML=='View tags') {this.innerHTML='Hide tags';} else {this.innerHTML='View tags';}; return false;"><?=((empty($LoggedUser['ShowTags'])) ? 'View tags' : 'Hide tags')?></a>
+ <a class="brackets" href="#" onclick="$('#taglist').gtoggle(); if (this.innerHTML == 'View tags') { this.innerHTML = 'Hide tags'; } else { this.innerHTML = 'View tags'; }; return false;"><?=((empty($LoggedUser['ShowTags'])) ? 'View tags' : 'Hide tags')?></a>
</td>
</tr>
</table>
@@ -866,7 +879,7 @@ if ($x % 7 != 0) { // Padding
<input type="submit" value="Filter torrents" />
<input type="hidden" name="action" id="ft_type" value="<?=($AdvancedSearch ? 'advanced' : 'basic')?>" />
<input type="hidden" name="searchsubmit" value="1" />
- <input type="button" value="Reset" onclick="location.href='torrents.php<? if (isset($_GET['action']) && $_GET['action'] == 'advanced') { ?>?action=advanced<? } ?>'" />
+ <input type="button" value="Reset" onclick="location.href = 'torrents.php<? if (isset($_GET['action']) && $_GET['action'] == 'advanced') { ?>?action=advanced<? } ?>'" />
&nbsp;&nbsp;
<? if ($Filtered) { ?>
<input type="submit" name="setdefault" value="Make default" />
@@ -883,23 +896,24 @@ if ($x % 7 != 0) { // Padding
</form>
<?
if ($TorrentCount == 0) {
- $DB->query("SELECT
- tags.Name,
- ((COUNT(tags.Name)-2)*(SUM(tt.PositiveVotes)-SUM(tt.NegativeVotes)))/(tags.Uses*0.8) AS Score
- FROM xbt_snatched AS s
- INNER JOIN torrents AS t ON t.ID=s.fid
- INNER JOIN torrents_group AS g ON t.GroupID=g.ID
- INNER JOIN torrents_tags AS tt ON tt.GroupID=g.ID
- INNER JOIN tags ON tags.ID=tt.TagID
- WHERE s.uid='$LoggedUser[ID]'
- AND tt.TagID != '13679'
- AND tt.TagID != '4820'
- AND tt.TagID != '2838'
- AND g.CategoryID='1'
- AND tags.Uses > '10'
- GROUP BY tt.TagID
- ORDER BY Score DESC
- LIMIT 8");
+ $DB->query("
+ SELECT
+ tags.Name,
+ ((COUNT(tags.Name) - 2) * (SUM(tt.PositiveVotes) - SUM(tt.NegativeVotes))) / (tags.Uses * 0.8) AS Score
+ FROM xbt_snatched AS s
+ INNER JOIN torrents AS t ON t.ID = s.fid
+ INNER JOIN torrents_group AS g ON t.GroupID = g.ID
+ INNER JOIN torrents_tags AS tt ON tt.GroupID = g.ID
+ INNER JOIN tags ON tags.ID = tt.TagID
+ WHERE s.uid = '$LoggedUser[ID]'
+ AND tt.TagID != '13679'
+ AND tt.TagID != '4820'
+ AND tt.TagID != '2838'
+ AND g.CategoryID = '1'
+ AND tags.Uses > '10'
+ GROUP BY tt.TagID
+ ORDER BY Score DESC
+ LIMIT 8");
?>
<div class="box pad" align="center">
<h2>Your search did not match anything.</h2>
@@ -992,7 +1006,7 @@ foreach ($Results as $Result) {
if ($GroupResults && (count($Torrents) > 1 || isset($GroupedCategories[$CategoryID - 1]))) {
// These torrents are in a group
- $DisplayName .= '<a href="torrents.php?id='.$GroupID.'" title="View Torrent" dir="ltr">'.$GroupName.'</a>';
+ $DisplayName .= "<a href=\"torrents.php?id=$GroupID\" title=\"View Torrent\" dir=\"ltr\">$GroupName</a>";
if ($GroupYear > 0) {
$DisplayName .= " [$GroupYear]";
}
@@ -1112,7 +1126,7 @@ $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGr
// Viewing a type that does not require grouping
list($TorrentID, $Data) = each($Torrents);
- $DisplayName .= '<a href="torrents.php?id='.$GroupID.'&amp;torrentid='.$TorrentID.'#torrent'.$TorrentID.'" title="View Torrent" dir="ltr">'.$GroupName.'</a>';
+ $DisplayName .= "<a href=\"torrents.php?id=$GroupID&amp;torrentid=$TorrentID#torrent$TorrentID\" title=\"View Torrent\" dir=\"ltr\">$GroupName</a>";
if (isset($GroupedCategories[$CategoryID - 1])) {
if ($GroupYear) {
$DisplayName .= " [$GroupYear]";
diff --git a/sections/torrents/delete_alias.php b/sections/torrents/delete_alias.php
index 63d600b..27d51d4 100644
--- a/sections/torrents/delete_alias.php
+++ b/sections/torrents/delete_alias.php
@@ -10,47 +10,60 @@ if (!check_perms('torrents_edit')) {
error(403);
}
-$DB->query("DELETE FROM torrents_artists WHERE GroupID='$GroupID' AND ArtistID='$ArtistID' AND Importance='$Importance'");
-$DB->query("SELECT Name FROM artists_group WHERE ArtistID=".$ArtistID);
+$DB->query("
+ DELETE FROM torrents_artists
+ WHERE GroupID = '$GroupID'
+ AND ArtistID = '$ArtistID'
+ AND Importance = '$Importance'");
+$DB->query("
+ SELECT Name
+ FROM artists_group
+ WHERE ArtistID = $ArtistID");
list($ArtistName) = $DB->next_record(MYSQLI_NUM, false);
-$DB->query("SELECT Name FROM torrents_group WHERE ID=".$GroupID);
+$DB->query("
+ SELECT Name
+ FROM torrents_group
+ WHERE ID = $GroupID");
list($GroupName) = $DB->next_record(MYSQLI_NUM, false);
-//Get a count of how many groups or requests use this artist ID
-$DB->query("SELECT ag.ArtistID
- FROM artists_group as ag
- LEFT JOIN requests_artists AS ra ON ag.ArtistID=ra.ArtistID
- WHERE ra.ArtistID IS NOT NULL
- AND ag.ArtistID = ".$ArtistID);
+// Get a count of how many groups or requests use this artist ID
+$DB->query("
+ SELECT ag.ArtistID
+ FROM artists_group as ag
+ LEFT JOIN requests_artists AS ra ON ag.ArtistID = ra.ArtistID
+ WHERE ra.ArtistID IS NOT NULL
+ AND ag.ArtistID = $ArtistID");
$ReqCount = $DB->record_count();
-$DB->query("SELECT ag.ArtistID
- FROM artists_group as ag
- LEFT JOIN torrents_artists AS ta ON ag.ArtistID=ta.ArtistID
- WHERE ta.ArtistID IS NOT NULL
- AND ag.ArtistID = ".$ArtistID);
+$DB->query("
+ SELECT ag.ArtistID
+ FROM artists_group as ag
+ LEFT JOIN torrents_artists AS ta ON ag.ArtistID = ta.ArtistID
+ WHERE ta.ArtistID IS NOT NULL
+ AND ag.ArtistID = $ArtistID");
$GroupCount = $DB->record_count();
if (($ReqCount + $GroupCount) == 0) {
- //The only group to use this artist
+ // The only group to use this artist
Artists::delete_artist($ArtistID);
}
-$DB->query("INSERT INTO torrents_group (ID, NumArtists)
+$DB->query("
+ INSERT INTO torrents_group (ID, NumArtists)
SELECT ta.GroupID, COUNT(ta.ArtistID)
FROM torrents_artists AS ta
- WHERE ta.GroupID='$GroupID'
- AND ta.Importance='1'
+ WHERE ta.GroupID = '$GroupID'
+ AND ta.Importance = '1'
GROUP BY ta.GroupID
ON DUPLICATE KEY UPDATE
- NumArtists=VALUES(NumArtists);");
+ NumArtists = VALUES (NumArtists);");
-$Cache->delete_value('torrents_details_'.$GroupID); // Delete torrent group cache
-$Cache->delete_value('groups_artists_'.$GroupID); // Delete group artist cache
-Misc::write_log("Artist (".$ArtistTypes[$Importance].") ".$ArtistID." (".$ArtistName.") was removed from the group ".$GroupID." (".$GroupName.") by user ".$LoggedUser['ID']." (".$LoggedUser['Username'].")");
-Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "removed artist ".$ArtistName." (".$ArtistTypes[$Importance].")", 0);
+$Cache->delete_value("torrents_details_$GroupID"); // Delete torrent group cache
+$Cache->delete_value("groups_artists_$GroupID"); // Delete group artist cache
+Misc::write_log('Artist ('.$ArtistTypes[$Importance].") $ArtistID ($ArtistName) was removed from the group $GroupID ($GroupName) by user ".$LoggedUser['ID'].' ('.$LoggedUser['Username'].')');
+Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "removed artist $ArtistName (".$ArtistTypes[$Importance].')', 0);
Torrents::update_hash($GroupID);
-$Cache->delete_value('artist_groups_'.$ArtistID);
+$Cache->delete_value("artist_groups_$ArtistID");
header('Location: '.$_SERVER['HTTP_REFERER']);
?>
diff --git a/sections/torrents/details.php b/sections/torrents/details.php
index 393121c..2e09416 100644
--- a/sections/torrents/details.php
+++ b/sections/torrents/details.php
@@ -409,7 +409,7 @@ if ($Categories[$GroupCategoryID - 1] == 'Music') {
<input type="hidden" name="action" value="add_alias" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="groupid" value="<?=$GroupID?>" />
- <input type="text" id="artist" name="aliasname[]" size="17" <? Users::has_autocomplete_enabled('other'); ?>/>
+ <input type="text" id="artist" name="aliasname[]" size="17"<? Users::has_autocomplete_enabled('other'); ?> />
<select name="importance[]">
<option value="1">Main</option>
<option value="2">Guest</option>
@@ -490,7 +490,7 @@ if (empty($LoggedUser['DisableTagging'])) {
<input type="hidden" name="action" value="add_tag" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="groupid" value="<?=$GroupID?>" />
- <input type="text" name="tagname" id="tagname" size="20" <? Users::has_autocomplete_enabled('other'); ?> />
+ <input type="text" name="tagname" id="tagname" size="20"<? Users::has_autocomplete_enabled('other'); ?> />
<input type="submit" value="+" />
</form>
<br /><br />
@@ -546,7 +546,8 @@ foreach ($TorrentList as $Torrent) {
unset($ReportedTimes);
$Reports = $Cache->get_value('reports_torrent_'.$TorrentID);
if ($Reports === false) {
- $DB->query("SELECT r.ID,
+ $DB->query("
+ SELECT r.ID,
r.ReporterID,
r.Type,
r.UserComment,
@@ -556,12 +557,12 @@ foreach ($TorrentList as $Torrent) {
AND Type != 'edited'
AND Status != 'Resolved'");
$Reports = $DB->to_array();
- $Cache->cache_value('reports_torrent_'.$TorrentID, $Reports, 0);
+ $Cache->cache_value("reports_torrent_$TorrentID", $Reports, 0);
}
if (count($Reports) > 0) {
$Reported = true;
include(SERVER_ROOT.'/sections/reportsv2/array.php');
- $ReportInfo = '<table class="reportinfo_table"><tr class="colhead_dark" style="font-weight: bold;"><td>This torrent has '.count($Reports).' active '.(count($Reports) > 1 ? "reports" : "report").':</td></tr>';
+ $ReportInfo = "\n<table class=\"reportinfo_table\">\n\t<tr class=\"colhead_dark\" style=\"font-weight: bold;\">\n\t\t<td>This torrent has ".count($Reports).' active '.(count($Reports) > 1 ? 'reports' : 'report').":</td>\n\t</tr>";
foreach ($Reports as $Report) {
list($ReportID, $ReporterID, $ReportType, $ReportReason, $ReportedTime) = $Report;
@@ -577,10 +578,10 @@ foreach ($TorrentList as $Torrent) {
//There was a type but it wasn't an option!
$ReportType = $Types['master']['other'];
}
- $ReportInfo .= "<tr><td>".(check_perms('admin_reports') ? "<a href=\"user.php?id=$ReporterID\">$ReporterName</a> <a href=\"reportsv2.php?view=report&amp;id=$ReportID\">reported it</a> " : 'Someone reported it ') . time_diff($ReportedTime, 2, true, true) . ' for the reason "' . $ReportType['title'] . '":';
- $ReportInfo .= "<blockquote>".$Text->full_format($ReportReason)."</blockquote></td></tr>";
+ $ReportInfo .= "\n\t<tr>\n\t\t<td>".(check_perms('admin_reports') ? "<a href=\"user.php?id=$ReporterID\">$ReporterName</a> <a href=\"reportsv2.php?view=report&amp;id=$ReportID\">reported it</a> " : 'Someone reported it ') . time_diff($ReportedTime, 2, true, true) . ' for the reason "' . $ReportType['title'] . '":';
+ $ReportInfo .= "\n<blockquote>".$Text->full_format($ReportReason)."</blockquote>\n\t\t</td>\n\t</tr>";
}
- $ReportInfo .= "</table>";
+ $ReportInfo .= "\n</table>";
}
$CanEdit = (check_perms('torrents_edit') || (($UserID == $LoggedUser['ID'] && !$LoggedUser['DisableWiki']) && !($Remastered && !$RemasterYear)));
@@ -589,7 +590,7 @@ foreach ($TorrentList as $Torrent) {
$FileTable = '
<table class="filelist_table">
<tr class="colhead_dark"><td>
- <div class="filelist_title" style="float: left;">File Name' . $RegenLink . '</div>
+ <div class="filelist_title" style="float: left;">File name' . $RegenLink . '</div>
<div class="filelist_path" style="float: right;">' . ($FilePath ? "/$FilePath/" : '') . '</div>
</td><td>
<strong>Size</strong>
@@ -733,7 +734,7 @@ foreach ($TorrentList as $Torrent) {
<div id="reported_<?=$TorrentID?>" class="hidden"><?=$ReportInfo?></div>
<? }
if (!empty($Description)) {
- echo '<blockquote>'.$Text->full_format($Description).'</blockquote>';}
+ echo "\n<blockquote>".$Text->full_format($Description).'</blockquote>';}
?>
</td>
</tr>
diff --git a/sections/torrents/download.php b/sections/torrents/download.php
index 7036f3c..bf39b98 100644
--- a/sections/torrents/download.php
+++ b/sections/torrents/download.php
@@ -8,18 +8,17 @@ if (!isset($_REQUEST['authkey']) || !isset($_REQUEST['torrent_pass'])) {
} else {
$UserInfo = $Cache->get_value('user_'.$_REQUEST['torrent_pass']);
if (!is_array($UserInfo)) {
- $DB->query("SELECT
- ID,
- DownloadAlt
+ $DB->query("
+ SELECT ID, DownloadAlt
FROM users_main AS m
- INNER JOIN users_info AS i ON i.UserID=m.ID
- WHERE m.torrent_pass='".db_string($_REQUEST['torrent_pass'])."'
- AND m.Enabled='1'");
+ INNER JOIN users_info AS i ON i.UserID = m.ID
+ WHERE m.torrent_pass = '".db_string($_REQUEST['torrent_pass'])."'
+ AND m.Enabled = '1'");
$UserInfo = $DB->next_record();
$Cache->cache_value('user_'.$_REQUEST['torrent_pass'], $UserInfo, 3600);
}
$UserInfo = array($UserInfo);
- list($UserID,$DownloadAlt)=array_shift($UserInfo);
+ list($UserID, $DownloadAlt) = array_shift($UserInfo);
if (!$UserID) {
error(0);
}
@@ -35,47 +34,53 @@ if (!is_number($TorrentID)) {
error(0);
}
-/* uTorrent remote redownloads .torrent files every fifteen minutes
- to prevent this retardation from blowing bandwidth etc., let's block it
- if he's downloaded the .torrent file twice before */
+/* uTorrent Remote redownloads .torrent files every fifteen minutes.
+ To prevent this retardation from blowing bandwidth etc., let's block it
+ if he has downloaded the .torrent file twice before */
if (strpos($_SERVER['HTTP_USER_AGENT'], 'BTWebClient') !== false) {
- $DB->query("SELECT 1 FROM users_downloads WHERE UserID=$UserID AND TorrentID=$TorrentID LIMIT 3");
+ $DB->query("
+ SELECT 1
+ FROM users_downloads
+ WHERE UserID = $UserID
+ AND TorrentID = $TorrentID
+ LIMIT 3");
if ($DB->record_count() > 2) {
- error('You have already downloaded this .torrent three times. If you need to download it again, please do so from your browser, not through uTorrent remote.');
+ error('You have already downloaded this torrent file three times. If you need to download it again, please do so from your browser, not through μTorrent Remote.');
die();
}
}
$Info = $Cache->get_value('torrent_download_'.$TorrentID);
if (!is_array($Info) || !array_key_exists('PlainArtists', $Info) || empty($Info[10])) {
- $DB->query("SELECT
- t.Media,
- t.Format,
- t.Encoding,
- IF(t.RemasterYear=0,tg.Year,t.RemasterYear),
- tg.ID AS GroupID,
- tg.Name,
- tg.WikiImage,
- tg.CategoryID,
- t.Size,
- t.FreeTorrent,
- t.info_hash
+ $DB->query("
+ SELECT
+ t.Media,
+ t.Format,
+ t.Encoding,
+ IF(t.RemasterYear = 0, tg.Year, t.RemasterYear),
+ tg.ID AS GroupID,
+ tg.Name,
+ tg.WikiImage,
+ tg.CategoryID,
+ t.Size,
+ t.FreeTorrent,
+ t.info_hash
FROM torrents AS t
- INNER JOIN torrents_group AS tg ON tg.ID=t.GroupID
- WHERE t.ID='".db_string($TorrentID)."'");
+ INNER JOIN torrents_group AS tg ON tg.ID = t.GroupID
+ WHERE t.ID = '".db_string($TorrentID)."'");
if ($DB->record_count() < 1) {
error(404);
}
- $Info = array($DB->next_record(MYSQLI_NUM, array(4,5,6,10)));
- $Artists = Artists::get_artist($Info[0][4],false);
+ $Info = array($DB->next_record(MYSQLI_NUM, array(4, 5, 6, 10)));
+ $Artists = Artists::get_artist($Info[0][4], false);
$Info['Artists'] = Artists::display_artists($Artists, false, true);
$Info['PlainArtists'] = Artists::display_artists($Artists, false, true, false);
- $Cache->cache_value('torrent_download_'.$TorrentID, $Info, 0);
+ $Cache->cache_value("torrent_download_$TorrentID", $Info, 0);
}
if (!is_array($Info[0])) {
error(404);
}
-list($Media,$Format,$Encoding,$Year,$GroupID,$Name,$Image, $CategoryID, $Size, $FreeTorrent, $InfoHash) = array_shift($Info); // used for generating the filename
+list($Media, $Format, $Encoding, $Year, $GroupID, $Name, $Image, $CategoryID, $Size, $FreeTorrent, $InfoHash) = array_shift($Info); // used for generating the filename
$Artists = $Info['Artists'];
// If he's trying use a token on this, we need to make sure he has one,
@@ -99,40 +104,52 @@ if ($_REQUEST['usetoken'] && $FreeTorrent == '0') {
if (!Torrents::has_token($TorrentID)) {
if ($FLTokens <= 0) {
- error("You do not have any freeleech tokens left. Please use the regular DL link.");
+ error('You do not have any freeleech tokens left. Please use the regular DL link.');
}
if ($Size >= 1073741824) {
- error("This torrent is too large. Please use the regular DL link.");
+ error('This torrent is too large. Please use the regular DL link.');
}
// Let the tracker know about this
if (!Tracker::update_tracker('add_token', array('info_hash' => rawurlencode($InfoHash), 'userid' => $UserID))) {
- error("Sorry! An error occurred while trying to register your token. Most often, this is due to the tracker being down or under heavy load. Please try again later.");
+ error('Sorry! An error occurred while trying to register your token. Most often, this is due to the tracker being down or under heavy load. Please try again later.');
}
if (!Torrents::has_token($TorrentID)) {
- $DB->query("INSERT INTO users_freeleeches (UserID, TorrentID, Time) VALUES ($UserID, $TorrentID, NOW())
- ON DUPLICATE KEY UPDATE Time=VALUES(Time), Expired=FALSE, Uses=Uses+1");
- $DB->query("UPDATE users_main SET FLTokens = FLTokens - 1 WHERE ID=$UserID");
+ $DB->query("
+ INSERT INTO users_freeleeches (UserID, TorrentID, Time)
+ VALUES ($UserID, $TorrentID, NOW())
+ ON DUPLICATE KEY UPDATE
+ Time = VALUES(Time),
+ Expired = FALSE,
+ Uses = Uses + 1");
+ $DB->query("
+ UPDATE users_main
+ SET FLTokens = FLTokens - 1
+ WHERE ID = $UserID");
// Fix for downloadthemall messing with the cached token count
$UInfo = Users::user_heavy_info($UserID);
$FLTokens = $UInfo['FLTokens'];
- $Cache->begin_transaction('user_info_heavy_'.$UserID);
- $Cache->update_row(false, array('FLTokens'=>($FLTokens - 1)));
+ $Cache->begin_transaction("user_info_heavy_$UserID");
+ $Cache->update_row(false, array('FLTokens' => ($FLTokens - 1)));
$Cache->commit_transaction(0);
- $Cache->delete_value('users_tokens_'.$UserID);
+ $Cache->delete_value("users_tokens_$UserID");
}
}
}
//Stupid Recent Snatches On User Page
if ($CategoryID == '1' && $Image != '') {
- $RecentSnatches = $Cache->get_value('recent_snatches_'.$UserID);
+ $RecentSnatches = $Cache->get_value("recent_snatches_$UserID");
if (!empty($RecentSnatches)) {
- $Snatch = array('ID'=>$GroupID,'Name'=>$Name,'Artist'=>$Artists,'WikiImage'=>$Image);
+ $Snatch = array(
+ 'ID' => $GroupID,
+ 'Name' => $Name,
+ 'Artist' => $Artists,
+ 'WikiImage' => $Image);
if (!in_array($Snatch, $RecentSnatches)) {
if (count($RecentSnatches) == 5) {
array_pop($RecentSnatches);
@@ -141,7 +158,7 @@ if ($CategoryID == '1' && $Image != '') {
} elseif (!is_array($RecentSnatches)) {
$RecentSnatches = array($Snatch);
}
- $Cache->cache_value('recent_snatches_'.$UserID, $RecentSnatches, 0);
+ $Cache->cache_value("recent_snatches_$UserID", $RecentSnatches, 0);
}
}
@@ -149,7 +166,10 @@ $DB->query("
INSERT IGNORE INTO users_downloads (UserID, TorrentID, Time)
VALUES ('$UserID', '$TorrentID', '".sqltime()."')");
-$DB->query("SELECT File FROM torrents_files WHERE TorrentID='$TorrentID'");
+$DB->query("
+ SELECT File
+ FROM torrents_files
+ WHERE TorrentID = '$TorrentID'");
list($Contents) = $DB->next_record(MYSQLI_NUM, false);
$FileName = TorrentsDL::construct_file_name($Info['PlainArtists'], $Name, $Year, $Media, $Format, $Encoding, false, $DownloadAlt);
diff --git a/sections/torrents/editgroupid.php b/sections/torrents/editgroupid.php
index 07ff4da..be2c26b 100644
--- a/sections/torrents/editgroupid.php
+++ b/sections/torrents/editgroupid.php
@@ -23,17 +23,23 @@ if ($OldGroupID == $GroupID) {
//Everything is legit, let's just confim they're not retarded
if (empty($_POST['confirm'])) {
- $DB->query("SELECT Name FROM torrents_group WHERE ID = ".$OldGroupID);
+ $DB->query("
+ SELECT Name
+ FROM torrents_group
+ WHERE ID = $OldGroupID");
if ($DB->record_count() < 1) {
//Trying to move to an empty group? I think not!
- set_message("That group doesn't exist!");
+ set_message('That group does not exist!');
header('Location: '.$_SERVER['HTTP_REFERER']);
die();
}
list($Name) = $DB->next_record();
- $DB->query("SELECT CategoryID, Name FROM torrents_group WHERE ID = ".$GroupID);
+ $DB->query("
+ SELECT CategoryID, Name
+ FROM torrents_group
+ WHERE ID = $GroupID");
list($CategoryID, $NewName) = $DB->next_record();
- if ($Categories[$CategoryID-1] != 'Music') {
+ if ($Categories[$CategoryID - 1] != 'Music') {
error('Target must be a music group.');
}
@@ -54,9 +60,13 @@ if (empty($_POST['confirm'])) {
<input type="hidden" name="oldgroupid" value="<?=$OldGroupID?>" />
<input type="hidden" name="groupid" value="<?=$GroupID?>" />
<h3>You are attempting to move the torrent with ID <?=$TorrentID?> from the group:</h3>
- <ul><li><?= Artists::display_artists($Artists[$OldGroupID], true, false)?> - <a href="torrents.php?id=<?=$OldGroupID?>"><?=$Name?></a></li></ul>
+ <ul>
+ <li><?= Artists::display_artists($Artists[$OldGroupID], true, false)?> - <a href="torrents.php?id=<?=$OldGroupID?>"><?=$Name?></a></li>
+ </ul>
<h3>Into the group:</h3>
- <ul><li><?= Artists::display_artists($Artists[$GroupID], true, false)?> - <a href="torrents.php?id=<?=$GroupID?>"><?=$NewName?></a></li></ul>
+ <ul>
+ <li><?= Artists::display_artists($Artists[$GroupID], true, false)?> - <a href="torrents.php?id=<?=$GroupID?>"><?=$NewName?></a></li>
+ </ul>
<input type="submit" value="Confirm" />
</form>
</div>
@@ -67,16 +77,22 @@ if (empty($_POST['confirm'])) {
authorize();
$DB->query("UPDATE torrents
- SET GroupID='$GroupID'
- WHERE ID=$TorrentID");
+ SET GroupID = '$GroupID'
+ WHERE ID = $TorrentID");
// Delete old torrent group if it's empty now
- $DB->query("SELECT COUNT(ID) FROM torrents WHERE GroupID='$OldGroupID'");
+ $DB->query("
+ SELECT COUNT(ID)
+ FROM torrents
+ WHERE GroupID = '$OldGroupID'");
list($TorrentsInGroup) = $DB->next_record();
if ($TorrentsInGroup == 0) {
- $DB->query("UPDATE torrents_comments SET GroupID='$GroupID' WHERE GroupID='$OldGroupID'");
- $Cache->delete_value('torrent_comments_'.$GroupID.'_catalogue_0');
- $Cache->delete_value('torrent_comments_'.$GroupID);
+ $DB->query("
+ UPDATE torrents_comments
+ SET GroupID = '$GroupID'
+ WHERE GroupID = '$OldGroupID'");
+ $Cache->delete_value("torrent_comments_{$GroupID}_catalogue_0");
+ $Cache->delete_value("torrent_comments_$GroupID");
Torrents::delete_group($OldGroupID);
} else {
Torrents::update_hash($OldGroupID);
@@ -84,11 +100,14 @@ if (empty($_POST['confirm'])) {
Torrents::update_hash($GroupID);
Misc::write_log("Torrent $TorrentID was edited by " . $LoggedUser['Username']); // TODO: this is probably broken
- Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "merged group ".$OldGroupID, 0);
- $DB->query("UPDATE group_log SET GroupID = ".$GroupID." WHERE GroupID = ".$OldGroupID);
+ Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "merged group $OldGroupID", 0);
+ $DB->query("
+ UPDATE group_log
+ SET GroupID = $GroupID
+ WHERE GroupID = $OldGroupID");
- $Cache->delete_value('torrents_details_'.$GroupID);
- $Cache->delete_value('torrent_download_'.$TorrentID);
+ $Cache->delete_value("torrents_details_$GroupID");
+ $Cache->delete_value("torrent_download_$TorrentID");
header("Location: torrents.php?id=$GroupID");
}
diff --git a/sections/torrents/functions.php b/sections/torrents/functions.php
index 53431b9..69e33fc 100644
--- a/sections/torrents/functions.php
+++ b/sections/torrents/functions.php
@@ -17,16 +17,16 @@ function get_group_info($GroupID, $Return = true, $RevisionID = 0, $PersonalProp
if ($RevisionID || !is_array($TorrentCache) || isset($OutdatedCache)) {
// Fetch the group details
- $SQL = "SELECT ";
+ $SQL = 'SELECT ';
if (!$RevisionID) {
- $SQL .= "
+ $SQL .= '
g.WikiBody,
- g.WikiImage, ";
+ g.WikiImage, ';
} else {
- $SQL .= "
+ $SQL .= '
w.Body,
- w.Image, ";
+ w.Image, ';
}
$SQL .= "
@@ -45,16 +45,17 @@ function get_group_info($GroupID, $Return = true, $RevisionID = 0, $PersonalProp
GROUP_CONCAT(tt.PositiveVotes SEPARATOR '|'),
GROUP_CONCAT(tt.NegativeVotes SEPARATOR '|')
FROM torrents_group AS g
- LEFT JOIN torrents_tags AS tt ON tt.GroupID=g.ID
- LEFT JOIN tags ON tags.ID=tt.TagID";
+ LEFT JOIN torrents_tags AS tt ON tt.GroupID = g.ID
+ LEFT JOIN tags ON tags.ID = tt.TagID";
if ($RevisionID) {
$SQL .= "
- LEFT JOIN wiki_torrents AS w ON w.PageID='".db_string($GroupID)."' AND w.RevisionID='".db_string($RevisionID)."' ";
+ LEFT JOIN wiki_torrents AS w ON w.PageID = '".db_string($GroupID)."'
+ AND w.RevisionID = '".db_string($RevisionID)."' ";
}
$SQL .= "
- WHERE g.ID='".db_string($GroupID)."'
+ WHERE g.ID = '".db_string($GroupID)."'
GROUP BY NULL";
$DB->query($SQL);
@@ -100,14 +101,14 @@ function get_group_info($GroupID, $Return = true, $RevisionID = 0, $PersonalProp
tln.TorrentID AS LogInDB,
t.ID AS HasFile
FROM torrents AS t
- LEFT JOIN torrents_bad_tags AS tbt ON tbt.TorrentID=t.ID
- LEFT JOIN torrents_bad_folders AS tbf on tbf.TorrentID=t.ID
- LEFT JOIN torrents_bad_files AS tfi on tfi.TorrentID=t.ID
- LEFT JOIN torrents_cassette_approved AS ca on ca.TorrentID=t.ID
- LEFT JOIN torrents_lossymaster_approved AS lma on lma.TorrentID=t.ID
- LEFT JOIN torrents_lossyweb_approved AS lwa on lwa.TorrentID=t.ID
- LEFT JOIN torrents_logs_new AS tln ON tln.TorrentID=t.ID
- WHERE t.GroupID='".db_string($GroupID)."'
+ LEFT JOIN torrents_bad_tags AS tbt ON tbt.TorrentID = t.ID
+ LEFT JOIN torrents_bad_folders AS tbf on tbf.TorrentID = t.ID
+ LEFT JOIN torrents_bad_files AS tfi on tfi.TorrentID = t.ID
+ LEFT JOIN torrents_cassette_approved AS ca on ca.TorrentID = t.ID
+ LEFT JOIN torrents_lossymaster_approved AS lma on lma.TorrentID = t.ID
+ LEFT JOIN torrents_lossyweb_approved AS lwa on lwa.TorrentID = t.ID
+ LEFT JOIN torrents_logs_new AS tln ON tln.TorrentID = t.ID
+ WHERE t.GroupID = '".db_string($GroupID)."'
GROUP BY t.ID
ORDER BY t.Remastered ASC,
(t.RemasterYear != 0) DESC,
@@ -122,7 +123,7 @@ function get_group_info($GroupID, $Return = true, $RevisionID = 0, $PersonalProp
$TorrentList = $DB->to_array('ID', MYSQLI_ASSOC);
if (count($TorrentList) == 0 && $ApiCall == false) {
- header("Location: log.php?search=".(empty($_GET['torrentid']) ? "Group+$GroupID" : "Torrent+$_GET[torrentid]"));
+ header('Location: log.php?search='.(empty($_GET['torrentid']) ? "Group+$GroupID" : "Torrent+$_GET[torrentid]"));
die();
} else if (count($TorrentList) == 0 && $ApiCall == true) {
return NULL;
@@ -134,7 +135,7 @@ function get_group_info($GroupID, $Return = true, $RevisionID = 0, $PersonalProp
}
// Store it all in cache
if (!$RevisionID) {
- $Cache->cache_value('torrents_details_'.$GroupID, array($TorrentDetails, $TorrentList), $CacheTime);
+ $Cache->cache_value("torrents_details_$GroupID", array($TorrentDetails, $TorrentList), $CacheTime);
}
} else { // If we're reading from cache
$TorrentDetails = $TorrentCache[0];
@@ -188,7 +189,10 @@ function is_valid_torrenthash($Str) {
function torrenthash_to_torrentid($Str) {
global $Cache, $DB;
- $DB->query("SELECT t.ID FROM torrents AS t WHERE HEX(t.info_hash)='".db_string($Str)."'");
+ $DB->query("
+ SELECT t.ID
+ FROM torrents AS t
+ WHERE HEX(t.info_hash) = '".db_string($Str)."'");
$TorrentID = (int)array_pop($DB->next_record(MYSQLI_ASSOC));
if ($TorrentID) {
return $TorrentID;
@@ -198,7 +202,10 @@ function torrenthash_to_torrentid($Str) {
function torrenthash_to_groupid($Str) {
global $Cache, $DB;
- $DB->query("SELECT t.GroupID FROM torrents AS t WHERE HEX(t.info_hash)='".db_string($Str)."'");
+ $DB->query("
+ SELECT t.GroupID
+ FROM torrents AS t
+ WHERE HEX(t.info_hash) = '".db_string($Str)."'");
$GroupID = (int)array_pop($DB->next_record(MYSQLI_ASSOC));
if ($GroupID) {
return $GroupID;
@@ -208,7 +215,10 @@ function torrenthash_to_groupid($Str) {
function torrentid_to_groupid($TorrentID) {
global $Cache, $DB;
- $DB->query("SELECT t.GroupID FROM torrents AS t WHERE t.ID='".db_string($TorrentID)."'");
+ $DB->query("
+ SELECT t.GroupID
+ FROM torrents AS t
+ WHERE t.ID = '".db_string($TorrentID)."'");
$GroupID = (int)array_pop($DB->next_record(MYSQLI_ASSOC));
if ($GroupID) {
return $GroupID;
@@ -219,7 +229,14 @@ function torrentid_to_groupid($TorrentID) {
//After adjusting / deleting logs, recalculate the score for the torrent.
function set_torrent_logscore($TorrentID) {
global $DB;
- $DB->query("UPDATE torrents SET LogScore = (SELECT FLOOR(AVG(Score)) FROM torrents_logs_new WHERE TorrentID = ".$TorrentID.") WHERE ID = ".$TorrentID);
+ $DB->query("
+ UPDATE torrents
+ SET LogScore = (
+ SELECT FLOOR(AVG(Score))
+ FROM torrents_logs_new
+ WHERE TorrentID = $TorrentID
+ )
+ WHERE ID = $TorrentID");
}
function get_group_requests($GroupID) {
@@ -228,11 +245,15 @@ function get_group_requests($GroupID) {
}
global $DB, $Cache;
- $Requests = $Cache->get_value('requests_group_'.$GroupID);
+ $Requests = $Cache->get_value("requests_group_$GroupID");
if ($Requests === false) {
- $DB->query("SELECT ID FROM requests WHERE GroupID = $GroupID AND TimeFilled = '0000-00-00 00:00:00'");
+ $DB->query("
+ SELECT ID
+ FROM requests
+ WHERE GroupID = $GroupID
+ AND TimeFilled = '0000-00-00 00:00:00'");
$Requests = $DB->collect('ID');
- $Cache->cache_value('requests_group_'.$GroupID, $Requests, 0);
+ $Cache->cache_value("requests_group_$GroupID", $Requests, 0);
}
$Requests = Requests::get_requests($Requests);
return $Requests['matches'];
@@ -241,7 +262,7 @@ function get_group_requests($GroupID) {
//Used to get reports info on a unison cache in both browsing pages and torrent pages.
function get_reports($TorrentID) {
global $Cache, $DB;
- $Reports = $Cache->get_value('reports_torrent_' . $TorrentID);
+ $Reports = $Cache->get_value("reports_torrent_$TorrentID");
if ($Reports === false) {
$DB->query("
SELECT
@@ -255,7 +276,7 @@ function get_reports($TorrentID) {
AND Type != 'edited'
AND Status != 'Resolved'");
$Reports = $DB->to_array();
- $Cache->cache_value('reports_torrent_' . $TorrentID, $Reports, 0);
+ $Cache->cache_value("reports_torrent_$TorrentID", $Reports, 0);
}
return $Reports;
}
@@ -264,7 +285,7 @@ function get_reports($TorrentID) {
function build_torrents_table($Cache, $DB, $LoggedUser, $GroupID, $GroupName, $GroupCategoryID, $ReleaseType, $TorrentList, $Types, $Text, $Username, $ReportedTimes) {
function filelist($Str) {
- return '</td><td>' . Format::get_size($Str[1]) . '</td></tr>';
+ return "</td>\n<td>" . Format::get_size($Str[1]) . "</td>\n</tr>";
}
$LastRemasterYear = '-';
@@ -295,7 +316,7 @@ function build_torrents_table($Cache, $DB, $LoggedUser, $GroupID, $GroupName, $G
$Reported = false;
unset($ReportedTimes);
- $Reports = $Cache->get_value('reports_torrent_' . $TorrentID);
+ $Reports = $Cache->get_value("reports_torrent_$TorrentID");
if ($Reports === false) {
$DB->query("
SELECT
@@ -309,31 +330,31 @@ function build_torrents_table($Cache, $DB, $LoggedUser, $GroupID, $GroupName, $G
AND Type != 'edited'
AND Status != 'Resolved'");
$Reports = $DB->to_array();
- $Cache->cache_value('reports_torrent_' . $TorrentID, $Reports, 0);
+ $Cache->cache_value("reports_torrent_$TorrentID", $Reports, 0);
}
if (count($Reports) > 0) {
$Reported = true;
include(SERVER_ROOT . '/sections/reportsv2/array.php');
- $ReportInfo = '<table><tr class="colhead_dark" style="font-weight: bold;"><td>This torrent has ' . count($Reports) . ' active ' . (count($Reports) > 1 ? 'reports' : 'report') . ':</td></tr>';
+ $ReportInfo = "\n<table>\n\t<tr class=\"colhead_dark\" style=\"font-weight: bold;\">\n\t\t<td>This torrent has " . count($Reports) . ' active ' . (count($Reports) > 1 ? 'reports' : 'report') . ":</td>\n\t</tr>";
foreach ($Reports as $Report) {
- list($ReportID, $ReporterID, $ReportType, $ReportReason, $ReportedTime) = $Report;
-
- $Reporter = Users::user_info($ReporterID);
- $ReporterName = $Reporter['Username'];
-
- if (array_key_exists($ReportType, $Types[$GroupCategoryID])) {
- $ReportType = $Types[$GroupCategoryID][$ReportType];
- } else if (array_key_exists($ReportType, $Types['master'])) {
- $ReportType = $Types['master'][$ReportType];
- } else {
- //There was a type but it wasn't an option!
- $ReportType = $Types['master']['other'];
- }
- $ReportInfo .= '<tr><td>' . (check_perms('admin_reports') ? "<a href=\"user.php?id=$ReporterID\">$ReporterName</a> <a href=\"reportsv2.php?view=report&amp;id=$ReportID\">reported it</a> " : 'Someone reported it ') . time_diff($ReportedTime, 2, true, true) . ' for the reason "' . $ReportType['title'] . '":';
- $ReportInfo .= '<blockquote>' . $Text->full_format($ReportReason) . '</blockquote></td></tr>';
+ list($ReportID, $ReporterID, $ReportType, $ReportReason, $ReportedTime) = $Report;
+
+ $Reporter = Users::user_info($ReporterID);
+ $ReporterName = $Reporter['Username'];
+
+ if (array_key_exists($ReportType, $Types[$GroupCategoryID])) {
+ $ReportType = $Types[$GroupCategoryID][$ReportType];
+ } else if (array_key_exists($ReportType, $Types['master'])) {
+ $ReportType = $Types['master'][$ReportType];
+ } else {
+ //There was a type but it wasn't an option!
+ $ReportType = $Types['master']['other'];
+ }
+ $ReportInfo .= "\n\t<tr>\n\t\t<td>" . (check_perms('admin_reports') ? "<a href=\"user.php?id=$ReporterID\">$ReporterName</a> <a href=\"reportsv2.php?view=report&amp;id=$ReportID\">reported it</a> " : 'Someone reported it ') . time_diff($ReportedTime, 2, true, true) . ' for the reason "' . $ReportType['title'] . '":';
+ $ReportInfo .= "\n\t\t\t<blockquote>" . $Text->full_format($ReportReason) . "</blockquote>\n\t\t</td>\n\t</tr>";
}
- $ReportInfo .= '</table>';
+ $ReportInfo .= "\n</table>";
}
$CanEdit = (check_perms('torrents_edit') || (($UserID == $LoggedUser['ID'] && !$LoggedUser['DisableWiki']) && !($Remastered && !$RemasterYear)));
@@ -377,26 +398,26 @@ function build_torrents_table($Cache, $DB, $LoggedUser, $GroupID, $GroupName, $G
$TorrentUploader = $Username; // Save this for "Uploaded by:" below
// similar to Torrents::torrent_info()
if ($Format) {
- $ExtraInfo.=display_str($Format);
+ $ExtraInfo .= display_str($Format);
$AddExtra = ' / ';
}
if ($Encoding) {
- $ExtraInfo.=$AddExtra . display_str($Encoding);
+ $ExtraInfo .= $AddExtra . display_str($Encoding);
$AddExtra = ' / ';
}
if ($HasLog) {
- $ExtraInfo.=$AddExtra . 'Log';
+ $ExtraInfo .= "{$AddExtra}Log";
$AddExtra = ' / ';
}
if ($HasLog && $LogInDB) {
- $ExtraInfo.=' (' . (int) $LogScore . '%)';
+ $ExtraInfo .= ' (' . (int) $LogScore . '%)';
}
if ($HasCue) {
- $ExtraInfo.=$AddExtra . 'Cue';
+ $ExtraInfo .= "{$AddExtra}Cue";
$AddExtra = ' / ';
}
if ($Scene) {
- $ExtraInfo.=$AddExtra . 'Scene';
+ $ExtraInfo .= "{$AddExtra}Scene";
$AddExtra = ' / ';
}
if (!$ExtraInfo) {
@@ -404,47 +425,47 @@ function build_torrents_table($Cache, $DB, $LoggedUser, $GroupID, $GroupName, $G
$AddExtra = ' / ';
}
if ($IsSnatched) {
- $ExtraInfo.=$AddExtra . Format::torrent_label('Snatched!');
+ $ExtraInfo .= $AddExtra . Format::torrent_label('Snatched!');
$AddExtra = ' / ';
}
if ($FreeTorrent == '1') {
- $ExtraInfo.=$AddExtra . Format::torrent_label('Freeleech!');
+ $ExtraInfo .= $AddExtra . Format::torrent_label('Freeleech!');
$AddExtra = ' / ';
}
if ($FreeTorrent == '2') {
- $ExtraInfo.=$AddExtra . Format::torrent_label('Neutral Leech!');
+ $ExtraInfo .= $AddExtra . Format::torrent_label('Neutral Leech!');
$AddExtra = ' / ';
}
if ($PersonalFL) {
- $ExtraInfo.=$AddExtra . Format::torrent_label('Personal Freeleech!');
+ $ExtraInfo .= $AddExtra . Format::torrent_label('Personal Freeleech!');
$AddExtra = ' / ';
}
if ($Reported) {
- $ExtraInfo.=$AddExtra . Format::torrent_label('Reported');
+ $ExtraInfo .= $AddExtra . Format::torrent_label('Reported');
$AddExtra = ' / ';
}
if (!empty($BadTags)) {
- $ExtraInfo.=$AddExtra . Format::torrent_label('Bad Tags');
+ $ExtraInfo .= $AddExtra . Format::torrent_label('Bad Tags');
$AddExtra = ' / ';
}
if (!empty($BadFolders)) {
- $ExtraInfo.=$AddExtra . Format::torrent_label('Bad Folders');
+ $ExtraInfo .= $AddExtra . Format::torrent_label('Bad Folders');
$AddExtra = ' / ';
}
if (!empty($CassetteApproved)) {
- $ExtraInfo.=$AddExtra . Format::torrent_label('Cassette Approved');
+ $ExtraInfo .= $AddExtra . Format::torrent_label('Cassette Approved');
$AddExtra = ' / ';
}
if (!empty($LossymasterApproved)) {
- $ExtraInfo.=$AddExtra . Format::torrent_label('Lossy Master Approved');
+ $ExtraInfo .= $AddExtra . Format::torrent_label('Lossy Master Approved');
$AddExtra = ' / ';
}
if (!empty($LossywebApproved)) {
- $ExtraInfo.=$AddExtra . Format::torrent_label('Lossy WEB Approved');
+ $ExtraInfo .= $AddExtra . Format::torrent_label('Lossy WEB Approved');
$AddExtra = ' / ';
}
if (!empty($BadFiles)) {
- $ExtraInfo.=$AddExtra . Format::torrent_label('Bad File Names');
+ $ExtraInfo .= $AddExtra . Format::torrent_label('Bad File Names');
$AddExtra = ' / ';
}
@@ -459,7 +480,7 @@ function build_torrents_table($Cache, $DB, $LoggedUser, $GroupID, $GroupName, $G
$EditionID++;
?>
<tr class="releases_<?=($ReleaseType)?> groupid_<?=($GroupID)?> edition group_torrent">
- <td colspan="5" class="edition_info"><strong><a href="#" onclick="toggle_edition(<?=($GroupID)?>, <?=($EditionID)?>, this, event)" title="Collapse this edition. Hold &quot;Ctrl&quot; while clicking to collapse all editions in this torrent group.">&minus;</a> <?= Torrents::edition_string($Torrent, $TorrentDetails) ?></strong></td>
+ <td colspan="5" class="edition_info"><strong><a href="#" onclick="toggle_edition(<?=($GroupID)?>, <?=($EditionID)?>, this, event);" title="Collapse this edition. Hold &quot;Ctrl&quot; while clicking to collapse all editions in this torrent group.">&minus;</a> <?= Torrents::edition_string($Torrent, $TorrentDetails) ?></strong></td>
</tr>
<?
}
@@ -512,14 +533,14 @@ function build_torrents_table($Cache, $DB, $LoggedUser, $GroupID, $GroupName, $G
</div>
<? } ?>
<div class="linkbox">
- <a href="#" class="brackets" onclick="show_peers('<?=($TorrentID)?>', 0);return false;">View peer list</a>
+ <a href="#" class="brackets" onclick="show_peers('<?=($TorrentID)?>', 0); return false;">View peer list</a>
<? if (check_perms('site_view_torrent_snatchlist')) { ?>
- <a href="#" class="brackets" onclick="show_downloads('<?=($TorrentID)?>', 0);return false;" title="View the list of users that have clicked the &quot;DL&quot; button.">View download list</a>
- <a href="#" class="brackets" onclick="show_snatches('<?=($TorrentID)?>', 0);return false;" title="View the list of users that have reported a snatch to the tracker.">View snatch list</a>
+ <a href="#" class="brackets" onclick="show_downloads('<?=($TorrentID)?>', 0); return false;" title="View the list of users that have clicked the &quot;DL&quot; button.">View download list</a>
+ <a href="#" class="brackets" onclick="show_snatches('<?=($TorrentID)?>', 0); return false;" title="View the list of users that have reported a snatch to the tracker.">View snatch list</a>
<? } ?>
- <a href="#" class="brackets" onclick="show_files('<?=($TorrentID)?>');return false;">View file list</a>
+ <a href="#" class="brackets" onclick="show_files('<?=($TorrentID)?>'); return false;">View file list</a>
<? if ($Reported) { ?>
- <a href="#" class="brackets" onclick="show_reported('<?=($TorrentID)?>');return false;">View report information</a>
+ <a href="#" class="brackets" onclick="show_reported('<?=($TorrentID)?>'); return false;">View report information</a>
<? } ?>
</div>
<div id="peers_<?=($TorrentID)?>" class="hidden"></div>
@@ -530,7 +551,7 @@ function build_torrents_table($Cache, $DB, $LoggedUser, $GroupID, $GroupName, $G
<div id="reported_<?=($TorrentID)?>" class="hidden"><?=($ReportInfo)?></div>
<? }
if (!empty($Description)) {
- echo '<blockquote>' . $Text->full_format($Description) . '</blockquote>';
+ echo "\n\t\t\t\t\t\t<blockquote>" . $Text->full_format($Description) . '</blockquote>';
} ?>
</td>
</tr>
diff --git a/sections/torrents/index.php b/sections/torrents/index.php
index 1df1e32..472f06d 100644
--- a/sections/torrents/index.php
+++ b/sections/torrents/index.php
@@ -8,10 +8,10 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
if ($i == $CurrentPage) {
$PageLinks[] = $i;
} else {
- $PageLinks[] = '<a href="#" onclick="'.$Action.'('.$TorrentID.', '.$i.')">'.$i.'</a>';
+ $PageLinks[] = "<a href=\"#\" onclick=\"$Action($TorrentID, $i)\">$i</a>";
}
}
- return implode(' | ',$PageLinks);
+ return implode(' | ', $PageLinks);
}
// This gets used in a few places
@@ -194,33 +194,36 @@ if (!empty($_REQUEST['action'])) {
$DB->query("
SELECT
CEIL((
- SELECT COUNT(ID)+1
+ SELECT COUNT(ID) + 1
FROM torrents_comments AS tc
- WHERE tc.GroupID='".db_string($GroupID)."')/".TORRENT_COMMENTS_PER_PAGE."
- ) AS Pages");
+ WHERE tc.GroupID = '".db_string($GroupID)."'
+ ) / ".TORRENT_COMMENTS_PER_PAGE.'
+ ) AS Pages');
list($Pages) = $DB->next_record();
$DB->query("
- INSERT INTO torrents_comments (GroupID,AuthorID,AddedTime,Body)
- VALUES ('".db_string($GroupID)."', '".db_string($LoggedUser['ID'])."','".sqltime()."','".db_string($_POST['body'])."')");
+ INSERT INTO torrents_comments
+ (GroupID, AuthorID, AddedTime, Body)
+ VALUES
+ ('".db_string($GroupID)."', '".db_string($LoggedUser['ID'])."', '".sqltime()."', '".db_string($_POST['body'])."')");
$PostID = $DB->inserted_id();
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Pages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
- $Cache->begin_transaction('torrent_comments_'.$GroupID.'_catalogue_'.$CatalogueID);
+ $Cache->begin_transaction("torrent_comments_{$GroupID}_catalogue_$CatalogueID");
$Post = array(
- 'ID'=>$PostID,
- 'AuthorID'=>$LoggedUser['ID'],
- 'AddedTime'=>sqltime(),
- 'Body'=>$_POST['body'],
- 'EditedUserID'=>0,
- 'EditedTime'=>'0000-00-00 00:00:00',
- 'Username'=>''
+ 'ID' => $PostID,
+ 'AuthorID' => $LoggedUser['ID'],
+ 'AddedTime' => sqltime(),
+ 'Body' => $_POST['body'],
+ 'EditedUserID' => 0,
+ 'EditedTime' => '0000-00-00 00:00:00',
+ 'Username' => ''
);
$Cache->insert('', $Post);
$Cache->commit_transaction(0);
- $Cache->increment('torrent_comments_'.$GroupID);
+ $Cache->increment("torrent_comments_$GroupID");
- header('Location: torrents.php?id='.$GroupID.'&page='.$Pages);
+ header("Location: torrents.php?id=$GroupID&page=$Pages");
break;
case 'get_post':
@@ -228,7 +231,10 @@ if (!empty($_REQUEST['action'])) {
if (!$_GET['post'] || !is_number($_GET['post'])) {
error(0);
}
- $DB->query("SELECT Body FROM torrents_comments WHERE ID='".db_string($_GET['post'])."'");
+ $DB->query("
+ SELECT Body
+ FROM torrents_comments
+ WHERE ID = '".db_string($_GET['post'])."'");
list($Body) = $DB->next_record(MYSQLI_NUM);
echo trim($Body);
@@ -254,8 +260,8 @@ if (!empty($_REQUEST['action'])) {
tc.GroupID,
tc.AddedTime
FROM torrents_comments AS tc
- WHERE tc.ID='".db_string($_POST['post'])."'");
- list($OldBody, $AuthorID,$GroupID,$AddedTime) = $DB->next_record();
+ WHERE tc.ID = '".db_string($_POST['post'])."'");
+ list($OldBody, $AuthorID, $GroupID, $AddedTime) = $DB->next_record();
$DB->query("
SELECT ceil(COUNT(ID) / ".TORRENT_COMMENTS_PER_PAGE.") AS Page
@@ -278,25 +284,28 @@ if (!empty($_REQUEST['action'])) {
Body = '".db_string($_POST['body'])."',
EditedUserID = '".db_string($LoggedUser['ID'])."',
EditedTime = '".sqltime()."'
- WHERE ID='".db_string($_POST['post'])."'");
+ WHERE ID = '".db_string($_POST['post'])."'");
// Update the cache
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
- $Cache->begin_transaction('torrent_comments_'.$GroupID.'_catalogue_'.$CatalogueID);
+ $Cache->begin_transaction("torrent_comments_{$GroupID}_catalogue_$CatalogueID");
$Cache->update_row($_POST['key'], array(
- 'ID'=>$_POST['post'],
- 'AuthorID'=>$AuthorID,
- 'AddedTime'=>$AddedTime,
- 'Body'=>$_POST['body'],
- 'EditedUserID'=>db_string($LoggedUser['ID']),
- 'EditedTime'=>sqltime(),
- 'Username'=>$LoggedUser['Username']
+ 'ID' => $_POST['post'],
+ 'AuthorID' => $AuthorID,
+ 'AddedTime' => $AddedTime,
+ 'Body' => $_POST['body'],
+ 'EditedUserID' => db_string($LoggedUser['ID']),
+ 'EditedTime' => sqltime(),
+ 'Username' => $LoggedUser['Username']
));
$Cache->commit_transaction(0);
- $DB->query("INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)
- VALUES ('torrents', ".db_string($_POST['post']).", ".db_string($LoggedUser['ID']).", '".sqltime()."', '".db_string($OldBody)."')");
+ $DB->query("
+ INSERT INTO comments_edits
+ (Page, PostID, EditUser, EditTime, Body)
+ VALUES
+ ('torrents', ".db_string($_POST['post']).", ".db_string($LoggedUser['ID']).", '".sqltime()."', '".db_string($OldBody)."')");
// This gets sent to the browser, which echoes it in place of the old body
echo $Text->full_format($_POST['body']);
@@ -317,33 +326,39 @@ if (!empty($_REQUEST['action'])) {
}
// Get topicid, forumid, number of pages
- $DB->query("SELECT
- GroupID,
- CEIL(COUNT(tc.ID)/".TORRENT_COMMENTS_PER_PAGE.") AS Pages,
- CEIL(SUM(IF(tc.ID<=".$_GET['postid'].",1,0))/".TORRENT_COMMENTS_PER_PAGE.") AS Page
+ $DB->query("
+ SELECT
+ GroupID,
+ CEIL(COUNT(tc.ID) / ".TORRENT_COMMENTS_PER_PAGE.") AS Pages,
+ CEIL(SUM(IF(tc.ID <= ".$_GET['postid'].", 1, 0)) / ".TORRENT_COMMENTS_PER_PAGE.") AS Page
FROM torrents_comments AS tc
- WHERE tc.GroupID=(SELECT GroupID FROM torrents_comments WHERE ID=".$_GET['postid'].")
- GROUP BY tc.GroupID");
+ WHERE tc.GroupID =
+ (SELECT GroupID
+ FROM torrents_comments
+ WHERE ID = ".$_GET['postid'].')
+ GROUP BY tc.GroupID');
list($GroupID, $Pages, $Page) = $DB->next_record();
// $Pages = number of pages in the thread
// $Page = which page the post is on
// These are set for cache clearing.
- $DB->query("DELETE FROM torrents_comments WHERE ID='".db_string($_GET['postid'])."'");
+ $DB->query("
+ DELETE FROM torrents_comments
+ WHERE ID = '".db_string($_GET['postid'])."'");
//We need to clear all subsequential catalogues as they've all been bumped with the absence of this post
$ThisCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
$LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $Pages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
for ($i = $ThisCatalogue; $i <= $LastCatalogue; $i++) {
- $Cache->delete_value('torrent_comments_'.$GroupID.'_catalogue_'.$i);
+ $Cache->delete_value("torrent_comments_{$GroupID}_catalogue_$i");
}
- // Delete thread info cache (eg. number of pages)
- $Cache->delete_value('torrent_comments_'.$GroupID);
+ // Delete thread info cache (e.g. number of pages)
+ $Cache->delete_value("torrent_comments_$GroupID");
break;
- case 'regen_filelist' :
+ case 'regen_filelist':
if (check_perms('users_mod') && !empty($_GET['torrentid']) && is_number($_GET['torrentid'])) {
Torrents::regenerate_filelist($_GET['torrentid']);
header('Location: torrents.php?torrentid='.$_GET['torrentid']);
@@ -352,9 +367,12 @@ if (!empty($_REQUEST['action'])) {
error(403);
}
break;
- case 'fix_group' :
+ case 'fix_group':
if ((check_perms('users_mod') || check_perms('torrents_fix_ghosts')) && authorize() && !empty($_GET['groupid']) && is_number($_GET['groupid'])) {
- $DB->query("SELECT COUNT(ID) FROM torrents WHERE GroupID = ".$_GET['groupid']);
+ $DB->query('
+ SELECT COUNT(ID)
+ FROM torrents
+ WHERE GroupID = '.$_GET['groupid']);
list($Count) = $DB->next_record();
if ($Count == 0) {
Torrents::delete_group($_GET['groupid']);
@@ -369,10 +387,10 @@ if (!empty($_REQUEST['action'])) {
error(403);
}
break;
- case 'warn' :
+ case 'warn':
include(SERVER_ROOT.'/sections/torrents/warn.php');
break;
- case 'take_warn' :
+ case 'take_warn':
include(SERVER_ROOT.'/sections/torrents/take_warn.php');
break;
case 'add_cover_art':
@@ -390,10 +408,13 @@ if (!empty($_REQUEST['action'])) {
if (!empty($_GET['id'])) {
include(SERVER_ROOT.'/sections/torrents/details.php');
} elseif (isset($_GET['torrentid']) && is_number($_GET['torrentid'])) {
- $DB->query("SELECT GroupID FROM torrents WHERE ID=".$_GET['torrentid']);
+ $DB->query('
+ SELECT GroupID
+ FROM torrents
+ WHERE ID = '.$_GET['torrentid']);
list($GroupID) = $DB->next_record();
if ($GroupID) {
- header("Location: torrents.php?id=".$GroupID."&torrentid=".$_GET['torrentid']);
+ header("Location: torrents.php?id=$GroupID&torrentid=".$_GET['torrentid']);
}
} else {
include(SERVER_ROOT.'/sections/torrents/browse2.php');
@@ -406,26 +427,31 @@ if (!empty($_REQUEST['action'])) {
if (!empty($_GET['id'])) {
include(SERVER_ROOT.'/sections/torrents/details.php');
} elseif (isset($_GET['torrentid']) && is_number($_GET['torrentid'])) {
- $DB->query("SELECT GroupID FROM torrents WHERE ID=".$_GET['torrentid']);
+ $DB->query("
+ SELECT GroupID
+ FROM torrents
+ WHERE ID = ".$_GET['torrentid']);
list($GroupID) = $DB->next_record();
if ($GroupID) {
- header("Location: torrents.php?id=".$GroupID."&torrentid=".$_GET['torrentid']."#torrent".$_GET['torrentid']);
+ header("Location: torrents.php?id=$GroupID&torrentid=".$_GET['torrentid'].'#torrent'.$_GET['torrentid']);
} else {
header("Location: log.php?search=Torrent+$_GET[torrentid]");
}
} elseif (!empty($_GET['type'])) {
include(SERVER_ROOT.'/sections/torrents/user.php');
} elseif (!empty($_GET['groupname']) && !empty($_GET['forward'])) {
- $DB->query("SELECT ID FROM torrents_group WHERE Name LIKE '".db_string($_GET['groupname'])."'");
+ $DB->query("
+ SELECT ID
+ FROM torrents_group
+ WHERE Name LIKE '".db_string($_GET['groupname'])."'");
list($GroupID) = $DB->next_record();
if ($GroupID) {
- header("Location: torrents.php?id=".$GroupID);
+ header("Location: torrents.php?id=$GroupID");
} else {
include(SERVER_ROOT.'/sections/torrents/browse2.php');
}
} else {
include(SERVER_ROOT.'/sections/torrents/browse2.php');
}
-
}
?>
diff --git a/sections/torrents/merge.php b/sections/torrents/merge.php
index 5845a21..18b2be8 100644
--- a/sections/torrents/merge.php
+++ b/sections/torrents/merge.php
@@ -16,7 +16,10 @@ if (!$NewGroupID || !is_number($NewGroupID)) {
if ($NewGroupID == $GroupID) {
error('Old group ID is the same as new group ID!');
}
-$DB->query("SELECT CategoryID, Name FROM torrents_group WHERE ID='$NewGroupID'");
+$DB->query("
+ SELECT CategoryID, Name
+ FROM torrents_group
+ WHERE ID = '$NewGroupID'");
if ($DB->record_count() == 0) {
error('Target group does not exist.');
}
@@ -25,10 +28,13 @@ if ($Categories[$CategoryID - 1] != 'Music') {
error('Only music groups can be merged.');
}
-$DB->query("SELECT Name FROM torrents_group WHERE ID = ".$GroupID);
+$DB->query("
+ SELECT Name
+ FROM torrents_group
+ WHERE ID = $GroupID");
list($Name) = $DB->next_record();
-//Everything is legit, let's just confim they're not retarded
+// Everything is legit, let's just confim they're not retarded
if (empty($_POST['confirm'])) {
$Artists = Artists::get_artists(array($GroupID, $NewGroupID));
@@ -46,9 +52,13 @@ if (empty($_POST['confirm'])) {
<input type="hidden" name="groupid" value="<?=$GroupID?>" />
<input type="hidden" name="targetgroupid" value="<?=$NewGroupID?>" />
<h3>You are attempting to merge the group:</h3>
- <ul><li><?= Artists::display_artists($Artists[$GroupID], true, false)?> - <a href="torrents.php?id=<?=$GroupID?>"><?=$Name?></a></li></ul>
+ <ul>
+ <li><?= Artists::display_artists($Artists[$GroupID], true, false)?> - <a href="torrents.php?id=<?=$GroupID?>"><?=$Name?></a></li>
+ </ul>
<h3>Into the group:</h3>
- <ul><li><?= Artists::display_artists($Artists[$NewGroupID], true, false)?> - <a href="torrents.php?id=<?=$NewGroupID?>"><?=$NewName?></a></li></ul>
+ <ul>
+ <li><?= Artists::display_artists($Artists[$NewGroupID], true, false)?> - <a href="torrents.php?id=<?=$NewGroupID?>"><?=$NewName?></a></li>
+ </ul>
<input type="submit" value="Confirm" />
</form>
</div>
@@ -60,78 +70,122 @@ if (empty($_POST['confirm'])) {
// Votes ninjutsu. This is so annoyingly complicated.
// 1. Get a list of everybody who voted on the old group and clear their cache keys
- $DB->query("SELECT UserID FROM users_votes WHERE GroupID='$GroupID'");
+ $DB->query("
+ SELECT UserID
+ FROM users_votes
+ WHERE GroupID = '$GroupID'");
while (list($UserID) = $DB->next_record()) {
- $Cache->delete_value('voted_albums_'.$UserID);
+ $Cache->delete_value("voted_albums_$UserID");
}
// 2. Update the existing votes where possible, clear out the duplicates left by key
// conflicts, and update the torrents_votes table
- $DB->query("UPDATE IGNORE users_votes SET GroupID='$NewGroupID' WHERE GroupID='$GroupID'");
- $DB->query("DELETE FROM users_votes WHERE GroupID='$GroupID'");
- $DB->query("INSERT INTO torrents_votes (GroupID, Ups, Total, Score)
- SELECT $NewGroupID, UpVotes, TotalVotes, VoteScore
- FROM (SELECT IFNULL(SUM(IF(Type='Up',1,0)),0) As UpVotes,
- COUNT(1) AS TotalVotes,
- binomial_ci(IFNULL(SUM(IF(Type='Up',1,0)),0), COUNT(1)) AS VoteScore
- FROM users_votes
- WHERE GroupID = $NewGroupID
- GROUP BY GroupID) AS a
- ON DUPLICATE KEY UPDATE
- Ups = a.UpVotes,
- Total = a.TotalVotes,
- Score = a.VoteScore;");
+ $DB->query("
+ UPDATE IGNORE users_votes
+ SET GroupID = '$NewGroupID'
+ WHERE GroupID = '$GroupID'");
+ $DB->query("
+ DELETE FROM users_votes
+ WHERE GroupID = '$GroupID'");
+ $DB->query("
+ INSERT INTO torrents_votes (GroupID, Ups, Total, Score)
+ SELECT $NewGroupID, UpVotes, TotalVotes, VoteScore
+ FROM (
+ SELECT
+ IFNULL(SUM(IF(Type = 'Up', 1, 0)), 0) As UpVotes,
+ COUNT(1) AS TotalVotes,
+ binomial_ci(IFNULL(SUM(IF(Type = 'Up', 1, 0)), 0), COUNT(1)) AS VoteScore
+ FROM users_votes
+ WHERE GroupID = $NewGroupID
+ GROUP BY GroupID
+ ) AS a
+ ON DUPLICATE KEY UPDATE
+ Ups = a.UpVotes,
+ Total = a.TotalVotes,
+ Score = a.VoteScore;");
// 3. Clear the votes_pairs keys!
- $DB->query("SELECT v2.GroupID
- FROM users_votes AS v1
- INNER JOIN users_votes AS v2 USING (UserID)
- WHERE (v1.Type = 'Up' OR v2.Type='Up')
- AND (v1.GroupID IN($GroupID, $NewGroupID))
- AND (v2.GroupID NOT IN($GroupID, $NewGroupID));");
+ $DB->query("
+ SELECT v2.GroupID
+ FROM users_votes AS v1
+ INNER JOIN users_votes AS v2 USING (UserID)
+ WHERE (v1.Type = 'Up' OR v2.Type = 'Up')
+ AND (v1.GroupID IN($GroupID, $NewGroupID))
+ AND (v2.GroupID NOT IN($GroupID, $NewGroupID));");
while (list($CacheGroupID) = $DB->next_record()) {
- $Cache->delete_value('vote_pairs_'.$CacheGroupID);
+ $Cache->delete_value("vote_pairs_$CacheGroupID");
}
// 4. Clear the new groups vote keys
- $Cache->delete_value('votes_'.$NewGroupID);
+ $Cache->delete_value("votes_$NewGroupID");
- $DB->query("UPDATE torrents SET GroupID='$NewGroupID' WHERE GroupID='$GroupID'");
- $DB->query("UPDATE wiki_torrents SET PageID='$NewGroupID' WHERE PageID='$GroupID'");
- $DB->query("UPDATE torrents_comments SET GroupID='$NewGroupID' WHERE GroupID='$GroupID'");
+ $DB->query("
+ UPDATE torrents
+ SET GroupID = '$NewGroupID'
+ WHERE GroupID = '$GroupID'");
+ $DB->query("
+ UPDATE wiki_torrents
+ SET PageID = '$NewGroupID'
+ WHERE PageID = '$GroupID'");
+ $DB->query("
+ UPDATE torrents_comments
+ SET GroupID = '$NewGroupID'
+ WHERE GroupID = '$GroupID'");
Torrents::delete_group($GroupID);
- Torrents::write_group_log($NewGroupID, 0, $LoggedUser['ID'], "Merged Group ".$GroupID." (".$Name.") to ".$NewGroupID." (".$NewName.")", 0);
- $DB->query("UPDATE group_log SET GroupID = ".$NewGroupID." WHERE GroupID = ".$GroupID);
+ Torrents::write_group_log($NewGroupID, 0, $LoggedUser['ID'], "Merged Group $GroupID ($Name) to $NewGroupID ($NewName)", 0);
+ $DB->query("
+ UPDATE group_log
+ SET GroupID = $NewGroupID
+ WHERE GroupID = $GroupID");
- $GroupID=$NewGroupID;
+ $GroupID = $NewGroupID;
//Collages
- $DB->query("SELECT CollageID FROM collages_torrents WHERE GroupID='$OldGroupID'"); //Select all collages that contain edited group
+ $DB->query("
+ SELECT CollageID
+ FROM collages_torrents
+ WHERE GroupID = '$OldGroupID'"); // Select all collages that contain edited group
while (list($CollageID) = $DB->next_record()) {
- $DB->query("UPDATE IGNORE collages_torrents SET GroupID='$NewGroupID' WHERE GroupID='$OldGroupID' AND CollageID='$CollageID'"); //Change collage groupid to new ID
- $DB->query("DELETE FROM collages_torrents WHERE GroupID='$OldGroupID' AND CollageID='$CollageID'");
- $Cache->delete_value('collage_'.$CollageID);
+ $DB->query("
+ UPDATE IGNORE collages_torrents
+ SET GroupID = '$NewGroupID'
+ WHERE GroupID = '$OldGroupID'
+ AND CollageID = '$CollageID'"); // Change collage group ID to new ID
+ $DB->query("
+ DELETE FROM collages_torrents
+ WHERE GroupID = '$OldGroupID'
+ AND CollageID = '$CollageID'");
+ $Cache->delete_value("collage_$CollageID");
}
- $Cache->delete_value('torrent_collages_'.$NewGroupID);
- $Cache->delete_value('torrent_collages_personal_'.$NewGroupID);
+ $Cache->delete_value("torrent_collages_$NewGroupID");
+ $Cache->delete_value("torrent_collages_personal_$NewGroupID");
- //Requests
- $DB->query("SELECT ID FROM requests WHERE GroupID='$OldGroupID'");
+ // Requests
+ $DB->query("
+ SELECT ID
+ FROM requests
+ WHERE GroupID = '$OldGroupID'");
$Requests = $DB->collect('ID');
- $DB->query("UPDATE requests SET GroupID = 'NewGroupID' WHERE GroupID = '$OldGroupID'");
+ $DB->query("
+ UPDATE requests
+ SET GroupID = 'NewGroupID'
+ WHERE GroupID = '$OldGroupID'");
foreach ($Requests as $RequestID) {
- $Cache->delete_value('request_'.$RequestID);
+ $Cache->delete_value("request_$RequestID");
}
- $DB->query("SELECT ID FROM torrents WHERE GroupID='$OldGroupID'");
+ $DB->query("
+ SELECT ID
+ FROM torrents
+ WHERE GroupID = '$OldGroupID'");
while (list($TorrentID) = $DB->next_record()) {
- $Cache->delete_value('torrent_download_'.$TorrentID);
+ $Cache->delete_value("torrent_download_$TorrentID");
}
- $Cache->delete_value('torrents_details_'.$GroupID);
- $Cache->delete_value('torrent_comments_'.$GroupID.'_catalogue_0');
- $Cache->delete_value('torrent_comments_'.$GroupID);
- $Cache->delete_value('groups_artists_'.$GroupID);
+ $Cache->delete_value("torrents_details_$GroupID");
+ $Cache->delete_value("torrent_comments_{$GroupID}_catalogue_0");
+ $Cache->delete_value("torrent_comments_$GroupID");
+ $Cache->delete_value("groups_artists_$GroupID");
Torrents::update_hash($GroupID);
- header('Location: torrents.php?id='.$GroupID);
+ header("Location: torrents.php?id=" . $GroupID);
}
?>
diff --git a/sections/torrents/nonwikiedit.php b/sections/torrents/nonwikiedit.php
index 9978900..672caec 100644
--- a/sections/torrents/nonwikiedit.php
+++ b/sections/torrents/nonwikiedit.php
@@ -10,7 +10,10 @@ $GroupID = $_POST['groupid'];
//Usual perm checks
if (!check_perms('torrents_edit')) {
- $DB->query("SELECT UserID FROM torrents WHERE GroupID = ".$GroupID);
+ $DB->query("
+ SELECT UserID
+ FROM torrents
+ WHERE GroupID = $GroupID");
if (!in_array($LoggedUser['ID'], $DB->collect('UserID'))) {
error(403);
}
@@ -26,7 +29,7 @@ if (check_perms('torrents_freeleech') && (isset($_POST['freeleech']) xor isset($
$Free = 0;
}
- if (isset($_POST['freeleechtype']) && in_array($_POST['freeleechtype'], array(0,1,2,3))) {
+ if (isset($_POST['freeleechtype']) && in_array($_POST['freeleechtype'], array(0, 1, 2, 3))) {
$FreeType = $_POST['freeleechtype'];
} else {
error(404);
@@ -41,28 +44,37 @@ $RecordLabel = db_string($_POST['record_label']);
$CatalogueNumber = db_string($_POST['catalogue_number']);
// Get some info for the group log
-$DB->query("SELECT Year FROM torrents_group WHERE ID = $GroupID");
+$DB->query("
+ SELECT Year
+ FROM torrents_group
+ WHERE ID = $GroupID");
list($OldYear) = $DB->next_record();
-$DB->query("UPDATE torrents_group SET
- Year = '$Year',
- RecordLabel = '".$RecordLabel."',
- CatalogueNumber = '".$CatalogueNumber."'
- WHERE ID = ".$GroupID);
+$DB->query("
+ UPDATE torrents_group
+ SET
+ Year = '$Year',
+ RecordLabel = '".$RecordLabel."',
+ CatalogueNumber = '".$CatalogueNumber."'
+ WHERE ID = $GroupID");
if ($OldYear != $Year) {
- $DB->query("INSERT INTO group_log (GroupID, UserID, Time, Info)
- VALUES ('$GroupID',".$LoggedUser['ID'].",'".sqltime()."','".db_string("Year changed from $OldYear to $Year")."')");
+ $DB->query("
+ INSERT INTO group_log (GroupID, UserID, Time, Info)
+ VALUES ('$GroupID', ".$LoggedUser['ID'].", '".sqltime()."', '".db_string("Year changed from $OldYear to $Year")."')");
}
-$DB->query("SELECT ID FROM torrents WHERE GroupID='$GroupID'");
+$DB->query("
+ SELECT ID
+ FROM torrents
+ WHERE GroupID = '$GroupID'");
while (list($TorrentID) = $DB->next_record()) {
- $Cache->delete_value('torrent_download_'.$TorrentID);
+ $Cache->delete_value("torrent_download_$TorrentID");
}
Torrents::update_hash($GroupID);
-$Cache->delete_value('torrents_details_'.$GroupID);
+$Cache->delete_value("torrents_details_$GroupID");
-header("Location: torrents.php?id=".$GroupID);
+header("Location: torrents.php?id=$GroupID");
?>
diff --git a/sections/torrents/remove_cover_art.php b/sections/torrents/remove_cover_art.php
index 234cf6e..4a1c76c 100644
--- a/sections/torrents/remove_cover_art.php
+++ b/sections/torrents/remove_cover_art.php
@@ -12,14 +12,22 @@ if (!is_number($ID) || !is_number($ID) || !is_number($GroupID) || !is_number($Gr
error(404);
}
-$DB->query("SELECT Image, Summary FROM cover_art WHERE ID = '$ID'");
+$DB->query("
+ SELECT Image, Summary
+ FROM cover_art
+ WHERE ID = '$ID'");
list($Image, $Summary) = $DB->next_record();
-$DB->query("DELETE FROM cover_art WHERE ID = '$ID'");
+$DB->query("
+ DELETE FROM cover_art
+ WHERE ID = '$ID'");
-$DB->query("INSERT INTO group_log (GroupID, UserID, Time, Info)
- VALUES ('$GroupID',".$LoggedUser['ID'].",'".sqltime()."','".db_string('Additional Cover "'.$Summary . ' - ' . $Image .'" removed from group')."')");
+$DB->query("
+ INSERT INTO group_log
+ (GroupID, UserID, Time, Info)
+ VALUES
+ ('$GroupID', ".$LoggedUser['ID'].", '".sqltime()."', '".db_string("Additional Cover \"$Summary - $Image\" removed from group")."')");
-$Cache->delete_value('torrents_cover_art_' . $GroupID);
+$Cache->delete_value("torrents_cover_art_$GroupID");
header('Location: '.$_SERVER['HTTP_REFERER']);
?>
diff --git a/sections/torrents/take_warn.php b/sections/torrents/take_warn.php
index 195e65c..2789d64 100644
--- a/sections/torrents/take_warn.php
+++ b/sections/torrents/take_warn.php
@@ -24,51 +24,56 @@ if ($Length != 'verbal') {
$Subject = 'You have received a warning';
$PrivateMessage = "You have received a $Length week warning for [url=$URL]this post.[/url]\n\n" . $PrivateMessage;
$WarnTime = time_plus($Time);
- $AdminComment = date('Y-m-d') . ' - Warned until ' . $WarnTime . ' by ' . $LoggedUser['Username'] . " for $URL \nReason: $Reason\n\n";
+ $AdminComment = date('Y-m-d') . " - Warned until $WarnTime by " . $LoggedUser['Username'] . " for $URL \nReason: $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;
$AdminComment = date('Y-m-d') . ' - Verbally warned by ' . $LoggedUser['Username'] . " for $URL \nReason: $Reason\n\n";
}
-$DB->query("INSERT INTO users_warnings_forums (UserID, Comment)
- VALUES('$UserID', '" . db_string($AdminComment) . "')
- ON DUPLICATE KEY UPDATE Comment = CONCAT('" . db_string($AdminComment) . "', Comment)");
+$DB->query("
+ INSERT INTO users_warnings_forums (UserID, Comment)
+ VALUES('$UserID', '" . db_string($AdminComment) . "')
+ ON DUPLICATE KEY UPDATE Comment = CONCAT('" . db_string($AdminComment) . "', Comment)");
Tools::update_user_notes($UserID, $AdminComment);
Misc::send_pm($UserID, $LoggedUser['ID'], $Subject, $PrivateMessage);
// Mainly
-$DB->query("SELECT
- tc.Body,
- tc.AuthorID,
- tc.GroupID,
- tc.AddedTime
- FROM torrents_comments AS tc
- WHERE tc.ID='$PostID'");
+$DB->query("
+ SELECT
+ tc.Body,
+ tc.AuthorID,
+ tc.GroupID,
+ tc.AddedTime
+ FROM torrents_comments AS tc
+ WHERE tc.ID = '$PostID'");
list($OldBody, $AuthorID, $GroupID, $AddedTime) = $DB->next_record();
-$DB->query("SELECT ceil(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page
- FROM torrents_comments
- WHERE GroupID = $GroupID AND ID <= $PostID");
+$DB->query("
+ SELECT ceil(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page
+ FROM torrents_comments
+ WHERE GroupID = $GroupID
+ AND ID <= $PostID");
list($Page) = $DB->next_record();
// Perform the update
-$DB->query("UPDATE torrents_comments
- SET Body = '" . db_string($Body) . "',
- EditedUserID = '" . db_string($LoggedUser['ID']) . "',
- EditedTime = '" . sqltime() . "'
- WHERE ID='$PostID'");
+$DB->query("
+ UPDATE torrents_comments
+ SET Body = '" . db_string($Body) . "',
+ EditedUserID = '" . db_string($LoggedUser['ID']) . "',
+ EditedTime = '" . sqltime() . "'
+ WHERE ID = '$PostID'");
// Update the cache
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
-$Cache->begin_transaction('torrent_comments_' . $GroupID . '_catalogue_' . $CatalogueID);
+$Cache->begin_transaction("torrent_comments_{$GroupID}_catalogue_$CatalogueID");
$Cache->update_row($_POST['key'], array('ID' => $_POST['postid'], 'AuthorID' => $AuthorID, 'AddedTime' => $AddedTime, 'Body' => $Body,
'EditedUserID' => db_string($LoggedUser['ID']), 'EditedTime' => sqltime(), 'Username' => $LoggedUser['Username']));
$Cache->commit_transaction(0);
-$DB->query("INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)
- VALUES ('torrents', " . db_string($_POST['postid']) . ", " . db_string($LoggedUser['ID']) . ", '" . sqltime() . "', '" . db_string($OldBody) . "')");
+$DB->query("
+ INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)
+ VALUES ('torrents', " . db_string($_POST['postid']) . ", " . db_string($LoggedUser['ID']) . ", '" . sqltime() . "', '" . db_string($OldBody) . "')");
header("Location: torrents.php?id=$GroupID&postid=$PostID#post$PostID");
?>
-;
diff --git a/sections/torrents/takedelete.php b/sections/torrents/takedelete.php
index 2679b2a..e75121a 100644
--- a/sections/torrents/takedelete.php
+++ b/sections/torrents/takedelete.php
@@ -6,24 +6,25 @@ if (!$TorrentID || !is_number($TorrentID)) {
error(404);
}
-if ($Cache->get_value('torrent_'.$TorrentID.'_lock')) {
+if ($Cache->get_value("torrent_{$TorrentID}_lock")) {
error('Torrent cannot be deleted because the upload process is not completed yet. Please try again later.');
}
-$DB->query("SELECT
- t.UserID,
- t.GroupID,
- t.Size,
- t.info_hash,
- tg.Name,
- ag.Name,
- t.Time,
- COUNT(x.uid)
+$DB->query("
+ SELECT
+ t.UserID,
+ t.GroupID,
+ t.Size,
+ t.info_hash,
+ tg.Name,
+ ag.Name,
+ t.Time,
+ COUNT(x.uid)
FROM torrents AS t
- LEFT JOIN torrents_group AS tg ON tg.ID=t.GroupID
- LEFT JOIN artists_group AS ag ON ag.ArtistID=tg.ArtistID
- LEFT JOIN xbt_snatched AS x ON x.fid=t.ID
- WHERE t.ID='$TorrentID'");
+ LEFT JOIN torrents_group AS tg ON tg.ID = t.GroupID
+ LEFT JOIN artists_group AS ag ON ag.ArtistID = tg.ArtistID
+ LEFT JOIN xbt_snatched AS x ON x.fid = t.ID
+ WHERE t.ID = '$TorrentID'");
list($UserID, $GroupID, $Size, $InfoHash, $Name, $ArtistName, $Time, $Snatches) = $DB->next_record(MYSQLI_NUM, false);
if (($LoggedUser['ID'] != $UserID || time_ago($Time) > 3600 * 24 * 7 || $Snatches > 4) && !check_perms('torrents_delete')) {
@@ -31,22 +32,22 @@ if (($LoggedUser['ID'] != $UserID || time_ago($Time) > 3600 * 24 * 7 || $Snatche
}
if ($ArtistName) {
- $Name = $ArtistName.' - '.$Name;
+ $Name = "$ArtistName - $Name";
}
if (isset($_SESSION['logged_user']['multi_delete'])) {
if ($_SESSION['logged_user']['multi_delete'] >= 3 && !check_perms('torrents_delete_fast')) {
- error('You have recently deleted 3 torrents, please contact a staff member if you need to delete more.');
+ error('You have recently deleted 3 torrents. Please contact a staff member if you need to delete more.');
}
$_SESSION['logged_user']['multi_delete']++;
} else {
$_SESSION['logged_user']['multi_delete'] = 1;
}
-$InfoHash = unpack("H*", $InfoHash);
+$InfoHash = unpack('H*', $InfoHash);
Torrents::delete_torrent($TorrentID, $GroupID);
-Misc::write_log('Torrent '.$TorrentID.' ('.$Name.') ('.number_format($Size / (1024 * 1024), 2).' MB) ('.strtoupper($InfoHash[1]).') was deleted by '.$LoggedUser['Username'].': ' .$_POST['reason'].' '.$_POST['extra']);
-Torrents::write_group_log($GroupID, $TorrentID, $LoggedUser['ID'], "deleted torrent (".number_format($Size / (1024 * 1024), 2)." MB, ".strtoupper($InfoHash[1]).") for reason: ".$_POST['reason']." ".$_POST['extra'], 0);
+Misc::write_log("Torrent $TorrentID ($Name) (".number_format($Size / (1024 * 1024), 2).' MB) ('.strtoupper($InfoHash[1]).') was deleted by '.$LoggedUser['Username'].': ' .$_POST['reason'].' '.$_POST['extra']);
+Torrents::write_group_log($GroupID, $TorrentID, $LoggedUser['ID'], 'deleted torrent ('.number_format($Size / (1024 * 1024), 2).' MB, '.strtoupper($InfoHash[1]).') for reason: '.$_POST['reason'].' '.$_POST['extra'], 0);
View::show_header('Torrent deleted');
?>
diff --git a/sections/torrents/takeedit.php b/sections/torrents/takeedit.php
index 18730ab..03cee3d 100644
--- a/sections/torrents/takeedit.php
+++ b/sections/torrents/takeedit.php
@@ -61,7 +61,7 @@ if ($_POST['album_desc']) {
}
if (check_perms('torrents_freeleech')) {
$Free = (int)$_POST['freeleech'];
- if (!in_array($Free, array(0,1,2))) {
+ if (!in_array($Free, array(0, 1, 2))) {
error(404);
}
$Properties['FreeLeech'] = $Free;
@@ -70,7 +70,7 @@ if (check_perms('torrents_freeleech')) {
$FreeType = 0;
} else {
$FreeType = (int)$_POST['freeleechtype'];
- if (!in_array($Free, array(0,1,2,3))) {
+ if (!in_array($Free, array(0, 1, 2, 3))) {
error(404);
}
}
@@ -80,7 +80,10 @@ if (check_perms('torrents_freeleech')) {
//******************************************************************************//
//--------------- Validate data in edit form -----------------------------------//
-$DB->query('SELECT UserID, Remastered, RemasterYear, FreeTorrent FROM torrents WHERE ID='.$TorrentID);
+$DB->query("
+ SELECT UserID, Remastered, RemasterYear, FreeTorrent
+ FROM torrents
+ WHERE ID = $TorrentID");
if ($DB->record_count() == 0) {
error(404);
}
@@ -254,12 +257,15 @@ foreach ($Properties as $Key => $Value) {
//--------------- Start database stuff -----------------------------------------//
$DBTorVals = array();
-$DB->query("SELECT Media, Format, Encoding, RemasterYear, Remastered, RemasterTItle, RemasterRecordLabel, RemasterCatalogueNumber, Scene, Description FROM torrents WHERE ID = ".$TorrentID);
+$DB->query("
+ SELECT Media, Format, Encoding, RemasterYear, Remastered, RemasterTItle, RemasterRecordLabel, RemasterCatalogueNumber, Scene, Description
+ FROM torrents
+ WHERE ID = $TorrentID");
$DBTorVals = $DB->to_array(false, MYSQLI_ASSOC);
$DBTorVals = $DBTorVals[0];
-$LogDetails = "";
+$LogDetails = '';
foreach ($DBTorVals as $Key => $Value) {
- $Value = "'".$Value."'";
+ $Value = "'$Value'";
if ($Value != $T[$Key]) {
if (!isset($T[$Key])) {
continue;
@@ -267,166 +273,245 @@ foreach ($DBTorVals as $Key => $Value) {
if ((empty($Value) && empty($T[$Key])) || ($Value == "'0'" && $T[$Key] == "''")) {
continue;
}
- if ($LogDetails == "") {
- $LogDetails = $Key.": ".$Value." -> ".$T[$Key];
+ if ($LogDetails == '') {
+ $LogDetails = "$Key: $Value -> ".$T[$Key];
} else {
- $LogDetails = $LogDetails.", ".$Key.": ".$Value." -> ".$T[$Key];
+ $LogDetails = "$LogDetails, $Key: $Value -> ".$T[$Key];
}
}
}
// Update info for the torrent
$SQL = "
- UPDATE torrents SET
- Media=$T[Media],
- Format=$T[Format],
- Encoding=$T[Encoding],
- RemasterYear=$T[RemasterYear],
- Remastered=$T[Remastered],
- RemasterTitle=$T[RemasterTitle],
- RemasterRecordLabel=$T[RemasterRecordLabel],
- RemasterCatalogueNumber=$T[RemasterCatalogueNumber],
- Scene=$T[Scene],
- Description=$T[TorrentDescription],";
+ UPDATE torrents
+ SET
+ Media = $T[Media],
+ Format = $T[Format],
+ Encoding = $T[Encoding],
+ RemasterYear = $T[RemasterYear],
+ Remastered = $T[Remastered],
+ RemasterTitle = $T[RemasterTitle],
+ RemasterRecordLabel = $T[RemasterRecordLabel],
+ RemasterCatalogueNumber = $T[RemasterCatalogueNumber],
+ Scene = $T[Scene],
+ Description = $T[TorrentDescription],";
if (check_perms('torrents_freeleech')) {
- $SQL .= "FreeTorrent=$T[FreeLeech],";
- $SQL .= "FreeLeechType=$T[FreeLeechType],";
+ $SQL .= "FreeTorrent = $T[FreeLeech],";
+ $SQL .= "FreeLeechType = $T[FreeLeechType],";
}
if (check_perms('users_mod')) {
if ($T[Format] != "'FLAC'") {
$SQL .= "
- HasLog='0',
- HasCue='0',
- ";
+ HasLog = '0',
+ HasCue = '0',";
} else {
$SQL .= "
- HasLog=$T[HasLog],
- HasCue=$T[HasCue],
- ";
+ HasLog = $T[HasLog],
+ HasCue = $T[HasCue],";
}
- $DB->query("SELECT TorrentID FROM torrents_bad_tags WHERE TorrentID='$TorrentID'");
+ $DB->query("
+ SELECT TorrentID
+ FROM torrents_bad_tags
+ WHERE TorrentID = '$TorrentID'");
list($btID) = $DB->next_record();
if (!$btID && $Properties['BadTags']) {
- $DB->query("INSERT INTO torrents_bad_tags VALUES($TorrentID, $LoggedUser[ID], '".sqltime()."')");
+ $DB->query("
+ INSERT INTO torrents_bad_tags
+ VALUES ($TorrentID, $LoggedUser[ID], '".sqltime()."')");
}
if ($btID && !$Properties['BadTags']) {
- $DB->query("DELETE FROM torrents_bad_tags WHERE TorrentID='$TorrentID'");
+ $DB->query("
+ DELETE FROM torrents_bad_tags
+ WHERE TorrentID = '$TorrentID'");
}
- $DB->query("SELECT TorrentID FROM torrents_bad_folders WHERE TorrentID='$TorrentID'");
+ $DB->query("
+ SELECT TorrentID
+ FROM torrents_bad_folders
+ WHERE TorrentID = '$TorrentID'");
list($bfID) = $DB->next_record();
if (!$bfID && $Properties['BadFolders']) {
- $DB->query("INSERT INTO torrents_bad_folders VALUES($TorrentID, $LoggedUser[ID], '".sqltime()."')");
+ $DB->query("
+ INSERT INTO torrents_bad_folders
+ VALUES ($TorrentID, $LoggedUser[ID], '".sqltime()."')");
}
if ($bfID && !$Properties['BadFolders']) {
- $DB->query("DELETE FROM torrents_bad_folders WHERE TorrentID='$TorrentID'");
+ $DB->query("
+ DELETE FROM torrents_bad_folders
+ WHERE TorrentID = '$TorrentID'");
}
- $DB->query("SELECT TorrentID FROM torrents_bad_files WHERE TorrentID='$TorrentID'");
+ $DB->query("
+ SELECT TorrentID
+ FROM torrents_bad_files
+ WHERE TorrentID = '$TorrentID'");
list($bfiID) = $DB->next_record();
if (!$bfiID && $Properties['BadFiles']) {
- $DB->query("INSERT INTO torrents_bad_files VALUES($TorrentID, $LoggedUser[ID], '".sqltime()."')");
+ $DB->query("
+ INSERT INTO torrents_bad_files
+ VALUES ($TorrentID, $LoggedUser[ID], '".sqltime()."')");
}
if ($bfiID && !$Properties['BadFiles']) {
- $DB->query("DELETE FROM torrents_bad_files WHERE TorrentID='$TorrentID'");
+ $DB->query("
+ DELETE FROM torrents_bad_files
+ WHERE TorrentID = '$TorrentID'");
}
- $DB->query("SELECT TorrentID FROM library_contest WHERE TorrentID='$TorrentID'");
+ $DB->query("
+ SELECT TorrentID
+ FROM library_contest
+ WHERE TorrentID = '$TorrentID'");
list($lbID) = $DB->next_record();
if (!$lbID && $Properties['LibraryUpload'] && $Properties['LibraryPoints'] > 0) {
- $DB->query("SELECT UserID FROM torrents WHERE ID = ".$TorrentID);
+ $DB->query("
+ SELECT UserID
+ FROM torrents
+ WHERE ID = $TorrentID");
list($UploaderID) = $DB->next_record();
- $DB->query("INSERT INTO library_contest VALUES ($UploaderID, $TorrentID, $Properties[LibraryPoints])");
+ $DB->query("
+ INSERT INTO library_contest
+ VALUES ($UploaderID, $TorrentID, $Properties[LibraryPoints])");
}
if ($lbID && !$Properties['LibraryUpload']) {
- $DB->query("DELETE FROM library_contest WHERE TorrentID='$TorrentID'");
+ $DB->query("
+ DELETE FROM library_contest
+ WHERE TorrentID = '$TorrentID'");
}
- $DB->query("SELECT TorrentID FROM torrents_cassette_approved WHERE TorrentID='$TorrentID'");
+ $DB->query("
+ SELECT TorrentID
+ FROM torrents_cassette_approved
+ WHERE TorrentID = '$TorrentID'");
list($caID) = $DB->next_record();
if (!$caID && $Properties['CassetteApproved']) {
- $DB->query("INSERT INTO torrents_cassette_approved VALUES($TorrentID, $LoggedUser[ID], '".sqltime()."')");
+ $DB->query("
+ INSERT INTO torrents_cassette_approved
+ VALUES ($TorrentID, $LoggedUser[ID], '".sqltime()."')");
}
if ($caID && !$Properties['CassetteApproved']) {
- $DB->query("DELETE FROM torrents_cassette_approved WHERE TorrentID='$TorrentID'");
+ $DB->query("
+ DELETE FROM torrents_cassette_approved
+ WHERE TorrentID = '$TorrentID'");
}
- $DB->query("SELECT TorrentID FROM torrents_lossymaster_approved WHERE TorrentID='$TorrentID'");
+ $DB->query("
+ SELECT TorrentID
+ FROM torrents_lossymaster_approved
+ WHERE TorrentID = '$TorrentID'");
list($lmaID) = $DB->next_record();
if (!$lmaID && $Properties['LossymasterApproved']) {
- $DB->query("INSERT INTO torrents_lossymaster_approved VALUES($TorrentID, $LoggedUser[ID], '".sqltime()."')");
+ $DB->query("
+ INSERT INTO torrents_lossymaster_approved
+ VALUES ($TorrentID, $LoggedUser[ID], '".sqltime()."')");
}
if ($lmaID && !$Properties['LossymasterApproved']) {
- $DB->query("DELETE FROM torrents_lossymaster_approved WHERE TorrentID='$TorrentID'");
+ $DB->query("
+ DELETE FROM torrents_lossymaster_approved
+ WHERE TorrentID = '$TorrentID'");
}
- $DB->query("SELECT TorrentID FROM torrents_lossyweb_approved WHERE TorrentID='$TorrentID'");
+ $DB->query("
+ SELECT TorrentID
+ FROM torrents_lossyweb_approved
+ WHERE TorrentID = '$TorrentID'");
list($lwID) = $DB->next_record();
if (!$lwID && $Properties['LossywebApproved']) {
- $DB->query("INSERT INTO torrents_lossyweb_approved VALUES($TorrentID, $LoggedUser[ID], '".sqltime()."')");
+ $DB->query("
+ INSERT INTO torrents_lossyweb_approved
+ VALUES ($TorrentID, $LoggedUser[ID], '".sqltime()."')");
}
if ($lwID && !$Properties['LossywebApproved']) {
- $DB->query("DELETE FROM torrents_lossyweb_approved WHERE TorrentID='$TorrentID'");
+ $DB->query("
+ DELETE FROM torrents_lossyweb_approved
+ WHERE TorrentID = '$TorrentID'");
}
}
$SQL .= "
- flags='2'
- WHERE ID=$TorrentID
-";
+ flags = '2'
+ WHERE ID = $TorrentID";
$DB->query($SQL);
if (check_perms('torrents_freeleech') && $Properties['FreeLeech'] != $CurFreeLeech) {
Torrents::freeleech_torrents($TorrentID, $Properties['FreeLeech'], $Properties['FreeLeechType']);
}
-$DB->query("SELECT GroupID, Time FROM torrents WHERE ID='$TorrentID'");
+$DB->query("
+ SELECT GroupID, Time
+ FROM torrents
+ WHERE ID = '$TorrentID'");
list($GroupID, $Time) = $DB->next_record();
// Competition
-if (strtotime($Time)>1241352173) {
+if (strtotime($Time) > 1241352173) {
if ($_POST['log_score'] == '100') {
- $DB->query("INSERT IGNORE into users_points (GroupID, UserID, Points) VALUES ('$GroupID', '$UserID', '1')");
+ $DB->query("
+ INSERT IGNORE into users_points (GroupID, UserID, Points)
+ VALUES ('$GroupID', '$UserID', '1')");
}
}
// End competiton
-$DB->query("SELECT LogScore FROM torrents WHERE ID = ".$TorrentID);
+$DB->query("
+ SELECT LogScore
+ FROM torrents
+ WHERE ID = $TorrentID");
list($LogScore) = $DB->next_record();
if ($Properties['Trumpable'] == 1 && $LogScore == 100) {
- $DB->query("UPDATE torrents SET LogScore = 99 WHERE ID = ".$TorrentID);
+ $DB->query("
+ UPDATE torrents
+ SET LogScore = 99
+ WHERE ID = $TorrentID");
$Results = array();
- $Results[] = "The original uploader has chosen to allow this log to be deducted one point for using EAC v0.95., -1 point [1]";
+ $Results[] = 'The original uploader has chosen to allow this log to be deducted one point for using EAC v0.95., -1 point [1]';
$Details = db_string(serialize($Results));
- $DB->query("UPDATE torrents_logs_new SET Score = 99, Details = '".$Details."' WHERE TorrentID = ".$TorrentID);
+ $DB->query("
+ UPDATE torrents_logs_new
+ SET Score = 99, Details = '$Details'
+ WHERE TorrentID = $TorrentID");
}
-$DB->query("SELECT Enabled FROM users_main WHERE ID =".$UserID);
+$DB->query("
+ SELECT Enabled
+ FROM users_main
+ WHERE ID = $UserID");
list($Enabled) = $DB->next_record();
if ($Properties['Trumpable'] == 0 && $LogScore == 99 && $Enabled == 1 && strtotime($Time) < 1284422400) {
- $DB->query("SELECT Log FROM torrents_logs_new WHERE TorrentID = ".$TorrentID);
+ $DB->query("
+ SELECT Log
+ FROM torrents_logs_new
+ WHERE TorrentID = $TorrentID");
list($Log) = $DB->next_record();
- if (strpos($Log, "EAC extraction") === 0) {
- $DB->query("UPDATE torrents SET LogScore = 100 WHERE ID = ".$TorrentID);
- $DB->query("UPDATE torrents_logs_new SET Score = 100, Details = '' WHERE TorrentID = ".$TorrentID);
+ if (strpos($Log, 'EAC extraction') === 0) {
+ $DB->query("
+ UPDATE torrents
+ SET LogScore = 100
+ WHERE ID = $TorrentID");
+ $DB->query("
+ UPDATE torrents_logs_new
+ SET Score = 100, Details = ''
+ WHERE TorrentID = $TorrentID");
}
}
-$DB->query("SELECT Name FROM torrents_group WHERE ID=$GroupID");
+$DB->query("
+ SELECT Name
+ FROM torrents_group
+ WHERE ID = $GroupID");
list($Name) = $DB->next_record(MYSQLI_NUM, false);
-Misc::write_log("Torrent $TorrentID ($Name) in group $GroupID was edited by ".$LoggedUser['Username']." (".$LogDetails.")"); // TODO: this is probably broken
+Misc::write_log("Torrent $TorrentID ($Name) in group $GroupID was edited by ".$LoggedUser['Username']." ($LogDetails)"); // TODO: this is probably broken
Torrents::write_group_log($GroupID, $TorrentID, $LoggedUser['ID'], $LogDetails, 0);
-$Cache->delete_value('torrents_details_'.$GroupID);
-$Cache->delete_value('torrent_download_'.$TorrentID);
+$Cache->delete_value("torrents_details_$GroupID");
+$Cache->delete_value("torrent_download_$TorrentID");
Torrents::update_hash($GroupID);
// All done!
diff --git a/sections/torrents/takemasspm.php b/sections/torrents/takemasspm.php
index a88fce9..9402e56 100644
--- a/sections/torrents/takemasspm.php
+++ b/sections/torrents/takemasspm.php
@@ -26,10 +26,10 @@ if (!check_perms('site_moderate_requests')) {
error(403);
}
-$Validate->SetFields('torrentid','1','number','Invalid torrent ID.',array('maxlength'=>1000000000, 'minlength'=>1)); // we shouldn't have torrent IDs higher than a billion
-$Validate->SetFields('groupid','1','number','Invalid group ID.',array('maxlength'=>1000000000, 'minlength'=>1)); // we shouldn't have group IDs higher than a billion either
-$Validate->SetFields('subject','0','string','Invalid subject.',array('maxlength'=>1000, 'minlength'=>1));
-$Validate->SetFields('message','0','string','Invalid message.',array('maxlength'=>10000, 'minlength'=>1));
+$Validate->SetFields('torrentid', '1', 'number', 'Invalid torrent ID.', array('maxlength' => 1000000000, 'minlength' => 1)); // we shouldn't have torrent IDs higher than a billion
+$Validate->SetFields('groupid', '1', 'number', 'Invalid group ID.', array('maxlength' => 1000000000, 'minlength' => 1)); // we shouldn't have group IDs higher than a billion either
+$Validate->SetFields('subject', '0', 'string', 'Invalid subject.', array('maxlength' => 1000, 'minlength' => 1));
+$Validate->SetFields('message', '0', 'string', 'Invalid message.', array('maxlength' => 10000, 'minlength' => 1));
$Err = $Validate->ValidateForm($_POST); // Validate the form
if ($Err) {
@@ -41,7 +41,10 @@ if ($Err) {
//******************************************************************************//
//--------------- Send PMs to users --------------------------------------------//
-$DB->query('SELECT uid FROM xbt_snatched WHERE fid='.$TorrentID);
+$DB->query("
+ SELECT uid
+ FROM xbt_snatched
+ WHERE fid = $TorrentID");
if ($DB->record_count() > 0) {
// Save this because send_pm uses $DB to run its own query... Oops...
diff --git a/sections/torrents/takenewgroup.php b/sections/torrents/takenewgroup.php
index 3835be1..6fb8ffd 100644
--- a/sections/torrents/takenewgroup.php
+++ b/sections/torrents/takenewgroup.php
@@ -48,12 +48,19 @@ if (empty($_POST['confirm'])) {
<?
View::show_footer();
} else {
- $DB->query("SELECT ArtistID, AliasID, Redirect, Name FROM artists_alias WHERE Name = '$ArtistName'");
+ $DB->query("
+ SELECT ArtistID, AliasID, Redirect, Name
+ FROM artists_alias
+ WHERE Name = '$ArtistName'");
if ($DB->record_count() == 0) {
$Redirect = 0;
- $DB->query("INSERT INTO artists_group (Name) VALUES ('$ArtistName')");
+ $DB->query("
+ INSERT INTO artists_group (Name)
+ VALUES ('$ArtistName')");
$ArtistID = $DB->inserted_id();
- $DB->query("INSERT INTO artists_alias (ArtistID, Name) VALUES ('$ArtistID', '$ArtistName')");
+ $DB->query("
+ INSERT INTO artists_alias (ArtistID, Name)
+ VALUES ('$ArtistID', '$ArtistName')");
$AliasID = $DB->inserted_id();
} else {
list($ArtistID, $AliasID, $Redirect, $ArtistName) = $DB->next_record();
@@ -62,22 +69,29 @@ if (empty($_POST['confirm'])) {
}
}
- $DB->query("INSERT INTO torrents_group
- (ArtistID, NumArtists, CategoryID, Name, Year, Time, WikiBody, WikiImage, SearchText)
+ $DB->query("
+ INSERT INTO torrents_group
+ (ArtistID, NumArtists, CategoryID, Name, Year, Time, WikiBody, WikiImage, SearchText)
VALUES
- ($ArtistID, '1', '1', '$Title', '$Year', '".sqltime()."', '', '', '$SearchText')");
+ ($ArtistID, '1', '1', '$Title', '$Year', '".sqltime()."', '', '', '$SearchText')");
$GroupID = $DB->inserted_id();
- $DB->query("INSERT INTO torrents_artists
- (GroupID, ArtistID, AliasID, Importance, UserID) VALUES
- ('$GroupID', '$ArtistID', '$AliasID', '1', '$LoggedUser[ID]')");
+ $DB->query("
+ INSERT INTO torrents_artists
+ (GroupID, ArtistID, AliasID, Importance, UserID)
+ VALUES
+ ('$GroupID', '$ArtistID', '$AliasID', '1', '$LoggedUser[ID]')");
- $DB->query("UPDATE torrents SET
- GroupID='$GroupID'
- WHERE ID='$TorrentID'");
+ $DB->query("
+ UPDATE torrents
+ SET GroupID = '$GroupID'
+ WHERE ID = '$TorrentID'");
// Delete old group if needed
- $DB->query("SELECT ID FROM torrents WHERE GroupID='$OldGroupID'");
+ $DB->query("
+ SELECT ID
+ FROM torrents
+ WHERE GroupID = '$OldGroupID'");
if ($DB->record_count() == 0) {
Torrents::delete_group($OldGroupID);
} else {
@@ -86,7 +100,7 @@ if (empty($_POST['confirm'])) {
Torrents::update_hash($GroupID);
- $Cache->delete_value('torrent_download_'.$TorrentID);
+ $Cache->delete_value("torrent_download_$TorrentID");
Misc::write_log("Torrent $TorrentID was edited by " . $LoggedUser['Username']);
diff --git a/sections/upload/generate_extra_torrents.php b/sections/upload/generate_extra_torrents.php
index c8650cd..c63e0ec 100644
--- a/sections/upload/generate_extra_torrents.php
+++ b/sections/upload/generate_extra_torrents.php
@@ -42,16 +42,24 @@ foreach ($ExtraTorrents as $ExtraTorrent) {
$ThisInsert['TotalSize'] = $ExtraTotalSize;
$Debug->set_flag('upload: torrent decoded');
- $DB->query("SELECT ID FROM torrents WHERE info_hash='" . db_string($ThisInsert['InfoHash']) . "'");
+ $DB->query("
+ SELECT ID
+ FROM torrents
+ WHERE info_hash = '" . db_string($ThisInsert['InfoHash']) . "'");
if ($DB->record_count() > 0) {
list($ExtraID) = $DB->next_record();
- $DB->query('SELECT TorrentID FROM torrents_files WHERE TorrentID = ' . $ExtraID);
+ $DB->query("
+ SELECT TorrentID
+ FROM torrents_files
+ WHERE TorrentID = $ExtraID");
if ($DB->record_count() > 0) {
- $Err = '<a href="torrents.php?torrentid=' . $ExtraID . '">The exact same torrent file already exists on the site!</a>';
+ $Err = "<a href=\"torrents.php?torrentid=$ExtraID\">The exact same torrent file already exists on the site!</a>";
} else {
//One of the lost torrents.
- $DB->query("INSERT INTO torrents_files (TorrentID, File) VALUES ($ExtraID, '$ThisInsert[TorEnc]')");
- $Err = "<a href=\"torrents.php?torrentid=$ExtraID\">Thank you for fixing this torrent</a>";
+ $DB->query("
+ INSERT INTO torrents_files (TorrentID, File)
+ VALUES ($ExtraID, '$ThisInsert[TorEnc]')");
+ $Err = "<a href=\"torrents.php?torrentid=$ExtraID\">Thank you for fixing this torrent.</a>";
}
}
}
diff --git a/sections/upload/upload.php b/sections/upload/upload.php
index 4ef7338..e2c1e27 100644
--- a/sections/upload/upload.php
+++ b/sections/upload/upload.php
@@ -9,8 +9,8 @@
// called again. //
//**********************************************************************//
-ini_set('max_file_uploads','100');
-View::show_header('Upload','upload,validate_upload,valid_tags,musicbrainz,multiformat_uploader');
+ini_set('max_file_uploads', '100');
+View::show_header('Upload', 'upload,validate_upload,valid_tags,musicbrainz,multiformat_uploader');
if (empty($Properties) && !empty($_GET['groupid']) && is_number($_GET['groupid'])) {
$DB->query('
@@ -27,7 +27,7 @@ if (empty($Properties) && !empty($_GET['groupid']) && is_number($_GET['groupid']
tg.VanityHouse
FROM torrents_group AS tg
LEFT JOIN torrents AS t ON t.GroupID = tg.ID
- WHERE tg.ID='.$_GET['groupid'].'
+ WHERE tg.ID = '.$_GET['groupid'].'
GROUP BY tg.ID');
if ($DB->record_count()) {
list($Properties) = $DB->to_array(false, MYSQLI_BOTH);
@@ -39,8 +39,8 @@ if (empty($Properties) && !empty($_GET['groupid']) && is_number($_GET['groupid']
SELECT
GROUP_CONCAT(tags.Name SEPARATOR ', ') AS TagList
FROM torrents_tags AS tt
- JOIN tags ON tags.ID=tt.TagID
- WHERE tt.GroupID='$_GET[groupid]'");
+ JOIN tags ON tags.ID = tt.TagID
+ WHERE tt.GroupID = '$_GET[groupid]'");
list($Properties['TagList']) = $DB->next_record();
} else {
@@ -61,9 +61,9 @@ if (empty($Properties) && !empty($_GET['groupid']) && is_number($_GET['groupid']
r.ReleaseType,
r.Image
FROM requests AS r
- WHERE r.ID='.$_GET['requestid']);
+ WHERE r.ID = '.$_GET['requestid']);
- list($Properties) = $DB->to_array(false,MYSQLI_BOTH);
+ list($Properties) = $DB->to_array(false, MYSQLI_BOTH);
$UploadForm = $Categories[$Properties['CategoryID'] - 1];
$Properties['CategoryName'] = $Categories[$Properties['CategoryID'] - 1];
$Properties['Artists'] = Requests::get_artists($_GET['requestid']);
@@ -84,7 +84,11 @@ if (!isset($Text)) {
$GenreTags = $Cache->get_value('genre_tags');
if (!$GenreTags) {
- $DB->query("SELECT Name FROM tags WHERE TagType='genre' ORDER BY Name");
+ $DB->query("
+ SELECT Name
+ FROM tags
+ WHERE TagType = 'genre'
+ ORDER BY Name");
$GenreTags = $DB->collect('Name');
$Cache->cache_value('genre_tags', $GenreTags, 3600 * 6);
}
@@ -100,7 +104,7 @@ $DNU = $DB->to_array();
list($Name, $Comment, $Updated) = reset($DNU);
reset($DNU);
$DB->query("
- SELECT IF(MAX(t.Time) < '$Updated' OR MAX(t.Time) IS NULL,1,0)
+ SELECT IF(MAX(t.Time) < '$Updated' OR MAX(t.Time) IS NULL, 1, 0)
FROM torrents AS t
WHERE UserID = ".$LoggedUser['ID']);
list($NewDNU) = $DB->next_record();
@@ -110,9 +114,9 @@ $HideDNU = check_perms('torrents_hide_dnu') && !$NewDNU;
<h3 id="dnu_header">Do not upload</h3>
<p><?=$NewDNU ? '<strong class="important_text">' : '' ?>Last updated: <?=time_diff($Updated)?><?=$NewDNU ? '</strong>' : '' ?></p>
<p>The following releases are currently forbidden from being uploaded to the site. Do not upload them unless your torrent meets a condition specified in the comment.
-<? if ($HideDNU) { ?>
+<? if ($HideDNU) { ?>
<span id="showdnu"><a href="#" onclick="$('#dnulist').gtoggle(); this.innerHTML = (this.innerHTML == 'Hide' ? 'Show' : 'Hide'); return false;" class="brackets">Show</a></span>
-<? } ?>
+<? } ?>
</p>
<table id="dnulist" class="<?=($HideDNU ? 'hidden' : '')?>">
<tr class="colhead">
diff --git a/sections/upload/upload_handle.php b/sections/upload/upload_handle.php
index 3ea2c41..60630f8 100644
--- a/sections/upload/upload_handle.php
+++ b/sections/upload/upload_handle.php
@@ -581,7 +581,7 @@ if (!$GroupID) {
foreach ($Artists as $Num => $Artist) {
$DB->query("
INSERT IGNORE INTO torrents_artists (GroupID, ArtistID, AliasID, UserID, Importance)
- VALUES ($GroupID, ".$Artist['id'].", ".$Artist['aliasid'].", ".$LoggedUser['ID'].", '$Importance')");
+ VALUES ($GroupID, ".$Artist['id'].', '.$Artist['aliasid'].', '.$LoggedUser['ID'].", '$Importance')");
$Cache->increment('stats_album_count');
}
}
@@ -591,13 +591,16 @@ if (!$GroupID) {
} else {
$DB->query("
UPDATE torrents_group
- SET Time='".sqltime()."'
- WHERE ID=$GroupID");
- $Cache->delete_value('torrent_group_'.$GroupID);
- $Cache->delete_value('torrents_details_'.$GroupID);
- $Cache->delete_value('detail_files_'.$GroupID);
+ SET Time = '".sqltime()."'
+ WHERE ID = $GroupID");
+ $Cache->delete_value("torrent_group_$GroupID");
+ $Cache->delete_value("torrents_details_$GroupID");
+ $Cache->delete_value("detail_files_$GroupID");
if ($Type == 'Music') {
- $DB->query("SELECT ReleaseType FROM torrents_group WHERE ID='$GroupID'");
+ $DB->query("
+ SELECT ReleaseType
+ FROM torrents_group
+ WHERE ID = '$GroupID'");
list($Properties['ReleaseType']) = $DB->next_record();
}
}
@@ -614,8 +617,8 @@ if (!$NoRevision) {
// Revision ID
$DB->query("
UPDATE torrents_group
- SET RevisionID='$RevisionID'
- WHERE ID=$GroupID");
+ SET RevisionID = '$RevisionID'
+ WHERE ID = $GroupID");
}
// Tags
@@ -630,7 +633,7 @@ if (!$Properties['GroupID']) {
(Name, UserID)
VALUES
('$Tag', $LoggedUser[ID])
- ON DUPLICATE KEY UPDATE Uses=Uses+1;
+ ON DUPLICATE KEY UPDATE Uses = Uses + 1;
");
$TagID = $DB->inserted_id();
@@ -639,7 +642,7 @@ if (!$Properties['GroupID']) {
(TagID, GroupID, UserID, PositiveVotes)
VALUES
($TagID, $GroupID, $LoggedUser[ID], 10)
- ON DUPLICATE KEY UPDATE PositiveVotes=PositiveVotes+1;
+ ON DUPLICATE KEY UPDATE PositiveVotes = PositiveVotes + 1;
");
}
}
@@ -654,8 +657,8 @@ $DB->query("
INSERT INTO torrents
(GroupID, UserID, Media, Format, Encoding,
Remastered, RemasterYear, RemasterTitle, RemasterRecordLabel, RemasterCatalogueNumber,
- Scene, HasLog, HasCue, info_hash, FileCount, FileList, FilePath, Size, Time,
- Description, LogScore, FreeTorrent, FreeLeechType)
+ Scene, HasLog, HasCue, info_hash, FileCount, FileList, FilePath,
+ Size, Time, Description, LogScore, FreeTorrent, FreeLeechType)
VALUES
($GroupID, $LoggedUser[ID], $T[Media], $T[Format], $T[Encoding], " .
"$T[Remastered], $T[RemasterYear], $T[RemasterTitle], $T[RemasterRecordLabel], $T[RemasterCatalogueNumber], " .
@@ -670,7 +673,7 @@ $Debug->set_flag('upload: ocelot updated');
// Prevent deletion of this torrent until the rest of the upload process is done
// (expire the key after 10 minutes to prevent locking it for too long in case there's a fatal error below)
-$Cache->cache_value('torrent_'.$TorrentID.'_lock', true, 600);
+$Cache->cache_value("torrent_{$TorrentID}_lock", true, 600);
//******************************************************************************//
//--------------- Write torrent file -------------------------------------------//
@@ -678,7 +681,7 @@ $Cache->cache_value('torrent_'.$TorrentID.'_lock', true, 600);
$DB->query("
INSERT INTO torrents_files (TorrentID, File)
VALUES ($TorrentID, '$TorEnc')");
-Misc::write_log("Torrent $TorrentID ($LogName) (".number_format($TotalSize / (1024 * 1024), 2)." MB) was uploaded by " . $LoggedUser['Username']);
+Misc::write_log("Torrent $TorrentID ($LogName) (".number_format($TotalSize / (1024 * 1024), 2).' MB) was uploaded by ' . $LoggedUser['Username']);
Torrents::write_group_log($GroupID, $TorrentID, $LoggedUser['ID'], 'uploaded ('.number_format($TotalSize / (1024 * 1024), 2).' MB)', 0);
Torrents::update_hash($GroupID);
@@ -722,8 +725,8 @@ if (trim($Properties['Image']) != '') {
if (count($RecentUploads) == 5) {
array_pop($RecentUploads);
}
- array_unshift($RecentUploads, array('ID'=>$GroupID, 'Name'=>trim($Properties['Title']), 'Artist'=>Artists::display_artists($ArtistForm, false, true), 'WikiImage'=>trim($Properties['Image'])));
- $Cache->cache_value('recent_uploads_'.$UserID, $RecentUploads, 0);
+ array_unshift($RecentUploads, array('ID' => $GroupID, 'Name' => trim($Properties['Title']), 'Artist' => Artists::display_artists($ArtistForm, false, true), 'WikiImage' => trim($Properties['Image'])));
+ $Cache->cache_value("recent_uploads_$UserID", $RecentUploads, 0);
} while (0);
}
}
@@ -732,8 +735,10 @@ if (trim($Properties['Image']) != '') {
//--------------- Contest ------------------------------------------------------//
if ($Properties['LibraryImage'] != '') {
$DB->query("
- INSERT INTO reportsv2 (ReporterID, TorrentID, Type, UserComment, Status, ReportedTime, Track, Image, ExtraID, Link)
- VALUES (0, $TorrentID, 'library', '".db_string(($Properties['MultiDisc'] ? 'Multi-disc' : ''))."', 'New', '".sqltime()."', '', '".db_string($Properties['LibraryImage'])."', '', '')");
+ INSERT INTO reportsv2
+ (ReporterID, TorrentID, Type, UserComment, Status, ReportedTime, Track, Image, ExtraID, Link)
+ VALUES
+ (0, $TorrentID, 'library', '".db_string(($Properties['MultiDisc'] ? 'Multi-disc' : ''))."', 'New', '".sqltime()."', '', '".db_string($Properties['LibraryImage'])."', '', '')");
}
//******************************************************************************//
@@ -778,7 +783,7 @@ if ($Type == 'Music') {
$Announce .= ' ['.$ReleaseTypes[$Properties['ReleaseType']].']';
}
$Announce .= ' - ';
- $Announce .= trim($Properties['Format'])." / ".trim($Properties['Bitrate']);
+ $Announce .= trim($Properties['Format']).' / '.trim($Properties['Bitrate']);
if ($HasLog == 1) {
$Announce .= ' / Log';
}
@@ -798,7 +803,7 @@ if ($Type == 'Music') {
}
$Title = $Announce;
-$AnnounceSSL = $Announce . " - https://".SSL_SITE_URL."/torrents.php?id=$GroupID / https://".SSL_SITE_URL."/torrents.php?action=download&id=$TorrentID";
+$AnnounceSSL = "$Announce - https://".SSL_SITE_URL."/torrents.php?id=$GroupID / https://".SSL_SITE_URL."/torrents.php?action=download&id=$TorrentID";
$Announce .= " - https://".SSL_SITE_URL."/torrents.php?id=$GroupID / https://".SSL_SITE_URL."/torrents.php?action=download&id=$TorrentID";
$AnnounceSSL .= ' - '.trim($Properties['TagList']);
@@ -844,8 +849,8 @@ $Item = $Feed->item($Title, $Text->strip_bbcode($Body), 'torrents.php?action=dow
$SQL = "
SELECT unf.ID, unf.UserID, torrent_pass
FROM users_notify_filters AS unf
- JOIN users_main AS um ON um.ID=unf.UserID
- WHERE um.Enabled='1'";
+ JOIN users_main AS um ON um.ID = unf.UserID
+ WHERE um.Enabled = '1'";
if (empty($ArtistsUnescaped)) {
$ArtistsUnescaped = $ArtistForm;
}
@@ -855,50 +860,49 @@ if (!empty($ArtistsUnescaped)) {
foreach ($ArtistsUnescaped as $Importance => $Artists) {
foreach ($Artists as $Artist) {
if ($Importance == 1 || $Importance == 4 || $Importance == 5 || $Importance == 6) {
- $ArtistNameList[] = "Artists LIKE '%|".db_string(str_replace('\\','\\\\',$Artist['name']), true)."|%'";
+ $ArtistNameList[] = "Artists LIKE '%|".db_string(str_replace('\\', '\\\\', $Artist['name']), true)."|%'";
} else {
- $GuestArtistNameList[] = "Artists LIKE '%|".db_string(str_replace('\\','\\\\',$Artist['name']), true)."|%'";
+ $GuestArtistNameList[] = "Artists LIKE '%|".db_string(str_replace('\\', '\\\\', $Artist['name']), true)."|%'";
}
}
}
// Don't add notification if >2 main artists or if tracked artist isn't a main artist
if (count($ArtistNameList) > 2 || $Artist['name'] == 'Various Artists') {
- $SQL.= " AND (ExcludeVA='0' AND (";
- $SQL.= implode(" OR ", array_merge($ArtistNameList,$GuestArtistNameList));
- $SQL.= " OR Artists='')) AND (";
+ $SQL .= " AND (ExcludeVA = '0' AND (";
+ $SQL .= implode(' OR ', array_merge($ArtistNameList, $GuestArtistNameList));
+ $SQL .= " OR Artists = '')) AND (";
} else {
- $SQL.= " AND (";
+ $SQL .= " AND (";
if (!empty($GuestArtistNameList)) {
- $SQL.= "(ExcludeVA='0' AND (";
- $SQL.= implode(" OR ", $GuestArtistNameList);
- $SQL.= ")) OR ";
+ $SQL .= "(ExcludeVA = '0' AND (";
+ $SQL .= implode(' OR ', $GuestArtistNameList);
+ $SQL .= ')) OR ';
}
- $SQL.= implode(" OR ", $ArtistNameList);
- $SQL.= " OR Artists='') AND (";
+ $SQL .= implode(' OR ', $ArtistNameList);
+ $SQL .= " OR Artists = '') AND (";
}
} else {
- $SQL.="AND (Artists='') AND (";
+ $SQL .= "AND (Artists = '') AND (";
}
-
reset($Tags);
$TagSQL = array();
$NotTagSQL = array();
foreach ($Tags as $Tag) {
- $TagSQL[]=" Tags LIKE '%|".db_string(trim($Tag))."|%' ";
- $NotTagSQL[]=" NotTags LIKE '%|".db_string(trim($Tag))."|%' ";
+ $TagSQL[] = " Tags LIKE '%|".db_string(trim($Tag))."|%' ";
+ $NotTagSQL[] = " NotTags LIKE '%|".db_string(trim($Tag))."|%' ";
}
-$TagSQL[]="Tags=''";
-$SQL.=implode(' OR ', $TagSQL);
+$TagSQL[] = "Tags = ''";
+$SQL .= implode(' OR ', $TagSQL);
-$SQL.= ") AND !(".implode(' OR ', $NotTagSQL).")";
+$SQL .= ") AND !(".implode(' OR ', $NotTagSQL).')';
-$SQL.=" AND (Categories LIKE '%|".db_string(trim($Type))."|%' OR Categories='') ";
+$SQL .= " AND (Categories LIKE '%|".db_string(trim($Type))."|%' OR Categories = '') ";
if ($Properties['ReleaseType']) {
- $SQL.=" AND (ReleaseTypes LIKE '%|".db_string(trim($ReleaseTypes[$Properties['ReleaseType']]))."|%' OR ReleaseTypes='') ";
+ $SQL .= " AND (ReleaseTypes LIKE '%|".db_string(trim($ReleaseTypes[$Properties['ReleaseType']]))."|%' OR ReleaseTypes = '') ";
} else {
- $SQL.=" AND (ReleaseTypes='') ";
+ $SQL .= " AND (ReleaseTypes = '') ";
}
/*
@@ -909,21 +913,21 @@ if ($Properties['ReleaseType']) {
if ($Properties['Format']) {
- $SQL.=" AND (Formats LIKE '%|".db_string(trim($Properties['Format']))."|%' OR Formats='') ";
+ $SQL .= " AND (Formats LIKE '%|".db_string(trim($Properties['Format']))."|%' OR Formats = '') ";
} else {
- $SQL.=" AND (Formats='') ";
+ $SQL .= " AND (Formats = '') ";
}
if ($_POST['bitrate']) {
- $SQL.=" AND (Encodings LIKE '%|".db_string(trim($_POST['bitrate']))."|%' OR Encodings='') ";
+ $SQL .= " AND (Encodings LIKE '%|".db_string(trim($_POST['bitrate']))."|%' OR Encodings = '') ";
} else {
- $SQL.=" AND (Encodings='') ";
+ $SQL .= " AND (Encodings = '') ";
}
if ($Properties['Media']) {
- $SQL.=" AND (Media LIKE '%|".db_string(trim($Properties['Media']))."|%' OR Media='') ";
+ $SQL .= " AND (Media LIKE '%|".db_string(trim($Properties['Media']))."|%' OR Media = '') ";
} else {
- $SQL.=" AND (Media='') ";
+ $SQL .= " AND (Media = '') ";
}
// Either they aren't using NewGroupsOnly
@@ -941,28 +945,31 @@ $SQL .= '))';
if ($Properties['Year'] && $Properties['RemasterYear']) {
- $SQL.=" AND (('".db_string(trim($Properties['Year']))."' BETWEEN FromYear AND ToYear)
+ $SQL .= " AND (('".db_string(trim($Properties['Year']))."' BETWEEN FromYear AND ToYear)
OR ('".db_string(trim($Properties['RemasterYear']))."' BETWEEN FromYear AND ToYear)
- OR (FromYear=0 AND ToYear=0)) ";
+ OR (FromYear = 0 AND ToYear = 0)) ";
} elseif ($Properties['Year'] || $Properties['RemasterYear']) {
- $SQL.=" AND (('".db_string(trim(Max($Properties['Year'],$Properties['RemasterYear'])))."' BETWEEN FromYear AND ToYear)
- OR (FromYear=0 AND ToYear=0)) ";
+ $SQL .= " AND (('".db_string(trim(Max($Properties['Year'],$Properties['RemasterYear'])))."' BETWEEN FromYear AND ToYear)
+ OR (FromYear = 0 AND ToYear = 0)) ";
} else {
- $SQL.=" AND (FromYear=0 AND ToYear=0) ";
+ $SQL .= " AND (FromYear = 0 AND ToYear = 0) ";
}
-$SQL.=" AND UserID != '".$LoggedUser['ID']."' ";
+$SQL .= " AND UserID != '".$LoggedUser['ID']."' ";
-$DB->query("SELECT Paranoia FROM users_main WHERE ID = $LoggedUser[ID]");
+$DB->query("
+ SELECT Paranoia
+ FROM users_main
+ WHERE ID = $LoggedUser[ID]");
list($Paranoia) = $DB->next_record();
$Paranoia = unserialize($Paranoia);
if (!is_array($Paranoia)) {
$Paranoia = array();
}
if (!in_array('notifications', $Paranoia)) {
- $SQL.=" AND (Users LIKE '%|".$LoggedUser['ID']."|%' OR Users = '') ";
+ $SQL .= " AND (Users LIKE '%|".$LoggedUser['ID']."|%' OR Users = '') ";
}
-$SQL.=" AND UserID != '".$LoggedUser['ID']."' ";
+$SQL .= " AND UserID != '".$LoggedUser['ID']."' ";
$DB->query($SQL);
$Debug->set_flag('upload: notification query finished');
@@ -976,17 +983,17 @@ if ($DB->record_count() > 0) {
$Rows = array();
foreach ($UserArray as $User) {
list($FilterID, $UserID, $Passkey) = $User;
- $Rows[]="('$UserID', '$GroupID', '$TorrentID', '$FilterID')";
- $Feed->populate('torrents_notify_'.$Passkey,$Item);
- $Cache->delete_value('notifications_new_'.$UserID);
+ $Rows[] = "('$UserID', '$GroupID', '$TorrentID', '$FilterID')";
+ $Feed->populate("torrents_notify_$Passkey", $Item);
+ $Cache->delete_value("notifications_new_$UserID");
}
- $InsertSQL.=implode(',', $Rows);
+ $InsertSQL .= implode(',', $Rows);
$DB->query($InsertSQL);
$Debug->set_flag('upload: notification inserts finished');
foreach ($FilterArray as $Filter) {
list($FilterID, $UserID, $Passkey) = $Filter;
- $Feed->populate('torrents_notify_'.$FilterID.'_'.$Passkey,$Item);
+ $Feed->populate("torrents_notify_{$FilterID}_$Passkey", $Item);
}
}
@@ -997,50 +1004,50 @@ $DB->query("
JOIN bookmarks_torrents AS b ON b.UserID = u.ID
WHERE b.GroupID = $GroupID");
while (list($UserID, $Passkey) = $DB->next_record()) {
- $Feed->populate('torrents_bookmarks_t_'.$Passkey, $Item);
+ $Feed->populate("torrents_bookmarks_t_$Passkey", $Item);
}
-$Feed->populate('torrents_all',$Item);
+$Feed->populate('torrents_all', $Item);
$Debug->set_flag('upload: notifications handled');
if ($Type == 'Music') {
- $Feed->populate('torrents_music',$Item);
+ $Feed->populate('torrents_music', $Item);
if ($Properties['Media'] == 'Vinyl') {
- $Feed->populate('torrents_vinyl',$Item);
+ $Feed->populate('torrents_vinyl', $Item);
}
if ($Properties['Bitrate'] == 'Lossless') {
- $Feed->populate('torrents_lossless',$Item);
+ $Feed->populate('torrents_lossless', $Item);
}
if ($Properties['Bitrate'] == '24bit Lossless') {
- $Feed->populate('torrents_lossless24',$Item);
+ $Feed->populate('torrents_lossless24', $Item);
}
if ($Properties['Format'] == 'MP3') {
- $Feed->populate('torrents_mp3',$Item);
+ $Feed->populate('torrents_mp3', $Item);
}
if ($Properties['Format'] == 'FLAC') {
- $Feed->populate('torrents_flac',$Item);
+ $Feed->populate('torrents_flac', $Item);
}
}
if ($Type == 'Applications') {
- $Feed->populate('torrents_apps',$Item);
+ $Feed->populate('torrents_apps', $Item);
}
if ($Type == 'E-Books') {
- $Feed->populate('torrents_ebooks',$Item);
+ $Feed->populate('torrents_ebooks', $Item);
}
if ($Type == 'Audiobooks') {
- $Feed->populate('torrents_abooks',$Item);
+ $Feed->populate('torrents_abooks', $Item);
}
if ($Type == 'E-Learning Videos') {
- $Feed->populate('torrents_evids',$Item);
+ $Feed->populate('torrents_evids', $Item);
}
if ($Type == 'Comedy') {
- $Feed->populate('torrents_comedy',$Item);
+ $Feed->populate('torrents_comedy', $Item);
}
if ($Type == 'Comics') {
- $Feed->populate('torrents_comics',$Item);
+ $Feed->populate('torrents_comics', $Item);
}
-// Clear Cache
-$Cache->delete_value('torrents_details_'.$GroupID);
+// Clear cache
+$Cache->delete_value("torrents_details_$GroupID");
// Allow deletion of this torrent now
-$Cache->delete_value('torrent_'.$TorrentID.'_lock');
+$Cache->delete_value("torrent_{$TorrentID}_lock");
diff --git a/sections/user/edit.php b/sections/user/edit.php
index 6d7ba4c..56ef992 100644
--- a/sections/user/edit.php
+++ b/sections/user/edit.php
@@ -201,11 +201,11 @@ echo $Val->GenerateJS('userform');
<div id="sortable_container" style="display: none;">
<a href="#" id="reset_sortable" class="brackets">Reset to default</a>
<ul class="sortable_list" id="sortable">
-<?Users::release_order()?>
+<?Users::release_order($SiteOptions)?>
</ul>
<p><small>Note: Checked items will be hidden.</small></p>
<script type="text/javascript" id="sortable_default">//<![CDATA[
- var sortable_list_default = <?=Users::release_order_default_js()?>;
+ var sortable_list_default = <?=Users::release_order_default_js($SiteOptions)?>;
//]]>
</script>
</div>
@@ -255,37 +255,37 @@ echo $Val->GenerateJS('userform');
<td>
<ul class="options_list nobullet">
<li>
- <input type="checkbox" name="showtfilter" id="showtfilter"<?=(!isset($SiteOptions['ShowTorFilter']) || $SiteOptions['ShowTorFilter'] ? ' checked="checked"' : '')?>/>
+ <input type="checkbox" name="showtfilter" id="showtfilter"<?=(!isset($SiteOptions['ShowTorFilter']) || $SiteOptions['ShowTorFilter'] ? ' checked="checked"' : '')?> />
<label for="showtfilter">Show filter controls</label>
</li>
<li>
- <input type="checkbox" name="showtags" id="showtags"<?Format::selected('ShowTags', 1, 'checked', $SiteOptions);?>/>
+ <input type="checkbox" name="showtags" id="showtags"<? Format::selected('ShowTags', 1, 'checked', $SiteOptions); ?>/>
<label for="showtags">Show filters for official tags</label>
</li>
</ul>
</td>
</tr>
<tr>
- <td class="label"><strong>Auto Complete</strong></td>
+ <td class="label"><strong>Auto completion</strong></td>
<td>
<select name="autocomplete">
- <option value="0" <? if (empty($SiteOptions['AutoComplete'])) { ?> selected="selected" <? } ?>>Everywhere</option>
- <option value="2" <? if ($SiteOptions['AutoComplete'] === 2) { ?>selected="selected" <? } ?>>Searches Only</option>
- <option value="1" <? if ($SiteOptions['AutoComplete'] === 1) { ?>selected="selected" <? } ?>>Disable</option>
+ <option value="0"<? if (empty($SiteOptions['AutoComplete'])) { ?> selected="selected"<? } ?>>Everywhere</option>
+ <option value="2"<? if ($SiteOptions['AutoComplete'] === 2) { ?> selected="selected"<? } ?>>Searches only</option>
+ <option value="1"<? if ($SiteOptions['AutoComplete'] === 1) { ?> selected="selected"<? } ?>>Disable</option>
</select>
</td>
</tr>
<tr>
<td class="label"><strong>Voting links</strong></td>
<td>
- <input type="checkbox" name="novotelinks" id="novotelinks" <? if (!empty($SiteOptions['NoVoteLinks'])) { ?>checked="checked" <? } ?>/>
+ <input type="checkbox" name="novotelinks" id="novotelinks"<? if (!empty($SiteOptions['NoVoteLinks'])) { ?> checked="checked"<? } ?> />
<label for="novotelinks">Disable voting links on artist pages, collages, and snatched lists</label>
</td>
</tr>
<tr>
<td class="label"><strong>Download torrents as text files</strong></td>
<td>
- <input type="checkbox" name="downloadalt" id="downloadalt" <? if ($DownloadAlt) { ?>checked="checked" <? } ?>/>
+ <input type="checkbox" name="downloadalt" id="downloadalt"<? if ($DownloadAlt) { ?> checked="checked"<? } ?> />
<label for="downloadalt">For users whose ISP blocks the downloading of torrent files</label>
</td>
</tr>
@@ -348,7 +348,7 @@ echo $Val->GenerateJS('userform');
<tr>
<td class="label"><strong>Auto-save text</strong></td>
<td>
- <input type="checkbox" name="disableautosave" id="disableautosave" <? if (!empty($SiteOptions['DisableAutoSave'])) { ?>checked="checked" <? } ?>/>
+ <input type="checkbox" name="disableautosave" id="disableautosave"<? if (!empty($SiteOptions['DisableAutoSave'])) { ?> checked="checked"<? } ?> />
<label for="disableautosave">Disable reply text from being saved automatically when changing pages in a thread</label>
</td>
</tr>
diff --git a/sections/user/takeedit.php b/sections/user/takeedit.php
index 811a069..195a093 100644
--- a/sections/user/takeedit.php
+++ b/sections/user/takeedit.php
@@ -218,7 +218,7 @@ $Options['DisableAutoSave'] = (!empty($_POST['disableautosave']) ? 1 : 0);
$Options['NoVoteLinks'] = (!empty($_POST['novotelinks']) ? 1 : 0);
$Options['CoverArt'] = (int) !empty($_POST['coverart']);
$Options['ShowExtraCovers'] = (int) !empty($_POST['show_extra_covers']);
-$Options['AutoComplete'] = (int) $_POST['autocomplete'];
+$Options['AutoComplete'] = (int) $_POST['autocomplete'];
if (isset($LoggedUser['DisableFreeTorrentTop10'])) {
$Options['DisableFreeTorrentTop10'] = $LoggedUser['DisableFreeTorrentTop10'];
diff --git a/sections/userhistory/catchup.php b/sections/userhistory/catchup.php
index 240cc9a..daf3293 100644
--- a/sections/userhistory/catchup.php
+++ b/sections/userhistory/catchup.php
@@ -1,17 +1,21 @@
<?
authorize();
if (($UserSubscriptions = $Cache->get_value('subscriptions_user_'.$LoggedUser['ID'])) === false) {
- $DB->query('SELECT TopicID FROM users_subscriptions WHERE UserID = '.db_string($LoggedUser['ID']));
+ $DB->query('
+ SELECT TopicID
+ FROM users_subscriptions
+ WHERE UserID = '.db_string($LoggedUser['ID']));
if ($UserSubscriptions = $DB->collect(0)) {
- $Cache->cache_value('subscriptions_user_'.$LoggedUser['ID'],$UserSubscriptions,0);
+ $Cache->cache_value('subscriptions_user_'.$LoggedUser['ID'], $UserSubscriptions, 0);
}
}
if (!empty($UserSubscriptions)) {
- $DB->query("INSERT INTO forums_last_read_topics (UserID, TopicID, PostID)
- SELECT '$LoggedUser[ID]', ID, LastPostID FROM
- forums_topics
- WHERE ID IN (".implode(',',$UserSubscriptions).")
- ON DUPLICATE KEY UPDATE PostID=LastPostID");
+ $DB->query("
+ INSERT INTO forums_last_read_topics (UserID, TopicID, PostID)
+ SELECT '$LoggedUser[ID]', ID, LastPostID
+ FROM forums_topics
+ WHERE ID IN (".implode(',', $UserSubscriptions).')
+ ON DUPLICATE KEY UPDATE PostID = LastPostID');
}
$Cache->delete_value('subscriptions_user_new_'.$LoggedUser['ID']);
header('Location: userhistory.php?action=subscriptions');
diff --git a/sections/userhistory/collage_subscribe.php b/sections/userhistory/collage_subscribe.php
index bcd5660..d31a067 100644
--- a/sections/userhistory/collage_subscribe.php
+++ b/sections/userhistory/collage_subscribe.php
@@ -9,20 +9,30 @@ if (!is_number($_GET['collageid'])) {
$CollageID = (int) $_GET['collageid'];
if (!$UserSubscriptions = $Cache->get_value('collage_subs_user_'.$LoggedUser['ID'])) {
- $DB->query('SELECT CollageID FROM users_collage_subs WHERE UserID = '.db_string($LoggedUser['ID']));
+ $DB->query('
+ SELECT CollageID
+ FROM users_collage_subs
+ WHERE UserID = '.db_string($LoggedUser['ID']));
$UserSubscriptions = $DB->collect(0);
- $Cache->cache_value('collage_subs_user_'.$LoggedUser['ID'],$UserSubscriptions,0);
+ $Cache->cache_value('collage_subs_user_'.$LoggedUser['ID'], $UserSubscriptions, 0);
}
if (($Key = array_search($CollageID, $UserSubscriptions)) !== false) {
- $DB->query('DELETE FROM users_collage_subs WHERE UserID = '.db_string($LoggedUser['ID']).' AND CollageID = '.$CollageID);
+ $DB->query('
+ DELETE FROM users_collage_subs
+ WHERE UserID = '.db_string($LoggedUser['ID'])."
+ AND CollageID = $CollageID");
unset($UserSubscriptions[$Key]);
Collages::decrease_subscriptions($CollageID);
} else {
- $DB->query("INSERT IGNORE INTO users_collage_subs (UserID, CollageID, LastVisit) VALUES ($LoggedUser[ID], ".$CollageID.", NOW())");
+ $DB->query("
+ INSERT IGNORE INTO users_collage_subs
+ (UserID, CollageID, LastVisit)
+ VALUES
+ ($LoggedUser[ID], $CollageID, NOW())");
array_push($UserSubscriptions, $CollageID);
Collages::increase_subscriptions($CollageID);
}
$Cache->replace_value('collage_subs_user_'.$LoggedUser['ID'], $UserSubscriptions, 0);
$Cache->delete_value('collage_subs_user_new_'.$LoggedUser['ID']);
-$Cache->delete_value('collage_'.$CollageID);
+$Cache->delete_value("collage_$CollageID");
diff --git a/sections/userhistory/email_history.php b/sections/userhistory/email_history.php
index e598494..3df1397 100644
--- a/sections/userhistory/email_history.php
+++ b/sections/userhistory/email_history.php
@@ -19,8 +19,8 @@ if (!is_number($UserID)) {
$DB->query("
SELECT ui.JoinDate, p.Level AS Class
FROM users_main AS um
- JOIN users_info AS ui ON um.ID=ui.UserID
- JOIN permissions AS p ON p.ID=um.PermissionID
+ JOIN users_info AS ui ON um.ID = ui.UserID
+ JOIN permissions AS p ON p.ID = um.PermissionID
WHERE um.ID = $UserID");
list($Joined, $Class) = $DB->next_record();
@@ -30,7 +30,10 @@ if (!check_perms('users_view_email', $Class)) {
$UsersOnly = $_GET['usersonly'];
-$DB->query("SELECT Username FROM users_main WHERE ID = ".$UserID);
+$DB->query("
+ SELECT Username
+ FROM users_main
+ WHERE ID = $UserID");
list($Username)= $DB->next_record();
View::show_header("Email history for $Username");
@@ -44,7 +47,8 @@ if ($UsersOnly == 1) {
FROM users_main AS u
LEFT JOIN users_main AS u2 ON u2.Email = u.Email AND u2.ID != '$UserID'
LEFT JOIN geoip_country AS c ON INET_ATON(u.IP) BETWEEN c.StartIP AND c.EndIP
- WHERE u.ID='$UserID' AND u2.ID > 0
+ WHERE u.ID = '$UserID'
+ AND u2.ID > 0
UNION
SELECT
h.Email,
@@ -52,9 +56,11 @@ if ($UsersOnly == 1) {
h.IP,
c.Code
FROM users_history_emails AS h
- LEFT JOIN users_history_emails AS h2 ON h2.email=h.email and h2.UserID != '$UserID'
+ LEFT JOIN users_history_emails AS h2 ON h2.email = h.email and h2.UserID != '$UserID'
LEFT JOIN geoip_country AS c ON INET_ATON(h.IP) BETWEEN c.StartIP AND c.EndIP
- WHERE h.UserID='$UserID' AND h2.UserID>0"/*AND Time != '0000-00-00 00:00:00'*/."
+ WHERE h.UserID = '$UserID'
+ AND h2.UserID > 0"
+ /*AND Time != '0000-00-00 00:00:00'*/."
ORDER BY Time DESC");
} else {
$DB->query("
@@ -65,7 +71,7 @@ if ($UsersOnly == 1) {
c.Code
FROM users_main AS u
LEFT JOIN geoip_country AS c ON INET_ATON(u.IP) BETWEEN c.StartIP AND c.EndIP
- WHERE u.ID='$UserID'
+ WHERE u.ID = '$UserID'
UNION
SELECT
h.Email,
@@ -74,7 +80,8 @@ if ($UsersOnly == 1) {
c.Code
FROM users_history_emails AS h
LEFT JOIN geoip_country AS c ON INET_ATON(h.IP) BETWEEN c.StartIP AND c.EndIP
- WHERE UserID='$UserID' "/*AND Time != '0000-00-00 00:00:00'*/."
+ WHERE UserID = '$UserID' "
+ /*AND Time != '0000-00-00 00:00:00'*/."
ORDER BY Time DESC");
}
$History = $DB->to_array();
@@ -124,8 +131,12 @@ foreach ($History as $Key => $Values) {
<td />
<td><?=time_diff($Time)?></td>
<td><?=display_str($IP)?></td>
-<? $UserURL = "https://".SSL_SITE_URL."/user.php?id=$UserID2";
- $DB->query("SELECT Enabled FROM users_main WHERE ID = ".$UserID2);
+<?
+ $UserURL = 'https://'.SSL_SITE_URL."/user.php?id=$UserID2";
+ $DB->query("
+ SELECT Enabled
+ FROM users_main
+ WHERE ID = $UserID2");
list($Enabled) = $DB->next_record();
$DB->set_query_id($ueQuery);
?>
diff --git a/sections/userhistory/email_history2.php b/sections/userhistory/email_history2.php
index b650769..8660132 100644
--- a/sections/userhistory/email_history2.php
+++ b/sections/userhistory/email_history2.php
@@ -20,8 +20,8 @@ $DB->query("
ui.JoinDate,
p.Level AS Class
FROM users_main AS um
- JOIN users_info AS ui ON um.ID=ui.UserID
- JOIN permissions AS p ON p.ID=um.PermissionID
+ JOIN users_info AS ui ON um.ID = ui.UserID
+ JOIN permissions AS p ON p.ID = um.PermissionID
WHERE um.ID = $UserID");
list($Joined, $Class) = $DB->next_record();
@@ -31,7 +31,10 @@ if (!check_perms('users_view_email', $Class)) {
$UsersOnly = $_GET['usersonly'];
-$DB->query("SELECT Username FROM users_main WHERE ID = ".$UserID);
+$DB->query("
+ SELECT Username
+ FROM users_main
+ WHERE ID = $UserID");
list($Username)= $DB->next_record();
View::show_header("Email history for $Username");
@@ -49,10 +52,11 @@ $DB->query("
GROUP_CONCAT(i.Donor SEPARATOR '|') AS UsersDonor,
GROUP_CONCAT(i.Warned SEPARATOR '|') AS UsersWarned
FROM users_main AS m
- LEFT JOIN users_history_emails AS h ON h.Email=m.Email AND h.UserID != m.ID
- LEFT JOIN users_main AS m2 ON m2.ID=h.UserID
- LEFT JOIN users_info AS i ON i.UserID=h.UserID
- WHERE m.ID='$UserID'"
+ LEFT JOIN users_history_emails AS h ON h.Email = m.Email
+ AND h.UserID != m.ID
+ LEFT JOIN users_main AS m2 ON m2.ID = h.UserID
+ LEFT JOIN users_info AS i ON i.UserID = h.UserID
+ WHERE m.ID = '$UserID'"
);
$CurrentEmail = array_shift($DB->to_array());
@@ -70,10 +74,11 @@ $DB->query("
i2.Donor AS UsersDonor,
i2.Warned AS UsersWarned
FROM users_history_emails AS h2
- LEFT JOIN users_history_emails AS h3 ON h3.Email=h2.Email AND h3.UserID != h2.UserID
- LEFT JOIN users_main AS m3 ON m3.ID=h3.UserID
- LEFT JOIN users_info AS i2 ON i2.UserID=h3.UserID
- WHERE h2.UserID='$UserID'
+ LEFT JOIN users_history_emails AS h3 ON h3.Email = h2.Email
+ AND h3.UserID != h2.UserID
+ LEFT JOIN users_main AS m3 ON m3.ID = h3.UserID
+ LEFT JOIN users_info AS i2 ON i2.UserID = h3.UserID
+ WHERE h2.UserID = '$UserID'
ORDER BY Time DESC"
);
$History = $DB->to_array();
@@ -107,7 +112,9 @@ if (count($History) == 1) {
$Invite['EndTime'] = $Joined;
$Invite['AccountAge'] = date(time() + time() - strtotime($Joined)); // Same as EndTime but without ' ago'
$Invite['IP'] = $History[0]['IP'];
- if ($Current['StartTime'] == '0000-00-00 00:00:00') { $Current['StartTime'] = $Joined; }
+ if ($Current['StartTime'] == '0000-00-00 00:00:00') {
+ $Current['StartTime'] = $Joined;
+ }
} else {
foreach ($History as $Key => $Val) {
if ($History[$Key + 1]['Time'] == '0000-00-00 00:00:00' && $Val['Time'] != '0000-00-00 00:00:00') {
@@ -281,12 +288,12 @@ if ($Old) {
<td>Start</td>
<td>End</td>
<td>Age of account</td>
- <td>Signup IP</td>
+ <td>Registration IP address</td>
</tr>
<?
// Matches on invite email
if ($OldMatches) {
- $i=0;
+ $i = 0;
ob_start();
foreach ($OldMatches as $Match) {
if ($Match['Email'] == $Invite['Email']) {
diff --git a/sections/userhistory/ip_history.php b/sections/userhistory/ip_history.php
index 5f635f7..e773b21 100644
--- a/sections/userhistory/ip_history.php
+++ b/sections/userhistory/ip_history.php
@@ -22,8 +22,8 @@ $DB->query("
um.Username,
p.Level AS Class
FROM users_main AS um
- LEFT JOIN permissions AS p ON p.ID=um.PermissionID
- WHERE um.ID = ".$UserID);
+ LEFT JOIN permissions AS p ON p.ID = um.PermissionID
+ WHERE um.ID = $UserID");
list($Username, $Class) = $DB->next_record();
if (!check_perms('users_view_ips', $Class)) {
@@ -41,7 +41,7 @@ View::show_header("IP address history for $Username");
?>
<script type="text/javascript">//<![CDATA[
function ShowIPs(rowname) {
- $('tr[name="'+rowname+'"]').gtoggle();
+ $('tr[name="' + rowname + '"]').gtoggle();
}
function Ban(ip, id, elemID) {
@@ -49,16 +49,16 @@ function Ban(ip, id, elemID) {
if (notes != null && notes.length > 0) {
var xmlhttp;
if (window.XMLHttpRequest) {
- xmlhttp=new XMLHttpRequest();
+ xmlhttp = new XMLHttpRequest();
} else {
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
+ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById(elemID).innerHTML = "<strong>[Banned]</strong>";
}
}
- xmlhttp.open("GET","tools.php?action=quick_ban&perform=create&ip=" + ip + "&notes=" + notes,true);
+ xmlhttp.open("GET", "tools.php?action=quick_ban&perform=create&ip=" + ip + "&notes=" + notes, true);
xmlhttp.send();
}
@@ -67,17 +67,17 @@ function Ban(ip, id, elemID) {
function UnBan(ip, id, elemID) {
var xmlhttp;
if (window.XMLHttpRequest) {
- xmlhttp=new XMLHttpRequest();
+ xmlhttp = new XMLHttpRequest();
} else {
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
+ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
- xmlhttp.onreadystatechange=function() {
+ xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById(elemID).innerHTML = "Ban";
document.getElementById(elemID).onclick = function() { Ban(ip, id, elemID); return false; };
}
}
- xmlhttp.open("GET","tools.php?action=quick_ban&perform=delete&id=" + id + "&ip=" + ip,true);
+ xmlhttp.open("GET","tools.php?action=quick_ban&perform=delete&id=" + id + "&ip=" + ip, true);
xmlhttp.send();
}
*/
@@ -101,11 +101,11 @@ if ($UsersOnly == 1) {
GROUP_CONCAT(ui2.Donor SEPARATOR '|'),
GROUP_CONCAT(ui2.Warned SEPARATOR '|')
FROM users_history_ips AS h1
- LEFT JOIN users_history_ips AS h2 ON h2.IP=h1.IP AND h2.UserID!=$UserID
- LEFT JOIN users_main AS um2 ON um2.ID=h2.UserID
- LEFT JOIN users_info AS ui2 ON ui2.UserID=h2.UserID
- WHERE h1.UserID='$UserID'
- AND h2.UserID>0 $SearchIPQuery
+ LEFT JOIN users_history_ips AS h2 ON h2.IP = h1.IP AND h2.UserID != $UserID
+ LEFT JOIN users_main AS um2 ON um2.ID = h2.UserID
+ LEFT JOIN users_info AS ui2 ON ui2.UserID = h2.UserID
+ WHERE h1.UserID = '$UserID'
+ AND h2.UserID > 0 $SearchIPQuery
GROUP BY h1.IP, h1.StartTime
ORDER BY h1.StartTime DESC
LIMIT $Limit");
@@ -124,15 +124,15 @@ if ($UsersOnly == 1) {
GROUP_CONCAT(ui2.Donor SEPARATOR '|'),
GROUP_CONCAT(ui2.Warned SEPARATOR '|')
FROM users_history_ips AS h1
- LEFT JOIN users_history_ips AS h2 ON h2.IP=h1.IP AND h2.UserID!=$UserID
- LEFT JOIN users_main AS um2 ON um2.ID=h2.UserID
- LEFT JOIN users_info AS ui2 ON ui2.UserID=h2.UserID
- WHERE h1.UserID='$UserID' $SearchIPQuery
+ LEFT JOIN users_history_ips AS h2 ON h2.IP = h1.IP AND h2.UserID != $UserID
+ LEFT JOIN users_main AS um2 ON um2.ID = h2.UserID
+ LEFT JOIN users_info AS ui2 ON ui2.UserID = h2.UserID
+ WHERE h1.UserID = '$UserID' $SearchIPQuery
GROUP BY h1.IP, h1.StartTime
ORDER BY h1.StartTime DESC
LIMIT $Limit");
}
-$DB->query("SELECT FOUND_ROWS()");
+$DB->query('SELECT FOUND_ROWS()');
list($NumResults) = $DB->next_record();
$DB->set_query_id($RS);
@@ -204,7 +204,11 @@ foreach ($Results as $Index => $Result) {
<?=$IP?> (<?=Tools::get_country_code_by_ajax($IP)?>)<?
if ($CanManageIPBans) {
if (!isset($IPs[$IP])) {
- $sql = "SELECT ID, FromIP, ToIP FROM ip_bans WHERE '".Tools::ip_to_unsigned($IP)."' BETWEEN FromIP AND ToIP LIMIT 1";
+ $sql = "
+ SELECT ID, FromIP, ToIP
+ FROM ip_bans
+ WHERE '".Tools::ip_to_unsigned($IP)."' BETWEEN FromIP AND ToIP
+ LIMIT 1";
$DB->query($sql);
if ($DB->record_count() > 0) {
@@ -215,7 +219,7 @@ foreach ($Results as $Index => $Result) {
} else {
$IPs[$IP] = false;
?>
- <a id="<?=$counter?>" href="#" onclick="Ban('<?=$IP?>', '<?=$ID?>', '<?=$counter?>'); this.onclick=null;return false;" class="brackets">Ban</a>
+ <a id="<?=$counter?>" href="#" onclick="Ban('<?=$IP?>', '<?=$ID?>', '<?=$counter?>'); this.onclick = null; return false;" class="brackets">Ban</a>
<?
}
$counter++;
diff --git a/sections/userhistory/ip_tracker_history.php b/sections/userhistory/ip_tracker_history.php
index eecc159..0ae829f 100644
--- a/sections/userhistory/ip_tracker_history.php
+++ b/sections/userhistory/ip_tracker_history.php
@@ -25,8 +25,8 @@ $DB->query("
SELECT um.Username,
p.Level AS Class
FROM users_main AS um
- LEFT JOIN permissions AS p ON p.ID=um.PermissionID
- WHERE um.ID = ".$UserID);
+ LEFT JOIN permissions AS p ON p.ID = um.PermissionID
+ WHERE um.ID = $UserID");
list($Username, $Class) = $DB->next_record();
if (!check_perms('users_view_ips', $Class)) {
@@ -35,7 +35,7 @@ if (!check_perms('users_view_ips', $Class)) {
$UsersOnly = $_GET['usersonly'];
-View::show_header("Tracker IP history for $Username");
+View::show_header("Tracker IP address history for $Username");
?>
<script type="text/javascript">
function ShowIPs(rowname) {
@@ -53,7 +53,7 @@ $TrackerIps = $DB->query("
ORDER BY tstamp DESC
LIMIT $Limit");
-$DB->query("SELECT FOUND_ROWS()");
+$DB->query('SELECT FOUND_ROWS()');
list($NumResults) = $DB->next_record();
$DB->set_query_id($TrackerIps);
diff --git a/sections/userhistory/post_history.php b/sections/userhistory/post_history.php
index f5a689b..8030e70 100644
--- a/sections/userhistory/post_history.php
+++ b/sections/userhistory/post_history.php
@@ -26,7 +26,7 @@ list($Page, $Limit) = Format::page_limit($PerPage);
$UserInfo = Users::user_info($UserID);
extract(array_intersect_key($UserInfo, array_flip(array('Username', 'Enabled', 'Title', 'Avatar', 'Donor', 'Warned'))));
-View::show_header('Post history for '.$Username,'subscriptions,comments,bbcode');
+View::show_header("Post history for $Username", 'subscriptions,comments,bbcode');
if ($LoggedUser['CustomForums']) {
unset($LoggedUser['CustomForums']['']);
@@ -44,40 +44,40 @@ if ($ShowGrouped) {
FROM forums_posts AS p
LEFT JOIN forums_topics AS t ON t.ID = p.TopicID';
if ($ShowUnread) {
- $sql.='
+ $sql .= '
LEFT JOIN forums_last_read_topics AS l ON l.TopicID = t.ID AND l.UserID = '.$LoggedUser['ID'];
}
- $sql .= '
+ $sql .= "
LEFT JOIN forums AS f ON f.ID = t.ForumID
- WHERE p.AuthorID = '.$UserID.'
- AND ((f.MinClassRead <= '.$LoggedUser['Class'];
+ WHERE p.AuthorID = $UserID
+ AND ((f.MinClassRead <= ".$LoggedUser['Class'];
if (!empty($RestrictedForums)) {
- $sql.='
- AND f.ID NOT IN (\''.$RestrictedForums.'\')';
+ $sql .= "
+ AND f.ID NOT IN ('$RestrictedForums')";
}
$sql .= ')';
if (!empty($PermittedForums)) {
- $sql.='
- OR f.ID IN (\''.$PermittedForums.'\')';
+ $sql .= "
+ OR f.ID IN ('$PermittedForums')";
}
$sql .= ')';
if ($ShowUnread) {
$sql .= '
- AND ((t.IsLocked=\'0\' OR t.IsSticky=\'1\')
- AND (l.PostID<t.LastPostID OR l.PostID IS NULL))';
+ AND ((t.IsLocked = \'0\' OR t.IsSticky = \'1\')
+ AND (l.PostID < t.LastPostID OR l.PostID IS NULL))';
}
- $sql .= '
+ $sql .= "
GROUP BY t.ID
ORDER BY p.ID DESC
- LIMIT '.$Limit;
+ LIMIT $Limit";
$PostIDs = $DB->query($sql);
- $DB->query("SELECT FOUND_ROWS()");
+ $DB->query('SELECT FOUND_ROWS()');
list($Results) = $DB->next_record();
if ($Results > $PerPage * ($Page - 1)) {
$DB->set_query_id($PostIDs);
$PostIDs = $DB->collect('ID');
- $sql = '
+ $sql = "
SELECT
p.ID,
p.AddedTime,
@@ -97,16 +97,21 @@ if ($ShowGrouped) {
LEFT JOIN users_main AS ed ON ed.ID = p.EditedUserID
JOIN forums_topics AS t ON t.ID = p.TopicID
JOIN forums AS f ON f.ID = t.ForumID
- LEFT JOIN forums_last_read_topics AS l ON l.UserID = '.$UserID.' AND l.TopicID = t.ID
- WHERE p.ID IN ('.implode(',',$PostIDs).')
+ LEFT JOIN forums_last_read_topics AS l ON l.UserID = $UserID
+ AND l.TopicID = t.ID
+ WHERE p.ID IN (".implode(',', $PostIDs).')
ORDER BY p.ID DESC';
$Posts = $DB->query($sql);
}
} else {
$sql = '
- SELECT SQL_CALC_FOUND_ROWS';
+ SELECT
+ SQL_CALC_FOUND_ROWS';
if ($ShowGrouped) {
- $sql.=' * FROM (SELECT';
+ $sql .= '
+ *
+ FROM (
+ SELECT';
}
$sql .= '
p.ID,
@@ -122,7 +127,7 @@ if ($ShowGrouped) {
$sql .= '
l.PostID AS LastRead,';
}
- $sql .= '
+ $sql .= "
t.IsLocked,
t.IsSticky
FROM forums_posts as p
@@ -131,26 +136,27 @@ if ($ShowGrouped) {
LEFT JOIN users_main AS ed ON ed.ID = p.EditedUserID
JOIN forums_topics AS t ON t.ID = p.TopicID
JOIN forums AS f ON f.ID = t.ForumID
- LEFT JOIN forums_last_read_topics AS l ON l.UserID = '.$UserID.' AND l.TopicID = t.ID
- WHERE p.AuthorID = '.$UserID.'
- AND ((f.MinClassRead <= '.$LoggedUser['Class'];
+ LEFT JOIN forums_last_read_topics AS l ON l.UserID = $UserID
+ AND l.TopicID = t.ID
+ WHERE p.AuthorID = $UserID
+ AND ((f.MinClassRead <= ".$LoggedUser['Class'];
if (!empty($RestrictedForums)) {
- $sql.='
- AND f.ID NOT IN (\''.$RestrictedForums.'\')';
+ $sql .= "
+ AND f.ID NOT IN ('$RestrictedForums')";
}
$sql .= ')';
if (!empty($PermittedForums)) {
- $sql.='
- OR f.ID IN (\''.$PermittedForums.'\')';
+ $sql .= "
+ OR f.ID IN ('$PermittedForums')";
}
$sql .= ')';
if ($ShowUnread) {
- $sql.='
- AND ( (t.IsLocked=\'0\' OR t.IsSticky=\'1\')
- AND (l.PostID<t.LastPostID OR l.PostID IS NULL)
+ $sql .= '
+ AND ( (t.IsLocked = \'0\' OR t.IsSticky = \'1\')
+ AND (l.PostID < t.LastPostID OR l.PostID IS NULL)
) ';
}
@@ -158,16 +164,16 @@ if ($ShowGrouped) {
ORDER BY p.ID DESC';
if ($ShowGrouped) {
- $sql.='
- ) AS sub
+ $sql .= '
+ ) AS sub
GROUP BY TopicID
ORDER BY ID DESC';
}
- $sql.=' LIMIT '.$Limit;
+ $sql .= " LIMIT $Limit";
$Posts = $DB->query($sql);
- $DB->query("SELECT FOUND_ROWS()");
+ $DB->query('SELECT FOUND_ROWS()');
list($Results) = $DB->next_record();
$DB->set_query_id($Posts);
@@ -194,9 +200,12 @@ if ($ShowGrouped) {
<?
if ($ViewingOwn) {
if (($UserSubscriptions = $Cache->get_value('subscriptions_user_'.$LoggedUser['ID'])) === false) {
- $DB->query("SELECT TopicID FROM users_subscriptions WHERE UserID = '$LoggedUser[ID]'");
+ $DB->query("
+ SELECT TopicID
+ FROM users_subscriptions
+ WHERE UserID = '$LoggedUser[ID]'");
$UserSubscriptions = $DB->collect(0);
- $Cache->cache_value('subscriptions_user_'.$LoggedUser['ID'],$UserSubscriptions,0);
+ $Cache->cache_value('subscriptions_user_'.$LoggedUser['ID'], $UserSubscriptions, 0);
$DB->set_query_id($Posts);
}
diff --git a/sections/userhistory/subscribed_collages.php b/sections/userhistory/subscribed_collages.php
index 9910a2c..cb9ecbf 100644
--- a/sections/userhistory/subscribed_collages.php
+++ b/sections/userhistory/subscribed_collages.php
@@ -23,8 +23,8 @@ if (!$ShowAll) {
FROM collages AS c
JOIN users_collage_subs AS s ON s.CollageID = c.ID
JOIN collages_torrents AS ct ON ct.CollageID = c.ID
- WHERE s.UserID=$LoggedUser[ID] AND c.Deleted='0'
- AND ct.AddedOn>s.LastVisit
+ WHERE s.UserID = $LoggedUser[ID] AND c.Deleted = '0'
+ AND ct.AddedOn > s.LastVisit
GROUP BY c.ID";
} else {
$sql = "
@@ -36,7 +36,7 @@ if (!$ShowAll) {
FROM collages AS c
JOIN users_collage_subs AS s ON s.CollageID = c.ID
LEFT JOIN collages_torrents AS ct ON ct.CollageID = c.ID
- WHERE s.UserID=$LoggedUser[ID] AND c.Deleted='0'
+ WHERE s.UserID = $LoggedUser[ID] AND c.Deleted = '0'
GROUP BY c.ID";
}
@@ -82,10 +82,12 @@ if (!$NumResults) {
unset($TorrentTable);
list($CollageID, $CollageName, $CollageSize, $LastVisit) = $Collage;
- $RS = $DB->query("SELECT GroupID FROM collages_torrents
- WHERE CollageID=$CollageID
- AND AddedOn>'" . db_string($LastVisit) . "'
- ORDER BY AddedOn");
+ $RS = $DB->query("
+ SELECT GroupID
+ FROM collages_torrents
+ WHERE CollageID = $CollageID
+ AND AddedOn > '" . db_string($LastVisit) . "'
+ ORDER BY AddedOn");
$NewTorrentCount = $DB->record_count();
//$NewTorrents = $DB->to_array();
//$Artists = Artists::get_artists($GroupID);
@@ -104,7 +106,7 @@ if (!$NumResults) {
// foreach ($NewTorrents as $TorrentGroup) {
// list($GroupID, $GroupName, $GroupYear, $ReleaseType, $RecordLabel, $CatalogueNumber, $WikiImage) = $TorrentGroup;
// $DisplayName = Artists::display_artists($Artists[$GroupID]);
- // $AltName=$GroupName;
+ // $AltName = $GroupName;
foreach ($TorrentList as $GroupID => $Group) {
extract(Torrents::array_group($Group));
@@ -117,11 +119,11 @@ if (!$NumResults) {
unset($ExtendedArtists[3]);
$DisplayName .= Artists::display_artists($ExtendedArtists);
} elseif (count($Artists) > 0) {
- $DisplayName .= Artists::display_artists(array('1'=>$Artists));
+ $DisplayName .= Artists::display_artists(array('1' => $Artists));
}
- $DisplayName .= '<a href="torrents.php?id='.$GroupID.'" title="View Torrent">'.$GroupName.'</a>';
+ $DisplayName .= "<a href=\"torrents.php?id=$GroupID\" title=\"View Torrent\">$GroupName</a>";
if ($GroupYear > 0) {
- $DisplayName = $DisplayName. " [$GroupYear]";
+ $DisplayName = "$DisplayName [$GroupYear]";
}
if ($GroupVanityHouse) {
$DisplayName .= ' [<abbr title="This is a Vanity House release">VH</abbr>]';
@@ -168,8 +170,13 @@ if (!$NumResults) {
}
$SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
- if ($Torrent['RemasterTitle'] != $LastRemasterTitle || $Torrent['RemasterYear'] != $LastRemasterYear ||
- $Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel || $Torrent['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber || $FirstUnknown || $Torrent['Media'] != $LastMedia) {
+ if ($Torrent['RemasterTitle'] != $LastRemasterTitle
+ || $Torrent['RemasterYear'] != $LastRemasterYear
+ || $Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel
+ || $Torrent['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber
+ || $FirstUnknown
+ || $Torrent['Media'] != $LastMedia
+ ) {
$EditionID++;
?>
<tr class="group_torrent groupid_<?=$CollageID . $GroupID?> edition<?=$SnatchedGroupClass?> hidden">
@@ -202,13 +209,13 @@ if (!$NumResults) {
list($TorrentID, $Torrent) = each($Torrents);
- $DisplayName = '<a href="torrents.php?id='.$GroupID.'" title="View Torrent">'.$GroupName.'</a>';
+ $DisplayName = "<a href=\"torrents.php?id=$GroupID\" title=\"View Torrent\">$GroupName</a>";
if ($Torrent['IsSnatched']) {
- $DisplayName .=' ' . Format::torrent_label('Snatched!');
+ $DisplayName .= ' ' . Format::torrent_label('Snatched!');
}
if (!empty($Torrent['FreeTorrent'])) {
- $DisplayName .=' ' . Format::torrent_label('Freeleech!');
+ $DisplayName .= ' ' . Format::torrent_label('Freeleech!');
}
$SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
?>
@@ -257,20 +264,21 @@ if (!$NumResults) {
</tr>
</table>
<!--</div>-->
- <table class="torrent_table<?=$ShowAll?' hidden':''?>" id="discog_table_<?=$CollageID?>">
- <tr class="colhead">
- <td width="1%"><!-- expand/collapse --></td>
- <td width="70%"><strong>Torrents</strong></td>
- <td>Size</td>
- <td class="sign"><img src="static/styles/<?=$LoggedUser['StyleName'] ?>/images/snatched.png" alt="Snatches" title="Snatches" /></td>
- <td class="sign"><img src="static/styles/<?=$LoggedUser['StyleName'] ?>/images/seeders.png" alt="Seeders" title="Seeders" /></td>
- <td class="sign"><img src="static/styles/<?=$LoggedUser['StyleName'] ?>/images/leechers.png" alt="Leechers" title="Leechers" /></td>
- </tr>
+ <table class="torrent_table<?=$ShowAll ? ' hidden' : ''?>" id="discog_table_<?=$CollageID?>">
+ <tr class="colhead">
+ <td width="1%"><!-- expand/collapse --></td>
+ <td width="70%"><strong>Torrents</strong></td>
+ <td>Size</td>
+ <td class="sign"><img src="static/styles/<?=$LoggedUser['StyleName'] ?>/images/snatched.png" alt="Snatches" title="Snatches" /></td>
+ <td class="sign"><img src="static/styles/<?=$LoggedUser['StyleName'] ?>/images/seeders.png" alt="Seeders" title="Seeders" /></td>
+ <td class="sign"><img src="static/styles/<?=$LoggedUser['StyleName'] ?>/images/leechers.png" alt="Leechers" title="Leechers" /></td>
+ </tr>
<?=$TorrentTable?>
- </table>
-<? } // foreach () ?>
+ </table>
<?
-} // else -- if (empty($NumResults)) ?>
+ } // foreach ()
+} // else -- if (empty($NumResults))
+?>
</div>
<?
diff --git a/sections/userhistory/thread_subscribe.php b/sections/userhistory/thread_subscribe.php
index 1a87a44..8da4efe 100644
--- a/sections/userhistory/thread_subscribe.php
+++ b/sections/userhistory/thread_subscribe.php
@@ -11,23 +11,39 @@ if (!is_number($_GET['topicid'])) {
}
require(SERVER_ROOT.'/sections/forums/index.php');
-$DB->query('SELECT ID FROM forums WHERE forums.ID = (SELECT ForumID FROM forums_topics WHERE ID = '.db_string($_GET['topicid']).')');
+$DB->query('
+ SELECT ID
+ FROM forums
+ WHERE forums.ID =
+ (
+ SELECT ForumID
+ FROM forums_topics
+ WHERE ID = '.db_string($_GET['topicid']).'
+ )');
list($ForumID) = $DB->next_record();
if (!check_forumperm($ForumID)) {
die();
}
if (!$UserSubscriptions = $Cache->get_value('subscriptions_user_'.$LoggedUser['ID'])) {
- $DB->query('SELECT TopicID FROM users_subscriptions WHERE UserID = '.db_string($LoggedUser['ID']));
+ $DB->query('
+ SELECT TopicID
+ FROM users_subscriptions
+ WHERE UserID = '.db_string($LoggedUser['ID']));
$UserSubscriptions = $DB->collect(0);
- $Cache->cache_value('subscriptions_user_'.$LoggedUser['ID'],$UserSubscriptions,0);
+ $Cache->cache_value('subscriptions_user_'.$LoggedUser['ID'], $UserSubscriptions, 0);
}
-if (($Key = array_search($_GET['topicid'],$UserSubscriptions)) !== false) {
- $DB->query('DELETE FROM users_subscriptions WHERE UserID = '.db_string($LoggedUser['ID']).' AND TopicID = '.db_string($_GET['topicid']));
+if (($Key = array_search($_GET['topicid'], $UserSubscriptions)) !== false) {
+ $DB->query('
+ DELETE FROM users_subscriptions
+ WHERE UserID = '.db_string($LoggedUser['ID']).'
+ AND TopicID = '.db_string($_GET['topicid']));
unset($UserSubscriptions[$Key]);
} else {
- $DB->query("INSERT IGNORE INTO users_subscriptions (UserID, TopicID) VALUES ($LoggedUser[ID], ".db_string($_GET['topicid']).")");
+ $DB->query("
+ INSERT IGNORE INTO users_subscriptions (UserID, TopicID)
+ VALUES ($LoggedUser[ID], ".db_string($_GET['topicid']).")");
array_push($UserSubscriptions, $_GET['topicid']);
}
$Cache->replace_value('subscriptions_user_'.$LoggedUser['ID'], $UserSubscriptions, 0);
diff --git a/sections/userhistory/token_history.php b/sections/userhistory/token_history.php
index 08e1161..837acde 100644
--- a/sections/userhistory/token_history.php
+++ b/sections/userhistory/token_history.php
@@ -37,14 +37,17 @@ if (isset($_GET['expire'])) {
if (!is_number($UserID) || !is_number($TorrentID)) {
error(403);
}
- $DB->query("SELECT info_hash FROM torrents where ID = $TorrentID");
+ $DB->query("
+ SELECT info_hash
+ FROM torrents
+ WHERE ID = $TorrentID");
if (list($InfoHash) = $DB->next_record(MYSQLI_NUM, FALSE)) {
$DB->query("
UPDATE users_freeleeches
- SET Expired=TRUE
- WHERE UserID=$UserID
- AND TorrentID=$TorrentID");
- $Cache->delete_value('users_tokens_'.$UserID);
+ SET Expired = TRUE
+ WHERE UserID = $UserID
+ AND TorrentID = $TorrentID");
+ $Cache->delete_value("users_tokens_$UserID");
Tracker::update_tracker('remove_token', array('info_hash' => rawurlencode($InfoHash), 'userid' => $UserID));
}
header("Location: userhistory.php?action=token_history&userid=$UserID");
@@ -74,7 +77,7 @@ $DB->query("
LIMIT $Limit");
$Tokens = $DB->to_array();
-$DB->query("SELECT FOUND_ROWS()");
+$DB->query('SELECT FOUND_ROWS()');
list($NumResults) = $DB->next_record();
$Pages = Format::get_pages($Page, $NumResults, 25);
@@ -90,7 +93,7 @@ $Pages = Format::get_pages($Page, $NumResults, 25);
<td>Expired</td>
<? if (check_perms('users_mod')) { ?>
<td>Downloaded</td>
- <td>Tokens Used</td>
+ <td>Tokens used</td>
<? } ?>
</tr>
<?
@@ -109,20 +112,21 @@ foreach ($Tokens as $Token) {
$Name = $ArtistName.$Name;
}
if ($Format && $Encoding) {
- $Name.=" [$Format / $Encoding]";
+ $Name .= " [$Format / $Encoding]";
}
?>
<tr class="<?=($i ? 'rowa' : 'rowb')?>">
<td><?=$Name?></td>
<td><?=time_diff($Time)?></td>
- <td><?=($Expired ? 'Yes' : 'No')?><?=(check_perms('users_mod') && !$Expired)?" <a href=\"userhistory.php?action=token_history&amp;expire=1&amp;userid=$UserID&amp;torrentid=$TorrentID\">(expire)</a>":''?>
+ <td><?=($Expired ? 'Yes' : 'No')?><?=(check_perms('users_mod') && !$Expired) ? " <a href=\"userhistory.php?action=token_history&amp;expire=1&amp;userid=$UserID&amp;torrentid=$TorrentID\">(expire)</a>" : ''; ?>
</td>
<? if (check_perms('users_mod')) { ?>
<td><?=Format::get_size($Downloaded)?></td>
<td><?=$Uses?></td>
<? } ?>
</tr>
-<? }
+<?
+}
?>
</table>
<div class="linkbox"><?=$Pages?></div>
diff --git a/static/functions/bbcode_sandbox.js b/static/functions/bbcode_sandbox.js
new file mode 100644
index 0000000..fa10253
--- /dev/null
+++ b/static/functions/bbcode_sandbox.js
@@ -0,0 +1,14 @@
+$(document).ready(function() {
+ $("#sandbox").keyup(function() {
+ $.ajax({
+ type : "POST",
+ dataType : "html",
+ url : "ajax.php?action=preview",
+ data : {
+ "body" : $(this).val()
+ }
+ }).done(function(response) {
+ $("#preview").html(response);
+ });
+ });
+}); \ No newline at end of file
diff --git a/static/functions/jquery-ui.js b/static/functions/jquery-ui.js
index aa7a923..4262890 100644
--- a/static/functions/jquery-ui.js
+++ b/static/functions/jquery-ui.js
@@ -1,6 +1,6 @@
-/*! jQuery UI - v1.9.1 - 2012-10-25
+/*! jQuery UI - v1.10.3 - 2013-07-03
* http://jqueryui.com
-* Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.position.js, jquery.ui.accordion.js, jquery.ui.autocomplete.js, jquery.ui.button.js, jquery.ui.datepicker.js, jquery.ui.dialog.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.effect.js, jquery.ui.effect-blind.js, jquery.ui.effect-bounce.js, jquery.ui.effect-clip.js, jquery.ui.effect-drop.js, jquery.ui.effect-explode.js, jquery.ui.effect-fade.js, jquery.ui.effect-fold.js, jquery.ui.effect-highlight.js, jquery.ui.effect-pulsate.js, jquery.ui.effect-scale.js, jquery.ui.effect-shake.js, jquery.ui.effect-slide.js, jquery.ui.effect-transfer.js, jquery.ui.menu.js, jquery.ui.progressbar.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.slider.js, jquery.ui.sortable.js, jquery.ui.spinner.js, jquery.ui.tabs.js, jquery.ui.tooltip.js
-* Copyright (c) 2012 jQuery Foundation and other contributors Licensed MIT */
+* Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.position.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.ui.tooltip.js
+* Copyright 2013 jQuery Foundation and other contributors Licensed MIT */
-(function(e,t){function i(t,n){var r,i,o,u=t.nodeName.toLowerCase();return"area"===u?(r=t.parentNode,i=r.name,!t.href||!i||r.nodeName.toLowerCase()!=="map"?!1:(o=e("img[usemap=#"+i+"]")[0],!!o&&s(o))):(/input|select|textarea|button|object/.test(u)?!t.disabled:"a"===u?t.href||n:n)&&s(t)}function s(t){return e.expr.filters.visible(t)&&!e(t).parents().andSelf().filter(function(){return e.css(this,"visibility")==="hidden"}).length}var n=0,r=/^ui-id-\d+$/;e.ui=e.ui||{};if(e.ui.version)return;e.extend(e.ui,{version:"1.9.1",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}}),e.fn.extend({_focus:e.fn.focus,focus:function(t,n){return typeof t=="number"?this.each(function(){var r=this;setTimeout(function(){e(r).focus(),n&&n.call(r)},t)}):this._focus.apply(this,arguments)},scrollParent:function(){var t;return e.ui.ie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?t=this.parents().filter(function(){return/(relative|absolute|fixed)/.test(e.css(this,"position"))&&/(auto|scroll)/.test(e.css(this,"overflow")+e.css(this,"overflow-y")+e.css(this,"overflow-x"))}).eq(0):t=this.parents().filter(function(){return/(auto|scroll)/.test(e.css(this,"overflow")+e.css(this,"overflow-y")+e.css(this,"overflow-x"))}).eq(0),/fixed/.test(this.css("position"))||!t.length?e(document):t},zIndex:function(n){if(n!==t)return this.css("zIndex",n);if(this.length){var r=e(this[0]),i,s;while(r.length&&r[0]!==document){i=r.css("position");if(i==="absolute"||i==="relative"||i==="fixed"){s=parseInt(r.css("zIndex"),10);if(!isNaN(s)&&s!==0)return s}r=r.parent()}}return 0},uniqueId:function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++n)})},removeUniqueId:function(){return this.each(function(){r.test(this.id)&&e(this).removeAttr("id")})}}),e("<a>").outerWidth(1).jquery||e.each(["Width","Height"],function(n,r){function u(t,n,r,s){return e.each(i,function(){n-=parseFloat(e.css(t,"padding"+this))||0,r&&(n-=parseFloat(e.css(t,"border"+this+"Width"))||0),s&&(n-=parseFloat(e.css(t,"margin"+this))||0)}),n}var i=r==="Width"?["Left","Right"]:["Top","Bottom"],s=r.toLowerCase(),o={innerWidth:e.fn.innerWidth,innerHeight:e.fn.innerHeight,outerWidth:e.fn.outerWidth,outerHeight:e.fn.outerHeight};e.fn["inner"+r]=function(n){return n===t?o["inner"+r].call(this):this.each(function(){e(this).css(s,u(this,n)+"px")})},e.fn["outer"+r]=function(t,n){return typeof t!="number"?o["outer"+r].call(this,t):this.each(function(){e(this).css(s,u(this,t,!0,n)+"px")})}}),e.extend(e.expr[":"],{data:e.expr.createPseudo?e.expr.createPseudo(function(t){return function(n){return!!e.data(n,t)}}):function(t,n,r){return!!e.data(t,r[3])},focusable:function(t){return i(t,!isNaN(e.attr(t,"tabindex")))},tabbable:function(t){var n=e.attr(t,"tabindex"),r=isNaN(n);return(r||n>=0)&&i(t,!r)}}),e(function(){var t=document.body,n=t.appendChild(n=document.createElement("div"));n.offsetHeight,e.extend(n.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0}),e.support.minHeight=n.offsetHeight===100,e.support.selectstart="onselectstart"in n,t.removeChild(n).style.display="none"}),function(){var t=/msie ([\w.]+)/.exec(navigator.userAgent.toLowerCase())||[];e.ui.ie=t.length?!0:!1,e.ui.ie6=parseFloat(t[1],10)===6}(),e.fn.extend({disableSelection:function(){return this.bind((e.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(e){e.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),e.extend(e.ui,{plugin:{add:function(t,n,r){var i,s=e.ui[t].prototype;for(i in r)s.plugins[i]=s.plugins[i]||[],s.plugins[i].push([n,r[i]])},call:function(e,t,n){var r,i=e.plugins[t];if(!i||!e.element[0].parentNode||e.element[0].parentNode.nodeType===11)return;for(r=0;r<i.length;r++)e.options[i[r][0]]&&i[r][1].apply(e.element,n)}},contains:e.contains,hasScroll:function(t,n){if(e(t).css("overflow")==="hidden")return!1;var r=n&&n==="left"?"scrollLeft":"scrollTop",i=!1;return t[r]>0?!0:(t[r]=1,i=t[r]>0,t[r]=0,i)},isOverAxis:function(e,t,n){return e>t&&e<t+n},isOver:function(t,n,r,i,s,o){return e.ui.isOverAxis(t,r,s)&&e.ui.isOverAxis(n,i,o)}})})(jQuery);(function(e,t){var n=0,r=Array.prototype.slice,i=e.cleanData;e.cleanData=function(t){for(var n=0,r;(r=t[n])!=null;n++)try{e(r).triggerHandler("remove")}catch(s){}i(t)},e.widget=function(t,n,r){var i,s,o,u,a=t.split(".")[0];t=t.split(".")[1],i=a+"-"+t,r||(r=n,n=e.Widget),e.expr[":"][i.toLowerCase()]=function(t){return!!e.data(t,i)},e[a]=e[a]||{},s=e[a][t],o=e[a][t]=function(e,t){if(!this._createWidget)return new o(e,t);arguments.length&&this._createWidget(e,t)},e.extend(o,s,{version:r.version,_proto:e.extend({},r),_childConstructors:[]}),u=new n,u.options=e.widget.extend({},u.options),e.each(r,function(t,i){e.isFunction(i)&&(r[t]=function(){var e=function(){return n.prototype[t].apply(this,arguments)},r=function(e){return n.prototype[t].apply(this,e)};return function(){var t=this._super,n=this._superApply,s;return this._super=e,this._superApply=r,s=i.apply(this,arguments),this._super=t,this._superApply=n,s}}())}),o.prototype=e.widget.extend(u,{widgetEventPrefix:u.widgetEventPrefix||t},r,{constructor:o,namespace:a,widgetName:t,widgetBaseClass:i,widgetFullName:i}),s?(e.each(s._childConstructors,function(t,n){var r=n.prototype;e.widget(r.namespace+"."+r.widgetName,o,n._proto)}),delete s._childConstructors):n._childConstructors.push(o),e.widget.bridge(t,o)},e.widget.extend=function(n){var i=r.call(arguments,1),s=0,o=i.length,u,a;for(;s<o;s++)for(u in i[s])a=i[s][u],i[s].hasOwnProperty(u)&&a!==t&&(e.isPlainObject(a)?n[u]=e.isPlainObject(n[u])?e.widget.extend({},n[u],a):e.widget.extend({},a):n[u]=a);return n},e.widget.bridge=function(n,i){var s=i.prototype.widgetFullName;e.fn[n]=function(o){var u=typeof o=="string",a=r.call(arguments,1),f=this;return o=!u&&a.length?e.widget.extend.apply(null,[o].concat(a)):o,u?this.each(function(){var r,i=e.data(this,s);if(!i)return e.error("cannot call methods on "+n+" prior to initialization; "+"attempted to call method '"+o+"'");if(!e.isFunction(i[o])||o.charAt(0)==="_")return e.error("no such method '"+o+"' for "+n+" widget instance");r=i[o].apply(i,a);if(r!==i&&r!==t)return f=r&&r.jquery?f.pushStack(r.get()):r,!1}):this.each(function(){var t=e.data(this,s);t?t.option(o||{})._init():new i(o,this)}),f}},e.Widget=function(){},e.Widget._childConstructors=[],e.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{disabled:!1,create:null},_createWidget:function(t,r){r=e(r||this.defaultElement||this)[0],this.element=e(r),this.uuid=n++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=e.widget.extend({},this.options,this._getCreateOptions(),t),this.bindings=e(),this.hoverable=e(),this.focusable=e(),r!==this&&(e.data(r,this.widgetName,this),e.data(r,this.widgetFullName,this),this._on(this.element,{remove:function(e){e.target===r&&this.destroy()}}),this.document=e(r.style?r.ownerDocument:r.document||r),this.window=e(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:e.noop,_getCreateEventData:e.noop,_create:e.noop,_init:e.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(e.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled "+"ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:e.noop,widget:function(){return this.element},option:function(n,r){var i=n,s,o,u;if(arguments.length===0)return e.widget.extend({},this.options);if(typeof n=="string"){i={},s=n.split("."),n=s.shift();if(s.length){o=i[n]=e.widget.extend({},this.options[n]);for(u=0;u<s.length-1;u++)o[s[u]]=o[s[u]]||{},o=o[s[u]];n=s.pop();if(r===t)return o[n]===t?null:o[n];o[n]=r}else{if(r===t)return this.options[n]===t?null:this.options[n];i[n]=r}}return this._setOptions(i),this},_setOptions:function(e){var t;for(t in e)this._setOption(t,e[t]);return this},_setOption:function(e,t){return this.options[e]=t,e==="disabled"&&(this.widget().toggleClass(this.widgetFullName+"-disabled ui-state-disabled",!!t).attr("aria-disabled",t),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")),this},enable:function(){return this._setOption("disabled",!1)},disable:function(){return this._setOption("disabled",!0)},_on:function(t,n){var r,i=this;n?(t=r=e(t),this.bindings=this.bindings.add(t)):(n=t,t=this.element,r=this.widget()),e.each(n,function(n,s){function o(){if(i.options.disabled===!0||e(this).hasClass("ui-state-disabled"))return;return(typeof s=="string"?i[s]:s).apply(i,arguments)}typeof s!="string"&&(o.guid=s.guid=s.guid||o.guid||e.guid++);var u=n.match(/^(\w+)\s*(.*)$/),a=u[1]+i.eventNamespace,f=u[2];f?r.delegate(f,a,o):t.bind(a,o)})},_off:function(e,t){t=(t||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.unbind(t).undelegate(t)},_delay:function(e,t){function n(){return(typeof e=="string"?r[e]:e).apply(r,arguments)}var r=this;return setTimeout(n,t||0)},_hoverable:function(t){this.hoverable=this.hoverable.add(t),this._on(t,{mouseenter:function(t){e(t.currentTarget).addClass("ui-state-hover")},mouseleave:function(t){e(t.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(t){this.focusable=this.focusable.add(t),this._on(t,{focusin:function(t){e(t.currentTarget).addClass("ui-state-focus")},focusout:function(t){e(t.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(t,n,r){var i,s,o=this.options[t];r=r||{},n=e.Event(n),n.type=(t===this.widgetEventPrefix?t:this.widgetEventPrefix+t).toLowerCase(),n.target=this.element[0],s=n.originalEvent;if(s)for(i in s)i in n||(n[i]=s[i]);return this.element.trigger(n,r),!(e.isFunction(o)&&o.apply(this.element[0],[n].concat(r))===!1||n.isDefaultPrevented())}},e.each({show:"fadeIn",hide:"fadeOut"},function(t,n){e.Widget.prototype["_"+t]=function(r,i,s){typeof i=="string"&&(i={effect:i});var o,u=i?i===!0||typeof i=="number"?n:i.effect||n:t;i=i||{},typeof i=="number"&&(i={duration:i}),o=!e.isEmptyObject(i),i.complete=s,i.delay&&r.delay(i.delay),o&&e.effects&&(e.effects.effect[u]||e.uiBackCompat!==!1&&e.effects[u])?r[t](i):u!==t&&r[u]?r[u](i.duration,i.easing,s):r.queue(function(n){e(this)[t](),s&&s.call(r[0]),n()})}}),e.uiBackCompat!==!1&&(e.Widget.prototype._getCreateOptions=function(){return e.metadata&&e.metadata.get(this.element[0])[this.widgetName]})})(jQuery);(function(e,t){var n=!1;e(document).mouseup(function(e){n=!1}),e.widget("ui.mouse",{version:"1.9.1",options:{cancel:"input,textarea,button,select,option",distance:1,delay:0},_mouseInit:function(){var t=this;this.element.bind("mousedown."+this.widgetName,function(e){return t._mouseDown(e)}).bind("click."+this.widgetName,function(n){if(!0===e.data(n.target,t.widgetName+".preventClickEvent"))return e.removeData(n.target,t.widgetName+".preventClickEvent"),n.stopImmediatePropagation(),!1}),this.started=!1},_mouseDestroy:function(){this.element.unbind("."+this.widgetName),this._mouseMoveDelegate&&e(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(t){if(n)return;this._mouseStarted&&this._mouseUp(t),this._mouseDownEvent=t;var r=this,i=t.which===1,s=typeof this.options.cancel=="string"&&t.target.nodeName?e(t.target).closest(this.options.cancel).length:!1;if(!i||s||!this._mouseCapture(t))return!0;this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){r.mouseDelayMet=!0},this.options.delay));if(this._mouseDistanceMet(t)&&this._mouseDelayMet(t)){this._mouseStarted=this._mouseStart(t)!==!1;if(!this._mouseStarted)return t.preventDefault(),!0}return!0===e.data(t.target,this.widgetName+".preventClickEvent")&&e.removeData(t.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(e){return r._mouseMove(e)},this._mouseUpDelegate=function(e){return r._mouseUp(e)},e(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate),t.preventDefault(),n=!0,!0},_mouseMove:function(t){return!e.ui.ie||document.documentMode>=9||!!t.button?this._mouseStarted?(this._mouseDrag(t),t.preventDefault()):(this._mouseDistanceMet(t)&&this._mouseDelayMet(t)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,t)!==!1,this._mouseStarted?this._mouseDrag(t):this._mouseUp(t)),!this._mouseStarted):this._mouseUp(t)},_mouseUp:function(t){return e(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,t.target===this._mouseDownEvent.target&&e.data(t.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(t)),!1},_mouseDistanceMet:function(e){return Math.max(Math.abs(this._mouseDownEvent.pageX-e.pageX),Math.abs(this._mouseDownEvent.pageY-e.pageY))>=this.options.distance},_mouseDelayMet:function(e){return this.mouseDelayMet},_mouseStart:function(e){},_mouseDrag:function(e){},_mouseStop:function(e){},_mouseCapture:function(e){return!0}})})(jQuery);(function(e,t){function h(e,t,n){return[parseInt(e[0],10)*(l.test(e[0])?t/100:1),parseInt(e[1],10)*(l.test(e[1])?n/100:1)]}function p(t,n){return parseInt(e.css(t,n),10)||0}e.ui=e.ui||{};var n,r=Math.max,i=Math.abs,s=Math.round,o=/left|center|right/,u=/top|center|bottom/,a=/[\+\-]\d+%?/,f=/^\w+/,l=/%$/,c=e.fn.position;e.position={scrollbarWidth:function(){if(n!==t)return n;var r,i,s=e("<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>"),o=s.children()[0];return e("body").append(s),r=o.offsetWidth,s.css("overflow","scroll"),i=o.offsetWidth,r===i&&(i=s[0].clientWidth),s.remove(),n=r-i},getScrollInfo:function(t){var n=t.isWindow?"":t.element.css("overflow-x"),r=t.isWindow?"":t.element.css("overflow-y"),i=n==="scroll"||n==="auto"&&t.width<t.element[0].scrollWidth,s=r==="scroll"||r==="auto"&&t.height<t.element[0].scrollHeight;return{width:i?e.position.scrollbarWidth():0,height:s?e.position.scrollbarWidth():0}},getWithinInfo:function(t){var n=e(t||window),r=e.isWindow(n[0]);return{element:n,isWindow:r,offset:n.offset()||{left:0,top:0},scrollLeft:n.scrollLeft(),scrollTop:n.scrollTop(),width:r?n.width():n.outerWidth(),height:r?n.height():n.outerHeight()}}},e.fn.position=function(t){if(!t||!t.of)return c.apply(this,arguments);t=e.extend({},t);var n,l,d,v,m,g=e(t.of),y=e.position.getWithinInfo(t.within),b=e.position.getScrollInfo(y),w=g[0],E=(t.collision||"flip").split(" "),S={};return w.nodeType===9?(l=g.width(),d=g.height(),v={top:0,left:0}):e.isWindow(w)?(l=g.width(),d=g.height(),v={top:g.scrollTop(),left:g.scrollLeft()}):w.preventDefault?(t.at="left top",l=d=0,v={top:w.pageY,left:w.pageX}):(l=g.outerWidth(),d=g.outerHeight(),v=g.offset()),m=e.extend({},v),e.each(["my","at"],function(){var e=(t[this]||"").split(" "),n,r;e.length===1&&(e=o.test(e[0])?e.concat(["center"]):u.test(e[0])?["center"].concat(e):["center","center"]),e[0]=o.test(e[0])?e[0]:"center",e[1]=u.test(e[1])?e[1]:"center",n=a.exec(e[0]),r=a.exec(e[1]),S[this]=[n?n[0]:0,r?r[0]:0],t[this]=[f.exec(e[0])[0],f.exec(e[1])[0]]}),E.length===1&&(E[1]=E[0]),t.at[0]==="right"?m.left+=l:t.at[0]==="center"&&(m.left+=l/2),t.at[1]==="bottom"?m.top+=d:t.at[1]==="center"&&(m.top+=d/2),n=h(S.at,l,d),m.left+=n[0],m.top+=n[1],this.each(function(){var o,u,a=e(this),f=a.outerWidth(),c=a.outerHeight(),w=p(this,"marginLeft"),x=p(this,"marginTop"),T=f+w+p(this,"marginRight")+b.width,N=c+x+p(this,"marginBottom")+b.height,C=e.extend({},m),k=h(S.my,a.outerWidth(),a.outerHeight());t.my[0]==="right"?C.left-=f:t.my[0]==="center"&&(C.left-=f/2),t.my[1]==="bottom"?C.top-=c:t.my[1]==="center"&&(C.top-=c/2),C.left+=k[0],C.top+=k[1],e.support.offsetFractions||(C.left=s(C.left),C.top=s(C.top)),o={marginLeft:w,marginTop:x},e.each(["left","top"],function(r,i){e.ui.position[E[r]]&&e.ui.position[E[r]][i](C,{targetWidth:l,targetHeight:d,elemWidth:f,elemHeight:c,collisionPosition:o,collisionWidth:T,collisionHeight:N,offset:[n[0]+k[0],n[1]+k[1]],my:t.my,at:t.at,within:y,elem:a})}),e.fn.bgiframe&&a.bgiframe(),t.using&&(u=function(e){var n=v.left-C.left,s=n+l-f,o=v.top-C.top,u=o+d-c,h={target:{element:g,left:v.left,top:v.top,width:l,height:d},element:{element:a,left:C.left,top:C.top,width:f,height:c},horizontal:s<0?"left":n>0?"right":"center",vertical:u<0?"top":o>0?"bottom":"middle"};l<f&&i(n+s)<l&&(h.horizontal="center"),d<c&&i(o+u)<d&&(h.vertical="middle"),r(i(n),i(s))>r(i(o),i(u))?h.important="horizontal":h.important="vertical",t.using.call(this,e,h)}),a.offset(e.extend(C,{using:u}))})},e.ui.position={fit:{left:function(e,t){var n=t.within,i=n.isWindow?n.scrollLeft:n.offset.left,s=n.width,o=e.left-t.collisionPosition.marginLeft,u=i-o,a=o+t.collisionWidth-s-i,f;t.collisionWidth>s?u>0&&a<=0?(f=e.left+u+t.collisionWidth-s-i,e.left+=u-f):a>0&&u<=0?e.left=i:u>a?e.left=i+s-t.collisionWidth:e.left=i:u>0?e.left+=u:a>0?e.left-=a:e.left=r(e.left-o,e.left)},top:function(e,t){var n=t.within,i=n.isWindow?n.scrollTop:n.offset.top,s=t.within.height,o=e.top-t.collisionPosition.marginTop,u=i-o,a=o+t.collisionHeight-s-i,f;t.collisionHeight>s?u>0&&a<=0?(f=e.top+u+t.collisionHeight-s-i,e.top+=u-f):a>0&&u<=0?e.top=i:u>a?e.top=i+s-t.collisionHeight:e.top=i:u>0?e.top+=u:a>0?e.top-=a:e.top=r(e.top-o,e.top)}},flip:{left:function(e,t){var n=t.within,r=n.offset.left+n.scrollLeft,s=n.width,o=n.isWindow?n.scrollLeft:n.offset.left,u=e.left-t.collisionPosition.marginLeft,a=u-o,f=u+t.collisionWidth-s-o,l=t.my[0]==="left"?-t.elemWidth:t.my[0]==="right"?t.elemWidth:0,c=t.at[0]==="left"?t.targetWidth:t.at[0]==="right"?-t.targetWidth:0,h=-2*t.offset[0],p,d;if(a<0){p=e.left+l+c+h+t.collisionWidth-s-r;if(p<0||p<i(a))e.left+=l+c+h}else if(f>0){d=e.left-t.collisionPosition.marginLeft+l+c+h-o;if(d>0||i(d)<f)e.left+=l+c+h}},top:function(e,t){var n=t.within,r=n.offset.top+n.scrollTop,s=n.height,o=n.isWindow?n.scrollTop:n.offset.top,u=e.top-t.collisionPosition.marginTop,a=u-o,f=u+t.collisionHeight-s-o,l=t.my[1]==="top",c=l?-t.elemHeight:t.my[1]==="bottom"?t.elemHeight:0,h=t.at[1]==="top"?t.targetHeight:t.at[1]==="bottom"?-t.targetHeight:0,p=-2*t.offset[1],d,v;a<0?(v=e.top+c+h+p+t.collisionHeight-s-r,e.top+c+h+p>a&&(v<0||v<i(a))&&(e.top+=c+h+p)):f>0&&(d=e.top-t.collisionPosition.marginTop+c+h+p-o,e.top+c+h+p>f&&(d>0||i(d)<f)&&(e.top+=c+h+p))}},flipfit:{left:function(){e.ui.position.flip.left.apply(this,arguments),e.ui.position.fit.left.apply(this,arguments)},top:function(){e.ui.position.flip.top.apply(this,arguments),e.ui.position.fit.top.apply(this,arguments)}}},function(){var t,n,r,i,s,o=document.getElementsByTagName("body")[0],u=document.createElement("div");t=document.createElement(o?"div":"body"),r={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},o&&e.extend(r,{position:"absolute",left:"-1000px",top:"-1000px"});for(s in r)t.style[s]=r[s];t.appendChild(u),n=o||document.documentElement,n.insertBefore(t,n.firstChild),u.style.cssText="position: absolute; left: 10.7432222px;",i=e(u).offset().left,e.support.offsetFractions=i>10&&i<11,t.innerHTML="",n.removeChild(t)}(),e.uiBackCompat!==!1&&function(e){var n=e.fn.position;e.fn.position=function(r){if(!r||!r.offset)return n.call(this,r);var i=r.offset.split(" "),s=r.at.split(" ");return i.length===1&&(i[1]=i[0]),/^\d/.test(i[0])&&(i[0]="+"+i[0]),/^\d/.test(i[1])&&(i[1]="+"+i[1]),s.length===1&&(/left|center|right/.test(s[0])?s[1]="center":(s[1]=s[0],s[0]="center")),n.call(this,e.extend(r,{at:s[0]+i[0]+" "+s[1]+i[1],offset:t}))}}(jQuery)})(jQuery);(function(e,t){var n=0,r={},i={};r.height=r.paddingTop=r.paddingBottom=r.borderTopWidth=r.borderBottomWidth="hide",i.height=i.paddingTop=i.paddingBottom=i.borderTopWidth=i.borderBottomWidth="show",e.widget("ui.accordion",{version:"1.9.1",options:{active:0,animate:{},collapsible:!1,event:"click",header:"> li > :first-child,> :not(li):even",heightStyle:"auto",icons:{activeHeader:"ui-icon-triangle-1-s",header:"ui-icon-triangle-1-e"},activate:null,beforeActivate:null},_create:function(){var t=this.accordionId="ui-accordion-"+(this.element.attr("id")||++n),r=this.options;this.prevShow=this.prevHide=e(),this.element.addClass("ui-accordion ui-widget ui-helper-reset"),this.headers=this.element.find(r.header).addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all"),this._hoverable(this.headers),this._focusable(this.headers),this.headers.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom").hide(),!r.collapsible&&(r.active===!1||r.active==null)&&(r.active=0),r.active<0&&(r.active+=this.headers.length),this.active=this._findActive(r.active).addClass("ui-accordion-header-active ui-state-active").toggleClass("ui-corner-all ui-corner-top"),this.active.next().addClass("ui-accordion-content-active").show(),this._createIcons(),this.refresh(),this.element.attr("role","tablist"),this.headers.attr("role","tab").each(function(n){var r=e(this),i=r.attr("id"),s=r.next(),o=s.attr("id");i||(i=t+"-header-"+n,r.attr("id",i)),o||(o=t+"-panel-"+n,s.attr("id",o)),r.attr("aria-controls",o),s.attr("aria-labelledby",i)}).next().attr("role","tabpanel"),this.headers.not(this.active).attr({"aria-selected":"false",tabIndex:-1}).next().attr({"aria-expanded":"false","aria-hidden":"true"}).hide(),this.active.length?this.active.attr({"aria-selected":"true",tabIndex:0}).next().attr({"aria-expanded":"true","aria-hidden":"false"}):this.headers.eq(0).attr("tabIndex",0),this._on(this.headers,{keydown:"_keydown"}),this._on(this.headers.next(),{keydown:"_panelKeyDown"}),this._setupEvents(r.event)},_getCreateEventData:function(){return{header:this.active,content:this.active.length?this.active.next():e()}},_createIcons:function(){var t=this.options.icons;t&&(e("<span>").addClass("ui-accordion-header-icon ui-icon "+t.header).prependTo(this.headers),this.active.children(".ui-accordion-header-icon").removeClass(t.header).addClass(t.activeHeader),this.headers.addClass("ui-accordion-icons"))},_destroyIcons:function(){this.headers.removeClass("ui-accordion-icons").children(".ui-accordion-header-icon").remove()},_destroy:function(){var e;this.element.removeClass("ui-accordion ui-widget ui-helper-reset").removeAttr("role"),this.headers.removeClass("ui-accordion-header ui-accordion-header-active ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top").removeAttr("role").removeAttr("aria-selected").removeAttr("aria-controls").removeAttr("tabIndex").each(function(){/^ui-accordion/.test(this.id)&&this.removeAttribute("id")}),this._destroyIcons(),e=this.headers.next().css("display","").removeAttr("role").removeAttr("aria-expanded").removeAttr("aria-hidden").removeAttr("aria-labelledby").removeClass("ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled").each(function(){/^ui-accordion/.test(this.id)&&this.removeAttribute("id")}),this.options.heightStyle!=="content"&&e.css("height","")},_setOption:function(e,t){if(e==="active"){this._activate(t);return}e==="event"&&(this.options.event&&this._off(this.headers,this.options.event),this._setupEvents(t)),this._super(e,t),e==="collapsible"&&!t&&this.options.active===!1&&this._activate(0),e==="icons"&&(this._destroyIcons(),t&&this._createIcons()),e==="disabled"&&this.headers.add(this.headers.next()).toggleClass("ui-state-disabled",!!t)},_keydown:function(t){if(t.altKey||t.ctrlKey)return;var n=e.ui.keyCode,r=this.headers.length,i=this.headers.index(t.target),s=!1;switch(t.keyCode){case n.RIGHT:case n.DOWN:s=this.headers[(i+1)%r];break;case n.LEFT:case n.UP:s=this.headers[(i-1+r)%r];break;case n.SPACE:case n.ENTER:this._eventHandler(t);break;case n.HOME:s=this.headers[0];break;case n.END:s=this.headers[r-1]}s&&(e(t.target).attr("tabIndex",-1),e(s).attr("tabIndex",0),s.focus(),t.preventDefault())},_panelKeyDown:function(t){t.keyCode===e.ui.keyCode.UP&&t.ctrlKey&&e(t.currentTarget).prev().focus()},refresh:function(){var t,n,r=this.options.heightStyle,i=this.element.parent();r==="fill"?(e.support.minHeight||(n=i.css("overflow"),i.css("overflow","hidden")),t=i.height(),this.element.siblings(":visible").each(function(){var n=e(this),r=n.css("position");if(r==="absolute"||r==="fixed")return;t-=n.outerHeight(!0)}),n&&i.css("overflow",n),this.headers.each(function(){t-=e(this).outerHeight(!0)}),this.headers.next().each(function(){e(this).height(Math.max(0,t-e(this).innerHeight()+e(this).height()))}).css("overflow","auto")):r==="auto"&&(t=0,this.headers.next().each(function(){t=Math.max(t,e(this).height("").height())}).height(t))},_activate:function(t){var n=this._findActive(t)[0];if(n===this.active[0])return;n=n||this.active[0],this._eventHandler({target:n,currentTarget:n,preventDefault:e.noop})},_findActive:function(t){return typeof t=="number"?this.headers.eq(t):e()},_setupEvents:function(t){var n={};if(!t)return;e.each(t.split(" "),function(e,t){n[t]="_eventHandler"}),this._on(this.headers,n)},_eventHandler:function(t){var n=this.options,r=this.active,i=e(t.currentTarget),s=i[0]===r[0],o=s&&n.collapsible,u=o?e():i.next(),a=r.next(),f={oldHeader:r,oldPanel:a,newHeader:o?e():i,newPanel:u};t.preventDefault();if(s&&!n.collapsible||this._trigger("beforeActivate",t,f)===!1)return;n.active=o?!1:this.headers.index(i),this.active=s?e():i,this._toggle(f),r.removeClass("ui-accordion-header-active ui-state-active"),n.icons&&r.children(".ui-accordion-header-icon").removeClass(n.icons.activeHeader).addClass(n.icons.header),s||(i.removeClass("ui-corner-all").addClass("ui-accordion-header-active ui-state-active ui-corner-top"),n.icons&&i.children(".ui-accordion-header-icon").removeClass(n.icons.header).addClass(n.icons.activeHeader),i.next().addClass("ui-accordion-content-active"))},_toggle:function(t){var n=t.newPanel,r=this.prevShow.length?this.prevShow:t.oldPanel;this.prevShow.add(this.prevHide).stop(!0,!0),this.prevShow=n,this.prevHide=r,this.options.animate?this._animate(n,r,t):(r.hide(),n.show(),this._toggleComplete(t)),r.attr({"aria-expanded":"false","aria-hidden":"true"}),r.prev().attr("aria-selected","false"),n.length&&r.length?r.prev().attr("tabIndex",-1):n.length&&this.headers.filter(function(){return e(this).attr("tabIndex")===0}).attr("tabIndex",-1),n.attr({"aria-expanded":"true","aria-hidden":"false"}).prev().attr({"aria-selected":"true",tabIndex:0})},_animate:function(e,t,n){var s,o,u,a=this,f=0,l=e.length&&(!t.length||e.index()<t.index()),c=this.options.animate||{},h=l&&c.down||c,p=function(){a._toggleComplete(n)};typeof h=="number"&&(u=h),typeof h=="string"&&(o=h),o=o||h.easing||c.easing,u=u||h.duration||c.duration;if(!t.length)return e.animate(i,u,o,p);if(!e.length)return t.animate(r,u,o,p);s=e.show().outerHeight(),t.animate(r,{duration:u,easing:o,step:function(e,t){t.now=Math.round(e)}}),e.hide().animate(i,{duration:u,easing:o,complete:p,step:function(e,n){n.now=Math.round(e),n.prop!=="height"?f+=n.now:a.options.heightStyle!=="content"&&(n.now=Math.round(s-t.outerHeight()-f),f=0)}})},_toggleComplete:function(e){var t=e.oldPanel;t.removeClass("ui-accordion-content-active").prev().removeClass("ui-corner-top").addClass("ui-corner-all"),t.length&&(t.parent()[0].className=t.parent()[0].className),this._trigger("activate",null,e)}}),e.uiBackCompat!==!1&&(function(e,t){e.extend(t.options,{navigation:!1,navigationFilter:function(){return this.href.toLowerCase()===location.href.toLowerCase()}});var n=t._create;t._create=function(){if(this.options.navigation){var t=this,r=this.element.find(this.options.header),i=r.next(),s=r.add(i).find("a").filter(this.options.navigationFilter)[0];s&&r.add(i).each(function(n){if(e.contains(this,s))return t.options.active=Math.floor(n/2),!1})}n.call(this)}}(jQuery,jQuery.ui.accordion.prototype),function(e,t){e.extend(t.options,{heightStyle:null,autoHeight:!0,clearStyle:!1,fillSpace:!1});var n=t._create,r=t._setOption;e.extend(t,{_create:function(){this.options.heightStyle=this.options.heightStyle||this._mergeHeightStyle(),n.call(this)},_setOption:function(e){if(e==="autoHeight"||e==="clearStyle"||e==="fillSpace")this.options.heightStyle=this._mergeHeightStyle();r.apply(this,arguments)},_mergeHeightStyle:function(){var e=this.options;if(e.fillSpace)return"fill";if(e.clearStyle)return"content";if(e.autoHeight)return"auto"}})}(jQuery,jQuery.ui.accordion.prototype),function(e,t){e.extend(t.options.icons,{activeHeader:null,headerSelected:"ui-icon-triangle-1-s"});var n=t._createIcons;t._createIcons=function(){this.options.icons&&(this.options.icons.activeHeader=this.options.icons.activeHeader||this.options.icons.headerSelected),n.call(this)}}(jQuery,jQuery.ui.accordion.prototype),function(e,t){t.activate=t._activate;var n=t._findActive;t._findActive=function(e){return e===-1&&(e=!1),e&&typeof e!="number"&&(e=this.headers.index(this.headers.filter(e)),e===-1&&(e=!1)),n.call(this,e)}}(jQuery,jQuery.ui.accordion.prototype),jQuery.ui.accordion.prototype.resize=jQuery.ui.accordion.prototype.refresh,function(e,t){e.extend(t.options,{change:null,changestart:null});var n=t._trigger;t._trigger=function(e,t,r){var i=n.apply(this,arguments);return i?(e==="beforeActivate"?i=n.call(this,"changestart",t,{oldHeader:r.oldHeader,oldContent:r.oldPanel,newHeader:r.newHeader,newContent:r.newPanel}):e==="activate"&&(i=n.call(this,"change",t,{oldHeader:r.oldHeader,oldContent:r.oldPanel,newHeader:r.newHeader,newContent:r.newPanel})),i):!1}}(jQuery,jQuery.ui.accordion.prototype),function(e,t){e.extend(t.options,{animate:null,animated:"slide"});var n=t._create;t._create=function(){var e=this.options;e.animate===null&&(e.animated?e.animated==="slide"?e.animate=300:e.animated==="bounceslide"?e.animate={duration:200,down:{easing:"easeOutBounce",duration:1e3}}:e.animate=e.animated:e.animate=!1),n.call(this)}}(jQuery,jQuery.ui.accordion.prototype))})(jQuery);(function(e,t){var n=0;e.widget("ui.autocomplete",{version:"1.9.1",defaultElement:"<input>",options:{appendTo:"body",autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null,change:null,close:null,focus:null,open:null,response:null,search:null,select:null},pending:0,_create:function(){var t,n,r;this.isMultiLine=this._isMultiLine(),this.valueMethod=this.element[this.element.is("input,textarea")?"val":"text"],this.isNewMenu=!0,this.element.addClass("ui-autocomplete-input").attr("autocomplete","off"),this._on(this.element,{keydown:function(i){if(this.element.prop("readOnly")){t=!0,r=!0,n=!0;return}t=!1,r=!1,n=!1;var s=e.ui.keyCode;switch(i.keyCode){case s.PAGE_UP:t=!0,this._move("previousPage",i);break;case s.PAGE_DOWN:t=!0,this._move("nextPage",i);break;case s.UP:t=!0,this._keyEvent("previous",i);break;case s.DOWN:t=!0,this._keyEvent("next",i);break;case s.ENTER:case s.NUMPAD_ENTER:this.menu.active&&(t=!0,i.preventDefault(),this.menu.select(i));break;case s.TAB:this.menu.active&&this.menu.select(i);break;case s.ESCAPE:this.menu.element.is(":visible")&&(this._value(this.term),this.close(i),i.preventDefault());break;default:n=!0,this._searchTimeout(i)}},keypress:function(r){if(t){t=!1,r.preventDefault();return}if(n)return;var i=e.ui.keyCode;switch(r.keyCode){case i.PAGE_UP:this._move("previousPage",r);break;case i.PAGE_DOWN:this._move("nextPage",r);break;case i.UP:this._keyEvent("previous",r);break;case i.DOWN:this._keyEvent("next",r)}},input:function(e){if(r){r=!1,e.preventDefault();return}this._searchTimeout(e)},focus:function(){this.selectedItem=null,this.previous=this._value()},blur:function(e){if(this.cancelBlur){delete this.cancelBlur;return}clearTimeout(this.searching),this.close(e),this._change(e)}}),this._initSource(),this.menu=e("<ul>").addClass("ui-autocomplete").appendTo(this.document.find(this.options.appendTo||"body")[0]).menu({input:e(),role:null}).zIndex(this.element.zIndex()+1).hide().data("menu"),this._on(this.menu.element,{mousedown:function(t){t.preventDefault(),this.cancelBlur=!0,this._delay(function(){delete this.cancelBlur});var n=this.menu.element[0];e(t.target).closest(".ui-menu-item").length||this._delay(function(){var t=this;this.document.one("mousedown",function(r){r.target!==t.element[0]&&r.target!==n&&!e.contains(n,r.target)&&t.close()})})},menufocus:function(t,n){if(this.isNewMenu){this.isNewMenu=!1;if(t.originalEvent&&/^mouse/.test(t.originalEvent.type)){this.menu.blur(),this.document.one("mousemove",function(){e(t.target).trigger(t.originalEvent)});return}}var r=n.item.data("ui-autocomplete-item")||n.item.data("item.autocomplete");!1!==this._trigger("focus",t,{item:r})?t.originalEvent&&/^key/.test(t.originalEvent.type)&&this._value(r.value):this.liveRegion.text(r.value)},menuselect:function(e,t){var n=t.item.data("ui-autocomplete-item")||t.item.data("item.autocomplete"),r=this.previous;this.element[0]!==this.document[0].activeElement&&(this.element.focus(),this.previous=r,this._delay(function(){this.previous=r,this.selectedItem=n})),!1!==this._trigger("select",e,{item:n})&&this._value(n.value),this.term=this._value(),this.close(e),this.selectedItem=n}}),this.liveRegion=e("<span>",{role:"status","aria-live":"polite"}).addClass("ui-helper-hidden-accessible").insertAfter(this.element),e.fn.bgiframe&&this.menu.element.bgiframe(),this._on(this.window,{beforeunload:function(){this.element.removeAttr("autocomplete")}})},_destroy:function(){clearTimeout(this.searching),this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete"),this.menu.element.remove(),this.liveRegion.remove()},_setOption:function(e,t){this._super(e,t),e==="source"&&this._initSource(),e==="appendTo"&&this.menu.element.appendTo(this.document.find(t||"body")[0]),e==="disabled"&&t&&this.xhr&&this.xhr.abort()},_isMultiLine:function(){return this.element.is("textarea")?!0:this.element.is("input")?!1:this.element.prop("isContentEditable")},_initSource:function(){var t,n,r=this;e.isArray(this.options.source)?(t=this.options.source,this.source=function(n,r){r(e.ui.autocomplete.filter(t,n.term))}):typeof this.options.source=="string"?(n=this.options.source,this.source=function(t,i){r.xhr&&r.xhr.abort(),r.xhr=e.ajax({url:n,data:t,dataType:"json",success:function(e){i(e)},error:function(){i([])}})}):this.source=this.options.source},_searchTimeout:function(e){clearTimeout(this.searching),this.searching=this._delay(function(){this.term!==this._value()&&(this.selectedItem=null,this.search(null,e))},this.options.delay)},search:function(e,t){e=e!=null?e:this._value(),this.term=this._value();if(e.length<this.options.minLength)return this.close(t);if(this._trigger("search",t)===!1)return;return this._search(e)},_search:function(e){this.pending++,this.element.addClass("ui-autocomplete-loading"),this.cancelSearch=!1,this.source({term:e},this._response())},_response:function(){var e=this,t=++n;return function(r){t===n&&e.__response(r),e.pending--,e.pending||e.element.removeClass("ui-autocomplete-loading")}},__response:function(e){e&&(e=this._normalize(e)),this._trigger("response",null,{content:e}),!this.options.disabled&&e&&e.length&&!this.cancelSearch?(this._suggest(e),this._trigger("open")):this._close()},close:function(e){this.cancelSearch=!0,this._close(e)},_close:function(e){this.menu.element.is(":visible")&&(this.menu.element.hide(),this.menu.blur(),this.isNewMenu=!0,this._trigger("close",e))},_change:function(e){this.previous!==this._value()&&this._trigger("change",e,{item:this.selectedItem})},_normalize:function(t){return t.length&&t[0].label&&t[0].value?t:e.map(t,function(t){return typeof t=="string"?{label:t,value:t}:e.extend({label:t.label||t.value,value:t.value||t.label},t)})},_suggest:function(t){var n=this.menu.element.empty().zIndex(this.element.zIndex()+1);this._renderMenu(n,t),this.menu.refresh(),n.show(),this._resizeMenu(),n.position(e.extend({of:this.element},this.options.position)),this.options.autoFocus&&this.menu.next()},_resizeMenu:function(){var e=this.menu.element;e.outerWidth(Math.max(e.width("").outerWidth()+1,this.element.outerWidth()))},_renderMenu:function(t,n){var r=this;e.each(n,function(e,n){r._renderItemData(t,n)})},_renderItemData:function(e,t){return this._renderItem(e,t).data("ui-autocomplete-item",t)},_renderItem:function(t,n){return e("<li>").append(e("<a>").text(n.label)).appendTo(t)},_move:function(e,t){if(!this.menu.element.is(":visible")){this.search(null,t);return}if(this.menu.isFirstItem()&&/^previous/.test(e)||this.menu.isLastItem()&&/^next/.test(e)){this._value(this.term),this.menu.blur();return}this.menu[e](t)},widget:function(){return this.menu.element},_value:function(){return this.valueMethod.apply(this.element,arguments)},_keyEvent:function(e,t){if(!this.isMultiLine||this.menu.element.is(":visible"))this._move(e,t),t.preventDefault()}}),e.extend(e.ui.autocomplete,{escapeRegex:function(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")},filter:function(t,n){var r=new RegExp(e.ui.autocomplete.escapeRegex(n),"i");return e.grep(t,function(e){return r.test(e.label||e.value||e)})}}),e.widget("ui.autocomplete",e.ui.autocomplete,{options:{messages:{noResults:"No search results.",results:function(e){return e+(e>1?" results are":" result is")+" available, use up and down arrow keys to navigate."}}},__response:function(e){var t;this._superApply(arguments);if(this.options.disabled||this.cancelSearch)return;e&&e.length?t=this.options.messages.results(e.length):t=this.options.messages.noResults,this.liveRegion.text(t)}})})(jQuery);(function(e,t){var n,r,i,s,o="ui-button ui-widget ui-state-default ui-corner-all",u="ui-state-hover ui-state-active ",a="ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",f=function(){var t=e(this).find(":ui-button");setTimeout(function(){t.button("refresh")},1)},l=function(t){var n=t.name,r=t.form,i=e([]);return n&&(r?i=e(r).find("[name='"+n+"']"):i=e("[name='"+n+"']",t.ownerDocument).filter(function(){return!this.form})),i};e.widget("ui.button",{version:"1.9.1",defaultElement:"<button>",options:{disabled:null,text:!0,label:null,icons:{primary:null,secondary:null}},_create:function(){this.element.closest("form").unbind("reset"+this.eventNamespace).bind("reset"+this.eventNamespace,f),typeof this.options.disabled!="boolean"?this.options.disabled=!!this.element.prop("disabled"):this.element.prop("disabled",this.options.disabled),this._determineButtonType(),this.hasTitle=!!this.buttonElement.attr("title");var t=this,u=this.options,a=this.type==="checkbox"||this.type==="radio",c="ui-state-hover"+(a?"":" ui-state-active"),h="ui-state-focus";u.label===null&&(u.label=this.type==="input"?this.buttonElement.val():this.buttonElement.html()),this.buttonElement.addClass(o).attr("role","button").bind("mouseenter"+this.eventNamespace,function(){if(u.disabled)return;e(this).addClass("ui-state-hover"),this===n&&e(this).addClass("ui-state-active")}).bind("mouseleave"+this.eventNamespace,function(){if(u.disabled)return;e(this).removeClass(c)}).bind("click"+this.eventNamespace,function(e){u.disabled&&(e.preventDefault(),e.stopImmediatePropagation())}),this.element.bind("focus"+this.eventNamespace,function(){t.buttonElement.addClass(h)}).bind("blur"+this.eventNamespace,function(){t.buttonElement.removeClass(h)}),a&&(this.element.bind("change"+this.eventNamespace,function(){if(s)return;t.refresh()}),this.buttonElement.bind("mousedown"+this.eventNamespace,function(e){if(u.disabled)return;s=!1,r=e.pageX,i=e.pageY}).bind("mouseup"+this.eventNamespace,function(e){if(u.disabled)return;if(r!==e.pageX||i!==e.pageY)s=!0})),this.type==="checkbox"?this.buttonElement.bind("click"+this.eventNamespace,function(){if(u.disabled||s)return!1;e(this).toggleClass("ui-state-active"),t.buttonElement.attr("aria-pressed",t.element[0].checked)}):this.type==="radio"?this.buttonElement.bind("click"+this.eventNamespace,function(){if(u.disabled||s)return!1;e(this).addClass("ui-state-active"),t.buttonElement.attr("aria-pressed","true");var n=t.element[0];l(n).not(n).map(function(){return e(this).button("widget")[0]}).removeClass("ui-state-active").attr("aria-pressed","false")}):(this.buttonElement.bind("mousedown"+this.eventNamespace,function(){if(u.disabled)return!1;e(this).addClass("ui-state-active"),n=this,t.document.one("mouseup",function(){n=null})}).bind("mouseup"+this.eventNamespace,function(){if(u.disabled)return!1;e(this).removeClass("ui-state-active")}).bind("keydown"+this.eventNamespace,function(t){if(u.disabled)return!1;(t.keyCode===e.ui.keyCode.SPACE||t.keyCode===e.ui.keyCode.ENTER)&&e(this).addClass("ui-state-active")}).bind("keyup"+this.eventNamespace,function(){e(this).removeClass("ui-state-active")}),this.buttonElement.is("a")&&this.buttonElement.keyup(function(t){t.keyCode===e.ui.keyCode.SPACE&&e(this).click()})),this._setOption("disabled",u.disabled),this._resetButton()},_determineButtonType:function(){var e,t,n;this.element.is("[type=checkbox]")?this.type="checkbox":this.element.is("[type=radio]")?this.type="radio":this.element.is("input")?this.type="input":this.type="button",this.type==="checkbox"||this.type==="radio"?(e=this.element.parents().last(),t="label[for='"+this.element.attr("id")+"']",this.buttonElement=e.find(t),this.buttonElement.length||(e=e.length?e.siblings():this.element.siblings(),this.buttonElement=e.filter(t),this.buttonElement.length||(this.buttonElement=e.find(t))),this.element.addClass("ui-helper-hidden-accessible"),n=this.element.is(":checked"),n&&this.buttonElement.addClass("ui-state-active"),this.buttonElement.prop("aria-pressed",n)):this.buttonElement=this.element},widget:function(){return this.buttonElement},_destroy:function(){this.element.removeClass("ui-helper-hidden-accessible"),this.buttonElement.removeClass(o+" "+u+" "+a).removeAttr("role").removeAttr("aria-pressed").html(this.buttonElement.find(".ui-button-text").html()),this.hasTitle||this.buttonElement.removeAttr("title")},_setOption:function(e,t){this._super(e,t);if(e==="disabled"){t?this.element.prop("disabled",!0):this.element.prop("disabled",!1);return}this._resetButton()},refresh:function(){var t=this.element.is(":disabled")||this.element.hasClass("ui-button-disabled");t!==this.options.disabled&&this._setOption("disabled",t),this.type==="radio"?l(this.element[0]).each(function(){e(this).is(":checked")?e(this).button("widget").addClass("ui-state-active").attr("aria-pressed","true"):e(this).button("widget").removeClass("ui-state-active").attr("aria-pressed","false")}):this.type==="checkbox"&&(this.element.is(":checked")?this.buttonElement.addClass("ui-state-active").attr("aria-pressed","true"):this.buttonElement.removeClass("ui-state-active").attr("aria-pressed","false"))},_resetButton:function(){if(this.type==="input"){this.options.label&&this.element.val(this.options.label);return}var t=this.buttonElement.removeClass(a),n=e("<span></span>",this.document[0]).addClass("ui-button-text").html(this.options.label).appendTo(t.empty()).text(),r=this.options.icons,i=r.primary&&r.secondary,s=[];r.primary||r.secondary?(this.options.text&&s.push("ui-button-text-icon"+(i?"s":r.primary?"-primary":"-secondary")),r.primary&&t.prepend("<span class='ui-button-icon-primary ui-icon "+r.primary+"'></span>"),r.secondary&&t.append("<span class='ui-button-icon-secondary ui-icon "+r.secondary+"'></span>"),this.options.text||(s.push(i?"ui-button-icons-only":"ui-button-icon-only"),this.hasTitle||t.attr("title",e.trim(n)))):s.push("ui-button-text-only"),t.addClass(s.join(" "))}}),e.widget("ui.buttonset",{version:"1.9.1",options:{items:"button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(button)"},_create:function(){this.element.addClass("ui-buttonset")},_init:function(){this.refresh()},_setOption:function(e,t){e==="disabled"&&this.buttons.button("option",e,t),this._super(e,t)},refresh:function(){var t=this.element.css("direction")==="rtl";this.buttons=this.element.find(this.options.items).filter(":ui-button").button("refresh").end().not(":ui-button").button().end().map(function(){return e(this).button("widget")[0]}).removeClass("ui-corner-all ui-corner-left ui-corner-right").filter(":first").addClass(t?"ui-corner-right":"ui-corner-left").end().filter(":last").addClass(t?"ui-corner-left":"ui-corner-right").end().end()},_destroy:function(){this.element.removeClass("ui-buttonset"),this.buttons.map(function(){return e(this).button("widget")[0]}).removeClass("ui-corner-left ui-corner-right").end().button("destroy")}})})(jQuery);(function($,undefined){function Datepicker(){this.debug=!1,this._curInst=null,this._keyEvent=!1,this._disabledInputs=[],this._datepickerShowing=!1,this._inDialog=!1,this._mainDivId="ui-datepicker-div",this._inlineClass="ui-datepicker-inline",this._appendClass="ui-datepicker-append",this._triggerClass="ui-datepicker-trigger",this._dialogClass="ui-datepicker-dialog",this._disableClass="ui-datepicker-disabled",this._unselectableClass="ui-datepicker-unselectable",this._currentClass="ui-datepicker-current-day",this._dayOverClass="ui-datepicker-days-cell-over",this.regional=[],this.regional[""]={closeText:"Done",prevText:"Prev",nextText:"Next",currentText:"Today",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],weekHeader:"Wk",dateFormat:"mm/dd/yy",firstDay:0,isRTL:!1,showMonthAfterYear:!1,yearSuffix:""},this._defaults={showOn:"focus",showAnim:"fadeIn",showOptions:{},defaultDate:null,appendText:"",buttonText:"...",buttonImage:"",buttonImageOnly:!1,hideIfNoPrevNext:!1,navigationAsDateFormat:!1,gotoCurrent:!1,changeMonth:!1,changeYear:!1,yearRange:"c-10:c+10",showOtherMonths:!1,selectOtherMonths:!1,showWeek:!1,calculateWeek:this.iso8601Week,shortYearCutoff:"+10",minDate:null,maxDate:null,duration:"fast",beforeShowDay:null,beforeShow:null,onSelect:null,onChangeMonthYear:null,onClose:null,numberOfMonths:1,showCurrentAtPos:0,stepMonths:1,stepBigMonths:12,altField:"",altFormat:"",constrainInput:!0,showButtonPanel:!1,autoSize:!1,disabled:!1},$.extend(this._defaults,this.regional[""]),this.dpDiv=bindHover($('<div id="'+this._mainDivId+'" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'))}function bindHover(e){var t="button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";return e.delegate(t,"mouseout",function(){$(this).removeClass("ui-state-hover"),this.className.indexOf("ui-datepicker-prev")!=-1&&$(this).removeClass("ui-datepicker-prev-hover"),this.className.indexOf("ui-datepicker-next")!=-1&&$(this).removeClass("ui-datepicker-next-hover")}).delegate(t,"mouseover",function(){$.datepicker._isDisabledDatepicker(instActive.inline?e.parent()[0]:instActive.input[0])||($(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"),$(this).addClass("ui-state-hover"),this.className.indexOf("ui-datepicker-prev")!=-1&&$(this).addClass("ui-datepicker-prev-hover"),this.className.indexOf("ui-datepicker-next")!=-1&&$(this).addClass("ui-datepicker-next-hover"))})}function extendRemove(e,t){$.extend(e,t);for(var n in t)if(t[n]==null||t[n]==undefined)e[n]=t[n];return e}$.extend($.ui,{datepicker:{version:"1.9.1"}});var PROP_NAME="datepicker",dpuuid=(new Date).getTime(),instActive;$.extend(Datepicker.prototype,{markerClassName:"hasDatepicker",maxRows:4,log:function(){this.debug&&console.log.apply("",arguments)},_widgetDatepicker:function(){return this.dpDiv},setDefaults:function(e){return extendRemove(this._defaults,e||{}),this},_attachDatepicker:function(target,settings){var inlineSettings=null;for(var attrName in this._defaults){var attrValue=target.getAttribute("date:"+attrName);if(attrValue){inlineSettings=inlineSettings||{};try{inlineSettings[attrName]=eval(attrValue)}catch(err){inlineSettings[attrName]=attrValue}}}var nodeName=target.nodeName.toLowerCase(),inline=nodeName=="div"||nodeName=="span";target.id||(this.uuid+=1,target.id="dp"+this.uuid);var inst=this._newInst($(target),inline);inst.settings=$.extend({},settings||{},inlineSettings||{}),nodeName=="input"?this._connectDatepicker(target,inst):inline&&this._inlineDatepicker(target,inst)},_newInst:function(e,t){var n=e[0].id.replace(/([^A-Za-z0-9_-])/g,"\\\\$1");return{id:n,input:e,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:t,dpDiv:t?bindHover($('<div class="'+this._inlineClass+' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>')):this.dpDiv}},_connectDatepicker:function(e,t){var n=$(e);t.append=$([]),t.trigger=$([]);if(n.hasClass(this.markerClassName))return;this._attachments(n,t),n.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).keyup(this._doKeyUp).bind("setData.datepicker",function(e,n,r){t.settings[n]=r}).bind("getData.datepicker",function(e,n){return this._get(t,n)}),this._autoSize(t),$.data(e,PROP_NAME,t),t.settings.disabled&&this._disableDatepicker(e)},_attachments:function(e,t){var n=this._get(t,"appendText"),r=this._get(t,"isRTL");t.append&&t.append.remove(),n&&(t.append=$('<span class="'+this._appendClass+'">'+n+"</span>"),e[r?"before":"after"](t.append)),e.unbind("focus",this._showDatepicker),t.trigger&&t.trigger.remove();var i=this._get(t,"showOn");(i=="focus"||i=="both")&&e.focus(this._showDatepicker);if(i=="button"||i=="both"){var s=this._get(t,"buttonText"),o=this._get(t,"buttonImage");t.trigger=$(this._get(t,"buttonImageOnly")?$("<img/>").addClass(this._triggerClass).attr({src:o,alt:s,title:s}):$('<button type="button"></button>').addClass(this._triggerClass).html(o==""?s:$("<img/>").attr({src:o,alt:s,title:s}))),e[r?"before":"after"](t.trigger),t.trigger.click(function(){return $.datepicker._datepickerShowing&&$.datepicker._lastInput==e[0]?$.datepicker._hideDatepicker():$.datepicker._datepickerShowing&&$.datepicker._lastInput!=e[0]?($.datepicker._hideDatepicker(),$.datepicker._showDatepicker(e[0])):$.datepicker._showDatepicker(e[0]),!1})}},_autoSize:function(e){if(this._get(e,"autoSize")&&!e.inline){var t=new Date(2009,11,20),n=this._get(e,"dateFormat");if(n.match(/[DM]/)){var r=function(e){var t=0,n=0;for(var r=0;r<e.length;r++)e[r].length>t&&(t=e[r].length,n=r);return n};t.setMonth(r(this._get(e,n.match(/MM/)?"monthNames":"monthNamesShort"))),t.setDate(r(this._get(e,n.match(/DD/)?"dayNames":"dayNamesShort"))+20-t.getDay())}e.input.attr("size",this._formatDate(e,t).length)}},_inlineDatepicker:function(e,t){var n=$(e);if(n.hasClass(this.markerClassName))return;n.addClass(this.markerClassName).append(t.dpDiv).bind("setData.datepicker",function(e,n,r){t.settings[n]=r}).bind("getData.datepicker",function(e,n){return this._get(t,n)}),$.data(e,PROP_NAME,t),this._setDate(t,this._getDefaultDate(t),!0),this._updateDatepicker(t),this._updateAlternate(t),t.settings.disabled&&this._disableDatepicker(e),t.dpDiv.css("display","block")},_dialogDatepicker:function(e,t,n,r,i){var s=this._dialogInst;if(!s){this.uuid+=1;var o="dp"+this.uuid;this._dialogInput=$('<input type="text" id="'+o+'" style="position: absolute; top: -100px; width: 0px;"/>'),this._dialogInput.keydown(this._doKeyDown),$("body").append(this._dialogInput),s=this._dialogInst=this._newInst(this._dialogInput,!1),s.settings={},$.data(this._dialogInput[0],PROP_NAME,s)}extendRemove(s.settings,r||{}),t=t&&t.constructor==Date?this._formatDate(s,t):t,this._dialogInput.val(t),this._pos=i?i.length?i:[i.pageX,i.pageY]:null;if(!this._pos){var u=document.documentElement.clientWidth,a=document.documentElement.clientHeight,f=document.documentElement.scrollLeft||document.body.scrollLeft,l=document.documentElement.scrollTop||document.body.scrollTop;this._pos=[u/2-100+f,a/2-150+l]}return this._dialogInput.css("left",this._pos[0]+20+"px").css("top",this._pos[1]+"px"),s.settings.onSelect=n,this._inDialog=!0,this.dpDiv.addClass(this._dialogClass),this._showDatepicker(this._dialogInput[0]),$.blockUI&&$.blockUI(this.dpDiv),$.data(this._dialogInput[0],PROP_NAME,s),this},_destroyDatepicker:function(e){var t=$(e),n=$.data(e,PROP_NAME);if(!t.hasClass(this.markerClassName))return;var r=e.nodeName.toLowerCase();$.removeData(e,PROP_NAME),r=="input"?(n.append.remove(),n.trigger.remove(),t.removeClass(this.markerClassName).unbind("focus",this._showDatepicker).unbind("keydown",this._doKeyDown).unbind("keypress",this._doKeyPress).unbind("keyup",this._doKeyUp)):(r=="div"||r=="span")&&t.removeClass(this.markerClassName).empty()},_enableDatepicker:function(e){var t=$(e),n=$.data(e,PROP_NAME);if(!t.hasClass(this.markerClassName))return;var r=e.nodeName.toLowerCase();if(r=="input")e.disabled=!1,n.trigger.filter("button").each(function(){this.disabled=!1}).end().filter("img").css({opacity:"1.0",cursor:""});else if(r=="div"||r=="span"){var i=t.children("."+this._inlineClass);i.children().removeClass("ui-state-disabled"),i.find("select.ui-datepicker-month, select.ui-datepicker-year").prop("disabled",!1)}this._disabledInputs=$.map(this._disabledInputs,function(t){return t==e?null:t})},_disableDatepicker:function(e){var t=$(e),n=$.data(e,PROP_NAME);if(!t.hasClass(this.markerClassName))return;var r=e.nodeName.toLowerCase();if(r=="input")e.disabled=!0,n.trigger.filter("button").each(function(){this.disabled=!0}).end().filter("img").css({opacity:"0.5",cursor:"default"});else if(r=="div"||r=="span"){var i=t.children("."+this._inlineClass);i.children().addClass("ui-state-disabled"),i.find("select.ui-datepicker-month, select.ui-datepicker-year").prop("disabled",!0)}this._disabledInputs=$.map(this._disabledInputs,function(t){return t==e?null:t}),this._disabledInputs[this._disabledInputs.length]=e},_isDisabledDatepicker:function(e){if(!e)return!1;for(var t=0;t<this._disabledInputs.length;t++)if(this._disabledInputs[t]==e)return!0;return!1},_getInst:function(e){try{return $.data(e,PROP_NAME)}catch(t){throw"Missing instance data for this datepicker"}},_optionDatepicker:function(e,t,n){var r=this._getInst(e);if(arguments.length==2&&typeof t=="string")return t=="defaults"?$.extend({},$.datepicker._defaults):r?t=="all"?$.extend({},r.settings):this._get(r,t):null;var i=t||{};typeof t=="string"&&(i={},i[t]=n);if(r){this._curInst==r&&this._hideDatepicker();var s=this._getDateDatepicker(e,!0),o=this._getMinMaxDate(r,"min"),u=this._getMinMaxDate(r,"max");extendRemove(r.settings,i),o!==null&&i.dateFormat!==undefined&&i.minDate===undefined&&(r.settings.minDate=this._formatDate(r,o)),u!==null&&i.dateFormat!==undefined&&i.maxDate===undefined&&(r.settings.maxDate=this._formatDate(r,u)),this._attachments($(e),r),this._autoSize(r),this._setDate(r,s),this._updateAlternate(r),this._updateDatepicker(r)}},_changeDatepicker:function(e,t,n){this._optionDatepicker(e,t,n)},_refreshDatepicker:function(e){var t=this._getInst(e);t&&this._updateDatepicker(t)},_setDateDatepicker:function(e,t){var n=this._getInst(e);n&&(this._setDate(n,t),this._updateDatepicker(n),this._updateAlternate(n))},_getDateDatepicker:function(e,t){var n=this._getInst(e);return n&&!n.inline&&this._setDateFromField(n,t),n?this._getDate(n):null},_doKeyDown:function(e){var t=$.datepicker._getInst(e.target),n=!0,r=t.dpDiv.is(".ui-datepicker-rtl");t._keyEvent=!0;if($.datepicker._datepickerShowing)switch(e.keyCode){case 9:$.datepicker._hideDatepicker(),n=!1;break;case 13:var i=$("td."+$.datepicker._dayOverClass+":not(."+$.datepicker._currentClass+")",t.dpDiv);i[0]&&$.datepicker._selectDay(e.target,t.selectedMonth,t.selectedYear,i[0]);var s=$.datepicker._get(t,"onSelect");if(s){var o=$.datepicker._formatDate(t);s.apply(t.input?t.input[0]:null,[o,t])}else $.datepicker._hideDatepicker();return!1;case 27:$.datepicker._hideDatepicker();break;case 33:$.datepicker._adjustDate(e.target,e.ctrlKey?-$.datepicker._get(t,"stepBigMonths"):-$.datepicker._get(t,"stepMonths"),"M");break;case 34:$.datepicker._adjustDate(e.target,e.ctrlKey?+$.datepicker._get(t,"stepBigMonths"):+$.datepicker._get(t,"stepMonths"),"M");break;case 35:(e.ctrlKey||e.metaKey)&&$.datepicker._clearDate(e.target),n=e.ctrlKey||e.metaKey;break;case 36:(e.ctrlKey||e.metaKey)&&$.datepicker._gotoToday(e.target),n=e.ctrlKey||e.metaKey;break;case 37:(e.ctrlKey||e.metaKey)&&$.datepicker._adjustDate(e.target,r?1:-1,"D"),n=e.ctrlKey||e.metaKey,e.originalEvent.altKey&&$.datepicker._adjustDate(e.target,e.ctrlKey?-$.datepicker._get(t,"stepBigMonths"):-$.datepicker._get(t,"stepMonths"),"M");break;case 38:(e.ctrlKey||e.metaKey)&&$.datepicker._adjustDate(e.target,-7,"D"),n=e.ctrlKey||e.metaKey;break;case 39:(e.ctrlKey||e.metaKey)&&$.datepicker._adjustDate(e.target,r?-1:1,"D"),n=e.ctrlKey||e.metaKey,e.originalEvent.altKey&&$.datepicker._adjustDate(e.target,e.ctrlKey?+$.datepicker._get(t,"stepBigMonths"):+$.datepicker._get(t,"stepMonths"),"M");break;case 40:(e.ctrlKey||e.metaKey)&&$.datepicker._adjustDate(e.target,7,"D"),n=e.ctrlKey||e.metaKey;break;default:n=!1}else e.keyCode==36&&e.ctrlKey?$.datepicker._showDatepicker(this):n=!1;n&&(e.preventDefault(),e.stopPropagation())},_doKeyPress:function(e){var t=$.datepicker._getInst(e.target);if($.datepicker._get(t,"constrainInput")){var n=$.datepicker._possibleChars($.datepicker._get(t,"dateFormat")),r=String.fromCharCode(e.charCode==undefined?e.keyCode:e.charCode);return e.ctrlKey||e.metaKey||r<" "||!n||n.indexOf(r)>-1}},_doKeyUp:function(e){var t=$.datepicker._getInst(e.target);if(t.input.val()!=t.lastVal)try{var n=$.datepicker.parseDate($.datepicker._get(t,"dateFormat"),t.input?t.input.val():null,$.datepicker._getFormatConfig(t));n&&($.datepicker._setDateFromField(t),$.datepicker._updateAlternate(t),$.datepicker._updateDatepicker(t))}catch(r){$.datepicker.log(r)}return!0},_showDatepicker:function(e){e=e.target||e,e.nodeName.toLowerCase()!="input"&&(e=$("input",e.parentNode)[0]);if($.datepicker._isDisabledDatepicker(e)||$.datepicker._lastInput==e)return;var t=$.datepicker._getInst(e);$.datepicker._curInst&&$.datepicker._curInst!=t&&($.datepicker._curInst.dpDiv.stop(!0,!0),t&&$.datepicker._datepickerShowing&&$.datepicker._hideDatepicker($.datepicker._curInst.input[0]));var n=$.datepicker._get(t,"beforeShow"),r=n?n.apply(e,[e,t]):{};if(r===!1)return;extendRemove(t.settings,r),t.lastVal=null,$.datepicker._lastInput=e,$.datepicker._setDateFromField(t),$.datepicker._inDialog&&(e.value=""),$.datepicker._pos||($.datepicker._pos=$.datepicker._findPos(e),$.datepicker._pos[1]+=e.offsetHeight);var i=!1;$(e).parents().each(function(){return i|=$(this).css("position")=="fixed",!i});var s={left:$.datepicker._pos[0],top:$.datepicker._pos[1]};$.datepicker._pos=null,t.dpDiv.empty(),t.dpDiv.css({position:"absolute",display:"block",top:"-1000px"}),$.datepicker._updateDatepicker(t),s=$.datepicker._checkOffset(t,s,i),t.dpDiv.css({position:$.datepicker._inDialog&&$.blockUI?"static":i?"fixed":"absolute",display:"none",left:s.left+"px",top:s.top+"px"});if(!t.inline){var o=$.datepicker._get(t,"showAnim"),u=$.datepicker._get(t,"duration"),a=function(){var e=t.dpDiv.find("iframe.ui-datepicker-cover");if(!!e.length){var n=$.datepicker._getBorders(t.dpDiv);e.css({left:-n[0],top:-n[1],width:t.dpDiv.outerWidth(),height:t.dpDiv.outerHeight()})}};t.dpDiv.zIndex($(e).zIndex()+1),$.datepicker._datepickerShowing=!0,$.effects&&($.effects.effect[o]||$.effects[o])?t.dpDiv.show(o,$.datepicker._get(t,"showOptions"),u,a):t.dpDiv[o||"show"](o?u:null,a),(!o||!u)&&a(),t.input.is(":visible")&&!t.input.is(":disabled")&&t.input.focus(),$.datepicker._curInst=t}},_updateDatepicker:function(e){this.maxRows=4;var t=$.datepicker._getBorders(e.dpDiv);instActive=e,e.dpDiv.empty().append(this._generateHTML(e)),this._attachHandlers(e);var n=e.dpDiv.find("iframe.ui-datepicker-cover");!n.length||n.css({left:-t[0],top:-t[1],width:e.dpDiv.outerWidth(),height:e.dpDiv.outerHeight()}),e.dpDiv.find("."+this._dayOverClass+" a").mouseover();var r=this._getNumberOfMonths(e),i=r[1],s=17;e.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width(""),i>1&&e.dpDiv.addClass("ui-datepicker-multi-"+i).css("width",s*i+"em"),e.dpDiv[(r[0]!=1||r[1]!=1?"add":"remove")+"Class"]("ui-datepicker-multi"),e.dpDiv[(this._get(e,"isRTL")?"add":"remove")+"Class"]("ui-datepicker-rtl"),e==$.datepicker._curInst&&$.datepicker._datepickerShowing&&e.input&&e.input.is(":visible")&&!e.input.is(":disabled")&&e.input[0]!=document.activeElement&&e.input.focus();if(e.yearshtml){var o=e.yearshtml;setTimeout(function(){o===e.yearshtml&&e.yearshtml&&e.dpDiv.find("select.ui-datepicker-year:first").replaceWith(e.yearshtml),o=e.yearshtml=null},0)}},_getBorders:function(e){var t=function(e){return{thin:1,medium:2,thick:3}[e]||e};return[parseFloat(t(e.css("border-left-width"))),parseFloat(t(e.css("border-top-width")))]},_checkOffset:function(e,t,n){var r=e.dpDiv.outerWidth(),i=e.dpDiv.outerHeight(),s=e.input?e.input.outerWidth():0,o=e.input?e.input.outerHeight():0,u=document.documentElement.clientWidth+(n?0:$(document).scrollLeft()),a=document.documentElement.clientHeight+(n?0:$(document).scrollTop());return t.left-=this._get(e,"isRTL")?r-s:0,t.left-=n&&t.left==e.input.offset().left?$(document).scrollLeft():0,t.top-=n&&t.top==e.input.offset().top+o?$(document).scrollTop():0,t.left-=Math.min(t.left,t.left+r>u&&u>r?Math.abs(t.left+r-u):0),t.top-=Math.min(t.top,t.top+i>a&&a>i?Math.abs(i+o):0),t},_findPos:function(e){var t=this._getInst(e),n=this._get(t,"isRTL");while(e&&(e.type=="hidden"||e.nodeType!=1||$.expr.filters.hidden(e)))e=e[n?"previousSibling":"nextSibling"];var r=$(e).offset();return[r.left,r.top]},_hideDatepicker:function(e){var t=this._curInst;if(!t||e&&t!=$.data(e,PROP_NAME))return;if(this._datepickerShowing){var n=this._get(t,"showAnim"),r=this._get(t,"duration"),i=function(){$.datepicker._tidyDialog(t)};$.effects&&($.effects.effect[n]||$.effects[n])?t.dpDiv.hide(n,$.datepicker._get(t,"showOptions"),r,i):t.dpDiv[n=="slideDown"?"slideUp":n=="fadeIn"?"fadeOut":"hide"](n?r:null,i),n||i(),this._datepickerShowing=!1;var s=this._get(t,"onClose");s&&s.apply(t.input?t.input[0]:null,[t.input?t.input.val():"",t]),this._lastInput=null,this._inDialog&&(this._dialogInput.css({position:"absolute",left:"0",top:"-100px"}),$.blockUI&&($.unblockUI(),$("body").append(this.dpDiv))),this._inDialog=!1}},_tidyDialog:function(e){e.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar")},_checkExternalClick:function(e){if(!$.datepicker._curInst)return;var t=$(e.target),n=$.datepicker._getInst(t[0]);(t[0].id!=$.datepicker._mainDivId&&t.parents("#"+$.datepicker._mainDivId).length==0&&!t.hasClass($.datepicker.markerClassName)&&!t.closest("."+$.datepicker._triggerClass).length&&$.datepicker._datepickerShowing&&(!$.datepicker._inDialog||!$.blockUI)||t.hasClass($.datepicker.markerClassName)&&$.datepicker._curInst!=n)&&$.datepicker._hideDatepicker()},_adjustDate:function(e,t,n){var r=$(e),i=this._getInst(r[0]);if(this._isDisabledDatepicker(r[0]))return;this._adjustInstDate(i,t+(n=="M"?this._get(i,"showCurrentAtPos"):0),n),this._updateDatepicker(i)},_gotoToday:function(e){var t=$(e),n=this._getInst(t[0]);if(this._get(n,"gotoCurrent")&&n.currentDay)n.selectedDay=n.currentDay,n.drawMonth=n.selectedMonth=n.currentMonth,n.drawYear=n.selectedYear=n.currentYear;else{var r=new Date;n.selectedDay=r.getDate(),n.drawMonth=n.selectedMonth=r.getMonth(),n.drawYear=n.selectedYear=r.getFullYear()}this._notifyChange(n),this._adjustDate(t)},_selectMonthYear:function(e,t,n){var r=$(e),i=this._getInst(r[0]);i["selected"+(n=="M"?"Month":"Year")]=i["draw"+(n=="M"?"Month":"Year")]=parseInt(t.options[t.selectedIndex].value,10),this._notifyChange(i),this._adjustDate(r)},_selectDay:function(e,t,n,r){var i=$(e);if($(r).hasClass(this._unselectableClass)||this._isDisabledDatepicker(i[0]))return;var s=this._getInst(i[0]);s.selectedDay=s.currentDay=$("a",r).html(),s.selectedMonth=s.currentMonth=t,s.selectedYear=s.currentYear=n,this._selectDate(e,this._formatDate(s,s.currentDay,s.currentMonth,s.currentYear))},_clearDate:function(e){var t=$(e),n=this._getInst(t[0]);this._selectDate(t,"")},_selectDate:function(e,t){var n=$(e),r=this._getInst(n[0]);t=t!=null?t:this._formatDate(r),r.input&&r.input.val(t),this._updateAlternate(r);var i=this._get(r,"onSelect");i?i.apply(r.input?r.input[0]:null,[t,r]):r.input&&r.input.trigger("change"),r.inline?this._updateDatepicker(r):(this._hideDatepicker(),this._lastInput=r.input[0],typeof r.input[0]!="object"&&r.input.focus(),this._lastInput=null)},_updateAlternate:function(e){var t=this._get(e,"altField");if(t){var n=this._get(e,"altFormat")||this._get(e,"dateFormat"),r=this._getDate(e),i=this.formatDate(n,r,this._getFormatConfig(e));$(t).each(function(){$(this).val(i)})}},noWeekends:function(e){var t=e.getDay();return[t>0&&t<6,""]},iso8601Week:function(e){var t=new Date(e.getTime());t.setDate(t.getDate()+4-(t.getDay()||7));var n=t.getTime();return t.setMonth(0),t.setDate(1),Math.floor(Math.round((n-t)/864e5)/7)+1},parseDate:function(e,t,n){if(e==null||t==null)throw"Invalid arguments";t=typeof t=="object"?t.toString():t+"";if(t=="")return null;var r=(n?n.shortYearCutoff:null)||this._defaults.shortYearCutoff;r=typeof r!="string"?r:(new Date).getFullYear()%100+parseInt(r,10);var i=(n?n.dayNamesShort:null)||this._defaults.dayNamesShort,s=(n?n.dayNames:null)||this._defaults.dayNames,o=(n?n.monthNamesShort:null)||this._defaults.monthNamesShort,u=(n?n.monthNames:null)||this._defaults.monthNames,a=-1,f=-1,l=-1,c=-1,h=!1,p=function(t){var n=y+1<e.length&&e.charAt(y+1)==t;return n&&y++,n},d=function(e){var n=p(e),r=e=="@"?14:e=="!"?20:e=="y"&&n?4:e=="o"?3:2,i=new RegExp("^\\d{1,"+r+"}"),s=t.substring(g).match(i);if(!s)throw"Missing number at position "+g;return g+=s[0].length,parseInt(s[0],10)},v=function(e,n,r){var i=$.map(p(e)?r:n,function(e,t){return[[t,e]]}).sort(function(e,t){return-(e[1].length-t[1].length)}),s=-1;$.each(i,function(e,n){var r=n[1];if(t.substr(g,r.length).toLowerCase()==r.toLowerCase())return s=n[0],g+=r.length,!1});if(s!=-1)return s+1;throw"Unknown name at position "+g},m=function(){if(t.charAt(g)!=e.charAt(y))throw"Unexpected literal at position "+g;g++},g=0;for(var y=0;y<e.length;y++)if(h)e.charAt(y)=="'"&&!p("'")?h=!1:m();else switch(e.charAt(y)){case"d":l=d("d");break;case"D":v("D",i,s);break;case"o":c=d("o");break;case"m":f=d("m");break;case"M":f=v("M",o,u);break;case"y":a=d("y");break;case"@":var b=new Date(d("@"));a=b.getFullYear(),f=b.getMonth()+1,l=b.getDate();break;case"!":var b=new Date((d("!")-this._ticksTo1970)/1e4);a=b.getFullYear(),f=b.getMonth()+1,l=b.getDate();break;case"'":p("'")?m():h=!0;break;default:m()}if(g<t.length){var w=t.substr(g);if(!/^\s+/.test(w))throw"Extra/unparsed characters found in date: "+w}a==-1?a=(new Date).getFullYear():a<100&&(a+=(new Date).getFullYear()-(new Date).getFullYear()%100+(a<=r?0:-100));if(c>-1){f=1,l=c;do{var E=this._getDaysInMonth(a,f-1);if(l<=E)break;f++,l-=E}while(!0)}var b=this._daylightSavingAdjust(new Date(a,f-1,l));if(b.getFullYear()!=a||b.getMonth()+1!=f||b.getDate()!=l)throw"Invalid date";return b},ATOM:"yy-mm-dd",COOKIE:"D, dd M yy",ISO_8601:"yy-mm-dd",RFC_822:"D, d M y",RFC_850:"DD, dd-M-y",RFC_1036:"D, d M y",RFC_1123:"D, d M yy",RFC_2822:"D, d M yy",RSS:"D, d M y",TICKS:"!",TIMESTAMP:"@",W3C:"yy-mm-dd",_ticksTo1970:(718685+Math.floor(492.5)-Math.floor(19.7)+Math.floor(4.925))*24*60*60*1e7,formatDate:function(e,t,n){if(!t)return"";var r=(n?n.dayNamesShort:null)||this._defaults.dayNamesShort,i=(n?n.dayNames:null)||this._defaults.dayNames,s=(n?n.monthNamesShort:null)||this._defaults.monthNamesShort,o=(n?n.monthNames:null)||this._defaults.monthNames,u=function(t){var n=h+1<e.length&&e.charAt(h+1)==t;return n&&h++,n},a=function(e,t,n){var r=""+t;if(u(e))while(r.length<n)r="0"+r;return r},f=function(e,t,n,r){return u(e)?r[t]:n[t]},l="",c=!1;if(t)for(var h=0;h<e.length;h++)if(c)e.charAt(h)=="'"&&!u("'")?c=!1:l+=e.charAt(h);else switch(e.charAt(h)){case"d":l+=a("d",t.getDate(),2);break;case"D":l+=f("D",t.getDay(),r,i);break;case"o":l+=a("o",Math.round(((new Date(t.getFullYear(),t.getMonth(),t.getDate())).getTime()-(new Date(t.getFullYear(),0,0)).getTime())/864e5),3);break;case"m":l+=a("m",t.getMonth()+1,2);break;case"M":l+=f("M",t.getMonth(),s,o);break;case"y":l+=u("y")?t.getFullYear():(t.getYear()%100<10?"0":"")+t.getYear()%100;break;case"@":l+=t.getTime();break;case"!":l+=t.getTime()*1e4+this._ticksTo1970;break;case"'":u("'")?l+="'":c=!0;break;default:l+=e.charAt(h)}return l},_possibleChars:function(e){var t="",n=!1,r=function(t){var n=i+1<e.length&&e.charAt(i+1)==t;return n&&i++,n};for(var i=0;i<e.length;i++)if(n)e.charAt(i)=="'"&&!r("'")?n=!1:t+=e.charAt(i);else switch(e.charAt(i)){case"d":case"m":case"y":case"@":t+="0123456789";break;case"D":case"M":return null;case"'":r("'")?t+="'":n=!0;break;default:t+=e.charAt(i)}return t},_get:function(e,t){return e.settings[t]!==undefined?e.settings[t]:this._defaults[t]},_setDateFromField:function(e,t){if(e.input.val()==e.lastVal)return;var n=this._get(e,"dateFormat"),r=e.lastVal=e.input?e.input.val():null,i,s;i=s=this._getDefaultDate(e);var o=this._getFormatConfig(e);try{i=this.parseDate(n,r,o)||s}catch(u){this.log(u),r=t?"":r}e.selectedDay=i.getDate(),e.drawMonth=e.selectedMonth=i.getMonth(),e.drawYear=e.selectedYear=i.getFullYear(),e.currentDay=r?i.getDate():0,e.currentMonth=r?i.getMonth():0,e.currentYear=r?i.getFullYear():0,this._adjustInstDate(e)},_getDefaultDate:function(e){return this._restrictMinMax(e,this._determineDate(e,this._get(e,"defaultDate"),new Date))},_determineDate:function(e,t,n){var r=function(e){var t=new Date;return t.setDate(t.getDate()+e),t},i=function(t){try{return $.datepicker.parseDate($.datepicker._get(e,"dateFormat"),t,$.datepicker._getFormatConfig(e))}catch(n){}var r=(t.toLowerCase().match(/^c/)?$.datepicker._getDate(e):null)||new Date,i=r.getFullYear(),s=r.getMonth(),o=r.getDate(),u=/([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,a=u.exec(t);while(a){switch(a[2]||"d"){case"d":case"D":o+=parseInt(a[1],10);break;case"w":case"W":o+=parseInt(a[1],10)*7;break;case"m":case"M":s+=parseInt(a[1],10),o=Math.min(o,$.datepicker._getDaysInMonth(i,s));break;case"y":case"Y":i+=parseInt(a[1],10),o=Math.min(o,$.datepicker._getDaysInMonth(i,s))}a=u.exec(t)}return new Date(i,s,o)},s=t==null||t===""?n:typeof t=="string"?i(t):typeof t=="number"?isNaN(t)?n:r(t):new Date(t.getTime());return s=s&&s.toString()=="Invalid Date"?n:s,s&&(s.setHours(0),s.setMinutes(0),s.setSeconds(0),s.setMilliseconds(0)),this._daylightSavingAdjust(s)},_daylightSavingAdjust:function(e){return e?(e.setHours(e.getHours()>12?e.getHours()+2:0),e):null},_setDate:function(e,t,n){var r=!t,i=e.selectedMonth,s=e.selectedYear,o=this._restrictMinMax(e,this._determineDate(e,t,new Date));e.selectedDay=e.currentDay=o.getDate(),e.drawMonth=e.selectedMonth=e.currentMonth=o.getMonth(),e.drawYear=e.selectedYear=e.currentYear=o.getFullYear(),(i!=e.selectedMonth||s!=e.selectedYear)&&!n&&this._notifyChange(e),this._adjustInstDate(e),e.input&&e.input.val(r?"":this._formatDate(e))},_getDate:function(e){var t=!e.currentYear||e.input&&e.input.val()==""?null:this._daylightSavingAdjust(new Date(e.currentYear,e.currentMonth,e.currentDay));return t},_attachHandlers:function(e){var t=this._get(e,"stepMonths"),n="#"+e.id.replace(/\\\\/g,"\\");e.dpDiv.find("[data-handler]").map(function(){var e={prev:function(){window["DP_jQuery_"+dpuuid].datepicker._adjustDate(n,-t,"M")},next:function(){window["DP_jQuery_"+dpuuid].datepicker._adjustDate(n,+t,"M")},hide:function(){window["DP_jQuery_"+dpuuid].datepicker._hideDatepicker()},today:function(){window["DP_jQuery_"+dpuuid].datepicker._gotoToday(n)},selectDay:function(){return window["DP_jQuery_"+dpuuid].datepicker._selectDay(n,+this.getAttribute("data-month"),+this.getAttribute("data-year"),this),!1},selectMonth:function(){return window["DP_jQuery_"+dpuuid].datepicker._selectMonthYear(n,this,"M"),!1},selectYear:function(){return window["DP_jQuery_"+dpuuid].datepicker._selectMonthYear(n,this,"Y"),!1}};$(this).bind(this.getAttribute("data-event"),e[this.getAttribute("data-handler")])})},_generateHTML:function(e){var t=new Date;t=this._daylightSavingAdjust(new Date(t.getFullYear(),t.getMonth(),t.getDate()));var n=this._get(e,"isRTL"),r=this._get(e,"showButtonPanel"),i=this._get(e,"hideIfNoPrevNext"),s=this._get(e,"navigationAsDateFormat"),o=this._getNumberOfMonths(e),u=this._get(e,"showCurrentAtPos"),a=this._get(e,"stepMonths"),f=o[0]!=1||o[1]!=1,l=this._daylightSavingAdjust(e.currentDay?new Date(e.currentYear,e.currentMonth,e.currentDay):new Date(9999,9,9)),c=this._getMinMaxDate(e,"min"),h=this._getMinMaxDate(e,"max"),p=e.drawMonth-u,d=e.drawYear;p<0&&(p+=12,d--);if(h){var v=this._daylightSavingAdjust(new Date(h.getFullYear(),h.getMonth()-o[0]*o[1]+1,h.getDate()));v=c&&v<c?c:v;while(this._daylightSavingAdjust(new Date(d,p,1))>v)p--,p<0&&(p=11,d--)}e.drawMonth=p,e.drawYear=d;var m=this._get(e,"prevText");m=s?this.formatDate(m,this._daylightSavingAdjust(new Date(d,p-a,1)),this._getFormatConfig(e)):m;var g=this._canAdjustMonth(e,-1,d,p)?'<a class="ui-datepicker-prev ui-corner-all" data-handler="prev" data-event="click" title="'+m+'"><span class="ui-icon ui-icon-circle-triangle-'+(n?"e":"w")+'">'+m+"</span></a>":i?"":'<a class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="'+m+'"><span class="ui-icon ui-icon-circle-triangle-'+(n?"e":"w")+'">'+m+"</span></a>",y=this._get(e,"nextText");y=s?this.formatDate(y,this._daylightSavingAdjust(new Date(d,p+a,1)),this._getFormatConfig(e)):y;var b=this._canAdjustMonth(e,1,d,p)?'<a class="ui-datepicker-next ui-corner-all" data-handler="next" data-event="click" title="'+y+'"><span class="ui-icon ui-icon-circle-triangle-'+(n?"w":"e")+'">'+y+"</span></a>":i?"":'<a class="ui-datepicker-next ui-corner-all ui-state-disabled" title="'+y+'"><span class="ui-icon ui-icon-circle-triangle-'+(n?"w":"e")+'">'+y+"</span></a>",w=this._get(e,"currentText"),E=this._get(e,"gotoCurrent")&&e.currentDay?l:t;w=s?this.formatDate(w,E,this._getFormatConfig(e)):w;var S=e.inline?"":'<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" data-handler="hide" data-event="click">'+this._get(e,"closeText")+"</button>",x=r?'<div class="ui-datepicker-buttonpane ui-widget-content">'+(n?S:"")+(this._isInRange(e,E)?'<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" data-handler="today" data-event="click">'+w+"</button>":"")+(n?"":S)+"</div>":"",T=parseInt(this._get(e,"firstDay"),10);T=isNaN(T)?0:T;var N=this._get(e,"showWeek"),C=this._get(e,"dayNames"),k=this._get(e,"dayNamesShort"),L=this._get(e,"dayNamesMin"),A=this._get(e,"monthNames"),O=this._get(e,"monthNamesShort"),M=this._get(e,"beforeShowDay"),_=this._get(e,"showOtherMonths"),D=this._get(e,"selectOtherMonths"),P=this._get(e,"calculateWeek")||this.iso8601Week,H=this._getDefaultDate(e),B="";for(var j=0;j<o[0];j++){var F="";this.maxRows=4;for(var I=0;I<o[1];I++){var q=this._daylightSavingAdjust(new Date(d,p,e.selectedDay)),R=" ui-corner-all",U="";if(f){U+='<div class="ui-datepicker-group';if(o[1]>1)switch(I){case 0:U+=" ui-datepicker-group-first",R=" ui-corner-"+(n?"right":"left");break;case o[1]-1:U+=" ui-datepicker-group-last",R=" ui-corner-"+(n?"left":"right");break;default:U+=" ui-datepicker-group-middle",R=""}U+='">'}U+='<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix'+R+'">'+(/all|left/.test(R)&&j==0?n?b:g:"")+(/all|right/.test(R)&&j==0?n?g:b:"")+this._generateMonthYearHeader(e,p,d,c,h,j>0||I>0,A,O)+'</div><table class="ui-datepicker-calendar"><thead>'+"<tr>";var z=N?'<th class="ui-datepicker-week-col">'+this._get(e,"weekHeader")+"</th>":"";for(var W=0;W<7;W++){var X=(W+T)%7;z+="<th"+((W+T+6)%7>=5?' class="ui-datepicker-week-end"':"")+">"+'<span title="'+C[X]+'">'+L[X]+"</span></th>"}U+=z+"</tr></thead><tbody>";var V=this._getDaysInMonth(d,p);d==e.selectedYear&&p==e.selectedMonth&&(e.selectedDay=Math.min(e.selectedDay,V));var J=(this._getFirstDayOfMonth(d,p)-T+7)%7,K=Math.ceil((J+V)/7),Q=f?this.maxRows>K?this.maxRows:K:K;this.maxRows=Q;var G=this._daylightSavingAdjust(new Date(d,p,1-J));for(var Y=0;Y<Q;Y++){U+="<tr>";var Z=N?'<td class="ui-datepicker-week-col">'+this._get(e,"calculateWeek")(G)+"</td>":"";for(var W=0;W<7;W++){var et=M?M.apply(e.input?e.input[0]:null,[G]):[!0,""],tt=G.getMonth()!=p,nt=tt&&!D||!et[0]||c&&G<c||h&&G>h;Z+='<td class="'+((W+T+6)%7>=5?" ui-datepicker-week-end":"")+(tt?" ui-datepicker-other-month":"")+(G.getTime()==q.getTime()&&p==e.selectedMonth&&e._keyEvent||H.getTime()==G.getTime()&&H.getTime()==q.getTime()?" "+this._dayOverClass:"")+(nt?" "+this._unselectableClass+" ui-state-disabled":"")+(tt&&!_?"":" "+et[1]+(G.getTime()==l.getTime()?" "+this._currentClass:"")+(G.getTime()==t.getTime()?" ui-datepicker-today":""))+'"'+((!tt||_)&&et[2]?' title="'+et[2]+'"':"")+(nt?"":' data-handler="selectDay" data-event="click" data-month="'+G.getMonth()+'" data-year="'+G.getFullYear()+'"')+">"+(tt&&!_?"&#xa0;":nt?'<span class="ui-state-default">'+G.getDate()+"</span>":'<a class="ui-state-default'+(G.getTime()==t.getTime()?" ui-state-highlight":"")+(G.getTime()==l.getTime()?" ui-state-active":"")+(tt?" ui-priority-secondary":"")+'" href="#">'+G.getDate()+"</a>")+"</td>",G.setDate(G.getDate()+1),G=this._daylightSavingAdjust(G)}U+=Z+"</tr>"}p++,p>11&&(p=0,d++),U+="</tbody></table>"+(f?"</div>"+(o[0]>0&&I==o[1]-1?'<div class="ui-datepicker-row-break"></div>':""):""),F+=U}B+=F}return B+=x+($.ui.ie6&&!e.inline?'<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>':""),e._keyEvent=!1,B},_generateMonthYearHeader:function(e,t,n,r,i,s,o,u){var a=this._get(e,"changeMonth"),f=this._get(e,"changeYear"),l=this._get(e,"showMonthAfterYear"),c='<div class="ui-datepicker-title">',h="";if(s||!a)h+='<span class="ui-datepicker-month">'+o[t]+"</span>";else{var p=r&&r.getFullYear()==n,d=i&&i.getFullYear()==n;h+='<select class="ui-datepicker-month" data-handler="selectMonth" data-event="change">';for(var v=0;v<12;v++)(!p||v>=r.getMonth())&&(!d||v<=i.getMonth())&&(h+='<option value="'+v+'"'+(v==t?' selected="selected"':"")+">"+u[v]+"</option>");h+="</select>"}l||(c+=h+(s||!a||!f?"&#xa0;":""));if(!e.yearshtml){e.yearshtml="";if(s||!f)c+='<span class="ui-datepicker-year">'+n+"</span>";else{var m=this._get(e,"yearRange").split(":"),g=(new Date).getFullYear(),y=function(e){var t=e.match(/c[+-].*/)?n+parseInt(e.substring(1),10):e.match(/[+-].*/)?g+parseInt(e,10):parseInt(e,10);return isNaN(t)?g:t},b=y(m[0]),w=Math.max(b,y(m[1]||""));b=r?Math.max(b,r.getFullYear()):b,w=i?Math.min(w,i.getFullYear()):w,e.yearshtml+='<select class="ui-datepicker-year" data-handler="selectYear" data-event="change">';for(;b<=w;b++)e.yearshtml+='<option value="'+b+'"'+(b==n?' selected="selected"':"")+">"+b+"</option>";e.yearshtml+="</select>",c+=e.yearshtml,e.yearshtml=null}}return c+=this._get(e,"yearSuffix"),l&&(c+=(s||!a||!f?"&#xa0;":"")+h),c+="</div>",c},_adjustInstDate:function(e,t,n){var r=e.drawYear+(n=="Y"?t:0),i=e.drawMonth+(n=="M"?t:0),s=Math.min(e.selectedDay,this._getDaysInMonth(r,i))+(n=="D"?t:0),o=this._restrictMinMax(e,this._daylightSavingAdjust(new Date(r,i,s)));e.selectedDay=o.getDate(),e.drawMonth=e.selectedMonth=o.getMonth(),e.drawYear=e.selectedYear=o.getFullYear(),(n=="M"||n=="Y")&&this._notifyChange(e)},_restrictMinMax:function(e,t){var n=this._getMinMaxDate(e,"min"),r=this._getMinMaxDate(e,"max"),i=n&&t<n?n:t;return i=r&&i>r?r:i,i},_notifyChange:function(e){var t=this._get(e,"onChangeMonthYear");t&&t.apply(e.input?e.input[0]:null,[e.selectedYear,e.selectedMonth+1,e])},_getNumberOfMonths:function(e){var t=this._get(e,"numberOfMonths");return t==null?[1,1]:typeof t=="number"?[1,t]:t},_getMinMaxDate:function(e,t){return this._determineDate(e,this._get(e,t+"Date"),null)},_getDaysInMonth:function(e,t){return 32-this._daylightSavingAdjust(new Date(e,t,32)).getDate()},_getFirstDayOfMonth:function(e,t){return(new Date(e,t,1)).getDay()},_canAdjustMonth:function(e,t,n,r){var i=this._getNumberOfMonths(e),s=this._daylightSavingAdjust(new Date(n,r+(t<0?t:i[0]*i[1]),1));return t<0&&s.setDate(this._getDaysInMonth(s.getFullYear(),s.getMonth())),this._isInRange(e,s)},_isInRange:function(e,t){var n=this._getMinMaxDate(e,"min"),r=this._getMinMaxDate(e,"max");return(!n||t.getTime()>=n.getTime())&&(!r||t.getTime()<=r.getTime())},_getFormatConfig:function(e){var t=this._get(e,"shortYearCutoff");return t=typeof t!="string"?t:(new Date).getFullYear()%100+parseInt(t,10),{shortYearCutoff:t,dayNamesShort:this._get(e,"dayNamesShort"),dayNames:this._get(e,"dayNames"),monthNamesShort:this._get(e,"monthNamesShort"),monthNames:this._get(e,"monthNames")}},_formatDate:function(e,t,n,r){t||(e.currentDay=e.selectedDay,e.currentMonth=e.selectedMonth,e.currentYear=e.selectedYear);var i=t?typeof t=="object"?t:this._daylightSavingAdjust(new Date(r,n,t)):this._daylightSavingAdjust(new Date(e.currentYear,e.currentMonth,e.currentDay));return this.formatDate(this._get(e,"dateFormat"),i,this._getFormatConfig(e))}}),$.fn.datepicker=function(e){if(!this.length)return this;$.datepicker.initialized||($(document).mousedown($.datepicker._checkExternalClick).find(document.body).append($.datepicker.dpDiv),$.datepicker.initialized=!0);var t=Array.prototype.slice.call(arguments,1);return typeof e!="string"||e!="isDisabled"&&e!="getDate"&&e!="widget"?e=="option"&&arguments.length==2&&typeof arguments[1]=="string"?$.datepicker["_"+e+"Datepicker"].apply($.datepicker,[this[0]].concat(t)):this.each(function(){typeof e=="string"?$.datepicker["_"+e+"Datepicker"].apply($.datepicker,[this].concat(t)):$.datepicker._attachDatepicker(this,e)}):$.datepicker["_"+e+"Datepicker"].apply($.datepicker,[this[0]].concat(t))},$.datepicker=new Datepicker,$.datepicker.initialized=!1,$.datepicker.uuid=(new Date).getTime(),$.datepicker.version="1.9.1",window["DP_jQuery_"+dpuuid]=$})(jQuery);(function(e,t){var n="ui-dialog ui-widget ui-widget-content ui-corner-all ",r={buttons:!0,height:!0,maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0,width:!0},i={maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0};e.widget("ui.dialog",{version:"1.9.1",options:{autoOpen:!0,buttons:{},closeOnEscape:!0,closeText:"close",dialogClass:"",draggable:!0,hide:null,height:"auto",maxHeight:!1,maxWidth:!1,minHeight:150,minWidth:150,modal:!1,position:{my:"center",at:"center",of:window,collision:"fit",using:function(t){var n=e(this).css(t).offset().top;n<0&&e(this).css("top",t.top-n)}},resizable:!0,show:null,stack:!0,title:"",width:300,zIndex:1e3},_create:function(){this.originalTitle=this.element.attr("title"),typeof this.originalTitle!="string"&&(this.originalTitle=""),this.oldPosition={parent:this.element.parent(),index:this.element.parent().children().index(this.element)},this.options.title=this.options.title||this.originalTitle;var t=this,r=this.options,i=r.title||"&#160;",s,o,u,a,f;s=(this.uiDialog=e("<div>")).addClass(n+r.dialogClass).css({display:"none",outline:0,zIndex:r.zIndex}).attr("tabIndex",-1).keydown(function(n){r.closeOnEscape&&!n.isDefaultPrevented()&&n.keyCode&&n.keyCode===e.ui.keyCode.ESCAPE&&(t.close(n),n.preventDefault())}).mousedown(function(e){t.moveToTop(!1,e)}).appendTo("body"),this.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(s),o=(this.uiDialogTitlebar=e("<div>")).addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").bind("mousedown",function(){s.focus()}).prependTo(s),u=e("<a href='#'></a>").addClass("ui-dialog-titlebar-close ui-corner-all").attr("role","button").click(function(e){e.preventDefault(),t.close(e)}).appendTo(o),(this.uiDialogTitlebarCloseText=e("<span>")).addClass("ui-icon ui-icon-closethick").text(r.closeText).appendTo(u),a=e("<span>").uniqueId().addClass("ui-dialog-title").html(i).prependTo(o),f=(this.uiDialogButtonPane=e("<div>")).addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),(this.uiButtonSet=e("<div>")).addClass("ui-dialog-buttonset").appendTo(f),s.attr({role:"dialog","aria-labelledby":a.attr("id")}),o.find("*").add(o).disableSelection(),this._hoverable(u),this._focusable(u),r.draggable&&e.fn.draggable&&this._makeDraggable(),r.resizable&&e.fn.resizable&&this._makeResizable(),this._createButtons(r.buttons),this._isOpen=!1,e.fn.bgiframe&&s.bgiframe(),this._on(s,{keydown:function(t){if(!r.modal||t.keyCode!==e.ui.keyCode.TAB)return;var n=e(":tabbable",s),i=n.filter(":first"),o=n.filter(":last");if(t.target===o[0]&&!t.shiftKey)return i.focus(1),!1;if(t.target===i[0]&&t.shiftKey)return o.focus(1),!1}})},_init:function(){this.options.autoOpen&&this.open()},_destroy:function(){var e,t=this.oldPosition;this.overlay&&this.overlay.destroy(),this.uiDialog.hide(),this.element.removeClass("ui-dialog-content ui-widget-content").hide().appendTo("body"),this.uiDialog.remove(),this.originalTitle&&this.element.attr("title",this.originalTitle),e=t.parent.children().eq(t.index),e.length&&e[0]!==this.element[0]?e.before(this.element):t.parent.append(this.element)},widget:function(){return this.uiDialog},close:function(t){var n=this,r,i;if(!this._isOpen)return;if(!1===this._trigger("beforeClose",t))return;return this._isOpen=!1,this.overlay&&this.overlay.destroy(),this.options.hide?this._hide(this.uiDialog,this.options.hide,function(){n._trigger("close",t)}):(this.uiDialog.hide(),this._trigger("close",t)),e.ui.dialog.overlay.resize(),this.options.modal&&(r=0,e(".ui-dialog").each(function(){this!==n.uiDialog[0]&&(i=e(this).css("z-index"),isNaN(i)||(r=Math.max(r,i)))}),e.ui.dialog.maxZ=r),this},isOpen:function(){return this._isOpen},moveToTop:function(t,n){var r=this.options,i;return r.modal&&!t||!r.stack&&!r.modal?this._trigger("focus",n):(r.zIndex>e.ui.dialog.maxZ&&(e.ui.dialog.maxZ=r.zIndex),this.overlay&&(e.ui.dialog.maxZ+=1,e.ui.dialog.overlay.maxZ=e.ui.dialog.maxZ,this.overlay.$el.css("z-index",e.ui.dialog.overlay.maxZ)),i={scrollTop:this.element.scrollTop(),scrollLeft:this.element.scrollLeft()},e.ui.dialog.maxZ+=1,this.uiDialog.css("z-index",e.ui.dialog.maxZ),this.element.attr(i),this._trigger("focus",n),this)},open:function(){if(this._isOpen)return;var t,n=this.options,r=this.uiDialog;return this._size(),this._position(n.position),r.show(n.show),this.overlay=n.modal?new e.ui.dialog.overlay(this):null,this.moveToTop(!0),t=this.element.find(":tabbable"),t.length||(t=this.uiDialogButtonPane.find(":tabbable"),t.length||(t=r)),t.eq(0).focus(),this._isOpen=!0,this._trigger("open"),this},_createButtons:function(t){var n=this,r=!1;this.uiDialogButtonPane.remove(),this.uiButtonSet.empty(),typeof t=="object"&&t!==null&&e.each(t,function(){return!(r=!0)}),r?(e.each(t,function(t,r){r=e.isFunction(r)?{click:r,text:t}:r;var i=e("<button type='button'></button>").attr(r,!0).unbind("click").click(function(){r.click.apply(n.element[0],arguments)}).appendTo(n.uiButtonSet);e.fn.button&&i.button()}),this.uiDialog.addClass("ui-dialog-buttons"),this.uiDialogButtonPane.appendTo(this.uiDialog)):this.uiDialog.removeClass("ui-dialog-buttons")},_makeDraggable:function(){function r(e){return{position:e.position,offset:e.offset}}var t=this,n=this.options;this.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",handle:".ui-dialog-titlebar",containment:"document",start:function(n,i){e(this).addClass("ui-dialog-dragging"),t._trigger("dragStart",n,r(i))},drag:function(e,n){t._trigger("drag",e,r(n))},stop:function(i,s){n.position=[s.position.left-t.document.scrollLeft(),s.position.top-t.document.scrollTop()],e(this).removeClass("ui-dialog-dragging"),t._trigger("dragStop",i,r(s)),e.ui.dialog.overlay.resize()}})},_makeResizable:function(n){function u(e){return{originalPosition:e.originalPosition,originalSize:e.originalSize,position:e.position,size:e.size}}n=n===t?this.options.resizable:n;var r=this,i=this.options,s=this.uiDialog.css("position"),o=typeof n=="string"?n:"n,e,s,w,se,sw,ne,nw";this.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:this.element,maxWidth:i.maxWidth,maxHeight:i.maxHeight,minWidth:i.minWidth,minHeight:this._minHeight(),handles:o,start:function(t,n){e(this).addClass("ui-dialog-resizing"),r._trigger("resizeStart",t,u(n))},resize:function(e,t){r._trigger("resize",e,u(t))},stop:function(t,n){e(this).removeClass("ui-dialog-resizing"),i.height=e(this).height(),i.width=e(this).width(),r._trigger("resizeStop",t,u(n)),e.ui.dialog.overlay.resize()}}).css("position",s).find(".ui-resizable-se").addClass("ui-icon ui-icon-grip-diagonal-se")},_minHeight:function(){var e=this.options;return e.height==="auto"?e.minHeight:Math.min(e.minHeight,e.height)},_position:function(t){var n=[],r=[0,0],i;if(t){if(typeof t=="string"||typeof t=="object"&&"0"in t)n=t.split?t.split(" "):[t[0],t[1]],n.length===1&&(n[1]=n[0]),e.each(["left","top"],function(e,t){+n[e]===n[e]&&(r[e]=n[e],n[e]=t)}),t={my:n[0]+(r[0]<0?r[0]:"+"+r[0])+" "+n[1]+(r[1]<0?r[1]:"+"+r[1]),at:n.join(" ")};t=e.extend({},e.ui.dialog.prototype.options.position,t)}else t=e.ui.dialog.prototype.options.position;i=this.uiDialog.is(":visible"),i||this.uiDialog.show(),this.uiDialog.position(t),i||this.uiDialog.hide()},_setOptions:function(t){var n=this,s={},o=!1;e.each(t,function(e,t){n._setOption(e,t),e in r&&(o=!0),e in i&&(s[e]=t)}),o&&this._size(),this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option",s)},_setOption:function(t,r){var i,s,o=this.uiDialog;switch(t){case"buttons":this._createButtons(r);break;case"closeText":this.uiDialogTitlebarCloseText.text(""+r);break;case"dialogClass":o.removeClass(this.options.dialogClass).addClass(n+r);break;case"disabled":r?o.addClass("ui-dialog-disabled"):o.removeClass("ui-dialog-disabled");break;case"draggable":i=o.is(":data(draggable)"),i&&!r&&o.draggable("destroy"),!i&&r&&this._makeDraggable();break;case"position":this._position(r);break;case"resizable":s=o.is(":data(resizable)"),s&&!r&&o.resizable("destroy"),s&&typeof r=="string"&&o.resizable("option","handles",r),!s&&r!==!1&&this._makeResizable(r);break;case"title":e(".ui-dialog-title",this.uiDialogTitlebar).html(""+(r||"&#160;"))}this._super(t,r)},_size:function(){var t,n,r,i=this.options,s=this.uiDialog.is(":visible");this.element.show().css({width:"auto",minHeight:0,height:0}),i.minWidth>i.width&&(i.width=i.minWidth),t=this.uiDialog.css({height:"auto",width:i.width}).outerHeight(),n=Math.max(0,i.minHeight-t),i.height==="auto"?e.support.minHeight?this.element.css({minHeight:n,height:"auto"}):(this.uiDialog.show(),r=this.element.css("height","auto").height(),s||this.uiDialog.hide(),this.element.height(Math.max(r,n))):this.element.height(Math.max(i.height-t,0)),this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())}}),e.extend(e.ui.dialog,{uuid:0,maxZ:0,getTitleId:function(e){var t=e.attr("id");return t||(this.uuid+=1,t=this.uuid),"ui-dialog-title-"+t},overlay:function(t){this.$el=e.ui.dialog.overlay.create(t)}}),e.extend(e.ui.dialog.overlay,{instances:[],oldInstances:[],maxZ:0,events:e.map("focus,mousedown,mouseup,keydown,keypress,click".split(","),function(e){return e+".dialog-overlay"}).join(" "),create:function(t){this.instances.length===0&&(setTimeout(function(){e.ui.dialog.overlay.instances.length&&e(document).bind(e.ui.dialog.overlay.events,function(t){if(e(t.target).zIndex()<e.ui.dialog.overlay.maxZ)return!1})},1),e(window).bind("resize.dialog-overlay",e.ui.dialog.overlay.resize));var n=this.oldInstances.pop()||e("<div>").addClass("ui-widget-overlay");return e(document).bind("keydown.dialog-overlay",function(r){var i=e.ui.dialog.overlay.instances;i.length!==0&&i[i.length-1]===n&&t.options.closeOnEscape&&!r.isDefaultPrevented()&&r.keyCode&&r.keyCode===e.ui.keyCode.ESCAPE&&(t.close(r),r.preventDefault())}),n.appendTo(document.body).css({width:this.width(),height:this.height()}),e.fn.bgiframe&&n.bgiframe(),this.instances.push(n),n},destroy:function(t){var n=e.inArray(t,this.instances),r=0;n!==-1&&this.oldInstances.push(this.instances.splice(n,1)[0]),this.instances.length===0&&e([document,window]).unbind(".dialog-overlay"),t.height(0).width(0).remove(),e.each(this.instances,function(){r=Math.max(r,this.css("z-index"))}),this.maxZ=r},height:function(){var t,n;return e.ui.ie?(t=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight),n=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight),t<n?e(window).height()+"px":t+"px"):e(document).height()+"px"},width:function(){var t,n;return e.ui.ie?(t=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth),n=Math.max(document.documentElement.offsetWidth,document.body.offsetWidth),t<n?e(window).width()+"px":t+"px"):e(document).width()+"px"},resize:function(){var t=e([]);e.each(e.ui.dialog.overlay.instances,function(){t=t.add(this)}),t.css({width:0,height:0}).css({width:e.ui.dialog.overlay.width(),height:e.ui.dialog.overlay.height()})}}),e.extend(e.ui.dialog.overlay.prototype,{destroy:function(){e.ui.dialog.overlay.destroy(this.$el)}})})(jQuery);(function(e,t){e.widget("ui.draggable",e.ui.mouse,{version:"1.9.1",widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1},_create:function(){this.options.helper=="original"&&!/^(?:r|a|f)/.test(this.element.css("position"))&&(this.element[0].style.position="relative"),this.options.addClasses&&this.element.addClass("ui-draggable"),this.options.disabled&&this.element.addClass("ui-draggable-disabled"),this._mouseInit()},_destroy:function(){this.element.removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled"),this._mouseDestroy()},_mouseCapture:function(t){var n=this.options;return this.helper||n.disabled||e(t.target).is(".ui-resizable-handle")?!1:(this.handle=this._getHandle(t),this.handle?(e(n.iframeFix===!0?"iframe":n.iframeFix).each(function(){e('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1e3}).css(e(this).offset()).appendTo("body")}),!0):!1)},_mouseStart:function(t){var n=this.options;return this.helper=this._createHelper(t),this.helper.addClass("ui-draggable-dragging"),this._cacheHelperProportions(),e.ui.ddmanager&&(e.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(),this.offset=this.positionAbs=this.element.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},e.extend(this.offset,{click:{left:t.pageX-this.offset.left,top:t.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.originalPosition=this.position=this._generatePosition(t),this.originalPageX=t.pageX,this.originalPageY=t.pageY,n.cursorAt&&this._adjustOffsetFromHelper(n.cursorAt),n.containment&&this._setContainment(),this._trigger("start",t)===!1?(this._clear(),!1):(this._cacheHelperProportions(),e.ui.ddmanager&&!n.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t),this._mouseDrag(t,!0),e.ui.ddmanager&&e.ui.ddmanager.dragStart(this,t),!0)},_mouseDrag:function(t,n){this.position=this._generatePosition(t),this.positionAbs=this._convertPositionTo("absolute");if(!n){var r=this._uiHash();if(this._trigger("drag",t,r)===!1)return this._mouseUp({}),!1;this.position=r.position}if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";return e.ui.ddmanager&&e.ui.ddmanager.drag(this,t),!1},_mouseStop:function(t){var n=!1;e.ui.ddmanager&&!this.options.dropBehaviour&&(n=e.ui.ddmanager.drop(this,t)),this.dropped&&(n=this.dropped,this.dropped=!1);var r=this.element[0],i=!1;while(r&&(r=r.parentNode))r==document&&(i=!0);if(!i&&this.options.helper==="original")return!1;if(this.options.revert=="invalid"&&!n||this.options.revert=="valid"&&n||this.options.revert===!0||e.isFunction(this.options.revert)&&this.options.revert.call(this.element,n)){var s=this;e(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){s._trigger("stop",t)!==!1&&s._clear()})}else this._trigger("stop",t)!==!1&&this._clear();return!1},_mouseUp:function(t){return e("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)}),e.ui.ddmanager&&e.ui.ddmanager.dragStop(this,t),e.ui.mouse.prototype._mouseUp.call(this,t)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear(),this},_getHandle:function(t){var n=!this.options.handle||!e(this.options.handle,this.element).length?!0:!1;return e(this.options.handle,this.element).find("*").andSelf().each(function(){this==t.target&&(n=!0)}),n},_createHelper:function(t){var n=this.options,r=e.isFunction(n.helper)?e(n.helper.apply(this.element[0],[t])):n.helper=="clone"?this.element.clone().removeAttr("id"):this.element;return r.parents("body").length||r.appendTo(n.appendTo=="parent"?this.element[0].parentNode:n.appendTo),r[0]!=this.element[0]&&!/(fixed|absolute)/.test(r.css("position"))&&r.css("position","absolute"),r},_adjustOffsetFromHelper:function(t){typeof t=="string"&&(t=t.split(" ")),e.isArray(t)&&(t={left:+t[0],top:+t[1]||0}),"left"in t&&(this.offset.click.left=t.left+this.margins.left),"right"in t&&(this.offset.click.left=this.helperProportions.width-t.right+this.margins.left),"top"in t&&(this.offset.click.top=t.top+this.margins.top),"bottom"in t&&(this.offset.click.top=this.helperProportions.height-t.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var t=this.offsetParent.offset();this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&e.contains(this.scrollParent[0],this.offsetParent[0])&&(t.left+=this.scrollParent.scrollLeft(),t.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&e.ui.ie)t={top:0,left:0};return{top:t.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:t.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var e=this.element.position();return{top:e.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:e.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var t=this.options;t.containment=="parent"&&(t.containment=this.helper[0].parentNode);if(t.containment=="document"||t.containment=="window")this.containment=[t.containment=="document"?0:e(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,t.containment=="document"?0:e(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,(t.containment=="document"?0:e(window).scrollLeft())+e(t.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(t.containment=="document"?0:e(window).scrollTop())+(e(t.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(t.containment)&&t.containment.constructor!=Array){var n=e(t.containment),r=n[0];if(!r)return;var i=n.offset(),s=e(r).css("overflow")!="hidden";this.containment=[(parseInt(e(r).css("borderLeftWidth"),10)||0)+(parseInt(e(r).css("paddingLeft"),10)||0),(parseInt(e(r).css("borderTopWidth"),10)||0)+(parseInt(e(r).css("paddingTop"),10)||0),(s?Math.max(r.scrollWidth,r.offsetWidth):r.offsetWidth)-(parseInt(e(r).css("borderLeftWidth"),10)||0)-(parseInt(e(r).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(s?Math.max(r.scrollHeight,r.offsetHeight):r.offsetHeight)-(parseInt(e(r).css("borderTopWidth"),10)||0)-(parseInt(e(r).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relative_container=n}else t.containment.constructor==Array&&(this.containment=t.containment)},_convertPositionTo:function(t,n){n||(n=this.position);var r=t=="absolute"?1:-1,i=this.options,s=this.cssPosition!="absolute"||this.scrollParent[0]!=document&&!!e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,o=/(html|body)/i.test(s[0].tagName);return{top:n.top+this.offset.relative.top*r+this.offset.parent.top*r-(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():o?0:s.scrollTop())*r,left:n.left+this.offset.relative.left*r+this.offset.parent.left*r-(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():o?0:s.scrollLeft())*r}},_generatePosition:function(t){var n=this.options,r=this.cssPosition!="absolute"||this.scrollParent[0]!=document&&!!e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,i=/(html|body)/i.test(r[0].tagName),s=t.pageX,o=t.pageY;if(this.originalPosition){var u;if(this.containment){if(this.relative_container){var a=this.relative_container.offset();u=[this.containment[0]+a.left,this.containment[1]+a.top,this.containment[2]+a.left,this.containment[3]+a.top]}else u=this.containment;t.pageX-this.offset.click.left<u[0]&&(s=u[0]+this.offset.click.left),t.pageY-this.offset.click.top<u[1]&&(o=u[1]+this.offset.click.top),t.pageX-this.offset.click.left>u[2]&&(s=u[2]+this.offset.click.left),t.pageY-this.offset.click.top>u[3]&&(o=u[3]+this.offset.click.top)}if(n.grid){var f=n.grid[1]?this.originalPageY+Math.round((o-this.originalPageY)/n.grid[1])*n.grid[1]:this.originalPageY;o=u?f-this.offset.click.top<u[1]||f-this.offset.click.top>u[3]?f-this.offset.click.top<u[1]?f+n.grid[1]:f-n.grid[1]:f:f;var l=n.grid[0]?this.originalPageX+Math.round((s-this.originalPageX)/n.grid[0])*n.grid[0]:this.originalPageX;s=u?l-this.offset.click.left<u[0]||l-this.offset.click.left>u[2]?l-this.offset.click.left<u[0]?l+n.grid[0]:l-n.grid[0]:l:l}}return{top:o-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():i?0:r.scrollTop()),left:s-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():i?0:r.scrollLeft())}},_clear:function(){this.helper.removeClass("ui-draggable-dragging"),this.helper[0]!=this.element[0]&&!this.cancelHelperRemoval&&this.helper.remove(),this.helper=null,this.cancelHelperRemoval=!1},_trigger:function(t,n,r){return r=r||this._uiHash(),e.ui.plugin.call(this,t,[n,r]),t=="drag"&&(this.positionAbs=this._convertPositionTo("absolute")),e.Widget.prototype._trigger.call(this,t,n,r)},plugins:{},_uiHash:function(e){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}}),e.ui.plugin.add("draggable","connectToSortable",{start:function(t,n){var r=e(this).data("draggable"),i=r.options,s=e.extend({},n,{item:r.element});r.sortables=[],e(i.connectToSortable).each(function(){var n=e.data(this,"sortable");n&&!n.options.disabled&&(r.sortables.push({instance:n,shouldRevert:n.options.revert}),n.refreshPositions(),n._trigger("activate",t,s))})},stop:function(t,n){var r=e(this).data("draggable"),i=e.extend({},n,{item:r.element});e.each(r.sortables,function(){this.instance.isOver?(this.instance.isOver=0,r.cancelHelperRemoval=!0,this.instance.cancelHelperRemoval=!1,this.shouldRevert&&(this.instance.options.revert=!0),this.instance._mouseStop(t),this.instance.options.helper=this.instance.options._helper,r.options.helper=="original"&&this.instance.currentItem.css({top:"auto",left:"auto"})):(this.instance.cancelHelperRemoval=!1,this.instance._trigger("deactivate",t,i))})},drag:function(t,n){var r=e(this).data("draggable"),i=this,s=function(t){var n=this.offset.click.top,r=this.offset.click.left,i=this.positionAbs.top,s=this.positionAbs.left,o=t.height,u=t.width,a=t.top,f=t.left;return e.ui.isOver(i+n,s+r,a,f,o,u)};e.each(r.sortables,function(s){var o=!1,u=this;this.instance.positionAbs=r.positionAbs,this.instance.helperProportions=r.helperProportions,this.instance.offset.click=r.offset.click,this.instance._intersectsWith(this.instance.containerCache)&&(o=!0,e.each(r.sortables,function(){return this.instance.positionAbs=r.positionAbs,this.instance.helperProportions=r.helperProportions,this.instance.offset.click=r.offset.click,this!=u&&this.instance._intersectsWith(this.instance.containerCache)&&e.ui.contains(u.instance.element[0],this.instance.element[0])&&(o=!1),o})),o?(this.instance.isOver||(this.instance.isOver=1,this.instance.currentItem=e(i).clone().removeAttr("id").appendTo(this.instance.element).data("sortable-item",!0),this.instance.options._helper=this.instance.options.helper,this.instance.options.helper=function(){return n.helper[0]},t.target=this.instance.currentItem[0],this.instance._mouseCapture(t,!0),this.instance._mouseStart(t,!0,!0),this.instance.offset.click.top=r.offset.click.top,this.instance.offset.click.left=r.offset.click.left,this.instance.offset.parent.left-=r.offset.parent.left-this.instance.offset.parent.left,this.instance.offset.parent.top-=r.offset.parent.top-this.instance.offset.parent.top,r._trigger("toSortable",t),r.dropped=this.instance.element,r.currentItem=r.element,this.instance.fromOutside=r),this.instance.currentItem&&this.instance._mouseDrag(t)):this.instance.isOver&&(this.instance.isOver=0,this.instance.cancelHelperRemoval=!0,this.instance.options.revert=!1,this.instance._trigger("out",t,this.instance._uiHash(this.instance)),this.instance._mouseStop(t,!0),this.instance.options.helper=this.instance.options._helper,this.instance.currentItem.remove(),this.instance.placeholder&&this.instance.placeholder.remove(),r._trigger("fromSortable",t),r.dropped=!1)})}}),e.ui.plugin.add("draggable","cursor",{start:function(t,n){var r=e("body"),i=e(this).data("draggable").options;r.css("cursor")&&(i._cursor=r.css("cursor")),r.css("cursor",i.cursor)},stop:function(t,n){var r=e(this).data("draggable").options;r._cursor&&e("body").css("cursor",r._cursor)}}),e.ui.plugin.add("draggable","opacity",{start:function(t,n){var r=e(n.helper),i=e(this).data("draggable").options;r.css("opacity")&&(i._opacity=r.css("opacity")),r.css("opacity",i.opacity)},stop:function(t,n){var r=e(this).data("draggable").options;r._opacity&&e(n.helper).css("opacity",r._opacity)}}),e.ui.plugin.add("draggable","scroll",{start:function(t,n){var r=e(this).data("draggable");r.scrollParent[0]!=document&&r.scrollParent[0].tagName!="HTML"&&(r.overflowOffset=r.scrollParent.offset())},drag:function(t,n){var r=e(this).data("draggable"),i=r.options,s=!1;if(r.scrollParent[0]!=document&&r.scrollParent[0].tagName!="HTML"){if(!i.axis||i.axis!="x")r.overflowOffset.top+r.scrollParent[0].offsetHeight-t.pageY<i.scrollSensitivity?r.scrollParent[0].scrollTop=s=r.scrollParent[0].scrollTop+i.scrollSpeed:t.pageY-r.overflowOffset.top<i.scrollSensitivity&&(r.scrollParent[0].scrollTop=s=r.scrollParent[0].scrollTop-i.scrollSpeed);if(!i.axis||i.axis!="y")r.overflowOffset.left+r.scrollParent[0].offsetWidth-t.pageX<i.scrollSensitivity?r.scrollParent[0].scrollLeft=s=r.scrollParent[0].scrollLeft+i.scrollSpeed:t.pageX-r.overflowOffset.left<i.scrollSensitivity&&(r.scrollParent[0].scrollLeft=s=r.scrollParent[0].scrollLeft-i.scrollSpeed)}else{if(!i.axis||i.axis!="x")t.pageY-e(document).scrollTop()<i.scrollSensitivity?s=e(document).scrollTop(e(document).scrollTop()-i.scrollSpeed):e(window).height()-(t.pageY-e(document).scrollTop())<i.scrollSensitivity&&(s=e(document).scrollTop(e(document).scrollTop()+i.scrollSpeed));if(!i.axis||i.axis!="y")t.pageX-e(document).scrollLeft()<i.scrollSensitivity?s=e(document).scrollLeft(e(document).scrollLeft()-i.scrollSpeed):e(window).width()-(t.pageX-e(document).scrollLeft())<i.scrollSensitivity&&(s=e(document).scrollLeft(e(document).scrollLeft()+i.scrollSpeed))}s!==!1&&e.ui.ddmanager&&!i.dropBehaviour&&e.ui.ddmanager.prepareOffsets(r,t)}}),e.ui.plugin.add("draggable","snap",{start:function(t,n){var r=e(this).data("draggable"),i=r.options;r.snapElements=[],e(i.snap.constructor!=String?i.snap.items||":data(draggable)":i.snap).each(function(){var t=e(this),n=t.offset();this!=r.element[0]&&r.snapElements.push({item:this,width:t.outerWidth(),height:t.outerHeight(),top:n.top,left:n.left})})},drag:function(t,n){var r=e(this).data("draggable"),i=r.options,s=i.snapTolerance,o=n.offset.left,u=o+r.helperProportions.width,a=n.offset.top,f=a+r.helperProportions.height;for(var l=r.snapElements.length-1;l>=0;l--){var c=r.snapElements[l].left,h=c+r.snapElements[l].width,p=r.snapElements[l].top,d=p+r.snapElements[l].height;if(!(c-s<o&&o<h+s&&p-s<a&&a<d+s||c-s<o&&o<h+s&&p-s<f&&f<d+s||c-s<u&&u<h+s&&p-s<a&&a<d+s||c-s<u&&u<h+s&&p-s<f&&f<d+s)){r.snapElements[l].snapping&&r.options.snap.release&&r.options.snap.release.call(r.element,t,e.extend(r._uiHash(),{snapItem:r.snapElements[l].item})),r.snapElements[l].snapping=!1;continue}if(i.snapMode!="inner"){var v=Math.abs(p-f)<=s,m=Math.abs(d-a)<=s,g=Math.abs(c-u)<=s,y=Math.abs(h-o)<=s;v&&(n.position.top=r._convertPositionTo("relative",{top:p-r.helperProportions.height,left:0}).top-r.margins.top),m&&(n.position.top=r._convertPositionTo("relative",{top:d,left:0}).top-r.margins.top),g&&(n.position.left=r._convertPositionTo("relative",{top:0,left:c-r.helperProportions.width}).left-r.margins.left),y&&(n.position.left=r._convertPositionTo("relative",{top:0,left:h}).left-r.margins.left)}var b=v||m||g||y;if(i.snapMode!="outer"){var v=Math.abs(p-a)<=s,m=Math.abs(d-f)<=s,g=Math.abs(c-o)<=s,y=Math.abs(h-u)<=s;v&&(n.position.top=r._convertPositionTo("relative",{top:p,left:0}).top-r.margins.top),m&&(n.position.top=r._convertPositionTo("relative",{top:d-r.helperProportions.height,left:0}).top-r.margins.top),g&&(n.position.left=r._convertPositionTo("relative",{top:0,left:c}).left-r.margins.left),y&&(n.position.left=r._convertPositionTo("relative",{top:0,left:h-r.helperProportions.width}).left-r.margins.left)}!r.snapElements[l].snapping&&(v||m||g||y||b)&&r.options.snap.snap&&r.options.snap.snap.call(r.element,t,e.extend(r._uiHash(),{snapItem:r.snapElements[l].item})),r.snapElements[l].snapping=v||m||g||y||b}}}),e.ui.plugin.add("draggable","stack",{start:function(t,n){var r=e(this).data("draggable").options,i=e.makeArray(e(r.stack)).sort(function(t,n){return(parseInt(e(t).css("zIndex"),10)||0)-(parseInt(e(n).css("zIndex"),10)||0)});if(!i.length)return;var s=parseInt(i[0].style.zIndex)||0;e(i).each(function(e){this.style.zIndex=s+e}),this[0].style.zIndex=s+i.length}}),e.ui.plugin.add("draggable","zIndex",{start:function(t,n){var r=e(n.helper),i=e(this).data("draggable").options;r.css("zIndex")&&(i._zIndex=r.css("zIndex")),r.css("zIndex",i.zIndex)},stop:function(t,n){var r=e(this).data("draggable").options;r._zIndex&&e(n.helper).css("zIndex",r._zIndex)}})})(jQuery);(function(e,t){e.widget("ui.droppable",{version:"1.9.1",widgetEventPrefix:"drop",options:{accept:"*",activeClass:!1,addClasses:!0,greedy:!1,hoverClass:!1,scope:"default",tolerance:"intersect"},_create:function(){var t=this.options,n=t.accept;this.isover=0,this.isout=1,this.accept=e.isFunction(n)?n:function(e){return e.is(n)},this.proportions={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight},e.ui.ddmanager.droppables[t.scope]=e.ui.ddmanager.droppables[t.scope]||[],e.ui.ddmanager.droppables[t.scope].push(this),t.addClasses&&this.element.addClass("ui-droppable")},_destroy:function(){var t=e.ui.ddmanager.droppables[this.options.scope];for(var n=0;n<t.length;n++)t[n]==this&&t.splice(n,1);this.element.removeClass("ui-droppable ui-droppable-disabled")},_setOption:function(t,n){t=="accept"&&(this.accept=e.isFunction(n)?n:function(e){return e.is(n)}),e.Widget.prototype._setOption.apply(this,arguments)},_activate:function(t){var n=e.ui.ddmanager.current;this.options.activeClass&&this.element.addClass(this.options.activeClass),n&&this._trigger("activate",t,this.ui(n))},_deactivate:function(t){var n=e.ui.ddmanager.current;this.options.activeClass&&this.element.removeClass(this.options.activeClass),n&&this._trigger("deactivate",t,this.ui(n))},_over:function(t){var n=e.ui.ddmanager.current;if(!n||(n.currentItem||n.element)[0]==this.element[0])return;this.accept.call(this.element[0],n.currentItem||n.element)&&(this.options.hoverClass&&this.element.addClass(this.options.hoverClass),this._trigger("over",t,this.ui(n)))},_out:function(t){var n=e.ui.ddmanager.current;if(!n||(n.currentItem||n.element)[0]==this.element[0])return;this.accept.call(this.element[0],n.currentItem||n.element)&&(this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("out",t,this.ui(n)))},_drop:function(t,n){var r=n||e.ui.ddmanager.current;if(!r||(r.currentItem||r.element)[0]==this.element[0])return!1;var i=!1;return this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function(){var t=e.data(this,"droppable");if(t.options.greedy&&!t.options.disabled&&t.options.scope==r.options.scope&&t.accept.call(t.element[0],r.currentItem||r.element)&&e.ui.intersect(r,e.extend(t,{offset:t.element.offset()}),t.options.tolerance))return i=!0,!1}),i?!1:this.accept.call(this.element[0],r.currentItem||r.element)?(this.options.activeClass&&this.element.removeClass(this.options.activeClass),this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("drop",t,this.ui(r)),this.element):!1},ui:function(e){return{draggable:e.currentItem||e.element,helper:e.helper,position:e.position,offset:e.positionAbs}}}),e.ui.intersect=function(t,n,r){if(!n.offset)return!1;var i=(t.positionAbs||t.position.absolute).left,s=i+t.helperProportions.width,o=(t.positionAbs||t.position.absolute).top,u=o+t.helperProportions.height,a=n.offset.left,f=a+n.proportions.width,l=n.offset.top,c=l+n.proportions.height;switch(r){case"fit":return a<=i&&s<=f&&l<=o&&u<=c;case"intersect":return a<i+t.helperProportions.width/2&&s-t.helperProportions.width/2<f&&l<o+t.helperProportions.height/2&&u-t.helperProportions.height/2<c;case"pointer":var h=(t.positionAbs||t.position.absolute).left+(t.clickOffset||t.offset.click).left,p=(t.positionAbs||t.position.absolute).top+(t.clickOffset||t.offset.click).top,d=e.ui.isOver(p,h,l,a,n.proportions.height,n.proportions.width);return d;case"touch":return(o>=l&&o<=c||u>=l&&u<=c||o<l&&u>c)&&(i>=a&&i<=f||s>=a&&s<=f||i<a&&s>f);default:return!1}},e.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(t,n){var r=e.ui.ddmanager.droppables[t.options.scope]||[],i=n?n.type:null,s=(t.currentItem||t.element).find(":data(droppable)").andSelf();e:for(var o=0;o<r.length;o++){if(r[o].options.disabled||t&&!r[o].accept.call(r[o].element[0],t.currentItem||t.element))continue;for(var u=0;u<s.length;u++)if(s[u]==r[o].element[0]){r[o].proportions.height=0;continue e}r[o].visible=r[o].element.css("display")!="none";if(!r[o].visible)continue;i=="mousedown"&&r[o]._activate.call(r[o],n),r[o].offset=r[o].element.offset(),r[o].proportions={width:r[o].element[0].offsetWidth,height:r[o].element[0].offsetHeight}}},drop:function(t,n){var r=!1;return e.each(e.ui.ddmanager.droppables[t.options.scope]||[],function(){if(!this.options)return;!this.options.disabled&&this.visible&&e.ui.intersect(t,this,this.options.tolerance)&&(r=this._drop.call(this,n)||r),!this.options.disabled&&this.visible&&this.accept.call(this.element[0],t.currentItem||t.element)&&(this.isout=1,this.isover=0,this._deactivate.call(this,n))}),r},dragStart:function(t,n){t.element.parentsUntil("body").bind("scroll.droppable",function(){t.options.refreshPositions||e.ui.ddmanager.prepareOffsets(t,n)})},drag:function(t,n){t.options.refreshPositions&&e.ui.ddmanager.prepareOffsets(t,n),e.each(e.ui.ddmanager.droppables[t.options.scope]||[],function(){if(this.options.disabled||this.greedyChild||!this.visible)return;var r=e.ui.intersect(t,this,this.options.tolerance),i=!r&&this.isover==1?"isout":r&&this.isover==0?"isover":null;if(!i)return;var s;if(this.options.greedy){var o=this.options.scope,u=this.element.parents(":data(droppable)").filter(function(){return e.data(this,"droppable").options.scope===o});u.length&&(s=e.data(u[0],"droppable"),s.greedyChild=i=="isover"?1:0)}s&&i=="isover"&&(s.isover=0,s.isout=1,s._out.call(s,n)),this[i]=1,this[i=="isout"?"isover":"isout"]=0,this[i=="isover"?"_over":"_out"].call(this,n),s&&i=="isout"&&(s.isout=0,s.isover=1,s._over.call(s,n))})},dragStop:function(t,n){t.element.parentsUntil("body").unbind("scroll.droppable"),t.options.refreshPositions||e.ui.ddmanager.prepareOffsets(t,n)}}})(jQuery);jQuery.effects||function(e,t){var n=e.uiBackCompat!==!1,r="ui-effects-";e.effects={effect:{}},function(t,n){function p(e,t,n){var r=a[t.type]||{};return e==null?n||!t.def?null:t.def:(e=r.floor?~~e:parseFloat(e),isNaN(e)?t.def:r.mod?(e+r.mod)%r.mod:0>e?0:r.max<e?r.max:e)}function d(e){var n=o(),r=n._rgba=[];return e=e.toLowerCase(),h(s,function(t,i){var s,o=i.re.exec(e),a=o&&i.parse(o),f=i.space||"rgba";if(a)return s=n[f](a),n[u[f].cache]=s[u[f].cache],r=n._rgba=s._rgba,!1}),r.length?(r.join()==="0,0,0,0"&&t.extend(r,c.transparent),n):c[e]}function v(e,t,n){return n=(n+1)%1,n*6<1?e+(t-e)*n*6:n*2<1?t:n*3<2?e+(t-e)*(2/3-n)*6:e}var r="backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor".split(" "),i=/^([\-+])=\s*(\d+\.?\d*)/,s=[{re:/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,parse:function(e){return[e[1],e[2],e[3],e[4]]}},{re:/rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,parse:function(e){return[e[1]*2.55,e[2]*2.55,e[3]*2.55,e[4]]}},{re:/#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,parse:function(e){return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]}},{re:/#([a-f0-9])([a-f0-9])([a-f0-9])/,parse:function(e){return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)]}},{re:/hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,space:"hsla",parse:function(e){return[e[1],e[2]/100,e[3]/100,e[4]]}}],o=t.Color=function(e,n,r,i){return new t.Color.fn.parse(e,n,r,i)},u={rgba:{props:{red:{idx:0,type:"byte"},green:{idx:1,type:"byte"},blue:{idx:2,type:"byte"}}},hsla:{props:{hue:{idx:0,type:"degrees"},saturation:{idx:1,type:"percent"},lightness:{idx:2,type:"percent"}}}},a={"byte":{floor:!0,max:255},percent:{max:1},degrees:{mod:360,floor:!0}},f=o.support={},l=t("<p>")[0],c,h=t.each;l.style.cssText="background-color:rgba(1,1,1,.5)",f.rgba=l.style.backgroundColor.indexOf("rgba")>-1,h(u,function(e,t){t.cache="_"+e,t.props.alpha={idx:3,type:"percent",def:1}}),o.fn=t.extend(o.prototype,{parse:function(r,i,s,a){if(r===n)return this._rgba=[null,null,null,null],this;if(r.jquery||r.nodeType)r=t(r).css(i),i=n;var f=this,l=t.type(r),v=this._rgba=[];i!==n&&(r=[r,i,s,a],l="array");if(l==="string")return this.parse(d(r)||c._default);if(l==="array")return h(u.rgba.props,function(e,t){v[t.idx]=p(r[t.idx],t)}),this;if(l==="object")return r instanceof o?h(u,function(e,t){r[t.cache]&&(f[t.cache]=r[t.cache].slice())}):h(u,function(t,n){var i=n.cache;h(n.props,function(e,t){if(!f[i]&&n.to){if(e==="alpha"||r[e]==null)return;f[i]=n.to(f._rgba)}f[i][t.idx]=p(r[e],t,!0)}),f[i]&&e.inArray(null,f[i].slice(0,3))<0&&(f[i][3]=1,n.from&&(f._rgba=n.from(f[i])))}),this},is:function(e){var t=o(e),n=!0,r=this;return h(u,function(e,i){var s,o=t[i.cache];return o&&(s=r[i.cache]||i.to&&i.to(r._rgba)||[],h(i.props,function(e,t){if(o[t.idx]!=null)return n=o[t.idx]===s[t.idx],n})),n}),n},_space:function(){var e=[],t=this;return h(u,function(n,r){t[r.cache]&&e.push(n)}),e.pop()},transition:function(e,t){var n=o(e),r=n._space(),i=u[r],s=this.alpha()===0?o("transparent"):this,f=s[i.cache]||i.to(s._rgba),l=f.slice();return n=n[i.cache],h(i.props,function(e,r){var i=r.idx,s=f[i],o=n[i],u=a[r.type]||{};if(o===null)return;s===null?l[i]=o:(u.mod&&(o-s>u.mod/2?s+=u.mod:s-o>u.mod/2&&(s-=u.mod)),l[i]=p((o-s)*t+s,r))}),this[r](l)},blend:function(e){if(this._rgba[3]===1)return this;var n=this._rgba.slice(),r=n.pop(),i=o(e)._rgba;return o(t.map(n,function(e,t){return(1-r)*i[t]+r*e}))},toRgbaString:function(){var e="rgba(",n=t.map(this._rgba,function(e,t){return e==null?t>2?1:0:e});return n[3]===1&&(n.pop(),e="rgb("),e+n.join()+")"},toHslaString:function(){var e="hsla(",n=t.map(this.hsla(),function(e,t){return e==null&&(e=t>2?1:0),t&&t<3&&(e=Math.round(e*100)+"%"),e});return n[3]===1&&(n.pop(),e="hsl("),e+n.join()+")"},toHexString:function(e){var n=this._rgba.slice(),r=n.pop();return e&&n.push(~~(r*255)),"#"+t.map(n,function(e){return e=(e||0).toString(16),e.length===1?"0"+e:e}).join("")},toString:function(){return this._rgba[3]===0?"transparent":this.toRgbaString()}}),o.fn.parse.prototype=o.fn,u.hsla.to=function(e){if(e[0]==null||e[1]==null||e[2]==null)return[null,null,null,e[3]];var t=e[0]/255,n=e[1]/255,r=e[2]/255,i=e[3],s=Math.max(t,n,r),o=Math.min(t,n,r),u=s-o,a=s+o,f=a*.5,l,c;return o===s?l=0:t===s?l=60*(n-r)/u+360:n===s?l=60*(r-t)/u+120:l=60*(t-n)/u+240,f===0||f===1?c=f:f<=.5?c=u/a:c=u/(2-a),[Math.round(l)%360,c,f,i==null?1:i]},u.hsla.from=function(e){if(e[0]==null||e[1]==null||e[2]==null)return[null,null,null,e[3]];var t=e[0]/360,n=e[1],r=e[2],i=e[3],s=r<=.5?r*(1+n):r+n-r*n,o=2*r-s;return[Math.round(v(o,s,t+1/3)*255),Math.round(v(o,s,t)*255),Math.round(v(o,s,t-1/3)*255),i]},h(u,function(e,r){var s=r.props,u=r.cache,a=r.to,f=r.from;o.fn[e]=function(e){a&&!this[u]&&(this[u]=a(this._rgba));if(e===n)return this[u].slice();var r,i=t.type(e),l=i==="array"||i==="object"?e:arguments,c=this[u].slice();return h(s,function(e,t){var n=l[i==="object"?e:t.idx];n==null&&(n=c[t.idx]),c[t.idx]=p(n,t)}),f?(r=o(f(c)),r[u]=c,r):o(c)},h(s,function(n,r){if(o.fn[n])return;o.fn[n]=function(s){var o=t.type(s),u=n==="alpha"?this._hsla?"hsla":"rgba":e,a=this[u](),f=a[r.idx],l;return o==="undefined"?f:(o==="function"&&(s=s.call(this,f),o=t.type(s)),s==null&&r.empty?this:(o==="string"&&(l=i.exec(s),l&&(s=f+parseFloat(l[2])*(l[1]==="+"?1:-1))),a[r.idx]=s,this[u](a)))}})}),h(r,function(e,n){t.cssHooks[n]={set:function(e,r){var i,s,u="";if(t.type(r)!=="string"||(i=d(r))){r=o(i||r);if(!f.rgba&&r._rgba[3]!==1){s=n==="backgroundColor"?e.parentNode:e;while((u===""||u==="transparent")&&s&&s.style)try{u=t.css(s,"backgroundColor"),s=s.parentNode}catch(a){}r=r.blend(u&&u!=="transparent"?u:"_default")}r=r.toRgbaString()}try{e.style[n]=r}catch(l){}}},t.fx.step[n]=function(e){e.colorInit||(e.start=o(e.elem,n),e.end=o(e.end),e.colorInit=!0),t.cssHooks[n].set(e.elem,e.start.transition(e.end,e.pos))}}),t.cssHooks.borderColor={expand:function(e){var t={};return h(["Top","Right","Bottom","Left"],function(n,r){t["border"+r+"Color"]=e}),t}},c=t.Color.names={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00",transparent:[null,null,null,0],_default:"#ffffff"}}(jQuery),function(){function i(){var t=this.ownerDocument.defaultView?this.ownerDocument.defaultView.getComputedStyle(this,null):this.currentStyle,n={},r,i;if(t&&t.length&&t[0]&&t[t[0]]){i=t.length;while(i--)r=t[i],typeof t[r]=="string"&&(n[e.camelCase(r)]=t[r])}else for(r in t)typeof t[r]=="string"&&(n[r]=t[r]);return n}function s(t,n){var i={},s,o;for(s in n)o=n[s],t[s]!==o&&!r[s]&&(e.fx.step[s]||!isNaN(parseFloat(o)))&&(i[s]=o);return i}var n=["add","remove","toggle"],r={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};e.each(["borderLeftStyle","borderRightStyle","borderBottomStyle","borderTopStyle"],function(t,n){e.fx.step[n]=function(e){if(e.end!=="none"&&!e.setAttr||e.pos===1&&!e.setAttr)jQuery.style(e.elem,n,e.end),e.setAttr=!0}}),e.effects.animateClass=function(t,r,o,u){var a=e.speed(r,o,u);return this.queue(function(){var r=e(this),o=r.attr("class")||"",u,f=a.children?r.find("*").andSelf():r;f=f.map(function(){var t=e(this);return{el:t,start:i.call(this)}}),u=function(){e.each(n,function(e,n){t[n]&&r[n+"Class"](t[n])})},u(),f=f.map(function(){return this.end=i.call(this.el[0]),this.diff=s(this.start,this.end),this}),r.attr("class",o),f=f.map(function(){var t=this,n=e.Deferred(),r=jQuery.extend({},a,{queue:!1,complete:function(){n.resolve(t)}});return this.el.animate(this.diff,r),n.promise()}),e.when.apply(e,f.get()).done(function(){u(),e.each(arguments,function(){var t=this.el;e.each(this.diff,function(e){t.css(e,"")})}),a.complete.call(r[0])})})},e.fn.extend({_addClass:e.fn.addClass,addClass:function(t,n,r,i){return n?e.effects.animateClass.call(this,{add:t},n,r,i):this._addClass(t)},_removeClass:e.fn.removeClass,removeClass:function(t,n,r,i){return n?e.effects.animateClass.call(this,{remove:t},n,r,i):this._removeClass(t)},_toggleClass:e.fn.toggleClass,toggleClass:function(n,r,i,s,o){return typeof r=="boolean"||r===t?i?e.effects.animateClass.call(this,r?{add:n}:{remove:n},i,s,o):this._toggleClass(n,r):e.effects.animateClass.call(this,{toggle:n},r,i,s)},switchClass:function(t,n,r,i,s){return e.effects.animateClass.call(this,{add:n,remove:t},r,i,s)}})}(),function(){function i(t,n,r,i){e.isPlainObject(t)&&(n=t,t=t.effect),t={effect:t},n==null&&(n={}),e.isFunction(n)&&(i=n,r=null,n={});if(typeof n=="number"||e.fx.speeds[n])i=r,r=n,n={};return e.isFunction(r)&&(i=r,r=null),n&&e.extend(t,n),r=r||n.duration,t.duration=e.fx.off?0:typeof r=="number"?r:r in e.fx.speeds?e.fx.speeds[r]:e.fx.speeds._default,t.complete=i||n.complete,t}function s(t){return!t||typeof t=="number"||e.fx.speeds[t]?!0:typeof t=="string"&&!e.effects.effect[t]?n&&e.effects[t]?!1:!0:!1}e.extend(e.effects,{version:"1.9.1",save:function(e,t){for(var n=0;n<t.length;n++)t[n]!==null&&e.data(r+t[n],e[0].style[t[n]])},restore:function(e,n){var i,s;for(s=0;s<n.length;s++)n[s]!==null&&(i=e.data(r+n[s]),i===t&&(i=""),e.css(n[s],i))},setMode:function(e,t){return t==="toggle"&&(t=e.is(":hidden")?"show":"hide"),t},getBaseline:function(e,t){var n,r;switch(e[0]){case"top":n=0;break;case"middle":n=.5;break;case"bottom":n=1;break;default:n=e[0]/t.height}switch(e[1]){case"left":r=0;break;case"center":r=.5;break;case"right":r=1;break;default:r=e[1]/t.width}return{x:r,y:n}},createWrapper:function(t){if(t.parent().is(".ui-effects-wrapper"))return t.parent();var n={width:t.outerWidth(!0),height:t.outerHeight(!0),"float":t.css("float")},r=e("<div></div>").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}),i={width:t.width(),height:t.height()},s=document.activeElement;try{s.id}catch(o){s=document.body}return t.wrap(r),(t[0]===s||e.contains(t[0],s))&&e(s).focus(),r=t.parent(),t.css("position")==="static"?(r.css({position:"relative"}),t.css({position:"relative"})):(e.extend(n,{position:t.css("position"),zIndex:t.css("z-index")}),e.each(["top","left","bottom","right"],function(e,r){n[r]=t.css(r),isNaN(parseInt(n[r],10))&&(n[r]="auto")}),t.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})),t.css(i),r.css(n).show()},removeWrapper:function(t){var n=document.activeElement;return t.parent().is(".ui-effects-wrapper")&&(t.parent().replaceWith(t),(t[0]===n||e.contains(t[0],n))&&e(n).focus()),t},setTransition:function(t,n,r,i){return i=i||{},e.each(n,function(e,n){var s=t.cssUnit(n);s[0]>0&&(i[n]=s[0]*r+s[1])}),i}}),e.fn.extend({effect:function(){function a(n){function u(){e.isFunction(i)&&i.call(r[0]),e.isFunction(n)&&n()}var r=e(this),i=t.complete,s=t.mode;(r.is(":hidden")?s==="hide":s==="show")?u():o.call(r[0],t,u)}var t=i.apply(this,arguments),r=t.mode,s=t.queue,o=e.effects.effect[t.effect],u=!o&&n&&e.effects[t.effect];return e.fx.off||!o&&!u?r?this[r](t.duration,t.complete):this.each(function(){t.complete&&t.complete.call(this)}):o?s===!1?this.each(a):this.queue(s||"fx",a):u.call(this,{options:t,duration:t.duration,callback:t.complete,mode:t.mode})},_show:e.fn.show,show:function(e){if(s(e))return this._show.apply(this,arguments);var t=i.apply(this,arguments);return t.mode="show",this.effect.call(this,t)},_hide:e.fn.hide,hide:function(e){if(s(e))return this._hide.apply(this,arguments);var t=i.apply(this,arguments);return t.mode="hide",this.effect.call(this,t)},__toggle:e.fn.toggle,toggle:function(t){if(s(t)||typeof t=="boolean"||e.isFunction(t))return this.__toggle.apply(this,arguments);var n=i.apply(this,arguments);return n.mode="toggle",this.effect.call(this,n)},cssUnit:function(t){var n=this.css(t),r=[];return e.each(["em","px","%","pt"],function(e,t){n.indexOf(t)>0&&(r=[parseFloat(n),t])}),r}})}(),function(){var t={};e.each(["Quad","Cubic","Quart","Quint","Expo"],function(e,n){t[n]=function(t){return Math.pow(t,e+2)}}),e.extend(t,{Sine:function(e){return 1-Math.cos(e*Math.PI/2)},Circ:function(e){return 1-Math.sqrt(1-e*e)},Elastic:function(e){return e===0||e===1?e:-Math.pow(2,8*(e-1))*Math.sin(((e-1)*80-7.5)*Math.PI/15)},Back:function(e){return e*e*(3*e-2)},Bounce:function(e){var t,n=4;while(e<((t=Math.pow(2,--n))-1)/11);return 1/Math.pow(4,3-n)-7.5625*Math.pow((t*3-2)/22-e,2)}}),e.each(t,function(t,n){e.easing["easeIn"+t]=n,e.easing["easeOut"+t]=function(e){return 1-n(1-e)},e.easing["easeInOut"+t]=function(e){return e<.5?n(e*2)/2:1-n(e*-2+2)/2}})}()}(jQuery);(function(e,t){var n=/up|down|vertical/,r=/up|left|vertical|horizontal/;e.effects.effect.blind=function(t,i){var s=e(this),o=["position","top","bottom","left","right","height","width"],u=e.effects.setMode(s,t.mode||"hide"),a=t.direction||"up",f=n.test(a),l=f?"height":"width",c=f?"top":"left",h=r.test(a),p={},d=u==="show",v,m,g;s.parent().is(".ui-effects-wrapper")?e.effects.save(s.parent(),o):e.effects.save(s,o),s.show(),v=e.effects.createWrapper(s).css({overflow:"hidden"}),m=v[l](),g=parseFloat(v.css(c))||0,p[l]=d?m:0,h||(s.css(f?"bottom":"right",0).css(f?"top":"left","auto").css({position:"absolute"}),p[c]=d?g:m+g),d&&(v.css(l,0),h||v.css(c,g+m)),v.animate(p,{duration:t.duration,easing:t.easing,queue:!1,complete:function(){u==="hide"&&s.hide(),e.effects.restore(s,o),e.effects.removeWrapper(s),i()}})}})(jQuery);(function(e,t){e.effects.effect.bounce=function(t,n){var r=e(this),i=["position","top","bottom","left","right","height","width"],s=e.effects.setMode(r,t.mode||"effect"),o=s==="hide",u=s==="show",a=t.direction||"up",f=t.distance,l=t.times||5,c=l*2+(u||o?1:0),h=t.duration/c,p=t.easing,d=a==="up"||a==="down"?"top":"left",v=a==="up"||a==="left",m,g,y,b=r.queue(),w=b.length;(u||o)&&i.push("opacity"),e.effects.save(r,i),r.show(),e.effects.createWrapper(r),f||(f=r[d==="top"?"outerHeight":"outerWidth"]()/3),u&&(y={opacity:1},y[d]=0,r.css("opacity",0).css(d,v?-f*2:f*2).animate(y,h,p)),o&&(f/=Math.pow(2,l-1)),y={},y[d]=0;for(m=0;m<l;m++)g={},g[d]=(v?"-=":"+=")+f,r.animate(g,h,p).animate(y,h,p),f=o?f*2:f/2;o&&(g={opacity:0},g[d]=(v?"-=":"+=")+f,r.animate(g,h,p)),r.queue(function(){o&&r.hide(),e.effects.restore(r,i),e.effects.removeWrapper(r),n()}),w>1&&b.splice.apply(b,[1,0].concat(b.splice(w,c+1))),r.dequeue()}})(jQuery);(function(e,t){e.effects.effect.clip=function(t,n){var r=e(this),i=["position","top","bottom","left","right","height","width"],s=e.effects.setMode(r,t.mode||"hide"),o=s==="show",u=t.direction||"vertical",a=u==="vertical",f=a?"height":"width",l=a?"top":"left",c={},h,p,d;e.effects.save(r,i),r.show(),h=e.effects.createWrapper(r).css({overflow:"hidden"}),p=r[0].tagName==="IMG"?h:r,d=p[f](),o&&(p.css(f,0),p.css(l,d/2)),c[f]=o?d:0,c[l]=o?0:d/2,p.animate(c,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){o||r.hide(),e.effects.restore(r,i),e.effects.removeWrapper(r),n()}})}})(jQuery);(function(e,t){e.effects.effect.drop=function(t,n){var r=e(this),i=["position","top","bottom","left","right","opacity","height","width"],s=e.effects.setMode(r,t.mode||"hide"),o=s==="show",u=t.direction||"left",a=u==="up"||u==="down"?"top":"left",f=u==="up"||u==="left"?"pos":"neg",l={opacity:o?1:0},c;e.effects.save(r,i),r.show(),e.effects.createWrapper(r),c=t.distance||r[a==="top"?"outerHeight":"outerWidth"](!0)/2,o&&r.css("opacity",0).css(a,f==="pos"?-c:c),l[a]=(o?f==="pos"?"+=":"-=":f==="pos"?"-=":"+=")+c,r.animate(l,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){s==="hide"&&r.hide(),e.effects.restore(r,i),e.effects.removeWrapper(r),n()}})}})(jQuery);(function(e,t){e.effects.effect.explode=function(t,n){function y(){c.push(this),c.length===r*i&&b()}function b(){s.css({visibility:"visible"}),e(c).remove(),u||s.hide(),n()}var r=t.pieces?Math.round(Math.sqrt(t.pieces)):3,i=r,s=e(this),o=e.effects.setMode(s,t.mode||"hide"),u=o==="show",a=s.show().css("visibility","hidden").offset(),f=Math.ceil(s.outerWidth()/i),l=Math.ceil(s.outerHeight()/r),c=[],h,p,d,v,m,g;for(h=0;h<r;h++){v=a.top+h*l,g=h-(r-1)/2;for(p=0;p<i;p++)d=a.left+p*f,m=p-(i-1)/2,s.clone().appendTo("body").wrap("<div></div>").css({position:"absolute",visibility:"visible",left:-p*f,top:-h*l}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:f,height:l,left:d+(u?m*f:0),top:v+(u?g*l:0),opacity:u?0:1}).animate({left:d+(u?0:m*f),top:v+(u?0:g*l),opacity:u?1:0},t.duration||500,t.easing,y)}}})(jQuery);(function(e,t){e.effects.effect.fade=function(t,n){var r=e(this),i=e.effects.setMode(r,t.mode||"toggle");r.animate({opacity:i},{queue:!1,duration:t.duration,easing:t.easing,complete:n})}})(jQuery);(function(e,t){e.effects.effect.fold=function(t,n){var r=e(this),i=["position","top","bottom","left","right","height","width"],s=e.effects.setMode(r,t.mode||"hide"),o=s==="show",u=s==="hide",a=t.size||15,f=/([0-9]+)%/.exec(a),l=!!t.horizFirst,c=o!==l,h=c?["width","height"]:["height","width"],p=t.duration/2,d,v,m={},g={};e.effects.save(r,i),r.show(),d=e.effects.createWrapper(r).css({overflow:"hidden"}),v=c?[d.width(),d.height()]:[d.height(),d.width()],f&&(a=parseInt(f[1],10)/100*v[u?0:1]),o&&d.css(l?{height:0,width:a}:{height:a,width:0}),m[h[0]]=o?v[0]:a,g[h[1]]=o?v[1]:0,d.animate(m,p,t.easing).animate(g,p,t.easing,function(){u&&r.hide(),e.effects.restore(r,i),e.effects.removeWrapper(r),n()})}})(jQuery);(function(e,t){e.effects.effect.highlight=function(t,n){var r=e(this),i=["backgroundImage","backgroundColor","opacity"],s=e.effects.setMode(r,t.mode||"show"),o={backgroundColor:r.css("backgroundColor")};s==="hide"&&(o.opacity=0),e.effects.save(r,i),r.show().css({backgroundImage:"none",backgroundColor:t.color||"#ffff99"}).animate(o,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){s==="hide"&&r.hide(),e.effects.restore(r,i),n()}})}})(jQuery);(function(e,t){e.effects.effect.pulsate=function(t,n){var r=e(this),i=e.effects.setMode(r,t.mode||"show"),s=i==="show",o=i==="hide",u=s||i==="hide",a=(t.times||5)*2+(u?1:0),f=t.duration/a,l=0,c=r.queue(),h=c.length,p;if(s||!r.is(":visible"))r.css("opacity",0).show(),l=1;for(p=1;p<a;p++)r.animate({opacity:l},f,t.easing),l=1-l;r.animate({opacity:l},f,t.easing),r.queue(function(){o&&r.hide(),n()}),h>1&&c.splice.apply(c,[1,0].concat(c.splice(h,a+1))),r.dequeue()}})(jQuery);(function(e,t){e.effects.effect.puff=function(t,n){var r=e(this),i=e.effects.setMode(r,t.mode||"hide"),s=i==="hide",o=parseInt(t.percent,10)||150,u=o/100,a={height:r.height(),width:r.width()};e.extend(t,{effect:"scale",queue:!1,fade:!0,mode:i,complete:n,percent:s?o:100,from:s?a:{height:a.height*u,width:a.width*u}}),r.effect(t)},e.effects.effect.scale=function(t,n){var r=e(this),i=e.extend(!0,{},t),s=e.effects.setMode(r,t.mode||"effect"),o=parseInt(t.percent,10)||(parseInt(t.percent,10)===0?0:s==="hide"?0:100),u=t.direction||"both",a=t.origin,f={height:r.height(),width:r.width(),outerHeight:r.outerHeight(),outerWidth:r.outerWidth()},l={y:u!=="horizontal"?o/100:1,x:u!=="vertical"?o/100:1};i.effect="size",i.queue=!1,i.complete=n,s!=="effect"&&(i.origin=a||["middle","center"],i.restore=!0),i.from=t.from||(s==="show"?{height:0,width:0}:f),i.to={height:f.height*l.y,width:f.width*l.x,outerHeight:f.outerHeight*l.y,outerWidth:f.outerWidth*l.x},i.fade&&(s==="show"&&(i.from.opacity=0,i.to.opacity=1),s==="hide"&&(i.from.opacity=1,i.to.opacity=0)),r.effect(i)},e.effects.effect.size=function(t,n){var r,i,s,o=e(this),u=["position","top","bottom","left","right","width","height","overflow","opacity"],a=["position","top","bottom","left","right","overflow","opacity"],f=["width","height","overflow"],l=["fontSize"],c=["borderTopWidth","borderBottomWidth","paddingTop","paddingBottom"],h=["borderLeftWidth","borderRightWidth","paddingLeft","paddingRight"],p=e.effects.setMode(o,t.mode||"effect"),d=t.restore||p!=="effect",v=t.scale||"both",m=t.origin||["middle","center"],g=o.css("position"),y=d?u:a,b={height:0,width:0};p==="show"&&o.show(),r={height:o.height(),width:o.width(),outerHeight:o.outerHeight(),outerWidth:o.outerWidth()},t.mode==="toggle"&&p==="show"?(o.from=t.to||b,o.to=t.from||r):(o.from=t.from||(p==="show"?b:r),o.to=t.to||(p==="hide"?b:r)),s={from:{y:o.from.height/r.height,x:o.from.width/r.width},to:{y:o.to.height/r.height,x:o.to.width/r.width}};if(v==="box"||v==="both")s.from.y!==s.to.y&&(y=y.concat(c),o.from=e.effects.setTransition(o,c,s.from.y,o.from),o.to=e.effects.setTransition(o,c,s.to.y,o.to)),s.from.x!==s.to.x&&(y=y.concat(h),o.from=e.effects.setTransition(o,h,s.from.x,o.from),o.to=e.effects.setTransition(o,h,s.to.x,o.to));(v==="content"||v==="both")&&s.from.y!==s.to.y&&(y=y.concat(l).concat(f),o.from=e.effects.setTransition(o,l,s.from.y,o.from),o.to=e.effects.setTransition(o,l,s.to.y,o.to)),e.effects.save(o,y),o.show(),e.effects.createWrapper(o),o.css("overflow","hidden").css(o.from),m&&(i=e.effects.getBaseline(m,r),o.from.top=(r.outerHeight-o.outerHeight())*i.y,o.from.left=(r.outerWidth-o.outerWidth())*i.x,o.to.top=(r.outerHeight-o.to.outerHeight)*i.y,o.to.left=(r.outerWidth-o.to.outerWidth)*i.x),o.css(o.from);if(v==="content"||v==="both")c=c.concat(["marginTop","marginBottom"]).concat(l),h=h.concat(["marginLeft","marginRight"]),f=u.concat(c).concat(h),o.find("*[width]").each(function(){var n=e(this),r={height:n.height(),width:n.width()};d&&e.effects.save(n,f),n.from={height:r.height*s.from.y,width:r.width*s.from.x},n.to={height:r.height*s.to.y,width:r.width*s.to.x},s.from.y!==s.to.y&&(n.from=e.effects.setTransition(n,c,s.from.y,n.from),n.to=e.effects.setTransition(n,c,s.to.y,n.to)),s.from.x!==s.to.x&&(n.from=e.effects.setTransition(n,h,s.from.x,n.from),n.to=e.effects.setTransition(n,h,s.to.x,n.to)),n.css(n.from),n.animate(n.to,t.duration,t.easing,function(){d&&e.effects.restore(n,f)})});o.animate(o.to,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){o.to.opacity===0&&o.css("opacity",o.from.opacity),p==="hide"&&o.hide(),e.effects.restore(o,y),d||(g==="static"?o.css({position:"relative",top:o.to.top,left:o.to.left}):e.each(["top","left"],function(e,t){o.css(t,function(t,n){var r=parseInt(n,10),i=e?o.to.left:o.to.top;return n==="auto"?i+"px":r+i+"px"})})),e.effects.removeWrapper(o),n()}})}})(jQuery);(function(e,t){e.effects.effect.shake=function(t,n){var r=e(this),i=["position","top","bottom","left","right","height","width"],s=e.effects.setMode(r,t.mode||"effect"),o=t.direction||"left",u=t.distance||20,a=t.times||3,f=a*2+1,l=Math.round(t.duration/f),c=o==="up"||o==="down"?"top":"left",h=o==="up"||o==="left",p={},d={},v={},m,g=r.queue(),y=g.length;e.effects.save(r,i),r.show(),e.effects.createWrapper(r),p[c]=(h?"-=":"+=")+u,d[c]=(h?"+=":"-=")+u*2,v[c]=(h?"-=":"+=")+u*2,r.animate(p,l,t.easing);for(m=1;m<a;m++)r.animate(d,l,t.easing).animate(v,l,t.easing);r.animate(d,l,t.easing).animate(p,l/2,t.easing).queue(function(){s==="hide"&&r.hide(),e.effects.restore(r,i),e.effects.removeWrapper(r),n()}),y>1&&g.splice.apply(g,[1,0].concat(g.splice(y,f+1))),r.dequeue()}})(jQuery);(function(e,t){e.effects.effect.slide=function(t,n){var r=e(this),i=["position","top","bottom","left","right","width","height"],s=e.effects.setMode(r,t.mode||"show"),o=s==="show",u=t.direction||"left",a=u==="up"||u==="down"?"top":"left",f=u==="up"||u==="left",l,c={};e.effects.save(r,i),r.show(),l=t.distance||r[a==="top"?"outerHeight":"outerWidth"](!0),e.effects.createWrapper(r).css({overflow:"hidden"}),o&&r.css(a,f?isNaN(l)?"-"+l:-l:l),c[a]=(o?f?"+=":"-=":f?"-=":"+=")+l,r.animate(c,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){s==="hide"&&r.hide(),e.effects.restore(r,i),e.effects.removeWrapper(r),n()}})}})(jQuery);(function(e,t){e.effects.effect.transfer=function(t,n){var r=e(this),i=e(t.to),s=i.css("position")==="fixed",o=e("body"),u=s?o.scrollTop():0,a=s?o.scrollLeft():0,f=i.offset(),l={top:f.top-u,left:f.left-a,height:i.innerHeight(),width:i.innerWidth()},c=r.offset(),h=e('<div class="ui-effects-transfer"></div>').appendTo(document.body).addClass(t.className).css({top:c.top-u,left:c.left-a,height:r.innerHeight(),width:r.innerWidth(),position:s?"fixed":"absolute"}).animate(l,t.duration,t.easing,function(){h.remove(),n()})}})(jQuery);(function(e,t){var n=!1;e.widget("ui.menu",{version:"1.9.1",defaultElement:"<ul>",delay:300,options:{icons:{submenu:"ui-icon-carat-1-e"},menus:"ul",position:{my:"left top",at:"right top"},role:"menu",blur:null,focus:null,select:null},_create:function(){this.activeMenu=this.element,this.element.uniqueId().addClass("ui-menu ui-widget ui-widget-content ui-corner-all").toggleClass("ui-menu-icons",!!this.element.find(".ui-icon").length).attr({role:this.options.role,tabIndex:0}).bind("click"+this.eventNamespace,e.proxy(function(e){this.options.disabled&&e.preventDefault()},this)),this.options.disabled&&this.element.addClass("ui-state-disabled").attr("aria-disabled","true"),this._on({"mousedown .ui-menu-item > a":function(e){e.preventDefault()},"click .ui-state-disabled > a":function(e){e.preventDefault()},"click .ui-menu-item:has(a)":function(t){var r=e(t.target).closest(".ui-menu-item");!n&&r.not(".ui-state-disabled").length&&(n=!0,this.select(t),r.has(".ui-menu").length?this.expand(t):this.element.is(":focus")||(this.element.trigger("focus",[!0]),this.active&&this.active.parents(".ui-menu").length===1&&clearTimeout(this.timer)))},"mouseenter .ui-menu-item":function(t){var n=e(t.currentTarget);n.siblings().children(".ui-state-active").removeClass("ui-state-active"),this.focus(t,n)},mouseleave:"collapseAll","mouseleave .ui-menu":"collapseAll",focus:function(e,t){var n=this.active||this.element.children(".ui-menu-item").eq(0);t||this.focus(e,n)},blur:function(t){this._delay(function(){e.contains(this.element[0],this.document[0].activeElement)||this.collapseAll(t)})},keydown:"_keydown"}),this.refresh(),this._on(this.document,{click:function(t){e(t.target).closest(".ui-menu").length||this.collapseAll(t),n=!1}})},_destroy:function(){this.element.removeAttr("aria-activedescendant").find(".ui-menu").andSelf().removeClass("ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons").removeAttr("role").removeAttr("tabIndex").removeAttr("aria-labelledby").removeAttr("aria-expanded").removeAttr("aria-hidden").removeAttr("aria-disabled").removeUniqueId().show(),this.element.find(".ui-menu-item").removeClass("ui-menu-item").removeAttr("role").removeAttr("aria-disabled").children("a").removeUniqueId().removeClass("ui-corner-all ui-state-hover").removeAttr("tabIndex").removeAttr("role").removeAttr("aria-haspopup").children().each(function(){var t=e(this);t.data("ui-menu-submenu-carat")&&t.remove()}),this.element.find(".ui-menu-divider").removeClass("ui-menu-divider ui-widget-content")},_keydown:function(t){function a(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}var n,r,i,s,o,u=!0;switch(t.keyCode){case e.ui.keyCode.PAGE_UP:this.previousPage(t);break;case e.ui.keyCode.PAGE_DOWN:this.nextPage(t);break;case e.ui.keyCode.HOME:this._move("first","first",t);break;case e.ui.keyCode.END:this._move("last","last",t);break;case e.ui.keyCode.UP:this.previous(t);break;case e.ui.keyCode.DOWN:this.next(t);break;case e.ui.keyCode.LEFT:this.collapse(t);break;case e.ui.keyCode.RIGHT:this.active&&!this.active.is(".ui-state-disabled")&&this.expand(t);break;case e.ui.keyCode.ENTER:case e.ui.keyCode.SPACE:this._activate(t);break;case e.ui.keyCode.ESCAPE:this.collapse(t);break;default:u=!1,r=this.previousFilter||"",i=String.fromCharCode(t.keyCode),s=!1,clearTimeout(this.filterTimer),i===r?s=!0:i=r+i,o=new RegExp("^"+a(i),"i"),n=this.activeMenu.children(".ui-menu-item").filter(function(){return o.test(e(this).children("a").text())}),n=s&&n.index(this.active.next())!==-1?this.active.nextAll(".ui-menu-item"):n,n.length||(i=String.fromCharCode(t.keyCode),o=new RegExp("^"+a(i),"i"),n=this.activeMenu.children(".ui-menu-item").filter(function(){return o.test(e(this).children("a").text())})),n.length?(this.focus(t,n),n.length>1?(this.previousFilter=i,this.filterTimer=this._delay(function(){delete this.previousFilter},1e3)):delete this.previousFilter):delete this.previousFilter}u&&t.preventDefault()},_activate:function(e){this.active.is(".ui-state-disabled")||(this.active.children("a[aria-haspopup='true']").length?this.expand(e):this.select(e))},refresh:function(){var t,n=this.options.icons.submenu,r=this.element.find(this.options.menus+":not(.ui-menu)").addClass("ui-menu ui-widget ui-widget-content ui-corner-all").hide().attr({role:this.options.role,"aria-hidden":"true","aria-expanded":"false"});t=r.add(this.element),t.children(":not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","presentation").children("a").uniqueId().addClass("ui-corner-all").attr({tabIndex:-1,role:this._itemRole()}),t.children(":not(.ui-menu-item)").each(function(){var t=e(this);/[^\-—–\s]/.test(t.text())||t.addClass("ui-widget-content ui-menu-divider")}),t.children(".ui-state-disabled").attr("aria-disabled","true"),r.each(function(){var t=e(this),r=t.prev("a"),i=e("<span>").addClass("ui-menu-icon ui-icon "+n).data("ui-menu-submenu-carat",!0);r.attr("aria-haspopup","true").prepend(i),t.attr("aria-labelledby",r.attr("id"))}),this.active&&!e.contains(this.element[0],this.active[0])&&this.blur()},_itemRole:function(){return{menu:"menuitem",listbox:"option"}[this.options.role]},focus:function(e,t){var n,r;this.blur(e,e&&e.type==="focus"),this._scrollIntoView(t),this.active=t.first(),r=this.active.children("a").addClass("ui-state-focus"),this.options.role&&this.element.attr("aria-activedescendant",r.attr("id")),this.active.parent().closest(".ui-menu-item").children("a:first").addClass("ui-state-active"),e&&e.type==="keydown"?this._close():this.timer=this._delay(function(){this._close()},this.delay),n=t.children(".ui-menu"),n.length&&/^mouse/.test(e.type)&&this._startOpening(n),this.activeMenu=t.parent(),this._trigger("focus",e,{item:t})},_scrollIntoView:function(t){var n,r,i,s,o,u;this._hasScroll()&&(n=parseFloat(e.css(this.activeMenu[0],"borderTopWidth"))||0,r=parseFloat(e.css(this.activeMenu[0],"paddingTop"))||0,i=t.offset().top-this.activeMenu.offset().top-n-r,s=this.activeMenu.scrollTop(),o=this.activeMenu.height(),u=t.height(),i<0?this.activeMenu.scrollTop(s+i):i+u>o&&this.activeMenu.scrollTop(s+i-o+u))},blur:function(e,t){t||clearTimeout(this.timer);if(!this.active)return;this.active.children("a").removeClass("ui-state-focus"),this.active=null,this._trigger("blur",e,{item:this.active})},_startOpening:function(e){clearTimeout(this.timer);if(e.attr("aria-hidden")!=="true")return;this.timer=this._delay(function(){this._close(),this._open(e)},this.delay)},_open:function(t){var n=e.extend({of:this.active},this.options.position);clearTimeout(this.timer),this.element.find(".ui-menu").not(t.parents(".ui-menu")).hide().attr("aria-hidden","true"),t.show().removeAttr("aria-hidden").attr("aria-expanded","true").position(n)},collapseAll:function(t,n){clearTimeout(this.timer),this.timer=this._delay(function(){var r=n?this.element:e(t&&t.target).closest(this.element.find(".ui-menu"));r.length||(r=this.element),this._close(r),this.blur(t),this.activeMenu=r},this.delay)},_close:function(e){e||(e=this.active?this.active.parent():this.element),e.find(".ui-menu").hide().attr("aria-hidden","true").attr("aria-expanded","false").end().find("a.ui-state-active").removeClass("ui-state-active")},collapse:function(e){var t=this.active&&this.active.parent().closest(".ui-menu-item",this.element);t&&t.length&&(this._close(),this.focus(e,t))},expand:function(e){var t=this.active&&this.active.children(".ui-menu ").children(".ui-menu-item").first();t&&t.length&&(this._open(t.parent()),this._delay(function(){this.focus(e,t)}))},next:function(e){this._move("next","first",e)},previous:function(e){this._move("prev","last",e)},isFirstItem:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},isLastItem:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},_move:function(e,t,n){var r;this.active&&(e==="first"||e==="last"?r=this.active[e==="first"?"prevAll":"nextAll"](".ui-menu-item").eq(-1):r=this.active[e+"All"](".ui-menu-item").eq(0));if(!r||!r.length||!this.active)r=this.activeMenu.children(".ui-menu-item")[t]();this.focus(n,r)},nextPage:function(t){var n,r,i;if(!this.active){this.next(t);return}if(this.isLastItem())return;this._hasScroll()?(r=this.active.offset().top,i=this.element.height(),this.active.nextAll(".ui-menu-item").each(function(){return n=e(this),n.offset().top-r-i<0}),this.focus(t,n)):this.focus(t,this.activeMenu.children(".ui-menu-item")[this.active?"last":"first"]())},previousPage:function(t){var n,r,i;if(!this.active){this.next(t);return}if(this.isFirstItem())return;this._hasScroll()?(r=this.active.offset().top,i=this.element.height(),this.active.prevAll(".ui-menu-item").each(function(){return n=e(this),n.offset().top-r+i>0}),this.focus(t,n)):this.focus(t,this.activeMenu.children(".ui-menu-item").first())},_hasScroll:function(){return this.element.outerHeight()<this.element.prop("scrollHeight")},select:function(t){this.active=this.active||e(t.target).closest(".ui-menu-item");var n={item:this.active};this.active.has(".ui-menu").length||this.collapseAll(t,!0),this._trigger("select",t,n)}})})(jQuery);(function(e,t){e.widget("ui.progressbar",{version:"1.9.1",options:{value:0,max:100},min:0,_create:function(){this.element.addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").attr({role:"progressbar","aria-valuemin":this.min,"aria-valuemax":this.options.max,"aria-valuenow":this._value()}),this.valueDiv=e("<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>").appendTo(this.element),this.oldValue=this._value(),this._refreshValue()},_destroy:function(){this.element.removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow"),this.valueDiv.remove()},value:function(e){return e===t?this._value():(this._setOption("value",e),this)},_setOption:function(e,t){e==="value"&&(this.options.value=t,this._refreshValue(),this._value()===this.options.max&&this._trigger("complete")),this._super(e,t)},_value:function(){var e=this.options.value;return typeof e!="number"&&(e=0),Math.min(this.options.max,Math.max(this.min,e))},_percentage:function(){return 100*this._value()/this.options.max},_refreshValue:function(){var e=this.value(),t=this._percentage();this.oldValue!==e&&(this.oldValue=e,this._trigger("change")),this.valueDiv.toggle(e>this.min).toggleClass("ui-corner-right",e===this.options.max).width(t.toFixed(0)+"%"),this.element.attr("aria-valuenow",e)}})})(jQuery);(function(e,t){e.widget("ui.resizable",e.ui.mouse,{version:"1.9.1",widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:1e3},_create:function(){var t=this,n=this.options;this.element.addClass("ui-resizable"),e.extend(this,{_aspectRatio:!!n.aspectRatio,aspectRatio:n.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:n.helper||n.ghost||n.animate?n.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)&&(this.element.wrap(e('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("resizable",this.element.data("resizable")),this.elementIsWrapper=!0,this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")}),this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0}),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css({margin:this.originalElement.css("margin")}),this._proportionallyResize()),this.handles=n.handles||(e(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se");if(this.handles.constructor==String){this.handles=="all"&&(this.handles="n,e,s,w,se,sw,ne,nw");var r=this.handles.split(",");this.handles={};for(var i=0;i<r.length;i++){var s=e.trim(r[i]),o="ui-resizable-"+s,u=e('<div class="ui-resizable-handle '+o+'"></div>');u.css({zIndex:n.zIndex}),"se"==s&&u.addClass("ui-icon ui-icon-gripsmall-diagonal-se"),this.handles[s]=".ui-resizable-"+s,this.element.append(u)}}this._renderAxis=function(t){t=t||this.element;for(var n in this.handles){this.handles[n].constructor==String&&(this.handles[n]=e(this.handles[n],this.element).show());if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var r=e(this.handles[n],this.element),i=0;i=/sw|ne|nw|se|n|s/.test(n)?r.outerHeight():r.outerWidth();var s=["padding",/ne|nw|n/.test(n)?"Top":/se|sw|s/.test(n)?"Bottom":/^e$/.test(n)?"Right":"Left"].join("");t.css(s,i),this._proportionallyResize()}if(!e(this.handles[n]).length)continue}},this._renderAxis(this.element),this._handles=e(".ui-resizable-handle",this.element).disableSelection(),this._handles.mouseover(function(){if(!t.resizing){if(this.className)var e=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);t.axis=e&&e[1]?e[1]:"se"}}),n.autoHide&&(this._handles.hide(),e(this.element).addClass("ui-resizable-autohide").mouseenter(function(){if(n.disabled)return;e(this).removeClass("ui-resizable-autohide"),t._handles.show()}).mouseleave(function(){if(n.disabled)return;t.resizing||(e(this).addClass("ui-resizable-autohide"),t._handles.hide())})),this._mouseInit()},_destroy:function(){this._mouseDestroy();var t=function(t){e(t).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};if(this.elementIsWrapper){t(this.element);var n=this.element;this.originalElement.css({position:n.css("position"),width:n.outerWidth(),height:n.outerHeight(),top:n.css("top"),left:n.css("left")}).insertAfter(n),n.remove()}return this.originalElement.css("resize",this.originalResizeStyle),t(this.originalElement),this},_mouseCapture:function(t){var n=!1;for(var r in this.handles)e(this.handles[r])[0]==t.target&&(n=!0);return!this.options.disabled&&n},_mouseStart:function(t){var r=this.options,i=this.element.position(),s=this.element;this.resizing=!0,this.documentScroll={top:e(document).scrollTop(),left:e(document).scrollLeft()},(s.is(".ui-draggable")||/absolute/.test(s.css("position")))&&s.css({position:"absolute",top:i.top,left:i.left}),this._renderProxy();var o=n(this.helper.css("left")),u=n(this.helper.css("top"));r.containment&&(o+=e(r.containment).scrollLeft()||0,u+=e(r.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:o,top:u},this.size=this._helper?{width:s.outerWidth(),height:s.outerHeight()}:{width:s.width(),height:s.height()},this.originalSize=this._helper?{width:s.outerWidth(),height:s.outerHeight()}:{width:s.width(),height:s.height()},this.originalPosition={left:o,top:u},this.sizeDiff={width:s.outerWidth()-s.width(),height:s.outerHeight()-s.height()},this.originalMousePosition={left:t.pageX,top:t.pageY},this.aspectRatio=typeof r.aspectRatio=="number"?r.aspectRatio:this.originalSize.width/this.originalSize.height||1;var a=e(".ui-resizable-"+this.axis).css("cursor");return e("body").css("cursor",a=="auto"?this.axis+"-resize":a),s.addClass("ui-resizable-resizing"),this._propagate("start",t),!0},_mouseDrag:function(e){var t=this.helper,n=this.options,r={},i=this,s=this.originalMousePosition,o=this.axis,u=e.pageX-s.left||0,a=e.pageY-s.top||0,f=this._change[o];if(!f)return!1;var l=f.apply(this,[e,u,a]);this._updateVirtualBoundaries(e.shiftKey);if(this._aspectRatio||e.shiftKey)l=this._updateRatio(l,e);return l=this._respectSize(l,e),this._propagate("resize",e),t.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"}),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),this._updateCache(l),this._trigger("resize",e,this.ui()),!1},_mouseStop:function(t){this.resizing=!1;var n=this.options,r=this;if(this._helper){var i=this._proportionallyResizeElements,s=i.length&&/textarea/i.test(i[0].nodeName),o=s&&e.ui.hasScroll(i[0],"left")?0:r.sizeDiff.height,u=s?0:r.sizeDiff.width,a={width:r.helper.width()-u,height:r.helper.height()-o},f=parseInt(r.element.css("left"),10)+(r.position.left-r.originalPosition.left)||null,l=parseInt(r.element.css("top"),10)+(r.position.top-r.originalPosition.top)||null;n.animate||this.element.css(e.extend(a,{top:l,left:f})),r.helper.height(r.size.height),r.helper.width(r.size.width),this._helper&&!n.animate&&this._proportionallyResize()}return e("body").css("cursor","auto"),this.element.removeClass("ui-resizable-resizing"),this._propagate("stop",t),this._helper&&this.helper.remove(),!1},_updateVirtualBoundaries:function(e){var t=this.options,n,i,s,o,u;u={minWidth:r(t.minWidth)?t.minWidth:0,maxWidth:r(t.maxWidth)?t.maxWidth:Infinity,minHeight:r(t.minHeight)?t.minHeight:0,maxHeight:r(t.maxHeight)?t.maxHeight:Infinity};if(this._aspectRatio||e)n=u.minHeight*this.aspectRatio,s=u.minWidth/this.aspectRatio,i=u.maxHeight*this.aspectRatio,o=u.maxWidth/this.aspectRatio,n>u.minWidth&&(u.minWidth=n),s>u.minHeight&&(u.minHeight=s),i<u.maxWidth&&(u.maxWidth=i),o<u.maxHeight&&(u.maxHeight=o);this._vBoundaries=u},_updateCache:function(e){var t=this.options;this.offset=this.helper.offset(),r(e.left)&&(this.position.left=e.left),r(e.top)&&(this.position.top=e.top),r(e.height)&&(this.size.height=e.height),r(e.width)&&(this.size.width=e.width)},_updateRatio:function(e,t){var n=this.options,i=this.position,s=this.size,o=this.axis;return r(e.height)?e.width=e.height*this.aspectRatio:r(e.width)&&(e.height=e.width/this.aspectRatio),o=="sw"&&(e.left=i.left+(s.width-e.width),e.top=null),o=="nw"&&(e.top=i.top+(s.height-e.height),e.left=i.left+(s.width-e.width)),e},_respectSize:function(e,t){var n=this.helper,i=this._vBoundaries,s=this._aspectRatio||t.shiftKey,o=this.axis,u=r(e.width)&&i.maxWidth&&i.maxWidth<e.width,a=r(e.height)&&i.maxHeight&&i.maxHeight<e.height,f=r(e.width)&&i.minWidth&&i.minWidth>e.width,l=r(e.height)&&i.minHeight&&i.minHeight>e.height;f&&(e.width=i.minWidth),l&&(e.height=i.minHeight),u&&(e.width=i.maxWidth),a&&(e.height=i.maxHeight);var c=this.originalPosition.left+this.originalSize.width,h=this.position.top+this.size.height,p=/sw|nw|w/.test(o),d=/nw|ne|n/.test(o);f&&p&&(e.left=c-i.minWidth),u&&p&&(e.left=c-i.maxWidth),l&&d&&(e.top=h-i.minHeight),a&&d&&(e.top=h-i.maxHeight);var v=!e.width&&!e.height;return v&&!e.left&&e.top?e.top=null:v&&!e.top&&e.left&&(e.left=null),e},_proportionallyResize:function(){var t=this.options;if(!this._proportionallyResizeElements.length)return;var n=this.helper||this.element;for(var r=0;r<this._proportionallyResizeElements.length;r++){var i=this._proportionallyResizeElements[r];if(!this.borderDif){var s=[i.css("borderTopWidth"),i.css("borderRightWidth"),i.css("borderBottomWidth"),i.css("borderLeftWidth")],o=[i.css("paddingTop"),i.css("paddingRight"),i.css("paddingBottom"),i.css("paddingLeft")];this.borderDif=e.map(s,function(e,t){var n=parseInt(e,10)||0,r=parseInt(o[t],10)||0;return n+r})}i.css({height:n.height()-this.borderDif[0]-this.borderDif[2]||0,width:n.width()-this.borderDif[1]-this.borderDif[3]||0})}},_renderProxy:function(){var t=this.element,n=this.options;this.elementOffset=t.offset();if(this._helper){this.helper=this.helper||e('<div style="overflow:hidden;"></div>');var r=e.ui.ie6?1:0,i=e.ui.ie6?2:-1;this.helper.addClass(this._helper).css({width:this.element.outerWidth()+i,height:this.element.outerHeight()+i,position:"absolute",left:this.elementOffset.left-r+"px",top:this.elementOffset.top-r+"px",zIndex:++n.zIndex}),this.helper.appendTo("body").disableSelection()}else this.helper=this.element},_change:{e:function(e,t,n){return{width:this.originalSize.width+t}},w:function(e,t,n){var r=this.options,i=this.originalSize,s=this.originalPosition;return{left:s.left+t,width:i.width-t}},n:function(e,t,n){var r=this.options,i=this.originalSize,s=this.originalPosition;return{top:s.top+n,height:i.height-n}},s:function(e,t,n){return{height:this.originalSize.height+n}},se:function(t,n,r){return e.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[t,n,r]))},sw:function(t,n,r){return e.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[t,n,r]))},ne:function(t,n,r){return e.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[t,n,r]))},nw:function(t,n,r){return e.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[t,n,r]))}},_propagate:function(t,n){e.ui.plugin.call(this,t,[n,this.ui()]),t!="resize"&&this._trigger(t,n,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),e.ui.plugin.add("resizable","alsoResize",{start:function(t,n){var r=e(this).data("resizable"),i=r.options,s=function(t){e(t).each(function(){var t=e(this);t.data("resizable-alsoresize",{width:parseInt(t.width(),10),height:parseInt(t.height(),10),left:parseInt(t.css("left"),10),top:parseInt(t.css("top"),10)})})};typeof i.alsoResize=="object"&&!i.alsoResize.parentNode?i.alsoResize.length?(i.alsoResize=i.alsoResize[0],s(i.alsoResize)):e.each(i.alsoResize,function(e){s(e)}):s(i.alsoResize)},resize:function(t,n){var r=e(this).data("resizable"),i=r.options,s=r.originalSize,o=r.originalPosition,u={height:r.size.height-s.height||0,width:r.size.width-s.width||0,top:r.position.top-o.top||0,left:r.position.left-o.left||0},a=function(t,r){e(t).each(function(){var t=e(this),i=e(this).data("resizable-alsoresize"),s={},o=r&&r.length?r:t.parents(n.originalElement[0]).length?["width","height"]:["width","height","top","left"];e.each(o,function(e,t){var n=(i[t]||0)+(u[t]||0);n&&n>=0&&(s[t]=n||null)}),t.css(s)})};typeof i.alsoResize=="object"&&!i.alsoResize.nodeType?e.each(i.alsoResize,function(e,t){a(e,t)}):a(i.alsoResize)},stop:function(t,n){e(this).removeData("resizable-alsoresize")}}),e.ui.plugin.add("resizable","animate",{stop:function(t,n){var r=e(this).data("resizable"),i=r.options,s=r._proportionallyResizeElements,o=s.length&&/textarea/i.test(s[0].nodeName),u=o&&e.ui.hasScroll(s[0],"left")?0:r.sizeDiff.height,a=o?0:r.sizeDiff.width,f={width:r.size.width-a,height:r.size.height-u},l=parseInt(r.element.css("left"),10)+(r.position.left-r.originalPosition.left)||null,c=parseInt(r.element.css("top"),10)+(r.position.top-r.originalPosition.top)||null;r.element.animate(e.extend(f,c&&l?{top:c,left:l}:{}),{duration:i.animateDuration,easing:i.animateEasing,step:function(){var n={width:parseInt(r.element.css("width"),10),height:parseInt(r.element.css("height"),10),top:parseInt(r.element.css("top"),10),left:parseInt(r.element.css("left"),10)};s&&s.length&&e(s[0]).css({width:n.width,height:n.height}),r._updateCache(n),r._propagate("resize",t)}})}}),e.ui.plugin.add("resizable","containment",{start:function(t,r){var i=e(this).data("resizable"),s=i.options,o=i.element,u=s.containment,a=u instanceof e?u.get(0):/parent/.test(u)?o.parent().get(0):u;if(!a)return;i.containerElement=e(a);if(/document/.test(u)||u==document)i.containerOffset={left:0,top:0},i.containerPosition={left:0,top:0},i.parentData={element:e(document),left:0,top:0,width:e(document).width(),height:e(document).height()||document.body.parentNode.scrollHeight};else{var f=e(a),l=[];e(["Top","Right","Left","Bottom"]).each(function(e,t){l[e]=n(f.css("padding"+t))}),i.containerOffset=f.offset(),i.containerPosition=f.position(),i.containerSize={height:f.innerHeight()-l[3],width:f.innerWidth()-l[1]};var c=i.containerOffset,h=i.containerSize.height,p=i.containerSize.width,d=e.ui.hasScroll(a,"left")?a.scrollWidth:p,v=e.ui.hasScroll(a)?a.scrollHeight:h;i.parentData={element:a,left:c.left,top:c.top,width:d,height:v}}},resize:function(t,n){var r=e(this).data("resizable"),i=r.options,s=r.containerSize,o=r.containerOffset,u=r.size,a=r.position,f=r._aspectRatio||t.shiftKey,l={top:0,left:0},c=r.containerElement;c[0]!=document&&/static/.test(c.css("position"))&&(l=o),a.left<(r._helper?o.left:0)&&(r.size.width=r.size.width+(r._helper?r.position.left-o.left:r.position.left-l.left),f&&(r.size.height=r.size.width/r.aspectRatio),r.position.left=i.helper?o.left:0),a.top<(r._helper?o.top:0)&&(r.size.height=r.size.height+(r._helper?r.position.top-o.top:r.position.top),f&&(r.size.width=r.size.height*r.aspectRatio),r.position.top=r._helper?o.top:0),r.offset.left=r.parentData.left+r.position.left,r.offset.top=r.parentData.top+r.position.top;var h=Math.abs((r._helper?r.offset.left-l.left:r.offset.left-l.left)+r.sizeDiff.width),p=Math.abs((r._helper?r.offset.top-l.top:r.offset.top-o.top)+r.sizeDiff.height),d=r.containerElement.get(0)==r.element.parent().get(0),v=/relative|absolute/.test(r.containerElement.css("position"));d&&v&&(h-=r.parentData.left),h+r.size.width>=r.parentData.width&&(r.size.width=r.parentData.width-h,f&&(r.size.height=r.size.width/r.aspectRatio)),p+r.size.height>=r.parentData.height&&(r.size.height=r.parentData.height-p,f&&(r.size.width=r.size.height*r.aspectRatio))},stop:function(t,n){var r=e(this).data("resizable"),i=r.options,s=r.position,o=r.containerOffset,u=r.containerPosition,a=r.containerElement,f=e(r.helper),l=f.offset(),c=f.outerWidth()-r.sizeDiff.width,h=f.outerHeight()-r.sizeDiff.height;r._helper&&!i.animate&&/relative/.test(a.css("position"))&&e(this).css({left:l.left-u.left-o.left,width:c,height:h}),r._helper&&!i.animate&&/static/.test(a.css("position"))&&e(this).css({left:l.left-u.left-o.left,width:c,height:h})}}),e.ui.plugin.add("resizable","ghost",{start:function(t,n){var r=e(this).data("resizable"),i=r.options,s=r.size;r.ghost=r.originalElement.clone(),r.ghost.css({opacity:.25,display:"block",position:"relative",height:s.height,width:s.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof i.ghost=="string"?i.ghost:""),r.ghost.appendTo(r.helper)},resize:function(t,n){var r=e(this).data("resizable"),i=r.options;r.ghost&&r.ghost.css({position:"relative",height:r.size.height,width:r.size.width})},stop:function(t,n){var r=e(this).data("resizable"),i=r.options;r.ghost&&r.helper&&r.helper.get(0).removeChild(r.ghost.get(0))}}),e.ui.plugin.add("resizable","grid",{resize:function(t,n){var r=e(this).data("resizable"),i=r.options,s=r.size,o=r.originalSize,u=r.originalPosition,a=r.axis,f=i._aspectRatio||t.shiftKey;i.grid=typeof i.grid=="number"?[i.grid,i.grid]:i.grid;var l=Math.round((s.width-o.width)/(i.grid[0]||1))*(i.grid[0]||1),c=Math.round((s.height-o.height)/(i.grid[1]||1))*(i.grid[1]||1);/^(se|s|e)$/.test(a)?(r.size.width=o.width+l,r.size.height=o.height+c):/^(ne)$/.test(a)?(r.size.width=o.width+l,r.size.height=o.height+c,r.position.top=u.top-c):/^(sw)$/.test(a)?(r.size.width=o.width+l,r.size.height=o.height+c,r.position.left=u.left-l):(r.size.width=o.width+l,r.size.height=o.height+c,r.position.top=u.top-c,r.position.left=u.left-l)}});var n=function(e){return parseInt(e,10)||0},r=function(e){return!isNaN(parseInt(e,10))}})(jQuery);(function(e,t){e.widget("ui.selectable",e.ui.mouse,{version:"1.9.1",options:{appendTo:"body",autoRefresh:!0,distance:0,filter:"*",tolerance:"touch"},_create:function(){var t=this;this.element.addClass("ui-selectable"),this.dragged=!1;var n;this.refresh=function(){n=e(t.options.filter,t.element[0]),n.addClass("ui-selectee"),n.each(function(){var t=e(this),n=t.offset();e.data(this,"selectable-item",{element:this,$element:t,left:n.left,top:n.top,right:n.left+t.outerWidth(),bottom:n.top+t.outerHeight(),startselected:!1,selected:t.hasClass("ui-selected"),selecting:t.hasClass("ui-selecting"),unselecting:t.hasClass("ui-unselecting")})})},this.refresh(),this.selectees=n.addClass("ui-selectee"),this._mouseInit(),this.helper=e("<div class='ui-selectable-helper'></div>")},_destroy:function(){this.selectees.removeClass("ui-selectee").removeData("selectable-item"),this.element.removeClass("ui-selectable ui-selectable-disabled"),this._mouseDestroy()},_mouseStart:function(t){var n=this;this.opos=[t.pageX,t.pageY];if(this.options.disabled)return;var r=this.options;this.selectees=e(r.filter,this.element[0]),this._trigger("start",t),e(r.appendTo).append(this.helper),this.helper.css({left:t.clientX,top:t.clientY,width:0,height:0}),r.autoRefresh&&this.refresh(),this.selectees.filter(".ui-selected").each(function(){var r=e.data(this,"selectable-item");r.startselected=!0,!t.metaKey&&!t.ctrlKey&&(r.$element.removeClass("ui-selected"),r.selected=!1,r.$element.addClass("ui-unselecting"),r.unselecting=!0,n._trigger("unselecting",t,{unselecting:r.element}))}),e(t.target).parents().andSelf().each(function(){var r=e.data(this,"selectable-item");if(r){var i=!t.metaKey&&!t.ctrlKey||!r.$element.hasClass("ui-selected");return r.$element.removeClass(i?"ui-unselecting":"ui-selected").addClass(i?"ui-selecting":"ui-unselecting"),r.unselecting=!i,r.selecting=i,r.selected=i,i?n._trigger("selecting",t,{selecting:r.element}):n._trigger("unselecting",t,{unselecting:r.element}),!1}})},_mouseDrag:function(t){var n=this;this.dragged=!0;if(this.options.disabled)return;var r=this.options,i=this.opos[0],s=this.opos[1],o=t.pageX,u=t.pageY;if(i>o){var a=o;o=i,i=a}if(s>u){var a=u;u=s,s=a}return this.helper.css({left:i,top:s,width:o-i,height:u-s}),this.selectees.each(function(){var a=e.data(this,"selectable-item");if(!a||a.element==n.element[0])return;var f=!1;r.tolerance=="touch"?f=!(a.left>o||a.right<i||a.top>u||a.bottom<s):r.tolerance=="fit"&&(f=a.left>i&&a.right<o&&a.top>s&&a.bottom<u),f?(a.selected&&(a.$element.removeClass("ui-selected"),a.selected=!1),a.unselecting&&(a.$element.removeClass("ui-unselecting"),a.unselecting=!1),a.selecting||(a.$element.addClass("ui-selecting"),a.selecting=!0,n._trigger("selecting",t,{selecting:a.element}))):(a.selecting&&((t.metaKey||t.ctrlKey)&&a.startselected?(a.$element.removeClass("ui-selecting"),a.selecting=!1,a.$element.addClass("ui-selected"),a.selected=!0):(a.$element.removeClass("ui-selecting"),a.selecting=!1,a.startselected&&(a.$element.addClass("ui-unselecting"),a.unselecting=!0),n._trigger("unselecting",t,{unselecting:a.element}))),a.selected&&!t.metaKey&&!t.ctrlKey&&!a.startselected&&(a.$element.removeClass("ui-selected"),a.selected=!1,a.$element.addClass("ui-unselecting"),a.unselecting=!0,n._trigger("unselecting",t,{unselecting:a.element})))}),!1},_mouseStop:function(t){var n=this;this.dragged=!1;var r=this.options;return e(".ui-unselecting",this.element[0]).each(function(){var r=e.data(this,"selectable-item");r.$element.removeClass("ui-unselecting"),r.unselecting=!1,r.startselected=!1,n._trigger("unselected",t,{unselected:r.element})}),e(".ui-selecting",this.element[0]).each(function(){var r=e.data(this,"selectable-item");r.$element.removeClass("ui-selecting").addClass("ui-selected"),r.selecting=!1,r.selected=!0,r.startselected=!0,n._trigger("selected",t,{selected:r.element})}),this._trigger("stop",t),this.helper.remove(),!1}})})(jQuery);(function(e,t){var n=5;e.widget("ui.slider",e.ui.mouse,{version:"1.9.1",widgetEventPrefix:"slide",options:{animate:!1,distance:0,max:100,min:0,orientation:"horizontal",range:!1,step:1,value:0,values:null},_create:function(){var t,r,i=this.options,s=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),o="<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",u=[];this._keySliding=!1,this._mouseSliding=!1,this._animateOff=!0,this._handleIndex=null,this._detectOrientation(),this._mouseInit(),this.element.addClass("ui-slider ui-slider-"+this.orientation+" ui-widget"+" ui-widget-content"+" ui-corner-all"+(i.disabled?" ui-slider-disabled ui-disabled":"")),this.range=e([]),i.range&&(i.range===!0&&(i.values||(i.values=[this._valueMin(),this._valueMin()]),i.values.length&&i.values.length!==2&&(i.values=[i.values[0],i.values[0]])),this.range=e("<div></div>").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+(i.range==="min"||i.range==="max"?" ui-slider-range-"+i.range:""))),r=i.values&&i.values.length||1;for(t=s.length;t<r;t++)u.push(o);this.handles=s.add(e(u.join("")).appendTo(this.element)),this.handle=this.handles.eq(0),this.handles.add(this.range).filter("a").click(function(e){e.preventDefault()}).mouseenter(function(){i.disabled||e(this).addClass("ui-state-hover")}).mouseleave(function(){e(this).removeClass("ui-state-hover")}).focus(function(){i.disabled?e(this).blur():(e(".ui-slider .ui-state-focus").removeClass("ui-state-focus"),e(this).addClass("ui-state-focus"))}).blur(function(){e(this).removeClass("ui-state-focus")}),this.handles.each(function(t){e(this).data("ui-slider-handle-index",t)}),this._on(this.handles,{keydown:function(t){var r,i,s,o,u=e(t.target).data("ui-slider-handle-index");switch(t.keyCode){case e.ui.keyCode.HOME:case e.ui.keyCode.END:case e.ui.keyCode.PAGE_UP:case e.ui.keyCode.PAGE_DOWN:case e.ui.keyCode.UP:case e.ui.keyCode.RIGHT:case e.ui.keyCode.DOWN:case e.ui.keyCode.LEFT:t.preventDefault();if(!this._keySliding){this._keySliding=!0,e(t.target).addClass("ui-state-active"),r=this._start(t,u);if(r===!1)return}}o=this.options.step,this.options.values&&this.options.values.length?i=s=this.values(u):i=s=this.value();switch(t.keyCode){case e.ui.keyCode.HOME:s=this._valueMin();break;case e.ui.keyCode.END:s=this._valueMax();break;case e.ui.keyCode.PAGE_UP:s=this._trimAlignValue(i+(this._valueMax()-this._valueMin())/n);break;case e.ui.keyCode.PAGE_DOWN:s=this._trimAlignValue(i-(this._valueMax()-this._valueMin())/n);break;case e.ui.keyCode.UP:case e.ui.keyCode.RIGHT:if(i===this._valueMax())return;s=this._trimAlignValue(i+o);break;case e.ui.keyCode.DOWN:case e.ui.keyCode.LEFT:if(i===this._valueMin())return;s=this._trimAlignValue(i-o)}this._slide(t,u,s)},keyup:function(t){var n=e(t.target).data("ui-slider-handle-index");this._keySliding&&(this._keySliding=!1,this._stop(t,n),this._change(t,n),e(t.target).removeClass("ui-state-active"))}}),this._refreshValue(),this._animateOff=!1},_destroy:function(){this.handles.remove(),this.range.remove(),this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all"),this._mouseDestroy()},_mouseCapture:function(t){var n,r,i,s,o,u,a,f,l=this,c=this.options;return c.disabled?!1:(this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()},this.elementOffset=this.element.offset(),n={x:t.pageX,y:t.pageY},r=this._normValueFromMouse(n),i=this._valueMax()-this._valueMin()+1,this.handles.each(function(t){var n=Math.abs(r-l.values(t));i>n&&(i=n,s=e(this),o=t)}),c.range===!0&&this.values(1)===c.min&&(o+=1,s=e(this.handles[o])),u=this._start(t,o),u===!1?!1:(this._mouseSliding=!0,this._handleIndex=o,s.addClass("ui-state-active").focus(),a=s.offset(),f=!e(t.target).parents().andSelf().is(".ui-slider-handle"),this._clickOffset=f?{left:0,top:0}:{left:t.pageX-a.left-s.width()/2,top:t.pageY-a.top-s.height()/2-(parseInt(s.css("borderTopWidth"),10)||0)-(parseInt(s.css("borderBottomWidth"),10)||0)+(parseInt(s.css("marginTop"),10)||0)},this.handles.hasClass("ui-state-hover")||this._slide(t,o,r),this._animateOff=!0,!0))},_mouseStart:function(){return!0},_mouseDrag:function(e){var t={x:e.pageX,y:e.pageY},n=this._normValueFromMouse(t);return this._slide(e,this._handleIndex,n),!1},_mouseStop:function(e){return this.handles.removeClass("ui-state-active"),this._mouseSliding=!1,this._stop(e,this._handleIndex),this._change(e,this._handleIndex),this._handleIndex=null,this._clickOffset=null,this._animateOff=!1,!1},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(e){var t,n,r,i,s;return this.orientation==="horizontal"?(t=this.elementSize.width,n=e.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)):(t=this.elementSize.height,n=e.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)),r=n/t,r>1&&(r=1),r<0&&(r=0),this.orientation==="vertical"&&(r=1-r),i=this._valueMax()-this._valueMin(),s=this._valueMin()+r*i,this._trimAlignValue(s)},_start:function(e,t){var n={handle:this.handles[t],value:this.value()};return this.options.values&&this.options.values.length&&(n.value=this.values(t),n.values=this.values()),this._trigger("start",e,n)},_slide:function(e,t,n){var r,i,s;this.options.values&&this.options.values.length?(r=this.values(t?0:1),this.options.values.length===2&&this.options.range===!0&&(t===0&&n>r||t===1&&n<r)&&(n=r),n!==this.values(t)&&(i=this.values(),i[t]=n,s=this._trigger("slide",e,{handle:this.handles[t],value:n,values:i}),r=this.values(t?0:1),s!==!1&&this.values(t,n,!0))):n!==this.value()&&(s=this._trigger("slide",e,{handle:this.handles[t],value:n}),s!==!1&&this.value(n))},_stop:function(e,t){var n={handle:this.handles[t],value:this.value()};this.options.values&&this.options.values.length&&(n.value=this.values(t),n.values=this.values()),this._trigger("stop",e,n)},_change:function(e,t){if(!this._keySliding&&!this._mouseSliding){var n={handle:this.handles[t],value:this.value()};this.options.values&&this.options.values.length&&(n.value=this.values(t),n.values=this.values()),this._trigger("change",e,n)}},value:function(e){if(arguments.length){this.options.value=this._trimAlignValue(e),this._refreshValue(),this._change(null,0);return}return this._value()},values:function(t,n){var r,i,s;if(arguments.length>1){this.options.values[t]=this._trimAlignValue(n),this._refreshValue(),this._change(null,t);return}if(!arguments.length)return this._values();if(!e.isArray(arguments[0]))return this.options.values&&this.options.values.length?this._values(t):this.value();r=this.options.values,i=arguments[0];for(s=0;s<r.length;s+=1)r[s]=this._trimAlignValue(i[s]),this._change(null,s);this._refreshValue()},_setOption:function(t,n){var r,i=0;e.isArray(this.options.values)&&(i=this.options.values.length),e.Widget.prototype._setOption.apply(this,arguments);switch(t){case"disabled":n?(this.handles.filter(".ui-state-focus").blur(),this.handles.removeClass("ui-state-hover"),this.handles.prop("disabled",!0),this.element.addClass("ui-disabled")):(this.handles.prop("disabled",!1),this.element.removeClass("ui-disabled"));break;case"orientation":this._detectOrientation(),this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation),this._refreshValue();break;case"value":this._animateOff=!0,this._refreshValue(),this._change(null,0),this._animateOff=!1;break;case"values":this._animateOff=!0,this._refreshValue();for(r=0;r<i;r+=1)this._change(null,r);this._animateOff=!1;break;case"min":case"max":this._animateOff=!0,this._refreshValue(),this._animateOff=!1}},_value:function(){var e=this.options.value;return e=this._trimAlignValue(e),e},_values:function(e){var t,n,r;if(arguments.length)return t=this.options.values[e],t=this._trimAlignValue(t),t;n=this.options.values.slice();for(r=0;r<n.length;r+=1)n[r]=this._trimAlignValue(n[r]);return n},_trimAlignValue:function(e){if(e<=this._valueMin())return this._valueMin();if(e>=this._valueMax())return this._valueMax();var t=this.options.step>0?this.options.step:1,n=(e-this._valueMin())%t,r=e-n;return Math.abs(n)*2>=t&&(r+=n>0?t:-t),parseFloat(r.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var t,n,r,i,s,o=this.options.range,u=this.options,a=this,f=this._animateOff?!1:u.animate,l={};this.options.values&&this.options.values.length?this.handles.each(function(r){n=(a.values(r)-a._valueMin())/(a._valueMax()-a._valueMin())*100,l[a.orientation==="horizontal"?"left":"bottom"]=n+"%",e(this).stop(1,1)[f?"animate":"css"](l,u.animate),a.options.range===!0&&(a.orientation==="horizontal"?(r===0&&a.range.stop(1,1)[f?"animate":"css"]({left:n+"%"},u.animate),r===1&&a.range[f?"animate":"css"]({width:n-t+"%"},{queue:!1,duration:u.animate})):(r===0&&a.range.stop(1,1)[f?"animate":"css"]({bottom:n+"%"},u.animate),r===1&&a.range[f?"animate":"css"]({height:n-t+"%"},{queue:!1,duration:u.animate}))),t=n}):(r=this.value(),i=this._valueMin(),s=this._valueMax(),n=s!==i?(r-i)/(s-i)*100:0,l[this.orientation==="horizontal"?"left":"bottom"]=n+"%",this.handle.stop(1,1)[f?"animate":"css"](l,u.animate),o==="min"&&this.orientation==="horizontal"&&this.range.stop(1,1)[f?"animate":"css"]({width:n+"%"},u.animate),o==="max"&&this.orientation==="horizontal"&&this.range[f?"animate":"css"]({width:100-n+"%"},{queue:!1,duration:u.animate}),o==="min"&&this.orientation==="vertical"&&this.range.stop(1,1)[f?"animate":"css"]({height:n+"%"},u.animate),o==="max"&&this.orientation==="vertical"&&this.range[f?"animate":"css"]({height:100-n+"%"},{queue:!1,duration:u.animate}))}})})(jQuery);(function(e,t){e.widget("ui.sortable",e.ui.mouse,{version:"1.9.1",widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3},_create:function(){var e=this.options;this.containerCache={},this.element.addClass("ui-sortable"),this.refresh(),this.floating=this.items.length?e.axis==="x"||/left|right/.test(this.items[0].item.css("float"))||/inline|table-cell/.test(this.items[0].item.css("display")):!1,this.offset=this.element.offset(),this._mouseInit(),this.ready=!0},_destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled"),this._mouseDestroy();for(var e=this.items.length-1;e>=0;e--)this.items[e].item.removeData(this.widgetName+"-item");return this},_setOption:function(t,n){t==="disabled"?(this.options[t]=n,this.widget().toggleClass("ui-sortable-disabled",!!n)):e.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(t,n){var r=this;if(this.reverting)return!1;if(this.options.disabled||this.options.type=="static")return!1;this._refreshItems(t);var i=null,s=e(t.target).parents().each(function(){if(e.data(this,r.widgetName+"-item")==r)return i=e(this),!1});e.data(t.target,r.widgetName+"-item")==r&&(i=e(t.target));if(!i)return!1;if(this.options.handle&&!n){var o=!1;e(this.options.handle,i).find("*").andSelf().each(function(){this==t.target&&(o=!0)});if(!o)return!1}return this.currentItem=i,this._removeCurrentsFromItems(),!0},_mouseStart:function(t,n,r){var i=this.options;this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(t),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},e.extend(this.offset,{click:{left:t.pageX-this.offset.left,top:t.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(t),this.originalPageX=t.pageX,this.originalPageY=t.pageY,i.cursorAt&&this._adjustOffsetFromHelper(i.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!=this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),i.containment&&this._setContainment(),i.cursor&&(e("body").css("cursor")&&(this._storedCursor=e("body").css("cursor")),e("body").css("cursor",i.cursor)),i.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",i.opacity)),i.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",i.zIndex)),this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",t,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions();if(!r)for(var s=this.containers.length-1;s>=0;s--)this.containers[s]._trigger("activate",t,this._uiHash(this));return e.ui.ddmanager&&(e.ui.ddmanager.current=this),e.ui.ddmanager&&!i.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t),this.dragging=!0,this.helper.addClass("ui-sortable-helper"),this._mouseDrag(t),!0},_mouseDrag:function(t){this.position=this._generatePosition(t),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs);if(this.options.scroll){var n=this.options,r=!1;this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-t.pageY<n.scrollSensitivity?this.scrollParent[0].scrollTop=r=this.scrollParent[0].scrollTop+n.scrollSpeed:t.pageY-this.overflowOffset.top<n.scrollSensitivity&&(this.scrollParent[0].scrollTop=r=this.scrollParent[0].scrollTop-n.scrollSpeed),this.overflowOffset.left+this.scrollParent[0].offsetWidth-t.pageX<n.scrollSensitivity?this.scrollParent[0].scrollLeft=r=this.scrollParent[0].scrollLeft+n.scrollSpeed:t.pageX-this.overflowOffset.left<n.scrollSensitivity&&(this.scrollParent[0].scrollLeft=r=this.scrollParent[0].scrollLeft-n.scrollSpeed)):(t.pageY-e(document).scrollTop()<n.scrollSensitivity?r=e(document).scrollTop(e(document).scrollTop()-n.scrollSpeed):e(window).height()-(t.pageY-e(document).scrollTop())<n.scrollSensitivity&&(r=e(document).scrollTop(e(document).scrollTop()+n.scrollSpeed)),t.pageX-e(document).scrollLeft()<n.scrollSensitivity?r=e(document).scrollLeft(e(document).scrollLeft()-n.scrollSpeed):e(window).width()-(t.pageX-e(document).scrollLeft())<n.scrollSensitivity&&(r=e(document).scrollLeft(e(document).scrollLeft()+n.scrollSpeed))),r!==!1&&e.ui.ddmanager&&!n.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t)}this.positionAbs=this._convertPositionTo("absolute");if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";for(var i=this.items.length-1;i>=0;i--){var s=this.items[i],o=s.item[0],u=this._intersectsWithPointer(s);if(!u)continue;if(s.instance!==this.currentContainer)continue;if(o!=this.currentItem[0]&&this.placeholder[u==1?"next":"prev"]()[0]!=o&&!e.contains(this.placeholder[0],o)&&(this.options.type=="semi-dynamic"?!e.contains(this.element[0],o):!0)){this.direction=u==1?"down":"up";if(this.options.tolerance!="pointer"&&!this._intersectsWithSides(s))break;this._rearrange(t,s),this._trigger("change",t,this._uiHash());break}}return this._contactContainers(t),e.ui.ddmanager&&e.ui.ddmanager.drag(this,t),this._trigger("sort",t,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(t,n){if(!t)return;e.ui.ddmanager&&!this.options.dropBehaviour&&e.ui.ddmanager.drop(this,t);if(this.options.revert){var r=this,i=this.placeholder.offset();this.reverting=!0,e(this.helper).animate({left:i.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft),top:i.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)},parseInt(this.options.revert,10)||500,function(){r._clear(t)})}else this._clear(t,n);return!1},cancel:function(){if(this.dragging){this._mouseUp({target:null}),this.options.helper=="original"?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var t=this.containers.length-1;t>=0;t--)this.containers[t]._trigger("deactivate",null,this._uiHash(this)),this.containers[t].containerCache.over&&(this.containers[t]._trigger("out",null,this._uiHash(this)),this.containers[t].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.options.helper!="original"&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),e.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?e(this.domPosition.prev).after(this.currentItem):e(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(t){var n=this._getItemsAsjQuery(t&&t.connected),r=[];return t=t||{},e(n).each(function(){var n=(e(t.item||this).attr(t.attribute||"id")||"").match(t.expression||/(.+)[-=_](.+)/);n&&r.push((t.key||n[1]+"[]")+"="+(t.key&&t.expression?n[1]:n[2]))}),!r.length&&t.key&&r.push(t.key+"="),r.join("&")},toArray:function(t){var n=this._getItemsAsjQuery(t&&t.connected),r=[];return t=t||{},n.each(function(){r.push(e(t.item||this).attr(t.attribute||"id")||"")}),r},_intersectsWith:function(e){var t=this.positionAbs.left,n=t+this.helperProportions.width,r=this.positionAbs.top,i=r+this.helperProportions.height,s=e.left,o=s+e.width,u=e.top,a=u+e.height,f=this.offset.click.top,l=this.offset.click.left,c=r+f>u&&r+f<a&&t+l>s&&t+l<o;return this.options.tolerance=="pointer"||this.options.forcePointerForContainers||this.options.tolerance!="pointer"&&this.helperProportions[this.floating?"width":"height"]>e[this.floating?"width":"height"]?c:s<t+this.helperProportions.width/2&&n-this.helperProportions.width/2<o&&u<r+this.helperProportions.height/2&&i-this.helperProportions.height/2<a},_intersectsWithPointer:function(t){var n=this.options.axis==="x"||e.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,t.top,t.height),r=this.options.axis==="y"||e.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,t.left,t.width),i=n&&r,s=this._getDragVerticalDirection(),o=this._getDragHorizontalDirection();return i?this.floating?o&&o=="right"||s=="down"?2:1:s&&(s=="down"?2:1):!1},_intersectsWithSides:function(t){var n=e.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,t.top+t.height/2,t.height),r=e.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,t.left+t.width/2,t.width),i=this._getDragVerticalDirection(),s=this._getDragHorizontalDirection();return this.floating&&s?s=="right"&&r||s=="left"&&!r:i&&(i=="down"&&n||i=="up"&&!n)},_getDragVerticalDirection:function(){var e=this.positionAbs.top-this.lastPositionAbs.top;return e!=0&&(e>0?"down":"up")},_getDragHorizontalDirection:function(){var e=this.positionAbs.left-this.lastPositionAbs.left;return e!=0&&(e>0?"right":"left")},refresh:function(e){return this._refreshItems(e),this.refreshPositions(),this},_connectWith:function(){var e=this.options;return e.connectWith.constructor==String?[e.connectWith]:e.connectWith},_getItemsAsjQuery:function(t){var n=[],r=[],i=this._connectWith();if(i&&t)for(var s=i.length-1;s>=0;s--){var o=e(i[s]);for(var u=o.length-1;u>=0;u--){var a=e.data(o[u],this.widgetName);a&&a!=this&&!a.options.disabled&&r.push([e.isFunction(a.options.items)?a.options.items.call(a.element):e(a.options.items,a.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),a])}}r.push([e.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):e(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]);for(var s=r.length-1;s>=0;s--)r[s][0].each(function(){n.push(this)});return e(n)},_removeCurrentsFromItems:function(){var t=this.currentItem.find(":data("+this.widgetName+"-item)");this.items=e.grep(this.items,function(e){for(var n=0;n<t.length;n++)if(t[n]==e.item[0])return!1;return!0})},_refreshItems:function(t){this.items=[],this.containers=[this];var n=this.items,r=[[e.isFunction(this.options.items)?this.options.items.call(this.element[0],t,{item:this.currentItem}):e(this.options.items,this.element),this]],i=this._connectWith();if(i&&this.ready)for(var s=i.length-1;s>=0;s--){var o=e(i[s]);for(var u=o.length-1;u>=0;u--){var a=e.data(o[u],this.widgetName);a&&a!=this&&!a.options.disabled&&(r.push([e.isFunction(a.options.items)?a.options.items.call(a.element[0],t,{item:this.currentItem}):e(a.options.items,a.element),a]),this.containers.push(a))}}for(var s=r.length-1;s>=0;s--){var f=r[s][1],l=r[s][0];for(var u=0,c=l.length;u<c;u++){var h=e(l[u]);h.data(this.widgetName+"-item",f),n.push({item:h,instance:f,width:0,height:0,left:0,top:0})}}},refreshPositions:function(t){this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset());for(var n=this.items.length-1;n>=0;n--){var r=this.items[n];if(r.instance!=this.currentContainer&&this.currentContainer&&r.item[0]!=this.currentItem[0])continue;var i=this.options.toleranceElement?e(this.options.toleranceElement,r.item):r.item;t||(r.width=i.outerWidth(),r.height=i.outerHeight());var s=i.offset();r.left=s.left,r.top=s.top}if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(var n=this.containers.length-1;n>=0;n--){var s=this.containers[n].element.offset();this.containers[n].containerCache.left=s.left,this.containers[n].containerCache.top=s.top,this.containers[n].containerCache.width=this.containers[n].element.outerWidth(),this.containers[n].containerCache.height=this.containers[n].element.outerHeight()}return this},_createPlaceholder:function(t){t=t||this;var n=t.options;if(!n.placeholder||n.placeholder.constructor==String){var r=n.placeholder;n.placeholder={element:function(){var n=e(document.createElement(t.currentItem[0].nodeName)).addClass(r||t.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper")[0];return r||(n.style.visibility="hidden"),n},update:function(e,i){if(r&&!n.forcePlaceholderSize)return;i.height()||i.height(t.currentItem.innerHeight()-parseInt(t.currentItem.css("paddingTop")||0,10)-parseInt(t.currentItem.css("paddingBottom")||0,10)),i.width()||i.width(t.currentItem.innerWidth()-parseInt(t.currentItem.css("paddingLeft")||0,10)-parseInt(t.currentItem.css("paddingRight")||0,10))}}}t.placeholder=e(n.placeholder.element.call(t.element,t.currentItem)),t.currentItem.after(t.placeholder),n.placeholder.update(t,t.placeholder)},_contactContainers:function(t){var n=null,r=null;for(var i=this.containers.length-1;i>=0;i--){if(e.contains(this.currentItem[0],this.containers[i].element[0]))continue;if(this._intersectsWith(this.containers[i].containerCache)){if(n&&e.contains(this.containers[i].element[0],n.element[0]))continue;n=this.containers[i],r=i}else this.containers[i].containerCache.over&&(this.containers[i]._trigger("out",t,this._uiHash(this)),this.containers[i].containerCache.over=0)}if(!n)return;if(this.containers.length===1)this.containers[r]._trigger("over",t,this._uiHash(this)),this.containers[r].containerCache.over=1;else{var s=1e4,o=null,u=this.containers[r].floating?"left":"top",a=this.containers[r].floating?"width":"height",f=this.positionAbs[u]+this.offset.click[u];for(var l=this.items.length-1;l>=0;l--){if(!e.contains(this.containers[r].element[0],this.items[l].item[0]))continue;if(this.items[l].item[0]==this.currentItem[0])continue;var c=this.items[l].item.offset()[u],h=!1;Math.abs(c-f)>Math.abs(c+this.items[l][a]-f)&&(h=!0,c+=this.items[l][a]),Math.abs(c-f)<s&&(s=Math.abs(c-f),o=this.items[l],this.direction=h?"up":"down")}if(!o&&!this.options.dropOnEmpty)return;this.currentContainer=this.containers[r],o?this._rearrange(t,o,null,!0):this._rearrange(t,null,this.containers[r].element,!0),this._trigger("change",t,this._uiHash()),this.containers[r]._trigger("change",t,this._uiHash(this)),this.options.placeholder.update(this.currentContainer,this.placeholder),this.containers[r]._trigger("over",t,this._uiHash(this)),this.containers[r].containerCache.over=1}},_createHelper:function(t){var n=this.options,r=e.isFunction(n.helper)?e(n.helper.apply(this.element[0],[t,this.currentItem])):n.helper=="clone"?this.currentItem.clone():this.currentItem;return r.parents("body").length||e(n.appendTo!="parent"?n.appendTo:this.currentItem[0].parentNode)[0].appendChild(r[0]),r[0]==this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),(r[0].style.width==""||n.forceHelperSize)&&r.width(this.currentItem.width()),(r[0].style.height==""||n.forceHelperSize)&&r.height(this.currentItem.height()),r},_adjustOffsetFromHelper:function(t){typeof t=="string"&&(t=t.split(" ")),e.isArray(t)&&(t={left:+t[0],top:+t[1]||0}),"left"in t&&(this.offset.click.left=t.left+this.margins.left),"right"in t&&(this.offset.click.left=this.helperProportions.width-t.right+this.margins.left),"top"in t&&(this.offset.click.top=t.top+this.margins.top),"bottom"in t&&(this.offset.click.top=this.helperProportions.height-t.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var t=this.offsetParent.offset();this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&e.contains(this.scrollParent[0],this.offsetParent[0])&&(t.left+=this.scrollParent.scrollLeft(),t.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&e.ui.ie)t={top:0,left:0};return{top:t.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:t.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var e=this.currentItem.position();return{top:e.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:e.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var t=this.options;t.containment=="parent"&&(t.containment=this.helper[0].parentNode);if(t.containment=="document"||t.containment=="window")this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,e(t.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(e(t.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(t.containment)){var n=e(t.containment)[0],r=e(t.containment).offset(),i=e(n).css("overflow")!="hidden";this.containment=[r.left+(parseInt(e(n).css("borderLeftWidth"),10)||0)+(parseInt(e(n).css("paddingLeft"),10)||0)-this.margins.left,r.top+(parseInt(e(n).css("borderTopWidth"),10)||0)+(parseInt(e(n).css("paddingTop"),10)||0)-this.margins.top,r.left+(i?Math.max(n.scrollWidth,n.offsetWidth):n.offsetWidth)-(parseInt(e(n).css("borderLeftWidth"),10)||0)-(parseInt(e(n).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,r.top+(i?Math.max(n.scrollHeight,n.offsetHeight):n.offsetHeight)-(parseInt(e(n).css("borderTopWidth"),10)||0)-(parseInt(e(n).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top]}},_convertPositionTo:function(t,n){n||(n=this.position);var r=t=="absolute"?1:-1,i=this.options,s=this.cssPosition!="absolute"||this.scrollParent[0]!=document&&!!e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,o=/(html|body)/i.test(s[0].tagName);return{top:n.top+this.offset.relative.top*r+this.offset.parent.top*r-(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():o?0:s.scrollTop())*r,left:n.left+this.offset.relative.left*r+this.offset.parent.left*r-(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():o?0:s.scrollLeft())*r}},_generatePosition:function(t){var n=this.options,r=this.cssPosition!="absolute"||this.scrollParent[0]!=document&&!!e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,i=/(html|body)/i.test(r[0].tagName);this.cssPosition=="relative"&&(this.scrollParent[0]==document||this.scrollParent[0]==this.offsetParent[0])&&(this.offset.relative=this._getRelativeOffset());var s=t.pageX,o=t.pageY;if(this.originalPosition){this.containment&&(t.pageX-this.offset.click.left<this.containment[0]&&(s=this.containment[0]+this.offset.click.left),t.pageY-this.offset.click.top<this.containment[1]&&(o=this.containment[1]+this.offset.click.top),t.pageX-this.offset.click.left>this.containment[2]&&(s=this.containment[2]+this.offset.click.left),t.pageY-this.offset.click.top>this.containment[3]&&(o=this.containment[3]+this.offset.click.top));if(n.grid){var u=this.originalPageY+Math.round((o-this.originalPageY)/n.grid[1])*n.grid[1];o=this.containment?u-this.offset.click.top<this.containment[1]||u-this.offset.click.top>this.containment[3]?u-this.offset.click.top<this.containment[1]?u+n.grid[1]:u-n.grid[1]:u:u;var a=this.originalPageX+Math.round((s-this.originalPageX)/n.grid[0])*n.grid[0];s=this.containment?a-this.offset.click.left<this.containment[0]||a-this.offset.click.left>this.containment[2]?a-this.offset.click.left<this.containment[0]?a+n.grid[0]:a-n.grid[0]:a:a}}return{top:o-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():i?0:r.scrollTop()),left:s-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():i?0:r.scrollLeft())}},_rearrange:function(e,t,n,r){n?n[0].appendChild(this.placeholder[0]):t.item[0].parentNode.insertBefore(this.placeholder[0],this.direction=="down"?t.item[0]:t.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var i=this.counter;this._delay(function(){i==this.counter&&this.refreshPositions(!r)})},_clear:function(t,n){this.reverting=!1;var r=[];!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null;if(this.helper[0]==this.currentItem[0]){for(var i in this._storedCSS)if(this._storedCSS[i]=="auto"||this._storedCSS[i]=="static")this._storedCSS[i]="";this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();this.fromOutside&&!n&&r.push(function(e){this._trigger("receive",e,this._uiHash(this.fromOutside))}),(this.fromOutside||this.domPosition.prev!=this.currentItem.prev().not(".ui-sortable-helper")[0]||this.domPosition.parent!=this.currentItem.parent()[0])&&!n&&r.push(function(e){this._trigger("update",e,this._uiHash())}),this!==this.currentContainer&&(n||(r.push(function(e){this._trigger("remove",e,this._uiHash())}),r.push(function(e){return function(t){e._trigger("receive",t,this._uiHash(this))}}.call(this,this.currentContainer)),r.push(function(e){return function(t){e._trigger("update",t,this._uiHash(this))}}.call(this,this.currentContainer))));for(var i=this.containers.length-1;i>=0;i--)n||r.push(function(e){return function(t){e._trigger("deactivate",t,this._uiHash(this))}}.call(this,this.containers[i])),this.containers[i].containerCache.over&&(r.push(function(e){return function(t){e._trigger("out",t,this._uiHash(this))}}.call(this,this.containers[i])),this.containers[i].containerCache.over=0);this._storedCursor&&e("body").css("cursor",this._storedCursor),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex",this._storedZIndex=="auto"?"":this._storedZIndex),this.dragging=!1;if(this.cancelHelperRemoval){if(!n){this._trigger("beforeStop",t,this._uiHash());for(var i=0;i<r.length;i++)r[i].call(this,t);this._trigger("stop",t,this._uiHash())}return this.fromOutside=!1,!1}n||this._trigger("beforeStop",t,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.helper[0]!=this.currentItem[0]&&this.helper.remove(),this.helper=null;if(!n){for(var i=0;i<r.length;i++)r[i].call(this,t);this._trigger("stop",t,this._uiHash())}return this.fromOutside=!1,!0},_trigger:function(){e.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(t){var n=t||this;return{helper:n.helper,placeholder:n.placeholder||e([]),position:n.position,originalPosition:n.originalPosition,offset:n.positionAbs,item:n.currentItem,sender:t?t.element:null}}})})(jQuery);(function(e){function t(e){return function(){var t=this.element.val();e.apply(this,arguments),this._refresh(),t!==this.element.val()&&this._trigger("change")}}e.widget("ui.spinner",{version:"1.9.1",defaultElement:"<input>",widgetEventPrefix:"spin",options:{culture:null,icons:{down:"ui-icon-triangle-1-s",up:"ui-icon-triangle-1-n"},incremental:!0,max:null,min:null,numberFormat:null,page:10,step:1,change:null,spin:null,start:null,stop:null},_create:function(){this._setOption("max",this.options.max),this._setOption("min",this.options.min),this._setOption("step",this.options.step),this._value(this.element.val(),!0),this._draw(),this._on(this._events),this._refresh(),this._on(this.window,{beforeunload:function(){this.element.removeAttr("autocomplete")}})},_getCreateOptions:function(){var t={},n=this.element;return e.each(["min","max","step"],function(e,r){var i=n.attr(r);i!==undefined&&i.length&&(t[r]=i)}),t},_events:{keydown:function(e){this._start(e)&&this._keydown(e)&&e.preventDefault()},keyup:"_stop",focus:function(){this.previous=this.element.val()},blur:function(e){if(this.cancelBlur){delete this.cancelBlur;return}this._refresh(),this.previous!==this.element.val()&&this._trigger("change",e)},mousewheel:function(e,t){if(!t)return;if(!this.spinning&&!this._start(e))return!1;this._spin((t>0?1:-1)*this.options.step,e),clearTimeout(this.mousewheelTimer),this.mousewheelTimer=this._delay(function(){this.spinning&&this._stop(e)},100),e.preventDefault()},"mousedown .ui-spinner-button":function(t){function r(){var e=this.element[0]===this.document[0].activeElement;e||(this.element.focus(),this.previous=n,this._delay(function(){this.previous=n}))}var n;n=this.element[0]===this.document[0].activeElement?this.previous:this.element.val(),t.preventDefault(),r.call(this),this.cancelBlur=!0,this._delay(function(){delete this.cancelBlur,r.call(this)});if(this._start(t)===!1)return;this._repeat(null,e(t.currentTarget).hasClass("ui-spinner-up")?1:-1,t)},"mouseup .ui-spinner-button":"_stop","mouseenter .ui-spinner-button":function(t){if(!e(t.currentTarget).hasClass("ui-state-active"))return;if(this._start(t)===!1)return!1;this._repeat(null,e(t.currentTarget).hasClass("ui-spinner-up")?1:-1,t)},"mouseleave .ui-spinner-button":"_stop"},_draw:function(){var e=this.uiSpinner=this.element.addClass("ui-spinner-input").attr("autocomplete","off").wrap(this._uiSpinnerHtml()).parent().append(this._buttonHtml());this.element.attr("role","spinbutton"),this.buttons=e.find(".ui-spinner-button").attr("tabIndex",-1).button().removeClass("ui-corner-all"),this.buttons.height()>Math.ceil(e.height()*.5)&&e.height()>0&&e.height(e.height()),this.options.disabled&&this.disable()},_keydown:function(t){var n=this.options,r=e.ui.keyCode;switch(t.keyCode){case r.UP:return this._repeat(null,1,t),!0;case r.DOWN:return this._repeat(null,-1,t),!0;case r.PAGE_UP:return this._repeat(null,n.page,t),!0;case r.PAGE_DOWN:return this._repeat(null,-n.page,t),!0}return!1},_uiSpinnerHtml:function(){return"<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>"},_buttonHtml:function(){return"<a class='ui-spinner-button ui-spinner-up ui-corner-tr'><span class='ui-icon "+this.options.icons.up+"'>&#9650;</span>"+"</a>"+"<a class='ui-spinner-button ui-spinner-down ui-corner-br'>"+"<span class='ui-icon "+this.options.icons.down+"'>&#9660;</span>"+"</a>"},_start:function(e){return!this.spinning&&this._trigger("start",e)===!1?!1:(this.counter||(this.counter=1),this.spinning=!0,!0)},_repeat:function(e,t,n){e=e||500,clearTimeout(this.timer),this.timer=this._delay(function(){this._repeat(40,t,n)},e),this._spin(t*this.options.step,n)},_spin:function(e,t){var n=this.value()||0;this.counter||(this.counter=1),n=this._adjustValue(n+e*this._increment(this.counter));if(!this.spinning||this._trigger("spin",t,{value:n})!==!1)this._value(n),this.counter++},_increment:function(t){var n=this.options.incremental;return n?e.isFunction(n)?n(t):Math.floor(t*t*t/5e4-t*t/500+17*t/200+1):1},_precision:function(){var e=this._precisionOf(this.options.step);return this.options.min!==null&&(e=Math.max(e,this._precisionOf(this.options.min))),e},_precisionOf:function(e){var t=e.toString(),n=t.indexOf(".");return n===-1?0:t.length-n-1},_adjustValue:function(e){var t,n,r=this.options;return t=r.min!==null?r.min:0,n=e-t,n=Math.round(n/r.step)*r.step,e=t+n,e=parseFloat(e.toFixed(this._precision())),r.max!==null&&e>r.max?r.max:r.min!==null&&e<r.min?r.min:e},_stop:function(e){if(!this.spinning)return;clearTimeout(this.timer),clearTimeout(this.mousewheelTimer),this.counter=0,this.spinning=!1,this._trigger("stop",e)},_setOption:function(e,t){if(e==="culture"||e==="numberFormat"){var n=this._parse(this.element.val());this.options[e]=t,this.element.val(this._format(n));return}(e==="max"||e==="min"||e==="step")&&typeof t=="string"&&(t=this._parse(t)),this._super(e,t),e==="disabled"&&(t?(this.element.prop("disabled",!0),this.buttons.button("disable")):(this.element.prop("disabled",!1),this.buttons.button("enable")))},_setOptions:t(function(e){this._super(e),this._value(this.element.val())}),_parse:function(e){return typeof e=="string"&&e!==""&&(e=window.Globalize&&this.options.numberFormat?Globalize.parseFloat(e,10,this.options.culture):+e),e===""||isNaN(e)?null:e},_format:function(e){return e===""?"":window.Globalize&&this.options.numberFormat?Globalize.format(e,this.options.numberFormat,this.options.culture):e},_refresh:function(){this.element.attr({"aria-valuemin":this.options.min,"aria-valuemax":this.options.max,"aria-valuenow":this._parse(this.element.val())})},_value:function(e,t){var n;e!==""&&(n=this._parse(e),n!==null&&(t||(n=this._adjustValue(n)),e=this._format(n))),this.element.val(e),this._refresh()},_destroy:function(){this.element.removeClass("ui-spinner-input").prop("disabled",!1).removeAttr("autocomplete").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow"),this.uiSpinner.replaceWith(this.element)},stepUp:t(function(e){this._stepUp(e)}),_stepUp:function(e){this._spin((e||1)*this.options.step)},stepDown:t(function(e){this._stepDown(e)}),_stepDown:function(e){this._spin((e||1)*-this.options.step)},pageUp:t(function(e){this._stepUp((e||1)*this.options.page)}),pageDown:t(function(e){this._stepDown((e||1)*this.options.page)}),value:function(e){if(!arguments.length)return this._parse(this.element.val());t(this._value).call(this,e)},widget:function(){return this.uiSpinner}})})(jQuery);(function(e,t){function i(){return++n}function s(e){return e.hash.length>1&&e.href.replace(r,"")===location.href.replace(r,"")}var n=0,r=/#.*$/;e.widget("ui.tabs",{version:"1.9.1",delay:300,options:{active:null,collapsible:!1,event:"click",heightStyle:"content",hide:null,show:null,activate:null,beforeActivate:null,beforeLoad:null,load:null},_create:function(){var t=this,n=this.options,r=n.active,i=location.hash.substring(1);this.running=!1,this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all").toggleClass("ui-tabs-collapsible",n.collapsible).delegate(".ui-tabs-nav > li","mousedown"+this.eventNamespace,function(t){e(this).is(".ui-state-disabled")&&t.preventDefault()}).delegate(".ui-tabs-anchor","focus"+this.eventNamespace,function(){e(this).closest("li").is(".ui-state-disabled")&&this.blur()}),this._processTabs();if(r===null){i&&this.tabs.each(function(t,n){if(e(n).attr("aria-controls")===i)return r=t,!1}),r===null&&(r=this.tabs.index(this.tabs.filter(".ui-tabs-active")));if(r===null||r===-1)r=this.tabs.length?0:!1}r!==!1&&(r=this.tabs.index(this.tabs.eq(r)),r===-1&&(r=n.collapsible?!1:0)),n.active=r,!n.collapsible&&n.active===!1&&this.anchors.length&&(n.active=0),e.isArray(n.disabled)&&(n.disabled=e.unique(n.disabled.concat(e.map(this.tabs.filter(".ui-state-disabled"),function(e){return t.tabs.index(e)}))).sort()),this.options.active!==!1&&this.anchors.length?this.active=this._findActive(this.options.active):this.active=e(),this._refresh(),this.active.length&&this.load(n.active)},_getCreateEventData:function(){return{tab:this.active,panel:this.active.length?this._getPanelForTab(this.active):e()}},_tabKeydown:function(t){var n=e(this.document[0].activeElement).closest("li"),r=this.tabs.index(n),i=!0;if(this._handlePageNav(t))return;switch(t.keyCode){case e.ui.keyCode.RIGHT:case e.ui.keyCode.DOWN:r++;break;case e.ui.keyCode.UP:case e.ui.keyCode.LEFT:i=!1,r--;break;case e.ui.keyCode.END:r=this.anchors.length-1;break;case e.ui.keyCode.HOME:r=0;break;case e.ui.keyCode.SPACE:t.preventDefault(),clearTimeout(this.activating),this._activate(r);return;case e.ui.keyCode.ENTER:t.preventDefault(),clearTimeout(this.activating),this._activate(r===this.options.active?!1:r);return;default:return}t.preventDefault(),clearTimeout(this.activating),r=this._focusNextTab(r,i),t.ctrlKey||(n.attr("aria-selected","false"),this.tabs.eq(r).attr("aria-selected","true"),this.activating=this._delay(function(){this.option("active",r)},this.delay))},_panelKeydown:function(t){if(this._handlePageNav(t))return;t.ctrlKey&&t.keyCode===e.ui.keyCode.UP&&(t.preventDefault(),this.active.focus())},_handlePageNav:function(t){if(t.altKey&&t.keyCode===e.ui.keyCode.PAGE_UP)return this._activate(this._focusNextTab(this.options.active-1,!1)),!0;if(t.altKey&&t.keyCode===e.ui.keyCode.PAGE_DOWN)return this._activate(this._focusNextTab(this.options.active+1,!0)),!0},_findNextTab:function(t,n){function i(){return t>r&&(t=0),t<0&&(t=r),t}var r=this.tabs.length-1;while(e.inArray(i(),this.options.disabled)!==-1)t=n?t+1:t-1;return t},_focusNextTab:function(e,t){return e=this._findNextTab(e,t),this.tabs.eq(e).focus(),e},_setOption:function(e,t){if(e==="active"){this._activate(t);return}if(e==="disabled"){this._setupDisabled(t);return}this._super(e,t),e==="collapsible"&&(this.element.toggleClass("ui-tabs-collapsible",t),!t&&this.options.active===!1&&this._activate(0)),e==="event"&&this._setupEvents(t),e==="heightStyle"&&this._setupHeightStyle(t)},_tabId:function(e){return e.attr("aria-controls")||"ui-tabs-"+i()},_sanitizeSelector:function(e){return e?e.replace(/[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g,"\\$&"):""},refresh:function(){var t=this.options,n=this.tablist.children(":has(a[href])");t.disabled=e.map(n.filter(".ui-state-disabled"),function(e){return n.index(e)}),this._processTabs(),t.active===!1||!this.anchors.length?(t.active=!1,this.active=e()):this.active.length&&!e.contains(this.tablist[0],this.active[0])?this.tabs.length===t.disabled.length?(t.active=!1,this.active=e()):this._activate(this._findNextTab(Math.max(0,t.active-1),!1)):t.active=this.tabs.index(this.active),this._refresh()},_refresh:function(){this._setupDisabled(this.options.disabled),this._setupEvents(this.options.event),this._setupHeightStyle(this.options.heightStyle),this.tabs.not(this.active).attr({"aria-selected":"false",tabIndex:-1}),this.panels.not(this._getPanelForTab(this.active)).hide().attr({"aria-expanded":"false","aria-hidden":"true"}),this.active.length?(this.active.addClass("ui-tabs-active ui-state-active").attr({"aria-selected":"true",tabIndex:0}),this._getPanelForTab(this.active).show().attr({"aria-expanded":"true","aria-hidden":"false"})):this.tabs.eq(0).attr("tabIndex",0)},_processTabs:function(){var t=this;this.tablist=this._getList().addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all").attr("role","tablist"),this.tabs=this.tablist.find("> li:has(a[href])").addClass("ui-state-default ui-corner-top").attr({role:"tab",tabIndex:-1}),this.anchors=this.tabs.map(function(){return e("a",this)[0]}).addClass("ui-tabs-anchor").attr({role:"presentation",tabIndex:-1}),this.panels=e(),this.anchors.each(function(n,r){var i,o,u,a=e(r).uniqueId().attr("id"),f=e(r).closest("li"),l=f.attr("aria-controls");s(r)?(i=r.hash,o=t.element.find(t._sanitizeSelector(i))):(u=t._tabId(f),i="#"+u,o=t.element.find(i),o.length||(o=t._createPanel(u),o.insertAfter(t.panels[n-1]||t.tablist)),o.attr("aria-live","polite")),o.length&&(t.panels=t.panels.add(o)),l&&f.data("ui-tabs-aria-controls",l),f.attr({"aria-controls":i.substring(1),"aria-labelledby":a}),o.attr("aria-labelledby",a)}),this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").attr("role","tabpanel")},_getList:function(){return this.element.find("ol,ul").eq(0)},_createPanel:function(t){return e("<div>").attr("id",t).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").data("ui-tabs-destroy",!0)},_setupDisabled:function(t){e.isArray(t)&&(t.length?t.length===this.anchors.length&&(t=!0):t=!1);for(var n=0,r;r=this.tabs[n];n++)t===!0||e.inArray(n,t)!==-1?e(r).addClass("ui-state-disabled").attr("aria-disabled","true"):e(r).removeClass("ui-state-disabled").removeAttr("aria-disabled");this.options.disabled=t},_setupEvents:function(t){var n={click:function(e){e.preventDefault()}};t&&e.each(t.split(" "),function(e,t){n[t]="_eventHandler"}),this._off(this.anchors.add(this.tabs).add(this.panels)),this._on(this.anchors,n),this._on(this.tabs,{keydown:"_tabKeydown"}),this._on(this.panels,{keydown:"_panelKeydown"}),this._focusable(this.tabs),this._hoverable(this.tabs)},_setupHeightStyle:function(t){var n,r,i=this.element.parent();t==="fill"?(e.support.minHeight||(r=i.css("overflow"),i.css("overflow","hidden")),n=i.height(),this.element.siblings(":visible").each(function(){var t=e(this),r=t.css("position");if(r==="absolute"||r==="fixed")return;n-=t.outerHeight(!0)}),r&&i.css("overflow",r),this.element.children().not(this.panels).each(function(){n-=e(this).outerHeight(!0)}),this.panels.each(function(){e(this).height(Math.max(0,n-e(this).innerHeight()+e(this).height()))}).css("overflow","auto")):t==="auto"&&(n=0,this.panels.each(function(){n=Math.max(n,e(this).height("").height())}).height(n))},_eventHandler:function(t){var n=this.options,r=this.active,i=e(t.currentTarget),s=i.closest("li"),o=s[0]===r[0],u=o&&n.collapsible,a=u?e():this._getPanelForTab(s),f=r.length?this._getPanelForTab(r):e(),l={oldTab:r,oldPanel:f,newTab:u?e():s,newPanel:a};t.preventDefault();if(s.hasClass("ui-state-disabled")||s.hasClass("ui-tabs-loading")||this.running||o&&!n.collapsible||this._trigger("beforeActivate",t,l)===!1)return;n.active=u?!1:this.tabs.index(s),this.active=o?e():s,this.xhr&&this.xhr.abort(),!f.length&&!a.length&&e.error("jQuery UI Tabs: Mismatching fragment identifier."),a.length&&this.load(this.tabs.index(s),t),this._toggle(t,l)},_toggle:function(t,n){function o(){r.running=!1,r._trigger("activate",t,n)}function u(){n.newTab.closest("li").addClass("ui-tabs-active ui-state-active"),i.length&&r.options.show?r._show(i,r.options.show,o):(i.show(),o())}var r=this,i=n.newPanel,s=n.oldPanel;this.running=!0,s.length&&this.options.hide?this._hide(s,this.options.hide,function(){n.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),u()}):(n.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),s.hide(),u()),s.attr({"aria-expanded":"false","aria-hidden":"true"}),n.oldTab.attr("aria-selected","false"),i.length&&s.length?n.oldTab.attr("tabIndex",-1):i.length&&this.tabs.filter(function(){return e(this).attr("tabIndex")===0}).attr("tabIndex",-1),i.attr({"aria-expanded":"true","aria-hidden":"false"}),n.newTab.attr({"aria-selected":"true",tabIndex:0})},_activate:function(t){var n,r=this._findActive(t);if(r[0]===this.active[0])return;r.length||(r=this.active),n=r.find(".ui-tabs-anchor")[0],this._eventHandler({target:n,currentTarget:n,preventDefault:e.noop})},_findActive:function(t){return t===!1?e():this.tabs.eq(t)},_getIndex:function(e){return typeof e=="string"&&(e=this.anchors.index(this.anchors.filter("[href$='"+e+"']"))),e},_destroy:function(){this.xhr&&this.xhr.abort(),this.element.removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible"),this.tablist.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all").removeAttr("role"),this.anchors.removeClass("ui-tabs-anchor").removeAttr("role").removeAttr("tabIndex").removeData("href.tabs").removeData("load.tabs").removeUniqueId(),this.tabs.add(this.panels).each(function(){e.data(this,"ui-tabs-destroy")?e(this).remove():e(this).removeClass("ui-state-default ui-state-active ui-state-disabled ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel").removeAttr("tabIndex").removeAttr("aria-live").removeAttr("aria-busy").removeAttr("aria-selected").removeAttr("aria-labelledby").removeAttr("aria-hidden").removeAttr("aria-expanded").removeAttr("role")}),this.tabs.each(function(){var t=e(this),n=t.data("ui-tabs-aria-controls");n?t.attr("aria-controls",n):t.removeAttr("aria-controls")}),this.options.heightStyle!=="content"&&this.panels.css("height","")},enable:function(n){var r=this.options.disabled;if(r===!1)return;n===t?r=!1:(n=this._getIndex(n),e.isArray(r)?r=e.map(r,function(e){return e!==n?e:null}):r=e.map(this.tabs,function(e,t){return t!==n?t:null})),this._setupDisabled(r)},disable:function(n){var r=this.options.disabled;if(r===!0)return;if(n===t)r=!0;else{n=this._getIndex(n);if(e.inArray(n,r)!==-1)return;e.isArray(r)?r=e.merge([n],r).sort():r=[n]}this._setupDisabled(r)},load:function(t,n){t=this._getIndex(t);var r=this,i=this.tabs.eq(t),o=i.find(".ui-tabs-anchor"),u=this._getPanelForTab(i),a={tab:i,panel:u};if(s(o[0]))return;this.xhr=e.ajax(this._ajaxSettings(o,n,a)),this.xhr&&this.xhr.statusText!=="canceled"&&(i.addClass("ui-tabs-loading"),u.attr("aria-busy","true"),this.xhr.success(function(e){setTimeout(function(){u.html(e),r._trigger("load",n,a)},1)}).complete(function(e,t){setTimeout(function(){t==="abort"&&r.panels.stop(!1,!0),i.removeClass("ui-tabs-loading"),u.removeAttr("aria-busy"),e===r.xhr&&delete r.xhr},1)}))},_ajaxSettings:function(t,n,r){var i=this;return{url:t.attr("href"),beforeSend:function(t,s){return i._trigger("beforeLoad",n,e.extend({jqXHR:t,ajaxSettings:s},r))}}},_getPanelForTab:function(t){var n=e(t).attr("aria-controls");return this.element.find(this._sanitizeSelector("#"+n))}}),e.uiBackCompat!==!1&&(e.ui.tabs.prototype._ui=function(e,t){return{tab:e,panel:t,index:this.anchors.index(e)}},e.widget("ui.tabs",e.ui.tabs,{url:function(e,t){this.anchors.eq(e).attr("href",t)}}),e.widget("ui.tabs",e.ui.tabs,{options:{ajaxOptions:null,cache:!1},_create:function(){this._super();var t=this;this._on({tabsbeforeload:function(n,r){if(e.data(r.tab[0],"cache.tabs")){n.preventDefault();return}r.jqXHR.success(function(){t.options.cache&&e.data(r.tab[0],"cache.tabs",!0)})}})},_ajaxSettings:function(t,n,r){var i=this.options.ajaxOptions;return e.extend({},i,{error:function(e,t){try{i.error(e,t,r.tab.closest("li").index(),r.tab[0])}catch(n){}}},this._superApply(arguments))},_setOption:function(e,t){e==="cache"&&t===!1&&this.anchors.removeData("cache.tabs"),this._super(e,t)},_destroy:function(){this.anchors.removeData("cache.tabs"),this._super()},url:function(e){this.anchors.eq(e).removeData("cache.tabs"),this._superApply(arguments)}}),e.widget("ui.tabs",e.ui.tabs,{abort:function(){this.xhr&&this.xhr.abort()}}),e.widget("ui.tabs",e.ui.tabs,{options:{spinner:"<em>Loading&#8230;</em>"},_create:function(){this._super(),this._on({tabsbeforeload:function(e,t){if(e.target!==this.element[0]||!this.options.spinner)return;var n=t.tab.find("span"),r=n.html();n.html(this.options.spinner),t.jqXHR.complete(function(){n.html(r)})}})}}),e.widget("ui.tabs",e.ui.tabs,{options:{enable:null,disable:null},enable:function(t){var n=this.options,r;if(t&&n.disabled===!0||e.isArray(n.disabled)&&e.inArray(t,n.disabled)!==-1)r=!0;this._superApply(arguments),r&&this._trigger("enable",null,this._ui(this.anchors[t],this.panels[t]))},disable:function(t){var n=this.options,r;if(t&&n.disabled===!1||e.isArray(n.disabled)&&e.inArray(t,n.disabled)===-1)r=!0;this._superApply(arguments),r&&this._trigger("disable",null,this._ui(this.anchors[t],this.panels[t]))}}),e.widget("ui.tabs",e.ui.tabs,{options:{add:null,remove:null,tabTemplate:"<li><a href='#{href}'><span>#{label}</span></a></li>"},add:function(n,r,i){i===t&&(i=this.anchors.length);var s,o,u=this.options,a=e(u.tabTemplate.replace(/#\{href\}/g,n).replace(/#\{label\}/g,r)),f=n.indexOf("#")?this._tabId(a):n.replace("#","");return a.addClass("ui-state-default ui-corner-top").data("ui-tabs-destroy",!0),a.attr("aria-controls",f),s=i>=this.tabs.length,o=this.element.find("#"+f),o.length||(o=this._createPanel(f),s?i>0?o.insertAfter(this.panels.eq(-1)):o.appendTo(this.element):o.insertBefore(this.panels[i])),o.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").hide(),s?a.appendTo(this.tablist):a.insertBefore(this.tabs[i]),u.disabled=e.map(u.disabled,function(e){return e>=i?++e:e}),this.refresh(),this.tabs.length===1&&u.active===!1&&this.option("active",0),this._trigger("add",null,this._ui(this.anchors[i],this.panels[i])),this},remove:function(t){t=this._getIndex(t);var n=this.options,r=this.tabs.eq(t).remove(),i=this._getPanelForTab(r).remove();return r.hasClass("ui-tabs-active")&&this.anchors.length>2&&this._activate(t+(t+1<this.anchors.length?1:-1)),n.disabled=e.map(e.grep(n.disabled,function(e){return e!==t}),function(e){return e>=t?--e:e}),this.refresh(),this._trigger("remove",null,this._ui(r.find("a")[0],i[0])),this}}),e.widget("ui.tabs",e.ui.tabs,{length:function(){return this.anchors.length}}),e.widget("ui.tabs",e.ui.tabs,{options:{idPrefix:"ui-tabs-"},_tabId:function(t){var n=t.is("li")?t.find("a[href]"):t;return n=n[0],e(n).closest("li").attr("aria-controls")||n.title&&n.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF\-]/g,"")||this.options.idPrefix+i()}}),e.widget("ui.tabs",e.ui.tabs,{options:{panelTemplate:"<div></div>"},_createPanel:function(t){return e(this.options.panelTemplate).attr("id",t).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").data("ui-tabs-destroy",!0)}}),e.widget("ui.tabs",e.ui.tabs,{_create:function(){var e=this.options;e.active===null&&e.selected!==t&&(e.active=e.selected===-1?!1:e.selected),this._super(),e.selected=e.active,e.selected===!1&&(e.selected=-1)},_setOption:function(e,t){if(e!=="selected")return this._super(e,t);var n=this.options;this._super("active",t===-1?!1:t),n.selected=n.active,n.selected===!1&&(n.selected=-1)},_eventHandler:function(){this._superApply(arguments),this.options.selected=this.options.active,this.options.selected===!1&&(this.options.selected=-1)}}),e.widget("ui.tabs",e.ui.tabs,{options:{show:null,select:null},_create:function(){this._super(),this.options.active!==!1&&this._trigger("show",null,this._ui(this.active.find(".ui-tabs-anchor")[0],this._getPanelForTab(this.active)[0]))},_trigger:function(e,t,n){var r=this._superApply(arguments);return r?(e==="beforeActivate"&&n.newTab.length?r=this._super("select",t,{tab:n.newTab.find(".ui-tabs-anchor")[0],panel:n.newPanel[0],index:n.newTab.closest("li").index()}):e==="activate"&&n.newTab.length&&(r=this._super("show",t,{tab:n.newTab.find(".ui-tabs-anchor")[0],panel:n.newPanel[0],index:n.newTab.closest("li").index()})),r):!1}}),e.widget("ui.tabs",e.ui.tabs,{select:function(e){e=this._getIndex(e);if(e===-1){if(!this.options.collapsible||this.options.selected===-1)return;e=this.options.selected}this.anchors.eq(e).trigger(this.options.event+this.eventNamespace)}}),function(){var t=0;e.widget("ui.tabs",e.ui.tabs,{options:{cookie:null},_create:function(){var e=this.options,t;e.active==null&&e.cookie&&(t=parseInt(this._cookie(),10),t===-1&&(t=!1),e.active=t),this._super()},_cookie:function(n){var r=[this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+ ++t)];return arguments.length&&(r.push(n===!1?-1:n),r.push(this.options.cookie)),e.cookie.apply(null,r)},_refresh:function(){this._super(),this.options.cookie&&this._cookie(this.options.active,this.options.cookie)},_eventHandler:function(){this._superApply(arguments),this.options.cookie&&this._cookie(this.options.active,this.options.cookie)},_destroy:function(){this._super(),this.options.cookie&&this._cookie(null,this.options.cookie)}})}(),e.widget("ui.tabs",e.ui.tabs,{_trigger:function(t,n,r){var i=e.extend({},r);return t==="load"&&(i.panel=i.panel[0],i.tab=i.tab.find(".ui-tabs-anchor")[0]),this._super(t,n,i)}}),e.widget("ui.tabs",e.ui.tabs,{options:{fx:null},_getFx:function(){var t,n,r=this.options.fx;return r&&(e.isArray(r)?(t=r[0],n=r[1]):t=n=r),r?{show:n,hide:t}:null},_toggle:function(e,t){function o(){n.running=!1,n._trigger("activate",e,t)}function u(){t.newTab.closest("li").addClass("ui-tabs-active ui-state-active"),r.length&&s.show?r.animate(s.show,s.show.duration,function(){o()}):(r.show(),o())}var n=this,r=t.newPanel,i=t.oldPanel,s=this._getFx();if(!s)return this._super(e,t);n.running=!0,i.length&&s.hide?i.animate(s.hide,s.hide.duration,function(){t.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),u()}):(t.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),i.hide(),u())}}))})(jQuery);(function(e){function n(t,n){var r=(t.attr("aria-describedby")||"").split(/\s+/);r.push(n),t.data("ui-tooltip-id",n).attr("aria-describedby",e.trim(r.join(" ")))}function r(t){var n=t.data("ui-tooltip-id"),r=(t.attr("aria-describedby")||"").split(/\s+/),i=e.inArray(n,r);i!==-1&&r.splice(i,1),t.removeData("ui-tooltip-id"),r=e.trim(r.join(" ")),r?t.attr("aria-describedby",r):t.removeAttr("aria-describedby")}var t=0;e.widget("ui.tooltip",{version:"1.9.1",options:{content:function(){return e(this).attr("title")},hide:!0,items:"[title]:not([disabled])",position:{my:"left top+15",at:"left bottom",collision:"flipfit flipfit"},show:!0,tooltipClass:null,track:!1,close:null,open:null},_create:function(){this._on({mouseover:"open",focusin:"open"}),this.tooltips={},this.parents={},this.options.disabled&&this._disable()},_setOption:function(t,n){var r=this;if(t==="disabled"){this[n?"_disable":"_enable"](),this.options[t]=n;return}this._super(t,n),t==="content"&&e.each(this.tooltips,function(e,t){r._updateContent(t)})},_disable:function(){var t=this;e.each(this.tooltips,function(n,r){var i=e.Event("blur");i.target=i.currentTarget=r[0],t.close(i,!0)}),this.element.find(this.options.items).andSelf().each(function(){var t=e(this);t.is("[title]")&&t.data("ui-tooltip-title",t.attr("title")).attr("title","")})},_enable:function(){this.element.find(this.options.items).andSelf().each(function(){var t=e(this);t.data("ui-tooltip-title")&&t.attr("title",t.data("ui-tooltip-title"))})},open:function(t){var n=this,r=e(t?t.target:this.element).closest(this.options.items);if(!r.length)return;if(this.options.track&&r.data("ui-tooltip-id")){this._find(r).position(e.extend({of:r},this.options.position)),this._off(this.document,"mousemove");return}r.attr("title")&&r.data("ui-tooltip-title",r.attr("title")),r.data("tooltip-open",!0),t&&t.type==="mouseover"&&r.parents().each(function(){var t;e(this).data("tooltip-open")&&(t=e.Event("blur"),t.target=t.currentTarget=this,n.close(t,!0)),this.title&&(e(this).uniqueId(),n.parents[this.id]={element:this,title:this.title},this.title="")}),this._updateContent(r,t)},_updateContent:function(e,t){var n,r=this.options.content,i=this;if(typeof r=="string")return this._open(t,e,r);n=r.call(e[0],function(n){if(!e.data("tooltip-open"))return;i._delay(function(){this._open(t,e,n)})}),n&&this._open(t,e,n)},_open:function(t,r,i){function f(e){a.of=e;if(s.is(":hidden"))return;s.position(a)}var s,o,u,a=e.extend({},this.options.position);if(!i)return;s=this._find(r);if(s.length){s.find(".ui-tooltip-content").html(i);return}r.is("[title]")&&(t&&t.type==="mouseover"?r.attr("title",""):r.removeAttr("title")),s=this._tooltip(r),n(r,s.attr("id")),s.find(".ui-tooltip-content").html(i),this.options.track&&t&&/^mouse/.test(t.originalEvent.type)?(this._on(this.document,{mousemove:f}),f(t)):s.position(e.extend({of:r},this.options.position)),s.hide(),this._show(s,this.options.show),this.options.show&&this.options.show.delay&&(u=setInterval(function(){s.is(":visible")&&(f(a.of),clearInterval(u))},e.fx.interval)),this._trigger("open",t,{tooltip:s}),o={keyup:function(t){if(t.keyCode===e.ui.keyCode.ESCAPE){var n=e.Event(t);n.currentTarget=r[0],this.close(n,!0)}},remove:function(){this._removeTooltip(s)}};if(!t||t.type==="mouseover")o.mouseleave="close";if(!t||t.type==="focusin")o.focusout="close";this._on(r,o)},close:function(t){var n=this,i=e(t?t.currentTarget:this.element),s=this._find(i);if(this.closing)return;i.data("ui-tooltip-title")&&i.attr("title",i.data("ui-tooltip-title")),r(i),s.stop(!0),this._hide(s,this.options.hide,function(){n._removeTooltip(e(this))}),i.removeData("tooltip-open"),this._off(i,"mouseleave focusout keyup"),i[0]!==this.element[0]&&this._off(i,"remove"),this._off(this.document,"mousemove"),t&&t.type==="mouseleave"&&e.each(this.parents,function(e,t){t.element.title=t.title,delete n.parents[e]}),this.closing=!0,this._trigger("close",t,{tooltip:s}),this.closing=!1},_tooltip:function(n){var r="ui-tooltip-"+t++,i=e("<div>").attr({id:r,role:"tooltip"}).addClass("ui-tooltip ui-widget ui-corner-all ui-widget-content "+(this.options.tooltipClass||""));return e("<div>").addClass("ui-tooltip-content").appendTo(i),i.appendTo(this.document[0].body),e.fn.bgiframe&&i.bgiframe(),this.tooltips[r]=n,i},_find:function(t){var n=t.data("ui-tooltip-id");return n?e("#"+n):e()},_removeTooltip:function(e){e.remove(),delete this.tooltips[e.attr("id")]},_destroy:function(){var t=this;e.each(this.tooltips,function(n,r){var i=e.Event("blur");i.target=i.currentTarget=r[0],t.close(i,!0),e("#"+n).remove(),r.data("ui-tooltip-title")&&(r.attr("title",r.data("ui-tooltip-title")),r.removeData("ui-tooltip-title"))})}})})(jQuery); \ No newline at end of file
+(function(e,t){function i(t,i){var a,n,r,o=t.nodeName.toLowerCase();return"area"===o?(a=t.parentNode,n=a.name,t.href&&n&&"map"===a.nodeName.toLowerCase()?(r=e("img[usemap=#"+n+"]")[0],!!r&&s(r)):!1):(/input|select|textarea|button|object/.test(o)?!t.disabled:"a"===o?t.href||i:i)&&s(t)}function s(t){return e.expr.filters.visible(t)&&!e(t).parents().addBack().filter(function(){return"hidden"===e.css(this,"visibility")}).length}var a=0,n=/^ui-id-\d+$/;e.ui=e.ui||{},e.extend(e.ui,{version:"1.10.3",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}}),e.fn.extend({focus:function(t){return function(i,s){return"number"==typeof i?this.each(function(){var t=this;setTimeout(function(){e(t).focus(),s&&s.call(t)},i)}):t.apply(this,arguments)}}(e.fn.focus),scrollParent:function(){var t;return t=e.ui.ie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(e.css(this,"position"))&&/(auto|scroll)/.test(e.css(this,"overflow")+e.css(this,"overflow-y")+e.css(this,"overflow-x"))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(e.css(this,"overflow")+e.css(this,"overflow-y")+e.css(this,"overflow-x"))}).eq(0),/fixed/.test(this.css("position"))||!t.length?e(document):t},zIndex:function(i){if(i!==t)return this.css("zIndex",i);if(this.length)for(var s,a,n=e(this[0]);n.length&&n[0]!==document;){if(s=n.css("position"),("absolute"===s||"relative"===s||"fixed"===s)&&(a=parseInt(n.css("zIndex"),10),!isNaN(a)&&0!==a))return a;n=n.parent()}return 0},uniqueId:function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++a)})},removeUniqueId:function(){return this.each(function(){n.test(this.id)&&e(this).removeAttr("id")})}}),e.extend(e.expr[":"],{data:e.expr.createPseudo?e.expr.createPseudo(function(t){return function(i){return!!e.data(i,t)}}):function(t,i,s){return!!e.data(t,s[3])},focusable:function(t){return i(t,!isNaN(e.attr(t,"tabindex")))},tabbable:function(t){var s=e.attr(t,"tabindex"),a=isNaN(s);return(a||s>=0)&&i(t,!a)}}),e("<a>").outerWidth(1).jquery||e.each(["Width","Height"],function(i,s){function a(t,i,s,a){return e.each(n,function(){i-=parseFloat(e.css(t,"padding"+this))||0,s&&(i-=parseFloat(e.css(t,"border"+this+"Width"))||0),a&&(i-=parseFloat(e.css(t,"margin"+this))||0)}),i}var n="Width"===s?["Left","Right"]:["Top","Bottom"],r=s.toLowerCase(),o={innerWidth:e.fn.innerWidth,innerHeight:e.fn.innerHeight,outerWidth:e.fn.outerWidth,outerHeight:e.fn.outerHeight};e.fn["inner"+s]=function(i){return i===t?o["inner"+s].call(this):this.each(function(){e(this).css(r,a(this,i)+"px")})},e.fn["outer"+s]=function(t,i){return"number"!=typeof t?o["outer"+s].call(this,t):this.each(function(){e(this).css(r,a(this,t,!0,i)+"px")})}}),e.fn.addBack||(e.fn.addBack=function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}),e("<a>").data("a-b","a").removeData("a-b").data("a-b")&&(e.fn.removeData=function(t){return function(i){return arguments.length?t.call(this,e.camelCase(i)):t.call(this)}}(e.fn.removeData)),e.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()),e.support.selectstart="onselectstart"in document.createElement("div"),e.fn.extend({disableSelection:function(){return this.bind((e.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(e){e.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),e.extend(e.ui,{plugin:{add:function(t,i,s){var a,n=e.ui[t].prototype;for(a in s)n.plugins[a]=n.plugins[a]||[],n.plugins[a].push([i,s[a]])},call:function(e,t,i){var s,a=e.plugins[t];if(a&&e.element[0].parentNode&&11!==e.element[0].parentNode.nodeType)for(s=0;a.length>s;s++)e.options[a[s][0]]&&a[s][1].apply(e.element,i)}},hasScroll:function(t,i){if("hidden"===e(t).css("overflow"))return!1;var s=i&&"left"===i?"scrollLeft":"scrollTop",a=!1;return t[s]>0?!0:(t[s]=1,a=t[s]>0,t[s]=0,a)}})})(jQuery);(function(e,t){var i=0,s=Array.prototype.slice,n=e.cleanData;e.cleanData=function(t){for(var i,s=0;null!=(i=t[s]);s++)try{e(i).triggerHandler("remove")}catch(a){}n(t)},e.widget=function(i,s,n){var a,r,o,h,l={},u=i.split(".")[0];i=i.split(".")[1],a=u+"-"+i,n||(n=s,s=e.Widget),e.expr[":"][a.toLowerCase()]=function(t){return!!e.data(t,a)},e[u]=e[u]||{},r=e[u][i],o=e[u][i]=function(e,i){return this._createWidget?(arguments.length&&this._createWidget(e,i),t):new o(e,i)},e.extend(o,r,{version:n.version,_proto:e.extend({},n),_childConstructors:[]}),h=new s,h.options=e.widget.extend({},h.options),e.each(n,function(i,n){return e.isFunction(n)?(l[i]=function(){var e=function(){return s.prototype[i].apply(this,arguments)},t=function(e){return s.prototype[i].apply(this,e)};return function(){var i,s=this._super,a=this._superApply;return this._super=e,this._superApply=t,i=n.apply(this,arguments),this._super=s,this._superApply=a,i}}(),t):(l[i]=n,t)}),o.prototype=e.widget.extend(h,{widgetEventPrefix:r?h.widgetEventPrefix:i},l,{constructor:o,namespace:u,widgetName:i,widgetFullName:a}),r?(e.each(r._childConstructors,function(t,i){var s=i.prototype;e.widget(s.namespace+"."+s.widgetName,o,i._proto)}),delete r._childConstructors):s._childConstructors.push(o),e.widget.bridge(i,o)},e.widget.extend=function(i){for(var n,a,r=s.call(arguments,1),o=0,h=r.length;h>o;o++)for(n in r[o])a=r[o][n],r[o].hasOwnProperty(n)&&a!==t&&(i[n]=e.isPlainObject(a)?e.isPlainObject(i[n])?e.widget.extend({},i[n],a):e.widget.extend({},a):a);return i},e.widget.bridge=function(i,n){var a=n.prototype.widgetFullName||i;e.fn[i]=function(r){var o="string"==typeof r,h=s.call(arguments,1),l=this;return r=!o&&h.length?e.widget.extend.apply(null,[r].concat(h)):r,o?this.each(function(){var s,n=e.data(this,a);return n?e.isFunction(n[r])&&"_"!==r.charAt(0)?(s=n[r].apply(n,h),s!==n&&s!==t?(l=s&&s.jquery?l.pushStack(s.get()):s,!1):t):e.error("no such method '"+r+"' for "+i+" widget instance"):e.error("cannot call methods on "+i+" prior to initialization; "+"attempted to call method '"+r+"'")}):this.each(function(){var t=e.data(this,a);t?t.option(r||{})._init():e.data(this,a,new n(r,this))}),l}},e.Widget=function(){},e.Widget._childConstructors=[],e.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{disabled:!1,create:null},_createWidget:function(t,s){s=e(s||this.defaultElement||this)[0],this.element=e(s),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=e.widget.extend({},this.options,this._getCreateOptions(),t),this.bindings=e(),this.hoverable=e(),this.focusable=e(),s!==this&&(e.data(s,this.widgetFullName,this),this._on(!0,this.element,{remove:function(e){e.target===s&&this.destroy()}}),this.document=e(s.style?s.ownerDocument:s.document||s),this.window=e(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:e.noop,_getCreateEventData:e.noop,_create:e.noop,_init:e.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(e.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled "+"ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:e.noop,widget:function(){return this.element},option:function(i,s){var n,a,r,o=i;if(0===arguments.length)return e.widget.extend({},this.options);if("string"==typeof i)if(o={},n=i.split("."),i=n.shift(),n.length){for(a=o[i]=e.widget.extend({},this.options[i]),r=0;n.length-1>r;r++)a[n[r]]=a[n[r]]||{},a=a[n[r]];if(i=n.pop(),s===t)return a[i]===t?null:a[i];a[i]=s}else{if(s===t)return this.options[i]===t?null:this.options[i];o[i]=s}return this._setOptions(o),this},_setOptions:function(e){var t;for(t in e)this._setOption(t,e[t]);return this},_setOption:function(e,t){return this.options[e]=t,"disabled"===e&&(this.widget().toggleClass(this.widgetFullName+"-disabled ui-state-disabled",!!t).attr("aria-disabled",t),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")),this},enable:function(){return this._setOption("disabled",!1)},disable:function(){return this._setOption("disabled",!0)},_on:function(i,s,n){var a,r=this;"boolean"!=typeof i&&(n=s,s=i,i=!1),n?(s=a=e(s),this.bindings=this.bindings.add(s)):(n=s,s=this.element,a=this.widget()),e.each(n,function(n,o){function h(){return i||r.options.disabled!==!0&&!e(this).hasClass("ui-state-disabled")?("string"==typeof o?r[o]:o).apply(r,arguments):t}"string"!=typeof o&&(h.guid=o.guid=o.guid||h.guid||e.guid++);var l=n.match(/^(\w+)\s*(.*)$/),u=l[1]+r.eventNamespace,c=l[2];c?a.delegate(c,u,h):s.bind(u,h)})},_off:function(e,t){t=(t||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.unbind(t).undelegate(t)},_delay:function(e,t){function i(){return("string"==typeof e?s[e]:e).apply(s,arguments)}var s=this;return setTimeout(i,t||0)},_hoverable:function(t){this.hoverable=this.hoverable.add(t),this._on(t,{mouseenter:function(t){e(t.currentTarget).addClass("ui-state-hover")},mouseleave:function(t){e(t.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(t){this.focusable=this.focusable.add(t),this._on(t,{focusin:function(t){e(t.currentTarget).addClass("ui-state-focus")},focusout:function(t){e(t.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(t,i,s){var n,a,r=this.options[t];if(s=s||{},i=e.Event(i),i.type=(t===this.widgetEventPrefix?t:this.widgetEventPrefix+t).toLowerCase(),i.target=this.element[0],a=i.originalEvent)for(n in a)n in i||(i[n]=a[n]);return this.element.trigger(i,s),!(e.isFunction(r)&&r.apply(this.element[0],[i].concat(s))===!1||i.isDefaultPrevented())}},e.each({show:"fadeIn",hide:"fadeOut"},function(t,i){e.Widget.prototype["_"+t]=function(s,n,a){"string"==typeof n&&(n={effect:n});var r,o=n?n===!0||"number"==typeof n?i:n.effect||i:t;n=n||{},"number"==typeof n&&(n={duration:n}),r=!e.isEmptyObject(n),n.complete=a,n.delay&&s.delay(n.delay),r&&e.effects&&e.effects.effect[o]?s[t](n):o!==t&&s[o]?s[o](n.duration,n.easing,a):s.queue(function(i){e(this)[t](),a&&a.call(s[0]),i()})}})})(jQuery);(function(e){var t=!1;e(document).mouseup(function(){t=!1}),e.widget("ui.mouse",{version:"1.10.3",options:{cancel:"input,textarea,button,select,option",distance:1,delay:0},_mouseInit:function(){var t=this;this.element.bind("mousedown."+this.widgetName,function(e){return t._mouseDown(e)}).bind("click."+this.widgetName,function(i){return!0===e.data(i.target,t.widgetName+".preventClickEvent")?(e.removeData(i.target,t.widgetName+".preventClickEvent"),i.stopImmediatePropagation(),!1):undefined}),this.started=!1},_mouseDestroy:function(){this.element.unbind("."+this.widgetName),this._mouseMoveDelegate&&e(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(i){if(!t){this._mouseStarted&&this._mouseUp(i),this._mouseDownEvent=i;var s=this,n=1===i.which,a="string"==typeof this.options.cancel&&i.target.nodeName?e(i.target).closest(this.options.cancel).length:!1;return n&&!a&&this._mouseCapture(i)?(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){s.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(i)&&this._mouseDelayMet(i)&&(this._mouseStarted=this._mouseStart(i)!==!1,!this._mouseStarted)?(i.preventDefault(),!0):(!0===e.data(i.target,this.widgetName+".preventClickEvent")&&e.removeData(i.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(e){return s._mouseMove(e)},this._mouseUpDelegate=function(e){return s._mouseUp(e)},e(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate),i.preventDefault(),t=!0,!0)):!0}},_mouseMove:function(t){return e.ui.ie&&(!document.documentMode||9>document.documentMode)&&!t.button?this._mouseUp(t):this._mouseStarted?(this._mouseDrag(t),t.preventDefault()):(this._mouseDistanceMet(t)&&this._mouseDelayMet(t)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,t)!==!1,this._mouseStarted?this._mouseDrag(t):this._mouseUp(t)),!this._mouseStarted)},_mouseUp:function(t){return e(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,t.target===this._mouseDownEvent.target&&e.data(t.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(t)),!1},_mouseDistanceMet:function(e){return Math.max(Math.abs(this._mouseDownEvent.pageX-e.pageX),Math.abs(this._mouseDownEvent.pageY-e.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}})})(jQuery);(function(t,e){function i(t,e,i){return[parseFloat(t[0])*(p.test(t[0])?e/100:1),parseFloat(t[1])*(p.test(t[1])?i/100:1)]}function s(e,i){return parseInt(t.css(e,i),10)||0}function n(e){var i=e[0];return 9===i.nodeType?{width:e.width(),height:e.height(),offset:{top:0,left:0}}:t.isWindow(i)?{width:e.width(),height:e.height(),offset:{top:e.scrollTop(),left:e.scrollLeft()}}:i.preventDefault?{width:0,height:0,offset:{top:i.pageY,left:i.pageX}}:{width:e.outerWidth(),height:e.outerHeight(),offset:e.offset()}}t.ui=t.ui||{};var a,o=Math.max,r=Math.abs,h=Math.round,l=/left|center|right/,c=/top|center|bottom/,u=/[\+\-]\d+(\.[\d]+)?%?/,d=/^\w+/,p=/%$/,f=t.fn.position;t.position={scrollbarWidth:function(){if(a!==e)return a;var i,s,n=t("<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>"),o=n.children()[0];return t("body").append(n),i=o.offsetWidth,n.css("overflow","scroll"),s=o.offsetWidth,i===s&&(s=n[0].clientWidth),n.remove(),a=i-s},getScrollInfo:function(e){var i=e.isWindow?"":e.element.css("overflow-x"),s=e.isWindow?"":e.element.css("overflow-y"),n="scroll"===i||"auto"===i&&e.width<e.element[0].scrollWidth,a="scroll"===s||"auto"===s&&e.height<e.element[0].scrollHeight;return{width:a?t.position.scrollbarWidth():0,height:n?t.position.scrollbarWidth():0}},getWithinInfo:function(e){var i=t(e||window),s=t.isWindow(i[0]);return{element:i,isWindow:s,offset:i.offset()||{left:0,top:0},scrollLeft:i.scrollLeft(),scrollTop:i.scrollTop(),width:s?i.width():i.outerWidth(),height:s?i.height():i.outerHeight()}}},t.fn.position=function(e){if(!e||!e.of)return f.apply(this,arguments);e=t.extend({},e);var a,p,m,g,v,b,_=t(e.of),y=t.position.getWithinInfo(e.within),w=t.position.getScrollInfo(y),x=(e.collision||"flip").split(" "),k={};return b=n(_),_[0].preventDefault&&(e.at="left top"),p=b.width,m=b.height,g=b.offset,v=t.extend({},g),t.each(["my","at"],function(){var t,i,s=(e[this]||"").split(" ");1===s.length&&(s=l.test(s[0])?s.concat(["center"]):c.test(s[0])?["center"].concat(s):["center","center"]),s[0]=l.test(s[0])?s[0]:"center",s[1]=c.test(s[1])?s[1]:"center",t=u.exec(s[0]),i=u.exec(s[1]),k[this]=[t?t[0]:0,i?i[0]:0],e[this]=[d.exec(s[0])[0],d.exec(s[1])[0]]}),1===x.length&&(x[1]=x[0]),"right"===e.at[0]?v.left+=p:"center"===e.at[0]&&(v.left+=p/2),"bottom"===e.at[1]?v.top+=m:"center"===e.at[1]&&(v.top+=m/2),a=i(k.at,p,m),v.left+=a[0],v.top+=a[1],this.each(function(){var n,l,c=t(this),u=c.outerWidth(),d=c.outerHeight(),f=s(this,"marginLeft"),b=s(this,"marginTop"),D=u+f+s(this,"marginRight")+w.width,T=d+b+s(this,"marginBottom")+w.height,C=t.extend({},v),M=i(k.my,c.outerWidth(),c.outerHeight());"right"===e.my[0]?C.left-=u:"center"===e.my[0]&&(C.left-=u/2),"bottom"===e.my[1]?C.top-=d:"center"===e.my[1]&&(C.top-=d/2),C.left+=M[0],C.top+=M[1],t.support.offsetFractions||(C.left=h(C.left),C.top=h(C.top)),n={marginLeft:f,marginTop:b},t.each(["left","top"],function(i,s){t.ui.position[x[i]]&&t.ui.position[x[i]][s](C,{targetWidth:p,targetHeight:m,elemWidth:u,elemHeight:d,collisionPosition:n,collisionWidth:D,collisionHeight:T,offset:[a[0]+M[0],a[1]+M[1]],my:e.my,at:e.at,within:y,elem:c})}),e.using&&(l=function(t){var i=g.left-C.left,s=i+p-u,n=g.top-C.top,a=n+m-d,h={target:{element:_,left:g.left,top:g.top,width:p,height:m},element:{element:c,left:C.left,top:C.top,width:u,height:d},horizontal:0>s?"left":i>0?"right":"center",vertical:0>a?"top":n>0?"bottom":"middle"};u>p&&p>r(i+s)&&(h.horizontal="center"),d>m&&m>r(n+a)&&(h.vertical="middle"),h.important=o(r(i),r(s))>o(r(n),r(a))?"horizontal":"vertical",e.using.call(this,t,h)}),c.offset(t.extend(C,{using:l}))})},t.ui.position={fit:{left:function(t,e){var i,s=e.within,n=s.isWindow?s.scrollLeft:s.offset.left,a=s.width,r=t.left-e.collisionPosition.marginLeft,h=n-r,l=r+e.collisionWidth-a-n;e.collisionWidth>a?h>0&&0>=l?(i=t.left+h+e.collisionWidth-a-n,t.left+=h-i):t.left=l>0&&0>=h?n:h>l?n+a-e.collisionWidth:n:h>0?t.left+=h:l>0?t.left-=l:t.left=o(t.left-r,t.left)},top:function(t,e){var i,s=e.within,n=s.isWindow?s.scrollTop:s.offset.top,a=e.within.height,r=t.top-e.collisionPosition.marginTop,h=n-r,l=r+e.collisionHeight-a-n;e.collisionHeight>a?h>0&&0>=l?(i=t.top+h+e.collisionHeight-a-n,t.top+=h-i):t.top=l>0&&0>=h?n:h>l?n+a-e.collisionHeight:n:h>0?t.top+=h:l>0?t.top-=l:t.top=o(t.top-r,t.top)}},flip:{left:function(t,e){var i,s,n=e.within,a=n.offset.left+n.scrollLeft,o=n.width,h=n.isWindow?n.scrollLeft:n.offset.left,l=t.left-e.collisionPosition.marginLeft,c=l-h,u=l+e.collisionWidth-o-h,d="left"===e.my[0]?-e.elemWidth:"right"===e.my[0]?e.elemWidth:0,p="left"===e.at[0]?e.targetWidth:"right"===e.at[0]?-e.targetWidth:0,f=-2*e.offset[0];0>c?(i=t.left+d+p+f+e.collisionWidth-o-a,(0>i||r(c)>i)&&(t.left+=d+p+f)):u>0&&(s=t.left-e.collisionPosition.marginLeft+d+p+f-h,(s>0||u>r(s))&&(t.left+=d+p+f))},top:function(t,e){var i,s,n=e.within,a=n.offset.top+n.scrollTop,o=n.height,h=n.isWindow?n.scrollTop:n.offset.top,l=t.top-e.collisionPosition.marginTop,c=l-h,u=l+e.collisionHeight-o-h,d="top"===e.my[1],p=d?-e.elemHeight:"bottom"===e.my[1]?e.elemHeight:0,f="top"===e.at[1]?e.targetHeight:"bottom"===e.at[1]?-e.targetHeight:0,m=-2*e.offset[1];0>c?(s=t.top+p+f+m+e.collisionHeight-o-a,t.top+p+f+m>c&&(0>s||r(c)>s)&&(t.top+=p+f+m)):u>0&&(i=t.top-e.collisionPosition.marginTop+p+f+m-h,t.top+p+f+m>u&&(i>0||u>r(i))&&(t.top+=p+f+m))}},flipfit:{left:function(){t.ui.position.flip.left.apply(this,arguments),t.ui.position.fit.left.apply(this,arguments)},top:function(){t.ui.position.flip.top.apply(this,arguments),t.ui.position.fit.top.apply(this,arguments)}}},function(){var e,i,s,n,a,o=document.getElementsByTagName("body")[0],r=document.createElement("div");e=document.createElement(o?"div":"body"),s={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},o&&t.extend(s,{position:"absolute",left:"-1000px",top:"-1000px"});for(a in s)e.style[a]=s[a];e.appendChild(r),i=o||document.documentElement,i.insertBefore(e,i.firstChild),r.style.cssText="position: absolute; left: 10.7432222px;",n=t(r).offset().left,t.support.offsetFractions=n>10&&11>n,e.innerHTML="",i.removeChild(e)}()})(jQuery);(function(e){e.widget("ui.draggable",e.ui.mouse,{version:"1.10.3",widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1,drag:null,start:null,stop:null},_create:function(){"original"!==this.options.helper||/^(?:r|a|f)/.test(this.element.css("position"))||(this.element[0].style.position="relative"),this.options.addClasses&&this.element.addClass("ui-draggable"),this.options.disabled&&this.element.addClass("ui-draggable-disabled"),this._mouseInit()},_destroy:function(){this.element.removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled"),this._mouseDestroy()},_mouseCapture:function(t){var i=this.options;return this.helper||i.disabled||e(t.target).closest(".ui-resizable-handle").length>0?!1:(this.handle=this._getHandle(t),this.handle?(e(i.iframeFix===!0?"iframe":i.iframeFix).each(function(){e("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>").css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1e3}).css(e(this).offset()).appendTo("body")}),!0):!1)},_mouseStart:function(t){var i=this.options;return this.helper=this._createHelper(t),this.helper.addClass("ui-draggable-dragging"),this._cacheHelperProportions(),e.ui.ddmanager&&(e.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(),this.offsetParent=this.helper.offsetParent(),this.offsetParentCssPosition=this.offsetParent.css("position"),this.offset=this.positionAbs=this.element.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},this.offset.scroll=!1,e.extend(this.offset,{click:{left:t.pageX-this.offset.left,top:t.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.originalPosition=this.position=this._generatePosition(t),this.originalPageX=t.pageX,this.originalPageY=t.pageY,i.cursorAt&&this._adjustOffsetFromHelper(i.cursorAt),this._setContainment(),this._trigger("start",t)===!1?(this._clear(),!1):(this._cacheHelperProportions(),e.ui.ddmanager&&!i.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t),this._mouseDrag(t,!0),e.ui.ddmanager&&e.ui.ddmanager.dragStart(this,t),!0)},_mouseDrag:function(t,i){if("fixed"===this.offsetParentCssPosition&&(this.offset.parent=this._getParentOffset()),this.position=this._generatePosition(t),this.positionAbs=this._convertPositionTo("absolute"),!i){var s=this._uiHash();if(this._trigger("drag",t,s)===!1)return this._mouseUp({}),!1;this.position=s.position}return this.options.axis&&"y"===this.options.axis||(this.helper[0].style.left=this.position.left+"px"),this.options.axis&&"x"===this.options.axis||(this.helper[0].style.top=this.position.top+"px"),e.ui.ddmanager&&e.ui.ddmanager.drag(this,t),!1},_mouseStop:function(t){var i=this,s=!1;return e.ui.ddmanager&&!this.options.dropBehaviour&&(s=e.ui.ddmanager.drop(this,t)),this.dropped&&(s=this.dropped,this.dropped=!1),"original"!==this.options.helper||e.contains(this.element[0].ownerDocument,this.element[0])?("invalid"===this.options.revert&&!s||"valid"===this.options.revert&&s||this.options.revert===!0||e.isFunction(this.options.revert)&&this.options.revert.call(this.element,s)?e(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){i._trigger("stop",t)!==!1&&i._clear()}):this._trigger("stop",t)!==!1&&this._clear(),!1):!1},_mouseUp:function(t){return e("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)}),e.ui.ddmanager&&e.ui.ddmanager.dragStop(this,t),e.ui.mouse.prototype._mouseUp.call(this,t)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear(),this},_getHandle:function(t){return this.options.handle?!!e(t.target).closest(this.element.find(this.options.handle)).length:!0},_createHelper:function(t){var i=this.options,s=e.isFunction(i.helper)?e(i.helper.apply(this.element[0],[t])):"clone"===i.helper?this.element.clone().removeAttr("id"):this.element;return s.parents("body").length||s.appendTo("parent"===i.appendTo?this.element[0].parentNode:i.appendTo),s[0]===this.element[0]||/(fixed|absolute)/.test(s.css("position"))||s.css("position","absolute"),s},_adjustOffsetFromHelper:function(t){"string"==typeof t&&(t=t.split(" ")),e.isArray(t)&&(t={left:+t[0],top:+t[1]||0}),"left"in t&&(this.offset.click.left=t.left+this.margins.left),"right"in t&&(this.offset.click.left=this.helperProportions.width-t.right+this.margins.left),"top"in t&&(this.offset.click.top=t.top+this.margins.top),"bottom"in t&&(this.offset.click.top=this.helperProportions.height-t.bottom+this.margins.top)},_getParentOffset:function(){var t=this.offsetParent.offset();return"absolute"===this.cssPosition&&this.scrollParent[0]!==document&&e.contains(this.scrollParent[0],this.offsetParent[0])&&(t.left+=this.scrollParent.scrollLeft(),t.top+=this.scrollParent.scrollTop()),(this.offsetParent[0]===document.body||this.offsetParent[0].tagName&&"html"===this.offsetParent[0].tagName.toLowerCase()&&e.ui.ie)&&(t={top:0,left:0}),{top:t.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:t.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"===this.cssPosition){var e=this.element.position();return{top:e.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:e.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var t,i,s,n=this.options;return n.containment?"window"===n.containment?(this.containment=[e(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,e(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,e(window).scrollLeft()+e(window).width()-this.helperProportions.width-this.margins.left,e(window).scrollTop()+(e(window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top],undefined):"document"===n.containment?(this.containment=[0,0,e(document).width()-this.helperProportions.width-this.margins.left,(e(document).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top],undefined):n.containment.constructor===Array?(this.containment=n.containment,undefined):("parent"===n.containment&&(n.containment=this.helper[0].parentNode),i=e(n.containment),s=i[0],s&&(t="hidden"!==i.css("overflow"),this.containment=[(parseInt(i.css("borderLeftWidth"),10)||0)+(parseInt(i.css("paddingLeft"),10)||0),(parseInt(i.css("borderTopWidth"),10)||0)+(parseInt(i.css("paddingTop"),10)||0),(t?Math.max(s.scrollWidth,s.offsetWidth):s.offsetWidth)-(parseInt(i.css("borderRightWidth"),10)||0)-(parseInt(i.css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(t?Math.max(s.scrollHeight,s.offsetHeight):s.offsetHeight)-(parseInt(i.css("borderBottomWidth"),10)||0)-(parseInt(i.css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relative_container=i),undefined):(this.containment=null,undefined)},_convertPositionTo:function(t,i){i||(i=this.position);var s="absolute"===t?1:-1,n="absolute"!==this.cssPosition||this.scrollParent[0]!==document&&e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent;return this.offset.scroll||(this.offset.scroll={top:n.scrollTop(),left:n.scrollLeft()}),{top:i.top+this.offset.relative.top*s+this.offset.parent.top*s-("fixed"===this.cssPosition?-this.scrollParent.scrollTop():this.offset.scroll.top)*s,left:i.left+this.offset.relative.left*s+this.offset.parent.left*s-("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():this.offset.scroll.left)*s}},_generatePosition:function(t){var i,s,n,a,o=this.options,r="absolute"!==this.cssPosition||this.scrollParent[0]!==document&&e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,h=t.pageX,l=t.pageY;return this.offset.scroll||(this.offset.scroll={top:r.scrollTop(),left:r.scrollLeft()}),this.originalPosition&&(this.containment&&(this.relative_container?(s=this.relative_container.offset(),i=[this.containment[0]+s.left,this.containment[1]+s.top,this.containment[2]+s.left,this.containment[3]+s.top]):i=this.containment,t.pageX-this.offset.click.left<i[0]&&(h=i[0]+this.offset.click.left),t.pageY-this.offset.click.top<i[1]&&(l=i[1]+this.offset.click.top),t.pageX-this.offset.click.left>i[2]&&(h=i[2]+this.offset.click.left),t.pageY-this.offset.click.top>i[3]&&(l=i[3]+this.offset.click.top)),o.grid&&(n=o.grid[1]?this.originalPageY+Math.round((l-this.originalPageY)/o.grid[1])*o.grid[1]:this.originalPageY,l=i?n-this.offset.click.top>=i[1]||n-this.offset.click.top>i[3]?n:n-this.offset.click.top>=i[1]?n-o.grid[1]:n+o.grid[1]:n,a=o.grid[0]?this.originalPageX+Math.round((h-this.originalPageX)/o.grid[0])*o.grid[0]:this.originalPageX,h=i?a-this.offset.click.left>=i[0]||a-this.offset.click.left>i[2]?a:a-this.offset.click.left>=i[0]?a-o.grid[0]:a+o.grid[0]:a)),{top:l-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():this.offset.scroll.top),left:h-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():this.offset.scroll.left)}},_clear:function(){this.helper.removeClass("ui-draggable-dragging"),this.helper[0]===this.element[0]||this.cancelHelperRemoval||this.helper.remove(),this.helper=null,this.cancelHelperRemoval=!1},_trigger:function(t,i,s){return s=s||this._uiHash(),e.ui.plugin.call(this,t,[i,s]),"drag"===t&&(this.positionAbs=this._convertPositionTo("absolute")),e.Widget.prototype._trigger.call(this,t,i,s)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}}),e.ui.plugin.add("draggable","connectToSortable",{start:function(t,i){var s=e(this).data("ui-draggable"),n=s.options,a=e.extend({},i,{item:s.element});s.sortables=[],e(n.connectToSortable).each(function(){var i=e.data(this,"ui-sortable");i&&!i.options.disabled&&(s.sortables.push({instance:i,shouldRevert:i.options.revert}),i.refreshPositions(),i._trigger("activate",t,a))})},stop:function(t,i){var s=e(this).data("ui-draggable"),n=e.extend({},i,{item:s.element});e.each(s.sortables,function(){this.instance.isOver?(this.instance.isOver=0,s.cancelHelperRemoval=!0,this.instance.cancelHelperRemoval=!1,this.shouldRevert&&(this.instance.options.revert=this.shouldRevert),this.instance._mouseStop(t),this.instance.options.helper=this.instance.options._helper,"original"===s.options.helper&&this.instance.currentItem.css({top:"auto",left:"auto"})):(this.instance.cancelHelperRemoval=!1,this.instance._trigger("deactivate",t,n))})},drag:function(t,i){var s=e(this).data("ui-draggable"),n=this;e.each(s.sortables,function(){var a=!1,o=this;this.instance.positionAbs=s.positionAbs,this.instance.helperProportions=s.helperProportions,this.instance.offset.click=s.offset.click,this.instance._intersectsWith(this.instance.containerCache)&&(a=!0,e.each(s.sortables,function(){return this.instance.positionAbs=s.positionAbs,this.instance.helperProportions=s.helperProportions,this.instance.offset.click=s.offset.click,this!==o&&this.instance._intersectsWith(this.instance.containerCache)&&e.contains(o.instance.element[0],this.instance.element[0])&&(a=!1),a})),a?(this.instance.isOver||(this.instance.isOver=1,this.instance.currentItem=e(n).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item",!0),this.instance.options._helper=this.instance.options.helper,this.instance.options.helper=function(){return i.helper[0]},t.target=this.instance.currentItem[0],this.instance._mouseCapture(t,!0),this.instance._mouseStart(t,!0,!0),this.instance.offset.click.top=s.offset.click.top,this.instance.offset.click.left=s.offset.click.left,this.instance.offset.parent.left-=s.offset.parent.left-this.instance.offset.parent.left,this.instance.offset.parent.top-=s.offset.parent.top-this.instance.offset.parent.top,s._trigger("toSortable",t),s.dropped=this.instance.element,s.currentItem=s.element,this.instance.fromOutside=s),this.instance.currentItem&&this.instance._mouseDrag(t)):this.instance.isOver&&(this.instance.isOver=0,this.instance.cancelHelperRemoval=!0,this.instance.options.revert=!1,this.instance._trigger("out",t,this.instance._uiHash(this.instance)),this.instance._mouseStop(t,!0),this.instance.options.helper=this.instance.options._helper,this.instance.currentItem.remove(),this.instance.placeholder&&this.instance.placeholder.remove(),s._trigger("fromSortable",t),s.dropped=!1)})}}),e.ui.plugin.add("draggable","cursor",{start:function(){var t=e("body"),i=e(this).data("ui-draggable").options;t.css("cursor")&&(i._cursor=t.css("cursor")),t.css("cursor",i.cursor)},stop:function(){var t=e(this).data("ui-draggable").options;t._cursor&&e("body").css("cursor",t._cursor)}}),e.ui.plugin.add("draggable","opacity",{start:function(t,i){var s=e(i.helper),n=e(this).data("ui-draggable").options;s.css("opacity")&&(n._opacity=s.css("opacity")),s.css("opacity",n.opacity)},stop:function(t,i){var s=e(this).data("ui-draggable").options;s._opacity&&e(i.helper).css("opacity",s._opacity)}}),e.ui.plugin.add("draggable","scroll",{start:function(){var t=e(this).data("ui-draggable");t.scrollParent[0]!==document&&"HTML"!==t.scrollParent[0].tagName&&(t.overflowOffset=t.scrollParent.offset())},drag:function(t){var i=e(this).data("ui-draggable"),s=i.options,n=!1;i.scrollParent[0]!==document&&"HTML"!==i.scrollParent[0].tagName?(s.axis&&"x"===s.axis||(i.overflowOffset.top+i.scrollParent[0].offsetHeight-t.pageY<s.scrollSensitivity?i.scrollParent[0].scrollTop=n=i.scrollParent[0].scrollTop+s.scrollSpeed:t.pageY-i.overflowOffset.top<s.scrollSensitivity&&(i.scrollParent[0].scrollTop=n=i.scrollParent[0].scrollTop-s.scrollSpeed)),s.axis&&"y"===s.axis||(i.overflowOffset.left+i.scrollParent[0].offsetWidth-t.pageX<s.scrollSensitivity?i.scrollParent[0].scrollLeft=n=i.scrollParent[0].scrollLeft+s.scrollSpeed:t.pageX-i.overflowOffset.left<s.scrollSensitivity&&(i.scrollParent[0].scrollLeft=n=i.scrollParent[0].scrollLeft-s.scrollSpeed))):(s.axis&&"x"===s.axis||(t.pageY-e(document).scrollTop()<s.scrollSensitivity?n=e(document).scrollTop(e(document).scrollTop()-s.scrollSpeed):e(window).height()-(t.pageY-e(document).scrollTop())<s.scrollSensitivity&&(n=e(document).scrollTop(e(document).scrollTop()+s.scrollSpeed))),s.axis&&"y"===s.axis||(t.pageX-e(document).scrollLeft()<s.scrollSensitivity?n=e(document).scrollLeft(e(document).scrollLeft()-s.scrollSpeed):e(window).width()-(t.pageX-e(document).scrollLeft())<s.scrollSensitivity&&(n=e(document).scrollLeft(e(document).scrollLeft()+s.scrollSpeed)))),n!==!1&&e.ui.ddmanager&&!s.dropBehaviour&&e.ui.ddmanager.prepareOffsets(i,t)}}),e.ui.plugin.add("draggable","snap",{start:function(){var t=e(this).data("ui-draggable"),i=t.options;t.snapElements=[],e(i.snap.constructor!==String?i.snap.items||":data(ui-draggable)":i.snap).each(function(){var i=e(this),s=i.offset();this!==t.element[0]&&t.snapElements.push({item:this,width:i.outerWidth(),height:i.outerHeight(),top:s.top,left:s.left})})},drag:function(t,i){var s,n,a,o,r,h,l,u,c,d,p=e(this).data("ui-draggable"),f=p.options,m=f.snapTolerance,g=i.offset.left,v=g+p.helperProportions.width,b=i.offset.top,y=b+p.helperProportions.height;for(c=p.snapElements.length-1;c>=0;c--)r=p.snapElements[c].left,h=r+p.snapElements[c].width,l=p.snapElements[c].top,u=l+p.snapElements[c].height,r-m>v||g>h+m||l-m>y||b>u+m||!e.contains(p.snapElements[c].item.ownerDocument,p.snapElements[c].item)?(p.snapElements[c].snapping&&p.options.snap.release&&p.options.snap.release.call(p.element,t,e.extend(p._uiHash(),{snapItem:p.snapElements[c].item})),p.snapElements[c].snapping=!1):("inner"!==f.snapMode&&(s=m>=Math.abs(l-y),n=m>=Math.abs(u-b),a=m>=Math.abs(r-v),o=m>=Math.abs(h-g),s&&(i.position.top=p._convertPositionTo("relative",{top:l-p.helperProportions.height,left:0}).top-p.margins.top),n&&(i.position.top=p._convertPositionTo("relative",{top:u,left:0}).top-p.margins.top),a&&(i.position.left=p._convertPositionTo("relative",{top:0,left:r-p.helperProportions.width}).left-p.margins.left),o&&(i.position.left=p._convertPositionTo("relative",{top:0,left:h}).left-p.margins.left)),d=s||n||a||o,"outer"!==f.snapMode&&(s=m>=Math.abs(l-b),n=m>=Math.abs(u-y),a=m>=Math.abs(r-g),o=m>=Math.abs(h-v),s&&(i.position.top=p._convertPositionTo("relative",{top:l,left:0}).top-p.margins.top),n&&(i.position.top=p._convertPositionTo("relative",{top:u-p.helperProportions.height,left:0}).top-p.margins.top),a&&(i.position.left=p._convertPositionTo("relative",{top:0,left:r}).left-p.margins.left),o&&(i.position.left=p._convertPositionTo("relative",{top:0,left:h-p.helperProportions.width}).left-p.margins.left)),!p.snapElements[c].snapping&&(s||n||a||o||d)&&p.options.snap.snap&&p.options.snap.snap.call(p.element,t,e.extend(p._uiHash(),{snapItem:p.snapElements[c].item})),p.snapElements[c].snapping=s||n||a||o||d)}}),e.ui.plugin.add("draggable","stack",{start:function(){var t,i=this.data("ui-draggable").options,s=e.makeArray(e(i.stack)).sort(function(t,i){return(parseInt(e(t).css("zIndex"),10)||0)-(parseInt(e(i).css("zIndex"),10)||0)});s.length&&(t=parseInt(e(s[0]).css("zIndex"),10)||0,e(s).each(function(i){e(this).css("zIndex",t+i)}),this.css("zIndex",t+s.length))}}),e.ui.plugin.add("draggable","zIndex",{start:function(t,i){var s=e(i.helper),n=e(this).data("ui-draggable").options;s.css("zIndex")&&(n._zIndex=s.css("zIndex")),s.css("zIndex",n.zIndex)},stop:function(t,i){var s=e(this).data("ui-draggable").options;s._zIndex&&e(i.helper).css("zIndex",s._zIndex)}})})(jQuery);(function(e){function t(e,t,i){return e>t&&t+i>e}e.widget("ui.droppable",{version:"1.10.3",widgetEventPrefix:"drop",options:{accept:"*",activeClass:!1,addClasses:!0,greedy:!1,hoverClass:!1,scope:"default",tolerance:"intersect",activate:null,deactivate:null,drop:null,out:null,over:null},_create:function(){var t=this.options,i=t.accept;this.isover=!1,this.isout=!0,this.accept=e.isFunction(i)?i:function(e){return e.is(i)},this.proportions={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight},e.ui.ddmanager.droppables[t.scope]=e.ui.ddmanager.droppables[t.scope]||[],e.ui.ddmanager.droppables[t.scope].push(this),t.addClasses&&this.element.addClass("ui-droppable")},_destroy:function(){for(var t=0,i=e.ui.ddmanager.droppables[this.options.scope];i.length>t;t++)i[t]===this&&i.splice(t,1);this.element.removeClass("ui-droppable ui-droppable-disabled")},_setOption:function(t,i){"accept"===t&&(this.accept=e.isFunction(i)?i:function(e){return e.is(i)}),e.Widget.prototype._setOption.apply(this,arguments)},_activate:function(t){var i=e.ui.ddmanager.current;this.options.activeClass&&this.element.addClass(this.options.activeClass),i&&this._trigger("activate",t,this.ui(i))},_deactivate:function(t){var i=e.ui.ddmanager.current;this.options.activeClass&&this.element.removeClass(this.options.activeClass),i&&this._trigger("deactivate",t,this.ui(i))},_over:function(t){var i=e.ui.ddmanager.current;i&&(i.currentItem||i.element)[0]!==this.element[0]&&this.accept.call(this.element[0],i.currentItem||i.element)&&(this.options.hoverClass&&this.element.addClass(this.options.hoverClass),this._trigger("over",t,this.ui(i)))},_out:function(t){var i=e.ui.ddmanager.current;i&&(i.currentItem||i.element)[0]!==this.element[0]&&this.accept.call(this.element[0],i.currentItem||i.element)&&(this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("out",t,this.ui(i)))},_drop:function(t,i){var s=i||e.ui.ddmanager.current,n=!1;return s&&(s.currentItem||s.element)[0]!==this.element[0]?(this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function(){var t=e.data(this,"ui-droppable");return t.options.greedy&&!t.options.disabled&&t.options.scope===s.options.scope&&t.accept.call(t.element[0],s.currentItem||s.element)&&e.ui.intersect(s,e.extend(t,{offset:t.element.offset()}),t.options.tolerance)?(n=!0,!1):undefined}),n?!1:this.accept.call(this.element[0],s.currentItem||s.element)?(this.options.activeClass&&this.element.removeClass(this.options.activeClass),this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("drop",t,this.ui(s)),this.element):!1):!1},ui:function(e){return{draggable:e.currentItem||e.element,helper:e.helper,position:e.position,offset:e.positionAbs}}}),e.ui.intersect=function(e,i,s){if(!i.offset)return!1;var n,a,o=(e.positionAbs||e.position.absolute).left,r=o+e.helperProportions.width,h=(e.positionAbs||e.position.absolute).top,l=h+e.helperProportions.height,u=i.offset.left,c=u+i.proportions.width,d=i.offset.top,p=d+i.proportions.height;switch(s){case"fit":return o>=u&&c>=r&&h>=d&&p>=l;case"intersect":return o+e.helperProportions.width/2>u&&c>r-e.helperProportions.width/2&&h+e.helperProportions.height/2>d&&p>l-e.helperProportions.height/2;case"pointer":return n=(e.positionAbs||e.position.absolute).left+(e.clickOffset||e.offset.click).left,a=(e.positionAbs||e.position.absolute).top+(e.clickOffset||e.offset.click).top,t(a,d,i.proportions.height)&&t(n,u,i.proportions.width);case"touch":return(h>=d&&p>=h||l>=d&&p>=l||d>h&&l>p)&&(o>=u&&c>=o||r>=u&&c>=r||u>o&&r>c);default:return!1}},e.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(t,i){var s,n,a=e.ui.ddmanager.droppables[t.options.scope]||[],o=i?i.type:null,r=(t.currentItem||t.element).find(":data(ui-droppable)").addBack();e:for(s=0;a.length>s;s++)if(!(a[s].options.disabled||t&&!a[s].accept.call(a[s].element[0],t.currentItem||t.element))){for(n=0;r.length>n;n++)if(r[n]===a[s].element[0]){a[s].proportions.height=0;continue e}a[s].visible="none"!==a[s].element.css("display"),a[s].visible&&("mousedown"===o&&a[s]._activate.call(a[s],i),a[s].offset=a[s].element.offset(),a[s].proportions={width:a[s].element[0].offsetWidth,height:a[s].element[0].offsetHeight})}},drop:function(t,i){var s=!1;return e.each((e.ui.ddmanager.droppables[t.options.scope]||[]).slice(),function(){this.options&&(!this.options.disabled&&this.visible&&e.ui.intersect(t,this,this.options.tolerance)&&(s=this._drop.call(this,i)||s),!this.options.disabled&&this.visible&&this.accept.call(this.element[0],t.currentItem||t.element)&&(this.isout=!0,this.isover=!1,this._deactivate.call(this,i)))}),s},dragStart:function(t,i){t.element.parentsUntil("body").bind("scroll.droppable",function(){t.options.refreshPositions||e.ui.ddmanager.prepareOffsets(t,i)})},drag:function(t,i){t.options.refreshPositions&&e.ui.ddmanager.prepareOffsets(t,i),e.each(e.ui.ddmanager.droppables[t.options.scope]||[],function(){if(!this.options.disabled&&!this.greedyChild&&this.visible){var s,n,a,o=e.ui.intersect(t,this,this.options.tolerance),r=!o&&this.isover?"isout":o&&!this.isover?"isover":null;r&&(this.options.greedy&&(n=this.options.scope,a=this.element.parents(":data(ui-droppable)").filter(function(){return e.data(this,"ui-droppable").options.scope===n}),a.length&&(s=e.data(a[0],"ui-droppable"),s.greedyChild="isover"===r)),s&&"isover"===r&&(s.isover=!1,s.isout=!0,s._out.call(s,i)),this[r]=!0,this["isout"===r?"isover":"isout"]=!1,this["isover"===r?"_over":"_out"].call(this,i),s&&"isout"===r&&(s.isout=!1,s.isover=!0,s._over.call(s,i)))}})},dragStop:function(t,i){t.element.parentsUntil("body").unbind("scroll.droppable"),t.options.refreshPositions||e.ui.ddmanager.prepareOffsets(t,i)}}})(jQuery);(function(e){function t(e){return parseInt(e,10)||0}function i(e){return!isNaN(parseInt(e,10))}e.widget("ui.resizable",e.ui.mouse,{version:"1.10.3",widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:90,resize:null,start:null,stop:null},_create:function(){var t,i,s,n,a,o=this,r=this.options;if(this.element.addClass("ui-resizable"),e.extend(this,{_aspectRatio:!!r.aspectRatio,aspectRatio:r.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:r.helper||r.ghost||r.animate?r.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)&&(this.element.wrap(e("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("ui-resizable",this.element.data("ui-resizable")),this.elementIsWrapper=!0,this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")}),this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0}),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css({margin:this.originalElement.css("margin")}),this._proportionallyResize()),this.handles=r.handles||(e(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se"),this.handles.constructor===String)for("all"===this.handles&&(this.handles="n,e,s,w,se,sw,ne,nw"),t=this.handles.split(","),this.handles={},i=0;t.length>i;i++)s=e.trim(t[i]),a="ui-resizable-"+s,n=e("<div class='ui-resizable-handle "+a+"'></div>"),n.css({zIndex:r.zIndex}),"se"===s&&n.addClass("ui-icon ui-icon-gripsmall-diagonal-se"),this.handles[s]=".ui-resizable-"+s,this.element.append(n);this._renderAxis=function(t){var i,s,n,a;t=t||this.element;for(i in this.handles)this.handles[i].constructor===String&&(this.handles[i]=e(this.handles[i],this.element).show()),this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)&&(s=e(this.handles[i],this.element),a=/sw|ne|nw|se|n|s/.test(i)?s.outerHeight():s.outerWidth(),n=["padding",/ne|nw|n/.test(i)?"Top":/se|sw|s/.test(i)?"Bottom":/^e$/.test(i)?"Right":"Left"].join(""),t.css(n,a),this._proportionallyResize()),e(this.handles[i]).length},this._renderAxis(this.element),this._handles=e(".ui-resizable-handle",this.element).disableSelection(),this._handles.mouseover(function(){o.resizing||(this.className&&(n=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)),o.axis=n&&n[1]?n[1]:"se")}),r.autoHide&&(this._handles.hide(),e(this.element).addClass("ui-resizable-autohide").mouseenter(function(){r.disabled||(e(this).removeClass("ui-resizable-autohide"),o._handles.show())}).mouseleave(function(){r.disabled||o.resizing||(e(this).addClass("ui-resizable-autohide"),o._handles.hide())})),this._mouseInit()},_destroy:function(){this._mouseDestroy();var t,i=function(t){e(t).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};return this.elementIsWrapper&&(i(this.element),t=this.element,this.originalElement.css({position:t.css("position"),width:t.outerWidth(),height:t.outerHeight(),top:t.css("top"),left:t.css("left")}).insertAfter(t),t.remove()),this.originalElement.css("resize",this.originalResizeStyle),i(this.originalElement),this},_mouseCapture:function(t){var i,s,n=!1;for(i in this.handles)s=e(this.handles[i])[0],(s===t.target||e.contains(s,t.target))&&(n=!0);return!this.options.disabled&&n},_mouseStart:function(i){var s,n,a,o=this.options,r=this.element.position(),h=this.element;return this.resizing=!0,/absolute/.test(h.css("position"))?h.css({position:"absolute",top:h.css("top"),left:h.css("left")}):h.is(".ui-draggable")&&h.css({position:"absolute",top:r.top,left:r.left}),this._renderProxy(),s=t(this.helper.css("left")),n=t(this.helper.css("top")),o.containment&&(s+=e(o.containment).scrollLeft()||0,n+=e(o.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:s,top:n},this.size=this._helper?{width:h.outerWidth(),height:h.outerHeight()}:{width:h.width(),height:h.height()},this.originalSize=this._helper?{width:h.outerWidth(),height:h.outerHeight()}:{width:h.width(),height:h.height()},this.originalPosition={left:s,top:n},this.sizeDiff={width:h.outerWidth()-h.width(),height:h.outerHeight()-h.height()},this.originalMousePosition={left:i.pageX,top:i.pageY},this.aspectRatio="number"==typeof o.aspectRatio?o.aspectRatio:this.originalSize.width/this.originalSize.height||1,a=e(".ui-resizable-"+this.axis).css("cursor"),e("body").css("cursor","auto"===a?this.axis+"-resize":a),h.addClass("ui-resizable-resizing"),this._propagate("start",i),!0},_mouseDrag:function(t){var i,s=this.helper,n={},a=this.originalMousePosition,o=this.axis,r=this.position.top,h=this.position.left,l=this.size.width,u=this.size.height,c=t.pageX-a.left||0,d=t.pageY-a.top||0,p=this._change[o];return p?(i=p.apply(this,[t,c,d]),this._updateVirtualBoundaries(t.shiftKey),(this._aspectRatio||t.shiftKey)&&(i=this._updateRatio(i,t)),i=this._respectSize(i,t),this._updateCache(i),this._propagate("resize",t),this.position.top!==r&&(n.top=this.position.top+"px"),this.position.left!==h&&(n.left=this.position.left+"px"),this.size.width!==l&&(n.width=this.size.width+"px"),this.size.height!==u&&(n.height=this.size.height+"px"),s.css(n),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),e.isEmptyObject(n)||this._trigger("resize",t,this.ui()),!1):!1},_mouseStop:function(t){this.resizing=!1;var i,s,n,a,o,r,h,l=this.options,u=this;return this._helper&&(i=this._proportionallyResizeElements,s=i.length&&/textarea/i.test(i[0].nodeName),n=s&&e.ui.hasScroll(i[0],"left")?0:u.sizeDiff.height,a=s?0:u.sizeDiff.width,o={width:u.helper.width()-a,height:u.helper.height()-n},r=parseInt(u.element.css("left"),10)+(u.position.left-u.originalPosition.left)||null,h=parseInt(u.element.css("top"),10)+(u.position.top-u.originalPosition.top)||null,l.animate||this.element.css(e.extend(o,{top:h,left:r})),u.helper.height(u.size.height),u.helper.width(u.size.width),this._helper&&!l.animate&&this._proportionallyResize()),e("body").css("cursor","auto"),this.element.removeClass("ui-resizable-resizing"),this._propagate("stop",t),this._helper&&this.helper.remove(),!1},_updateVirtualBoundaries:function(e){var t,s,n,a,o,r=this.options;o={minWidth:i(r.minWidth)?r.minWidth:0,maxWidth:i(r.maxWidth)?r.maxWidth:1/0,minHeight:i(r.minHeight)?r.minHeight:0,maxHeight:i(r.maxHeight)?r.maxHeight:1/0},(this._aspectRatio||e)&&(t=o.minHeight*this.aspectRatio,n=o.minWidth/this.aspectRatio,s=o.maxHeight*this.aspectRatio,a=o.maxWidth/this.aspectRatio,t>o.minWidth&&(o.minWidth=t),n>o.minHeight&&(o.minHeight=n),o.maxWidth>s&&(o.maxWidth=s),o.maxHeight>a&&(o.maxHeight=a)),this._vBoundaries=o},_updateCache:function(e){this.offset=this.helper.offset(),i(e.left)&&(this.position.left=e.left),i(e.top)&&(this.position.top=e.top),i(e.height)&&(this.size.height=e.height),i(e.width)&&(this.size.width=e.width)},_updateRatio:function(e){var t=this.position,s=this.size,n=this.axis;return i(e.height)?e.width=e.height*this.aspectRatio:i(e.width)&&(e.height=e.width/this.aspectRatio),"sw"===n&&(e.left=t.left+(s.width-e.width),e.top=null),"nw"===n&&(e.top=t.top+(s.height-e.height),e.left=t.left+(s.width-e.width)),e},_respectSize:function(e){var t=this._vBoundaries,s=this.axis,n=i(e.width)&&t.maxWidth&&t.maxWidth<e.width,a=i(e.height)&&t.maxHeight&&t.maxHeight<e.height,o=i(e.width)&&t.minWidth&&t.minWidth>e.width,r=i(e.height)&&t.minHeight&&t.minHeight>e.height,h=this.originalPosition.left+this.originalSize.width,l=this.position.top+this.size.height,u=/sw|nw|w/.test(s),c=/nw|ne|n/.test(s);return o&&(e.width=t.minWidth),r&&(e.height=t.minHeight),n&&(e.width=t.maxWidth),a&&(e.height=t.maxHeight),o&&u&&(e.left=h-t.minWidth),n&&u&&(e.left=h-t.maxWidth),r&&c&&(e.top=l-t.minHeight),a&&c&&(e.top=l-t.maxHeight),e.width||e.height||e.left||!e.top?e.width||e.height||e.top||!e.left||(e.left=null):e.top=null,e},_proportionallyResize:function(){if(this._proportionallyResizeElements.length){var e,t,i,s,n,a=this.helper||this.element;for(e=0;this._proportionallyResizeElements.length>e;e++){if(n=this._proportionallyResizeElements[e],!this.borderDif)for(this.borderDif=[],i=[n.css("borderTopWidth"),n.css("borderRightWidth"),n.css("borderBottomWidth"),n.css("borderLeftWidth")],s=[n.css("paddingTop"),n.css("paddingRight"),n.css("paddingBottom"),n.css("paddingLeft")],t=0;i.length>t;t++)this.borderDif[t]=(parseInt(i[t],10)||0)+(parseInt(s[t],10)||0);n.css({height:a.height()-this.borderDif[0]-this.borderDif[2]||0,width:a.width()-this.borderDif[1]-this.borderDif[3]||0})}}},_renderProxy:function(){var t=this.element,i=this.options;this.elementOffset=t.offset(),this._helper?(this.helper=this.helper||e("<div style='overflow:hidden;'></div>"),this.helper.addClass(this._helper).css({width:this.element.outerWidth()-1,height:this.element.outerHeight()-1,position:"absolute",left:this.elementOffset.left+"px",top:this.elementOffset.top+"px",zIndex:++i.zIndex}),this.helper.appendTo("body").disableSelection()):this.helper=this.element},_change:{e:function(e,t){return{width:this.originalSize.width+t}},w:function(e,t){var i=this.originalSize,s=this.originalPosition;return{left:s.left+t,width:i.width-t}},n:function(e,t,i){var s=this.originalSize,n=this.originalPosition;return{top:n.top+i,height:s.height-i}},s:function(e,t,i){return{height:this.originalSize.height+i}},se:function(t,i,s){return e.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[t,i,s]))},sw:function(t,i,s){return e.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[t,i,s]))},ne:function(t,i,s){return e.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[t,i,s]))},nw:function(t,i,s){return e.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[t,i,s]))}},_propagate:function(t,i){e.ui.plugin.call(this,t,[i,this.ui()]),"resize"!==t&&this._trigger(t,i,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),e.ui.plugin.add("resizable","animate",{stop:function(t){var i=e(this).data("ui-resizable"),s=i.options,n=i._proportionallyResizeElements,a=n.length&&/textarea/i.test(n[0].nodeName),o=a&&e.ui.hasScroll(n[0],"left")?0:i.sizeDiff.height,r=a?0:i.sizeDiff.width,h={width:i.size.width-r,height:i.size.height-o},l=parseInt(i.element.css("left"),10)+(i.position.left-i.originalPosition.left)||null,u=parseInt(i.element.css("top"),10)+(i.position.top-i.originalPosition.top)||null;i.element.animate(e.extend(h,u&&l?{top:u,left:l}:{}),{duration:s.animateDuration,easing:s.animateEasing,step:function(){var s={width:parseInt(i.element.css("width"),10),height:parseInt(i.element.css("height"),10),top:parseInt(i.element.css("top"),10),left:parseInt(i.element.css("left"),10)};n&&n.length&&e(n[0]).css({width:s.width,height:s.height}),i._updateCache(s),i._propagate("resize",t)}})}}),e.ui.plugin.add("resizable","containment",{start:function(){var i,s,n,a,o,r,h,l=e(this).data("ui-resizable"),u=l.options,c=l.element,d=u.containment,p=d instanceof e?d.get(0):/parent/.test(d)?c.parent().get(0):d;p&&(l.containerElement=e(p),/document/.test(d)||d===document?(l.containerOffset={left:0,top:0},l.containerPosition={left:0,top:0},l.parentData={element:e(document),left:0,top:0,width:e(document).width(),height:e(document).height()||document.body.parentNode.scrollHeight}):(i=e(p),s=[],e(["Top","Right","Left","Bottom"]).each(function(e,n){s[e]=t(i.css("padding"+n))}),l.containerOffset=i.offset(),l.containerPosition=i.position(),l.containerSize={height:i.innerHeight()-s[3],width:i.innerWidth()-s[1]},n=l.containerOffset,a=l.containerSize.height,o=l.containerSize.width,r=e.ui.hasScroll(p,"left")?p.scrollWidth:o,h=e.ui.hasScroll(p)?p.scrollHeight:a,l.parentData={element:p,left:n.left,top:n.top,width:r,height:h}))},resize:function(t){var i,s,n,a,o=e(this).data("ui-resizable"),r=o.options,h=o.containerOffset,l=o.position,u=o._aspectRatio||t.shiftKey,c={top:0,left:0},d=o.containerElement;d[0]!==document&&/static/.test(d.css("position"))&&(c=h),l.left<(o._helper?h.left:0)&&(o.size.width=o.size.width+(o._helper?o.position.left-h.left:o.position.left-c.left),u&&(o.size.height=o.size.width/o.aspectRatio),o.position.left=r.helper?h.left:0),l.top<(o._helper?h.top:0)&&(o.size.height=o.size.height+(o._helper?o.position.top-h.top:o.position.top),u&&(o.size.width=o.size.height*o.aspectRatio),o.position.top=o._helper?h.top:0),o.offset.left=o.parentData.left+o.position.left,o.offset.top=o.parentData.top+o.position.top,i=Math.abs((o._helper?o.offset.left-c.left:o.offset.left-c.left)+o.sizeDiff.width),s=Math.abs((o._helper?o.offset.top-c.top:o.offset.top-h.top)+o.sizeDiff.height),n=o.containerElement.get(0)===o.element.parent().get(0),a=/relative|absolute/.test(o.containerElement.css("position")),n&&a&&(i-=o.parentData.left),i+o.size.width>=o.parentData.width&&(o.size.width=o.parentData.width-i,u&&(o.size.height=o.size.width/o.aspectRatio)),s+o.size.height>=o.parentData.height&&(o.size.height=o.parentData.height-s,u&&(o.size.width=o.size.height*o.aspectRatio))},stop:function(){var t=e(this).data("ui-resizable"),i=t.options,s=t.containerOffset,n=t.containerPosition,a=t.containerElement,o=e(t.helper),r=o.offset(),h=o.outerWidth()-t.sizeDiff.width,l=o.outerHeight()-t.sizeDiff.height;t._helper&&!i.animate&&/relative/.test(a.css("position"))&&e(this).css({left:r.left-n.left-s.left,width:h,height:l}),t._helper&&!i.animate&&/static/.test(a.css("position"))&&e(this).css({left:r.left-n.left-s.left,width:h,height:l})}}),e.ui.plugin.add("resizable","alsoResize",{start:function(){var t=e(this).data("ui-resizable"),i=t.options,s=function(t){e(t).each(function(){var t=e(this);t.data("ui-resizable-alsoresize",{width:parseInt(t.width(),10),height:parseInt(t.height(),10),left:parseInt(t.css("left"),10),top:parseInt(t.css("top"),10)})})};"object"!=typeof i.alsoResize||i.alsoResize.parentNode?s(i.alsoResize):i.alsoResize.length?(i.alsoResize=i.alsoResize[0],s(i.alsoResize)):e.each(i.alsoResize,function(e){s(e)})},resize:function(t,i){var s=e(this).data("ui-resizable"),n=s.options,a=s.originalSize,o=s.originalPosition,r={height:s.size.height-a.height||0,width:s.size.width-a.width||0,top:s.position.top-o.top||0,left:s.position.left-o.left||0},h=function(t,s){e(t).each(function(){var t=e(this),n=e(this).data("ui-resizable-alsoresize"),a={},o=s&&s.length?s:t.parents(i.originalElement[0]).length?["width","height"]:["width","height","top","left"];e.each(o,function(e,t){var i=(n[t]||0)+(r[t]||0);i&&i>=0&&(a[t]=i||null)}),t.css(a)})};"object"!=typeof n.alsoResize||n.alsoResize.nodeType?h(n.alsoResize):e.each(n.alsoResize,function(e,t){h(e,t)})},stop:function(){e(this).removeData("resizable-alsoresize")}}),e.ui.plugin.add("resizable","ghost",{start:function(){var t=e(this).data("ui-resizable"),i=t.options,s=t.size;t.ghost=t.originalElement.clone(),t.ghost.css({opacity:.25,display:"block",position:"relative",height:s.height,width:s.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass("string"==typeof i.ghost?i.ghost:""),t.ghost.appendTo(t.helper)},resize:function(){var t=e(this).data("ui-resizable");t.ghost&&t.ghost.css({position:"relative",height:t.size.height,width:t.size.width})},stop:function(){var t=e(this).data("ui-resizable");t.ghost&&t.helper&&t.helper.get(0).removeChild(t.ghost.get(0))}}),e.ui.plugin.add("resizable","grid",{resize:function(){var t=e(this).data("ui-resizable"),i=t.options,s=t.size,n=t.originalSize,a=t.originalPosition,o=t.axis,r="number"==typeof i.grid?[i.grid,i.grid]:i.grid,h=r[0]||1,l=r[1]||1,u=Math.round((s.width-n.width)/h)*h,c=Math.round((s.height-n.height)/l)*l,d=n.width+u,p=n.height+c,f=i.maxWidth&&d>i.maxWidth,m=i.maxHeight&&p>i.maxHeight,g=i.minWidth&&i.minWidth>d,v=i.minHeight&&i.minHeight>p;i.grid=r,g&&(d+=h),v&&(p+=l),f&&(d-=h),m&&(p-=l),/^(se|s|e)$/.test(o)?(t.size.width=d,t.size.height=p):/^(ne)$/.test(o)?(t.size.width=d,t.size.height=p,t.position.top=a.top-c):/^(sw)$/.test(o)?(t.size.width=d,t.size.height=p,t.position.left=a.left-u):(t.size.width=d,t.size.height=p,t.position.top=a.top-c,t.position.left=a.left-u)}})})(jQuery);(function(e){e.widget("ui.selectable",e.ui.mouse,{version:"1.10.3",options:{appendTo:"body",autoRefresh:!0,distance:0,filter:"*",tolerance:"touch",selected:null,selecting:null,start:null,stop:null,unselected:null,unselecting:null},_create:function(){var t,i=this;this.element.addClass("ui-selectable"),this.dragged=!1,this.refresh=function(){t=e(i.options.filter,i.element[0]),t.addClass("ui-selectee"),t.each(function(){var t=e(this),i=t.offset();e.data(this,"selectable-item",{element:this,$element:t,left:i.left,top:i.top,right:i.left+t.outerWidth(),bottom:i.top+t.outerHeight(),startselected:!1,selected:t.hasClass("ui-selected"),selecting:t.hasClass("ui-selecting"),unselecting:t.hasClass("ui-unselecting")})})},this.refresh(),this.selectees=t.addClass("ui-selectee"),this._mouseInit(),this.helper=e("<div class='ui-selectable-helper'></div>")},_destroy:function(){this.selectees.removeClass("ui-selectee").removeData("selectable-item"),this.element.removeClass("ui-selectable ui-selectable-disabled"),this._mouseDestroy()},_mouseStart:function(t){var i=this,s=this.options;this.opos=[t.pageX,t.pageY],this.options.disabled||(this.selectees=e(s.filter,this.element[0]),this._trigger("start",t),e(s.appendTo).append(this.helper),this.helper.css({left:t.pageX,top:t.pageY,width:0,height:0}),s.autoRefresh&&this.refresh(),this.selectees.filter(".ui-selected").each(function(){var s=e.data(this,"selectable-item");s.startselected=!0,t.metaKey||t.ctrlKey||(s.$element.removeClass("ui-selected"),s.selected=!1,s.$element.addClass("ui-unselecting"),s.unselecting=!0,i._trigger("unselecting",t,{unselecting:s.element}))}),e(t.target).parents().addBack().each(function(){var s,n=e.data(this,"selectable-item");return n?(s=!t.metaKey&&!t.ctrlKey||!n.$element.hasClass("ui-selected"),n.$element.removeClass(s?"ui-unselecting":"ui-selected").addClass(s?"ui-selecting":"ui-unselecting"),n.unselecting=!s,n.selecting=s,n.selected=s,s?i._trigger("selecting",t,{selecting:n.element}):i._trigger("unselecting",t,{unselecting:n.element}),!1):undefined}))},_mouseDrag:function(t){if(this.dragged=!0,!this.options.disabled){var i,s=this,n=this.options,a=this.opos[0],o=this.opos[1],r=t.pageX,h=t.pageY;return a>r&&(i=r,r=a,a=i),o>h&&(i=h,h=o,o=i),this.helper.css({left:a,top:o,width:r-a,height:h-o}),this.selectees.each(function(){var i=e.data(this,"selectable-item"),l=!1;i&&i.element!==s.element[0]&&("touch"===n.tolerance?l=!(i.left>r||a>i.right||i.top>h||o>i.bottom):"fit"===n.tolerance&&(l=i.left>a&&r>i.right&&i.top>o&&h>i.bottom),l?(i.selected&&(i.$element.removeClass("ui-selected"),i.selected=!1),i.unselecting&&(i.$element.removeClass("ui-unselecting"),i.unselecting=!1),i.selecting||(i.$element.addClass("ui-selecting"),i.selecting=!0,s._trigger("selecting",t,{selecting:i.element}))):(i.selecting&&((t.metaKey||t.ctrlKey)&&i.startselected?(i.$element.removeClass("ui-selecting"),i.selecting=!1,i.$element.addClass("ui-selected"),i.selected=!0):(i.$element.removeClass("ui-selecting"),i.selecting=!1,i.startselected&&(i.$element.addClass("ui-unselecting"),i.unselecting=!0),s._trigger("unselecting",t,{unselecting:i.element}))),i.selected&&(t.metaKey||t.ctrlKey||i.startselected||(i.$element.removeClass("ui-selected"),i.selected=!1,i.$element.addClass("ui-unselecting"),i.unselecting=!0,s._trigger("unselecting",t,{unselecting:i.element})))))}),!1}},_mouseStop:function(t){var i=this;return this.dragged=!1,e(".ui-unselecting",this.element[0]).each(function(){var s=e.data(this,"selectable-item");s.$element.removeClass("ui-unselecting"),s.unselecting=!1,s.startselected=!1,i._trigger("unselected",t,{unselected:s.element})}),e(".ui-selecting",this.element[0]).each(function(){var s=e.data(this,"selectable-item");s.$element.removeClass("ui-selecting").addClass("ui-selected"),s.selecting=!1,s.selected=!0,s.startselected=!0,i._trigger("selected",t,{selected:s.element})}),this._trigger("stop",t),this.helper.remove(),!1}})})(jQuery);(function(t){function e(t,e,i){return t>e&&e+i>t}function i(t){return/left|right/.test(t.css("float"))||/inline|table-cell/.test(t.css("display"))}t.widget("ui.sortable",t.ui.mouse,{version:"1.10.3",widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3,activate:null,beforeStop:null,change:null,deactivate:null,out:null,over:null,receive:null,remove:null,sort:null,start:null,stop:null,update:null},_create:function(){var t=this.options;this.containerCache={},this.element.addClass("ui-sortable"),this.refresh(),this.floating=this.items.length?"x"===t.axis||i(this.items[0].item):!1,this.offset=this.element.offset(),this._mouseInit(),this.ready=!0},_destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled"),this._mouseDestroy();for(var t=this.items.length-1;t>=0;t--)this.items[t].item.removeData(this.widgetName+"-item");return this},_setOption:function(e,i){"disabled"===e?(this.options[e]=i,this.widget().toggleClass("ui-sortable-disabled",!!i)):t.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(e,i){var s=null,n=!1,a=this;return this.reverting?!1:this.options.disabled||"static"===this.options.type?!1:(this._refreshItems(e),t(e.target).parents().each(function(){return t.data(this,a.widgetName+"-item")===a?(s=t(this),!1):undefined}),t.data(e.target,a.widgetName+"-item")===a&&(s=t(e.target)),s?!this.options.handle||i||(t(this.options.handle,s).find("*").addBack().each(function(){this===e.target&&(n=!0)}),n)?(this.currentItem=s,this._removeCurrentsFromItems(),!0):!1:!1)},_mouseStart:function(e,i,s){var n,a,o=this.options;if(this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(e),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},t.extend(this.offset,{click:{left:e.pageX-this.offset.left,top:e.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(e),this.originalPageX=e.pageX,this.originalPageY=e.pageY,o.cursorAt&&this._adjustOffsetFromHelper(o.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!==this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),o.containment&&this._setContainment(),o.cursor&&"auto"!==o.cursor&&(a=this.document.find("body"),this.storedCursor=a.css("cursor"),a.css("cursor",o.cursor),this.storedStylesheet=t("<style>*{ cursor: "+o.cursor+" !important; }</style>").appendTo(a)),o.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",o.opacity)),o.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",o.zIndex)),this.scrollParent[0]!==document&&"HTML"!==this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",e,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions(),!s)for(n=this.containers.length-1;n>=0;n--)this.containers[n]._trigger("activate",e,this._uiHash(this));return t.ui.ddmanager&&(t.ui.ddmanager.current=this),t.ui.ddmanager&&!o.dropBehaviour&&t.ui.ddmanager.prepareOffsets(this,e),this.dragging=!0,this.helper.addClass("ui-sortable-helper"),this._mouseDrag(e),!0},_mouseDrag:function(e){var i,s,n,a,o=this.options,r=!1;for(this.position=this._generatePosition(e),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs),this.options.scroll&&(this.scrollParent[0]!==document&&"HTML"!==this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-e.pageY<o.scrollSensitivity?this.scrollParent[0].scrollTop=r=this.scrollParent[0].scrollTop+o.scrollSpeed:e.pageY-this.overflowOffset.top<o.scrollSensitivity&&(this.scrollParent[0].scrollTop=r=this.scrollParent[0].scrollTop-o.scrollSpeed),this.overflowOffset.left+this.scrollParent[0].offsetWidth-e.pageX<o.scrollSensitivity?this.scrollParent[0].scrollLeft=r=this.scrollParent[0].scrollLeft+o.scrollSpeed:e.pageX-this.overflowOffset.left<o.scrollSensitivity&&(this.scrollParent[0].scrollLeft=r=this.scrollParent[0].scrollLeft-o.scrollSpeed)):(e.pageY-t(document).scrollTop()<o.scrollSensitivity?r=t(document).scrollTop(t(document).scrollTop()-o.scrollSpeed):t(window).height()-(e.pageY-t(document).scrollTop())<o.scrollSensitivity&&(r=t(document).scrollTop(t(document).scrollTop()+o.scrollSpeed)),e.pageX-t(document).scrollLeft()<o.scrollSensitivity?r=t(document).scrollLeft(t(document).scrollLeft()-o.scrollSpeed):t(window).width()-(e.pageX-t(document).scrollLeft())<o.scrollSensitivity&&(r=t(document).scrollLeft(t(document).scrollLeft()+o.scrollSpeed))),r!==!1&&t.ui.ddmanager&&!o.dropBehaviour&&t.ui.ddmanager.prepareOffsets(this,e)),this.positionAbs=this._convertPositionTo("absolute"),this.options.axis&&"y"===this.options.axis||(this.helper[0].style.left=this.position.left+"px"),this.options.axis&&"x"===this.options.axis||(this.helper[0].style.top=this.position.top+"px"),i=this.items.length-1;i>=0;i--)if(s=this.items[i],n=s.item[0],a=this._intersectsWithPointer(s),a&&s.instance===this.currentContainer&&n!==this.currentItem[0]&&this.placeholder[1===a?"next":"prev"]()[0]!==n&&!t.contains(this.placeholder[0],n)&&("semi-dynamic"===this.options.type?!t.contains(this.element[0],n):!0)){if(this.direction=1===a?"down":"up","pointer"!==this.options.tolerance&&!this._intersectsWithSides(s))break;this._rearrange(e,s),this._trigger("change",e,this._uiHash());break}return this._contactContainers(e),t.ui.ddmanager&&t.ui.ddmanager.drag(this,e),this._trigger("sort",e,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(e,i){if(e){if(t.ui.ddmanager&&!this.options.dropBehaviour&&t.ui.ddmanager.drop(this,e),this.options.revert){var s=this,n=this.placeholder.offset(),a=this.options.axis,o={};a&&"x"!==a||(o.left=n.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollLeft)),a&&"y"!==a||(o.top=n.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollTop)),this.reverting=!0,t(this.helper).animate(o,parseInt(this.options.revert,10)||500,function(){s._clear(e)})}else this._clear(e,i);return!1}},cancel:function(){if(this.dragging){this._mouseUp({target:null}),"original"===this.options.helper?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var e=this.containers.length-1;e>=0;e--)this.containers[e]._trigger("deactivate",null,this._uiHash(this)),this.containers[e].containerCache.over&&(this.containers[e]._trigger("out",null,this._uiHash(this)),this.containers[e].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),"original"!==this.options.helper&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),t.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?t(this.domPosition.prev).after(this.currentItem):t(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(e){var i=this._getItemsAsjQuery(e&&e.connected),s=[];return e=e||{},t(i).each(function(){var i=(t(e.item||this).attr(e.attribute||"id")||"").match(e.expression||/(.+)[\-=_](.+)/);i&&s.push((e.key||i[1]+"[]")+"="+(e.key&&e.expression?i[1]:i[2]))}),!s.length&&e.key&&s.push(e.key+"="),s.join("&")},toArray:function(e){var i=this._getItemsAsjQuery(e&&e.connected),s=[];return e=e||{},i.each(function(){s.push(t(e.item||this).attr(e.attribute||"id")||"")}),s},_intersectsWith:function(t){var e=this.positionAbs.left,i=e+this.helperProportions.width,s=this.positionAbs.top,n=s+this.helperProportions.height,a=t.left,o=a+t.width,r=t.top,h=r+t.height,l=this.offset.click.top,c=this.offset.click.left,u="x"===this.options.axis||s+l>r&&h>s+l,d="y"===this.options.axis||e+c>a&&o>e+c,p=u&&d;return"pointer"===this.options.tolerance||this.options.forcePointerForContainers||"pointer"!==this.options.tolerance&&this.helperProportions[this.floating?"width":"height"]>t[this.floating?"width":"height"]?p:e+this.helperProportions.width/2>a&&o>i-this.helperProportions.width/2&&s+this.helperProportions.height/2>r&&h>n-this.helperProportions.height/2},_intersectsWithPointer:function(t){var i="x"===this.options.axis||e(this.positionAbs.top+this.offset.click.top,t.top,t.height),s="y"===this.options.axis||e(this.positionAbs.left+this.offset.click.left,t.left,t.width),n=i&&s,a=this._getDragVerticalDirection(),o=this._getDragHorizontalDirection();return n?this.floating?o&&"right"===o||"down"===a?2:1:a&&("down"===a?2:1):!1},_intersectsWithSides:function(t){var i=e(this.positionAbs.top+this.offset.click.top,t.top+t.height/2,t.height),s=e(this.positionAbs.left+this.offset.click.left,t.left+t.width/2,t.width),n=this._getDragVerticalDirection(),a=this._getDragHorizontalDirection();return this.floating&&a?"right"===a&&s||"left"===a&&!s:n&&("down"===n&&i||"up"===n&&!i)},_getDragVerticalDirection:function(){var t=this.positionAbs.top-this.lastPositionAbs.top;return 0!==t&&(t>0?"down":"up")},_getDragHorizontalDirection:function(){var t=this.positionAbs.left-this.lastPositionAbs.left;return 0!==t&&(t>0?"right":"left")},refresh:function(t){return this._refreshItems(t),this.refreshPositions(),this},_connectWith:function(){var t=this.options;return t.connectWith.constructor===String?[t.connectWith]:t.connectWith},_getItemsAsjQuery:function(e){var i,s,n,a,o=[],r=[],h=this._connectWith();if(h&&e)for(i=h.length-1;i>=0;i--)for(n=t(h[i]),s=n.length-1;s>=0;s--)a=t.data(n[s],this.widgetFullName),a&&a!==this&&!a.options.disabled&&r.push([t.isFunction(a.options.items)?a.options.items.call(a.element):t(a.options.items,a.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),a]);for(r.push([t.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):t(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]),i=r.length-1;i>=0;i--)r[i][0].each(function(){o.push(this)});return t(o)},_removeCurrentsFromItems:function(){var e=this.currentItem.find(":data("+this.widgetName+"-item)");this.items=t.grep(this.items,function(t){for(var i=0;e.length>i;i++)if(e[i]===t.item[0])return!1;return!0})},_refreshItems:function(e){this.items=[],this.containers=[this];var i,s,n,a,o,r,h,l,c=this.items,u=[[t.isFunction(this.options.items)?this.options.items.call(this.element[0],e,{item:this.currentItem}):t(this.options.items,this.element),this]],d=this._connectWith();if(d&&this.ready)for(i=d.length-1;i>=0;i--)for(n=t(d[i]),s=n.length-1;s>=0;s--)a=t.data(n[s],this.widgetFullName),a&&a!==this&&!a.options.disabled&&(u.push([t.isFunction(a.options.items)?a.options.items.call(a.element[0],e,{item:this.currentItem}):t(a.options.items,a.element),a]),this.containers.push(a));for(i=u.length-1;i>=0;i--)for(o=u[i][1],r=u[i][0],s=0,l=r.length;l>s;s++)h=t(r[s]),h.data(this.widgetName+"-item",o),c.push({item:h,instance:o,width:0,height:0,left:0,top:0})},refreshPositions:function(e){this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset());var i,s,n,a;for(i=this.items.length-1;i>=0;i--)s=this.items[i],s.instance!==this.currentContainer&&this.currentContainer&&s.item[0]!==this.currentItem[0]||(n=this.options.toleranceElement?t(this.options.toleranceElement,s.item):s.item,e||(s.width=n.outerWidth(),s.height=n.outerHeight()),a=n.offset(),s.left=a.left,s.top=a.top);if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(i=this.containers.length-1;i>=0;i--)a=this.containers[i].element.offset(),this.containers[i].containerCache.left=a.left,this.containers[i].containerCache.top=a.top,this.containers[i].containerCache.width=this.containers[i].element.outerWidth(),this.containers[i].containerCache.height=this.containers[i].element.outerHeight();return this},_createPlaceholder:function(e){e=e||this;var i,s=e.options;s.placeholder&&s.placeholder.constructor!==String||(i=s.placeholder,s.placeholder={element:function(){var s=e.currentItem[0].nodeName.toLowerCase(),n=t("<"+s+">",e.document[0]).addClass(i||e.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper");return"tr"===s?e.currentItem.children().each(function(){t("<td>&#160;</td>",e.document[0]).attr("colspan",t(this).attr("colspan")||1).appendTo(n)}):"img"===s&&n.attr("src",e.currentItem.attr("src")),i||n.css("visibility","hidden"),n},update:function(t,n){(!i||s.forcePlaceholderSize)&&(n.height()||n.height(e.currentItem.innerHeight()-parseInt(e.currentItem.css("paddingTop")||0,10)-parseInt(e.currentItem.css("paddingBottom")||0,10)),n.width()||n.width(e.currentItem.innerWidth()-parseInt(e.currentItem.css("paddingLeft")||0,10)-parseInt(e.currentItem.css("paddingRight")||0,10)))}}),e.placeholder=t(s.placeholder.element.call(e.element,e.currentItem)),e.currentItem.after(e.placeholder),s.placeholder.update(e,e.placeholder)},_contactContainers:function(s){var n,a,o,r,h,l,c,u,d,p,f=null,m=null;for(n=this.containers.length-1;n>=0;n--)if(!t.contains(this.currentItem[0],this.containers[n].element[0]))if(this._intersectsWith(this.containers[n].containerCache)){if(f&&t.contains(this.containers[n].element[0],f.element[0]))continue;f=this.containers[n],m=n}else this.containers[n].containerCache.over&&(this.containers[n]._trigger("out",s,this._uiHash(this)),this.containers[n].containerCache.over=0);if(f)if(1===this.containers.length)this.containers[m].containerCache.over||(this.containers[m]._trigger("over",s,this._uiHash(this)),this.containers[m].containerCache.over=1);else{for(o=1e4,r=null,p=f.floating||i(this.currentItem),h=p?"left":"top",l=p?"width":"height",c=this.positionAbs[h]+this.offset.click[h],a=this.items.length-1;a>=0;a--)t.contains(this.containers[m].element[0],this.items[a].item[0])&&this.items[a].item[0]!==this.currentItem[0]&&(!p||e(this.positionAbs.top+this.offset.click.top,this.items[a].top,this.items[a].height))&&(u=this.items[a].item.offset()[h],d=!1,Math.abs(u-c)>Math.abs(u+this.items[a][l]-c)&&(d=!0,u+=this.items[a][l]),o>Math.abs(u-c)&&(o=Math.abs(u-c),r=this.items[a],this.direction=d?"up":"down"));if(!r&&!this.options.dropOnEmpty)return;if(this.currentContainer===this.containers[m])return;r?this._rearrange(s,r,null,!0):this._rearrange(s,null,this.containers[m].element,!0),this._trigger("change",s,this._uiHash()),this.containers[m]._trigger("change",s,this._uiHash(this)),this.currentContainer=this.containers[m],this.options.placeholder.update(this.currentContainer,this.placeholder),this.containers[m]._trigger("over",s,this._uiHash(this)),this.containers[m].containerCache.over=1}},_createHelper:function(e){var i=this.options,s=t.isFunction(i.helper)?t(i.helper.apply(this.element[0],[e,this.currentItem])):"clone"===i.helper?this.currentItem.clone():this.currentItem;return s.parents("body").length||t("parent"!==i.appendTo?i.appendTo:this.currentItem[0].parentNode)[0].appendChild(s[0]),s[0]===this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),(!s[0].style.width||i.forceHelperSize)&&s.width(this.currentItem.width()),(!s[0].style.height||i.forceHelperSize)&&s.height(this.currentItem.height()),s},_adjustOffsetFromHelper:function(e){"string"==typeof e&&(e=e.split(" ")),t.isArray(e)&&(e={left:+e[0],top:+e[1]||0}),"left"in e&&(this.offset.click.left=e.left+this.margins.left),"right"in e&&(this.offset.click.left=this.helperProportions.width-e.right+this.margins.left),"top"in e&&(this.offset.click.top=e.top+this.margins.top),"bottom"in e&&(this.offset.click.top=this.helperProportions.height-e.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var e=this.offsetParent.offset();return"absolute"===this.cssPosition&&this.scrollParent[0]!==document&&t.contains(this.scrollParent[0],this.offsetParent[0])&&(e.left+=this.scrollParent.scrollLeft(),e.top+=this.scrollParent.scrollTop()),(this.offsetParent[0]===document.body||this.offsetParent[0].tagName&&"html"===this.offsetParent[0].tagName.toLowerCase()&&t.ui.ie)&&(e={top:0,left:0}),{top:e.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:e.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"===this.cssPosition){var t=this.currentItem.position();return{top:t.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:t.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var e,i,s,n=this.options;"parent"===n.containment&&(n.containment=this.helper[0].parentNode),("document"===n.containment||"window"===n.containment)&&(this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,t("document"===n.containment?document:window).width()-this.helperProportions.width-this.margins.left,(t("document"===n.containment?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]),/^(document|window|parent)$/.test(n.containment)||(e=t(n.containment)[0],i=t(n.containment).offset(),s="hidden"!==t(e).css("overflow"),this.containment=[i.left+(parseInt(t(e).css("borderLeftWidth"),10)||0)+(parseInt(t(e).css("paddingLeft"),10)||0)-this.margins.left,i.top+(parseInt(t(e).css("borderTopWidth"),10)||0)+(parseInt(t(e).css("paddingTop"),10)||0)-this.margins.top,i.left+(s?Math.max(e.scrollWidth,e.offsetWidth):e.offsetWidth)-(parseInt(t(e).css("borderLeftWidth"),10)||0)-(parseInt(t(e).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,i.top+(s?Math.max(e.scrollHeight,e.offsetHeight):e.offsetHeight)-(parseInt(t(e).css("borderTopWidth"),10)||0)-(parseInt(t(e).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top])},_convertPositionTo:function(e,i){i||(i=this.position);var s="absolute"===e?1:-1,n="absolute"!==this.cssPosition||this.scrollParent[0]!==document&&t.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,a=/(html|body)/i.test(n[0].tagName);return{top:i.top+this.offset.relative.top*s+this.offset.parent.top*s-("fixed"===this.cssPosition?-this.scrollParent.scrollTop():a?0:n.scrollTop())*s,left:i.left+this.offset.relative.left*s+this.offset.parent.left*s-("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():a?0:n.scrollLeft())*s}},_generatePosition:function(e){var i,s,n=this.options,a=e.pageX,o=e.pageY,r="absolute"!==this.cssPosition||this.scrollParent[0]!==document&&t.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,h=/(html|body)/i.test(r[0].tagName);return"relative"!==this.cssPosition||this.scrollParent[0]!==document&&this.scrollParent[0]!==this.offsetParent[0]||(this.offset.relative=this._getRelativeOffset()),this.originalPosition&&(this.containment&&(e.pageX-this.offset.click.left<this.containment[0]&&(a=this.containment[0]+this.offset.click.left),e.pageY-this.offset.click.top<this.containment[1]&&(o=this.containment[1]+this.offset.click.top),e.pageX-this.offset.click.left>this.containment[2]&&(a=this.containment[2]+this.offset.click.left),e.pageY-this.offset.click.top>this.containment[3]&&(o=this.containment[3]+this.offset.click.top)),n.grid&&(i=this.originalPageY+Math.round((o-this.originalPageY)/n.grid[1])*n.grid[1],o=this.containment?i-this.offset.click.top>=this.containment[1]&&i-this.offset.click.top<=this.containment[3]?i:i-this.offset.click.top>=this.containment[1]?i-n.grid[1]:i+n.grid[1]:i,s=this.originalPageX+Math.round((a-this.originalPageX)/n.grid[0])*n.grid[0],a=this.containment?s-this.offset.click.left>=this.containment[0]&&s-this.offset.click.left<=this.containment[2]?s:s-this.offset.click.left>=this.containment[0]?s-n.grid[0]:s+n.grid[0]:s)),{top:o-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():h?0:r.scrollTop()),left:a-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():h?0:r.scrollLeft())}},_rearrange:function(t,e,i,s){i?i[0].appendChild(this.placeholder[0]):e.item[0].parentNode.insertBefore(this.placeholder[0],"down"===this.direction?e.item[0]:e.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var n=this.counter;this._delay(function(){n===this.counter&&this.refreshPositions(!s)})},_clear:function(t,e){this.reverting=!1;var i,s=[];if(!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null,this.helper[0]===this.currentItem[0]){for(i in this._storedCSS)("auto"===this._storedCSS[i]||"static"===this._storedCSS[i])&&(this._storedCSS[i]="");this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();for(this.fromOutside&&!e&&s.push(function(t){this._trigger("receive",t,this._uiHash(this.fromOutside))}),!this.fromOutside&&this.domPosition.prev===this.currentItem.prev().not(".ui-sortable-helper")[0]&&this.domPosition.parent===this.currentItem.parent()[0]||e||s.push(function(t){this._trigger("update",t,this._uiHash())}),this!==this.currentContainer&&(e||(s.push(function(t){this._trigger("remove",t,this._uiHash())}),s.push(function(t){return function(e){t._trigger("receive",e,this._uiHash(this))}}.call(this,this.currentContainer)),s.push(function(t){return function(e){t._trigger("update",e,this._uiHash(this))}}.call(this,this.currentContainer)))),i=this.containers.length-1;i>=0;i--)e||s.push(function(t){return function(e){t._trigger("deactivate",e,this._uiHash(this))}}.call(this,this.containers[i])),this.containers[i].containerCache.over&&(s.push(function(t){return function(e){t._trigger("out",e,this._uiHash(this))}}.call(this,this.containers[i])),this.containers[i].containerCache.over=0);if(this.storedCursor&&(this.document.find("body").css("cursor",this.storedCursor),this.storedStylesheet.remove()),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex","auto"===this._storedZIndex?"":this._storedZIndex),this.dragging=!1,this.cancelHelperRemoval){if(!e){for(this._trigger("beforeStop",t,this._uiHash()),i=0;s.length>i;i++)s[i].call(this,t);this._trigger("stop",t,this._uiHash())}return this.fromOutside=!1,!1}if(e||this._trigger("beforeStop",t,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.helper[0]!==this.currentItem[0]&&this.helper.remove(),this.helper=null,!e){for(i=0;s.length>i;i++)s[i].call(this,t);this._trigger("stop",t,this._uiHash())}return this.fromOutside=!1,!0},_trigger:function(){t.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(e){var i=e||this;return{helper:i.helper,placeholder:i.placeholder||t([]),position:i.position,originalPosition:i.originalPosition,offset:i.positionAbs,item:i.currentItem,sender:e?e.element:null}}})})(jQuery);(function(t){function e(e,i){var s=(e.attr("aria-describedby")||"").split(/\s+/);s.push(i),e.data("ui-tooltip-id",i).attr("aria-describedby",t.trim(s.join(" ")))}function i(e){var i=e.data("ui-tooltip-id"),s=(e.attr("aria-describedby")||"").split(/\s+/),n=t.inArray(i,s);-1!==n&&s.splice(n,1),e.removeData("ui-tooltip-id"),s=t.trim(s.join(" ")),s?e.attr("aria-describedby",s):e.removeAttr("aria-describedby")}var s=0;t.widget("ui.tooltip",{version:"1.10.3",options:{content:function(){var e=t(this).attr("title")||"";return t("<a>").text(e).html()},hide:!0,items:"[title]:not([disabled])",position:{my:"left top+15",at:"left bottom",collision:"flipfit flip"},show:!0,tooltipClass:null,track:!1,close:null,open:null},_create:function(){this._on({mouseover:"open",focusin:"open"}),this.tooltips={},this.parents={},this.options.disabled&&this._disable()},_setOption:function(e,i){var s=this;return"disabled"===e?(this[i?"_disable":"_enable"](),this.options[e]=i,void 0):(this._super(e,i),"content"===e&&t.each(this.tooltips,function(t,e){s._updateContent(e)}),void 0)},_disable:function(){var e=this;t.each(this.tooltips,function(i,s){var n=t.Event("blur");n.target=n.currentTarget=s[0],e.close(n,!0)}),this.element.find(this.options.items).addBack().each(function(){var e=t(this);e.is("[title]")&&e.data("ui-tooltip-title",e.attr("title")).attr("title","")})},_enable:function(){this.element.find(this.options.items).addBack().each(function(){var e=t(this);e.data("ui-tooltip-title")&&e.attr("title",e.data("ui-tooltip-title"))})},open:function(e){var i=this,s=t(e?e.target:this.element).closest(this.options.items);s.length&&!s.data("ui-tooltip-id")&&(s.attr("title")&&s.data("ui-tooltip-title",s.attr("title")),s.data("ui-tooltip-open",!0),e&&"mouseover"===e.type&&s.parents().each(function(){var e,s=t(this);s.data("ui-tooltip-open")&&(e=t.Event("blur"),e.target=e.currentTarget=this,i.close(e,!0)),s.attr("title")&&(s.uniqueId(),i.parents[this.id]={element:this,title:s.attr("title")},s.attr("title",""))}),this._updateContent(s,e))},_updateContent:function(t,e){var i,s=this.options.content,n=this,a=e?e.type:null;return"string"==typeof s?this._open(e,t,s):(i=s.call(t[0],function(i){t.data("ui-tooltip-open")&&n._delay(function(){e&&(e.type=a),this._open(e,t,i)})}),i&&this._open(e,t,i),void 0)},_open:function(i,s,n){function a(t){l.of=t,o.is(":hidden")||o.position(l)}var o,r,h,l=t.extend({},this.options.position);if(n){if(o=this._find(s),o.length)return o.find(".ui-tooltip-content").html(n),void 0;s.is("[title]")&&(i&&"mouseover"===i.type?s.attr("title",""):s.removeAttr("title")),o=this._tooltip(s),e(s,o.attr("id")),o.find(".ui-tooltip-content").html(n),this.options.track&&i&&/^mouse/.test(i.type)?(this._on(this.document,{mousemove:a}),a(i)):o.position(t.extend({of:s},this.options.position)),o.hide(),this._show(o,this.options.show),this.options.show&&this.options.show.delay&&(h=this.delayedShow=setInterval(function(){o.is(":visible")&&(a(l.of),clearInterval(h))},t.fx.interval)),this._trigger("open",i,{tooltip:o}),r={keyup:function(e){if(e.keyCode===t.ui.keyCode.ESCAPE){var i=t.Event(e);i.currentTarget=s[0],this.close(i,!0)}},remove:function(){this._removeTooltip(o)}},i&&"mouseover"!==i.type||(r.mouseleave="close"),i&&"focusin"!==i.type||(r.focusout="close"),this._on(!0,s,r)}},close:function(e){var s=this,n=t(e?e.currentTarget:this.element),a=this._find(n);this.closing||(clearInterval(this.delayedShow),n.data("ui-tooltip-title")&&n.attr("title",n.data("ui-tooltip-title")),i(n),a.stop(!0),this._hide(a,this.options.hide,function(){s._removeTooltip(t(this))}),n.removeData("ui-tooltip-open"),this._off(n,"mouseleave focusout keyup"),n[0]!==this.element[0]&&this._off(n,"remove"),this._off(this.document,"mousemove"),e&&"mouseleave"===e.type&&t.each(this.parents,function(e,i){t(i.element).attr("title",i.title),delete s.parents[e]}),this.closing=!0,this._trigger("close",e,{tooltip:a}),this.closing=!1)},_tooltip:function(e){var i="ui-tooltip-"+s++,n=t("<div>").attr({id:i,role:"tooltip"}).addClass("ui-tooltip ui-widget ui-corner-all ui-widget-content "+(this.options.tooltipClass||""));return t("<div>").addClass("ui-tooltip-content").appendTo(n),n.appendTo(this.document[0].body),this.tooltips[i]=e,n},_find:function(e){var i=e.data("ui-tooltip-id");return i?t("#"+i):t()},_removeTooltip:function(t){t.remove(),delete this.tooltips[t.attr("id")]},_destroy:function(){var e=this;t.each(this.tooltips,function(i,s){var n=t.Event("blur");n.target=n.currentTarget=s[0],e.close(n,!0),t("#"+i).remove(),s.data("ui-tooltip-title")&&(s.attr("title",s.data("ui-tooltip-title")),s.removeData("ui-tooltip-title"))})}})})(jQuery); \ No newline at end of file