[原創]限制18歲以下的會員瀏覽某版面---需搭配生日MOD

MODs Released by Other phpbb Sites
非官方認證通過之 MOD ,或許有安全性之疑慮,所有問題由原發表者回覆!

版主: 版主管理群

主題已鎖定
Martinet
竹貓忠實會員
竹貓忠實會員
文章: 850
註冊時間: 2003-06-09 21:58
聯繫:

[原創]限制18歲以下的會員瀏覽某版面---需搭配生日MOD

文章 Martinet »

########################################################
## Mod Title: 限制18歲以下的會員瀏覽某版面\r
## Mod Version: 1.0
## Mod Date: 2003 10月 31日
##
## By: Martinet Oaf < oafwork@hotmail.com >
##
## Description:
## 需搭配生日Mod使用
## 讓你的某一個版面不給18歲以下的會員瀏覽
##
#
## Installation Level: 簡單
## Installation Time: 1 分鐘不到 ^^"
## Files To Edit: 2
## Included Files: (NONE)
##
########################################################
## Author Notes:
## 我的站 : http://oafwork.sytes.net/letstalk/
## 這個Mod是我裝在筆記型電腦上..所以沒辦法把demo給大家看..在此說聲sorry^^"
########################################################

到viewtopic.php 及 viewforum.php 下尋找 (兩個都要喔)

代碼: 選擇全部

// Start auth check 
// 
在後面加上 :
//18禁check By Martinet Oaf~~ y^^Y
//echo $userdata['user_id'];
$idtemp = $userdata['user_id'];
$time_now = time();
$date_now = create_date('md', $time_now, $board_config['board_timezone']);
$date_forward = create_date('md', $time_now+($board_config['birthday_check_day']*86400), $board_config['board_timezone']);
$sql = "SELECT user_id, username, user_birthday, user_level FROM ".USERS_TABLE." WHERE user_id= $idtemp";
if(!$result = $db->sql_query($sql))
{
$pass = "false";
message_die(GENERAL_ERROR, "Could not fetch birthday for users.", "", __LINE__, __FILE__, $sql);
} else
{
$birthdayrows = array();
$birthdayrows = $db->sql_fetchrowset($result);
}
if (!empty($birthdayrows))
{
$this_year = create_date('Y', $time_now, $board_config['board_timezone']);
$date_today = $this_year.$date_now;
$date_forward = $this_year.$date_forward;
while (list($user_number, $birthdayrow) = each($birthdayrows))
{
$user_birthday2 = $this_year.($user_birthday = realdate("md",$birthdayrow['user_birthday'] ));
// give user a year more, if he alread have had birthday
$user_age = $this_year - realdate ( 'Y',$birthdayrow['user_birthday'] );
if ( $user_birthday2 < $date_today ) $user_birthday2 += 10000;
if ( $user_birthday2 == $date_today )
{
//user have birthday today
$user_age = $this_year - realdate ( 'Y',$birthdayrow['user_birthday'] );
}
}
}


$is_auth = array();
$is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_row);


if(($user_age<18 ||!$userdata['session_logged_in'] ) && $forum_id==2)
{
$pass = "false";
if ( !$userdata['session_logged_in'] )
{
$redirect = POST_FORUM_URL . "=$forum_id" . ( ( isset($start) ) ? "&start=$start" : '' );
redirect(append_sid("login.$phpEx?redirect=viewforum.$phpEx&$redirect", true));
}
//
// The user is not authed to read this forum ...
//
$message = "對不起....只有<b><font color=red>18歲以上</font></b>的人才可以瀏覽本文章";

message_die(GENERAL_MESSAGE, $message);


}
//18禁check 完畢
紅色的部分請改成$forum_id==你的版面ID
譬如說..該版面的網址是 http://xxxx/xxxx/viewforum.php?f=7
則他的版面ID是 7
主題已鎖定

回到「非官方認證外掛」