Esempio n. 1
0
 public function message_parser($input_message, $param = null)
 {
     $message_code = strtoupper(trim($input_message['content']));
     if (cjk_strlen($message_code) < 2) {
         return false;
     }
     if (!$param) {
         $param = 1;
     }
     switch ($message_code) {
         default:
             if (cjk_strlen($input_message['content']) > 1 and substr($input_message['content'], 0, 1) == '@') {
                 if ($user_info = $this->model('account')->get_user_info_by_username(substr($input_message['content'], 1), true)) {
                     $response_message[] = array('title' => $user_info['signature'], 'link' => get_js_url('/m/people/' . $user_info['url_token']), 'image_file' => get_avatar_url($user_info['uid'], ''));
                     if ($user_actions = $this->model('actions')->get_user_actions($user_info['uid'], calc_page_limit($param, 4), 101)) {
                         foreach ($user_actions as $key => $val) {
                             $response_message[] = array('title' => $val['question_info']['question_content'], 'link' => get_js_url('/m/question/' . $val['question_info']['question_id']), 'image_file' => get_avatar_url($val['question_info']['published_uid'], 'max'));
                         }
                     }
                 }
             } else {
                 if ($topic_info = $this->model('topic')->get_topic_by_title($input_message['content'])) {
                     $response_message[] = array('title' => $topic_info['topic_title'], 'link' => get_js_url('/m/topic/' . $topic_info['url_token']), 'image_file' => get_topic_pic_url('', $topic_info['topic_pic']));
                     if ($topic_posts = $this->model('posts')->get_posts_list(null, $param, 4, 'new', array($topic_info['topic_id']))) {
                         foreach ($topic_posts as $key => $val) {
                             if ($val['uid']) {
                                 $image_file = get_avatar_url($val['uid'], 'max');
                                 $title = $val['title'];
                                 $link = get_js_url('/m/article/' . $val['id']);
                             } else {
                                 $image_file = get_avatar_url($val['published_uid'], 'max');
                                 $title = $val['question_content'];
                                 $link = get_js_url('/m/question/' . $val['question_id']);
                             }
                             $response_message[] = array('title' => $title, 'link' => $link, 'image_file' => $image_file);
                         }
                     }
                 } else {
                     if ($search_result = $this->model('search')->search_questions($input_message['content'], null, $param, 5)) {
                         foreach ($search_result as $key => $val) {
                             if (!$response_message) {
                                 $image_file = AWS_APP::config()->get('weixin')->default_list_image;
                             } else {
                                 $image_file = get_avatar_url($val['published_uid'], 'max');
                             }
                             $response_message[] = array('title' => $val['question_content'], 'link' => get_js_url('/m/question/' . $val['question_id']), 'image_file' => $image_file);
                         }
                     }
                 }
             }
             break;
         case 'NEW_ARTICLE':
             if ($input_message['param']) {
                 $child_param = explode('_', $input_message['param']);
                 switch ($child_param[0]) {
                     case 'FEATURE':
                         $topic_ids = $this->model('feature')->get_topics_by_feature_id($child_param[1]);
                         break;
                 }
             }
             if ($topic_ids) {
                 $article_list = $this->model('article')->get_articles_list_by_topic_ids($param, 5, 'add_time DESC', $topic_ids);
             } else {
                 $article_list = $this->model('article')->get_articles_list(null, $param, 5, 'add_time DESC');
             }
             foreach ($article_list as $key => $val) {
                 if (!$response_message) {
                     if (!($image_file = $this->get_client_list_image_by_command('COMMAND_' . $message_code))) {
                         $image_file = AWS_APP::config()->get('weixin')->default_list_image;
                     }
                 } else {
                     $image_file = get_avatar_url($val['uid'], 'max');
                 }
                 $response_message[] = array('title' => $val['title'], 'link' => get_js_url('/m/article/' . $val['id']), 'image_file' => $image_file);
             }
             break;
         case 'HOT_QUESTION':
             if ($input_message['param']) {
                 $child_param = explode('_', $input_message['param']);
                 switch ($child_param[0]) {
                     case 'CATEGORY':
                         $category_id = intval($child_param[1]);
                         break;
                     case 'FEATURE':
                         $topic_ids = $this->model('feature')->get_topics_by_feature_id($child_param[1]);
                         break;
                 }
             }
             if ($question_list = $this->model('posts')->get_hot_posts('question', $category_id, $topic_ids, 7, $param, 5)) {
                 foreach ($question_list as $key => $val) {
                     if (!$response_message) {
                         if (!($image_file = $this->get_client_list_image_by_command('COMMAND_' . $message_code))) {
                             $image_file = AWS_APP::config()->get('weixin')->default_list_image;
                         }
                     } else {
                         $image_file = get_avatar_url($val['published_uid'], 'max');
                     }
                     $response_message[] = array('title' => $val['question_content'], 'link' => get_js_url('/m/question/' . $val['question_id']), 'image_file' => $image_file);
                 }
             } else {
                 $response_message = '暂无问题';
             }
             break;
         case 'NEW_QUESTION':
             if ($input_message['param']) {
                 $child_param = explode('_', $input_message['param']);
                 switch ($child_param[0]) {
                     case 'CATEGORY':
                         $category_id = intval($child_param[1]);
                         break;
                     case 'FEATURE':
                         $topic_ids = $this->model('feature')->get_topics_by_feature_id($child_param[1]);
                         break;
                 }
             }
             if ($question_list = $this->model('posts')->get_posts_list('question', $param, 5, 'new', $topic_ids, $category_id)) {
                 foreach ($question_list as $key => $val) {
                     if (!$response_message) {
                         if (!($image_file = $this->get_client_list_image_by_command('COMMAND_' . $message_code))) {
                             $image_file = AWS_APP::config()->get('weixin')->default_list_image;
                         }
                     } else {
                         if ($val['uid']) {
                             $image_file = get_avatar_url($val['uid'], 'max');
                         } else {
                             $image_file = get_avatar_url($val['published_uid'], 'max');
                         }
                     }
                     if ($val['uid']) {
                         $title = $val['title'];
                         $link = get_js_url('/m/article/' . $val['id']);
                     } else {
                         $title = $val['question_content'];
                         $link = get_js_url('/m/question/' . $val['question_id']);
                     }
                     $response_message[] = array('title' => $title, 'link' => $link, 'image_file' => $image_file);
                 }
             } else {
                 $response_message = '暂无问题';
             }
             break;
         case 'NEW_POSTS':
             if ($input_message['param']) {
                 $child_param = explode('_', $input_message['param']);
                 switch ($child_param[0]) {
                     case 'CATEGORY':
                         $category_id = intval($child_param[1]);
                         break;
                     case 'FEATURE':
                         $topic_ids = $this->model('feature')->get_topics_by_feature_id($child_param[1]);
                         break;
                 }
             }
             if ($question_list = $this->model('posts')->get_posts_list(null, $param, 5, 'new', $topic_ids, $category_id)) {
                 foreach ($question_list as $key => $val) {
                     if (!$response_message) {
                         if (!($image_file = $this->get_client_list_image_by_command('COMMAND_' . $message_code))) {
                             $image_file = AWS_APP::config()->get('weixin')->default_list_image;
                         }
                     } else {
                         if ($val['uid']) {
                             $image_file = get_avatar_url($val['uid'], 'max');
                         } else {
                             $image_file = get_avatar_url($val['published_uid'], 'max');
                         }
                     }
                     if ($val['uid']) {
                         $title = $val['title'];
                         $link = get_js_url('/m/article/' . $val['id']);
                     } else {
                         $title = $val['question_content'];
                         $link = get_js_url('/m/question/' . $val['question_id']);
                     }
                     $response_message[] = array('title' => $title, 'link' => $link, 'image_file' => $image_file);
                 }
             } else {
                 $response_message = '暂无内容';
             }
             break;
         case 'NO_ANSWER_QUESTION':
             if ($input_message['param']) {
                 $child_param = explode('_', $input_message['param']);
                 switch ($child_param[0]) {
                     case 'CATEGORY':
                         $category_id = intval($child_param[1]);
                         break;
                     case 'FEATURE':
                         $topic_ids = $this->model('feature')->get_topics_by_feature_id($child_param[1]);
                         break;
                 }
             }
             if ($question_list = $this->model('posts')->get_posts_list('question', $param, 5, 'unresponsive', $topic_ids, $category_id)) {
                 foreach ($question_list as $key => $val) {
                     if (!$response_message) {
                         if (!($image_file = $this->get_client_list_image_by_command('COMMAND_' . $message_code))) {
                             $image_file = AWS_APP::config()->get('weixin')->default_list_image;
                         }
                     } else {
                         if ($val['uid']) {
                             $image_file = get_avatar_url($val['uid'], 'max');
                         } else {
                             $image_file = get_avatar_url($val['published_uid'], 'max');
                         }
                     }
                     if ($val['uid']) {
                         $title = $val['title'];
                         $link = get_js_url('/m/article/' . $val['id']);
                     } else {
                         $title = $val['question_content'];
                         $link = get_js_url('/m/question/' . $val['question_id']);
                     }
                     $response_message[] = array('title' => $title, 'link' => $link, 'image_file' => $image_file);
                 }
             } else {
                 $response_message = '暂无问题';
             }
             break;
         case 'RECOMMEND_QUESTION':
             if ($input_message['param']) {
                 $child_param = explode('_', $input_message['param']);
                 switch ($child_param[0]) {
                     case 'CATEGORY':
                         $category_id = intval($child_param[1]);
                         break;
                     case 'FEATURE':
                         $topic_ids = $this->model('feature')->get_topics_by_feature_id($child_param[1]);
                         break;
                 }
             }
             if ($question_list = $this->model('posts')->get_posts_list('question', $param, 5, null, $topic_ids, $category_id, null, null, true)) {
                 foreach ($question_list as $key => $val) {
                     if (!$response_message) {
                         if (!($image_file = $this->get_client_list_image_by_command('COMMAND_' . $message_code))) {
                             $image_file = AWS_APP::config()->get('weixin')->default_list_image;
                         }
                     } else {
                         if ($val['uid']) {
                             $image_file = get_avatar_url($val['uid'], 'max');
                         } else {
                             $image_file = get_avatar_url($val['published_uid'], 'max');
                         }
                     }
                     if ($val['uid']) {
                         $title = $val['title'];
                         $link = get_js_url('/m/article/' . $val['id']);
                     } else {
                         $title = $val['question_content'];
                         $link = get_js_url('/m/question/' . $val['question_id']);
                     }
                     $response_message[] = array('title' => $title, 'link' => $link, 'image_file' => $image_file);
                 }
             } else {
                 $response_message = '暂无问题';
             }
             break;
         case 'HOME_ACTIONS':
             if ($this->user_id) {
                 if ($home_actions = $this->model('actions')->home_activity($this->user_id, calc_page_limit($param, 5))) {
                     foreach ($home_actions as $key => $val) {
                         if (!$response_message) {
                             if (!($image_file = $this->get_client_list_image_by_command('COMMAND_' . $message_code))) {
                                 $image_file = AWS_APP::config()->get('weixin')->default_list_image;
                             }
                         } else {
                             $image_file = get_avatar_url($val['user_info']['uid'], 'max');
                         }
                         if ($val['associate_action'] == ACTION_LOG::ANSWER_QUESTION or $val['associate_action'] == ACTION_LOG::ADD_AGREE) {
                             $link = get_js_url('/m/question/' . $val['question_info']['question_id'] . '?answer_id=' . $val['answer_info']['answer_id'] . '&single=TRUE');
                         } else {
                             $link = $val['link'];
                         }
                         $response_message[] = array('title' => $val['title'], 'link' => $link, 'image_file' => $image_file);
                     }
                 } else {
                     $response_message = '暂时没有最新动态';
                 }
             } else {
                 $response_message = $this->bind_message;
             }
             break;
         case 'NOTIFICATIONS':
             if ($this->user_id) {
                 if ($notifications = $this->model('notify')->list_notification($this->user_id, 0, calc_page_limit($param, 5))) {
                     $response_message = '最新通知:';
                     foreach ($notifications as $key => $val) {
                         $response_message .= "\n\n• " . $val['message'];
                     }
                     $response_message .= "\n\n请输入 '更多' 显示其他相关内容";
                 } else {
                     $this->delete('weixin_message', "weixin_id = '" . $this->quote($input_message['fromUsername']) . "'");
                     if ($param > 1) {
                         $response_message = '没有更多新通知了';
                     } else {
                         $response_message = '暂时没有新通知';
                     }
                 }
             } else {
                 $response_message = $this->bind_message;
             }
             break;
         case 'MY_QUESTION':
             if ($this->user_id) {
                 if ($user_actions = $this->model('actions')->get_user_actions($this->user_id, calc_page_limit($param, 5), 101)) {
                     foreach ($user_actions as $key => $val) {
                         if (!$response_message) {
                             if (!($image_file = $this->get_client_list_image_by_command('COMMAND_' . $message_code))) {
                                 $image_file = AWS_APP::config()->get('weixin')->default_list_image;
                             }
                         } else {
                             $image_file = get_avatar_url($val['question_info']['published_uid'], 'max');
                         }
                         $response_message[] = array('title' => $val['question_info']['question_content'], 'link' => get_js_url('/m/question/' . $val['question_info']['question_id']), 'image_file' => $image_file);
                     }
                 } else {
                     $this->delete('weixin_message', "weixin_id = '" . $this->quote($input_message['fromUsername']) . "'");
                     if ($param > 1) {
                         $response_message = '没有更多提问了';
                     } else {
                         $response_message = '你还没有进行提问';
                     }
                 }
             } else {
                 $response_message = $this->bind_message;
             }
             break;
     }
     if (!$response_message) {
         return false;
     }
     return array('message' => $response_message, 'action' => $message_code . '-' . ($param + 1));
 }
Esempio n. 2
0
 public function save_topic_relation_action()
 {
     if (!$_POST['topic_title'] or !$_POST['item_id'] or !$_POST['type']) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('指定的项目不存在')));
     }
     switch ($_POST['type']) {
         case 'question':
             if (!($question_info = $this->model('question')->get_question_info_by_id($_POST['item_id']))) {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('指定问题不存在')));
             }
             if (!$this->user_info['permission']['edit_question_topic'] and $this->user_id != $question_info['published_uid']) {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你没有权限进行此操作')));
             }
             break;
         case 'article':
             if (!($article_info = $this->model('article')->get_article_info_by_id($_POST['item_id']))) {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('指定项目不存在')));
             }
             if (!$this->user_info['permission']['edit_question_topic'] and $this->user_id != $article_info['uid']) {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你没有权限进行此操作')));
             }
             break;
     }
     if (!($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'])) {
         if ($this->user_info['permission']['function_interval'] and AWS_APP::cache()->get('function_interval_timer_question_topic_last_edit_' . $this->user_id) == $_POST['item_id']) {
             AWS_APP::cache()->set('function_interval_timer_question_topic_' . $this->user_id, time(), 86400);
         } else {
             if ($this->user_info['permission']['function_interval'] and time() - AWS_APP::cache()->get('function_interval_timer_question_topic_' . $this->user_id) < $this->user_info['permission']['function_interval']) {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('灌水预防机制已经打开, 在 %s 秒内不能操作', $this->user_info['permission']['function_interval'])));
             }
         }
     }
     if (trim($_POST['topic_title']) == '') {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('请输入话题标题')));
     }
     if (strstr($_POST['topic_title'], '/') or strstr($_POST['topic_title'], '-')) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('话题标题不能包含 / 与 -')));
     }
     if (!$this->model('topic')->get_topic_id_by_title($_POST['topic_title']) and get_setting('topic_title_limit') and cjk_strlen($_POST['topic_title']) > get_setting('topic_title_limit')) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('话题标题字数不得超过 %s 字节', get_setting('topic_title_limit'))));
     }
     switch ($_POST['type']) {
         case 'question':
             if ($question_info['lock'] and !($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'])) {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('锁定问题不能添加话题')));
             }
             break;
         case 'article':
             if ($article_info['lock'] and !($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'])) {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('锁定文章不能添加话题')));
             }
             break;
     }
     if (sizeof($this->model('topic')->get_topics_by_item_id($_POST['item_id'], $_POST['type'])) >= get_setting('question_topics_limit') and get_setting('question_topics_limit')) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('单个问题或文章话题数量最多为 %s 个, 请调整话题数量', get_setting('question_topics_limit'))));
     }
     if (!($topic_id = $this->model('topic')->save_topic($_POST['topic_title'], $this->user_id, $this->user_info['permission']['create_topic']))) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('话题已锁定或没有创建话题权限, 不能添加话题')));
     }
     $this->model('topic')->save_topic_relation($this->user_id, $topic_id, $_POST['item_id'], $_POST['type']);
     if (!($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'])) {
         AWS_APP::cache()->set('function_interval_timer_question_topic_' . $this->user_id, time(), 86400);
         AWS_APP::cache()->set('function_interval_timer_question_topic_last_edit_' . $this->user_id, intval($_POST['item_id']), 86400);
     }
     H::ajax_json_output(AWS_APP::RSM(array('topic_id' => $topic_id, 'topic_url' => get_js_url('topic/' . $topic_id)), 1, null));
 }
Esempio n. 3
0
 public function modify_article_action()
 {
     if (!($article_info = $this->model('article')->get_article_info_by_id($_POST['article_id']))) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('文章不存在')));
     }
     if ($article_info['lock'] and !($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'])) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('文章已锁定, 不能编辑')));
     }
     if (!$this->user_info['permission']['is_administortar'] and !$this->user_info['permission']['is_moderator'] and !$this->user_info['permission']['edit_article']) {
         if ($article_info['uid'] != $this->user_id) {
             H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你没有权限编辑这个文章')));
         }
     }
     if (!$_POST['title']) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请输入文章标题')));
     }
     if (get_setting('category_enable') == 'N') {
         $_POST['category_id'] = 1;
     }
     if (!$_POST['category_id']) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请选择文章分类')));
     }
     if (get_setting('question_title_limit') > 0 and cjk_strlen($_POST['title']) > get_setting('question_title_limit')) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('文章标题字数不得大于') . ' ' . get_setting('question_title_limit') . ' ' . AWS_APP::lang()->_t('字节')));
     }
     if (!$this->user_info['permission']['publish_url'] and FORMAT::outside_url_exists($_POST['message'])) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你所在的用户组不允许发布站外链接')));
     }
     if (human_valid('question_valid_hour') and !AWS_APP::captcha()->is_validate($_POST['seccode_verify'])) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('请填写正确的验证码')));
     }
     if (!$this->model('publish')->insert_attach_is_self_upload($_POST['message'], $_POST['attach_ids'])) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('只允许插入当前页面上传的附件')));
     }
     // !注: 来路检测后面不能再放报错提示
     if (!valid_post_hash($_POST['post_hash'])) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('页面停留时间过长,或内容已提交,请刷新页面')));
     }
     $this->model('draft')->delete_draft(1, 'article', $this->user_id);
     if ($_POST['do_delete'] and !$this->user_info['permission']['is_administortar'] and !$this->user_info['permission']['is_moderator']) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('对不起, 你没有删除文章的权限')));
     }
     if ($_POST['do_delete']) {
         if ($this->user_id != $article_info['uid']) {
             $this->model('account')->send_delete_message($article_info['uid'], $article_info['title'], $article_info['message']);
         }
         $this->model('article')->remove_article($article_info['id']);
         H::ajax_json_output(AWS_APP::RSM(array('url' => get_js_url('/home/explore/')), 1, null));
     }
     $this->model('article')->update_article($article_info['id'], $_POST['title'], $_POST['message'], $_POST['topics'], $_POST['category_id'], $this->user_info['permission']['create_topic']);
     if ($_POST['attach_access_key']) {
         $this->model('publish')->update_attach('article', $article_info['id'], $_POST['attach_access_key']);
     }
     H::ajax_json_output(AWS_APP::RSM(array('url' => get_js_url('/article/' . $article_info['id'])), 1, null));
 }
Esempio n. 4
0
/**
 * 双字节语言版 substr
 *
 * 使用方法同 substr(), $dot 参数为截断后带上的字符串, 一般场景下使用省略号
 *
 * @param  string
 * @param  int
 * @param  int
 * @param  string
 * @param  string
 * @return string
 */
function cjk_substr($string, $start, $length, $charset = 'UTF-8', $dot = '')
{
    if (cjk_strlen($string, $charset) <= $length) {
        return $string;
    }
    if (function_exists('mb_substr')) {
        return mb_substr($string, $start, $length, $charset) . $dot;
    } else {
        return iconv_substr($string, $start, $length, $charset) . $dot;
    }
}
 /**
  * 敏感词替换
  * @param unknown_type $content
  * @param unknown_type $replace
  * @return mixed
  */
 public static function sensitive_words($content, $replace = '*')
 {
     if (!$content or !get_setting('sensitive_words')) {
         return $content;
     }
     if (is_array($content) && $content) {
         foreach ($content as $key => $val) {
             $content[$key] = self::sensitive_words($val, $replace);
         }
         return $content;
     }
     $sensitive_words = explode("\n", get_setting('sensitive_words'));
     foreach ($sensitive_words as $word) {
         $word = trim($word);
         if (!$word) {
             continue;
         }
         $replace_str = '';
         $word_length = cjk_strlen($word);
         for ($i = 0; $i < $word_length; $i++) {
             $replace_str .= $replace;
         }
         $content = str_replace($word, $replace_str, $content);
     }
     return $content;
 }
Esempio n. 6
0
 public function check_stop_keyword($keyword)
 {
     $keyword = trim($keyword);
     if ($keyword == '') {
         return false;
     }
     if (cjk_strlen($keyword) == 1) {
         return false;
     }
     if (strstr($keyword, '了') or strstr($keyword, '的') or strstr($keyword, '有')) {
         return false;
     }
     $stop_words_list = array('末', '啊', '阿', '哎', '哎呀', '哎哟', '唉', '俺', '俺们', '按', '按照', '吧', '吧哒', '把', '被', '本', '本着', '比', '比方', '比如', '鄙人', '彼', '彼此', '边', '别', '别说', '并', '并且', '不比', '不成', '不单', '不但', '不独', '不管', '不光', '不过', '不仅', '不拘', '不论', '不怕', '不然', '不如', '不特', '不惟', '不问', '不只', '朝', '朝着', '趁', '趁着', '乘', '冲', '除', '除此之外', '除非', '此', '此间', '此外', '从', '从而', '打', '待', '但', '但是', '当', '当着', '到', '得', '等', '等等', '地', '第', '叮咚', '对', '对于', '多', '多少', '而', '而况', '而且', '而是', '而外', '而言', '而已', '尔后', '反过来', '反过来说', '反之', '非但', '非徒', '否则', '嘎', '嘎登', '该', '赶', '个', '各', '各个', '各位', '各种', '各自', '给', '根据', '跟', '故', '故此', '固然', '关于', '管', '归', '果然', '果真', '过', '哈', '哈哈', '呵', '和', '何', '何处', '何况', '何时', '嘿', '哼', '哼唷', '呼哧', '乎', '哗', '还是', '换句话说', '换言之', '或', '或是', '或者', '及', '及其', '及至', '即', '即便', '即或', '即令', '即若', '即使', '几', '几时', '己', '既', '既然', '既是', '继而', '加之', '假如', '假若', '假使', '鉴于', '将', '较', '较之', '叫', '接着', '结果', '借', '紧接着', '进而', '尽', '尽管', '经', '经过', '就', '就是', '就是说', '据', '具体地说', '具体说来', '开始', '开外', '靠', '咳', '可', '可见', '可是', '可以', '况且', '啦', '来', '来着', '离', '例如', '哩', '连', '连同', '两者', '临', '另', '另外', '另一方面', '论', '嘛', '吗', '慢说', '漫说', '冒', '么', '每', '每当', '们', '莫若', '某', '某个', '某些', '拿', '哪', '哪边', '哪儿', '哪个', '哪里', '哪年', '哪怕', '哪天', '哪些', '哪样', '那', '那边', '那儿', '那个', '那会儿', '那里', '那么', '那么些', '那么样', '那时', '那些', '那样', '乃', '乃至', '呢', '能', '你', '你们', '您', '宁', '宁可', '宁肯', '宁愿', '哦', '呕', '啪达', '旁人', '呸', '凭', '凭借', '其', '其次', '其二', '其他', '其它', '其一', '其余', '其中', '起', '起见', '起见', '岂但', '恰恰相反', '前后', '前者', '且', '然而', '然后', '然则', '让', '人家', '任', '任何', '任凭', '如', '如此', '如果', '如何', '如其', '如若', '如上所述', '若', '若非', '若是', '啥', '上下', '尚且', '设若', '设使', '甚而', '甚么', '甚至', '省得', '时候', '什么', '什么样', '使得', '是', '首先', '谁', '谁知', '顺', '顺着', '虽', '虽然', '虽说', '虽则', '随', '随着', '所', '所以', '他', '他们', '他人', '它', '它们', '她', '她们', '倘', '倘或', '倘然', '倘若', '倘使', '腾', '替', '通过', '同', '同时', '哇', '万一', '往', '望', '为', '为何', '为什么', '为着', '喂', '嗡嗡', '我', '我们', '呜', '呜呼', '乌乎', '无论', '无宁', '毋宁', '嘻', '吓', '相对而言', '像', '向', '向着', '嘘', '呀', '焉', '沿', '沿着', '要', '要不', '要不然', '要不是', '要么', '要是', '也', '也罢', '也好', '一', '一般', '一旦', '一方面', '一来', '一切', '一样', '一则', '依', '依照', '矣', '以', '以便', '以及', '以免', '以至', '以至于', '以致', '抑或', '因', '因此', '因而', '因为', '哟', '用', '由', '由此可见', '由于', '又', '于', '于是', '于是乎', '与', '与此同时', '与否', '与其', '越是', '云云', '哉', '再说', '再者', '在', '在下', '咱', '咱们', '则', '怎', '怎么', '怎么办', '怎么样', '怎样', '咋', '照', '照着', '者', '这', '这边', '这儿', '这个', '这会儿', '这就是说', '这里', '这么', '这么点儿', '这么些', '这么样', '这时', '这些', '这样', '正如', '吱', '之', '之类', '之所以', '之一', '只是', '只限', '只要', '至', '至于', '诸位', '着', '着呢', '自', '自从', '自个儿', '自各儿', '自己', '自家', '自身', '综上所述', '总而言之', '总之', '纵', '纵令', '纵然', '纵使', '遵照', '作为', '兮', '呃', '呗', '咚', '咦', '喏', '啐', '喔唷', '嗬', '嗯', '嗳', 'a\'s', 'able', 'about', 'above', 'according', 'accordingly', 'across', 'actually', 'after', 'afterwards', 'again', 'against', 'ain\'t', 'all', 'allow', 'allows', 'almost', 'alone', 'along', 'already', 'also', 'although', 'always', 'am', 'among', 'amongst', 'an', 'and', 'another', 'any', 'anybody', 'anyhow', 'anyone', 'anything', 'anyway', 'anyways', 'anywhere', 'apart', 'appear', 'appreciate', 'appropriate', 'are', 'aren\'t', 'around', 'as', 'aside', 'ask', 'asking', 'associated', 'at', 'available', 'away', 'awfully', 'be', 'became', 'because', 'become', 'becomes', 'becoming', 'been', 'before', 'beforehand', 'behind', 'being', 'believe', 'below', 'beside', 'besides', 'best', 'better', 'between', 'beyond', 'both', 'brief', 'but', 'by', 'c\'mon', 'c\'s', 'came', 'can', 'can\'t', 'cannot', 'cant', 'cause', 'causes', 'certain', 'certainly', 'changes', 'clearly', 'co', 'com', 'come', 'comes', 'concerning', 'consequently', 'consider', 'considering', 'contain', 'containing', 'contains', 'corresponding', 'could', 'couldn\'t', 'course', 'currently', 'definitely', 'described', 'despite', 'did', 'didn\'t', 'different', 'do', 'does', 'doesn\'t', 'doing', 'don\'t', 'done', 'down', 'downwards', 'during', 'each', 'edu', 'eg', 'eight', 'either', 'else', 'elsewhere', 'enough', 'entirely', 'especially', 'et', 'etc', 'even', 'ever', 'every', 'everybody', 'everyone', 'everything', 'everywhere', 'ex', 'exactly', 'example', 'except', 'far', 'few', 'fifth', 'first', 'five', 'followed', 'following', 'follows', 'for', 'former', 'formerly', 'forth', 'four', 'from', 'further', 'furthermore', 'get', 'gets', 'getting', 'given', 'gives', 'go', 'goes', 'going', 'gone', 'got', 'gotten', 'greetings', 'had', 'hadn\'t', 'happens', 'hardly', 'has', 'hasn\'t', 'have', 'haven\'t', 'having', 'he', 'he\'s', 'hello', 'help', 'hence', 'her', 'here', 'here\'s', 'hereafter', 'hereby', 'herein', 'hereupon', 'hers', 'herself', 'hi', 'him', 'himself', 'his', 'hither', 'hopefully', 'how', 'howbeit', 'however', 'i\'d', 'i\'ll', 'i\'m', 'i\'ve', 'ie', 'if', 'ignored', 'immediate', 'in', 'inasmuch', 'inc', 'indeed', 'indicate', 'indicated', 'indicates', 'inner', 'insofar', 'instead', 'into', 'inward', 'is', 'isn\'t', 'it', 'it\'d', 'it\'ll', 'it\'s', 'its', 'itself', 'just', 'keep', 'keeps', 'kept', 'know', 'known', 'knows', 'last', 'lately', 'later', 'latter', 'latterly', 'least', 'less', 'lest', 'let', 'let\'s', 'like', 'liked', 'likely', 'little', 'look', 'looking', 'looks', 'ltd', 'mainly', 'many', 'may', 'maybe', 'me', 'mean', 'meanwhile', 'merely', 'might', 'more', 'moreover', 'most', 'mostly', 'much', 'must', 'my', 'myself', 'name', 'namely', 'nd', 'near', 'nearly', 'necessary', 'need', 'needs', 'neither', 'never', 'nevertheless', 'new', 'next', 'nine', 'no', 'nobody', 'non', 'none', 'noone', 'nor', 'normally', 'not', 'nothing', 'novel', 'now', 'nowhere', 'obviously', 'of', 'off', 'often', 'oh', 'ok', 'okay', 'old', 'on', 'once', 'one', 'ones', 'only', 'onto', 'or', 'other', 'others', 'otherwise', 'ought', 'our', 'ours', 'ourselves', 'out', 'outside', 'over', 'overall', 'own', 'particular', 'particularly', 'per', 'perhaps', 'placed', 'please', 'plus', 'possible', 'presumably', 'probably', 'provides', 'que', 'quite', 'qv', 'rather', 'rd', 're', 'really', 'reasonably', 'regarding', 'regardless', 'regards', 'relatively', 'respectively', 'right', 'said', 'same', 'saw', 'say', 'saying', 'says', 'second', 'secondly', 'see', 'seeing', 'seem', 'seemed', 'seeming', 'seems', 'seen', 'self', 'selves', 'sensible', 'sent', 'serious', 'seriously', 'seven', 'several', 'shall', 'she', 'should', 'shouldn\'t', 'since', 'six', 'so', 'some', 'somebody', 'somehow', 'someone', 'something', 'sometime', 'sometimes', 'somewhat', 'somewhere', 'soon', 'sorry', 'specified', 'specify', 'specifying', 'still', 'sub', 'such', 'sup', 'sure', 't\'s', 'take', 'taken', 'tell', 'tends', 'th', 'than', 'thank', 'thanks', 'thanx', 'that', 'that\'s', 'thats', 'the', 'their', 'theirs', 'them', 'themselves', 'then', 'thence', 'there', 'there\'s', 'thereafter', 'thereby', 'therefore', 'therein', 'theres', 'thereupon', 'these', 'they', 'they\'d', 'they\'ll', 'they\'re', 'they\'ve', 'think', 'third', 'this', 'thorough', 'thoroughly', 'those', 'though', 'three', 'through', 'throughout', 'thru', 'thus', 'to', 'together', 'too', 'took', 'toward', 'towards', 'tried', 'tries', 'truly', 'try', 'trying', 'twice', 'two', 'un', 'under', 'unfortunately', 'unless', 'unlikely', 'until', 'unto', 'up', 'upon', 'us', 'use', 'used', 'useful', 'uses', 'using', 'usually', 'value', 'various', 'very', 'via', 'viz', 'vs', 'want', 'wants', 'was', 'wasn\'t', 'way', 'we', 'we\'d', 'we\'ll', 'we\'re', 'we\'ve', 'welcome', 'well', 'went', 'were', 'weren\'t', 'what', 'what\'s', 'whatever', 'when', 'whence', 'whenever', 'where', 'where\'s', 'whereafter', 'whereas', 'whereby', 'wherein', 'whereupon', 'wherever', 'whether', 'which', 'while', 'whither', 'who', 'who\'s', 'whoever', 'whole', 'whom', 'whose', 'why', 'will', 'willing', 'wish', 'with', 'within', 'without', 'won\'t', 'wonder', 'would', 'wouldn\'t', 'yes', 'yet', 'you', 'you\'d', 'you\'ll', 'you\'re', 'you\'ve', 'your', 'yours', 'yourself', 'yourselves', 'zero');
     if (in_array($keyword, $stop_words_list)) {
         return false;
     }
     return true;
 }
Esempio n. 7
0
 public function save_question_comment_action()
 {
     if (!$_GET['question_id']) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('问题不存在')));
     }
     if (!$this->user_info['permission']['publish_comment']) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你没有发表评论的权限')));
     }
     if (trim($_POST['message']) == '') {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请输入评论内容')));
     }
     $question_info = $this->model('question')->get_question_info_by_id($_GET['question_id']);
     if ($question_info['lock'] and !($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'])) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('不能评论锁定的问题')));
     }
     if (get_setting('comment_limit') > 0 and cjk_strlen($_POST['message']) > get_setting('comment_limit')) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('评论内容字数不得超过 %s 字节', get_setting('comment_limit'))));
     }
     $this->model('question')->insert_question_comment($_GET['question_id'], $this->user_id, $_POST['message']);
     H::ajax_json_output(AWS_APP::RSM(array('item_id' => intval($_GET['question_id']), 'type_name' => 'question'), 1, null));
 }
Esempio n. 8
0
 public function save_topic_relation_action()
 {
     if (!$this->user_info['permission']['is_administortar'] and !$this->user_info['permission']['is_service']) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('你没有权限为工单添加话题')));
     }
     $_POST['topic_title'] = trim($_POST['topic_title']);
     if (!$_POST['topic_title']) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请输入话题标题')));
     }
     if (!$_POST['item_id']) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请选择工单')));
     }
     if (strstr($_POST['topic_title'], '/') or strstr($_POST['topic_title'], '-')) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('话题标题不能包含 / 与 -')));
     }
     $ticket_info = $this->model('ticket')->get_ticket_info_by_id($_POST['item_id']);
     if (!$ticket_info) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('该工单不存在')));
     }
     if (!$this->model('topic')->get_topic_id_by_title($_POST['topic_title']) and get_setting('topic_title_limit') and cjk_strlen($_POST['topic_title']) > get_setting('topic_title_limit')) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('话题标题字数不得超过 %s 字节', get_setting('topic_title_limit'))));
     }
     if (count($this->model('topic')->get_topics_by_item_id($ticket_info['id'], 'ticket')) >= get_setting('question_topics_limit') and get_setting('question_topics_limit')) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('单个工单话题数量最多为 %s 个, 请调整话题数量', get_setting('question_topics_limit'))));
     }
     $topic_id = $this->model('topic')->save_topic($_POST['topic_title'], $this->user_id, $this->user_info['permission']['create_topic']);
     if (!$topic_id) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('话题已锁定或没有创建话题权限, 不能添加话题')));
     }
     $this->model('topic')->save_topic_relation($this->user_id, $topic_id, $ticket_info['id'], 'ticket');
     H::ajax_json_output(AWS_APP::RSM(array('topic_id' => $topic_id, 'topic_url' => get_js_url('topic/' . $topic_id)), 1, null));
 }
Esempio n. 9
0
 /**
  * 敏感词替换
  * @param unknown_type $content
  * @param unknown_type $replace
  * @return mixed
  */
 public static function sensitive_words($content, $replace = '*')
 {
     if (!$content or !get_setting('sensitive_words')) {
         return $content;
     }
     if (is_array($content) && $content) {
         foreach ($content as $key => $val) {
             $content[$key] = self::sensitive_words($val, $replace);
         }
         return $content;
     }
     $sensitive_words = explode("\n", get_setting('sensitive_words'));
     foreach ($sensitive_words as $word) {
         $word = trim($word);
         if (!$word) {
             continue;
         }
         if (substr($word, 0, 1) == '{' and substr($word, -1, 1) == '}') {
             $regex[] = substr($word, 1, -1);
         } else {
             $word_length = cjk_strlen($word);
             $replace_str = '';
             for ($i = 0; $i < $word_length; $i++) {
                 $replace_str .= $replace;
             }
             $content = str_replace($word, $replace_str, $content);
         }
     }
     if (isset($regex)) {
         preg_replace($regex, '***', $content);
     }
     return $content;
 }