- ชื่อ: Password Protect Boards
- ผู้เขียน: Yağız...
- นำเสนอโดย: DexMoreGroup
- ประเภท: Security and Moderation
- รองรับ: SMF 2.0.x
- ปรับปรุงล่าสุด: 1 ตุลาคม 2554
- ต้นฉบับ: Password Protect Boards
รายละเอียด mod นี้ใช้สำหรับกำหนดรหัสผ่านในการเข้าใช้งานบอร์ด ซึ่งสามารถกำหนดใช้ในแต่ละบอร์ดได้อย่างอิสระ และแต่ละบอร์ดก็สามารถกำหนดรหัสผ่านให้แตกต่างกันได้
ตัวอย่าง
แก้ไขไฟล์:file $sourcedir/Load.php
ค้นหา -->>
b.id_theme, b.override_theme, b.count_posts, b.id_profile, b.redirect
เพิ่มไว้หลัง -->>
, b.passwd
ค้นหา -->>
'posts_count' => empty($row['count_posts']),
เพิ่มไว้หลัง -->>
'passwd' => $row['passwd'],
ค้นหา -->>
if ($user_info['is_mod'])
$user_info['groups'][] = 3;
เพิ่มไว้หลัง -->>
// Can they view this board?
if (!$user_info['is_admin'] && !$user_info['is_mod'] && $board_info['passwd'] && !in_array($board, $_SESSION['board_access']))
{
if (!isset($_POST['passwd']) || sha1($board_info['name'] . $_POST['passwd']) != $board_info['passwd'])
{
loadPermissions();
loadTheme();
global $sourcedir;
require_once($sourcedir . '/passwdBoard.php');
passwdBoardFailed(!empty($board) ? "board=$board" : "topic=$topic");
}
else
$_SESSION['board_access'][] = $board;
}
ค้นหา -->>
$sc = $_SESSION['session_value'];
เพิ่มไว้หลัง -->>
if (!isset($_SESSION['board_access']))
$_SESSION['board_access'] = array();
ค้นหา -->>
// Just build this here, it makes it easier to change/use - administrators can see all boards.
if ($user_info['is_admin'])
$user_info['query_see_board'] = '1=1';
// Otherwise just the groups in $user_info['groups'].
else
$user_info['query_see_board'] = '(FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $user_info['groups']) . ', b.member_groups) != 0' . (isset($user_info['mod_cache']) ? ' OR ' . $user_info['mod_cache']['mq'] : '') . ')';
เพิ่มไว้หลัง -->>
// Passwordify it!
if (!$user_info['is_admin'] && !empty($_SESSION['board_access']))
$user_info['query_see_board'] .= 'AND (b.id_board IN (' . implode(',', $_SESSION['board_access']) . ') OR CHAR_LENGTH(b.passwd) = 0)';
elseif (!$user_info['is_admin'])
$user_info['query_see_board'] .= 'AND CHAR_LENGTH(b.passwd) = 0';
file $sourcedir/Subs-BoardIndex.php
ค้นหา -->>
IFNULL(mods_mem.id_member, 0) AS id_moderator, mods_mem.real_name AS mod_real_name
เพิ่มไว้หลัง -->>
, b.passwd
ค้นหา -->>
'href' => $scripturl . '?board=' . $row_board['id_board'] . '.0',
เพิ่มไว้หลัง -->>
'passwd' => !empty($row_board['passwd']),
ค้นหา -->>
// Find all boards and categories, as well as related information. This will be sorted by the natural order of boards and categories, which we control.
เพิ่มไว้ก่อน -->>
if ($user_info['is_guest'])
$query_see_board = 'FIND_IN_SET(-1, b.member_groups)';
elseif ($user_info['is_admin'])
$query_see_board = '1';
else
$query_see_board = '(FIND_IN_SET(' . implode(', b.member_groups) OR FIND_IN_SET(', $user_info['groups']) . ', b.member_groups))';
ค้นหา -->>
WHERE {query_see_board}'
แก้เป็น -->>
WHERE ' . $query_see_board
ค้นหา -->>
// Determine a global most recent topic.
if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard)
$latest_post = array(
'timestamp' => $row_board['poster_time'],
'ref' => &$this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'],
);
แก้เป็น -->>
// Determine a global most recent topic.
// Edited by Password Protect boards
if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard && (empty($row_board['passwd']) || in_array($row_board['id_board'], $_SESSION['board_access']) || $user_info['is_admin']))
$latest_post = array(
'timestamp' => $row_board['poster_time'],
'ref' => &$this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'],
);
file $sourcedir/Subs-Boards.php
if (isset($boardOptions['board_name']))
{
$boardUpdates[] = 'name = {string:board_name}';
$boardUpdateParameters['board_name'] = $boardOptions['board_name'];
}
เพิ่มไว้ก่อน -->>
if (isset($boardOptions['passwd']))
{
$boardUpdates[] = 'passwd = {string:passwd}';
$boardUpdateParameters['passwd'] = $boardOptions['passwd'];
}
ค้นหา -->>
b.num_posts, b.num_topics, c.id_cat, c.name AS cat_name, c.cat_order, c.can_collapse
เพิ่มไว้หลัง -->>
, b.passwd
ค้นหา -->>
'prev_board' => $prevBoard
เพิ่มไว้ก่อน -->>
'passwd' => !empty($row['passwd']),
file $sourcedir/ManageBoards.php
ค้นหา -->>
'override_theme' => 0,
เพิ่มไว้ก่อน -->>
'passwd' => '',
ค้นหา -->>
$boardOptions['board_description'] = preg_replace('~[&]([^;]{8}|[^;]{0,8}$)~', '&$1', $_POST['desc']);
เพิ่มไว้หลัง -->>
if ( $_POST['passwdBoard'] != "#FAKEPASSWORD" )
$boardOptions['passwd'] = !empty($_POST['passwdBoard']) ? sha1($boardOptions['board_name'] . $_POST['passwdBoard']) : '';
file $themedir/ManageBoards.template.php
ค้นหา -->>
if (!empty($context['board']['is_recycle']))
เพิ่มไว้ก่อน -->>
echo '
<div id="passwd_div">
<dl class="settings">
<dt>
<strong>', $txt['mpasswd_board'], ':</strong><br />
<span class="smalltext">', $txt['mpasswd_board_desc'], '</span><br />
</dt>
<dd>
<input type="password" name="passwdBoard" value="', $context['board']['passwd'] ? '#FAKEPASSWORD' : '', '" class="input_text" />
</dd>
</dl>
</div>';
file $themedir/BoardIndex.template.php
ค้นหา -->>
// Show some basic information about the number of posts, etc.
เพิ่มไว้ก่อน -->>
echo '
<p>';
if (!$context['user']['is_admin'] && !$context['user']['is_mod'] && !isset($board['moderators'][$context['user']['id']]) && $board['passwd'] && !in_array($board['id'], $_SESSION['board_access']))
echo '
', $txt['passwd_board'], '
<form style="display:inline" action="', $board['href'], '" method="post">
<input type="password" name="passwd" />
<input type="submit" value="', $txt['passwd_board_enter'], '" />
</form>';
else if ($board['passwd'])
echo '
<img src="', $settings['images_url'], '/icons/quick_lock.gif" style="vertical-align: bottom;" alt="', $txt['passwd_board_notice'], '" title="', $txt['passwd_board_notice'], '" />';
echo '
</p>';
ค้นหา -->>
if (!empty($board['last_post']['id']))
แก้เป็น -->>
if (!empty($board['last_post']['id']) && (empty($board['passwd']) || in_array($board['id'], $_SESSION['board_access']) || $context['user']['is_admin']))
file $themedir/languages/Modifications.english.php
เพิ่ม -->>
// Password Protected Board
$txt['passwd_board'] = 'Please enter the board password: ';
$txt['mpasswd_board'] = 'Password for this board';
$txt['mpasswd_board_desc'] = 'Leave blank for no password';
$txt['passwd_board_enter'] = 'Enter Board';
$txt['passwd_board_notice'] = 'Board is protected';
$txt['passwd_board_error'] = 'This board is password protected and you have not provided the correct password during this session';
file $themedir/languages/Modifications.thai-utf8.php
เพิ่ม -->>
// Password Protected Board
$txt['passwd_board'] = 'กรุณาใส่รหัสผ่านบอร์ด: ';
$txt['mpasswd_board'] = 'รหัสผ่านสำหรับบอร์ดนี้';
$txt['mpasswd_board_desc'] = 'ปล่อยว่าง = ไม่มีรหัสผ่าน';
$txt['passwd_board_enter'] = 'ใส่ชื่อบอร์ด';
$txt['passwd_board_notice'] = 'บอร์ดมีการป้องกัน';
$txt['passwd_board_error'] = 'บอร์ดนี้มีรหัสผ่านป้องกันและคุณยังไม่ได้ใส่รหัสผ่านที่ถูกต้องในระหว่างเซสชันนี้';
ดาวน์โหลด: passwdBoard2.rar
ขออภัย! ส่วนนี้สงวนไว้เฉพาะสมาชิกเท่านั้น กรุณา เข้าสู่ระบบ หรือ ลงทะเบียนแตกไฟล์แล้วอัพโหลดไปไว้ที่
file passwdBoard.php -->> $sourcedir
file passwdBoard.template.php -->> $themesdir/default
สร้างไฟล์: add_settings_20.php เพื่อสร้างฐานข้อมูล ไว้ใน $boarddir (ที่เดียวกับไฟล์ SSI.php) รัน http://www.your_url.xxx/$boarddir/add_settings_20.php -->> Enter เสร็จแล้วลบทิ้ง
<?php
// If SSI.php is in the same place as this file, and SMF isn't defined, this is being run standalone.
if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
require_once(dirname(__FILE__) . '/SSI.php');
// Hmm... no SSI.php and no SMF?
elseif (!defined('SMF'))
die('<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.');
db_extend('Packages');
$smcFunc['db_add_column']('{db_prefix}boards', array('name' => 'passwd', 'type' => 'varchar', 'size' => 64), array(), 'ignore');
?>
การตั้งค่า: ผู้ดูแล -->> แก้ไขบอร์ด -->> รหัสผ่านสำหรับบอร์ดนี้
ลิงค์หัวข้อ:
http://dexmore.com/topic/10847