PATH:
home
/
sudairsocs
/
www
/
forum
/
Sources
<?php /** * This file takes care of actions on topics: * lock/unlock a topic, sticky/unsticky it, * * Simple Machines Forum (SMF) * * @package SMF * @author Simple Machines https://www.simplemachines.org * @copyright 2022 Simple Machines and individual contributors * @license https://www.simplemachines.org/about/smf/license.php BSD * * @version 2.1.0 */ if (!defined('SMF')) die('No direct access...'); /** * Locks a topic... either by way of a moderator or the topic starter. * What this does: * - locks a topic, toggles between locked/unlocked/admin locked. * - only admins can unlock topics locked by other admins. * - requires the lock_own or lock_any permission. * - logs the action to the moderator log. * - returns to the topic after it is done. * - it is accessed via ?action=lock. */ function LockTopic() { global $topic, $user_info, $sourcedir, $board, $smcFunc; // Just quit if there's no topic to lock. if (empty($topic)) fatal_lang_error('not_a_topic', false); checkSession('get'); // Get Subs-Post.php for sendNotifications. require_once($sourcedir . '/Subs-Post.php'); // Find out who started the topic - in case User Topic Locking is enabled. $request = $smcFunc['db_query']('', ' SELECT id_member_started, locked FROM {db_prefix}topics WHERE id_topic = {int:current_topic} LIMIT 1', array( 'current_topic' => $topic, ) ); list ($starter, $locked) = $smcFunc['db_fetch_row']($request); $smcFunc['db_free_result']($request); // Can you lock topics here, mister? $user_lock = !allowedTo('lock_any'); if ($user_lock && $starter == $user_info['id']) isAllowedTo('lock_own'); else isAllowedTo('lock_any'); // Another moderator got the job done first? if (isset($_GET['sa']) && $_GET['sa'] == 'unlock' && $locked == '0') fatal_lang_error('error_topic_locked_already', false); elseif (isset($_GET['sa']) && $_GET['sa'] == 'lock' && ($locked == '1' || $locked == '2')) fatal_lang_error('error_topic_unlocked_already', false); // Locking with high privileges. if ($locked == '0' && !$user_lock) $locked = '1'; // Locking with low privileges. elseif ($locked == '0') $locked = '2'; // Unlocking - make sure you don't unlock what you can't. elseif ($locked == '2' || ($locked == '1' && !$user_lock)) $locked = '0'; // You cannot unlock this! else fatal_lang_error('locked_by_admin', 'user'); // Actually lock the topic in the database with the new value. $smcFunc['db_query']('', ' UPDATE {db_prefix}topics SET locked = {int:locked} WHERE id_topic = {int:current_topic}', array( 'current_topic' => $topic, 'locked' => $locked, ) ); // If they are allowed a "moderator" permission, log it in the moderator log. if (!$user_lock) logAction($locked ? 'lock' : 'unlock', array('topic' => $topic, 'board' => $board)); // Notify people that this topic has been locked? sendNotifications($topic, empty($locked) ? 'unlock' : 'lock'); // Back to the topic! redirectexit('topic=' . $topic . '.' . $_REQUEST['start'] . ';moderate'); } /** * Sticky a topic. * Can't be done by topic starters - that would be annoying! * What this does: * - stickies a topic - toggles between sticky and normal. * - requires the make_sticky permission. * - adds an entry to the moderator log. * - when done, sends the user back to the topic. * - accessed via ?action=sticky. */ function Sticky() { global $topic, $board, $sourcedir, $smcFunc; // Make sure the user can sticky it, and they are stickying *something*. isAllowedTo('make_sticky'); // You can't sticky a board or something! if (empty($topic)) fatal_lang_error('not_a_topic', false); checkSession('get'); // We need Subs-Post.php for the sendNotifications() function. require_once($sourcedir . '/Subs-Post.php'); // Is this topic already stickied, or no? $request = $smcFunc['db_query']('', ' SELECT is_sticky FROM {db_prefix}topics WHERE id_topic = {int:current_topic} LIMIT 1', array( 'current_topic' => $topic, ) ); list ($is_sticky) = $smcFunc['db_fetch_row']($request); $smcFunc['db_free_result']($request); // Another moderator got the job done first? if (isset($_GET['sa']) && $_GET['sa'] == 'nonsticky' && $is_sticky == '0') fatal_lang_error('error_topic_nonsticky_already', false); elseif (isset($_GET['sa']) && $_GET['sa'] == 'sticky' && $is_sticky == '1') fatal_lang_error('error_topic_sticky_already', false); // Toggle the sticky value.... pretty simple ;). $smcFunc['db_query']('', ' UPDATE {db_prefix}topics SET is_sticky = {int:is_sticky} WHERE id_topic = {int:current_topic}', array( 'current_topic' => $topic, 'is_sticky' => empty($is_sticky) ? 1 : 0, ) ); // Log this sticky action - always a moderator thing. logAction(empty($is_sticky) ? 'sticky' : 'unsticky', array('topic' => $topic, 'board' => $board)); // Notify people that this topic has been stickied? if (empty($is_sticky)) sendNotifications($topic, 'sticky'); // Take them back to the now stickied topic. redirectexit('topic=' . $topic . '.' . $_REQUEST['start'] . ';moderate'); } ?>
[+]
..
[-] Errors.php~
[edit]
[-] ReportedContent.php
[edit]
[-] Profile.php~
[edit]
[-] Notify.php
[edit]
[-] Security.php~
[edit]
[-] ScheduledTasks.php
[edit]
[-] ModerationCenter.php
[edit]
[-] Mentions.php
[edit]
[-] DbExtra-mysql.php~
[edit]
[-] Subs-MessageIndex.php
[edit]
[-] Display.php~
[edit]
[-] DbPackages-sqlite.php
[edit]
[-] ManageSettings.php~
[edit]
[-] Subs-Compat.php
[edit]
[-] ManageScheduledTasks.php
[edit]
[-] Security.php
[edit]
[-] Profile-View.php~
[edit]
[-] BoardIndex.php
[edit]
[-] Class-Punycode.php
[edit]
[-] Subs-Db-postgresql.php~
[edit]
[-] MessageIndex.php
[edit]
[-] ManageMail.php~
[edit]
[-] Modlog.php
[edit]
[-] Calendar.php
[edit]
[-] Subs-Members.php~
[edit]
[-] Profile-Modify.php~
[edit]
[-] .reference
[edit]
[-] RemoveTopic.php~
[edit]
[-] ManageSmileys.php
[edit]
[-] MoveTopic.php
[edit]
[-] RemoveTopic.php
[edit]
[-] Subs-Post.php~
[edit]
[-] Profile.php
[edit]
[+]
Unicode
[-] Groups.php
[edit]
[-] Subs-Sound.php~
[edit]
[-] Groups.php~
[edit]
[-] Recent.php~
[edit]
[-] Who.php~
[edit]
[-] Class-TOTP.php
[edit]
[-] ManageRegistration.php~
[edit]
[-] Agreement.php
[edit]
[-] ReportToMod.php
[edit]
[-] Profile-Actions.php
[edit]
[-] Subs-Db-sqlite.php~
[edit]
[-] Display.php
[edit]
[-] ManageCalendar.php~
[edit]
[-] PersonalMessage.php
[edit]
[-] ManageAttachments.php~
[edit]
[-] Subs-Attachments.php
[edit]
[-] Help.php
[edit]
[-] Subs-Notify.php
[edit]
[-] index.php
[edit]
[-] Subs-Admin.php~
[edit]
[-] Subs-Db-mysql.php~
[edit]
[-] Subs-Package.php
[edit]
[-] Printpage.php
[edit]
[-] Subs-Post.php
[edit]
[-] Class-SearchAPI.php
[edit]
[-] Subs-Admin.php
[edit]
[-] DbExtra-postgresql.php
[edit]
[-] ManageSmileys.php~
[edit]
[-] Class-Graphics.php~
[edit]
[-] Subs-Categories.php
[edit]
[-] ManageSearch.php~
[edit]
[-] Subs-Editor.php~
[edit]
[-] Likes.php
[edit]
[-] Subs.php~
[edit]
[-] SendTopic.php
[edit]
[-] DbPackages-postgresql.php
[edit]
[-] DbSearch-mysql.php
[edit]
[-] Xml.php
[edit]
[-] Reports.php
[edit]
[-] Subs-Membergroups.php
[edit]
[-] ManagePosts.php
[edit]
[-] ManageAttachments.php
[edit]
[-] ManagePaid.php~
[edit]
[-] SearchAPI-Standard.php
[edit]
[-] DbExtra-mysql.php
[edit]
[-] ManageLanguages.php
[edit]
[+]
Cache
[-] Session.php
[edit]
[-] Load.php~
[edit]
[-] Packages.php~
[edit]
[-] ManageScheduledTasks.php~
[edit]
[-] Karma.php
[edit]
[-] Poll.php~
[edit]
[-] ManageMembers.php~
[edit]
[-] News.php
[edit]
[-] Subs-Compat.php~
[edit]
[-] DbSearch-sqlite.php
[edit]
[-] Subs-Charset.php
[edit]
[-] Subs.php
[edit]
[-] Reminder.php
[edit]
[-] Modlog.php~
[edit]
[-] ManagePaid.php
[edit]
[-] LogInOut.php
[edit]
[-] DbSearch-postgresql.php
[edit]
[-] hcaptcha.php
[edit]
[-] Subs-BoardIndex.php
[edit]
[-] ManageMembergroups.php~
[edit]
[+]
minify
[-] Class-Graphics.php
[edit]
[-] Subs-Graphics.php~
[edit]
[-] Subs-Menu.php
[edit]
[-] Admin.php~
[edit]
[-] ManageMail.php
[edit]
[-] SearchAPI-Custom.php
[edit]
[-] ScheduledTasks.php~
[edit]
[-] Logging.php
[edit]
[-] DbPackages-mysql.php
[edit]
[-] Subs-Recent.php
[edit]
[-] Class-CurlFetchWeb.php~
[edit]
[-] ModerationCenter.php~
[edit]
[+]
random_compat
[-] Admin.php
[edit]
[-] Class-Package.php
[edit]
[-] ManageMaintenance.php
[edit]
[-] Packages.php
[edit]
[-] Subs-BoardIndex.php~
[edit]
[-] ManageBans.php~
[edit]
[-] ManageMembers.php
[edit]
[-] ManageServer.php
[edit]
[-] Subs-Db-mysql.php
[edit]
[-] ManageErrors.php
[edit]
[-] Subs-Calendar.php
[edit]
[-] Subs-Editor.php
[edit]
[-] Load.php
[edit]
[-] Subs-Graphics.php
[edit]
[-] Subs-Boards.php
[edit]
[-] News.php~
[edit]
[-] Stats.php
[edit]
[-] ManageNews.php
[edit]
[-] Subs-Db-sqlite.php
[edit]
[-] Attachments.php
[edit]
[-] Subs-ReportedContent.php
[edit]
[-] Register.php~
[edit]
[-] Subs-Sound.php
[edit]
[-] Who.php
[edit]
[-] Subs-Members.php
[edit]
[-] Search.php~
[edit]
[-] ManageRegistration.php
[edit]
[-] Help.php~
[edit]
[-] PostModeration.php
[edit]
[-] ShowAttachments.php
[edit]
[-] Subs-Db-postgresql.php
[edit]
[-] Recent.php
[edit]
[-] Memberlist.php
[edit]
[-] ManageBoards.php
[edit]
[-] Themes.php~
[edit]
[-] Errors.php
[edit]
[-] ManagePermissions.php
[edit]
[-] SplitTopics.php
[edit]
[-] Profile-Modify.php
[edit]
[-] Themes.php
[edit]
[-] Register.php
[edit]
[-] Profile-Export.php
[edit]
[-] ManageServer.php~
[edit]
[-] Subs-Auth.php
[edit]
[-] PersonalMessage.php~
[edit]
[-] ManageSearchEngines.php
[edit]
[-] Drafts.php
[edit]
[-] Subs-Package.php~
[edit]
[-] Subs-MembersOnline.php
[edit]
[-] ManageCalendar.php
[edit]
[-] Memberlist.php~
[edit]
[-] QueryString.php
[edit]
[-] Poll.php
[edit]
[-] ManageMembergroups.php
[edit]
[+]
tasks
[-] ManageSearch.php
[edit]
[-] Subs-Auth.php~
[edit]
[-] Agreement.php~
[edit]
[-] Topic.php
[edit]
[-] QueryString.php~
[edit]
[-] ViewQuery.php
[edit]
[-] ManageMaintenance.php~
[edit]
[-] PackageGet.php
[edit]
[-] Post.php
[edit]
[-] Subs-Timezones.php
[edit]
[-] ManageErrors.php~
[edit]
[-] Post.php~
[edit]
[-] SearchAPI-Fulltext.php~
[edit]
[-] Profile-View.php
[edit]
[-] Subs-OpenID.php
[edit]
[-] ManageBans.php
[edit]
[-] Class-CurlFetchWeb.php
[edit]
[-] DbExtra-sqlite.php
[edit]
[-] ManageNews.php~
[edit]
[-] Subscriptions-PayPal.php
[edit]
[-] ManageSearchEngines.php~
[edit]
[-] RepairBoards.php
[edit]
[-] Class-BrowserDetect.php
[edit]
[+]
ReCaptcha
[-] Subs-List.php
[edit]
[-] Notify.php~
[edit]
[-] ManageSettings.php
[edit]
[-] RepairBoards.php~
[edit]
[-] Subs-Themes.php
[edit]
[-] Search.php
[edit]
[-] SearchAPI-Fulltext.php
[edit]