Пример #1
0
 public function praseComment($val, $num, $last, $data)
 {
     $val['comment_text'] = mgStripTags($data['substr'] ? mgSubStr($val['comment_text'], 0, $data['substr'], $data['trim']) : $val['comment_text']);
     $val['comment_date'] = date($data['datefmt'], $this->stack['static_var']['time_zone'] + $val['comment_date']);
     $val['comment_alt'] = $num % 2;
     return $val;
 }
Пример #2
0
 public function prasePost($val, $num, $last)
 {
     $val["post_content"] = $this->getArgs["striptags"] ? mgStripTags($val["post_content"]) : $val["post_content"];
     if (!$this->getArgs["content"]) {
         $post = explode("<!--more-->", $val["post_content"]);
         $val["post_content"] = $this->getArgs["sub"] == 0 ? $post[0] : mgSubStr($post[0], 0, $this->getArgs["sub"]);
     }
     $val["post_alt"] = $num % 2;
     $val["post_tags"] = $val["post_tags"] ? explode(",", $val["post_tags"]) : array();
     $val["post_utc"] = $this->stack['static_var']['time_zone'] + $val["post_time"];
     $val["post_time"] = date($this->getArgs["time_format"], $val["post_utc"]);
     $val["post_year"] = date("Y", $val["post_utc"]);
     $val["post_month"] = date("n", $val["post_utc"]);
     $val["post_day"] = date("j", $val["post_utc"]);
     $val["post_is_last"] = $last;
     if ($val['post_is_page']) {
         $val["permalink"] = $this->stack['static_var']['index'] . vsprintf($this->stack['permalink']['pages']['path'], mgArrayIntersectKey($val, $this->stack['permalink']['pages']['value']));
     } else {
         $val["permalink"] = $this->stack['static_var']['index'] . vsprintf($this->stack['permalink']['archives']['path'], mgArrayIntersectKey($val, $this->stack['permalink']['archives']['value']));
     }
     $val["category_permalink"] = $this->stack['static_var']['index'] . vsprintf($this->stack['permalink']['category']['path'], mgArrayIntersectKey($val, $this->stack['permalink']['category']['value']));
     $val["trackback_permalink"] = $this->stack['static_var']['index'] . vsprintf($this->stack['permalink']['trackbacks']['path'], mgArrayIntersectKey($val, $this->stack['permalink']['trackbacks']['value']));
     $val["rss_permalink"] = $this->stack['static_var']['index'] . vsprintf($this->stack['permalink']['archives_rss']['path'], mgArrayIntersectKey($val, $this->stack['permalink']['archives_rss']['value']));
     $val["post_comment_url"] = $this->stack['static_var']['index'] . vsprintf($this->stack['permalink']['post_comment']['path'], mgArrayIntersectKey($val, $this->stack['permalink']['post_comment']['value']));
     return $val;
 }
Пример #3
0
 public function praseFilter($val)
 {
     if ($filterName = $this->getLanguage($val['comment_filter_name'], 'comment_filter')) {
         $val['comment_filter_name'] = $filterName;
     }
     $val['comment_filter_type'] = $this->getLanguage('filter_' . $val['comment_filter_type'], 'comment_filter');
     $val['comment_filter_value'] = mgStripTags(mgSubStr($val['comment_filter_value'], 0, 30));
     return $val;
 }
Пример #4
0
 public function runModule($args)
 {
     $require = array('count' => 20, 'id' => null, 'time_format' => $this->stack['static_var']['post_date_format'], 'sub' => 10);
     $getArgs = $this->initArgs($args, $require);
     $item = Json::json_decode(file_get_contents("http://api.fanfou.com/statuses/user_timeline.json?id={$getArgs['id']}&count={$getArgs['count']}"));
     $result = array();
     foreach ($item as $val) {
         $result[] = array('screen_name' => $val->user->screen_name, 'id' => $val->user->id, 'name' => $val->user->name, 'location' => $val->user->location, 'description' => $val->user->description, 'profile_image_url' => $val->user->profile_image_url, 'url' => $val->user->url, 'protected' => $val->user->protected, 'created_at' => date($getArgs['time_format'], strtotime($val->created_at) + (28800 - $this->stack['static_var']['server_timezone'])), 'status_id' => $val->id, 'text' => $getArgs['sub'] == 0 ? $val->text : mgSubStr($val->text, 0, $getArgs['sub']));
     }
     return $result;
 }
Пример #5
0
 public function praseComment($val, $num, $last, $data)
 {
     if ($val['comment_publish'] == 'waitting' || $val['comment_publish'] == 'spam') {
         if ($_SERVER["REMOTE_ADDR"] != $val['comment_ip'] || $_SERVER["HTTP_USER_AGENT"] != $val['comment_agent']) {
             return false;
         }
     }
     $val['comment_text'] = nl2br(mgStripTags($data['substr'] ? mgSubStr($val['comment_text'], 0, $data['substr'], $data['trim']) : $val['comment_text']));
     $val['comment_date'] = date($data['time_format'], $this->stack['static_var']['time_zone'] + $val['comment_date']);
     $val['comment_alt'] = $num % 2;
     return $val;
 }
Пример #6
0
 public function runModule($args)
 {
     $require = array('id' => null, 'time_format' => $this->stack['static_var']['post_date_format'], 'sub' => 10);
     $getArgs = $this->initArgs($args, $require);
     $xmlDocument = new DOMDocument("1.0", "UTF-8");
     $xmlDocument->loadXML(file_get_contents("http://ws.audioscrobbler.com/1.0/user/{$getArgs['id']}/recenttracks.xml"));
     $xpath = new DOMXPath($xmlDocument);
     $item = $xpath->query("//recenttracks/track");
     $result = array();
     foreach ($item as $val) {
         $result[] = array('artist' => $val->childNodes->item(1)->nodeValue, 'name' => $getArgs['sub'] == 0 ? $val->childNodes->item(3)->nodeValue : mgSubStr($val->childNodes->item(3)->nodeValue, 0, $getArgs['sub']), 'mbid' => $val->childNodes->item(5)->nodeValue, 'album' => $val->childNodes->item(7)->nodeValue, 'url' => $val->childNodes->item(9)->nodeValue, 'date' => date($getArgs['time_format'], $val->childNodes->item(11)->getAttribute("uts") + (28800 - $this->stack['static_var']['server_timezone'])), 'timestamp' => $val->childNodes->item(11)->getAttribute("uts"));
     }
     return $result;
 }
Пример #7
0
 public function praseComment($val, $num, $last)
 {
     $val = $this->prasePost($val, $num, $last);
     if (($val['comment_publish'] == 'waitting' || $val['comment_publish'] == 'spam') && $this->getArgs['private']) {
         if ($_SERVER["REMOTE_ADDR"] != $val['comment_ip'] || $_SERVER["HTTP_USER_AGENT"] != $val['comment_agent']) {
             return false;
         }
     }
     $val['comment_text'] = mgStripTags($val['comment_text']);
     $val['comment_text'] = $this->getArgs['striptags'] ? $val["comment_text"] : nl2br($val["comment_text"]);
     $val['comment_text'] = $this->getArgs['substr'] ? mgSubStr($val['comment_text'], 0, $this->getArgs['substr']) : $val['comment_text'];
     $val['comment_date'] = date($this->getArgs['time_format'], $this->stack['static_var']['time_zone'] + $val['comment_date']);
     $val['comment_alt'] = $num % 2;
     $val['comment_is_last'] = $last;
     return $val;
 }
Пример #8
0
 public function runModule()
 {
     $result = array();
     if (isset($_GET['cf_id'])) {
         $filterModel = $this->loadModel('comment_filters');
         $result = $filterModel->fetchOneByKey($_GET['cf_id']);
         $this->stack['admin_menu_list']['children'][2]['menu_name'] = '编辑 "' . mgSubStr($this->getLanguage($result['comment_filter_name'], 'comment_filter'), 0, 15, '...') . '"';
         $this->stack['admin_menu_list']['children'][2]['path_name'] = '/admin/comments/filter/?cf_id=' . $_GET['cf_id'];
         $this->stack['static_var']['admin_title'] = '编辑 "' . mgSubStr($this->getLanguage($result['comment_filter_name'], 'comment_filter'), 0, 15, '...') . '"';
         $result['do'] = 'update';
         return $result;
     } else {
         $result['comment_filter_type'] = 'all';
         $result['do'] = 'insert';
         $result['comment_filter_name'] = NULL;
         return $result;
     }
 }
Пример #9
0
 public function insertComment()
 {
     $this->showWord = false;
     if ($this->stack['static_var']['comment_ajax_validator'] && !$this->stack['access']['login']) {
         $this->requirePost();
     }
     $postModel = $this->loadModel('posts');
     $commentModel = $this->loadModel('comments');
     $post = array();
     $input = array();
     if (isset($_GET['post_id'])) {
         $post = $postModel->fetchPostById($_GET['post_id'], NULL, false);
     } else {
         if (isset($_GET['post_name'])) {
             $post = $postModel->fetchPostByName($_GET['post_name'], NULL, false);
         }
     }
     if ($post && $post['post_allow_comment']) {
         $this->result['open'] = true;
         $this->result['word'] = '感谢您的参与,您的评论已经提交';
         $input['comment_publish'] = 'approved';
         $input['comment_date'] = time() - $this->stack['static_var']['server_timezone'];
         $input['post_id'] = $post['post_id'];
         $input['comment_type'] = 'comment';
         $input['comment_agent'] = $_SERVER["HTTP_USER_AGENT"];
         $input['comment_ip'] = $_SERVER["REMOTE_ADDR"];
         $input['comment_user'] = isset($_POST['comment_user']) ? $_POST['comment_user'] : NULL;
         $input['comment_email'] = isset($_POST['comment_email']) ? $_POST['comment_email'] : NULL;
         $input['comment_homepage'] = isset($_POST['comment_homepage']) ? $_POST['comment_homepage'] : NULL;
         $input['comment_text'] = isset($_POST['comment_text']) ? $_POST['comment_text'] : NULL;
         $userModel = $this->loadModel('users');
         if ($this->stack['access']['login']) {
             $user = $userModel->fetchOneByKey($this->stack['access']['user_id']);
             $input['comment_user'] = $user["user_name"];
             $input['comment_email'] = $user["user_mail"];
             $input['comment_homepage'] = $user["user_url"];
         }
         if (NULL == $input['comment_user']) {
             $this->result['word'] = '对不起,您必须填写用户名';
             $this->showWord = true;
             return;
         }
         if (NULL == $input['comment_text']) {
             $this->result['word'] = '对不起,评论内容不能为空';
             $this->showWord = true;
             return;
         }
         if ($this->stack['static_var']['comment_email_notnull'] && NULL == $input['comment_email']) {
             $this->result['word'] = '对不起,您必须填写电子邮件';
             $this->showWord = true;
             return;
         }
         if ($this->stack['static_var']['comment_homepage_notnull'] && NULL == $input['comment_homepage']) {
             $this->result['word'] = '对不起,您必须填写个人主页';
             $this->showWord = true;
             return;
         }
         if ($this->stack['static_var']['comment_check']) {
             $this->result['word'] = '您的评论正在等待审核';
             $input['comment_publish'] = 'waitting';
             $this->showWord = true;
         }
         if (isset($this->stack['comment_filter']) && $this->stack['comment_filter']) {
             $this->result['word'] = $this->stack['comment_filter']['word'];
             $input['comment_publish'] = $this->stack['comment_filter']['publish'];
             $this->showWord = true;
         }
         $commentModel->insertTable($input);
         if ($input['comment_publish'] == 'approved') {
             $postModel->increaseFieldByKey($post['post_id'], 'post_comment_num');
             $staticModel = $this->loadModel('statics');
             $staticModel->increaseValueByName('count_comments');
             $this->deleteCache('static_var');
         }
         //发送邮件提示
         if ($this->stack['static_var']['comment_email'] && $input['comment_publish'] != 'spam') {
             $author = $userModel->fetchOneByKey($post['user_id']);
             if ($author['user_mail']) {
                 $this->result['mailer']['subject'] = '"' . $this->stack['static_var']['blog_name'] . '"回响提示';
                 $this->result['mailer']['body'] = $input['comment_user'] . '在[' . date('Y-m-d H:i:s', $this->stack['static_var']['time_zone'] + $input['comment_date']) . "]说:\r\n" . mgSubStr(mgStripTags($input['comment_text']), 0, 100) . "\r\n" . ($input['comment_email'] ? "\r\n电子邮箱:" . $input['comment_email'] : '') . ($input['comment_homepage'] ? "\r\n网址:" . $input['comment_homepage'] : '');
                 $this->result['mailer']['send_to'] = $author['user_mail'];
                 $this->result['mailer']['send_to_user'] = $author['user_name'];
                 if ($input['comment_publish'] == 'waitting') {
                     $this->result['mailer']['body'] .= "\r\n[这篇评论等待审核]";
                 }
                 if ($input['comment_email']) {
                     $this->result['mailer']['reply'] = array($input['comment_user'], $input['comment_email']);
                 }
             }
         }
     } else {
         $this->result['open'] = true;
         $this->result['word'] = '对不起,该文章禁止评论';
     }
 }
Пример #10
0
 public function insertTrackback()
 {
     $postModel = $this->loadModel('posts');
     $commentModel = $this->loadModel('comments');
     $post = array();
     $input = array();
     if (isset($_GET['post_id'])) {
         $post = $postModel->fetchPostById($_GET['post_id'], NULL, false);
     } else {
         if (isset($_GET['post_name'])) {
             $post = $postModel->fetchPostByName($_GET['post_name'], NULL, false);
         }
     }
     if ($post && $post['post_allow_ping']) {
         $this->result['success'] = '0';
         $this->result['word'] = 'success!';
         $input['comment_publish'] = 'approved';
         $input['comment_date'] = time() - $this->stack['static_var']['server_timezone'];
         $input['post_id'] = $post['post_id'];
         $input['comment_type'] = 'trackback';
         $input['comment_agent'] = $_SERVER["HTTP_USER_AGENT"];
         $input['comment_ip'] = $_SERVER["REMOTE_ADDR"];
         $input['comment_user'] = isset($_POST['blog_name']) ? $_POST['blog_name'] : NULL;
         $input['comment_title'] = isset($_POST['title']) ? $_POST['title'] : NULL;
         $input['comment_homepage'] = isset($_POST['url']) ? $_POST['url'] : NULL;
         $input['comment_text'] = mgSubStr(isset($_POST['excerpt']) ? $_POST['excerpt'] : NULL, 0, 200, '[...]');
         if (NULL == $input['comment_homepage']) {
             $this->result['success'] = '1';
             $this->result['word'] = 'We require all Trackbacks to provide an url.';
             return;
         }
         if (NULL == $input['comment_text']) {
             $this->result['success'] = '1';
             $this->result['word'] = 'We require all Trackbacks to provide an excerption.';
             return;
         }
         if ($this->stack['static_var']['comment_check']) {
             $input['comment_publish'] = 'waitting';
         }
         if (isset($this->stack['comment_filter']) && $this->stack['comment_filter']) {
             $this->result['word'] = $this->stack['comment_filter']['word'];
             $input['comment_publish'] = $this->stack['comment_filter']['publish'];
         }
         $commentModel->insertTable($input);
         if ($input['comment_publish'] == 'approved') {
             $postModel->increaseFieldByKey($post['post_id'], 'post_comment_num');
             $staticModel = $this->loadModel('statics');
             $staticModel->increaseValueByName('count_comments');
             $this->deleteCache('static_var');
         }
         //发送邮件提示
         if ($this->stack['static_var']['comment_email'] && $input['comment_publish'] != 'spam') {
             $userModel = $this->loadModel('users');
             $author = $userModel->fetchOneByKey($post['user_id']);
             if ($author['user_mail']) {
                 $this->result['mailer']['subject'] = '"' . $this->stack['static_var']['blog_name'] . '"回响提示';
                 $this->result['mailer']['body'] = $input['comment_user'] . '在[' . date('Y-m-d H:i:s', $this->stack['static_var']['time_zone'] + $input['comment_date']) . "]发布引用通告:\r\n" . mgSubStr(mgStripTags($input['comment_text']), 0, 100) . "\r\n" . ($input['comment_homepage'] ? "\r\n网址:" . $input['comment_homepage'] : '');
                 if ($input['comment_publish'] == 'waitting') {
                     $this->result['mailer']['body'] .= "\r\n[这篇引用通告等待审核]";
                 }
                 $this->result['mailer']['send_to'] = $author['user_mail'];
                 $this->result['mailer']['send_to_user'] = $author['user_name'];
             }
         }
     } else {
         $this->result['success'] = '1';
         $this->result['word'] = 'Invalid ID or the ID refers to a locked entry.';
     }
 }