[外掛]未滿18禁止觀看某版面--1.8.0資料庫版

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

版主: 版主管理群

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

[外掛]未滿18禁止觀看某版面--1.8.0資料庫版

文章 Martinet »

########################################################
## Mod Title: 限制18歲以下的會員瀏覽某版面 --
## Mod Version: 1.8.0
## Mod Date: 2004 2月 23日
##
## By: Martinet Oaf < oafwork@hotmail.com >
##
## Description:
## 需搭配生日Mod使用
## 讓你的某幾個版面不給18歲以下的會員瀏覽
##
#
## Installation Level: 簡單
## Installation Time: 5 分鐘
## Files To Edit: 6
## Included Files: (NONE)
##
########################################################
## Author Notes:
## 抓蟲蟲....抓蟲蟲...抓蟲蟲.......
##
## 讓小正太門在首頁也看不到18X的版面 , 而且從(未滿18無法瀏覽..) 變成 查無此版面\r
##
########################################################


ALTER TABLE `phpbb_forums` ADD `adult_only` INT( 1 ) DEFAULT '0' NOT NULL ;

-----------

打開 viewtopic.php

找到\r

$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, t.topic_last_post_id, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments" . $count_sql . "
FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f" . $join_sql_table . "
WHERE $join_sql
AND f.forum_id = t.forum_id
$order_sql";


裡面找到\r

f.auth_attachments

後面加上

,f.adult_only


找到\r
// Start auth check
//


前面加上

//18禁check By Martinet Oaf~
//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'] );
}
}
}




if(($user_age<18 ||!$userdata['session_logged_in'] ) && $forum_topic_data['adult_only'])
{
message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
}
//18禁check完畢\r

---------

打開 viewforum.php

找到\r

// Start auth check
//


前面加上

//18禁check By Martinet Oaf~
//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'] );
}
}
}




if(($user_age<18 ||!$userdata['session_logged_in'] ) && $forum_row['adult_only'])
{
message_die(GENERAL_MESSAGE, 'Forum_not_exist');
}
//18禁check完畢\r

-----

打開 admin/admin_forums.php

找到
$forumstatus = $row['forum_status'];
後面加上

$forum_adultonly_status = $row['adult_only'];

找到
$forumstatus = FORUM_UNLOCKED;
            $forum_id = '';
            $prune_enabled = '';
後面加上
$forum_adultonly_status = 0;


找到\r
'S_PRUNE_ENABLED' => $prune_enabled,

後面加上

'S_FORUM_ADULTONLY_YES' => ($forum_adultonly_status==1)? 'checked' : '',
'S_FORUM_ADULTONLY_NO' => ($forum_adultonly_status!=1)? 'checked' : '',

找到
'L_DAYS' => $lang['Days'],

後面加上
'L_ADULTONLY' => $lang['adult_only'],
'L_AD_YES' => $lang['adult_only_yes'],
'L_AD_NO' => $lang['adult_only_no'],


找到
$sql = "INSERT INTO " . FORUMS_TABLE . " (forum_id, forum_name, cat_id, forum_desc, forum_order, forum_status, prune_enable" . $field_sql . ")
   VALUES ('" . $next_id . "', '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', " . intval($HTTP_POST_VARS[POST_CAT_URL]) . ", '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', $next_order, " . intval($HTTP_POST_VARS['forumstatus']) . ", " . intval($HTTP_POST_VARS['prune_enable']) . $value_sql . ")";

在行內找到
prune_enable

後面加上

, adult_only

在行內找到

$value_sql

前面加上
",'".$HTTP_POST_VARS['adult_only']."'".


找到\r

$sql = "UPDATE " . FORUMS_TABLE . "
   SET forum_name = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', cat_id = " . intval($HTTP_POST_VARS[POST_CAT_URL]) . ", forum_desc = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', forum_status = " . intval($HTTP_POST_VARS['forumstatus']) . ", prune_enable = " . intval($HTTP_POST_VARS['prune_enable']) . "
   WHERE forum_id = " . intval($HTTP_POST_VARS[POST_FORUM_URL]);

在行內找到\r

prune_enable = " . intval($HTTP_POST_VARS['prune_enable']) . "

後面加上

,adult_only = '".$HTTP_POST_VARS['adult_only']."'
---------

打開 language/your_language/lang_admin.php

找到\r
//
// That's all Folks!
// -------------------------------------------------

前面加上

$lang['adult_only'] = '未滿18歲不能進入本版面?';
$lang['adult_only_yes'] = '是';
$lang['adult_only_no'] = '否';
-----------------

打開 index.php

找到\r
//
// Start output of page
//

前面加上

//18禁check By Martinet Oaf~
//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'] );
}
}
}
if(!$userdata['session_logged_in'])
{
$user_age = 15;
}


找到\r
for($j = 0; $j < $total_forums; $j++)
{


後面加上

$pass = false;
if($forum_data[$j]['adult_only'] ==0 )
{
$pass = true;
}
else if($user_age>=18)
{
$pass = true;
}

找到\r

if ( $is_auth_ary[$forum_id]['auth_view'] )
{


取代為\r
if ( $is_auth_ary[$forum_id]['auth_view'] &&$pass)
{


打開 template/你的風格/admin/forum_edit_body.tpl
找到
<tr>
<td class="row1">{L_FORUM_NAME}</td>
<td class="row2"><input type="text" size="25" name="forumname" value="{FORUM_NAME}" class="post" /></td>
</tr>


後面加上
<tr>
<td class="row1">{L_ADULTONLY}</td>
<td class="row2">{L_AD_YES}<input type="radio" name="adult_only" value="1" class="post" {S_FORUM_ADULTONLY_YES}/>
&nbsp&nbsp&nbsp{L_AD_NO}<input type="radio" name="adult_only" value="0" class="post" {S_FORUM_ADULTONLY_NO}/></td>
</tr>
主題已鎖定

回到「非官方認證外掛」