コード例 #1
0
 /**
  * 添加评论操作
  * @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 {
                 // 评论
                 $config['comment_type'] = '评论 我 的分享:';
                 if (!empty($add['app_uid'])) {
                     model('Notify')->sendNotify($add['app_uid'], 'comment', $config);
                 }
             }
         }
     }
     $this->error = $res ? L('PUBLIC_CONCENT_IS_OK') : L('PUBLIC_CONCENT_IS_ERROR');
     // 评论成功,评论失败
     return $res;
 }
コード例 #2
0
ファイル: blog.php プロジェクト: xudong7930/mobile
                         $cuid = form_input($_POST['cuid']);
                         //评论uid
                         if ($cuid == "" || $cuid == null) {
                             $result = array("status" => "error", "code" => 505, "msg" => "cuid field requird");
                             throwJSON($result);
                             exit;
                         }
                         $message = form_input($_POST['message']);
                         if ($message == "" || $message == null) {
                             $result = array("status" => "error", "code" => 505, "msg" => "message field requird");
                             throwJSON($result);
                             exit;
                         }
                         $cusername = get_username($cuid);
                         $ip = get_client_ip();
                         $port = get_client_port();
                         $home_comment = array("uid" => $uid, "id" => $bid, "idtype" => "blogid", "authorid" => $cuid, "author" => $cusername, "ip" => $ip, "port" => $port, "dateline" => $now, "message" => $message, "magicflicker" => 0, "status" => 0);
                         $flag = $db->AutoExecute("disc_home_comment", $home_comment, "INSERT");
                         if ($flag) {
                             $data = array("status" => "ok", "code" => 200, "msg" => "评论成功");
                         } else {
                             $data = array("status" => "error", "code" => 505, "msg" => "评论失败");
                         }
                     } else {
                         $data = array("status" => "error", "msg" => "no module to handle this action.");
                     }
                 }
             }
         }
     }
 }
コード例 #3
0
 /**
  * 添加分享
  * @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 {
                 $data['type'] = 'post';
             }
         }
     }
     // 添加分享信息
     $feed_id = $this->data($data)->add();
     if (!$feed_id) {
         return false;
     }
     if ($data['video_id']) {
         D('video')->where('video_id=' . $data['video_id'])->setField('feed_id', $feed_id);
         //如果有的话
         if (D('video_transfer')->where('video_id=' . $data['video_id'])->count()) {
             D('video_transfer')->where('video_id=' . $data['video_id'])->setField('feed_id', $feed_id);
         }
     }
     if (!$data['is_audit']) {
         $touid = D('user_group_link')->where('user_group_id=1')->field('uid')->findAll();
         foreach ($touid as $k => $v) {
             model('Notify')->sendNotify($v['uid'], 'feed_audit');
         }
     }
     // 目前处理方案格式化数据
     $data['content'] = str_replace(chr(31), '', $data['content']);
     $data['body'] = str_replace(chr(31), '', $data['body']);
     // 添加关联数据
     $feed_data = D('FeedData')->data(array('feed_id' => $feed_id, 'feed_data' => serialize($data), 'client_ip' => get_client_ip(), 'client_port' => get_client_port(), 'feed_content' => $data['body']))->add();
     // 添加分享成功后
     if ($feed_id && $feed_data) {
         //锁定发布
         lockSubmit();
         //分享发布成功后的钩子
         //Addons::hook("weibo_publish_after",array('weibo_id'=>$feed_id,'post'=>$data));
         // 发送通知消息 - 重点 - 需要简化把上节点的信息去掉.
         if ($data['is_repost'] == 1) {
             // 转发分享
             $isAtMe && ($content = $data['content']);
             // 内容用户
             $extUid[] = $data['sourceInfo']['transpond_data']['uid'];
             // 资源作者用户
             if ($isAtMe && !empty($data['curid'])) {
                 // 上节点用户
                 $appRowData = $this->get($data['curid']);
                 $extUid[] = $appRowData['uid'];
             }
         } else {
             // 其他分享
             $content = $data['content'];
             //更新最近@的人
             model('Atme')->updateRecentAt($content);
             // 内容用户
         }
         // 发送@消息
         model('Atme')->setAppName('Public')->setAppTable('feed')->addAtme($content, $feed_id, $extUid, $lessUids);
         $data['client_ip'] = get_client_ip();
         $data['feed_id'] = $feed_id;
         $data['feed_data'] = serialize($data);
         // 主动创建渲染后的缓存
         $return = $this->setFeedCache($data);
         $return['user_info'] = model('User')->getUserInfo($uid);
         $return['GroupData'] = model('UserGroupLink')->getUserGroupData($uid);
         //获取用户组信息
         $return['feed_id'] = $feed_id;
         $return['app_row_id'] = $data['app_row_id'];
         $return['is_audit'] = $data['is_audit'];
         // 统计数修改
         model('UserData')->setUid($uid)->updateKey('feed_count', 1);
         // if($app =='public'){ //TODO 分享验证条件
         model('UserData')->setUid($uid)->updateKey('weibo_count', 1);
         // }
         //更新附件信息
         $attach_info['app_name'] = 'public';
         $attach_info['table'] = 'feed';
         $attach_info['row_id'] = $feed_id;
         $attach_map['attach_id'] = array('IN', $data['attach_id']);
         model('Attach')->where($attach_map)->save($attach_info);
         if (!$return) {
             $this->error = L('PUBLIC_CACHE_FAIL');
             // Feed缓存写入失败
         }
         return $return;
     } else {
         $this->error = L('PUBLIC_ADMIN_OPRETING_ERROR');
         // 操作失败
         return false;
     }
 }
コード例 #4
0
 public function addcomment()
 {
     $data['app'] = 'public';
     $data['table'] = 'webpage';
     $data['row_id'] = intval($_POST['row_id']);
     $data['app_uid'] = 0;
     $data['uid'] = $this->mid;
     $data['content'] = t($_POST['content']);
     $data['to_comment_id'] = intval($_POST['to_comment_id']);
     $data['to_uid'] = intval($_POST['to_uid']);
     // $data['data'] = '';
     $data['ctime'] = time();
     $data['is_del'] = 0;
     $data['client_type'] = 0;
     $data['is_audit'] = 1;
     $data['storey'] = 0;
     $data['app_detail_url'] = '';
     $data['app_detail_summary'] = '';
     $data['client_ip'] = get_client_ip();
     $data['client_port'] = get_client_port();
     $result = model('Comment')->add($data);
     $res = array();
     if ($result) {
         $res['status'] = 1;
         $res['data'] = '评论成功';
     } else {
         $res['status'] = 0;
         $res['data'] = '评论失败';
     }
     $with_new_weibo = intval($_POST['with_new_weibo']);
     if ($with_new_weibo == 1) {
         // 用户发送内容
         $d['content'] = '';
         $d['body'] = $data['content'];
         $d['source_url'] = '';
         // 滤掉话题两端的空白
         $d['body'] = preg_replace("/#[\\s]*([^#^\\s][^#]*[^#^\\s])[\\s]*#/is", '#' . trim("\${1}") . '#', $d['body']);
         // 发送分享的类型
         $type = 'post';
         // 所属应用名称
         $app = 'public';
         if ($data = model('Feed')->put($this->mid, $app, $type, $d)) {
             model('Credit')->setUserCredit($this->mid, 'add_weibo');
             // 添加话题
             model('FeedTopic')->addTopic(html_entity_decode($d['body'], ENT_QUOTES, 'UTF-8'), $data['feed_id'], $type);
             // 更新用户最后发表的分享
             $last['last_feed_id'] = $data['feed_id'];
             $last['last_post_time'] = $_SERVER['REQUEST_TIME'];
             model('User')->where('uid=' . $this->mid)->save($last);
         }
     }
     exit(json_encode($res));
 }
コード例 #5
0
ファイル: signup.php プロジェクト: xudong7930/mobile
 * Project: 51fabu
 * Function: 手机app用户注册处理
 * Time: 2015-5-20 15:22:16 @ Create
 * Copyright (c) 2007 - 2015 51fabu Studio
 * Website: http://51fabu.bj-soft.cn
 * Developer: 51fabu<*****@*****.**>
 * last-modify: 2015年8月17日14:14:02
 * ===========================================
 */
include "init.inc.php";
$now = time();
$data = array();
$date = date("Y-m-d", $now);
$clientIP = get_client_ip();
//客户端IP
$clientPort = get_client_port();
//客户端端口
$mobile = "";
$nickname = "";
$gender = "";
$password = "";
$captcha = "";
//手机号
if (isset($_POST['mobile'])) {
    $mobile = form_input($_POST["mobile"]);
}
if (isNull($mobile)) {
    throwJSON(array("status" => "error", "code" => 301, "msg" => "mobile can not be null"));
    exit;
} else {
    $sql = "select uid from disc_common_member_profile where mobile={$mobile}";