·设为首页收藏本站📧邮箱修改🎁免费下载专区🔐设置/修改密码👽群雄群聊
返回列表 发布新帖

Discuz periodscheck函数 时间段设置检测

164 0

马上注册,免费下载更多dz插件网资源。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
/**
* 时间段设置检测
* @param $periods - 那种时间段 $settings[$periods]  $settings['postbanperiods'] $settings['postmodperiods']
* @param $showmessage - 是否提示信息
* @return 返回检查结果
*/
function periodscheck($periods, $showmessage = 1) {
        global $_G;
        if(($periods == 'postmodperiods' || $periods == 'postbanperiods') && ($_G['setting']['postignorearea'] || $_G['setting']['postignoreip'])) {
                if($_G['setting']['postignoreip']) {
                        foreach(explode("\n", $_G['setting']['postignoreip']) as $ctrlip) {
                                if(preg_match("/^(".preg_quote(($ctrlip = trim($ctrlip)), '/').")/", $_G['clientip'])) {
                                        return false;
                                        break;
                                }
                        }
                }
                if($_G['setting']['postignorearea']) {
                        $location = $whitearea = '';
                        require_once libfile('function/misc');
                        $location = trim(convertip($_G['clientip'], "./"));
                        if($location) {
                                $whitearea = preg_quote(trim($_G['setting']['postignorearea']), '/');
                                $whitearea = str_replace(array("\\*"), array('.*'), $whitearea);
                                $whitearea = '.*'.$whitearea.'.*';
                                $whitearea = '/^('.str_replace(array("\r\n", ' '), array('.*|.*', ''), $whitearea).')$/i';
                                if(@preg_match($whitearea, $location)) {
                                        return false;
                                }
                        }
                }
        }
        if(!$_G['group']['disableperiodctrl'] && $_G['setting'][$periods]) {
                $now = dgmdate(TIMESTAMP, 'G.i', $_G['setting']['timeoffset']);
                foreach(explode("\r\n", str_replace(':', '.', $_G['setting'][$periods])) as $period) {
                        list($periodbegin, $periodend) = explode('-', $period);
                        if(($periodbegin > $periodend && ($now >= $periodbegin || $now < $periodend)) || ($periodbegin < $periodend && $now >= $periodbegin && $now < $periodend)) {
                                $banperiods = str_replace("\r\n", ', ', $_G['setting'][$periods]);
                                if($showmessage) {
                                        showmessage('period_nopermission', NULL, array('banperiods' => $banperiods), array('login' => 1));
                                } else {
                                        return TRUE;
                                }
                        }
                }
        }
        return FALSE;
}
我要说一句 收起回复

回复

 懒得打字嘛,点击右侧快捷回复【查看最新发布】   【应用商城享更多资源】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

投诉/建议联系

discuzaddons@vip.qq.com

未经授权禁止转载,复制和建立镜像,
如有违反,按照公告处理!!!
  • 联系QQ客服
  • 添加微信客服

联系DZ插件网微信客服|最近更新|Archiver|手机版|小黑屋|DZ插件网! ( 鄂ICP备20010621号-1 )|网站地图

您的IP:3.16.15.149,125.74.42.78,GMT+8, 2024-5-1 11:57 , Processed in 0.191523 second(s), 67 queries , Gzip On, Redis On.

Based on Discuz! W1.0 Licensed

© 2001-2024 Discuz! Team.

关灯 在本版发帖
扫一扫添加微信客服
QQ客服返回顶部
快速回复 返回顶部 返回列表