当前位置: 首页>>代码示例>>PHP>>正文


PHP preg_html函数代码示例

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


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

示例1: _escapeData

 /**
  * 检测数据安全性
  * @param array $data 待检测的数据
  * @return array 验证后的数据
  */
 private function _escapeData($data)
 {
     $add['type'] = !$data['type'] ? 1 : $data['type'];
     $add['app'] = !$data['app'] ? $this->_app : $data['app'];
     $add['table'] = !$data['table'] ? $this->_app_table : $data['table'];
     $add['row_id'] = intval($data['row_id']);
     $add['app_uid'] = intval($data['app_uid']);
     $add['uid'] = $GLOBALS['ts']['mid'];
     $add['content'] = preg_html($data['content']);
     $add['to_comment_id'] = intval($data['to_comment_id']);
     $add['to_uid'] = intval($data['to_uid']);
     $add['data'] = serialize($data['data']);
     $add['ctime'] = $_SERVER['REQUEST_TIME'];
     $add['client_type'] = isset($data['client_type']) ? intval($data['client_type']) : getVisitorClient();
     $add['app_detail_summary'] = t($data['app_detail_summary']);
     $add['app_detail_url'] = $data['app_detail_url'];
     return $add;
 }
开发者ID:omusico,项目名称:ThinkSNS-4,代码行数:23,代码来源:CommentModel.class.php

示例2: parseComment

 /**
  * 渲染评论页面 在addcomment方法中调用
  */
 public function parseComment($data)
 {
     $data['userInfo'] = model('User')->getUserInfo($GLOBALS['ts']['uid']);
     // 获取用户组信息
     $data['userInfo']['groupData'] = model('UserGroupLink')->getUserGroupData($GLOBALS['ts']['uid']);
     $data['content'] = preg_html($data['content']);
     $data['content'] = parse_html($data['content']);
     $data['iscommentdel'] = CheckPermission('core_normal', 'comment_del');
     return $this->renderFile(dirname(__FILE__) . "/_parseComment.html", $data);
 }
开发者ID:a349944418,项目名称:kaopu,代码行数:13,代码来源:EventCommentWidget.class.php

示例3: addReplyToCommentForApi

 /**
  * 添加评论回复forApi
  * @param int reply_id 评论ID
  * @param int content 回复内容
  * @param int uid 回复者UID
  * @return bool 是否回复成功
  */
 public function addReplyToCommentForApi($reply_id, $content, $uid)
 {
     $reply_detail = $this->where('reply_id=' . $reply_id)->find();
     $data['weiba_id'] = intval($reply_detail['weiba_id']);
     $data['post_id'] = intval($reply_detail['post_id']);
     $data['post_uid'] = intval($reply_detail['post_uid']);
     $data['to_reply_id'] = $reply_id;
     $data['to_uid'] = intval($reply_detail['uid']);
     $data['uid'] = $uid;
     $data['ctime'] = time();
     $data['content'] = preg_html(h($content));
     if ($data['reply_id'] = D('weiba_reply')->add($data)) {
         $map['last_reply_uid'] = $data['uid'];
         $map['last_reply_time'] = $data['ctime'];
         D('weiba_post')->where('post_id=' . $data['post_id'])->save($map);
         D('weiba_post')->where('post_id=' . $data['post_id'])->setInc('reply_count');
         //回复统计数加1
         //同步到分享评论
         //$feed_id = intval($_POST['feed_id']);
         $datas['app'] = 'weiba';
         $datas['table'] = 'feed';
         $datas['row_id'] = D('weiba_post')->where('post_id=' . $data['post_id'])->getField('feed_id');
         $datas['app_uid'] = intval($data['post_uid']);
         $datas['to_comment_id'] = intval($reply_detail['comment_id']);
         $datas['to_uid'] = $data['to_uid'];
         $datas['uid'] = $data['uid'];
         $datas['content'] = preg_html($data['content']);
         $datas['ctime'] = $data['ctime'];
         $datas['client_type'] = getVisitorClient();
         if ($comment_id = D('comment')->add($datas)) {
             D('weiba_reply')->where('reply_id=' . $data['reply_id'])->setField('comment_id', $comment_id);
             // 被评论内容的“评论统计数”加1,同时可检测出app,table,row_id的有效性
             D('feed')->where('feed_id=' . $datas['row_id'])->setInc('comment_count');
             // 给应用UID添加一个未读的评论数
             if ($GLOBALS['ts']['mid'] != $datas['app_uid'] && $datas['app_uid'] != '') {
                 !$notCount && model('UserData')->updateKey('unread_comment', 1, true, $datas['app_uid']);
             }
             model('Feed')->cleanCache($datas['row_id']);
         }
         return true;
     } else {
         return false;
     }
 }
开发者ID:medz,项目名称:thinksns-4,代码行数:51,代码来源:WeibaReplyModel.class.php

示例4: 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 = 'group', $type = '', $data = array(), $app_id = 0, $app_table = 'group_feed', $extUid = null, $lessUids = null, $isAtMe = true, $is_repost = 0)
 {
     // 判断数据的正确性
     if (!$uid || $type == '') {
         return false;
     }
     if (strpos($type, 'postvideo') !== false) {
         $type = 'postvideo';
     }
     //分享类型合法性验证 - 临时解决方案
     if (!in_array($type, array('post', 'repost', 'postvideo', 'postfile', 'postimage'))) {
         $type = 'post';
     }
     // //应用类型验证 用于分享框 - 临时解决方案
     // if ( !in_array( $app , array('public','weiba','tipoff') ) ){
     //     $app = 'public';
     //     $type = 'post';
     //     $app_table = 'feed';
     // }
     $app_table = strtolower($app_table);
     // 添加feed表记录
     $data['gid'] = $data['gid'];
     $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;
     //判断是否先审后发
     //         $weiboSet = model('Xdata')->get('admin_Config:feed');
     //         $weibo_premission = $weiboSet['weibo_premission'];
     //         if(in_array('audit',$weibo_premission) || CheckPermission('core_normal','feed_audit')){
     //             $data['is_audit'] = 0;
     //         }else{
     $data['is_audit'] = 1;
     //         }
     // 分享内容处理
     if (Addons::requireHooks('weibo_publish_content')) {
         Addons::hook("weibo_publish_content", array(&$data));
     } else {
         // 拼装数据,如果是评论再转发、回复评论等情况,需要额外叠加对话数据
         $data['body'] = str_replace(SITE_URL, '[SITE_URL]', preg_html($data['body']));
         // 获取用户发送的内容,仅仅以//进行分割
         $scream = explode('//', $data['body']);
         // 截取内容信息为分享内容字数 - 重点
         $feedConf = model('Xdata')->get('admin_Config:feed');
         $feedNums = $feedConf['weibo_nums'];
         $body = array();
         foreach ($scream as $value) {
             $tbody[] = $value;
             $bodyStr = implode('//', $tbody);
             if (get_str_length($bodyStr) > $feedNums) {
                 break;
             }
             $body[] = $value;
             unset($bodyStr);
         }
         $data['body'] = implode('//', $body);
         // 获取用户发布内容
         $data['content'] = trim($scream[0]);
     }
     //分享到分享的应用资源,加入原资源链接
     $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') {
         $typedata = model('Video')->_weiboTypePublish($_POST['videourl']);
         if ($typedata && $typedata['flashvar'] && $typedata['flashimg']) {
             $data = array_merge($data, $typedata);
         } else {
             $data['type'] = 'post';
         }
     }
     // 添加分享信息
     $feed_id = $this->data($data)->add();
     if (!$feed_id) {
         return false;
     }
     //         if(!$data['is_audit']){
//.........这里部分代码省略.........
开发者ID:omusico,项目名称:ThinkSNS-4,代码行数:101,代码来源:GroupFeedModel.class.php

示例5: formatFeedContent

 /**
  * 截取微博内容,将微博中的URL替换成{ts_urlX}进行字符数目统计
  * @param string $content 微博内容
  * @param string $weiboNums 微博截取数目,默认为0
  * @return array 格式化后的微博内容,body与content
  */
 public function formatFeedContent($content, $weiboNums = 0)
 {
     // 拼装数据,如果是评论再转发、回复评论等情况,需要额外叠加对话数据
     $content = str_replace(SITE_URL, '[SITE_URL]', preg_html($content));
     // 格式化微博信息 - URL
     $content = preg_replace_callback('/((?:https?|mailto|ftp):\\/\\/([^\\x{2e80}-\\x{9fff}\\s<\'\\"“”‘’,。}]*)?)/u', '_format_feed_content_url_length', $content);
     $replaceHash = $GLOBALS['replaceHash'];
     unset($GLOBALS['replaceHash']);
     // 获取用户发送的内容,仅仅以//进行分割
     $scream = explode('//', $content);
     // 截取内容信息为微博内容字数 - 重点
     $feedNums = 0;
     if (empty($weiboNums)) {
         $feedConf = model('Xdata')->get('admin_Config:feed');
         $feedNums = $feedConf['weibo_nums'];
     } else {
         $feedNums = $weiboNums;
     }
     $body = array();
     // 还原URL操作
     $patterns = array_keys($replaceHash);
     $replacements = array_values($replaceHash);
     foreach ($scream as $value) {
         $tbody[] = $value;
         $bodyStr = implode('//', $tbody);
         if (get_str_length(ltrim($bodyStr)) > $feedNums) {
             break;
         }
         $body[] = str_replace($patterns, $replacements, $value);
         unset($bodyStr);
     }
     $data['body'] = implode('//', $body);
     // 获取用户发布内容
     $scream[0] = str_replace($patterns, $replacements, $scream[0]);
     $data['content'] = trim($scream[0]);
     return $data;
 }
开发者ID:yang7hua,项目名称:hunshe,代码行数:43,代码来源:FeedModel.class.php

示例6: parseComment

 /**
  * 渲染评论页面 在addcomment方法中调用
  */
 public function parseComment($data, $talkbox)
 {
     $data['userInfo'] = model('User')->getUserInfo($GLOBALS['ts']['uid']);
     // 获取用户组信息
     $data['userInfo']['groupData'] = model('UserGroupLink')->getUserGroupData($GLOBALS['ts']['uid']);
     $data['content'] = preg_html($data['content']);
     $data['content'] = parse_html($data['content']);
     $data['content'] = str_replace('__THEME__', THEME_PUBLIC_URL, parse_html($data['content']));
     $data['iscommentdel'] = CheckPermission('core_normal', 'comment_del');
     if ($talkbox) {
         $html = '<dl model-node="comment_list" class="msg-dialog">';
         $html .= '<dt class="right">';
         $html .= '<a href="' . U('public/Profile/index', array('uid' => $data['userInfo']['uid'])) . '"><img src="' . $data['userInfo']['avatar_tiny'] . '"></a>';
         $html .= '</dt>';
         $html .= '<dd class="dialog-r">';
         $html .= '<i class="arrow-mes-r"></i>';
         $html .= '<p class="info">' . $data['userInfo']['space_link'] . ':&nbsp;' . $data['content'] . '</p>';
         $html .= '<p class="date"><span class="right">';
         $html .= '<a href="javascript:;" event-node="comment_del" event-args="comment_id=' . $data['comment_id'] . '">删除</a>' . "\n";
         $html .= '<i class="vline">|</i>' . "\n";
         $html .= '<a href="javascript:;" event-args="row_id=' . $data['row_id'] . '&app_uid=' . $data['app_uid'] . '&to_comment_id=' . $data['to_comment_id'] . '&to_uid=' . $data['to_uid'] . '&to_comment_uname=' . $data['userInfo']['uname'] . '&app_name=' . $data['app'] . '&table=' . $data['table'] . '" event-node="reply_comment" >回复</a>';
         $html .= '</span>刚刚</p>';
         $html .= '</dd>';
         $html .= '</dl>';
         return $html;
     } else {
         return $this->renderFile(dirname(__FILE__) . "/_parseComment.html", $data);
     }
 }
开发者ID:heroforroose,项目名称:ThinkSNS-4,代码行数:32,代码来源:CommentWidget.class.php

示例7: parseReply

 /**
  * 渲染评论页面 在addcomment方法中调用
  */
 public function parseReply($data)
 {
     $data['userInfo'] = model('User')->getUserInfo($GLOBALS['ts']['uid']);
     $data['userInfo']['groupData'] = model('UserGroupLink')->getUserGroupData($GLOBALS['ts']['uid']);
     //获取用户组信息
     $data['content'] = preg_html($data['content']);
     $data['content'] = parse_html($data['content']);
     return $this->renderFile(dirname(__FILE__) . "/_parseComment.html", $data);
 }
开发者ID:naliduo,项目名称:ThinkSNS,代码行数:12,代码来源:WeibaReplyWidget.class.php

示例8: comment_post

 /**
  * 评论帖子 --using
  *
  * @param
  *        	integer post_id 帖子ID
  * @param
  *        	integer to_comment_id 评论ID
  * @param
  *        	string content 评论内容
  * @param
  *        	integer from 来源(2-android 3-iPhone)
  * @return array 状态+提示
  */
 public function comment_post()
 {
     $return['status'] = 0;
     $return['msg'] = '发布失败';
     //检测用户是否被禁言
     if ($isDisabled = model('DisableUser')->isDisableUser($this->mid, 'post')) {
         return array('status' => 0, 'msg' => '您已经被禁言了');
     }
     if (!t($this->data['content'])) {
         $return['msg'] = '评论内容不能为空';
         return $return;
     }
     if (!intval($this->data['post_id'])) {
         $return['msg'] = '参数非法';
         return $return;
     }
     if (!$this->mid || !CheckPermission('weiba_normal', 'weiba_reply')) {
         $return['msg'] = '你无权发布';
         return $return;
     }
     $feed_detail = M('weiba_post')->where('post_id=' . intval($this->data['post_id']))->find();
     $data['weiba_id'] = intval($feed_detail['weiba_id']);
     $data['post_id'] = intval($this->data['post_id']);
     $data['post_uid'] = intval($feed_detail['post_uid']);
     if (!empty($this->data['to_comment_id'])) {
         $data['to_reply_id'] = intval($this->data['to_comment_id']);
         $data['to_uid'] = model('Comment')->where('comment_id=' . intval($this->data['to_comment_id']))->getField('uid');
     }
     $data['uid'] = $this->mid;
     $data['ctime'] = time();
     $data['content'] = preg_html(h($this->data['content']));
     /* # 格式化emoji */
     $data['content'] = formatEmoji(true, $data['content']);
     $data['attach_id'] = intval($this->data['attach_id']);
     $filterContentStatus = filter_words($data['content']);
     if (!$filterContentStatus['status']) {
         return array('status' => 0, 'msg' => $filterContentStatus['data']);
     }
     $data['content'] = $filterContentStatus['data'];
     if (isSubmitLocked()) {
         $return['msg'] = '发布内容过于频繁,请稍后再试!';
         return $return;
     }
     if ($data['reply_id'] = D('weiba_reply')->add($data)) {
         // 锁定发布
         lockSubmit();
         // 添加积分
         model('Credit')->setUserCredit(intval($data['post_uid']), 'comment_topic');
         model('Credit')->setUserCredit($data['to_uid'], 'commented_topic');
         $map['last_reply_uid'] = $this->mid;
         $map['last_reply_time'] = $data['ctime'];
         $map['reply_count'] = array('exp', 'reply_count+1');
         $map['reply_all_count'] = array('exp', 'reply_all_count+1');
         D('weiba_post')->where('post_id=' . $data['post_id'])->save($map);
         // 同步到微博评论
         $datas['app'] = 'weiba';
         $datas['table'] = 'feed';
         $datas['content'] = preg_html($data['content']);
         $datas['app_uid'] = intval($feed_detail['post_uid']);
         $datas['row_id'] = intval($feed_detail['feed_id']);
         $datas['to_comment_id'] = $data['to_reply_id'] ? D('weiba_reply')->where('reply_id=' . $data['to_reply_id'])->getField('comment_id') : 0;
         $datas['to_uid'] = intval($data['to_uid']);
         $datas['uid'] = $this->mid;
         $datas['ctime'] = time();
         $datas['client_type'] = getVisitorClient();
         // $datas ['from'] = 'weiba';
         $data['cancomment'] = 1;
         // 解锁
         unlockSubmit();
         if ($comment_id = model('Comment')->addComment($datas)) {
             $data1['comment_id'] = $comment_id;
             // $data1['storey'] = model('Comment')->where('comment_id='.$comment_id)->getField('storey');
             D('weiba_reply')->where('reply_id=' . $data['reply_id'])->save($data1);
             // 给应用UID添加一个未读的评论数
             // if ($GLOBALS ['ts'] ['mid'] != $datas ['app_uid'] && $datas ['app_uid'] != '') {
             //     ! $notCount && model('UserData')->updateKey('unread_comment_weiba', 1, true, $datas ['app_uid']);
             // }
             model('Feed')->cleanCache($datas['row_id']);
         }
         // 转发到我的微博
         if ($this->data['ifShareFeed'] == 1) {
             $commentInfo = model('Source')->getSourceInfo($datas['table'], $datas['row_id'], false, $datas['app']);
             $oldInfo = isset($commentInfo['sourceInfo']) ? $commentInfo['sourceInfo'] : $commentInfo;
             // 根据评论的对象获取原来的内容
             $s['sid'] = $data['post_id'];
             $s['app_name'] = 'weiba';
             if (!empty($data['to_comment_id'])) {
//.........这里部分代码省略.........
开发者ID:medz,项目名称:thinksns-4,代码行数:101,代码来源:WeibaApi.class.php

示例9: parseComment

 public function parseComment($data)
 {
     $data['userInfo'] = model('User')->getUserInfo($GLOBALS['ts']['uid']);
     $data['content'] = preg_html($data['content']);
     $data['content'] = parse_html($data['content']);
     //return $this->renderFile(dirname(__FILE__)."/_parseComment.html",$data);
 }
开发者ID:songhongyu,项目名称:THINKSNS,代码行数:7,代码来源:SystemApi.class.php


注:本文中的preg_html函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。