Empty commit

This commit is contained in:
Git 2013-06-06 08:01:03 +00:00
parent 8016cb4277
commit ac26edc0ca
43 changed files with 997 additions and 633 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
config.php
release/*
static/similar
static/stylespreview
*.swp
*.project
*.php~

View File

@ -23,7 +23,10 @@
if (!$Enabled = $Cache->get_value('enabled_'.$UserID)) {
require(SERVER_ROOT.'/classes/mysql.class.php'); //Require the database wrapper
$DB=NEW DB_MYSQL; //Load the database wrapper
$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();
$Cache->cache_value('enabled_'.$UserID, $Enabled, 0);
}

View File

@ -7,7 +7,9 @@ function convert($str) {
//Alternative approach with potential.
function flush() {
global $Cache, $DB;
$DB->query("SELECT Alias, ArticleID FROM wiki_aliases");
$DB->query("
SELECT Alias, ArticleID
FROM wiki_aliases");
$Aliases = $DB->to_array('Alias');
$Cache->cache_value('wiki_aliases', $Aliases, 3600 * 24 * 14); // 2 weeks
}
@ -16,7 +18,9 @@ function to_id($Alias) {
global $Cache, $DB;
$Aliases = $Cache->get_value('wiki_aliases');
if (!$Aliases) {
$DB->query("SELECT Alias, ArticleID FROM wiki_aliases");
$DB->query("
SELECT Alias, ArticleID
FROM wiki_aliases");
$Aliases = $DB->to_array('Alias');
$Cache->cache_value('wiki_aliases', $Aliases, 3600 * 24 * 14); // 2 weeks
}
@ -30,7 +34,10 @@ function flush() {
function to_id($Alias) {
global $DB;
$Alias = $this->convert($Alias);
$DB->query("SELECT ArticleID FROM wiki_aliases WHERE Alias LIKE '$Alias'");
$DB->query("
SELECT ArticleID
FROM wiki_aliases
WHERE Alias LIKE '$Alias'");
list($ArticleID) = $DB->next_record();
return $ArticleID;
}

View File

@ -37,7 +37,8 @@ public static function get_artists($GroupIDs) {
if (empty($IDs)) {
$IDs = "null";
}
$DB->query("SELECT ta.GroupID,
$DB->query("
SELECT ta.GroupID,
ta.ArtistID,
aa.Name,
ta.Importance,
@ -217,11 +218,18 @@ public static function display_artist($Artist, $MakeLink = true, $Escape = true)
public static function delete_artist($ArtistID) {
global $DB, $LoggedUser, $Cache;
$DB->query("SELECT Name FROM artists_group WHERE ArtistID = ".$ArtistID);
$DB->query("
SELECT Name
FROM artists_group
WHERE ArtistID = ".$ArtistID);
list($Name) = $DB->next_record(MYSQLI_NUM, false);
// Delete requests
$DB->query("SELECT RequestID FROM requests_artists WHERE ArtistID=".$ArtistID." AND ArtistID != 0");
$DB->query("
SELECT RequestID
FROM requests_artists
WHERE ArtistID = $ArtistID
AND ArtistID != 0");
$Requests = $DB->to_array();
foreach ($Requests AS $Request) {
list($RequestID) = $Request;
@ -251,7 +259,7 @@ public static function delete_artist($ArtistID) {
} else {
$Username = 'System';
}
Misc::write_log('Artist '.$ArtistID.' ('.$Name.') was deleted by '.$Username);
Misc::write_log("Artist $ArtistID ($Name) was deleted by $Username");
}

View File

@ -85,7 +85,10 @@ public static function all_bookmarks($Type, $UserID = false) {
$CacheKey = 'bookmarks_' . $Type . '_' . $UserID;
if (($Bookmarks = $Cache->get_value($CacheKey)) === false) {
list ($Table, $Col) = self::bookmark_schema($Type);
$DB->query("SELECT $Col FROM $Table WHERE UserID = '$UserID'");
$DB->query("
SELECT $Col
FROM $Table
WHERE UserID = '$UserID'");
$Bookmarks = $DB->collect($Col);
$Cache->cache_value($CacheKey, $Bookmarks, 0);
}

View File

@ -4,7 +4,10 @@ public static function get_comment_count($CollageID) {
global $DB, $Cache;
$NumComments = $Cache->get_value('collage_comments_'.$CollageID);
if ($NumComments === false) {
$DB->query("SELECT COUNT(ID) FROM collages_comments WHERE CollageID = '$CollageID'");
$DB->query("
SELECT COUNT(ID)
FROM collages_comments
WHERE CollageID = '$CollageID'");
list($NumComments) = $DB->next_record();
$Cache->cache_value('collage_comments_'.$CollageID, $NumComments, 0);
}
@ -33,13 +36,19 @@ public static function get_comment_catalogue($CollageID, $CatalogueID) {
public static function increase_subscriptions($CollageID) {
global $DB;
$DB->query("UPDATE collages SET Subscribers = Subscribers + 1 WHERE ID = '$CollageID'");
$DB->query("
UPDATE collages
SET Subscribers = Subscribers + 1
WHERE ID = '$CollageID'");
}
public static function decrease_subscriptions($CollageID) {
global $DB;
$DB->query("UPDATE collages SET Subscribers = IF(Subscribers < 1, 0, Subscribers - 1) WHERE ID = '$CollageID'");
$DB->query("
UPDATE collages
SET Subscribers = IF(Subscribers < 1, 0, Subscribers - 1)
WHERE ID = '$CollageID'");
}
}
}

View File

@ -41,12 +41,14 @@ public static function quote_notify($Body, $PostID, $Page, $PageID) {
//remove any dupes in the array (the fast way)
$Usernames = array_flip(array_flip($Usernames));
$DB->query("SELECT m.ID, p.PushService
FROM users_main AS m
LEFT JOIN users_info AS i ON i.UserID = m.ID
LEFT JOIN users_push_notifications AS p ON p.UserID = m.ID
WHERE m.Username IN ('" . implode("', '", $Usernames) . "')
AND i.NotifyOnQuote = '1' AND i.UserID != $LoggedUser[ID]");
$DB->query("
SELECT m.ID, p.PushService
FROM users_main AS m
LEFT JOIN users_info AS i ON i.UserID = m.ID
LEFT JOIN users_push_notifications AS p ON p.UserID = m.ID
WHERE m.Username IN ('" . implode("', '", $Usernames) . "')
AND i.NotifyOnQuote = '1'
AND i.UserID != $LoggedUser[ID]");
$Results = $DB->to_array();
foreach ($Results as $Result) {
@ -57,8 +59,11 @@ public static function quote_notify($Body, $PostID, $Page, $PageID) {
$PageID = db_string($PageID);
$PostID = db_string($PostID);
$DB->query("INSERT IGNORE INTO users_notify_quoted (UserID, QuoterID, Page, PageID, PostID, Date)
VALUES ('$UserID', '$QuoterID', '$Page', '$PageID', '$PostID', '" . sqltime() . "')");
$DB->query("
INSERT IGNORE INTO users_notify_quoted
(UserID, QuoterID, Page, PageID, PostID, Date)
VALUES
('$UserID', '$QuoterID', '$Page', '$PageID', '$PostID', '" . sqltime() . "')");
$Cache->delete_value('notify_quoted_' . $UserID);
}

View File

@ -24,7 +24,10 @@ function make_tree() {
?>
<div class="invitetree pad">
<?
$DB->query("SELECT TreePosition, TreeID, TreeLevel FROM invite_tree WHERE UserID=$UserID");
$DB->query("
SELECT TreePosition, TreeID, TreeLevel
FROM invite_tree
WHERE UserID = $UserID");
list($TreePosition, $TreeID, $TreeLevel) = $DB->next_record(MYSQLI_NUM, false);
if (!$TreeID) {
@ -33,9 +36,9 @@ function make_tree() {
$DB->query("
SELECT TreePosition
FROM invite_tree
WHERE TreeID=$TreeID
AND TreeLevel=$TreeLevel
AND TreePosition>$TreePosition
WHERE TreeID = $TreeID
AND TreeLevel = $TreeLevel
AND TreePosition > $TreePosition
ORDER BY TreePosition ASC
LIMIT 1");
if ($DB->record_count()) {

View File

@ -25,7 +25,10 @@ public static function get_user_info($Username) {
public static function compare_user_with($Username1, $Limit = 15) {
global $Cache, $LoggedUser, $DB;
$DB->query("SELECT username FROM lastfm_users WHERE ID='$LoggedUser[ID]'");
$DB->query("
SELECT username
FROM lastfm_users
WHERE ID='$LoggedUser[ID]'");
if ($DB->record_count() > 0) {
list($Username2) = $DB->next_record();
//Make sure the usernames are in the correct order to avoid dupe cache keys.
@ -104,7 +107,10 @@ public static function clear_cache($Username, $Uid) {
$Cache->delete_value('lastfm_top_artists_' . $Username);
$Cache->delete_value('lastfm_top_albums_' . $Username);
$Cache->delete_value('lastfm_top_tracks_' . $Username);
$DB->query("SELECT username FROM lastfm_users WHERE ID='$LoggedUser[ID]'");
$DB->query("
SELECT username
FROM lastfm_users
WHERE ID='$LoggedUser[ID]'");
if ($DB->record_count() > 0) {
list($Username2) = $DB->next_record();
//Make sure the usernames are in the correct order to avoid dupe cache keys.

View File

@ -108,7 +108,10 @@ public static function send_pm($ToID, $FromID, $Subject, $Body, $ConvID = '') {
$Cache->cache_value('inbox_new_'.$ID, $UnRead);
}
$DB->query("SELECT Username FROM users_main WHERE ID = '$FromID'");
$DB->query("
SELECT Username
FROM users_main
WHERE ID = '$FromID'");
list($SenderName) = $DB->next_record();
foreach ($ToID as $ID) {
$DB->query("
@ -141,7 +144,10 @@ public static function create_thread($ForumID, $AuthorID, $Title, $PostBody) {
return -1;
}
$DB->query("SELECT Username FROM users_main WHERE ID=".$AuthorID);
$DB->query("
SELECT Username
FROM users_main
WHERE ID=".$AuthorID);
if ($DB->record_count() < 1) {
return -2;
}

View File

@ -20,7 +20,10 @@
* Making a query
$DB->query("SELECT * FROM table...");
$DB->query("
SELECT *
FROM table...");
Is functionally equivalent to using mysqli_query("SELECT * FROM table...")
Stores the result set in $this->QueryID
Returns the result set, so you can save it for later (see set_query_id())
@ -48,13 +51,13 @@
* The conventional way of retrieving a row from a result set is as follows:
list($All,$Columns,$That,$You,$Select) = $DB->next_record();
list($All, $Columns, $That, $You, $Select) = $DB->next_record();
-----
* This is how you loop over the result set:
while (list($All,$Columns,$That,$You,$Select) = $DB->next_record()) {
echo "Do stuff with ".$All." of the ".$Columns.$That.$You.$Select;
while (list($All, $Columns, $That, $You, $Select) = $DB->next_record()) {
echo "Do stuff with $All of the ".$Columns.$That.$You.$Select;
}
-----
@ -96,8 +99,12 @@
Example:
$FoodRS = $DB->query("SELECT * FROM food");
$DB->query("SELECT * FROM drink");
$FoodRS = $DB->query("
SELECT *
FROM food");
$DB->query("
SELECT *
FROM drink");
$Drinks = $DB->next_record();
$DB->set_query_id($FoodRS);
$Food = $DB->next_record();

View File

@ -25,7 +25,10 @@ public static function get_permissions($PermissionID) {
global $DB, $Cache;
$Permission = $Cache->get_value('perm_'.$PermissionID);
if (empty($Permission)) {
$DB->query("SELECT p.Level AS Class, p.Values as Permissions, p.Secondary, p.PermittedForums FROM permissions AS p WHERE ID='$PermissionID'");
$DB->query("
SELECT p.Level AS Class, p.Values as Permissions, p.Secondary, p.PermittedForums
FROM permissions AS p
WHERE ID='$PermissionID'");
$Permission = $DB->next_record(MYSQLI_ASSOC, array('Permissions'));
$Permission['Permissions'] = unserialize($Permission['Permissions']);
$Cache->cache_value('perm_'.$PermissionID, $Permission, 2592000);
@ -49,8 +52,10 @@ public static function get_permissions_for_user($UserID, $CustomPermissions = fa
// Fetch custom permissions if they weren't passed in.
if ($CustomPermissions === false) {
$DB->query('SELECT um.CustomPermissions FROM users_main AS um
WHERE um.ID = '.((int)$UserID));
$DB->query('
SELECT um.CustomPermissions
FROM users_main AS um
WHERE um.ID = '.((int)$UserID));
list($CustomPermissions) = $DB->next_record(MYSQLI_NUM, false);
}

View File

@ -8,30 +8,34 @@ class Requests {
public static function update_sphinx_requests($RequestID) {
global $DB, $Cache;
$DB->query("REPLACE INTO sphinx_requests_delta (
ID, UserID, TimeAdded, LastVote, CategoryID, Title,
Year, ReleaseType, CatalogueNumber, BitrateList,
FormatList, MediaList, LogCue, FillerID, TorrentID,
TimeFilled, Visible, Votes, Bounty)
SELECT
ID, r.UserID, UNIX_TIMESTAMP(TimeAdded) AS TimeAdded,
UNIX_TIMESTAMP(LastVote) AS LastVote, CategoryID,
Title, Year, ReleaseType, CatalogueNumber, BitrateList,
FormatList, MediaList, LogCue, FillerID, TorrentID,
UNIX_TIMESTAMP(TimeFilled) AS TimeFilled, Visible,
COUNT(rv.UserID) AS Votes, SUM(rv.Bounty) >> 10 AS Bounty
FROM requests AS r LEFT JOIN requests_votes AS rv ON rv.RequestID=r.ID
wHERE ID = ".$RequestID."
GROUP BY r.ID");
$DB->query("
REPLACE INTO sphinx_requests_delta (
ID, UserID, TimeAdded, LastVote, CategoryID, Title,
Year, ReleaseType, CatalogueNumber, BitrateList,
FormatList, MediaList, LogCue, FillerID, TorrentID,
TimeFilled, Visible, Votes, Bounty)
SELECT
ID, r.UserID, UNIX_TIMESTAMP(TimeAdded) AS TimeAdded,
UNIX_TIMESTAMP(LastVote) AS LastVote, CategoryID,
Title, Year, ReleaseType, CatalogueNumber, BitrateList,
FormatList, MediaList, LogCue, FillerID, TorrentID,
UNIX_TIMESTAMP(TimeFilled) AS TimeFilled, Visible,
COUNT(rv.UserID) AS Votes, SUM(rv.Bounty) >> 10 AS Bounty
FROM requests AS r
LEFT JOIN requests_votes AS rv ON rv.RequestID=r.ID
WHERE ID = $RequestID
GROUP BY r.ID");
$DB->query("UPDATE sphinx_requests_delta
SET ArtistList = (SELECT
GROUP_CONCAT(aa.Name SEPARATOR ' ')
FROM requests_artists AS ra
JOIN artists_alias AS aa ON aa.AliasID=ra.AliasID
WHERE ra.RequestID = ".$RequestID."
GROUP BY NULL)
WHERE ID = ".$RequestID);
$DB->query("
UPDATE sphinx_requests_delta
SET ArtistList = (
SELECT GROUP_CONCAT(aa.Name SEPARATOR ' ')
FROM requests_artists AS ra
JOIN artists_alias AS aa ON aa.AliasID=ra.AliasID
WHERE ra.RequestID = $RequestID
GROUP BY NULL
)
WHERE ID = $RequestID");
$Cache->delete_value('requests_'.$RequestID);
}
@ -72,35 +76,36 @@ public static function get_requests($RequestIDs, $Return = true) {
*/
if (count($NotFound) > 0) {
$DB->query("SELECT
r.ID AS ID,
r.UserID,
u.Username,
r.TimeAdded,
r.LastVote,
r.CategoryID,
r.Title,
r.Year,
r.Image,
r.Description,
r.CatalogueNumber,
r.RecordLabel,
r.ReleaseType,
r.BitrateList,
r.FormatList,
r.MediaList,
r.LogCue,
r.FillerID,
filler.Username,
r.TorrentID,
r.TimeFilled,
r.GroupID,
r.OCLC
FROM requests AS r
LEFT JOIN users_main AS u ON u.ID=r.UserID
LEFT JOIN users_main AS filler ON filler.ID=FillerID AND FillerID!=0
WHERE r.ID IN (".$IDs.")
ORDER BY ID");
$DB->query("
SELECT
r.ID AS ID,
r.UserID,
u.Username,
r.TimeAdded,
r.LastVote,
r.CategoryID,
r.Title,
r.Year,
r.Image,
r.Description,
r.CatalogueNumber,
r.RecordLabel,
r.ReleaseType,
r.BitrateList,
r.FormatList,
r.MediaList,
r.LogCue,
r.FillerID,
filler.Username,
r.TorrentID,
r.TimeFilled,
r.GroupID,
r.OCLC
FROM requests AS r
LEFT JOIN users_main AS u ON u.ID=r.UserID
LEFT JOIN users_main AS filler ON filler.ID=FillerID AND FillerID!=0
WHERE r.ID IN ($IDs)
ORDER BY ID");
$Requests = $DB->to_array();
foreach ($Requests as $Request) {
@ -121,7 +126,10 @@ public static function get_comment_count($RequestID) {
global $Cache, $DB;
$NumComments = $Cache->get_value('request_comments_'.$RequestID);
if ($NumComments === false) {
$DB->query("SELECT COUNT(ID) FROM requests_comments WHERE RequestID = '$RequestID'");
$DB->query("
SELECT COUNT(ID)
FROM requests_comments
WHERE RequestID = '$RequestID'");
list($NumComments) = $DB->next_record();
$Cache->cache_value('request_comments_'.$RequestID, $NumComments, 0);
}

View File

@ -216,12 +216,14 @@
// Enabled - if the user's enabled or not
// Permissions
if (isset($_COOKIE['session'])) { $LoginCookie=$Enc->decrypt($_COOKIE['session']); }
if (isset($_COOKIE['session'])) {
$LoginCookie = $Enc->decrypt($_COOKIE['session']);
}
if (isset($LoginCookie)) {
list($SessionID, $LoggedUser['ID'])=explode("|~|",$Enc->decrypt($LoginCookie));
list($SessionID, $LoggedUser['ID']) = explode("|~|", $Enc->decrypt($LoginCookie));
$LoggedUser['ID'] = (int)$LoggedUser['ID'];
$UserID=$LoggedUser['ID']; //TODO: UserID should not be LoggedUser
$UserID = $LoggedUser['ID']; //TODO: UserID should not be LoggedUser
if (!$LoggedUser['ID'] || !$SessionID) {
logout();
@ -244,14 +246,17 @@
$Cache->cache_value('users_sessions_'.$UserID, $UserSessions, 0);
}
if (!array_key_exists($SessionID,$UserSessions)) {
if (!array_key_exists($SessionID, $UserSessions)) {
logout();
}
// Check if user is enabled
$Enabled = $Cache->get_value('enabled_'.$LoggedUser['ID']);
if ($Enabled === false) {
$DB->query("SELECT Enabled FROM users_main WHERE ID='$LoggedUser[ID]'");
$DB->query("
SELECT Enabled
FROM users_main
WHERE ID='$LoggedUser[ID]'");
list($Enabled) = $DB->next_record();
$Cache->cache_value('enabled_'.$LoggedUser['ID'], $Enabled, 0);
}
@ -336,7 +341,10 @@
if (isset($LoggedUser['Permissions']['site_torrents_notify'])) {
$LoggedUser['Notify'] = $Cache->get_value('notify_filters_'.$LoggedUser['ID']);
if (!is_array($LoggedUser['Notify'])) {
$DB->query("SELECT ID, Label FROM users_notify_filters WHERE UserID='$LoggedUser[ID]'");
$DB->query("
SELECT ID, Label
FROM users_notify_filters
WHERE UserID='$LoggedUser[ID]'");
$LoggedUser['Notify'] = $DB->to_array('ID');
$Cache->cache_value('notify_filters_'.$LoggedUser['ID'], $LoggedUser['Notify'], 2592000);
}
@ -371,7 +379,10 @@
('$LoggedUser[ID]', '$NewIP', '".sqltime()."')");
$ipcc = Tools::geoip($NewIP);
$DB->query("UPDATE users_main SET IP='$NewIP', ipcc='".$ipcc."' WHERE ID='$LoggedUser[ID]'");
$DB->query("
UPDATE users_main
SET IP='$NewIP', ipcc='$ipcc'
WHERE ID='$LoggedUser[ID]'");
$Cache->begin_transaction('user_info_heavy_'.$LoggedUser['ID']);
$Cache->update_row(false, array('IP' => $_SERVER['REMOTE_ADDR']));
$Cache->commit_transaction(0);
@ -383,7 +394,12 @@
// Get stylesheets
$Stylesheets = $Cache->get_value('stylesheets');
if (!is_array($Stylesheets)) {
$DB->query('SELECT ID, LOWER(REPLACE(Name," ","_")) AS Name, Name AS ProperName FROM stylesheets');
$DB->query('
SELECT
ID,
LOWER(REPLACE(Name," ","_")) AS Name,
Name AS ProperName
FROM stylesheets');
$Stylesheets = $DB->to_array('ID', MYSQLI_BOTH);
$Cache->cache_value('stylesheets', $Stylesheets, 600);
}
@ -396,12 +412,10 @@
}
}
$Debug->set_flag('end user handling');
$Debug->set_flag('start function definitions');
/**
* Log out the current session
*/
@ -413,7 +427,10 @@ function logout() {
if ($SessionID) {
$DB->query("DELETE FROM users_sessions WHERE UserID='$LoggedUser[ID]' AND SessionID='".db_string($SessionID)."'");
$DB->query("
DELETE FROM users_sessions
WHERE UserID='$LoggedUser[ID]'
AND SessionID='".db_string($SessionID)."'");
$Cache->begin_transaction('users_sessions_'.$LoggedUser['ID']);
$Cache->delete_row($SessionID);
@ -453,8 +470,6 @@ function authorize($Ajax = false) {
return true;
}
$Debug->set_flag('ending function definitions');
//Include /sections/*/index.php
$Document = basename(parse_url($_SERVER['SCRIPT_FILENAME'], PHP_URL_PATH), '.php');

View File

@ -177,19 +177,28 @@ public static function disable_users($UserIDs, $AdminComment, $BanReason = 1) {
$Cache->delete_value('user_info_heavy_'.$UserID);
$Cache->delete_value('user_stats_'.$UserID);
$DB->query("SELECT SessionID FROM users_sessions WHERE UserID='$UserID' AND Active = 1");
$DB->query("
SELECT SessionID
FROM users_sessions
WHERE UserID='$UserID'
AND Active = 1");
while (list($SessionID) = $DB->next_record()) {
$Cache->delete_value('session_'.$UserID.'_'.$SessionID);
}
$Cache->delete_value('users_sessions_'.$UserID);
$DB->query("DELETE FROM users_sessions WHERE UserID='$UserID'");
$DB->query("
DELETE FROM users_sessions
WHERE UserID='$UserID'");
}
// Remove the users from the tracker.
$DB->query("SELECT torrent_pass FROM users_main WHERE ID in (".implode(', ',$UserIDs).')');
$DB->query("
SELECT torrent_pass
FROM users_main
WHERE ID in (".implode(', ',$UserIDs).')');
$PassKeys = $DB->collect('torrent_pass');
$Concat = '';
foreach ($PassKeys as $PassKey) {

View File

@ -77,9 +77,11 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true,
*/
if (count($NotFound) > 0) {
$DB->query("SELECT
g.ID, g.Name, g.Year, g.RecordLabel, g.CatalogueNumber, g.TagList, g.ReleaseType, g.VanityHouse, g.WikiImage, g.CategoryID
FROM torrents_group AS g WHERE g.ID IN ($IDs)");
$DB->query("
SELECT
g.ID, g.Name, g.Year, g.RecordLabel, g.CatalogueNumber, g.TagList, g.ReleaseType, g.VanityHouse, g.WikiImage, g.CategoryID
FROM torrents_group AS g
WHERE g.ID IN ($IDs)");
while ($Group = $DB->next_record(MYSQLI_ASSOC, true)) {
unset($NotFound[$Group['ID']]);
@ -96,13 +98,14 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true,
}
if ($Torrents) {
$DB->query("SELECT
ID, GroupID, Media, Format, Encoding, RemasterYear, Remastered, RemasterTitle,
RemasterRecordLabel, RemasterCatalogueNumber, Scene, HasLog, HasCue, LogScore,
FileCount, FreeTorrent, Size, Leechers, Seeders, Snatched, Time, ID AS HasFile
FROM torrents AS t
WHERE GroupID IN($IDs)
ORDER BY GroupID, Remastered, (RemasterYear != 0) DESC, RemasterYear, RemasterTitle,
$DB->query("
SELECT
ID, GroupID, Media, Format, Encoding, RemasterYear, Remastered, RemasterTitle,
RemasterRecordLabel, RemasterCatalogueNumber, Scene, HasLog, HasCue, LogScore,
FileCount, FreeTorrent, Size, Leechers, Seeders, Snatched, Time, ID AS HasFile
FROM torrents AS t
WHERE GroupID IN($IDs)
ORDER BY GroupID, Remastered, (RemasterYear != 0) DESC, RemasterYear, RemasterTitle,
RemasterRecordLabel, RemasterCatalogueNumber, Media, Format, Encoding, ID");
while ($Torrent = $DB->next_record(MYSQLI_ASSOC, true)) {
$Found[$Torrent['GroupID']]['Torrents'][$Torrent['ID']] = $Torrent;
@ -211,8 +214,11 @@ public static function torrent_properties(&$Torrent, &$Flags) {
*/
public static function write_group_log($GroupID, $TorrentID, $UserID, $Message, $Hidden) {
global $DB,$Time;
$DB->query("INSERT INTO group_log (GroupID, TorrentID, UserID, Info, Time, Hidden) VALUES ("
.$GroupID.", ".$TorrentID.", ".$UserID.", '".db_string($Message)."', '".sqltime()."', ".$Hidden.")");
$DB->query("
INSERT INTO group_log
(GroupID, TorrentID, UserID, Info, Time, Hidden)
VALUES
($GroupID, $TorrentID, $UserID, '".db_string($Message)."', '".sqltime()."', $Hidden)");
}
@ -223,14 +229,20 @@ public static function write_group_log($GroupID, $TorrentID, $UserID, $Message,
* @param int $GroupID Set it if you have it handy, to save a query. Otherwise, it will be found.
* @param string $OcelotReason The deletion reason for ocelot to report to users.
*/
public static function delete_torrent($ID, $GroupID=0, $OcelotReason=-1) {
public static function delete_torrent($ID, $GroupID = 0, $OcelotReason = -1) {
global $DB, $Cache, $LoggedUser;
if (!$GroupID) {
$DB->query("SELECT GroupID, UserID FROM torrents WHERE ID='$ID'");
$DB->query("
SELECT GroupID, UserID
FROM torrents
WHERE ID='$ID'");
list($GroupID, $UploaderID) = $DB->next_record();
}
if (empty($UserID)) {
$DB->query("SELECT UserID FROM torrents WHERE ID='$ID'");
$DB->query("
SELECT UserID
FROM torrents
WHERE ID='$ID'");
list($UserID) = $DB->next_record();
}
@ -244,14 +256,22 @@ public static function delete_torrent($ID, $GroupID=0, $OcelotReason=-1) {
}
$DB->query("SELECT info_hash FROM torrents WHERE ID = ".$ID);
$DB->query("
SELECT info_hash
FROM torrents
WHERE ID = ".$ID);
list($InfoHash) = $DB->next_record(MYSQLI_BOTH, false);
$DB->query("DELETE FROM torrents WHERE ID = ".$ID);
$DB->query("
DELETE FROM torrents
WHERE ID = ".$ID);
Tracker::update_tracker('delete_torrent', array('info_hash' => rawurlencode($InfoHash), 'id' => $ID, 'reason' => $OcelotReason));
$Cache->decrement('stats_torrent_count');
$DB->query("SELECT COUNT(ID) FROM torrents WHERE GroupID='$GroupID'");
$DB->query("
SELECT COUNT(ID)
FROM torrents
WHERE GroupID='$GroupID'");
list($Count) = $DB->next_record();
if ($Count == 0) {
@ -261,34 +281,56 @@ public static function delete_torrent($ID, $GroupID=0, $OcelotReason=-1) {
}
// Torrent notifications
$DB->query("SELECT UserID FROM users_notify_torrents WHERE TorrentID='$ID'");
$DB->query("
SELECT UserID
FROM users_notify_torrents
WHERE TorrentID='$ID'");
while (list($UserID) = $DB->next_record()) {
$Cache->delete_value('notifications_new_'.$UserID);
}
$DB->query("DELETE FROM users_notify_torrents WHERE TorrentID='$ID'");
$DB->query("
DELETE FROM users_notify_torrents
WHERE TorrentID='$ID'");
$DB->query("UPDATE reportsv2 SET
$DB->query("
UPDATE reportsv2
SET
Status='Resolved',
LastChangeTime='".sqltime()."',
ModComment='Report already dealt with (Torrent deleted)'
WHERE TorrentID=".$ID."
WHERE TorrentID = $ID
AND Status != 'Resolved'");
$Reports = $DB->affected_rows();
if ($Reports) {
$Cache->decrement('num_torrent_reportsv2', $Reports);
}
$DB->query("DELETE FROM torrents_files WHERE TorrentID='$ID'");
$DB->query("DELETE FROM torrents_bad_tags WHERE TorrentID = ".$ID);
$DB->query("DELETE FROM torrents_bad_folders WHERE TorrentID = ".$ID);
$DB->query("DELETE FROM torrents_bad_files WHERE TorrentID = ".$ID);
$DB->query("DELETE FROM torrents_cassette_approved WHERE TorrentID = ".$ID);
$DB->query("DELETE FROM torrents_lossymaster_approved WHERE TorrentID = ".$ID);
$DB->query("DELETE FROM torrents_lossyweb_approved WHERE TorrentID = ".$ID);
$DB->query("
DELETE FROM torrents_files
WHERE TorrentID = '$ID'");
$DB->query("
DELETE FROM torrents_bad_tags
WHERE TorrentID = ".$ID);
$DB->query("
DELETE FROM torrents_bad_folders
WHERE TorrentID = ".$ID);
$DB->query("
DELETE FROM torrents_bad_files
WHERE TorrentID = ".$ID);
$DB->query("
DELETE FROM torrents_cassette_approved
WHERE TorrentID = ".$ID);
$DB->query("
DELETE FROM torrents_lossymaster_approved
WHERE TorrentID = ".$ID);
$DB->query("
DELETE FROM torrents_lossyweb_approved
WHERE TorrentID = ".$ID);
// Tells Sphinx that the group is removed
$DB->query("REPLACE INTO sphinx_delta (ID,Time) VALUES ($ID, UNIX_TIMESTAMP())");
$DB->query("
REPLACE INTO sphinx_delta (ID, Time)
VALUES ($ID, UNIX_TIMESTAMP())");
$Cache->delete_value('torrent_download_'.$ID);
$Cache->delete_value('torrent_group_'.$GroupID);
@ -305,9 +347,12 @@ public static function delete_torrent($ID, $GroupID=0, $OcelotReason=-1) {
public static function delete_group($GroupID) {
global $DB, $Cache;
Misc::write_log("Group ".$GroupID." automatically deleted (No torrents have this group).");
Misc::write_log("Group $GroupID automatically deleted (No torrents have this group).");
$DB->query("SELECT CategoryID FROM torrents_group WHERE ID='$GroupID'");
$DB->query("
SELECT CategoryID
FROM torrents_group
WHERE ID='$GroupID'");
list($Category) = $DB->next_record();
if ($Category == 1) {
$Cache->decrement('stats_album_count');
@ -317,11 +362,19 @@ public static function delete_group($GroupID) {
// Collages
$DB->query("SELECT CollageID FROM collages_torrents WHERE GroupID='$GroupID'");
$DB->query("
SELECT CollageID
FROM collages_torrents
WHERE GroupID='$GroupID'");
if ($DB->record_count() > 0) {
$CollageIDs = $DB->collect('CollageID');
$DB->query("UPDATE collages SET NumTorrents=NumTorrents-1 WHERE ID IN (".implode(', ',$CollageIDs).")");
$DB->query("DELETE FROM collages_torrents WHERE GroupID='$GroupID'");
$DB->query("
UPDATE collages
SET NumTorrents=NumTorrents-1
WHERE ID IN (".implode(', ',$CollageIDs).')');
$DB->query("
DELETE FROM collages_torrents
WHERE GroupID='$GroupID'");
foreach ($CollageIDs as $CollageID) {
$Cache->delete_value('collage_'.$CollageID);
@ -331,10 +384,15 @@ public static function delete_group($GroupID) {
// Artists
// Collect the artist IDs and then wipe the torrents_artist entry
$DB->query("SELECT ArtistID FROM torrents_artists WHERE GroupID = ".$GroupID);
$DB->query("
SELECT ArtistID
FROM torrents_artists
WHERE GroupID = ".$GroupID);
$Artists = $DB->collect('ArtistID');
$DB->query("DELETE FROM torrents_artists WHERE GroupID='$GroupID'");
$DB->query("
DELETE FROM torrents_artists
WHERE GroupID='$GroupID'");
foreach ($Artists as $ArtistID) {
if (empty($ArtistID)) {
@ -365,9 +423,15 @@ public static function delete_group($GroupID) {
}
// Requests
$DB->query("SELECT ID FROM requests WHERE GroupID='$GroupID'");
$DB->query("
SELECT ID
FROM requests
WHERE GroupID='$GroupID'");
$Requests = $DB->collect('ID');
$DB->query("UPDATE requests SET GroupID = NULL WHERE GroupID = '$GroupID'");
$DB->query("
UPDATE requests
SET GroupID = NULL
WHERE GroupID = '$GroupID'");
foreach ($Requests as $RequestID) {
$Cache->delete_value('request_'.$RequestID);
}
@ -404,7 +468,10 @@ public static function update_hash($GroupID) {
WHERE ID='$GroupID'");
// Fetch album vote score
$DB->query("SELECT Score FROM torrents_votes WHERE GroupID=$GroupID");
$DB->query("
SELECT Score
FROM torrents_votes
WHERE GroupID=$GroupID");
if ($DB->record_count()) {
list($VoteScore) = $DB->next_record();
} else {
@ -559,7 +626,11 @@ public static function filelist_get_file($File) {
if ($Spaces = strspn($Name, ' ')) {
$Name = str_replace(' ', '&nbsp;', substr($Name, 0, $Spaces)) . substr($Name, $Spaces);
}
return array('ext' => $FileExt, 'size' => substr($Size, 1, -1), 'name' => substr($Name, 0, -$DelimLen));
return array(
'ext' => $FileExt,
'size' => substr($Size, 1, -1),
'name' => substr($Name, 0, -$DelimLen)
);
}
/**
@ -744,7 +815,10 @@ public static function has_snatched($TorrentID, $AllUsers = false) {
$SnatchedTorrents[$i] = array();
}
// Not found in cache. Since we don't have a suitable index, it's faster to update everything
$DB->query("SELECT fid, tstamp AS TorrentID FROM xbt_snatched WHERE uid='$UserID'");
$DB->query("
SELECT fid, tstamp AS TorrentID
FROM xbt_snatched
WHERE uid = '$UserID'");
while (list($ID) = $DB->next_record(MYSQLI_NUM, false)) {
$SnatchedTorrents[$ID & $LastBucket][(int)$ID] = true;
}
@ -754,7 +828,11 @@ public static function has_snatched($TorrentID, $AllUsers = false) {
return true;
} else {
// Old cache, check if torrent has been snatched recently
$DB->query("SELECT fid FROM xbt_snatched WHERE uid='$UserID' AND tstamp>=$LastUpdate");
$DB->query("
SELECT fid
FROM xbt_snatched
WHERE uid = '$UserID'
AND tstamp >= $LastUpdate");
while (list($ID) = $DB->next_record(MYSQLI_NUM, false)) {
$CurBucketID = $ID & $LastBucket;
if ($SnatchedTorrents[$CurBucketID] === false) {

View File

@ -7,9 +7,10 @@ class USER_RANK {
// Returns a 101 row array (101 percentiles - 0 - 100), with the minimum value for that percentile as the value for each row
// BTW - ingenious
function build_table($MemKey, $Query) {
global $Cache,$DB;
global $Cache, $DB;
$DB->query("DROP TEMPORARY TABLE IF EXISTS temp_stats");
$DB->query("
DROP TEMPORARY TABLE IF EXISTS temp_stats");
$DB->query("
CREATE TEMPORARY TABLE temp_stats (
@ -17,9 +18,13 @@ function build_table($MemKey, $Query) {
Val bigint(20) NOT NULL
);");
$DB->query("INSERT INTO temp_stats (Val) ".$Query);
$DB->query("
INSERT INTO temp_stats (Val) ".
$Query);
$DB->query("SELECT COUNT(ID) FROM temp_stats");
$DB->query("
SELECT COUNT(ID)
FROM temp_stats");
list($UserCount) = $DB->next_record();
$DB->query("

View File

@ -178,7 +178,10 @@ public static function user_heavy_info($UserID) {
}
unset($HeavyInfo['PermittedForums']);
$DB->query("SELECT PermissionID FROM users_levels WHERE UserID = $UserID");
$DB->query("
SELECT PermissionID
FROM users_levels
WHERE UserID = $UserID");
$PermIDs = $DB->collect('PermissionID');
foreach ($PermIDs AS $PermID) {
$Perms = Permissions::get_permissions($PermID);

View File

@ -36,7 +36,10 @@ public static function get_user_votes($UserID) {
$UserVotes = $Cache->get_value('voted_albums_'.$UserID);
if ($UserVotes === false) {
$DB->query('SELECT GroupID, Type FROM users_votes WHERE UserID='.$UserID);
$DB->query('
SELECT GroupID, Type
FROM users_votes
WHERE UserID='.$UserID);
$UserVotes = $DB->to_array('GroupID', MYSQL_ASSOC, false);
$Cache->cache_value('voted_albums_'.$UserID, $UserVotes);
}
@ -55,7 +58,10 @@ public static function get_group_votes($GroupID) {
$GroupVotes = $Cache->get_value('votes_'.$GroupID);
if ($GroupVotes === false) {
$DB->query("SELECT Ups AS Ups, Total AS Total FROM torrents_votes WHERE GroupID=$GroupID");
$DB->query("
SELECT Ups AS Ups, Total AS Total
FROM torrents_votes
WHERE GroupID = $GroupID");
if ($DB->record_count() == 0) {
$GroupVotes = array('Ups'=>0, 'Total'=>0);
} else {
@ -166,8 +172,10 @@ public static function binomial_score($Ups, $Total) {
if (($Total <= 0) || ($Ups < 0)) {
return 0;
}
$phat = $Ups/$Total;
return ($phat + Z_VAL*Z_VAL/(2*$Total) - Z_VAL*sqrt(($phat*(1-$phat)+Z_VAL*Z_VAL/(4*$Total))/$Total))/(1+Z_VAL*Z_VAL/$Total);
$phat = $Ups / $Total;
$Numerator = ($phat + Z_VAL * Z_VAL / (2 * $Total) - Z_VAL * sqrt(($phat * (1 - $phat) + Z_VAL * Z_VAL / (4 * $Total)) / $Total));
$Denominator = (1 + Z_VAL * Z_VAL / $Total);
return ($Numerator / $Denominator);
}
/**
@ -207,14 +215,18 @@ public static function get_rank_all($GroupID) {
if ($Rankings === false) {
$Rankings = array();
$i = 0;
$DB->query("SELECT GroupID FROM torrents_votes ORDER BY Score DESC LIMIT 100");
$DB->query("
SELECT GroupID
FROM torrents_votes
ORDER BY Score DESC
LIMIT 100");
while (list($GID) = $DB->next_record()) {
$Rankings[$GID] = ++$i;
}
$Cache->cache_value('voting_ranks_overall', $Rankings, 259200); // 3 days
}
return isset($Rankings[$GroupID])?$Rankings[$GroupID]:false;
return (isset($Rankings[$GroupID]) ? $Rankings[$GroupID] : false);
}
/**
@ -238,18 +250,20 @@ public static function get_rank_year($GroupID, $Year) {
if ($Rankings === false) {
$Rankings = array();
$i = 0;
$DB->query("SELECT GroupID
FROM torrents_votes AS v
JOIN torrents_group AS g ON g.ID = v.GroupID
WHERE g.Year = $Year
ORDER BY Score DESC LIMIT 100");
$DB->query("
SELECT GroupID
FROM torrents_votes AS v
JOIN torrents_group AS g ON g.ID = v.GroupID
WHERE g.Year = $Year
ORDER BY Score DESC
LIMIT 100");
while (list($GID) = $DB->next_record()) {
$Rankings[$GID] = ++$i;
}
$Cache->cache_value('voting_ranks_year_'.$Year , $Rankings, 259200); // 3 days
}
return isset($Rankings[$GroupID])?$Rankings[$GroupID]:false;
return (isset($Rankings[$GroupID]) ? $Rankings[$GroupID] : false);
}
/**
@ -277,19 +291,21 @@ public static function get_rank_decade($GroupID, $Year) {
if ($Rankings === false) {
$Rankings = array();
$i = 0;
$DB->query("SELECT GroupID
FROM torrents_votes AS v
JOIN torrents_group AS g ON g.ID = v.GroupID
WHERE g.Year BETWEEN $Year AND ".($Year+9)."
AND g.CategoryID = 1
ORDER BY Score DESC LIMIT 100");
$DB->query("
SELECT GroupID
FROM torrents_votes AS v
JOIN torrents_group AS g ON g.ID = v.GroupID
WHERE g.Year BETWEEN $Year AND " . ($Year + 9) . "
AND g.CategoryID = 1
ORDER BY Score DESC
LIMIT 100");
while (list($GID) = $DB->next_record()) {
$Rankings[$GID] = ++$i;
}
$Cache->cache_value('voting_ranks_decade_'.$Year , $Rankings, 259200); // 3 days
}
return isset($Rankings[$GroupID])?$Rankings[$GroupID]:false;
return (isset($Rankings[$GroupID]) ? $Rankings[$GroupID] : false);
}
}
?>

View File

@ -271,7 +271,10 @@
if (check_perms('users_mod')) {
global $SBlogReadTime, $LatestSBlogTime;
if (!$SBlogReadTime && ($SBlogReadTime = $Cache->get_value('staff_blog_read_'.$LoggedUser['ID'])) === false) {
$DB->query("SELECT Time FROM staff_blog_visits WHERE UserID = ".$LoggedUser['ID']);
$DB->query("
SELECT Time
FROM staff_blog_visits
WHERE UserID = ".$LoggedUser['ID']);
if (list($SBlogReadTime) = $DB->next_record()) {
$SBlogReadTime = strtotime($SBlogReadTime);
} else {
@ -280,7 +283,9 @@
$Cache->cache_value('staff_blog_read_'.$LoggedUser['ID'], $SBlogReadTime, 1209600);
}
if (!$LatestSBlogTime && ($LatestSBlogTime = $Cache->get_value('staff_blog_latest_time')) === false) {
$DB->query("SELECT MAX(Time) FROM staff_blog");
$DB->query("
SELECT MAX(Time)
FROM staff_blog");
if (list($LatestSBlogTime) = $DB->next_record()) {
$LatestSBlogTime = strtotime($LatestSBlogTime);
} else {
@ -406,7 +411,10 @@
// Torrent reports code
$NumTorrentReports = $Cache->get_value('num_torrent_reportsv2');
if ($NumTorrentReports === false) {
$DB->query("SELECT COUNT(ID) FROM reportsv2 WHERE Status='New'");
$DB->query("
SELECT COUNT(ID)
FROM reportsv2
WHERE Status='New'");
list($NumTorrentReports) = $DB->next_record();
$Cache->cache_value('num_torrent_reportsv2', $NumTorrentReports, 0);
}
@ -416,7 +424,10 @@
// Other reports code
$NumOtherReports = $Cache->get_value('num_other_reports');
if ($NumOtherReports === false) {
$DB->query("SELECT COUNT(ID) FROM reports WHERE Status='New'");
$DB->query("
SELECT COUNT(ID)
FROM reports
WHERE Status='New'");
list($NumOtherReports) = $DB->next_record();
$Cache->cache_value('num_other_reports', $NumOtherReports, 0);
}

View File

@ -135,44 +135,66 @@ function image_height($Type, $Data) {
}
function send_pm($ToID,$FromID,$Subject,$Body,$ConvID='') {
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')");
$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
$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')");
$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
$DB->query("
UPDATE pm_conversations_users
SET
InInbox='1',
UnRead='1',
ReceivedDate='".sqltime()."'
WHERE UserID='$ToID'
WHERE UserID='$ToID'
AND ConvID='$ConvID'");
$DB->query("UPDATE pm_conversations_users SET
$DB->query("
UPDATE pm_conversations_users
SET
InSentbox='1',
SentDate='".sqltime()."'
WHERE UserID='$FromID'
WHERE UserID='$FromID'
AND ConvID='$ConvID'");
}
$DB->query("INSERT INTO pm_messages
(SenderID, ConvID, SentDate, Body) VALUES
('$FromID', '$ConvID', '".sqltime()."', '".$Body."')");
$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'");
/*$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);
@ -218,7 +240,7 @@ function make_utf8($Str) {
$Encoding = 'UTF-8';
}
if (empty($Encoding)) {
$Encoding = mb_detect_encoding($Str,'UTF-8, ISO-8859-1');
$Encoding = mb_detect_encoding($Str, 'UTF-8, ISO-8859-1');
}
if (empty($Encoding)) {
$Encoding = 'ISO-8859-1';
@ -226,7 +248,7 @@ function make_utf8($Str) {
if ($Encoding == 'UTF-8') {
return $Str;
} else {
return @mb_convert_encoding($Str,'UTF-8',$Encoding);
return @mb_convert_encoding($Str, 'UTF-8', $Encoding);
}
}
}

View File

@ -0,0 +1,44 @@
<?
$FeaturedMerchURL = '';
$FeaturedMerch = $Cache->get_value('featured_merch');
if ($FeaturedMerch === false) {
$DB->query('
SELECT ProductID, Title, Image, ArtistID
FROM featured_merch
WHERE Ended = 0');
$FeaturedMerch = $DB->next_record(MYSQLI_ASSOC);
$Cache->cache_value('featured_merch', $FeaturedMerch, 0);
}
if ($FeaturedMerch != null) {
?>
<div id="merchbox" class="box">
<div class="head colhead_dark">
<strong>Featured Product</strong>
</div>
<div class="center">
<a href="http://anonym.to/?<?=$FeaturedMerchURL . $FeaturedMerch['ProductID']?>"><img src="<?=ImageTools::process($FeaturedMerch['Image'])?>" width="100%" alt="Featured Product Image" /></a>
</div>
<div class="center pad">
<a href="http://anonym.to/?<?=$FeaturedMerchURL . $FeaturedMerch['ProductID']?>"><em>Product Page</em></a>
<? if ($FeaturedMerch['ArtistID'] > 0) {
$UserInfo = Users::user_info($FeaturedMerch['ArtistID']);
?> - Artist: <a href="user.php?id=<?=$FeaturedMerch['ArtistID']?>"><?=$UserInfo['Username']?></a>
<? } ?>
</div>
</div>
<? } else { ?>
<div class="box">
<div class="head colhead_dark">
<strong>It's a mystery!</strong>
</div>
<div class="center">
You may want to put an image here.
</div>
</div>
<?
}
?>

View File

@ -30,7 +30,7 @@
<div class="thin">
<div class="sidebar">
<?
include('feat_merch.php');
include('feat_album.php');
if (check_perms('users_mod')) {

View File

@ -39,6 +39,12 @@
}
}
if (substr($_REQUEST['action'],0,16) == 'rerender_gallery' && !isset($argv[1])) {
if (!check_perms('site_debug')) {
error(403);
}
}
include(SERVER_ROOT."/classes/validate.class.php");
$Val = new VALIDATE;

View File

@ -0,0 +1,78 @@
<?
enforce_login();
if (!check_perms('users_mod')) {
error(403);
}
if (!empty($_POST)) {
if (empty($_POST['productid']) || !is_number($_POST['productid'])) {
error('ProductID should be a number...');
header('Location: tools.php?action=featured_merch');
die();
}
$ProductID = (int)$_POST['productid'];
$Title = db_string($_POST['title']);
$Image = db_string($_POST['image']);
$AritstID = ((int)$_POST['artistid'] > 0) ? (int)$_POST['artistid'] : 0;
if (!$Title) {
$Title = db_string('Featured Product');
}
$DB->query("
UPDATE featured_merch
SET Ended = '".sqltime()."'
WHERE Ended = 0");
$DB->query("
INSERT INTO featured_merch (ProductID, Title, Image, ArtistID, Started)
VALUES ($ProductID, '$Title', '$Image', '$ArtistID', '".sqltime()."')");
$Cache->delete_value('featured_merch');
header('Location: index.php');
die();
}
View::show_header();
?>
<h2>Change the featured merchandise</h2>
<div class="thin box pad">
<form action="" method="post">
<input type="hidden" name="action" value="featured_merch" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<table align="center">
<tr>
<td class="label">Product ID:</td>
<td>
<input type="text" name="productid" size="10" />
</td>
</tr>
<tr>
<td class="label">Title:</td>
<td>
<input type="text" name="title" size="30" />
</td>
</tr>
<tr>
<td class="label">Image:</td>
<td>
<input type="text" name="image" size="30" />
</td>
</tr>
<tr>
<td colspan="2" class="center">
<input type="submit" value="Submit" />
</td>
</tr>
<tr>
<td class="label">Artist ID:</td>
<td>
<input type="text" name="artistid" size="10" />
</td>
</tr>
</table>
</form>
</div>
<?
View::show_footer();
?>

View File

@ -1,44 +1,20 @@
<?
if (!isset($_GET['name'])) {
if (!isset($Err)) {
error(404);
}
} else {
$Name = false;
foreach ($Stylesheets as $Stylesheet) {
if ($Stylesheet["Name"] === $_GET['name'])
$Name = $_GET['name'];
}
if (!$Name) {
error(404);
}
if (isset($_GET['format']) && $_GET['format'] === "data") {
global $Cache;
$ImageData = $Cache->get_value("cssgallery_".$Name);
if (!empty($ImageData)) {
echo json_encode(array('data' => $ImageData, 'status' => "0"));
die();
} else {
echo json_encode(array('status' => "-1"));
die();
}
} else {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" style="overflow: hidden !important; margin: 0 !important; padding: 0 !important;">
<head>
<title>Stylesheet Gallery</title>
<meta http-equiv="X-UA-Compatible" content="chrome=1; IE=edge" />
<meta http-equiv="X-UA-Compatible" content="chrome=1;IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="<? echo STATIC_SERVER; ?>styles/global.css?v=<?=filemtime(STATIC_SERVER.'styles/global.css')?>" rel="stylesheet" type="text/css" />
<link href="<? echo STATIC_SERVER; ?>styles/<?= $Name ?>/style.css?v=<?=filemtime(STATIC_SERVER.'styles/'.$Name.'/style.css')?>" title="<?= $Name ?>" rel="stylesheet" type="text/css" media="screen" />
<? if (isset($_GET['save']) && $_GET['save'] === 'true' && check_perms('admin_clear_cache')) { ?>
<script src="<? echo STATIC_SERVER; ?>functions/jquery.js?v=<?=filemtime(STATIC_SERVER.'functions/jquery.js')?>"></script>
<script src="<? echo STATIC_SERVER; ?>functions/stylesheetgallery.js?v=<?=filemtime(STATIC_SERVER.'functions/stylesheetgallery.js')?>"></script>
<? } ?>
<link type="text/css" rel="stylesheet" href="style.css" />
<link type="text/css" rel="stylesheet" href="../global.css" />
<style>
html, body {
width: 1200px !important;
height: 1000px !important;
overflow: hidden !important;
}
</style>
</head>
<body id="user" style="overflow: hidden !important; margin: 0 !important; padding: 0 !important; position: absolute !important;" stylesheet="<?= $Name ?>">
<body id="user" style="overflow: hidden !important; margin: 0 !important; padding: 0 !important; position: absolute !important;">
<div id="wrapper">
<h1 class="hidden">Gazelle</h1>
<div id="header">
@ -110,38 +86,39 @@
<span class="hidden">Artist: </span>
<form class="search_form" name="artists" action="" method="get">
<script type="text/javascript" src="static/functions/autocomplete.js?v=1362029969"></script>
<input id="artistsearch" value="Artists" type="text" name="artistname" size="17" />
<input id="artistsearch" value="Artists" type="text" name="artistname" size="17"/>
<ul id="artistcomplete" style="visibility: hidden;"><li/></ul>
</form>
</li>
<li id="searchbar_requests">
<span class="hidden">Requests: </span>
<form class="search_form" name="requests" action="" method="get">
<input id="requestssearch" value="Requests" type="text" name="search" size="17" />
<input id="requestssearch" value="Requests" type="text" name="search" size="17"/>
</form>
</li>
<li id="searchbar_forums">
<span class="hidden">Forums: </span>
<form class="search_form" name="forums" action="" method="get">
<input value="search" type="hidden" name="action" />
<input id="forumssearch" value="Forums" type="text" name="search" size="17" />
<input id="forumssearch" value="Forums" type="text" name="search" size="17"/>
</form>
</li>
<li id="searchbar_log">
<span class="hidden">Log: </span>
<form class="search_form" name="log" action="" method="get">
<input id="logsearch" value="Log" type="text" name="search" size="17" />
<input id="logsearch" value="Log" type="text" name="search" size="17"/>
</form>
</li>
<li id="searchbar_users">
<span class="hidden">Users: </span>
<form class="search_form" name="users" action="" method="get">
<input type="hidden" name="action" value="search" />
<input id="userssearch" value="Users" type="text" name="search" size="20" />
<input id="userssearch" value="Users" type="text" name="search" size="20"/>
</form>
</li>
</ul>
</div>
</div>
<div id="content">
<div class="thin">
@ -171,7 +148,7 @@
<span title="Jump to last read" class="last_read" style="float: left;">
<a href="#"></a>
</span>
<span class="last_poster" style="float: right;">by <a href="#">Rippy</a> <span title="Aug 14 1992, 18:35" class="time">Just now</span></span>
<span class="last_poster" style="float: right;">by <a href="#">Ananke</a> <span title="Aug 14 1992, 18:35" class="time">Just now</span></span>
</td>
<td>385</td>
<td>95,197</td>
@ -180,7 +157,7 @@
<td title="Read" class="read"></td>
<td>
<h4 class="min_padding">
<a href="#"><?=SITE_NAME?></a>
<a href="#">What.CD</a>
</h4>
</td>
<td>
@ -196,7 +173,8 @@
</table>
<h3>Community</h3>
<table class="forum_index">
<tbody><tr class="colhead">
<tbody>
<tr class="colhead">
<td style="width: 2%;"></td>
<td style="width: 25%;">Forum</td>
<td>Last post</td>
@ -315,13 +293,13 @@
<span title="Jump to last read" class="last_read" style="float: left;">
<a href="#"></a>
</span>
<span class="last_poster" style="float: right;">by <a href="#">Ananke</a> <span class="time">1 min ago</span></span>
<span class="last_poster" style="float: right;">by <a href="#">tuutiki</a> <span class="time">1 min ago</span></span>
</td>
<td>22,564</td>
<td>608,253</td>
</tr>
<tr class="rowa">
<td title="Unead" class="unread"></td>
<td title="Unread" class="unread"></td>
<td>
<h4 class="min_padding">
<a href="#">Vanity House</a>
@ -341,8 +319,12 @@
</div>
</div>
</div>
<div id="extra1"><span></span></div>
<div id="extra2"><span></span></div>
<div id="extra3"><span></span></div>
<div id="extra4"><span></span></div>
<div id="extra5"><span></span></div>
<div id="extra6"><span></span></div>
</div>
</body>
</html>
<?
}
}

View File

@ -0,0 +1,50 @@
var page = require('webpage').create();
var system = require('system');
var fs = require('fs');
var returnStatus = {};
var rootPath = system.args[1];
var staticPath = system.args[2];
var toolsMiscPath = system.args[4];
// Check if all paths are accessible
// We assume at least read rights on all paths and files
if (!fs.isDirectory(rootPath) || !fs.isDirectory(rootPath + '/' + staticPath) || !fs.isDirectory(rootPath + '/' + staticPath + 'styles/' + system.args[3] + '/') || !fs.isDirectory(toolsMiscPath)) {
// Incorrect paths, are they passed correctly?
returnStatus.status = -1;
console.log(JSON.stringify(returnStatus));
phantom.exit();
}
fs.changeWorkingDirectory(toolsMiscPath);
if (!fs.exists('render_base.html')) {
// Rendering base doesn't exist, who broke things?
returnStatus.status = -2;
console.log(JSON.stringify(returnStatus));
phantom.exit();
}
page.open('render_base.html', function () {
// Fixed view size
page.viewportSize = {
width: 1200,
height: 1000
};
// Switch to specific stylesheet subdirectory
fs.changeWorkingDirectory(rootPath + '/' + staticPath + 'styles/' + system.args[3] + '/');
if (!fs.isWritable(fs.workingDirectory)) {
// Don't have write access.
returnStatus.status = -3;
console.log(JSON.stringify(returnStatus));
phantom.exit();
}
fs.write('preview.html', page.content, 'w');
if (!fs.isFile('preview.html')) {
// Failed to store specific preview file.
returnStatus.status = -4;
console.log(JSON.stringify(returnStatus));
phantom.exit();
}
page.close();
returnStatus.status = 0;
console.log(JSON.stringify(returnStatus));
phantom.exit();
});

View File

@ -0,0 +1,77 @@
var page = require('webpage').create();
var system = require('system');
var fs = require('fs');
var returnStatus = {};
var rootPath = system.args[1];
var staticPath = system.args[2];
// Check if all paths are accessible
// We assume at least read rights on all paths and files
if (!fs.isDirectory(rootPath) || !fs.isDirectory(rootPath + '/' + staticPath) || !fs.isDirectory(rootPath + '/' + staticPath + 'styles/' + system.args[3] + '/') || !fs.isDirectory(rootPath + '/' + staticPath + '/stylespreview')) {
//Incorrect paths, are they passed correctly?
returnStatus.status = -1;
console.log(JSON.stringify(returnStatus));
phantom.exit();
}
// Switch to given stylesheet directory
fs.changeWorkingDirectory(rootPath + '/' + staticPath + 'styles/' + system.args[3] + '/');
if (!fs.exists('preview.html')) {
// Preview file doesn't exist. Running things in the wrong order perhaps?
returnStatus.status = -2;
console.log(JSON.stringify(returnStatus));
phantom.exit();
}
// Open the file, start working.
page.open('preview.html', function () {
if (page.framePlainText == "") {
// Preview is empty. Did it get created properly?
returnStatus.status = -3;
console.log(JSON.stringify(returnStatus));
phantom.exit();
}
page.viewportSize = {
width: 1200,
height: 1000
};
// Save files to static
fs.changeWorkingDirectory(rootPath + '/' + staticPath + '/stylespreview');
if (!fs.isWritable(fs.workingDirectory)) {
// Don't have write access.
returnStatus.status = -4;
console.log(JSON.stringify(returnStatus));
phantom.exit();
}
page.render('full_' + system.args[3] + '.png');
if (!fs.isFile('full_' + system.args[3] + '.png')) {
// Failed to store full image.
returnStatus.status = -5;
console.log(JSON.stringify(returnStatus));
phantom.exit();
}
page.viewportSize = {
width: 600,
height: 500
};
page.zoomFactor = 0.5;
page.render('thumb_' + system.args[3] + '.png');
if (!fs.isFile('thumb_' + system.args[3] + '.png')) {
// Failed to store thumbnail image.
returnStatus.status = -6;
console.log(JSON.stringify(returnStatus));
phantom.exit();
}
// Remove temp files
fs.changeWorkingDirectory(rootPath + '/' + staticPath + 'styles/' + system.args[3] + '/');
if (!fs.isFile('preview.html') || !fs.isWritable('preview.html')) {
// Can't find temp file to remove. Are the paths correct?
returnStatus.status = -7;
console.log(JSON.stringify(returnStatus));
phantom.exit();
}
fs.remove('preview.html');
// All good and done
page.close();
returnStatus.status = 0;
console.log(JSON.stringify(returnStatus));
phantom.exit();
});

View File

@ -1,106 +1,115 @@
<?
if (!(check_perms('users_mod') || check_perms('admin_clear_cache'))) {
error(403);
}
// If this is accessed by itself through AJAX (e.g. when already rerendering images)
if (isset($_POST['ajax']) && isset($_POST['image'])) {
if (!isset($_POST['stylesheet']) ) {
echo json_encode(array('status' => "-2"));
die();
}
//Get the actual image data from the sent data string.
$FullData = $_POST['image'];
list($type, $ImageData) = explode(';', $FullData);
list(, $Base64Data) = explode(',', $ImageData);
$Image = base64_decode($Base64Data);
//Save the image to a file
file_put_contents(STATIC_SERVER.'thumb_'.$_POST['stylesheet'].'.png', $Image);
//Check if the file got saved properly, return status message.
if (!file_exists(STATIC_SERVER.'thumb_'.$_POST['stylesheet'].'.png')) {
echo json_encode(array('status' => "-1"));
die();
} else {
echo json_encode(array('status' => "0"));
die();
}
} elseif (!isset($_POST['ajax'])) {
// If this is accessed by the administrating user, display the page (creates calls to itself through AJAX).
View::show_header('Rerender stylesheet gallery images', 'jquery,stylesheetgallery_rerender_queue');
View::show_header('Rerender stylesheet gallery images', 'jquery');
global $DB;
$DB->query('
SELECT
ID,
LOWER(REPLACE(Name," ","_")) AS Name,
Name AS ProperName
FROM stylesheets');
$Styles = $DB->to_array('ID', MYSQLI_BOTH);
?>
<style>
#protected {
position: relative;
}
#protecting_overlay {
display: block;
opacity: 0.01;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.statusbutton > iframe { border: none; }
.statusbutton > iframe[src^="queue_"] { background: none repeat scroll 0 0 gray !important; }
.statusbutton > iframe.finished { background: none repeat scroll 0 0 yellowgreen !important; }
.statusbutton {
overflow: hidden;
width: 10px;
height: 10px;
border-radius: 10px;
display: inline-block;
border: 0px none;
background: red;
box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
margin: 0 2px -1px 0;
}
</style>
<div class="thin">
<h2>Rerender stylesheet gallery images</h2>
<div class="sidebar">
<div class="box box_info box_userinfo_stats">
<div class="head colhead_dark">Color codes</div>
<div class="box box_info">
<div class="head colhead_dark">Rendering parameters</div>
<ul class="stats nobullet">
<li><div class="statusbutton" style="background: gray;"></div> <span> - Queued</span></li>
<li><div class="statusbutton" style="background: yellow;"></div> <span> - Currently encoding render</span></li>
<li><div class="statusbutton" style="background: yellowgreen;"></div> <span> - Rendered successfully</span></li>
<li><div class="statusbutton" style="background: red;"></div> <span> - Rendering returned an error, check console</span></li>
<li><div class="statusbutton" style="background: blue;"></div> <span> - Storage returned an error</span></li>
<li><div class="statusbutton" style="background: purple;"></div> <span> - Incomplete data error</span></li>
<li>Server root: <?= var_dump(SERVER_ROOT); ?></li>
<li>Static server: <?= var_dump(STATIC_SERVER); ?></li>
<li>Whoami: <? echo(shell_exec('whoami')); ?></li>
<li>Path: <? echo dirname(__FILE__); ?></li>
<li>Phantomjs ver: <? echo (shell_exec('/usr/bin/phantomjs -v;')); ?></li>
<li>Styles: <? var_dump($Styles) ?></li>
</ul>
</div>
</div>
<div class="main_column">
<div class="box">
<div class="head">
<span>About rendering</span>
</div>
<div class="head">About rendering</div>
<div class="pad">
<p>You are currently rerendering the stylesheet gallery images. Please don't close this page until rendering is finished or some images may be left unrendered.</p>
<p>This is a processing-intensive operation; you're likely to see a spike in your CPU &amp; RAM usage.</p>
<p>Tested and debugged on up-to-date Webkit and Gecko browsers; Opera will result in undefined behavior.</p>
<p><strong>Important:</strong> Be sure to double-check the gallery once all rendering is finished.</p>
<br />
<a href="#" class="brackets" id="start_rerendering">Begin rendering</a>
<p>You are now rendering stylesheet gallery images.</p>
<p>The used parameters can be seen on the right, returned statuses are displayed below.</p>
</div>
</div>
<div class="box">
<div class="head">
<span>Rendering status</span>
</div>
<div class="pad" id="protected">
<div id="protecting_overlay"></div>
<? foreach ($Stylesheets as $Style) { ?>
<p><span class="statusbutton" style="background: gray;"><iframe src="#" data-src="user.php?action=stylesheetgallery&amp;name=<?= $Style['Name'] ?>&amp;save=true" width="100%" height="100%"></iframe></span> - <?=$Style['Name']?></p>
<? } ?>
<div class="head">Rendering status</div>
<div class="pad">
<?
//set_time_limit(0);
foreach ($Styles as $Style) {
?>
<div class="box">
<h6><?= $Style['Name'] ?></h6>
<p>Build preview:
<?
$BuildResult = json_decode(shell_exec('/usr/bin/phantomjs ' . dirname(__FILE__) . '/render_build_preview.js ' . SERVER_ROOT . ' ' . STATIC_SERVER . ' ' . $Style['Name'] . ' ' . dirname(__FILE__) . ';'), true);
switch ($BuildResult["status"]) {
case 0:
echo "Success.";
break;
case -1:
echo "Err -1: Incorrect paths, are they passed correctly?";
break;
case -2:
echo "Err -2: Rendering base doesn't exist, who broke things?";
break;
case -3:
echo "Err -3: Don't have disk write access.";
break;
case -4:
echo "Err -4: Failed to store specific preview file.";
break;
default:
echo "Err: Unknown error returned";
} ?>
</p>
<?
//If build was successful, snap a preview.
if ($BuildResult["status"] == 0) { ?>
<p>Snap preview:
<?
$SnapResult = json_decode(shell_exec('/usr/bin/phantomjs ' . dirname(__FILE__) . '/render_snap_preview.js ' . SERVER_ROOT . ' ' . STATIC_SERVER . ' ' . $Style['Name'] . ' ' . dirname(__FILE__) . ';'), true);
switch ($SnapResult["status"]) {
case 0:
echo 'Success.';
break;
case -1:
echo 'Err -1: Incorrect paths. Are they passed correctly? Do all folders exist?';
break;
case -2:
echo 'Err -2: Preview file does not exist; running things in the wrong order perhaps?';
break;
case -3:
echo 'Err -3: Preview is empty; did it get created properly?';
break;
case -4:
echo 'Err -4: Do not have disk write access.';
break;
case -5:
echo 'Err -5: Failed to store full image.';
break;
case -6:
echo 'Err -6: Failed to store thumbnail image.';
break;
case -7:
echo 'Err -7: Cannot find temp file to remove; are the paths correct?';
break;
default:
echo 'Err: Unknown error returned.';
}
?>
</p>
<?
}
?>
</div>
<?
};
?>
</div>
</div>
</div>
</div>
<? View::show_footer();
} else {
// Faulty operation, too many parameters or too few, error out.
error(500);
}
?>
<?
View::show_footer();

View File

@ -59,7 +59,7 @@ function checked($Checked) {
$SiteOptions = array();
}
View::show_header($Username.' > Settings','user,jquery,jquery-ui,release_sort,password_validate,validate,push_settings,cssgallery,preview_paranoia');
View::show_header($Username.' > Settings','user,jquery,jquery-ui,release_sort,password_validate,validate,push_settings,cssgallery,preview_paranoia,bbcode');
@ -69,14 +69,13 @@ function checked($Checked) {
WHERE ID = '$UserID'");
$LastFMUsername = '';
list($LastFMUsername) = $DB->next_record();
echo $Val->GenerateJS('userform');
?>
<div class="thin">
<div class="header">
<h2><?=Users::format_username($UserID, false, false, false)?> &gt; Settings</h2>
</div>
<form class="edit_form" name="user" id="userform" action="" method="post" onsubmit="return formVal();" autocomplete="off">
<form class="edit_form" name="user" id="userform" action="" method="post" onsubmit="return userform_submit();" autocomplete="off">
<div>
<input type="hidden" name="action" value="takeedit" />
<input type="hidden" name="userid" value="<?=$UserID?>" />
@ -93,7 +92,7 @@ function checked($Checked) {
<td>
<select name="stylesheet" id="stylesheet">
<? foreach ($Stylesheets as $Style) { ?>
<option value="<?=$Style['ID']?>"<? if ($Style['ID'] == $StyleID) { ?> selected="selected"<? } ?>><?=$Style['ProperName']?></option>
<option value="<?=($Style['ID'])?>"<? if ($Style['ID'] == $StyleID) { ?> selected="selected"<? } ?>><?=($Style['ProperName'])?></option>
<? } ?>
</select>&nbsp;&nbsp;
<a href="#" id="toggle_css_gallery" class="brackets">Show gallery</a>
@ -102,14 +101,28 @@ function checked($Checked) {
<div id="css_gallery">
<? foreach ($Stylesheets as $Style) { ?>
<div class="preview_wrapper">
<div class="preview_image" name="<?=$Style['Name']?>" style="background: url('<?=STATIC_SERVER.'thumb_'.$Style['Name'].'.png'?>') no-repeat scroll center top #CCC;"></div>
<div class="preview_image" name="<?=($Style['Name'])?>" style="background: url('<?=(STATIC_SERVER.'stylespreview/thumb_'.$Style['Name'].'.png')?>') no-repeat scroll center top #CCC;"></div>
<p class="preview_name"><input type="radio" name="stylesheet_gallery" value="<?=($Style['ID'])?>" /> <?=($Style['ProperName'])?></p>
</div>
<? } ?>
</div>
</td>
</tr>
<? if (check_perms('site_advanced_search')) { ?>
<tr>
<td class="label"><strong>OpenDyslexic</strong></td>
<td>
<input type="checkbox" name="useopendyslexic" id="useopendyslexic"<? if (!empty($SiteOptions['UseOpenDyslexic'])) { ?> checked="checked"<? } ?> />
<label for="useopendyslexic">Use the OpenDyslexic font</label>
<p>Read about OpenDyslexic, a <span title="Creative Commons Attribution 3.0 Unported License">CC-BY 3.0</span> licensed font designed for users with dyslexia, at <a href="http://opendyslexic.org" target="_blank">http://opendyslexic.org/</a>.</p>
<p>This is an experimental feature, and some stylesheets will have display issues.</p>
</td>
</tr>
<tr class="colhead_dark">
<td colspan="2">
<strong>Torrent options</strong>
</td>
</tr>
<? if (check_perms('site_advanced_search')) { ?>
<tr>
<td class="label"><strong>Default search type</strong></td>
<td>
@ -119,7 +132,7 @@ function checked($Checked) {
</select>
</td>
</tr>
<? } ?>
<? } ?>
<tr>
<td class="label"><strong>Torrent grouping</strong></td>
<td>
@ -149,16 +162,6 @@ function checked($Checked) {
<label for="showsnatched">Display "Snatched!" next to snatched torrents</label>
</td>
</tr>
<tr>
<td class="label"><strong>Forum posts per page</strong></td>
<td>
<select name="postsperpage" id="postsperpage">
<option value="25"<? if ($SiteOptions['PostsPerPage'] == 25) { ?> selected="selected"<? } ?>>25 (Default)</option>
<option value="50"<? if ($SiteOptions['PostsPerPage'] == 50) { ?> selected="selected"<? } ?>>50</option>
<option value="100"<? if ($SiteOptions['PostsPerPage'] == 100) { ?> selected="selected"<? } ?>>100</option>
</select>
</td>
</tr>
<tr>
<td class="label"><strong>Sort/hide release types</strong></td>
<td>
@ -221,7 +224,7 @@ function checked($Checked) {
<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</label>
</li>
<li>
@ -232,17 +235,32 @@ function checked($Checked) {
</td>
</tr>
<tr>
<td class="label"><strong>Subscription</strong></td>
<td class="label"><strong>Voting links</strong></td>
<td>
<input type="checkbox" name="autosubscribe" id="autosubscribe"<? if (!empty($SiteOptions['AutoSubscribe'])) { ?> checked="checked"<? } ?> />
<label for="autosubscribe">Subscribe to topics when posting</label>
<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>Quote notifications</strong></td>
<td class="label"><strong>Download torrents as text files</strong></td>
<td>
<input type="checkbox" name="notifyquotes" id="notifyquotes"<? if (!empty($SiteOptions['NotifyOnQuote'])) { ?> checked="checked"<? } ?> />
<label for="notifyquotes">Notifications when someone quotes you in the forum</label>
<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>
<tr class="colhead_dark">
<td colspan="2">
<strong>Community options</strong>
</td>
</tr>
<tr>
<td class="label"><strong>Forum posts per page</strong></td>
<td>
<select name="postsperpage" id="postsperpage">
<option value="25"<? if ($SiteOptions['PostsPerPage'] == 25) { ?> selected="selected"<? } ?>>25 (Default)</option>
<option value="50"<? if ($SiteOptions['PostsPerPage'] == 50) { ?> selected="selected"<? } ?>>50</option>
<option value="100"<? if ($SiteOptions['PostsPerPage'] == 100) { ?> selected="selected"<? } ?>>100</option>
</select>
</td>
</tr>
<tr>
@ -266,15 +284,6 @@ function checked($Checked) {
<label for="enablematurecontent">Show mature content</label>
</td>
</tr>
<tr>
<td class="label"><strong>OpenDyslexic</strong></td>
<td>
<input type="checkbox" name="useopendyslexic" id="useopendyslexic"<? if (!empty($SiteOptions['UseOpenDyslexic'])) { ?> checked="checked"<? } ?> />
<label for="useopendyslexic">Use the OpenDyslexic font</label>
<p>Read about OpenDyslexic, a <span title="Creative Commons Attribution 3.0 Unported License">CC-BY 3.0</span> licensed font designed for users with dyslexia, at <a href="http://opendyslexic.org" target="_blank">http://opendyslexic.org/</a>.</p>
<p>This is an experimental feature, and some stylesheets will have display issues.</p>
</td>
</tr>
<tr>
<td class="label"><strong>Avatars</strong></td>
<td>
@ -295,7 +304,6 @@ function checked($Checked) {
</select>
</td>
</tr>
<!---->
<tr>
<td class="label"><strong>Auto-save text</strong></td>
<td>
@ -303,18 +311,23 @@ function checked($Checked) {
<label for="disableautosave">Disable reply text from being saved automatically when changing pages in a thread</label>
</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" <? } ?>/>
<label for="novotelinks">Disable voting links on artist pages, collages, and snatched lists</label>
<tr class="colhead_dark">
<td colspan="2">
<strong>Notifications</strong>
</td>
</tr>
<tr>
<td class="label"><strong>Download torrents as text files</strong></td>
<td class="label"><strong>Subscriptions</strong></td>
<td>
<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>
<input type="checkbox" name="autosubscribe" id="autosubscribe"<? if (!empty($SiteOptions['AutoSubscribe'])) { ?> checked="checked"<? } ?> />
<label for="autosubscribe">Subscribe to topics when posting</label>
</td>
</tr>
<tr>
<td class="label"><strong>Quote notifications</strong></td>
<td>
<input type="checkbox" name="notifyquotes" id="notifyquotes"<? if (!empty($SiteOptions['NotifyOnQuote'])) { ?> checked="checked"<? } ?> />
<label for="notifyquotes">Notifications when someone quotes you in the forum</label>
</td>
</tr>
<tr>
@ -370,7 +383,7 @@ function checked($Checked) {
<td class="label">&nbsp;</td>
<td>
<p><span class="warning">Note: Paranoia has nothing to do with your security on this site; the only thing affected by this setting is other users' ability to see your site activity and taste in music.</span></p>
<p>Select the elements <strong>you want to show</strong> on your profile. For example, if you tick "Show count" for "Snatched", users will be able to see how many torrents you have snatched. If you tick "Show list", they will be able to see the full list of torrents you've snatched.</p>
<p>Select the elements <strong>you want to show</strong> on your profile. For example, if you check "Show count" for "Snatched", users will be able to see how many torrents you have snatched. If you check "Show list", they will be able to see the full list of torrents you have snatched.</p>
<p><span class="warning">Some information will still be available in the site log.</span></p>
</td>
</tr>
@ -558,7 +571,7 @@ function checked($Checked) {
</tr>
<tr>
<td colspan="2" class="right">
<input type="button" value="Save Profile" onclick="userform_submit();"/>
<input type="submit" value="Save Profile" />
</td>
</tr>
</table>

View File

@ -14,9 +14,6 @@
}
switch ($_REQUEST['action']) {
case 'stylesheetgallery':
include('stylesheetgallery.php');
break;
case 'notify':
include('notify_edit.php');
break;

View File

@ -30,15 +30,33 @@
ToYear,
Users
FROM users_notify_filters
WHERE UserID='$LoggedUser[ID]'
UNION ALL
SELECT NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL");
$i = 0;
$NumFilters = $DB->record_count() - 1;
WHERE UserID=$LoggedUser[ID]");
$NumFilters = $DB->record_count();
$Notifications = $DB->to_array();
$Notifications[] = array(
'ID' => false,
'Label' => '',
'Artists' => '',
'ExcludeVA' => false,
'NewGroupsOnly' => true,
'Tags' => '',
'NotTags' => '',
'ReleaseTypes' => '',
'Categories' => '',
'Formats' => '',
'Encodings' => '',
'Media' => '',
'FromYear' => '',
'ToYear' => '',
'Users' => ''
);
$i = 0;
foreach ($Notifications as $N) { // $N stands for Notifications
$i++;
$NewFilter = $N['ID'] === false;
$N['Artists'] = implode(', ', explode('|', substr($N['Artists'], 1, -1)));
$N['Tags'] = implode(', ', explode('|', substr($N['Tags'], 1, -1)));
$N['NotTags'] = implode(', ', explode('|', substr($N['NotTags'], 1, -1)));
@ -62,23 +80,27 @@
if ($N['ToYear'] == 0) {
$N['ToYear'] = '';
}
$i++;
if ($i > $NumFilters && $NumFilters > 0) { ?>
<h3>Create a new notification filter</h3>
if ($NewFilter && $NumFilters > 0) {
?>
<br /><br />
<h3>Create a new notification filter</h3>
<? } elseif ($NumFilters > 0) { ?>
<h3>
<a href="feeds.php?feed=torrents_notify_<?=$N['ID']?>_<?=$LoggedUser['torrent_pass']?>&amp;user=<?=$LoggedUser['ID']?>&amp;auth=<?=$LoggedUser['RSS_Auth']?>&amp;passkey=<?=$LoggedUser['torrent_pass']?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;name=<?=urlencode($N['Label'])?>"><img src="<?=STATIC_SERVER?>/common/symbols/rss.png" alt="RSS feed" /></a>
<?=display_str($N['Label'])?>
<a href="user.php?action=notify_delete&amp;id=<?=$N['ID']?>&amp;auth=<?=$LoggedUser['AuthKey']?>" onclick="return confirm('Are you sure you want to delete this notification filter?')" class="brackets">Delete</a>
<a href="#" onclick="$('#filter_<?=$N['ID']?>').toggle(); return false;" class="brackets">Show</a>
</h3>
<h3>
<a href="feeds.php?feed=torrents_notify_<?=$N['ID']?>_<?=$LoggedUser['torrent_pass']?>&amp;user=<?=$LoggedUser['ID']?>&amp;auth=<?=$LoggedUser['RSS_Auth']?>&amp;passkey=<?=$LoggedUser['torrent_pass']?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;name=<?=urlencode($N['Label'])?>"><img src="<?=STATIC_SERVER?>/common/symbols/rss.png" alt="RSS feed" /></a>
<?=display_str($N['Label'])?>
<a href="user.php?action=notify_delete&amp;id=<?=$N['ID']?>&amp;auth=<?=$LoggedUser['AuthKey']?>" onclick="return confirm('Are you sure you want to delete this notification filter?')" class="brackets">Delete</a>
<a href="#" onclick="$('#filter_<?=$N['ID']?>').toggle(); return false;" class="brackets">Show</a>
</h3>
<? } ?>
<form class="<?=(($i > $NumFilters) ? 'create_form' : 'edit_form')?>" name="notification" action="user.php" method="post">
<form class="<?=($NewFilter ? 'create_form' : 'edit_form')?>" name="notification" action="user.php" method="post">
<input type="hidden" name="formid" value="<?=$i?>" />
<input type="hidden" name="action" value="notify_handle" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<table <?=(($i <= $NumFilters) ? 'id="filter_'.$N['ID'].'" class="layout hidden"' : 'class="layout"')?>>
<? if ($i > $NumFilters) { ?>
<? if (!$NewFilter) { ?>
<input type="hidden" name="id<?=$i?>" value="<?=$N['ID']?>" />
<? } ?>
<table <?=(!$NewFilter ? 'id="filter_'.$N['ID'].'" class="layout hidden"' : 'class="layout"')?>>
<? if ($NewFilter) { ?>
<tr>
<td class="label"><strong>Notification filter name</strong></td>
<td>
@ -91,8 +113,6 @@
<strong>All fields below here are optional</strong>
</td>
</tr>
<? } else { ?>
<input type="hidden" name="id<?=$i?>" value="<?=$N['ID']?>" />
<? } ?>
<tr>
<td class="label"><strong>One of these artists</strong></td>
@ -107,7 +127,7 @@
<td class="label"><strong>One of these users</strong></td>
<td>
<textarea name="users<?=$i?>" style="width: 100%;" rows="5"><?=display_str($Usernames)?></textarea>
<p class="min_padding">Comma-separated list of usernames</em></p>
<p class="min_padding">Comma-separated list of usernames</p>
</td>
</tr>
<tr>
@ -186,14 +206,11 @@
</tr>
<tr>
<td colspan="2" class="center">
<input type="submit" value="<?=(($i > $NumFilters) ? 'Create filter' : 'Update filter')?>" />
<input type="submit" value="<?=($NewFilter ? 'Create filter' : 'Update filter')?>" />
</td>
</tr>
</table>
</form>
<? if ($i == $NumFilters) { ?>
<br /><br />
<? }
} ?>
<? } ?>
</div>
<? View::show_footer(); ?>

View File

@ -46,13 +46,17 @@
</tr>
<?
$DB->query("SELECT Alias FROM wiki_aliases WHERE ArticleID='$ArticleID'");
$DB->query("
SELECT Alias
FROM wiki_aliases
WHERE ArticleID = '$ArticleID'");
while (list($Revision, $Title, $AuthorID, $AuthorName, $Date) = $DB->next_record()) { ?>
<tr>
<td><?=$Revision?></td>
<td><?=$Title?></td>
</tr>
<? } ?>
<?
} ?>
<tr>
<td class="center" colspan="6">
<input type="submit" value="Compare" />

View File

@ -58,7 +58,11 @@ function get_body($ID, $Rev) {
if ($Rev == $Revision) {
$Str = $Body;
} else {
$DB->query("SELECT Body FROM wiki_revisions WHERE ID='$ID' AND Revision='$Rev'");
$DB->query("
SELECT Body
FROM wiki_revisions
WHERE ID='$ID'
AND Revision='$Rev'");
if (!$DB->record_count()) {
error(404);
}

View File

@ -4,7 +4,10 @@
error(404);
}
$DB->query("SELECT Title FROM wiki_articles WHERE ID = $ID");
$DB->query("
SELECT Title
FROM wiki_articles
WHERE ID = $ID");
if ($DB->record_count() < 1) {
error(404);
@ -12,7 +15,7 @@
list($Title) = $DB->next_record(MYSQLI_NUM, false);
//Log
Misc::write_log("Wiki article ".$ID." (".$Title.") was deleted by ".$LoggedUser['Username']);
Misc::write_log("Wiki article $ID ($Title) was deleted by ".$LoggedUser['Username']);
//Delete
$DB->query("DELETE FROM wiki_articles WHERE ID = $ID");
$DB->query("DELETE FROM wiki_aliases WHERE ArticleID = $ID");

View File

@ -55,9 +55,12 @@
$SQL .= "%' ";
}
$SQL.=" ORDER BY $Order $Way LIMIT $Limit ";
$SQL.= "
ORDER BY $Order $Way
LIMIT $Limit ";
$RS = $DB->query($SQL);
$DB->query("SELECT FOUND_ROWS()");
$DB->query("
SELECT FOUND_ROWS()");
list($NumResults) = $DB->next_record();
View::show_header('Search articles');

View File

@ -12,7 +12,10 @@
$Err = $Val->ValidateForm($_POST);
if (!$Err) {
$DB->query("SELECT ID FROM wiki_articles WHERE Title='$P[title]'");
$DB->query("
SELECT ID
FROM wiki_articles
WHERE Title='$P[title]'");
if ($DB->record_count() > 0) {
list($ID) = $DB->next_record();
$Err = 'An article with that name already exists <a href="wiki.php?action=article&amp;id='.$ID.'">here</a>.';
@ -39,29 +42,36 @@
$Edit = $Read; //Human error fix.
}
} else {
$Read=100;
$Edit=100;
$Read = 100;
$Edit = 100;
}
$DB->query("INSERT INTO wiki_articles
(Revision, Title, Body, MinClassRead, MinClassEdit, Date, Author) VALUES
('1', '$P[title]', '$P[body]', '$Read', '$Edit', '".sqltime()."', '$LoggedUser[ID]')");
$DB->query("
INSERT INTO wiki_articles
(Revision, Title, Body, MinClassRead, MinClassEdit, Date, Author)
VALUES
('1', '$P[title]', '$P[body]', '$Read', '$Edit', '".sqltime()."', '$LoggedUser[ID]')");
$ArticleID = $DB->inserted_id();
//$NewAlias = $Alias->convert($_POST['alias']);
//if ($NewAlias != '') {
// $DB->query("INSERT INTO wiki_aliases (Alias, ArticleID) VALUES ('$NewAlias', '$ArticleID')");
//}
/*
$NewAlias = $Alias->convert($_POST['alias']);
if ($NewAlias != '') {
$DB->query("
INSERT INTO wiki_aliases (Alias, ArticleID)
VALUES ('$NewAlias', '$ArticleID')");
}
*/
$TitleAlias = $Alias->convert($_POST['title']);
if ($TitleAlias != $Alias) {
$DB->query("INSERT INTO wiki_aliases (Alias, ArticleID) VALUES ('".db_string($TitleAlias)."', '$ArticleID')");
$DB->query("
INSERT INTO wiki_aliases (Alias, ArticleID)
VALUES ('".db_string($TitleAlias)."', '$ArticleID')");
}
$Alias->flush();
Misc::write_log("Wiki article ".$ArticleID." (".$_POST['title'].") was created by ".$LoggedUser['Username']);
Misc::write_log("Wiki article $ArticleID (".$_POST['title'].") was created by ".$LoggedUser['Username']);
header('Location: wiki.php?action=article&id='.$ArticleID);

View File

@ -1,8 +1,5 @@
(function($) {
/*! jQuery Ajax Queue v0.1.2pre | (c) 2013 Corey Frang | Licensed MIT */
(function(e){var r=e({});e.ajaxQueue=function(n){function t(r){u=e.ajax(n),u.done(a.resolve).fail(a.reject).then(r,r)}var u,a=e.Deferred(),i=a.promise();return r.queue(t),i.abort=function(o){if(u)return u.abort(o);var c=r.queue(),f=e.inArray(t,c);return f>-1&&c.splice(f,1),a.rejectWith(n.context||n,[i,o,""]),i},i}})(jQuery);
//@ sourceMappingURL=dist/jquery.ajaxQueue.min.map
$(document).ready(function () {
// If the custom stylesheet field is empty, select the current style from the previews
if(!$('input#styleurl').val()){

View File

@ -16,7 +16,7 @@ var listener = {
var f = function() {
callback.call(el);
};
el.attachEvent('on'+type, f);
el.attachEvent('on' + type, f);
}
}
};
@ -51,9 +51,9 @@ function html_entity_decode(str) {
function get_size(size) {
var steps = 0;
while (size>=1024) {
while (size >= 1024) {
steps++;
size=size/1024;
size = size / 1024;
}
var ext;
switch(steps) {
@ -107,7 +107,7 @@ function ratio(dividend, divisor, color) {
} else if (dividend == 0 && divisor > 0) {
return '<span class="r00">-∞</span>';
}
var rat = ((dividend/divisor)-0.005).toFixed(2); //Subtract .005 to floor to 2 decimals
var rat = ((dividend / divisor) - 0.005).toFixed(2); //Subtract .005 to floor to 2 decimals
if (color) {
var col = get_ratio_color(rat);
if (col) {
@ -132,7 +132,7 @@ function error_message(message) {
$("#content").raw().insertBefore(messageDiv,$("#content").raw().firstChild);
}
//returns key if true, and false if false better than the php funciton
//returns key if true, and false if false. better than the PHP funciton
function in_array(needle, haystack, strict) {
if (strict === undefined) {
strict = false;
@ -161,7 +161,6 @@ var util = function (selector, context) {
return new util.fn.init(selector, context);
}
util.fn = util.prototype = {
objects: new Array(),
init: function (selector, context) {
@ -191,7 +190,7 @@ util.fn = util.prototype = {
return this;
},
listen: function (event, callback) {
for (var i=0,il=this.objects.length;i<il;i++) {
for (var i = 0, il = this.objects.length; i < il; i++) {
var object = this.objects[i];
if (document.addEventListener) {
object.addEventListener(event, callback, false);
@ -201,15 +200,26 @@ util.fn = util.prototype = {
}
return this;
},
unbind: function (event, callback) {
for (var i = 0, il = this.objects.length; i < il; i++) {
var object = this.objects[i];
if (document.addEventListener) {
object.removeEventListener(event, callback, false);
} else {
object.detachEvent('on' + event, callback);
}
}
return this;
},
remove: function () {
for (var i=0,il=this.objects.length;i<il;i++) {
for (var i = 0, il = this.objects.length; i < il; i++) {
var object = this.objects[i];
object.parentNode.removeChild(object);
}
return this;
},
add_class: function (class_name, force) {
for (var i=0,il=this.objects.length;i<il;i++) {
for (var i = 0, il = this.objects.length; i < il; i++) {
var object = this.objects[i];
if (object.className === '') {
object.className = class_name;
@ -220,7 +230,7 @@ util.fn = util.prototype = {
return this;
},
remove_class: function (class_name) {
for (var i=0,il=this.objects.length;i<il;i++) {
for (var i = 0, il = this.objects.length; i < il; i++) {
var object = this.objects[i];
var classes = object.className.split(' ');
var result = array_search(class_name, classes);
@ -232,7 +242,7 @@ util.fn = util.prototype = {
return this;
},
has_class: function(class_name) {
for (var i=0,il=this.objects.length;i<il;i++) {
for (var i = 0, il = this.objects.length; i < il; i++) {
var object = this.objects[i];
var classes = object.className.split(' ');
if (array_search(class_name, classes)) {
@ -242,7 +252,7 @@ util.fn = util.prototype = {
return false;
},
toggle_class: function(class_name) {
for (var i=0,il=this.objects.length;i<il;i++) {
for (var i = 0, il = this.objects.length; i < il; i++) {
var object = this.objects[i];
var classes = object.className.split(' ');
var result = array_search(class_name, classes);
@ -260,13 +270,13 @@ util.fn = util.prototype = {
return this;
},
disable : function () {
for (var i=0,il=this.objects.length;i<il;i++) {
for (var i = 0, il = this.objects.length; i < il; i++) {
this.objects[i].disabled = true;
}
return this;
},
enable : function () {
for (var i=0,il=this.objects.length;i<il;i++) {
for (var i = 0, il = this.objects.length; i < il; i++) {
if (this.objects[i].disabled == true) {
this.objects[i].disabled = false;
}
@ -274,7 +284,7 @@ util.fn = util.prototype = {
return this;
},
html : function (html) {
for (var i=0,il=this.objects.length;i<il;i++) {
for (var i = 0, il = this.objects.length; i < il; i++) {
this.objects[i].innerHTML = html;
}
return this;
@ -307,6 +317,5 @@ util.fn = util.prototype = {
}
}
util.fn.init.prototype = util.fn;
var $ = util;

File diff suppressed because one or more lines are too long

View File

@ -1,42 +0,0 @@
(function ($){
// Work through the queue of stylesheets
function recursivelyProcessQueue(queue){
// If our work here is done, call it a day.
if(queue.length < 1) return 0;
var nextTarget = queue.pop();
var originalSrc = nextTarget.attr('src');
nextTarget.attr('src', nextTarget.attr('data-src'));
nextTarget.load(function() {
var targetHtml = $(this).contents().find("html");
targetHtml.on('click', function() {
targetHtml.unbind();
recursivelyProcessQueue(queue);
// Avoid unnecessary caching, cahce might lead to undefined behavior.
nextTarget.attr('src', '#');
nextTarget.addClass('finished');
return 0;
})
});
// Be sure to close off.
return 0;
}
$(document).ready(function (){
// Build a queue of stylesheets to be rendered
var queue = [];
$('.statusbutton').children('iframe').each(function() {
var targetDiv = $(this);
queue.push(targetDiv);
});
// We'd prefer to work from top-down, not bottom-up.
queue = queue.reverse();
$('#start_rerendering').click(function(event) {
event.preventDefault();
recursivelyProcessQueue(queue);
$(this).css('text-decoration', 'line-through');
$(this).unbind();
return false;
});
});
})(jQuery);

View File

@ -157,15 +157,12 @@ function ToggleIdenticons() {
}
function userform_submit() {
var userform = jQuery('#userform');
if (jQuery('#resetpasskey').is(':checked')) {
if (confirm('Are you sure you want to reset your passkey?')) {
userform.submit();
if (!confirm('Are you sure you want to reset your passkey?')) {
return false;
}
}
else {
userform.submit();
};
return formVal();
}
function togglePassKey(key) {

View File

@ -67,6 +67,7 @@ function validDate(theDate) {
function showError(fields,alertStr) {
var tField=Array();
var obj, el;
if (typeof(fields) == 'object') {
tField[0] = fields;
@ -74,22 +75,20 @@ function showError(fields,alertStr) {
tField = fields.split(',');
}
for (s = 0; s <= tField.length - 1; s++) {
if ($('#'+tField[s])) {
$('#'+tField[s]).className=$('#'+tField[s]).className+" elem_error";
obj = $('#'+tField[s]);
if (obj) {
el = obj.raw();
obj.add_class("elem_error");
if (s == 0) {
$('#'+tField[s]).focus();
el.focus();
try {
$('#'+tField[s]).select();
el.select();
} catch (error) {
}
}
errorElems[errorElems.length] = tField[s];
if ($('#'+tField[s]).type != "select-one") {
$('#'+tField[s]).onkeypress=function() { clearElemError(); };
} else {
$('#'+tField[s]).onchange=function() { clearElemError(); };
}
var evtType = el.type == "select-one" ? "change" : "keypress";
obj.listen(evtType, clearElemError);
errorElems.push(tField[s]);
}
}
@ -115,14 +114,13 @@ function clearErrors(theForm) {
}
function clearElemError(evt) {
var obj, el;
for (x = 0; x <= errorElems.length - 1; x++) {
elem = $('#'+errorElems[x]);
if ($('#'+elem).type != "select-one") {
$('#'+elem).onkeypress = "";
} else {
$('#'+elem).onchange = "";
}
elem.className = elemStyles[elem.id];
obj = $('#'+errorElems[x]);
el = obj.raw();
var evtType = el.type == "select-one" ? "change" : "keypress";
obj.unbind(evtType, clearElemError);
el.className = elemStyles[el.id];
}
errorElems = Array();
}