好!欢迎访问迷津渡口 现在时间是: 天气 °C ~ °C

迷津渡口

越感到迷惑 越接近真理

emlog MVC解构20--控制器Controller之Comment_Controller

Comment_Controller只有一个方法:发表评论。

function addComment($params) {
    // 获取提交的评论名,删除前后的空格,特殊字符添加反斜杠
    $name = isset($_POST['comname']) ? addslashes(trim($_POST['comname'])) : '';
    // 获取提交的评论内容,删除前后的空格,特殊字符添加反斜杠
    $content = isset($_POST['comment']) ? addslashes(trim($_POST['comment'])) : '';
    // 获取提交的评论者邮箱,删除前后的空格,特殊字符添加反斜杠
    $mail = isset($_POST['commail']) ? addslashes(trim($_POST['commail'])) : '';
    // 获取提交的评论者个人网站网址,删除前后的空格,特殊字符添加反斜杠
    $url = isset($_POST['comurl']) ? addslashes(trim($_POST['comurl'])) : '';
    // 获取提交的验证码,转换为大写,删除前后的空格,特殊字符添加反斜杠
    $imgcode = isset($_POST['imgcode']) ? addslashes(trim(strtoupper($_POST['imgcode']))) : '';
    // 获取提交的评论的日志ID
    $blogId = isset($_POST['gid']) ? intval($_POST['gid']) : -1;
    // 获取提交的评论的父评论ID
    $pid = isset($_POST['pid']) ? intval($_POST['pid']) : 0;
    
    // 注册用户且登录
    if (ISLOGIN === true) {
        // 建立缓存对象
        $CACHE = Cache::getInstance();
        // 获取用户缓存信息数组
        $user_cache = $CACHE->readCache('user');
        // 通过缓存获取用户名,特殊字符添加反斜杠
        $name = addslashes($user_cache[UID]['name_orig']);
        // 通过缓存获取用户邮箱,特殊字符添加反斜杠
        $mail = addslashes($user_cache[UID]['mail']);
        // 将本站地址设为个人网站网站,特殊字符添加反斜杠
        $url = addslashes(BLOG_URL);
    }
    
    // $url变量非空,且不管大小写$url的前四个字符不是http,则在$url前面添加http://
    if ($url && strncasecmp($url,'http',4)) {
        $url = 'http://'.$url;
    }
    
    // 执行挂载在'comment_post'钩子上的函数
    // 'comment_post':发表评论扩展点(写入评论前),可用于垃圾评论防范
    doAction('comment_post');
    
    // 建立评论模型
    $Comment_Model = new Comment_Model();
    // 把获取的评论者信息写入cookie
    $Comment_Model->setCommentCookie($name,$mail,$url);
    // 判断评论,输出错误信息
    if($Comment_Model->isLogCanComment($blogId) === false) {
        emMsg('评论失败:该文章已关闭评论');
    } elseif ($Comment_Model->isCommentExist($blogId, $name, $content) === true) {
        emMsg('评论失败:已存在相同内容评论');
    } elseif (ROLE == ROLE_VISITOR && $Comment_Model->isCommentTooFast() === true) {
        emMsg('评论失败:您提交评论的速度太快了,请稍后再发表评论');
    } elseif (empty($name)) {
        emMsg('评论失败:请填写姓名');
    } elseif (strlen($name) > 20) {
        emMsg('评论失败:姓名不符合规范');
    } elseif ($mail != '' && !checkMail($mail)) {
        emMsg('评论失败:邮件地址不符合规范');
    } elseif (ISLOGIN == false && $Comment_Model->isNameAndMailValid($name, $mail) === false) {
        emMsg('评论失败:禁止使用管理员昵称或邮箱评论');
    } elseif (!empty($url) && preg_match("/^(http|https)\:\/\/[^<>'\"]*$/", $url) == false) {
        emMsg('评论失败:主页地址不符合规范','javascript:history.back(-1);');
    } elseif (empty($content)) {
        emMsg('评论失败:请填写评论内容');
    } elseif (strlen($content) > 8000) {
        emMsg('评论失败:内容不符合规范');
    } elseif (ROLE == ROLE_VISITOR && Option::get('comment_needchinese') == 'y' && !preg_match('/[\x{4e00}-\x{9fa5}]/iu', $content)) {
        emMsg('评论失败:评论内容需包含中文');
    } elseif (ISLOGIN == false && Option::get('comment_code') == 'y' && session_start() && $imgcode != $_SESSION['code']) {
        emMsg('评论失败:验证码错误');
    } else { // 评论信息输入正确
        // 清空验证码信息
        $_SESSION['code'] = null;
        // 添加评论
        $Comment_Model->addComment($name, $content, $mail, $url, $imgcode, $blogId, $pid);
    }
}


点赞2
   支持一下
挤眼 亲亲 咆哮 开心 想想 可怜 糗大了 委屈 哈哈 小声点 右哼哼 左哼哼 疑问 坏笑 赚钱啦 悲伤 耍酷 勾引 厉害 握手 耶 嘻嘻 害羞 鼓掌 馋嘴 抓狂 抱抱 围观 威武 给力
 点赞
 签到
 表情
 图片
 代码
提交评论

清空信息
关闭评论
strongtale
 strongtale 约 2 小时前回复
#186
<a href="http://www.chocopictures.com/nike-sb-blazer-low-negro-gum-sole-zapatosk">nike sb blazer low negro gum sole</a> <a href="http://www.baluntan.com/north-face-gore-tex-running-jacket-northfaceh">north face gore tex running jacket</a> <a href="http://www.anderonedream.com/frau-nike-air-zoom-90-it-rosa-wei%C3%9F-schuhek">frau nike air zoom 90 it rosa wei脽</a> <a href="http://www.variaponsel.com/nike-flyknit-triple-sort-skoi">nike flyknit triple sort</a> <a href="http://www.allmydibs.com/nike-air-max-rouge-and-blanc-femmes-chaussuresh">nike air max rouge and blanc femmes</a> <a href="http://www.macusaa.com/kids-miami-dolphins-hat-hatl">kids miami dolphins hat</a>
strongtale http://www.strongtale.com/
dastforoush
 dastforoush 约 9 小时前回复
#185
<a href="http://www.retailnav.com/nike-tiempo-legend-6-azul-zapatosl">nike tiempo legend 6 azul</a> <a href="http://www.merleflugge.com/ray-ban-metal-frame-glasses-sunglassesh">ray ban metal frame glasses</a> <a href="http://www.airfarelinks.com/arizona-cardinals-new-era-nfl-heather-2-tone-9fifty-snapback-hatj">arizona cardinals new era nfl heather 2 tone 9fifty snapback</a> <a href="http://www.vidiyow.com/air-jordan-after-game-bianca-nero-rosso-scarpej">air jordan after game bianca nero rosso</a> <a href="http://www.quiveutdescds.com/nike-gt-blazer-schwarz-schuhei">nike gt blazer schwarz</a> <a href="http://www.wapkaa.com/m%C3%A6nd-nike-lebron-12-bl%C3%A5-gr%C3%A5-orange-skoh">m忙nd nike lebron 12 bl氓 gr氓 orange</a>
dastforoush http://www.dastforoush.com/
chromacell
 chromacell 2019-04-19 08:50回复
#184
<a href="http://www.bradleykountryacres.net/nike-cortez-schwarz-wei%C3%9F-rot-kurpesf">nike cortez schwarz wei脽 rot</a> <a href="http://www.buyggmotors.net/adidas-zx-750-bleu-ciel-rose-schuhed">adidas zx 750 bleu ciel rose</a> <a href="http://www.calvaryneworleans.net/nike-air-max-bw-kvinders-orange-sort-obuvg">nike air max bw kvinders orange sort</a> <a href="http://www.calvarynola.net/nike-free-run-5.0-bl%C3%A5-lyser%C3%B8d-kurpesf">nike free run 5.0 bl氓 lyser酶d</a> <a href="http://www.campaignribbons.net/air-jordan-7-retro-infrarojo-thermostat-kurpesf">air jordan 7 retro infrarojo thermostat</a> <a href="http://www.camxl.net/nike-air-max-2017-femmes-vert-blanc-schuheg">nike air max 2017 femmes vert blanc</a>
chromacell http://www.chromacell.net/
abelsnorth
 abelsnorth 2019-04-19 05:18回复
#183
<a href="http://www.ctnwphoenix.com/lebron-soldier-10-sort-and-r%C3%B8d-rocks-skoh">lebron soldier 10 sort and r酶d rocks</a> <a href="http://www.nunninsurance.com/tom-brady-michigan-jersey-womens-nfli">tom brady michigan jersey womens</a> <a href="http://www.bethliggett.com/adidas-ace-16-all-svart-obuvk">adidas ace 16 all svart</a> <a href="http://www.mikashbaby.com/how-to-tell-if-coach-sunglasses-are-real-coachh">how to tell if coach sunglasses are real</a> <a href="http://www.equidesquercy.com/nike-roshe-run-maschio-nero-and-bianca-scarpej">nike roshe run maschio nero and bianca</a> <a href="http://www.sabatp.com/maschio-nike-free-5.0-arancia-bianca-scarpei">maschio nike free 5.0 arancia bianca</a>
abelsnorth http://www.abelsnorth.com/
prepperdays
 prepperdays 2019-04-17 02:27回复
#182
<a href="http://www.videogue.com/adidas-flux-zx-gold-and-schwarz-schuheh">adidas flux zx gold and schwarz</a> <a href="http://www.actuelvet.com/adidas-15.3-messi-exclusive-fg-yellow-red-black-shoesk">adidas 15.3 messi exclusive fg yellow red black</a> <a href="http://www.jstreetdoc.com/nike-free-tr-blomst-lyser%C3%B8d-skoj">nike free tr blomst lyser酶d</a> <a href="http://www.rightcardeals.com/adidas-gazelle-schwarz-gum-schuheh">adidas gazelle schwarz gum</a> <a href="http://www.wearesmashed.com/nike-free-4.0-flyknit-orange-black-shoesk">nike free 4.0 flyknit orange black</a> <a href="http://www.icecardonline.com/discount-michael-kors-backpack-mkh">discount michael kors backpack</a>
prepperdays http://www.prepperdays.com/
theislandbody
 theislandbody 2019-04-16 17:29回复
#181
<a href="http://www.theislandbody.com/nike-flynit-air-max-femminile-nero-argento-scarpel">nike flynit air max femminile nero argento</a> <a href="http://www.zululeads.com/air-jordan-retro-5-silver-red-shoesj">air jordan retro 5 silver red</a> <a href="http://www.notmyrichie.com/nike-zoom-pegasus-34-kvinders-himmelbl%C3%A5-sort-skoi">nike zoom pegasus 34 kvinders himmelbl氓 sort</a> <a href="http://www.mintyschoice.com/nike-lebron-witness-oro-rosa-scarpeq">nike lebron witness oro rosa</a> <a href="http://www.mamapjblog.com/air-jordan-retro-29-yellow-white-shoesj">air jordan retro 29 yellow white</a> <a href="http://www.pdfunicorn.com/michael-kors-medium-leather-tote-mkh">michael kors medium leather tote</a>
theislandbody http://www.theislandbody.com/
soopsip
 soopsip 2019-04-16 13:51回复
#180
<a href="http://www.chocopictures.com/usc-dad-hat-hath">usc dad hat</a> <a href="http://www.baluntan.com/femmes-nike-flyknit-lunar-3-noir-purplish-rouge-chaussuresh">femmes nike flyknit lunar 3 noir purplish rouge</a> <a href="http://www.anderonedream.com/nike-free-5.0-hot-rose-chaussuresj">nike free 5.0 hot rose</a> <a href="http://www.variaponsel.com/dam%C3%A4nner-nike-air-vapormax-plus-rosa-schuhek">dam盲nner nike air vapormax plus rosa</a> <a href="http://www.allmydibs.com/kyrie-irving-youth-large-jersey-nflh">kyrie irving youth large jersey</a> <a href="http://www.macusaa.com/air-jordan-retro-4.5-gr%C3%A5-rosa-obuvi">air jordan retro 4.5 gr氓 rosa</a>
soopsip http://www.soopsip.com/
batatastudio
 batatastudio 2019-04-16 09:27回复
#179
<a href="http://www.poppiesdelray.com/air-max-90-kvinner-r%C3%B8d-bl%C3%A5-hvit-obuvk">air max 90 kvinner r酶d bl氓 hvit</a> <a href="http://www.soundsofbuzz.com/nike-kobe-11-bianca-and-nero-scarpei">nike kobe 11 bianca and nero</a> <a href="http://www.hozloli.com/nike-magista-opus-tpu-fg-azul-negro-zapatosh">nike magista opus tpu fg azul negro</a> <a href="http://www.privetaustria.com/nike-free-3.0-flyknit-herre-sort-skok">nike free 3.0 flyknit herre sort</a> <a href="http://www.goodnnasty.com/air-jordan-retro-1-r%C3%B8d-and-svart-obuvi">air jordan retro 1 r酶d and svart</a> <a href="http://www.ankarasanal.com/nike-free-flyknit-3.0-azul-zapatosl">nike free flyknit 3.0 azul</a>
batatastudio http://www.batatastudio.com/
anteageserums
 anteageserums 2019-04-15 20:45回复
#178
<a href="http://www.chocopictures.com/adidas-stan-smith-white-gold-silver-shoesj">adidas stan smith white gold silver</a> <a href="http://www.baluntan.com/washington-wizards-mitchell--ness-nba-rugged-snapback-cap-hatk">washington wizards mitchell  ness nba rugged snapback cap</a> <a href="http://www.anderonedream.com/nike-flyknit-air-max-m%C3%A6nd-bl%C3%A5-sort-orange-skoj">nike flyknit air max m忙nd bl氓 sort orange</a> <a href="http://www.variaponsel.com/purple-polo-sweater-poloh">purple polo sweater</a> <a href="http://www.allmydibs.com/adidas-tubular-red-womens-shoesi">adidas tubular red womens</a> <a href="http://www.macusaa.com/nike-free-run-flyknit-5.0-nero-scarpej">nike free run flyknit 5.0 nero</a>
[url=http://www.anteageserums.com/]anteageserums[/url]
alrightdesign
 alrightdesign 2019-04-15 07:50回复
#177
<a href="http://www.sguerradesign.com/texas-rangers-new-era-mlb-retro-classic-batting-practice-59fifty-cap-hath">texas rangers new era mlb retro classic batting practice 59fifty cap</a> <a href="http://www.zeneventsja.com/nike-air-max-97-femmes-violet-rose-chaussuresh">nike air max 97 femmes violet rose</a> <a href="http://www.adharaweb.com/femminile-nike-blazer-tutti-nero-scarpel">femminile nike blazer tutti nero</a> <a href="http://www.jrelselaw.com/womens-nike-free-tr-orange-shoesj">womens nike free tr orange</a> <a href="http://www.intellalegal.com/air-jordan-imminent-lyser%C3%B8d-himmelbl%C3%A5-skoi">air jordan imminent lyser酶d himmelbl氓</a> <a href="http://www.carmelscoffee.com/femminile-nike-air-max-thea-tutti-verde-scarpeq">femminile nike air max thea tutti verde</a>
alrightdesign http://www.alrightdesign.com/
顶部留言底部
 00:00/00:00
我想和你虚度时光 - 花房姑娘(9)
  1. 我想和你虚度时光
  2. 花房姑娘
  3. 恋恋风尘
  4. 我喜爱一切不彻底的事物
  5. 我的心里是满的
  6. Long Way
  7. 给少年的歌
  8. 晴日共剪窗
  9. 天上的月你的脸