comment = array('Intercept', 'message'); class Intercept { public static function message($comment) { /* 校验验证码是否正确 */ $sum = (int)Typecho_Request::getInstance()->sum; if (!$sum) throw new Typecho_Widget_Exception('请输入计算结果!', 403); session_start(); if ($sum !== $_SESSION['commentCode']) throw new Typecho_Widget_Exception('计算结果有误,请检查!', 403); /* 用户输入内容画图模式 */ if (preg_match('/\{!\{(.*)\}!\}/', $comment['text'], $matches)) { /* 如果判断是否有双引号,如果有双引号,则禁止评论 */ if (strpos($matches[1], '"') !== false || _checkXSS($matches[1])) { $comment['status'] = 'waiting'; } /* 普通评论 */ } else { /* 判断用户输入是否大于字符 */ if (Helper::options()->JTextLimit && strlen($comment['text']) > Helper::options()->JTextLimit) { $comment['status'] = 'waiting'; } else { /* 判断评论内容是否包含敏感词 */ if (Helper::options()->JSensitiveWords) { if (_checkSensitiveWords(Helper::options()->JSensitiveWords, $comment['text'])) { $comment['status'] = 'waiting'; } } /* 判断评论是否至少包含一个中文 */ if (Helper::options()->JLimitOneChinese === "on") { if (preg_match("/[\x{4e00}-\x{9fa5}]/u", $comment['text']) == 0) { $comment['status'] = 'waiting'; } } } } Typecho_Cookie::delete('__typecho_remember_text'); return $comment; } } /* 邮件通知 */ if ( Helper::options()->JCommentMail === 'on' && Helper::options()->JCommentMailHost && Helper::options()->JCommentMailPort && Helper::options()->JCommentMailFromName && Helper::options()->JCommentMailAccount && Helper::options()->JCommentMailPassword && Helper::options()->JCommentSMTPSecure ) { Typecho_Plugin::factory('Widget_Feedback')->finishComment = array('Email', 'send'); } class Email { public static function send($comment) { $mail = new PHPMailer(); $mail->isSMTP(); $mail->SMTPAuth = true; $mail->CharSet = 'UTF-8'; $mail->SMTPSecure = Helper::options()->JCommentSMTPSecure; $mail->Host = Helper::options()->JCommentMailHost; $mail->Port = Helper::options()->JCommentMailPort; $mail->FromName = Helper::options()->JCommentMailFromName; $mail->Username = Helper::options()->JCommentMailAccount; $mail->From = Helper::options()->JCommentMailAccount; $mail->Password = Helper::options()->JCommentMailPassword; $mail->isHTML(true); $text = $comment->text; $text = preg_replace_callback( '/\:\:\(\s*(呵呵|哈哈|吐舌|太开心|笑眼|花心|小乖|乖|捂嘴笑|滑稽|你懂的|不高兴|怒|汗|黑线|泪|真棒|喷|惊哭|阴险|鄙视|酷|啊|狂汗|what|疑问|酸爽|呀咩爹|委屈|惊讶|睡觉|笑尿|挖鼻|吐|犀利|小红脸|懒得理|勉强|爱心|心碎|玫瑰|礼物|彩虹|太阳|星星月亮|钱币|茶杯|蛋糕|大拇指|胜利|haha|OK|沙发|手纸|香蕉|便便|药丸|红领巾|蜡烛|音乐|灯泡|开心|钱|咦|呼|冷|生气|弱|吐血|狗头)\s*\)/is', function ($match) { return ''; }, $text ); $text = preg_replace_callback( '/\:\@\(\s*(高兴|小怒|脸红|内伤|装大款|赞一个|害羞|汗|吐血倒地|深思|不高兴|无语|亲亲|口水|尴尬|中指|想一想|哭泣|便便|献花|皱眉|傻笑|狂汗|吐|喷水|看不见|鼓掌|阴暗|长草|献黄瓜|邪恶|期待|得意|吐舌|喷血|无所谓|观察|暗地观察|肿包|中枪|大囧|呲牙|抠鼻|不说话|咽气|欢呼|锁眉|蜡烛|坐等|击掌|惊喜|喜极而泣|抽烟|不出所料|愤怒|无奈|黑线|投降|看热闹|扇耳光|小眼睛|中刀)\s*\)/is', function ($match) { return ''; }, $text ); $text = preg_replace('/\{!\{([^\"]*)\}!\}/', '', $text); $html = '