好!欢迎访问迷津渡口 现在时间是: 天气 °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
   支持一下
挤眼 亲亲 咆哮 开心 想想 可怜 糗大了 委屈 哈哈 小声点 右哼哼 左哼哼 疑问 坏笑 赚钱啦 悲伤 耍酷 勾引 厉害 握手 耶 嘻嘻 害羞 鼓掌 馋嘴 抓狂 抱抱 围观 威武 给力
 点赞
 签到
 表情
 图片
 代码
提交评论

清空信息
关闭评论
paolamoney
 paolamoney 约 21 小时前回复
#83
<a href="http://www.knapzac.com/nike-justin-evans-ash-backer-tampa-bay-buccaneers-nfl-21-t-shirt-nflr">nike justin evans ash backer tampa bay buccaneers nfl 21 t shirt</a> <a href="http://www.nipiservices.com/nike-free-run-4.0-v2-sort-and-bl%C3%A5-kurpesf">nike free run 4.0 v2 sort and bl氓</a> <a href="http://www.awningsbyben.com/nike-zoom-hyperrev-2015-rojo-head-schuhef">nike zoom hyperrev 2015 rojo head</a> <a href="http://www.blogtourney.com/nike-zoom-tutti-out-bianca-blu-obuvg">nike zoom tutti out bianca blu</a> <a href="http://www.buranna.com/nike-air-max-lunar-90-jcrd-rojo-clay-chaussuresa">nike air max lunar 90 jcrd rojo clay</a> <a href="http://www.cardilwo.com/nike-kd-9-negro-fluorescent-verde-butya">nike kd 9 negro fluorescent verde</a>
paolamoney http://www.paolamoney.com/
fizalisfresh
 fizalisfresh 2019-02-14 22:39回复
#82
<a href="http://www.cardiachits.com/air-jordan-retro-13-blue-green-shoesh">air jordan retro 13 blue green</a> <a href="http://www.zestchannel.com/femminile-air-jordan-retro-1-rosa-viola-scarpei">femminile air jordan retro 1 rosa viola</a> <a href="http://www.eczacinim.com/air-jordan-retro-4-dam%C3%A4nner-gold-rot-schuhej">air jordan retro 4 dam盲nner gold rot</a> <a href="http://www.chilangorails.com/usc-trojans-nike-ncaa-col-aro-swooshflex-cap-hath">usc trojans nike ncaa col aro swooshflex cap</a> <a href="http://www.mariusen.com/adidas-springblade-pro-rose-jaune-chaussuresh">adidas springblade pro rose jaune</a> <a href="http://www.brittonoilco.com/femminile-nike-free-tr-fit-arancia-gituttio-scarpeq">femminile nike free tr fit arancia gituttio</a>
fizalisfresh http://www.fizalisfresh.com/
thefarmergirl
 thefarmergirl 2019-02-14 03:57回复
#81
<a href="http://www.teamdalarna.com/mujeres-nike-air-presto-gris-rosado-zapatosk">mujeres nike air presto gris rosado</a> <a href="http://www.syairshamyoun.com/nike-kobe-9-high-krm-ext-r%C3%B8d-mamba-skoi">nike kobe 9 high krm ext r酶d mamba</a> <a href="http://www.fizalisfresh.com/mennns-asics-asics-gel-kayano-17-gul-hvit-obuvl">mennns asics asics gel kayano 17 gul hvit</a> <a href="http://www.fsscas.com/air-jordan-retro-18-grey-silver-shoesh">air jordan retro 18 grey silver</a> <a href="http://www.imagimp.com/femminile-air-jordan-retro-1-oro-blu-scarpei">femminile air jordan retro 1 oro blu</a> <a href="http://www.burmamaritime.com/nike-kobe-11-flyknit-grau-schuhej">nike kobe 11 flyknit grau</a>
thefarmergirl http://www.thefarmergirl.com/
givenkface
 givenkface 2019-02-13 10:34回复
#80
<a href="http://www.iremaxvn.com/billig-nike-vapormax-dam%C3%A4nner-rosa-skod">billig nike vapormax dam盲nner rosa</a> <a href="http://www.multinutwraps.com/philadelphia-flyers-jersey-nflc">philadelphia flyers jersey</a> <a href="http://www.vipartonline.com/buy-burberry-belt-online-india-beltr">buy burberry belt online india</a> <a href="http://www.wantaoren.com/ray-ban-rb4098-jackie-ohh-ii-sunglasses-shiny-black-egg-sunglassesc">ray ban rb4098 jackie ohh ii sunglasses shiny black egg</a> <a href="http://www.tokodanaya.com/orlando-magic-white-blue-tisa-snapback-cap-style-2-handsome-style-hatg">orlando magic white blue tisa snapback cap style 2 handsome style</a> <a href="http://www.dinerwareoc.com/ray-ban-rb2140-wayfarer-sunglasses-tortoise-frame-brown-polarized-sunglassesd">ray ban rb2140 wayfarer sunglasses tortoise frame brown polarized</a>
givenkface http://www.givenkface.com/
thermilax
 thermilax 2019-02-13 03:11回复
#79
<a href="http://www.maisonbagshop.com/nike-free-3.0-v5-tiffany-blu-nikes-femminile-for-vendita-chaussuresg">nike free 3.0 v5 tiffany blu nikes femminile for vendita</a> <a href="http://www.nomoreash.com/air-jordan-retro-14-thunder-for-vente-oregon-kurpese">air jordan retro 14 thunder for vente oregon</a> <a href="http://www.webeados.com/nike-hyperdunk-2014-low-gul-lyser%C3%B8d-obuva">nike hyperdunk 2014 low gul lyser酶d</a> <a href="http://www.yvutube.com/polo-ralph-lauren-children-big-pony-fleece-zip-hoodie-gr%C3%B8n-polox">polo ralph lauren children big pony fleece zip hoodie gr酶n</a> <a href="http://www.darkangelsmd.com/new-blance-500-enfants-marron-argent-schuhed">new blance 500 enfants marron argent</a> <a href="http://www.gbwpvqyg.com/nike-lunarepic-low-flyknit-for-verkauf-scarpec">nike lunarepic low flyknit for verkauf</a>
[url=http://www.thermilax.com/]thermilax[/url]
truckent
 truckent 2019-02-11 21:58回复
#78
<a href="http://www.cameroncurran.com/nike-youth-leon-hall-limited-white-jersey-oakland-raiders-nfl-29-rush-vapor-untouchable-nflw">nike youth leon hall limited white jersey oakland raiders nfl 29 rush vapor untouchable</a> <a href="http://www.energyawnings.com/nike-zoom-pegasus-31-negro-and-blanco-instructions-chaussuresa">nike zoom pegasus 31 negro and blanco instructions</a> <a href="http://www.fpbsmeeting.com/vibram-fivefingers-flow-hvid-lyser%C3%B8d-butya">vibram fivefingers flow hvid lyser酶d</a> <a href="http://www.ninahblog.com/adidas-ultra-boost-icy-bleu-gun-butyc">adidas ultra boost icy bleu gun</a> <a href="http://www.thecarolinatc.com/le-coq-sportif-sko-r%C3%B8d-orange-obuvg">le coq sportif sko r酶d orange</a> <a href="http://www.cafedegino.com/bon-march%C3%A9-nike-air-max-tailwind-8-kurpesa">bon march茅 nike air max tailwind 8</a>
truckent http://www.truckent.com/
wanbilm
 wanbilm 2019-02-10 03:08回复
#77
<a href="http://www.drmilliecalko.com/kvinners-air-jordan-retro-3-bl%C3%A5-lilla-schuhec">kvinners air jordan retro 3 bl氓 lilla</a> <a href="http://www.jishnuguha.com/nike-air-max-ltd-rojo-negro-and-blanco-chaussurese">nike air max ltd rojo negro and blanco</a> <a href="http://www.joehalvorson.com/lebron-13-mid-argento-butyg">lebron 13 mid argento</a> <a href="http://www.proximityhome.com/air-jordan-retro-6-todas-amarillo-scarpea">air jordan retro 6 todas amarillo</a> <a href="http://www.samexllc.com/air-jordan-retro-5-b%C3%B8rn-gr%C3%A5-schuhec">air jordan retro 5 b酶rn gr氓</a> <a href="http://www.sandeneuhofer.com/nike-air-max-1-essential-turbo-vert-butyf">nike air max 1 essential turbo vert</a>
wanbilm http://www.wanbilm.com/
lavaforchange
 lavaforchange 2019-02-10 02:12回复
#76
<a href="http://www.wuxiangtaichi.com/nike-flyknit-racer-verde-cielo-azul-zapatosk">nike flyknit racer verde cielo azul</a> <a href="http://www.culdesacmag.com/air-jordan-retro-1-kvinders-gr%C3%A5-bl%C3%A5-skoi">air jordan retro 1 kvinders gr氓 bl氓</a> <a href="http://www.livinggreedy.com/nike-lunar-control-3-oransje-obuvl">nike lunar control 3 oransje</a> <a href="http://www.clickstroy.com/air-max-95-essential-black-shoesh">air max 95 essential black</a> <a href="http://www.zotorrent.com/adidas-soccers-scarpe-cielo-blu-verde-scarpei">adidas soccers scarpe cielo blu verde</a> <a href="http://www.viptarimas.com/nike-air-max-2017-gr%C3%BCn-rot-schuhej">nike air max 2017 gr眉n rot</a>
lavaforchange http://www.lavaforchange.com/
rdjanitorial
 rdjanitorial 2019-02-09 09:15回复
#75
<a href="http://www.lagunawoodsre.com/nike-kobe-9-high-gold-orangen-schuhej">nike kobe 9 high gold orangen</a> <a href="http://www.highbacklink.com/adidas-nmd-runner-herre-bl%C3%A5-skoh">adidas nmd runner herre bl氓</a> <a href="http://www.vuurogen.com/femmes-nike-roshe-run-slip-gris-oranger-chaussuresh">femmes nike roshe run slip gris oranger</a> <a href="http://www.rsvppersonnel.com/dallas-mavericks-mitchell--ness-nba-under-over-snapback-cap-hatl">dallas mavericks mitchell  ness nba under over snapback cap</a> <a href="http://www.shonema.com/air-jordan-after-game-argent-bleu-ciel-chaussuresh">air jordan after game argent bleu ciel</a> <a href="http://www.enventsurvey.com/adidas-zx-850-negro-naranja-zapatosp">adidas zx 850 negro naranja</a>
rdjanitorial http://www.rdjanitorial.com/
fincasagaro
 fincasagaro 2019-02-09 06:10回复
#74
<a href="http://www.albainmaz.com/air-jordan-3-infrarot-23-order-scarpec">air jordan 3 infrarot 23 order</a> <a href="http://www.seemyvcard.com/nike-air-max-90-dam%C3%A4nner-blau-lila-kurpesc">nike air max 90 dam盲nner blau lila</a> <a href="http://www.joegauntlett.com/cheap-clear-ray-ban-glasses-sunglassesf">cheap clear ray ban glasses</a> <a href="http://www.rpnailsalon.com/padres-4-wil-myers-dark-blue-alternate-1-cool-base-stitched-mlb-jersey-nflr">padres 4 wil myers dark blue alternate 1 cool base stitched mlb jersey</a> <a href="http://www.hrubinlaser.com/nike-free-everyday-kvinders-s%C3%B8lv-skoa">nike free everyday kvinders s酶lv</a> <a href="http://www.pruvitallday.com/nike-shox-r4-black-and-blue-sneakere">nike shox r4 black and blue</a>
fincasagaro http://www.fincasagaro.com/
顶部留言底部
 00:00/00:00
我想和你虚度时光 - 花房姑娘(9)
  1. 我想和你虚度时光
  2. 花房姑娘
  3. 恋恋风尘
  4. 我喜爱一切不彻底的事物
  5. 我的心里是满的
  6. Long Way
  7. 给少年的歌
  8. 晴日共剪窗
  9. 天上的月你的脸