Empty commit

This commit is contained in:
Git 2011-10-11 08:00:15 +00:00
parent a7056c9651
commit 547fdc9829
16 changed files with 97 additions and 37 deletions

View File

@ -329,6 +329,7 @@ function user_heavy_info($UserID) {
i.DownloadAlt,
i.LastReadNews,
i.RestrictedForums,
i.PermittedForums,
m.FLTokens
FROM users_main AS m
INNER JOIN users_info AS i ON i.UserID=m.ID
@ -347,6 +348,10 @@ function user_heavy_info($UserID) {
$HeavyInfo['CustomForums'] = null;
}
unset($HeavyInfo['RestrictedForums']);
if (!empty($HeavyInfo['PermittedForums'])) {
$HeavyInfo['CustomForums'] = array_fill_keys(explode(',', $HeavyInfo['PermittedForums']), 1);
}
unset($HeavyInfo['PermittedForums']);
if(!empty($HeavyInfo['SiteOptions'])) {
$HeavyInfo['SiteOptions'] = unserialize($HeavyInfo['SiteOptions']);

View File

@ -126,15 +126,16 @@
$NewSubscriptions = $Cache->get_value('subscriptions_user_new_'.$LoggedUser['ID']);
if($NewSubscriptions === FALSE) {
if($LoggedUser['CustomForums']) {
unset($LoggedUser['CustomForums']['']);
$RestrictedForums = implode("','", array_keys($LoggedUser['CustomForums'], 0));
unset($LoggedUser['CustomForums']['']);
$RestrictedForums = implode("','", array_keys($LoggedUser['CustomForums'], 0));
$PermittedForums = implode("','", array_keys($LoggedUser['CustomForums'], 1));
}
$DB->query("SELECT COUNT(s.TopicID)
FROM users_subscriptions AS s
JOIN forums_last_read_topics AS l ON s.UserID = l.UserID AND s.TopicID = l.TopicID
JOIN forums_topics AS t ON l.TopicID = t.ID
JOIN forums AS f ON t.ForumID = f.ID
WHERE f.MinClassRead <= ".$LoggedUser['Class']."
WHERE (f.MinClassRead <= ".$LoggedUser['Class']." OR f.ID IN ('$PermittedForums'))
AND l.PostID < t.LastPostID
AND s.UserID = ".$LoggedUser['ID'].
(!empty($RestrictedForums) ? "

View File

@ -1127,6 +1127,7 @@ CREATE TABLE `users_info` (
`HideCountryChanges` enum('0','1') NOT NULL DEFAULT '0',
`RestrictedForums` varchar(150) NOT NULL DEFAULT '',
`DisableRequests` enum('0','1') NOT NULL DEFAULT '0',
`PermittedForums` varchar(150) NOT NULL DEFAULT '',
UNIQUE KEY `UserID` (`UserID`),
KEY `SupportFor` (`SupportFor`),
KEY `DisableInvites` (`DisableInvites`),

View File

@ -61,12 +61,9 @@
if(!isset($Forums[$ForumID])) { error(404); }
// Make sure they're allowed to look at the page
if (!check_perms('site_moderate_forums')) {
$DB->query("SELECT RestrictedForums FROM users_info WHERE UserID = ".$LoggedUser['ID']);
list($RestrictedForums) = $DB->next_record();
$RestrictedForums = explode(',', $RestrictedForums);
if (array_search($ForumID, $RestrictedForums) !== FALSE) { error(403); }
if (isset($LoggedUser['CustomForums'][$ForumID]) && $LoggedUser['CustomForums'][$ForumID] === 0) { error(403); }
}
if($Forums[$ForumID]['MinClassRead'] > $LoggedUser['Class']) { error(403); }
if($LoggedUser['CustomForums'][$ForumID] != 1 && $Forums[$ForumID]['MinClassRead'] > $LoggedUser['Class']) { error(403); }
// Start printing
show_header('Forums > '. $Forums[$ForumID]['Name']);

View File

@ -42,9 +42,9 @@ function get_thread_info($ThreadID, $Return = true, $SelectiveCache = false) {
}
}
function check_forumperm($ForumID) {
function check_forumperm($ForumID, $Perm = 'Read') {
global $LoggedUser, $Forums;
if($Forums[$ForumID]['MinClassRead'] > $LoggedUser['Class'] && (!isset($LoggedUser['CustomForums'][$ForumID]) || $LoggedUser['CustomForums'][$ForumID] == 0)) {
if($Forums[$ForumID]['MinClass'.$Perm] > $LoggedUser['Class'] && (!isset($LoggedUser['CustomForums'][$ForumID]) || $LoggedUser['CustomForums'][$ForumID] == 0)) {
return false;
}
if(isset($LoggedUser['CustomForums'][$ForumID]) && $LoggedUser['CustomForums'][$ForumID] == 0) {

View File

@ -39,10 +39,10 @@
$DB->query("SELECT RestrictedForums FROM users_info WHERE UserID = ".$LoggedUser['ID']);
list($RestrictedForums) = $DB->next_record();
$RestrictedForums = explode(',', $RestrictedForums);
$PermittedForums = array_keys($LoggedUser['PermittedForums']);
foreach ($Forums as $Forum) {
list($ForumID, $CategoryID, $ForumName, $ForumDescription, $MinRead, $MinWrite, $MinCreate, $NumTopics, $NumPosts, $LastPostID, $LastAuthorID, $LastPostAuthorName, $LastTopicID, $LastTime, $SpecificRules, $LastTopic, $Locked, $Sticky) = array_values($Forum);
if ($MinRead>$LoggedUser['Class'] || array_search($ForumID, $RestrictedForums) !== FALSE) {
if ($LoggedUser['CustomForums'][$ForumID] != 1 && ($MinRead>$LoggedUser['Class'] || array_search($ForumID, $RestrictedForums) !== FALSE)) {
continue;
}
$Row = ($Row == 'a') ? 'b' : 'a';

View File

@ -146,6 +146,7 @@
if($LoggedUser['CustomForums']) {
unset($LoggedUser['CustomForums']['']);
$RestrictedForums = implode("','", array_keys($LoggedUser['CustomForums'], 0));
$PermittedForums = implode("','", array_keys($LoggedUser['CustomForums'], 1));
}
if($Type == 'body') {
@ -165,10 +166,15 @@
JOIN forums_topics AS t ON t.ID=p.TopicID
JOIN forums AS f ON f.ID=t.ForumID
WHERE
f.MinClassRead<='$LoggedUser[Class]' AND ";
((f.MinClassRead<='$LoggedUser[Class]'";
if(!empty($RestrictedForums)) {
$sql.="f.ID NOT IN ('".$RestrictedForums."') AND ";
$sql.=" AND f.ID NOT IN ('".$RestrictedForums."')";
}
$sql .= ')';
if(!empty($PermittedForums)) {
$sql.=' OR f.ID IN (\''.$PermittedForums.'\')';
}
$sql .= ') AND ';
//In tests, this is significantly faster than LOCATE
$sql .= "p.Body LIKE '%";
@ -200,10 +206,15 @@
FROM forums_topics AS t
JOIN forums AS f ON f.ID=t.ForumID
WHERE
f.MinClassRead<='$LoggedUser[Class]' AND ";
((f.MinClassRead<='$LoggedUser[Class]'";
if(!empty($RestrictedForums)) {
$sql.="f.ID NOT IN ('".$RestrictedForums."') AND ";
$sql.=" AND f.ID NOT IN ('".$RestrictedForums."')";
}
$sql .= ')';
if(!empty($PermittedForums)) {
$sql.=' OR f.ID IN (\''.$PermittedForums.'\')';
}
$sql .= ') AND ';
$sql .= "t.Title LIKE '%";
$sql .= implode("%' AND t.Title LIKE '%", $Words);
$sql .= "%' ";

View File

@ -48,7 +48,7 @@
if (!isset($Forums[$ForumID])) { error(404); }
if($LoggedUser['Class'] < $Forums[$ForumID]['MinClassWrite'] || $LoggedUser['Class'] < $Forums[$ForumID]['MinClassCreate']) {
if(!check_forumperm($ForumID, 'Write') || !check_forumperm($ForumID, 'Create')) {
error(403);
}

View File

@ -50,8 +50,8 @@
$ThreadInfo = get_thread_info($TopicID);
$ForumID = $ThreadInfo['ForumID'];
if($LoggedUser['Class'] < $Forums[$ForumID]['MinClassRead'] || !$ForumID) { error(403); }
if($LoggedUser['Class'] < $Forums[$ForumID]['MinClassWrite'] || $LoggedUser['DisablePosting'] || $ThreadInfo['IsLocked'] == "1" && !check_perms('site_moderate_forums')) { error(403); }
if(!check_forumperm($ForumID)) { error(403); }
if(!check_forumperm($ForumID, 'Write') || $LoggedUser['DisablePosting'] || $ThreadInfo['IsLocked'] == "1" && !check_perms('site_moderate_forums')) { error(403); }
if(isset($_POST['subscribe'])) {
$DB->query("INSERT IGNORE INTO users_subscriptions VALUES ($LoggedUser[ID], '".db_string($TopicID)."')");

View File

@ -51,7 +51,7 @@
// Make sure they aren't trying to edit posts they shouldn't
// We use die() here instead of error() because whatever we spit out is displayed to the user in the box where his forum post is
if($LoggedUser['Class'] < $MinClassWrite || ($IsLocked && !check_perms('site_moderate_forums'))) {
if(!check_forumperm($ForumID, 'Write') || ($IsLocked && !check_perms('site_moderate_forums'))) {
error('Either the thread is locked, or you lack the permission to edit this post.',true);
}
if($UserID != $AuthorID && !check_perms('site_moderate_forums')) {

View File

@ -419,7 +419,7 @@
</div>
<?
if(!$ThreadInfo['IsLocked'] || check_perms('site_moderate_forums')) {
if($Forums[$ForumID]['MinClassWrite'] <= $LoggedUser['Class'] && !$LoggedUser['DisablePosting']) {
if(check_forumperm($ForumID, 'Write') && !$LoggedUser['DisablePosting']) {
//TODO: Preview, come up with a standard, make it look like post or just a block of formatted bbcode, but decide and write some proper html
?>
<br />

View File

@ -65,6 +65,7 @@
$DisableLeech = (isset($_POST['DisableLeech'])) ? 0 : 1;
$RestrictedForums = db_string(trim($_POST['RestrictedForums']));
$PermittedForums = db_string(trim($_POST['PermittedForums']));
$EnableUser = (int)$_POST['UserStatus'];
$ResetRatioWatch = (isset($_POST['ResetRatioWatch']))? 1 : 0;
$ResetPasskey = (isset($_POST['ResetPasskey']))? 1 : 0;
@ -104,6 +105,8 @@
i.Artist,
i.Warned,
i.SupportFor,
i.RestricForums,
i.PermittedForums,
DisableAvatar,
DisableInvites,
DisablePosting,
@ -350,13 +353,36 @@
if ($RestrictedForums != db_string($Cur['RestrictedForums']) && check_perms('users_mod')) {
$UpdateSet[]="RestrictedForums='$RestrictedForums'";
$EditSummary[]="restricted forum(s): $RestrictedForums";
if(empty($RestrictedForums)) {
$HeavyUpdates['CustomForums'] = null;
} else {
$HeavyUpdates['CustomForums'] = array_fill_keys(explode(',', $RestrictedForums), 0);
}
if ($PermittedForums != db_string($Cur['PermittedForums']) && check_perms('users_mod')) {
$ForumSet=explode(',',$PermittedForums);
$ForumList = array();
foreach ($ForumSet as $ForumID) {
if ($Forums[$ForumID]['MinClassCreate'] <= $LoggedUser['Class']) {
$ForumList[] = $ForumID;
}
}
$PermittedForums = implode(',',$ForumSet);
$UpdateSet[]="PermittedForums='$PermittedForums'";
$EditSummary[]="permitted forum(s): $PermittedForums";
}
if(empty($RestrictedForums) && empty($PermittedForums)) {
$HeavyUpdates['CustomForums'] = null;
} else {
$HeavyUpdates['CustomForums'] = array();
$Forums = explode(',',$RestrictedForums);
foreach ($Forums as $Forum) {
$HeavyUpdates['CustomForums'][$Forum] = 0;
}
$Forums = explode(',',$PermittedForums);
foreach ($Forums as $Forum) {
$HeavyUpdates['CustomForums'][$Forum] = 1;
}
}
if ($DisableAvatar!=$Cur['DisableAvatar'] && check_perms('users_disable_any')) {
$UpdateSet[]="DisableAvatar='$DisableAvatar'";
$EditSummary[]="avatar status changed";

View File

@ -43,6 +43,7 @@
i.Warned,
i.SupportFor,
i.RestrictedForums,
i.PermittedForums,
i.Inviter,
inviter.Username,
COUNT(posts.id) AS ForumPosts,
@ -71,7 +72,7 @@
header("Location: log.php?search=User+".$UserID);
}
list($Username, $Email, $LastAccess, $IP, $Class, $Uploaded, $Downloaded, $RequiredRatio, $CustomTitle, $torrent_pass, $Enabled, $Paranoia, $Invites, $DisableLeech, $Visible, $JoinDate, $Info, $Avatar, $Country, $AdminComment, $Donor, $Artist, $Warned, $SupportFor, $RestrictedForums, $InviterID, $InviterName, $ForumPosts, $RatioWatchEnds, $RatioWatchDownload, $DisableAvatar, $DisableInvites, $DisablePosting, $DisableForums, $DisableTagging, $DisableUpload, $DisableWiki, $DisablePM, $DisableIRC, $DisableRequests, $DisableCountry, $FLTokens) = $DB->next_record(MYSQLI_NUM, array(8,11));
list($Username, $Email, $LastAccess, $IP, $Class, $Uploaded, $Downloaded, $RequiredRatio, $CustomTitle, $torrent_pass, $Enabled, $Paranoia, $Invites, $DisableLeech, $Visible, $JoinDate, $Info, $Avatar, $Country, $AdminComment, $Donor, $Artist, $Warned, $SupportFor, $RestrictedForums, $PermittedForums, $InviterID, $InviterName, $ForumPosts, $RatioWatchEnds, $RatioWatchDownload, $DisableAvatar, $DisableInvites, $DisablePosting, $DisableForums, $DisableTagging, $DisableUpload, $DisableWiki, $DisablePM, $DisableIRC, $DisableRequests, $DisableCountry, $FLTokens) = $DB->next_record(MYSQLI_NUM, array(8,11));
} else { // Person viewing is a normal user
$DB->query("SELECT
m.Username,
@ -1158,10 +1159,16 @@ function check_paranoia_here($Setting) {
</tr>
<tr>
<td class="label">Restricted Forums (comma-delimited):</td>
<td>
<input type="text" size="60" name="RestrictedForums" value="<?=display_str($RestrictedForums)?>" />
</td>
</tr>
<td>
<input type="text" size="60" name="RestrictedForums" value="<?=display_str($RestrictedForums)?>" />
</td>
</tr>
<tr>
<td class="label">Extra Forums (comma-delimited):</td>
<td>
<input type="text" size="60" name="PermittedForums" value="<?=display_str($PermittedForums)?>" />
</td>
</tr>
<? } ?>
</table><br />

View File

@ -72,11 +72,17 @@
$sql .= '
LEFT JOIN forums AS f ON f.ID = t.ForumID
WHERE p.AuthorID = '.$UserID.'
AND f.MinClassRead <= '.$LoggedUser['Class'];
AND ((f.MinClassRead <= '.$LoggedUser['Class'];
if(!empty($RestrictedForums)) {
$sql.='
AND f.ID NOT IN (\''.$RestrictedForums.'\')';
}
$sql .= ')';
if(!empty($PermittedForums)) {
$sql.='
OR f.ID IN (\''.$PermittedForums.'\')';
}
$sql .= ')';
if($ShowUnread) {
$sql .= '
AND ((t.IsLocked=\'0\' OR t.IsSticky=\'1\')

View File

@ -22,7 +22,9 @@
if($LoggedUser['CustomForums']) {
unset($LoggedUser['CustomForums']['']);
$RestrictedForums = implode("','", array_keys($LoggedUser['CustomForums'], 0));
$PermittedForums = implode("','", array_keys($LoggedUser['CustomForums'], 1));
}
$ShowUnread = (!isset($_GET['showunread']) && !isset($HeavyInfo['SubscriptionsUnread']) || isset($HeavyInfo['SubscriptionsUnread']) && !!$HeavyInfo['SubscriptionsUnread'] || isset($_GET['showunread']) && !!$_GET['showunread']);
$ShowCollapsed = (!isset($_GET['collapse']) && !isset($HeavyInfo['SubscriptionsCollapse']) || isset($HeavyInfo['SubscriptionsCollapse']) && !!$HeavyInfo['SubscriptionsCollapse'] || isset($_GET['collapse']) && !!$_GET['collapse']);
$sql = 'SELECT
@ -35,11 +37,15 @@
LEFT JOIN forums_last_read_topics AS l ON p.TopicID = l.TopicID AND l.UserID = s.UserID
WHERE s.UserID = '.$LoggedUser['ID'].'
AND p.ID <= IFNULL(l.PostID,t.LastPostID)
AND f.MinClassRead <= '.$LoggedUser['Class'];
AND ((f.MinClassRead <= '.$LoggedUser['Class'];
if(!empty($RestrictedForums)) {
$sql.='
AND f.ID NOT IN (\''.$RestrictedForums.'\')';
$sql.=' AND f.ID NOT IN (\''.$RestrictedForums.'\')';
}
$sql .= ')';
if(!empty($PermittedForums)) {
$sql.=' OR f.ID IN (\''.$PermittedForums.'\')';
}
$sql .= ')';
if($ShowUnread) {
$sql .= '
AND IF(l.PostID IS NULL OR (t.IsLocked = \'1\' && t.IsSticky = \'0\'), t.LastPostID, l.PostID) < t.LastPostID';

View File

@ -10,9 +10,9 @@
error(0);
}
$DB->query('SELECT MinClassRead FROM forums WHERE forums.ID = (SELECT ForumID FROM forums_topics WHERE ID = '.db_string($_GET['topicid']).')');
list($MinClassRead) = $DB->next_record();
if($MinClassRead>$LoggedUser['Class']) {
$DB->query('SELECT MinClassRead, ID FROM forums WHERE forums.ID = (SELECT ForumID FROM forums_topics WHERE ID = '.db_string($_GET['topicid']).')');
list($MinClassRead, $ForumID) = $DB->next_record();
if(!check_forumperm($ForumID)) {
die();
}