diff --git a/app/Models/ForumMod.php b/app/Models/ForumMod.php new file mode 100644 index 000000000..62ac92c1e --- /dev/null +++ b/app/Models/ForumMod.php @@ -0,0 +1,10 @@ +findOrFail(intval($post))->toArray(); + } + $topicId = $post['topicid']; + if (!isset($topics[$topicId])) { + $topics[$topicId] = \App\Models\Topic::query()->findOrFail($topicId); + } + /** @var \App\Models\Topic $topicInfo */ + $topicInfo = $topics[$topicId]; + + $forumId = $topicInfo->forumid; + + if (is_null($protectedForumIdArr)) { + $protectedForumIdArr = []; + $protectedForumIds = \Nexus\Database\NexusDB::remember("setting_protected_forum", 600, function () { + return \App\Models\Setting::getByName('misc.protected_forum'); + }); + $protectedForumIdArr = $protectedForumIds ? preg_split("/[,\s]+/", $protectedForumIds) : []; + } + if (is_null($forumMods)) { + $forumMods = []; + $results = \App\Models\ForumMod::query()->get(); + foreach ($results as $item) { + $forumMods[$item->forumid] = $item->userid; + } + } + $isForumMod = isset($forumMods[$forumId]) && $forumMods[$forumId] == $uid; + $log = sprintf( + "uid: $uid, class: %s, post: {$post['id']}, forumId: $forumId, protectedForumIdArr: %s, forumMods: %s, isForumMod: %s", + get_user_class(), json_encode($protectedForumIdArr), json_encode($forumMods), $isForumMod + ); + if ( + in_array($forumId, $protectedForumIdArr) + && get_user_class() < \App\Models\User::CLASS_ADMINISTRATOR + && $uid != $post['userid'] + && $uid != $topicInfo->userid + && !$isForumMod + ) { + do_log("$log, FALSE"); + return false; + } + do_log("$log, TRUE"); + return true; +} + ?> diff --git a/public/announce.php b/public/announce.php index f8ba0453c..b4f91e553 100644 --- a/public/announce.php +++ b/public/announce.php @@ -384,7 +384,7 @@ do_log("notSeedBoxMaxSpeedMbps: $notSeedBoxMaxSpeedMbps, upSpeedMbps: $upSpeedMbps"); if ($upSpeedMbps > $notSeedBoxMaxSpeedMbps) { (new \App\Repositories\UserRepository())->updateDownloadPrivileges(null, $userid, 'no', 'upload_over_speed'); - do_log("user: $userid downloading privileges have been disabled! (over speed), notSeedBoxMaxSpeedMbps: $notSeedBoxMaxSpeedMbps > upSpeedMbps: $upSpeedMbps", 'error'); + do_log("user: $userid downloading privileges have been disabled! (over speed), upSpeedMbps: $upSpeedMbps > notSeedBoxMaxSpeedMbps: $notSeedBoxMaxSpeedMbps", 'error'); err("Your downloading privileges have been disabled! (over speed)"); } } diff --git a/public/forums.php b/public/forums.php index 542d67c1d..12ce4ce0c 100644 --- a/public/forums.php +++ b/public/forums.php @@ -270,6 +270,9 @@ function insert_compose_frame($id, $type = 'new') { $postid = intval($_GET["postid"] ?? 0); check_whether_exist($postid, 'post'); + if (!can_view_post($CURUSER['id'], $postid)) { + permissiondenied(); + } stdhead($lang_forums['head_post_reply']); begin_main_frame(); insert_compose_frame($postid, 'quote'); @@ -685,15 +688,15 @@ function insert_compose_frame($id, $type = 'new') $forumpostad=$Advertisement->get_ad('forumpost'); //check if privacy protection enabled in this forum - $protected_forums = Nexus\Database\NexusDB::remember("setting_protected_forum", 600, function () { - return \App\Models\Setting::getByName('misc.protected_forum'); - }); - - if ($protected_forums and in_array(strval($forumid),explode(",",$protected_forums))){ - $protected_enabled=true; - }else{ - $protected_enabled=false; - } +// $protected_forums = Nexus\Database\NexusDB::remember("setting_protected_forum", 600, function () { +// return \App\Models\Setting::getByName('misc.protected_forum'); +// }); +// +// if ($protected_forums and in_array(strval($forumid),explode(",",$protected_forums))){ +// $protected_enabled=true; +// }else{ +// $protected_enabled=false; +// } foreach ($allPosts as $arr) { @@ -761,15 +764,18 @@ function insert_compose_frame($id, $type = 'new') print("\n"); print("