- ชื่อ: Password Protect Boards
- ผู้เขียน: Dragooon
- นำเสนอโดย: DexMoreGroup
- ประเภท: Security and Moderation
- รองรับ: SMF 1.1.xx
- ปรับปรุงล่าสุด: 8 มีนาคม 2551
- ต้นฉบับ: Password Protect Boards
รายละเอียด mod นี้ใช้สำหรับกำหนดรหัสผ่านในการเข้าใช้งานบอร์ด ซึ่งสามารถกำหนดใช้ในแต่ละบอร์ดได้อย่างอิสระ และแต่ละบอร์ดก็สามารถกำหนดรหัสผ่านให้แตกต่างกันได้
ตัวอย่าง
แก้ไขไฟล์:file $sourcedir/Load.php
ค้นหา -->>
b.ID_THEME, b.override_theme, b.permission_mode, b.countPosts
เพิ่มไว้หลัง -->>
, b.passwd
ค้นหา -->>
'posts_count' => empty($row['countPosts']),
เพิ่มไว้หลัง -->>
'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();
require_once($GLOBALS['sourcedir'] . '/passwdBoard.php');
passwdBoardFailed(!empty($board) ? "board=$board" : "topic=$topic");
}
else
$_SESSION['board_access'][] = $board;
}
ค้นหา -->>
$sc = $_SESSION['rand_code'];
เพิ่มไว้หลัง -->>
if ( !isset($_SESSION['board_access']) )
$_SESSION['board_access'] = array();
ค้นหา -->>
// Registered user.... just the groups in $user_info['groups'].
else
$user_info['query_see_board'] = '(FIND_IN_SET(' . implode(', b.memberGroups) OR FIND_IN_SET(', $user_info['groups']) . ', b.memberGroups))';
เพิ่มไว้หลัง -->>
// 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/BoardIndex.php
ค้นหา -->>
IFNULL(mods_mem.ID_MEMBER, 0) AS ID_MODERATOR, mods_mem.realName AS modRealName
เพิ่มไว้หลัง -->>
, 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.
เพิ่มไว้ก่อน -->>
// Had to copy!
// Password Protect Board Edits
if ($user_info['is_guest'])
$query_see_board = 'FIND_IN_SET(-1, b.memberGroups)';
// Administrators can see all boards.
elseif ($user_info['is_admin'])
$query_see_board = '1';
// Registered user.... just the groups in $user_info['groups'].
else
$query_see_board = '(FIND_IN_SET(' . implode(', b.memberGroups) OR FIND_IN_SET(', $user_info['groups']) . ', b.memberGroups))';
ค้นหา -->>
WHERE $user_info[query_see_board]
แก้เป็น -->>
WHERE $query_see_board
ค้นหา -->>
// Determine a global most recent topic.
if (!empty($row_board['posterTime']) && forum_time(true, $row_board['posterTime']) > $most_recent_topic['timestamp'])
$most_recent_topic = array(
'timestamp' => forum_time(true, $row_board['posterTime']),
'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($row_board['posterTime']) && forum_time(true, $row_board['posterTime']) > $most_recent_topic['timestamp'] && (empty($row_board['passwd']) || in_array($row_board['ID_BOARD'], $_SESSION['board_access']) || $user_info['is_admin']))
$most_recent_topic = array(
'timestamp' => forum_time(true, $row_board['posterTime']),
'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 = \'' . $boardOptions['board_name'] . '\'';
เพิ่มไว้หลัง -->>
if (isset($boardOptions['board_name']))
$boardUpdates[] = 'name = \'' . $boardOptions['board_name'] . '\'';
ค้นหา -->>
b.permission_mode, c.ID_CAT, c.name AS cName, c.catOrder, c.canCollapse
เพิ่มไว้หลัง -->>
, 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
ค้นหา -->>
// Finish off the table.
เพิ่มไว้ก่อน -->>
echo '
<tr>
<td>
<b>', $txt['passwdBoard1'], '</b><br />
', $txt['passwdBoard2'], '<br /><br />
</td>
<td align="right">
<input type="password" name="passwdBoard" value="', $context['board']['passwd'] ? '#FAKEPASSWORD' : '', '" />
</td>
</tr>';
file $themedir/BoardIndex.template.php
ค้นหา -->>
// Show some basic information about the number of posts, etc.
เพิ่มไว้ก่อน -->>
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 '<br/>
', $txt['passwdBoard3'], '
<form style="display:inline" action="', $board['href'], '" method="post">
<input type="password" name="passwd" />
<input type="submit" value="', $txt['passwdBoard4'], '" />
</form>';
else if ( $board['passwd'] )
echo '<img src="', $settings['images_url'], '/icons/quick_lock.gif" style="vertical-align:bottom" title="', $txt['passwdBoard6'], '" />';
ค้นหา -->>
/* The board's and children's 'last_post's have:
time, timestamp (a number that represents the time.), id (of the post), topic (topic id.),
link, href, subject, start (where they should go for the first unread post.),
and member. (which has id, name, link, href, username in it.) */
if (!empty($board['last_post']['id']))
echo '
<b>', $txt[22], '</b> ', $txt[525], ' ', $board['last_post']['member']['link'] , '<br />
', $txt['smf88'], ' ', $board['last_post']['link'], '<br />
', $txt[30], ' ', $board['last_post']['time'];
แก้เป็น -->>
/* The board's and children's 'last_post's have:
time, timestamp (a number that represents the time.), id (of the post), topic (topic id.),
link, href, subject, start (where they should go for the first unread post.),
and member. (which has id, name, link, href, username in it.) */
// Edited by password protect board
if (!empty($board['last_post']['id']) && (empty($board['passwd']) || in_array($board['id'],$_SESSION['board_access']) || $context['user']['is_admin']))
echo '
<b>', $txt[22], '</b> ', $txt[525], ' ', $board['last_post']['member']['link'] , '<br />
', $txt['smf88'], ' ', $board['last_post']['link'], '<br />
', $txt[30], ' ', $board['last_post']['time'];
file $themedir/languages/Modifications.thai-utf8.php
เพิ่ม -->>
ขออภัย! ส่วนนี้สงวนไว้เฉพาะสมาชิกเท่านั้น กรุณา เข้าสู่ระบบ หรือ ลงทะเบียนดาวน์โหลด: passwdBoard.rar
ขออภัย! ส่วนนี้สงวนไว้เฉพาะสมาชิกเท่านั้น กรุณา เข้าสู่ระบบ หรือ ลงทะเบียนแตกไฟล์แล้วอัพโหลดไปไว้ที่
file passwdBoard.php -->> $sourcedir
file passwdBoard.template.php -->> $themesdir/default
สร้างไฟล์: add_settings.php เพื่อสร้างฐานข้อมูล ไว้ใน $boarddir (ที่เดียวกับไฟล์ SSI.php) รัน http://www.your_url.xxx/$boarddir/add_settings.php -->> Enter เสร็จแล้วลบทิ้ง
<?php
/**********************************************************
* IgnoreBoards
* Written by Michael Miller
* copyright (C) 2004 Michael Miller
**********************************************************/
// 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.');
$res = db_query("SHOW COLUMNS FROM {$db_prefix}boards LIKE 'passwd'", __FILE__, __LINE__);
if ( mysql_num_rows($res) == 0 )
{
$res = db_query("ALTER TABLE {$db_prefix}boards ADD passwd VARCHAR(64) NOT NULL", __FILE__, __LINE__);
if ( !$res )
echo "Could not alter the table: {$db_prefix}boards to add in the required column";
}
?>
การตั้งค่า: ผู้ดูแล -->> แก้ไขบอร์ด -->> ใช้รหัสผ่านสำหรับบอร์ดนี้
ลิงค์หัวข้อ:
http://dexmore.com/topic/2215