18禁區年齡限制[各版面後台設置]

Home Home
引用 | 編輯 香吉士
2009-09-21 18:54
樓主
推文 x1
【插件資訊】

插件名稱:18禁區年齡限制[各版面後台設置]
適用版本:7.0
語言編碼:通用
插件作者:藍天綠地 |修改版:pole1010
版權所屬:藍天綠地 |修改版:pole1010
原帖連結:http://coz.tw/dz6/thread-15990-1-1.html
支持網站:http://pole.twhosts.info/upload/forumdisplay.php?fid=13

【插件說明】

數據庫升級
複製程式
ALTER TABLE `cdb_forums` ADD `isadult` TINYINT( 1 ) DEFAULT '0' NOT NULL

include/common.inc.php

複製程式
m.sigstatus,
之前加入
複製程式
m.bday,

forumdisplay.php

複製程式
    } elseif($forum['password'] != $_DCOOKIE['fidpw'.$fid]) {
                include template('forumdisplay_passwd');
                exit();
        }
}

下面加
複製程式
if ($bday == '0000-00-00') {
    if ($forum['isadult']) {
                showmessage('你還未設定生日日期,請先到控制台設定。','memcp.php?action=profile');
        }
}else{
        list($year, $month, $day) = explode('-', $bday);
        $bday = intval($year) ? $dateformat : preg_replace("/[^nj]*[Yy][^nj]*/", '', $dateformat);
        $bday = str_replace('n', $month, $bday);
        $bday = str_replace('j', $day, $bday);
        $bday = str_replace('Y', $year, $bday);
        $bday = str_replace('y', substr($year, 2, 4), $bday);
        $birth_y = date("y");
        $birth_m = date("m");
        $birth_d = date("d");
        $birthyear = intval($bday);
        $birthyears = $year > $birth_y ? gmdate('Y', $timestamp + $data['timeoffset'] * 3600) - $birthyear : '';
        $checkbday = $birthyears ? ''.($birth_m > $month ? $birthyears : ''.($birth_m >= $month && $birth_d >= $day ? $birthyears : $birthyears - 1).'').'' : '';
}

if ($forum['isadult'] && $checkbday < 18) {
    if ($groupid != 7) {
                showmessage('對不起!您現時只有 '.$checkbday.' 歲,本論壇只有 18 歲以上用戶才可以訪問,請返回。','index.php');
        }else{
                showmessage('對不起!請您先登入或註冊,本論壇只有 18 歲以上用戶才可以訪問,請返回。','logging.php?action=login');
        }
}

viewthread.php

複製程式
if(empty($forum['allowview'])) {

        if(!$forum['viewperm'] && !$readaccess) {
                showmessage('group_nopermission', NULL, 'NOPERM');
        } elseif($forum['viewperm'] && !forumperm($forum['viewperm'])) {
                $navtitle = '';
                showmessage('forum_nopermission', NULL, 'NOPERM');
        }

下面加
複製程式
if ($bday == '0000-00-00') {
    if ($forum['isadult']) {
                showmessage('你還未設定生日日期,請先到控制台設定。','memcp.php?action=profile');
        }
}else{
        list($year, $month, $day) = explode('-', $bday);
        $bday = intval($year) ? $dateformat : preg_replace("/[^nj]*[Yy][^nj]*/", '', $dateformat);
        $bday = str_replace('n', $month, $bday);
        $bday = str_replace('j', $day, $bday);
        $bday = str_replace('Y', $year, $bday);
        $bday = str_replace('y', substr($year, 2, 4), $bday);
        $birth_y = date("y");
        $birth_m = date("m");
        $birth_d = date("d");
        $birthyear = intval($bday);
        $birthyears = $year > $birth_y ? gmdate('Y', $timestamp + $data['timeoffset'] * 3600) - $birthyear : '';
        $checkbday = $birthyears ? ''.($birth_m > $month ? $birthyears : ''.($birth_m >= $month && $birth_d >= $day ? $birthyears : $birthyears - 1).'').'' : '';
}

if ($forum['isadult'] && $checkbday < 18) {
    if ($groupid != 7) {
                showmessage('對不起!您現時只有 '.$checkbday.' 歲,本論壇只有 18 歲以上用戶才可以訪問,請返回。','index.php');
        }else{
                showmessage('對不起!請您先登入或註冊,本論壇只有 18 歲以上用戶才可以訪問,請返回。','logging.php?action=login');
        }
}

admin/forums.inc.php

複製程式
showsetting('forums_edit_basic_display', 'statusnew', $forum['status'], 'radio');
下面加
複製程式
showsetting('forums_edit_basic_isadult', 'isadultnew', $forum['isadult'], 'radio');


複製程式
status='$statusnew',

後面加(要空白一格)
複製程式
isadult='$isadultnew',
templates/default/admincp.lang.php

複製程式
'forums_edit_basic_scheme' => '論壇設置方案:',

上面加
複製程式
'forums_edit_basic_isadult' => '18禁板塊:',
'forums_edit_basic_isadult_comment' => '限制瀏覽會員必須為18歲以上',

限制發文回覆
post.php

複製程式
if(empty($forum['allowview'])) {
        if(!$forum['viewperm'] && !$readaccess) {
                showmessage('group_nopermission', NULL, 'NOPERM');
        } elseif($forum['viewperm'] && !forumperm($forum['viewperm'])) {
                showmessage('forum_nopermission', NULL, 'NOPERM');
        }

下面加
複製程式
if ($bday == '0000-00-00') {
    if ($forum['isadult']) {
                showmessage('你還未設定生日日期,請先到控制台設定。','memcp.php?action=profile');
        }
}else{
        list($year, $month, $day) = explode('-', $bday);
        $bday = intval($year) ? $dateformat : preg_replace("/[^nj]*[Yy][^nj]*/", '', $dateformat);
        $bday = str_replace('n', $month, $bday);
        $bday = str_replace('j', $day, $bday);
        $bday = str_replace('Y', $year, $bday);
        $bday = str_replace('y', substr($year, 2, 4), $bday);
        $birth_y = date("y");
        $birth_m = date("m");
        $birth_d = date("d");
        $birthyear = intval($bday);
        $birthyears = $year > $birth_y ? gmdate('Y', $timestamp + $data['timeoffset'] * 3600) - $birthyear : '';
        $checkbday = $birthyears ? ''.($birth_m > $month ? $birthyears : ''.($birth_m >= $month && $birth_d >= $day ? $birthyears : $birthyears - 1).'').'' : '';
}

if ($forum['isadult'] && $checkbday < 18) {
    if ($groupid != 7) {
                showmessage('對不起!您現時只有 '.$checkbday.' 歲,本論壇只有 18 歲以上用戶才可以訪問,請返回。','index.php');
        }else{
                showmessage('對不起!請您先登入或註冊,本論壇只有 18 歲以上用戶才可以訪問,請返回。','logging.php?action=login');
        }
}

更新緩存
修改完後請至版塊限制!!
後臺顯示:


如未達到年齡:




反安裝
複製程式
ALTER TABLE `cdb_forums` DROP `isadult` TINYINT( 1 ) DEFAULT '0' NOT NULL


獻花 x1