Don't reset search options when saving profile settings

Fix expression for cleaning up default search URL

Fix typo preventing threads from being cached

Don't include sticky post in reply count

Cast RemasterYear to int because '0' != ''

Don't compare escaped artist name to unescaped
This commit is contained in:
World Wide Web Owner 2011-04-17 11:05:01 +00:00
parent d3b5585c3e
commit dcbc1b1af7
22 changed files with 48 additions and 50 deletions

View File

@ -71,7 +71,7 @@ function check_paranoia($Property, $Paranoia, $UserClass, $UserID = false) {
case 'snatched': case 'snatched+':
$May = $May || check_perms('site_view_torrent_snatchlist', $UserClass);
break;
case 'uploading': case 'uploading+':
case 'uploads': case 'uploads+':
case 'seeding': case 'seeding+':
case 'leeching': case 'leeching+':
$May = $May || check_perms('users_view_seedleech', $UserClass);

View File

@ -372,7 +372,7 @@ function music_form($GenreTags) {
</select>
<span id="other_bitrate_span"<? if(!$OtherBitrate) { echo ' class="hidden"'; } ?>>
<input type="text" name="other_bitrate" size="5" id="other_bitrate"<? if($OtherBitrate) { echo " value='".display_str($Torrent['Bitrate'])."'";} ?> onchange="AltBitrate()" />
<input type="checkbox" id="vbr" name="vbr"<? if(isset($VBR)) { echo ' checked="checked"'; } ?> /> (VBR)
<input type="checkbox" id="vbr" name="vbr"<? if(isset($VBR)) { echo ' checked="checked"'; } ?> /><label for="vbr"> (VBR)</label>
</span>
</td>
</tr>
@ -572,14 +572,19 @@ function audiobook_form() {
<td>
<select id="bitrate" name="bitrate" onchange="Bitrate()">
<option value="">---</option>
<? if($Torrent['Bitrate'] && !in_array($Torrent['Bitrate'], $this->Bitrates)) {
<?
if($Torrent['Bitrate'] && !in_array($Torrent['Bitrate'], $this->Bitrates)) {
$OtherBitrate = true;
if(substr($Torrent['Bitrate'], strlen($Torrent['Bitrate']) - strlen(" (VBR)")) == " (VBR)") {
$Torrent['Bitrate'] = substr($Torrent['Bitrate'], 0, strlen($Torrent['Bitrate'])-6);
$VBR = true;
}
} else {
$OtherBitrate = false;
}
foreach(display_array($this->Bitrates) as $Bitrate) {
echo "<option value='$Bitrate'";
if($Bitrate == $Torrent['Bitrate']) {
if($Bitrate == $Torrent['Bitrate'] || (!$OtherBitrate || $Bitrate == "Other")) {
echo " selected='selected'";
}
echo ">";
@ -589,10 +594,8 @@ function audiobook_form() {
?>
</select>
<span id="other_bitrate_span"<? if(!$OtherBitrate) { echo ' class="hidden"'; } ?> >
<input type="text" name="other_bitrate" size="5" id="other_bitrate"<? if($OtherBitrate) { echo " value='".display_str($Torrent['Encoding'])."'";} ?> onchange="AltBitrate()" />
<? if($this->NewTorrent) { ?>
<input type="checkbox" id="vbr" name="vbr" /> (VBR)
<? } ?>
<input type="text" name="other_bitrate" size="5" id="other_bitrate"<? if($OtherBitrate) { echo " value='".display_str($Torrent['Bitrate'])."'";} ?> onchange="AltBitrate()" />
<input type="checkbox" id="vbr" name="vbr"<? if(isset($VBR)) { echo ' checked="checked"'; } ?> /><label for="vbr"> (VBR)</label>
</span>
</td>
</tr>

View File

@ -393,7 +393,7 @@ function site_ban_ip($IP) {
if(!is_array($IPBans)) {
//Cache lock!
$Lock = $Cache->get_value('ip_bans_lock');
if($Lock) {
if($Lock && substr($_SERVER['REQUEST_URI'], 0, 29) != '/torrents.php?action=download') {
?><script type="script/javascript">setTimeout('window.location="http://<?=NONSSL_SITE_URL?><?=$_SERVER['REQUEST_URI']?>"', 5)</script><?
} else {
$Cache->cache_value('ip_bans_lock', '1', 10);

View File

@ -1 +0,0 @@
<? //phpinfo();

View File

@ -332,12 +332,12 @@ function compare($X, $Y){
<? }
if (check_perms('site_torrents_notify')) {
if (($Notify = $Cache->get_value('notify_artists_'.$LoggedUser['ID'])) === FALSE) {
if (($Notify = $Cache->get_value('notify_artists_'.$LoggedUser['ID'])) === false) {
$DB->query("SELECT ID, Artists FROM users_notify_filters WHERE UserID='$LoggedUser[ID]' AND Label='Artist notifications' LIMIT 1");
$Notify = $DB->next_record(MYSQLI_ASSOC);
$Notify = $DB->next_record(MYSQLI_ASSOC, false);
$Cache->cache_value('notify_artists_'.$LoggedUser['ID'], $Notify, 0);
}
if (stripos($Notify['Artists'], '|'.$Name.'|') === FALSE) {
if (stripos($Notify['Artists'], '|'.$Name.'|') === false) {
?>
<a href="artist.php?action=notify&amp;artistid=<?=$ArtistID?>&amp;auth=<?=$LoggedUser['AuthKey']?>">[Notify of new uploads]</a>
<?

View File

@ -19,6 +19,7 @@ function get_thread_info($ThreadID, $Return = true, $SelectiveCache = false) {
if($DB->record_count()==0) { error(404); }
$ThreadInfo = $DB->next_record(MYSQLI_ASSOC);
if($ThreadInfo['StickyPostID']) {
$ThreadInfo['Posts']--;
$DB->query("SELECT
p.ID,
p.AuthorID,
@ -32,8 +33,8 @@ function get_thread_info($ThreadID, $Return = true, $SelectiveCache = false) {
WHERE p.TopicID = '$ThreadID' AND p.ID = '".$ThreadInfo['StickyPostID']."'");
list($ThreadInfo['StickyPost']) = $DB->to_array(false, MYSQLI_ASSOC);
}
if(!$SelectiveCache || (!$ThreadInfo['IsLocked'] || $ThreadInfo['IsSticky'])) {
$Cache->cache_value('thread_'.$TheadID.'_info', $ThreadInfo, 0);
if(!$SelectiveCache || !$ThreadInfo['IsLocked'] || $ThreadInfo['IsSticky']) {
$Cache->cache_value('thread_'.$ThreadID.'_info', $ThreadInfo, 0);
}
}
if($Return) {

View File

@ -1,5 +1,6 @@
<?
authorize();
include(SERVER_ROOT.'/sections/forums/functions.php');
//TODO: Remove all the stupid queries that could get their information just as easily from the cache
/*********************************************************************\
@ -47,24 +48,7 @@
}
$TopicID = $_POST['thread'];
if(!$ThreadInfo = $Cache->get_value('thread_'.$TopicID.'_info')) {
$DB->query("SELECT
t.Title,
t.ForumID,
t.IsLocked,
t.IsSticky,
COUNT(fp.id) AS Posts,
t.LastPostAuthorID,
ISNULL(p.TopicID) AS NoPoll
FROM forums_topics AS t
JOIN forums_posts AS fp ON fp.TopicID = t.ID
LEFT JOIN forums_polls AS p ON p.TopicID=t.ID
WHERE t.ID = '$TopicID'
GROUP BY fp.TopicID");
if($DB->record_count()==0) { error(404); }
$ThreadInfo = $DB->next_record(MYSQLI_ASSOC, false);
$Cache->cache_value('thread_'.$TopicID.'_info', $ThreadInfo, 0);
}
$ThreadInfo = get_thread_info($TopicID);
$ForumID = $ThreadInfo['ForumID'];
if($LoggedUser['Class'] < $Forums[$ForumID]['MinClassRead'] || !$ForumID) { error(403); }

View File

@ -332,7 +332,7 @@
<table class="forum_post box vertical_margin<? if (((!$ThreadInfo['IsLocked'] || $ThreadInfo['IsSticky']) && $PostID>$LastRead && strtotime($AddedTime)>$LoggedUser['CatchupTime']) || (isset($RequestKey) && $Key==$RequestKey)) { echo ' forum_unread'; } if($HeavyInfo['DisableAvatars']) { echo ' noavatar'; } ?>" id="post<?=$PostID?>">
<tr class="colhead_dark">
<td colspan="2">
<span style="float:left;"><a class="post_id" href='forums.php?action=viewthread&amp;threadid=<?=$ThreadID?>&amp;post=<?=($CatalogueID*THREAD_CATALOGUE)+($Key+1)?>#post<?=$PostID?>'>#<?=$PostID?></a>
<span style="float:left;"><a class="post_id" href='forums.php?action=viewthread&amp;threadid=<?=$ThreadID?>&amp;postid=<?=$PostID?>#post<?=$PostID?>'>#<?=$PostID?></a>
<strong><?=format_username($AuthorID, $Username, $Donor, $Warned, $Enabled == 2 ? false : true, $PermissionID)?></strong>
<span class="user_title"><?=!empty($UserTitle) ? '('.$UserTitle.')' : '' ?></span>
<?=time_diff($AddedTime,2)?>

View File

@ -55,26 +55,26 @@ function header_link($SortKey,$DefaultWay="desc") {
// Setting default search options
if(!empty($_GET['setdefault'])) {
$UnsetList[]='/(&?page\=.+?&?)/i';
$UnsetList[]='/(&?setdefault\=.+?&?)/i';
$UnsetList = array('page','setdefault');
$UnsetRegexp = '/(&|^)('.implode('|',$UnsetList).')=.*?(&|$)/i';
$DB->query("SELECT SiteOptions FROM users_info WHERE UserID='".db_string($LoggedUser['ID'])."'");
list($SiteOptions)=$DB->next_record(MYSQLI_NUM, true);
list($SiteOptions)=$DB->next_record(MYSQLI_NUM, false);
if(!empty($SiteOptions)) {
$SiteOptions = unserialize($SiteOptions);
} else {
$SiteOptions = array();
}
$SiteOptions['DefaultSearch']=preg_replace($UnsetList,'',$_SERVER['QUERY_STRING']);
$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'=>preg_replace($UnsetList,'',$_SERVER['QUERY_STRING'])));
$Cache->update_row(false, array('DefaultSearch'=>$SiteOptions['DefaultSearch']));
$Cache->commit_transaction(0);
// Clearing default search options
} elseif(!empty($_GET['cleardefault'])) {
$DB->query("SELECT SiteOptions FROM users_info WHERE UserID='".db_string($LoggedUser['ID'])."'");
list($SiteOptions)=$DB->next_record(MYSQLI_NUM, true);
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'])."'");

View File

@ -149,9 +149,9 @@
case 'Audiobooks':
case 'Comedy':
$Validate->SetFields('title',
/*$Validate->SetFields('title',
'1','string','Title must be between 2 and 300 characters.',array('maxlength'=>300, 'minlength'=>2));
^ this is commented out because there is no title field on these pages*/
$Validate->SetFields('year',
'1','number','The year of the release must be entered.');

View File

@ -110,7 +110,7 @@ function header_link($SortKey,$DefaultWay="DESC") {
}
$User = user_info($UserID);
$Perms = get_permissions($UserInfo['PermissionID']);
$Perms = get_permissions($User['PermissionID']);
$UserClass = $Perms['Class'];
switch($_GET['type']) {
@ -136,7 +136,7 @@ function header_link($SortKey,$DefaultWay="DESC") {
$From = "xbt_files_users AS xfu JOIN torrents AS t ON t.ID=xfu.fid";
break;
case 'uploaded':
if (!check_paranoia('uploads', $User['Paranoia'], $UserClass, $UserID)) { error(403); }
if ((empty($_GET['filter']) || $_GET['filter'] != 'perfectflac') && !check_paranoia('uploads', $User['Paranoia'], $UserClass, $UserID)) { error(403); }
$Time = 'unix_timestamp(t.Time)';
$UserField = 't.UserID';
$ExtraWhere = 'AND flags!=1';
@ -153,7 +153,7 @@ function header_link($SortKey,$DefaultWay="DESC") {
error(404);
}
if(!empty($_GET['filter']) && (($_GET['filter'] == "perfectflac") || ($_GET['filter'] == "uniquegroup"))) {
if(!empty($_GET['filter'])) {
if($_GET['filter'] == "perfectflac") {
if (!check_paranoia('perfectflacs', $User['Paranoia'], $UserClass, $UserID)) { error(403); }
$ExtraWhere .= " AND t.Format = 'FLAC'";

View File

@ -736,7 +736,7 @@
foreach($GroupInfo[1] as $TorrentInfo) {
if (($TorrentInfo['Media'] == $ThisMedia)
&& ($TorrentInfo['Remastered'] == $ThisRemastered)
&& ($TorrentInfo['RemasterYear'] == $ThisRemasterYear)
&& ($TorrentInfo['RemasterYear'] == (int)$ThisRemasterYear)
&& ($TorrentInfo['RemasterTitle'] == $ThisRemasterTitle)
&& ($TorrentInfo['RemasterRecordLabel'] == $ThisRemasterRecordLabel)
&& ($TorrentInfo['RemasterCatalogueNumber'] == $ThisRemasterCatalogueNumber)

View File

@ -177,6 +177,9 @@
die();
}
if(!empty($LoggedUser['DefaultSearch'])) {
$Options['DefaultSearch'] = $LoggedUser['DefaultSearch'];
}
$Options['DisableGrouping'] = (!empty($_POST['disablegrouping']) ? 1 : 0);
$Options['TorrentGrouping'] = (!empty($_POST['torrentgrouping']) ? 1 : 0);
$Options['DiscogView'] = (!empty($_POST['discogview']) ? 1 : 0);
@ -187,15 +190,15 @@
$Options['DisableSmileys'] = (!empty($_POST['disablesmileys']) ? 1 : 0);
$Options['DisableAvatars'] = (!empty($_POST['disableavatars']) ? 1 : 0);
if(!empty($_POST['hidetypes'])) {
if(!empty($_POST['hidetypes'])) {
foreach($_POST['hidetypes'] as $Type) {
$Options['HideTypes'][] = (int) $Type;
}
} else {
$Options['HideTypes']=array();
$Options['HideTypes'] = array();
}
if (check_perms('site_advanced_search')) {
$Options['SearchType'] =$_POST['searchtype'];
$Options['SearchType'] = $_POST['searchtype'];
} else {
unset($Options['SearchType']);
}

View File

@ -5,7 +5,11 @@ function Categories() {
}
function Remaster() {
$('#remaster_true').toggle();
if($('#remaster').raw().checked) {
$('#remaster_true').show();
} else {
$('#remaster_true').hide();
}
}
function Format() {

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 784 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 923 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

File diff suppressed because one or more lines are too long