• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP filter_words函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中filter_words函数的典型用法代码示例。如果您正苦于以下问题:PHP filter_words函数的具体用法?PHP filter_words怎么用?PHP filter_words使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了filter_words函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: m__commentadd

function m__commentadd()
{
    global $dbm, $c;
    $fields = array();
    if (isset($_SESSION['postdata']['comment']) && time() - $_SESSION['postdata']['comment'] < 60) {
        die('{"code":"101","msg":"歇会再评论吧"}');
    }
    if (trim($_POST['comment']) == '') {
        die('{"code":"1","msg":"发表内容不能为空"}');
    }
    $code = md5(strtoupper($_POST['code']));
    if ($code != $_SESSION['feedback']) {
        die('{"code":"140","msg":"验证码错误"}');
    }
    if (!isset($_POST['id']) || !is_numeric($_POST['id'])) {
        die('{"code":"202","msg":"id号出错"}');
    }
    if (!isset($_POST['parent_id']) || !is_numeric($_POST['parent_id'])) {
        die('{"code","203","msg":"上级ID出错"}');
    }
    $fields['info_id'] = intval($_POST['id']);
    $fields['parent_id'] = intval($_POST['parent_id']);
    $content = filter_words($_POST['comment']);
    $fields['content'] = helper::utf8_substr($content, 0, 300);
    $user = filter_words($_POST['user'], 'user');
    // 匿名用户名存cookie
    if (!isset($_COOKIE['uname']) && empty($_COOKIE['uname'])) {
        $_COOKIE['uname'] = $user;
        setcookie('uname', $user, time() + 3600, '/');
    }
    $fields['uname'] = helper::utf8_substr($user, 0, 10);
    $fields['date_add'] = time();
    $fields['ip'] = helper::getip();
    if ($fields['parent_id'] != 0) {
        $ress = $dbm->query_update("UPDATE " . TB_PREFIX . "comment SET son = son + 1 WHERE comment_id = '{$fields['parent_id']}'");
    }
    $res = $dbm->single_insert(TB_PREFIX . 'comment', $fields);
    if (empty($res['error']) && empty($ress['error'])) {
        $_SESSION['postdata']['comment'] = time();
        die('{"code":"0","msg":"发表成功"}');
    }
    die('{"code":"1","msg":"发表失败:' . $ress['error'] . '"}');
}
开发者ID:cranefly,项目名称:crane,代码行数:43,代码来源:comment.php


示例2: addComment

 /**
  * 添加评论操作
  * @param array $data 评论数据
  * @param boolean $forApi 是否用于API,默认为false
  * @param boolean $notCount 是否统计到未读评论
  * @param array $lessUids 除去@用户ID
  * @return boolean 是否添加评论成功 
  */
 public function addComment($data, $forApi = false, $notCount = false, $lessUids = null)
 {
     // 判断用户是否登录
     if (!$GLOBALS['ts']['mid']) {
         $this->error = L('PUBLIC_REGISTER_REQUIRED');
         // 请先登录
         return false;
     }
     if (isSubmitLocked()) {
         $this->error = '发布内容过于频繁,请稍后再试!';
         return false;
     }
     /* # 将Emoji编码 */
     $data['content'] = formatEmoji(true, $data['content']);
     // 检测数据安全性
     $add = $this->_escapeData($data);
     if ($add['content'] === '') {
         $this->error = L('PUBLIC_COMMENT_CONTENT_REQUIRED');
         // 评论内容不可为空
         return false;
     }
     $add['is_del'] = 0;
     //判断是否先审后发
     $filterStatus = filter_words($add['content']);
     $weiboSet = model('Xdata')->get('admin_Config:feed');
     $weibo_premission = $weiboSet['weibo_premission'];
     if (in_array('audit', $weibo_premission) || CheckPermission('core_normal', 'feed_audit') || $filterStatus['type'] == 2) {
         $add['is_audit'] = 0;
     } else {
         $add['is_audit'] = 1;
     }
     $add['client_ip'] = get_client_ip();
     $add['client_port'] = get_client_port();
     if ($res = $this->add($add)) {
         //锁定发布
         lockSubmit();
         //添加楼层信息 弃用 20130607
         /*             $storeyCount = $this->where("table='".$add['table']."' and row_id=".$data['row_id'].' and comment_id<'.$res)->count();
                     $this->where('comment_id='.$res)->setField('storey',$storeyCount+1); */
         if (!$add['is_audit']) {
             $touid = D('user_group_link')->where('user_group_id=1')->field('uid')->findAll();
             $touidArr = getSubByKey($touid, 'uid');
             model('Notify')->sendNotify($touidArr, 'comment_audit');
         }
         // 获取排除@用户ID
         $lessUids[] = intval($data['app_uid']);
         !empty($data['to_uid']) && ($lessUids[] = intval($data['to_uid']));
         // 获取用户发送的内容,仅仅以//进行分割
         $scream = explode('//', $data['content']);
         model('Atme')->setAppName('Public')->setAppTable('comment')->addAtme(trim($scream[0]), $res, null, $lessUids);
         // 被评论内容的“评论统计数”加1,同时可检测出app,table,row_id的有效性
         $pk = D($add['table'])->getPk();
         $where = "`{$pk}`={$add['row_id']}";
         D($add['table'])->setInc('comment_count', $where);
         //兼容旧版本app
         //            D($add['table'])->setInc('commentCount', $where);
         //            D($add['table'])->setInc('comment_all_count', $where);
         D($add['app'])->setInc('commentCount', $where);
         D($add['app'])->setInc('comment_all_count', $where);
         //评论时间
         M($add['app'])->where('feed_id=' . $add['row_id'])->setField('rTime', time());
         // 给应用UID添加一个未读的评论数 原作者
         if ($GLOBALS['ts']['mid'] != $add['app_uid'] && $add['app_uid'] != '' && $add['app_uid'] != $add['to_uid']) {
             !$notCount && model('UserData')->updateKey('unread_comment', 1, true, $add['app_uid']);
         }
         // 回复发送提示信息
         if (!empty($add['to_uid']) && $add['to_uid'] != $GLOBALS['ts']['mid']) {
             !$notCount && model('UserData')->updateKey('unread_comment', 1, true, $add['to_uid']);
         }
         // 加积分操作
         if ($add['table'] == 'feed') {
             model('Credit')->setUserCredit($GLOBALS['ts']['mid'], 'comment_weibo');
             model('Credit')->setUserCredit($data['app_uid'], 'commented_weibo');
             model('Feed')->cleanCache($add['row_id']);
         }
         // 发邮件
         if ($add['to_uid'] != $GLOBALS['ts']['mid'] || $add['app_uid'] != $GLOBALS['ts']['mid'] && $add['app_uid'] != '') {
             $author = model('User')->getUserInfo($GLOBALS['ts']['mid']);
             $config['name'] = $author['uname'];
             $config['space_url'] = $author['space_url'];
             $config['face'] = $author['avatar_small'];
             $sourceInfo = model('Source')->getCommentSource($add, $forApi);
             $config['content'] = parse_html($add['content']);
             $config['ctime'] = date('Y-m-d H:i:s', time());
             $config['sourceurl'] = $sourceInfo['source_url'];
             $config['source_content'] = parse_html($sourceInfo['source_content']);
             $config['source_ctime'] = isset($sourceInfo['ctime']) ? date('Y-m-d H:i:s', $sourceInfo['ctime']) : date('Y-m-d H:i:s');
             if (!empty($add['to_uid'])) {
                 // 回复
                 $config['comment_type'] = '回复 我 的评论:';
                 model('Notify')->sendNotify($add['to_uid'], 'comment', $config);
             } else {
//.........这里部分代码省略.........
开发者ID:omusico,项目名称:ThinkSNS-4,代码行数:101,代码来源:CommentModel.class.php


示例3: get_all_data

/**
 *
 *
 * @global string $db_url
 * @global dom $dom
 * @param boolean $parse_smileys Defaults to TRUE
 * @param boolean $filter_words Defaults to FALSE
 * @param boolean $processUsername Defaults to FALSE
 * @param boolean $processTime Defaults to FALSE
 * @param boolean $apply_filter Defaults to TRUE
 * @return array
 */
function get_all_data($parse_smileys = true, $filter_words = false, $processUsername = false, $processTime = false, $apply_filter = true)
{
    global $db_url;
    global $dom;
    $db = YDB::factory($db_url);
    $data = array();
    $data = $db->queryAll(parse_tbprefix("SELECT p.pid AS id, p.ip AS ip , p.uid AS uid ,p.uname AS uname,p.content AS post_content,p.post_time AS time,r.content AS reply_content,r.r_time AS reply_time ,u.username AS b_username FROM <post> AS p LEFT JOIN <reply> AS r ON p.pid=r.pid LEFT JOIN <sysuser> AS u ON p.uid=u.uid ORDER BY p.post_time DESC"));
    foreach ($data as &$_data) {
        if ($apply_filter && ZFramework::app()->filter_type == ConfigController::FILTER_TRIPTAGS) {
            if (strstr(ZFramework::app()->allowed_tags, 'code')) {
                $_data['post_content'] = preg_replace_callback('|<code>(.*)</code>|sU', create_function('$matches', 'return "<pre class=\'prettyprint\'>".str_replace(">","&gt;",str_replace("<","&lt;",$matches[1]))."</pre>";'), $_data['post_content']);
                $_data['reply_content'] = preg_replace_callback('|<code>(.*)</code>|sU', create_function('$matches', 'return "<pre class=\'prettyprint\'>".str_replace(">","&gt;",str_replace("<","&lt;",$matches[1]))."</pre>";'), $_data['reply_content']);
                if (!strstr(ZFramework::app()->allowed_tags, 'pre')) {
                    ZFramework::app()->allowed_tags .= "<pre>";
                }
            }
            $_data['post_content'] = strip_tags($_data['post_content'], ZFramework::app()->allowed_tags);
            $_data['reply_content'] = strip_tags($_data['reply_content'], ZFramework::app()->allowed_tags);
        } else {
            $_data['post_content'] = htmlentities($_data['post_content'], ENT_COMPAT, 'UTF-8');
            $_data['reply_content'] = htmlentities($_data['reply_content'], ENT_COMPAT, 'UTF-8');
        }
        if ($parse_smileys) {
            $dom->loadHTML($_data['post_content']);
            $_data['post_content'] = html_entity_decode(parse_smileys($_data['post_content'], SMILEYDIR, getSmileys()));
            if ($_data['reply_content']) {
                $dom->loadHTML($_data['reply_content']);
                $_data['reply_content'] = html_entity_decode(parse_smileys($_data['reply_content'], SMILEYDIR, getSmileys()));
            }
        }
        if ($filter_words) {
            $_data['post_content'] = filter_words($_data['post_content']);
        }
        if ($processUsername) {
            $_data['user'] = $_data['uname'] == ZFramework::app()->admin ? "<font color='red'>{$_data['uname']}</font>" : $_data['uname'];
        }
        if ($processTime) {
            $_data['time'] = date('m-d H:i', $_data['time'] + ZFramework::app()->timezone * 60 * 60);
            $_data['reply_time'] = date('m-d H:i', $_data['reply_time'] + ZFramework::app()->timezone * 60 * 60);
        }
    }
    return $data;
}
开发者ID:yunsite,项目名称:yuan-pad,代码行数:55,代码来源:functions.php


示例4: doPost

 /**
  * 执行发布帖子
  * @return void
  */
 public function doPost()
 {
     if ($_GET['post_type'] == 'index') {
         $type = false;
     } else {
         $type = true;
     }
     $weibaid = intval($_POST['weiba_id']);
     if (!CheckPermission('weiba_normal', 'weiba_post')) {
         $this->error('对不起,您没有权限进行该操作!', $type);
     }
     $is_lock = M('weiba_blacklist')->where('weiba_id=' . $weibaid . ' and uid=' . $this->mid)->find();
     if ($is_lock) {
         $this->error('您是黑名单用户没有发帖权限', $type);
     }
     $weibaid = intval($_POST['weiba_id']);
     if (!$weibaid) {
         $this->error('请选择微吧,等待返回选择微吧', $type);
     }
     $weiba = D('weiba')->where('weiba_id=' . $weibaid)->find();
     //黑名单功能添加
     if (!CheckPermission('core_admin', 'admin_login')) {
         switch ($weiba['who_can_post']) {
             case 1:
                 $map['weiba_id'] = $weibaid;
                 $map['follower_uid'] = $this->mid;
                 $res = D('weiba_follow')->where($map)->find();
                 if (!$res && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,请关注该微吧!', $type);
                 }
                 break;
             case 2:
                 $map['weiba_id'] = $weibaid;
                 $map['level'] = array('in', '2,3');
                 $weiba_admin = D('weiba_follow')->where($map)->order('level desc')->field('follower_uid')->findAll();
                 if (!in_array($this->mid, getSubByKey($weiba_admin, 'follower_uid')) && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,仅限该吧管理员发帖!', $type);
                 }
                 break;
             case 3:
                 $map['weiba_id'] = $weibaid;
                 $map['level'] = 3;
                 $weiba_admin = D('weiba_follow')->where($map)->order('level desc')->field('follower_uid')->find();
                 if ($this->mid != $weiba_admin['follower_uid'] && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,仅限该吧吧主发帖!', $type);
                 }
                 break;
         }
     }
     $checkContent = str_replace('&nbsp;', '', $_POST['content']);
     $checkContent = str_replace('<br />', '', $checkContent);
     $checkContent = str_replace('<p>', '', $checkContent);
     $checkContent = str_replace('</p>', '', $checkContent);
     $checkContents = preg_replace('/<img(.*?)src=/i', 'img', $checkContent);
     $checkContents = preg_replace('/<embed(.*?)src=/i', 'img', $checkContents);
     if (strlen(t($_POST['title'])) == 0) {
         $this->error('帖子标题不能为空,等待返回添加标题', $type);
     }
     if (strlen(t($checkContents)) == 0) {
         $this->error('帖子内容不能为空,等待返回添加内容', $type);
     }
     preg_match_all('/./us', t($_POST['title']), $match);
     if (count($match[0]) > 25) {
         //汉字和字母都为一个字
         $this->error('帖子标题不能超过25个字,等待返回修改标题', $type);
     }
     /* # 帖子内容 */
     $content = h($_POST['content']);
     if (get_str_length($content) >= 20000) {
         $this->error('帖子内容过长!无法发布!');
     }
     unset($content);
     if ($_POST['attach_ids']) {
         $attach = explode('|', $_POST['attach_ids']);
         foreach ($attach as $k => $a) {
             if (!$a) {
                 unset($attach[$k]);
             }
         }
         $attach = array_map('intval', $attach);
         $data['attach'] = serialize($attach);
     }
     $data['weiba_id'] = $weibaid;
     $data['title'] = t($_POST['title']);
     $data['content'] = h($_POST['content']);
     $data['post_uid'] = $this->mid;
     $data['post_time'] = time();
     $data['last_reply_uid'] = $this->mid;
     $data['last_reply_time'] = $data['post_time'];
     $filterTitleStatus = filter_words($data['title']);
     if (!$filterTitleStatus['status']) {
         $this->error($filterTitleStatus['data'], $type);
     }
     $data['title'] = $filterTitleStatus['data'];
     $filterContentStatus = filter_words($data['content']);
     if (!$filterContentStatus['status']) {
//.........这里部分代码省略.........
开发者ID:songhongyu,项目名称:THINKSNS,代码行数:101,代码来源:IndexAction.class.php


示例5: doForward

 public function doForward()
 {
     // 获取传入的值
     $post = $_POST;
     // 安全过滤
     foreach ($post as $key => $val) {
         $post[$key] = t($post[$key]);
     }
     // 过滤内容值
     // $post['body'] = filter_keyword($post['body']);
     $filterBodyStatus = filter_words($post['body']);
     if (!$filterBodyStatus['status']) {
         echo $filterBodyStatus['data'];
         exit;
         // $return = array('status'=>0,'data'=>$filterBodyStatus['data']);
         // exit(json_encode($return));
     }
     $post['body'] = $filterBodyStatus['data'];
     // 判断资源是否删除
     if (empty($post['curid'])) {
         $map['feed_id'] = intval($post['sid']);
     } else {
         $map['feed_id'] = intval($post['curid']);
     }
     $map['is_del'] = 0;
     $isExist = model('Feed')->where($map)->count();
     if ($isExist == 0) {
         // $return['status'] = 0;
         echo $return['data'] = '内容已被删除,转发失败';
         exit;
         // exit(json_encode($return));
     }
     // 进行分享操作
     $return = model('Share')->shareFeed($post, 'share');
     if ($return['status'] == 1) {
         $app_name = $post['app_name'];
         // 添加积分
         if ($app_name == 'public') {
             model('Credit')->setUserCredit($this->uid, 'forward_weibo');
             // 分享被转发
             $suid = model('Feed')->where($map)->getField('uid');
             model('Credit')->setUserCredit($suid, 'forwarded_weibo');
         }
         if ($app_name == 'weiba') {
             model('Credit')->setUserCredit($this->uid, 'forward_topic');
             // 分享被转发
             $suid = D('Feed')->where('feed_id=' . $map['feed_id'])->getField('uid');
             model('Credit')->setUserCredit($suid, 'forwarded_topic');
         }
         $this->assign($return['data']);
         // 分享配置
         $weiboSet = model('Xdata')->get('admin_Config:feed');
         $this->assign('weibo_premission', $weiboSet['weibo_premission']);
         $return['data'] = $this->fetch('PostFeed');
         $this->doForwardTrue();
         exit;
     } else {
         echo '0';
         exit;
     }
     // exit(json_encode($return));
     // $r=array();
     // $weibo_id = intval($_POST['feed_id']);
     // if ($weibo_id <= 0) {
     // echo '参数错误';
     // exit();
     // }
     // if (empty($_POST['content'])) {
     // echo '内容不能为空';
     // exit();
     // }
     //
     // $data['id'] = $weibo_id;
     // $weibo = api('WeiboStatuses')->data($data)->show();
     // unset($data);
     // if ( empty($weibo) ) {
     // // redirect(U('wap/Index/index'), 3, '参数错误');
     // echo '参数错误';
     // exit();
     // }
     // $p['comment'] = $_POST['comment'];
     // // 整合被转发的内容
     // if ( $weibo['is_repost'] == 1 ) {
     // $_POST['content'] .= "//@{$weibo['uname']}:{$weibo['feed_content']}";
     // }
     //
     // // 仅取前140字
     // $admin_Config = model('Xdata')->lget('admin_Config');
     // $weibo_nums = $admin_Config['feed']['weibo_nums'];
     // $_POST['content'] = mb_substr($_POST['content'], 0,$weibo_nums , 'UTF8');
     //
     // $data['content'] = $_POST['content'];
     // $data['from'] = $this->_type_wap;
     // $data['transpond_id'] = $weibo['transpond_id'] ? $weibo['transpond_id'] : $weibo_id;
     // if (intval($_POST['isComment']) == 1) {
     // $weibo = api('WeiboStatuses')->data(array('id'=>$weibo_id))->show();
     // // $weibo = $this->__formatByContent($weibo);
     // $data['reply_data'] = $weibo['weibo_id'];
     // if ( !empty($weibo['transpond_data']) ) {
     // $data['reply_data'] .= ',' . $weibo['transpond_data']['weibo_id'];
//.........这里部分代码省略.........
开发者ID:songhongyu,项目名称:THINKSNS,代码行数:101,代码来源:IndexAction.class.php


示例6: shareFeed

 /**
  * 分享/转发分享操作,需要传入POST的值
  *
  * @return json 分享/转发分享后的结果信息JSON数据
  */
 public function shareFeed()
 {
     // 获取传入的值
     $post = $this->data;
     // 安全过滤
     foreach ($post as $key => $val) {
         $post[$key] = t($post[$key]);
     }
     // 过滤内容值
     // $post['body'] = filter_keyword($post['body']);
     $filterBodyStatus = filter_words($post['content']);
     if (!$filterBodyStatus['status']) {
         $return = array('status' => 0, 'msg' => $filterBodyStatus['data']);
         return $return;
     }
     $post['body'] = $filterBodyStatus['data'];
     // 判断资源是否删除
     if (empty($post['curid'])) {
         $map['feed_id'] = intval($post['sid']);
     } else {
         $map['feed_id'] = intval($post['curid']);
     }
     $map['is_del'] = 0;
     $isExist = model('Feed')->where($map)->count();
     if ($isExist == 0) {
         $return['status'] = 0;
         $return['msg'] = '内容已被删除,转发失败';
         return $return;
     }
     // 进行分享操作
     $res = model('Share')->shareFeed($post, 'share');
     if ($res['status'] == 1) {
         $app_name = $post['app_name'];
         // 添加积分
         if ($app_name == 'public') {
             model('Credit')->setUserCredit($this->uid, 'forward_weibo');
             // 分享被转发
             $suid = model('Feed')->where($map)->getField('uid');
             model('Credit')->setUserCredit($suid, 'forwarded_weibo');
         }
         if ($app_name == 'weiba') {
             model('Credit')->setUserCredit($this->uid, 'forward_topic');
             // 分享被转发
             $suid = D('Feed')->where('feed_id=' . $map['feed_id'])->getField('uid');
             model('Credit')->setUserCredit($suid, 'forwarded_topic');
         }
         $return = array('status' => 1, 'msg' => '转发成功');
         return $return;
     }
     $return = array('status' => 0, 'msg' => $res['data']);
     return $return;
 }
开发者ID:songhongyu,项目名称:THINKSNS,代码行数:57,代码来源:WeiboApi.class.php


示例7: addcomment

 /**
  * 添加评论的操作
  *
  * @return array 评论添加状态和提示信息
  */
 public function addcomment()
 {
     // 返回结果集默认值
     $return = array('status' => 0, 'data' => L('PUBLIC_CONCENT_IS_ERROR'));
     // 获取接收数据
     $data['app'] = t($_POST['app_name']);
     $data['table'] = t($_POST['table_name']);
     //model ( 'Comment' )->addComment已针对$data['content']转义,请勿重复操作
     //$data ['content'] = h ( $_POST ['content'] );
     $data['content'] = $_POST['content'];
     $data['app_uid'] = intval($_POST['app_uid']);
     $data['app_row_id'] = intval($_POST['app_row_id']);
     $data['app_row_table'] = t($_POST['app_row_table']);
     $data['row_id'] = intval($_POST['row_id']);
     $data['to_comment_id'] = intval($_POST['to_comment_id']);
     $data['to_uid'] = intval($_POST['to_uid']);
     $data['ifShareFeed'] = intval($_POST['ifShareFeed']);
     $data['comment_old'] = intval($_POST['comment_old']);
     $data['app_detail_summary'] = t($_POST['app_detail_summary']);
     $source = model('Source')->getSourceInfo($data['table'], $data['row_id'], false, $data['app']);
     $uid = $source['uid'];
     if ($this->mid != $uid) {
         $userPrivacy = model('UserPrivacy')->getPrivacy($this->mid, $uid);
         if ($userPrivacy['comment_weibo'] == 1) {
             exit(json_encode(array('status' => 0, 'data' => L('PUBLIC_CONCENT_TIPES'))));
         }
     }
     $filterContentStatus = filter_words($data['content']);
     if (!$filterContentStatus['status']) {
         exit(json_encode(array('status' => 0, 'data' => $filterContentStatus['data'])));
     }
     $data['content'] = $filterContentStatus['data'];
     // 判断资源是否被删除
     $dao = M($data['table']);
     $idField = $dao->getPk();
     $map[$idField] = intval($data['row_id']);
     $sourceInfo = $dao->where($map)->find();
     if (!$sourceInfo) {
         $return['status'] = 0;
         $return['data'] = '内容已被删除,评论失败';
         exit(json_encode($return));
     }
     //兼容旧方法
     if (empty($data['app_detail_summary'])) {
         $source = model('Source')->getSourceInfo($data['table'], $data['row_id'], false, $data['app']);
         $data['app_detail_summary'] = $source['source_body'];
         $data['app_detail_url'] = $source['source_url'];
         $data['app_uid'] = $source['source_user_info']['uid'];
     } else {
         $data['app_detail_summary'] = $data['app_detail_summary'] . '<a class="ico-details" href="' . $data['app_detail_url'] . '"></a>';
     }
     // 添加评论操作
     $data['comment_id'] = model('Comment')->addComment($data);
     $return['sql'] = D()->getLastSql();
     if ($data['comment_id']) {
         $talkbox = intval($_POST['talkbox']);
         $return['status'] = 1;
         $return['data'] = $this->parseComment($data, $talkbox);
         // 同步到微吧
         if ($data['app'] == 'weiba') {
             $this->_upateToweiba($data);
         }
         // 去掉回复用户@
         $lessUids = array();
         if (!empty($data['to_uid'])) {
             $lessUids[] = $data['to_uid'];
         }
         if ($_POST['ifShareFeed'] == 1) {
             // 转发到我的分享
             //解锁内容发布
             unlockSubmit();
             $this->_updateToweibo($data, $sourceInfo, $lessUids);
         } else {
             if ($data['comment_old'] != 0) {
                 // 是否评论给原来作者
                 unlockSubmit();
                 $this->_updateToComment($data, $sourceInfo, $lessUids);
             }
         }
     }
     !$data['comment_id'] && ($return['data'] = model('Comment')->getError());
     exit(json_encode($return));
 }
开发者ID:heroforroose,项目名称:ThinkSNS-4,代码行数:88,代码来源:CommentWidget.class.php


示例8: comment_weibo

 /**
  * 评论一条微博 --using
  *
  * @param
  *        	integer feed_id 微博ID
  * @param
  *        	integer to_comment_id 评论ID
  * @param
  *        	string content 评论内容
  * @param
  *        	integer from 来源(2-android 3-iPhone)
  * @return array 状态+提示
  */
 public function comment_weibo()
 {
     if (!CheckPermission('core_normal', 'feed_comment')) {
         return array('status' => 0, 'msg' => '您没有权限');
     }
     if (!t($this->data['content'])) {
         return array('status' => 0, 'msg' => '评论内容不能为空');
     }
     //检测用户是否被禁言
     if ($isDisabled = model('DisableUser')->isDisableUser($this->mid, 'post')) {
         return array('status' => 0, 'msg' => '您已经被禁言了');
     }
     $feed_detail = model('Feed')->where('feed_id=' . intval($this->data['feed_id']))->find();
     $data['type'] = 1;
     $data['app'] = $feed_detail['app'];
     $data['table'] = 'feed';
     $data['row_id'] = intval($this->data['feed_id']);
     $data['app_uid'] = $feed_detail['uid'];
     $data['content'] = $this->data['content'];
     // $data ['from'] = 'feed';
     /* # 将emoji编码 */
     $data['content'] = formatEmoji(true, $data['content']);
     if ($this->data['to_comment_id']) {
         $data['to_comment_id'] = intval($this->data['to_comment_id']);
         $data['to_uid'] = model('Comment')->where('comment_id=' . intval($this->data['to_comment_id']))->getField('uid');
     }
     if ($data['comment_id'] = model('Comment')->addComment($data, true)) {
         //如果回复的源为微吧,同步评论到相应的帖子
         if ($data['app'] == 'weiba') {
             $weiba_post_detail = M('weiba_post')->where(array('post_id' => $feed_detail['app_row_id']))->find();
             $wr_data['weiba_id'] = intval($weiba_post_detail['weiba_id']);
             $wr_data['post_id'] = intval($weiba_post_detail['post_id']);
             $wr_data['post_uid'] = intval($weiba_post_detail['post_uid']);
             if (!empty($this->data['to_comment_id'])) {
                 $wr_data['to_reply_id'] = intval($this->data['to_comment_id']);
                 $wr_data['to_uid'] = model('Comment')->where('comment_id=' . intval($this->data['to_comment_id']))->getField('uid');
             }
             $wr_data['uid'] = $this->mid;
             $wr_data['ctime'] = time();
             $wr_data['content'] = $data['content'];
             $filterContentStatus = filter_words($wr_data['content']);
             if (!$filterContentStatus['status']) {
                 return array('status' => 0, 'msg' => $filterContentStatus['data']);
             }
             $wr_data['content'] = $filterContentStatus['data'];
             $wr_data['reply_id'] = $data['comment_id'];
             D('weiba_reply')->add($wr_data);
             $wp_up['last_reply_uid'] = $this->mid;
             $wp_up['last_reply_time'] = $wr_data['ctime'];
             $wp_up['reply_count'] = array('exp', 'reply_count+1');
             $wp_up['reply_all_count'] = array('exp', 'reply_all_count+1');
             D('weiba_post', 'weiba')->where('post_id = ' . $feed_detail['app_row_id'])->save($wp_up);
         }
         return array('status' => 1, 'msg' => '评论成功', 'cid' => $data['comment_id']);
     } else {
         return array('status' => 0, 'msg' => '评论失败');
     }
 }
开发者ID:medz,项目名称:thinksns-4,代码行数:71,代码来源:WeiboApi.class.php


示例9: doPost

 /**
  * 执行发布帖子
  * @return void
  */
 public function doPost()
 {
     if ($_GET['post_type'] == 'index') {
         $type = false;
     } else {
         $type = true;
     }
     $weibaid = intval($_POST['weiba_id']);
     if (!CheckPermission('weiba_normal', 'weiba_post')) {
         $this->error('对不起,您没有权限进行该操作!', $type);
     }
     $is_lock = M('weiba_blacklist')->where('weiba_id=' . $weibaid . ' and uid=' . $this->mid)->find();
     if ($is_lock) {
         $this->error('您是黑名单用户没有发帖权限', $type);
     }
     $weibaid = intval($_POST['weiba_id']);
     if (!$weibaid) {
         $this->error('请选择微吧,等待返回选择微吧', $type);
     }
     $weiba = D('weiba')->where('weiba_id=' . $weibaid)->find();
     //黑名单功能添加
     if (!CheckPermission('core_admin', 'admin_login')) {
         switch ($weiba['who_can_post']) {
             case 1:
                 $map['weiba_id'] = $weibaid;
                 $map['follower_uid'] = $this->mid;
                 $res = D('weiba_follow')->where($map)->find();
                 if (!$res && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,请关注该微吧!', $type);
                 }
                 break;
             case 2:
                 $map['weiba_id'] = $weibaid;
                 $map['level'] = array('in', '2,3');
                 $weiba_admin = D('weiba_follow')->where($map)->order('level desc')->field('follower_uid')->findAll();
                 if (!in_array($this->mid, getSubByKey($weiba_admin, 'follower_uid')) && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,仅限该吧管理员发帖!', $type);
                 }
                 break;
             case 3:
                 $map['weiba_id'] = $weibaid;
                 $map['level'] = 3;
                 $weiba_admin = D('weiba_follow')->where($map)->order('level desc')->field('follower_uid')->find();
                 if ($this->mid != $weiba_admin['follower_uid'] && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,仅限该吧吧主发帖!', $type);
                 }
                 break;
         }
     }
     $checkContent = str_replace('&nbsp;', '', $_POST['content']);
     $checkContent = str_replace('<br />', '', $checkContent);
     $checkContent = str_replace('<p>', '', $checkContent);
     $checkContent = str_replace('</p>', '', $checkContent);
     $checkContents = preg_replace('/<img(.*?)src=/i', 'img', $checkContent);
     $checkContents = preg_replace('/<embed(.*?)src=/i', 'img', $checkContents);
     if (strlen(t($_POST['title'])) == 0) {
         $this->error('帖子标题不能为空,等待返回添加标题', $type);
     }
     if (strlen(t($checkContents)) == 0) {
         $this->error('帖子内容不能为空,等待返回添加内容', $type);
     }
     preg_match_all('/./us', t($_POST['title']), $match);
     if (count($match[0]) > 25) {
         //汉字和字母都为一个字
         $this->error('帖子标题不能超过25个字,等待返回修改标题', $type);
     }
     /* # 帖子内容 */
     $content = h($_POST['content']);
     if (get_str_length($content) >= 20000) {
         $this->error('帖子内容过长!无法发布!');
     }
     unset($content);
     if ($_POST['attach_ids']) {
         $attach = explode('|', $_POST['attach_ids']);
         foreach ($attach as $k => $a) {
             if (!$a) {
                 unset($attach[$k]);
             }
         }
         $attach = array_map('intval', $attach);
         $data['attach'] = serialize($attach);
     }
     $data['weiba_id'] = $weibaid;
     $data['title'] = t($_POST['title']);
     $data['content'] = h($_POST['content']);
     $data['post_uid'] = $this->mid;
     $data['post_time'] = time();
     $data['last_reply_uid'] = $this->mid;
     $data['last_reply_time'] = $data['post_time'];
     $filterTitleStatus = filter_words($data['title']);
     if (!$filterTitleStatus['status']) {
         $this->error($filterTitleStatus['data'], $type);
     }
     $data['title'] = $filterTitleStatus['data'];
     $filterContentStatus = filter_words($data['content']);
     if (!$filterContentStatus['status']) {
//.........这里部分代码省略.........
开发者ID:jacyxie,项目名称:xindongfang,代码行数:101,代码来源:IndexAction.class.php


示例10: strip_words

/**
 * Parse the input, strip stop/non-words, remove accents, lower case and
 * add to the index.
 *
 * @uses filter_words The function that strips the stop/non-words
 * @uses add_to_index The function that adds the filtered words to the index
 * @return void
 */
function strip_words($arr)
{
    global $allowed_chars;
    $words = $arr['title'] . " " . $arr['subtitle'] . " " . $arr['introduction'] . " " . $arr['body'] . " " . $arr['keywords'];
    $words = unentify(strip_tags(str_replace(">", "> ", str_replace("<", " <", $words))));
    $words = transliterate_accents($words);
    $words = strtolower($words);
    $result = preg_split('/[^' . preg_quote($allowed_chars) . ']/', $words);
    $filter = filter_words($result);
    add_to_index($filter, $arr['code']);
}
开发者ID:wborbajr,项目名称:TecnodataApp,代码行数:19,代码来源:module_search.php


示例11: shareFeed

 /**
  * 分享/转发分享操作,需要传入POST的值
  *
  * @return json 分享/转发分享后的结果信息JSON数据
  */
 public function shareFeed()
 {
     // 获取传入的值
     $post = $_POST;
     // 安全过滤
     foreach ($post as $key => $val) {
         $post[$key] = t($post[$key]);
     }
     // 过滤内容值
     // $post['body'] = filter_keyword($post['body']);
     $filterBodyStatus = filter_words($post['body']);
     if (!$filterBodyStatus['status']) {
         $return = array('status' => 0, 'data' => $filterBodyStatus['data']);
         exit(json_encode($return));
     }
     $post['body'] = $filterBodyStatus['data'];
     // 判断资源是否删除
     if (empty($post['curid'])) {
         $map['feed_id'] = intval($post['sid']);
     } else {
         $map['feed_id'] = intval($post['curid']);
     }
     $map['is_del'] = 0;
     $isExist = model('Feed')->where($map)->count();
     if ($isExist == 0) {
         $return['status'] = 0;
         $return['data'] = '内容已被删除,转发失败';
         exit(json_encode($return));
     }
     // 进行分享操作
     $return = model('Share')->shareFeed($post, 'share');
     if ($return['status'] == 1) {
         $app_name = $post['app_name'];
         // 添加积分
         if ($app_name == 'public') {
             model('Credit')->setUserCredit($this->uid, 'forward_weibo');
             // 分享被转发
             $suid = model('Feed')->where($map)->getField('uid');
             model('Credit')->setUserCredit($suid, 'forwarded_weibo');
         }
         if ($app_name == 'weiba') {
             model('Credit')->setUserCredit($this->uid, 'forward_topic');
             // 分享被转发
             $suid = D('Feed')->where('feed_id=' . $map['feed_id'])->getField('uid');
             model('Credit')->setUserCredit($suid, 'forwarded_topic');
         }
         $this->assign($return['data']);
         // 分享配置
         $weiboSet = model('Xdata')->get('admin_Config:feed');
         $this->assign('weibo_premission', $weiboSet['weibo_premission']);
         $return['data'] = $this->fetch('PostFeed');
     }
     if ($post['comment'] == '1') {
     }
     exit(json_encode($return));
 }
开发者ID:omusico,项目名称:ThinkSNS-4,代码行数:61,代码来源:FeedAction.class.php


示例12: sprintf

    $regex = '/^([a-z]*)' . $filter . '$/i';
    $line = sprintf("\nconst char g_prefix_%s[] = \"", $filter);
    foreach ($db as $word) {
        if (preg_match($regex, $word, $res)) {
            $s = '\\0' . ucfirst($res[1]);
            if (strlen($s) > $maxlen) {
                continue;
            }
            if (strlen($line . $s) > 75) {
                echo "{$line}\"\n";
                $line = "\t\"";
            }
            $line .= $s;
        }
    }
    echo "{$line}\";\n";
}
echo "#ifndef __DB_H__\n";
echo "#define __DB_H__\n";
filter_words('cal');
filter_words('matic');
filter_words('meter');
filter_words('ferous');
filter_words('metric');
filter_words('nated');
filter_words('stic');
filter_words('opic');
filter_words('ected');
filter_words('graph');
filter_words('scope');
echo "\n#endif/*__DB_H__*/\n";
开发者ID:ahmedomarjee,项目名称:openbeacon-ng,代码行数:31,代码来源:db-update.php


示例13: put

 /**
  * 添加分享
  * @param integer $uid 操作用户ID
  * @param string $app 分享应用类型,默认为public
  * @param string $type 分享类型,
  * @param array $data 分享相关数据
  * @param integer $app_id 应用资源ID,默认为0
  * @param string $app_table 应用资源表名,默认为feed
  * @param array  $extUid 额外用户ID,默认为null
  * @param array $lessUids 去除的用户ID,默认为null
  * @param boolean $isAtMe 是否为进行发送,默认为true
  * @return mix 添加失败返回false,成功返回新的分享ID
  */
 public function put($uid, $app = 'public', $type = '', $data = array(), $app_id = 0, $app_table = 'feed', $extUid = null, $lessUids = null, $isAtMe = true, $is_repost = 0)
 {
     if (isSubmitLocked()) {
         $this->error = '发布内容过于频繁,请稍后再试';
         return false;
     }
     // 判断数据的正确性
     if (!$uid || $type == '') {
         $this->error = L('PUBLIC_ADMIN_OPRETING_ERROR');
         return false;
     }
     if (strpos($type, 'postvideo') !== false) {
         $type = 'postvideo';
     }
     //分享类型合法性验证 - 临时解决方案
     $checkType = array('post', 'repost', 'postvideo', 'postfile', 'postimage', 'weiba_post', 'weiba_repost', 'long_post', 'photo_post', 'photo_repost', 'vote_post', 'vote_repost', 'event_post', 'event_repost', 'blog_post', 'blog_repost', 'poster_post', 'poster_repost');
     if (!in_array($type, $checkType)) {
         $type = 'post';
     }
     //应用类型验证 用于分享框 - 临时解决方案
     $checkApp = array('w3g', 'public', 'weiba', 'tipoff', 'photo', 'vote', 'event', 'blog', 'poster');
     if (!in_array($app, $checkApp)) {
         $app = 'public';
         $type = 'post';
         $app_table = 'feed';
     }
     $app_table = strtolower($app_table);
     // 添加feed表记录
     $data['uid'] = $uid;
     $data['app'] = $app;
     $data['type'] = $type;
     $data['app_row_id'] = $app_id;
     $data['app_row_table'] = $app_table;
     $data['publish_time'] = time();
     $data['from'] = isset($data['from']) ? intval($data['from']) : getVisitorClient();
     $data['is_del'] = $data['comment_count'] = $data['repost_count'] = 0;
     $data['is_repost'] = $is_repost;
     //判断是否先审后发
     $filterStatus = filter_words($data['body']);
     $weiboSet = model('Xdata')->get('admin_Config:feed');
     $weibo_premission = $weiboSet['weibo_premission'];
     if (in_array('audit', $weibo_premission) || CheckPermission('core_normal', 'feed_audit') || $filterStatus['type'] == 2) {
         $data['is_audit'] = 0;
     } else {
         $data['is_audit'] = 1;
     }
     // 分享内容处理
     if (Addons::requireHooks('weibo_publish_content')) {
         Addons::hook("weibo_publish_content", array(&$data));
     } else {
         // 截取内容信息为分享内容字数 - 长分享
         //$feedConf = model('Xdata')->get('admin_Config:feed');
         //$feedNums = $feedConf['weibo_nums'];
         //if(Addons::requireHooks('show_longtext_button')){
         //	$feedNums = 20000;
         //	$data['body'] = str_replace(SITE_URL, '[SITE_URL]', $data['body']);
         //}else{
         //	$data['body'] = str_replace(SITE_URL, '[SITE_URL]', preg_html($data['body']));
         //}
         $content = $this->formatFeedContent($data['body']);
         $data['body'] = $content['body'];
         $data['content'] = $content['content'];
     }
     //分享到分享的应用资源,加入原资源链接
     $data['body'] .= $data['source_url'];
     $data['content'] .= $data['source_url'];
     // 分享类型插件钩子
     // if($type){
     // 	$addonsData = array();
     // 	Addons::hook("weibo_type",array("typeId"=>$type,"typeData"=>$type_data,"result"=>&$addonsData));
     // 	$data = array_merge($data,$addonsData);
     // }
     if ($type == 'postvideo') {
         if ($_POST['video_id']) {
             $video_info = D('video')->where('video_id=' . $data['video_id'])->find();
             $data['transfer_id'] = $video_info['transfer_id'];
             $data['video_path'] = $video_info['video_path'];
             $data['video_mobile_path'] = $video_info['video_mobile_path'];
             $data['video_part_path'] = $video_info['video_part_path'];
             $data['image_path'] = $video_info['image_path'];
             $data['image_width'] = $video_info['image_width'];
             $data['image_height'] = $video_info['image_height'];
         } else {
             $typedata = model('Video')->_weiboTypePublish($_POST['videourl']);
             if ($typedata && $typedata['flashvar'] && $typedata['flashimg']) {
                 $data = array_merge($data, $typedata);
             } else {
//.........这里部分代码省略.........
开发者ID:nanhuacrab,项目名称:ThinkSNS4,代码行数:101,代码来源:FeedModel.class.php


示例14: add_post

 public function add_post($imgs)
 {
     if (!CheckPermission('weiba_normal', 'weiba_post')) {
         $this->error('对不起,您没有权限进行该操作!');
     }
     $weibaid = intval($this->data['weiba_id']);
     if (!$weibaid) {
         $this->error('请选择微吧!');
     }
     $weiba = D('weiba')->where('weiba_id=' . $weibaid)->find();
     if (!CheckPermission('core_admin', 'admin_login')) {
         switch ($weiba['who_can_post']) {
             case 1:
                 $map['weiba_id'] = $weibaid;
                 $map['follower_uid'] = $this->mid;
                 $res = D('weiba_follow')->where($map)->find();
                 if (!$res && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,请关注该微吧!');
                 }
                 break;
             case 2:
                 $map['weiba_id'] = $weibaid;
                 $map['level'] = array('in', '2,3');
                 $weiba_admin = D('weiba_follow')->where($map)->order('level desc')->field('follower_uid')->findAll();
                 if (!in_array($this->mid, getSubByKey($weiba_admin, 'follower_uid')) && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,仅限管理员发帖!');
                 }
                 break;
             case 3:
                 $map['weiba_id'] = $weibaid;
                 $map['level'] = 3;
                 $weiba_admin = D('weiba_follow')->where($map)->order('level desc')->field('follower_uid')->find();
                 if ($this->mid != $weiba_admin['follower_uid'] && !CheckPermission('core_admin', 'admin_login')) {
                     $this->error('对不起,您没有发帖权限,仅限吧主发帖!');
                 }
                 break;
         }
     }
     if (!empty($imgs)) {
         foreach ($imgs as $v) {
             $src = getImageUrlByAttachId($v['attach_id'], 320, 1000);
             $src && ($img_arr[] = '<img src="' 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP filter_xss函数代码示例发布时间:2022-05-15
下一篇:
PHP filter_var_array函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap