/** * 添加评论 * @param $cid 内容ID * @param $content 内容 * @param $reply_id 回复内容ID * @param $reply_user_id 回复内容的用户ID * @param $type (0视频、1网台、2用户、3专辑) * @return $ret 评论信息 */ function create() { $mInfo = $this->mUser->verify_credentials(); if (!$mInfo) { $this->errorOutput(USENAME_NOLOGIN); } include_once ROOT_DIR . 'lib/class/banword.class.php'; $banword = new banword(); $status = 1; $banwords = $banword->banword($this->input['content']); if ($banwords && $banwords != 'null') { $status = 0; $banwords = implode(',', $banwords); } else { $banwords = ''; } $info = array('id' => 0, 'cid' => 0, 'user_id' => $mInfo['id'], 'content' => "", 'ip' => hg_getip(), 'reply_id' => 0, 'reply_user_id' => 0, 'create_time' => time(), 'type' => 0, 'state' => $status); $info['cid'] = $this->input['cid']; $info['content'] = urldecode($this->input['content']); $info['type'] = $this->input['type']; //默认为视频 $info['reply_id'] = $this->input['reply_id']; $info['reply_user_id'] = $this->input['reply_user_id']; if (!$info['cid']) { $this->errorOutput(OBJECT_NULL); } $sql = "INSERT INTO " . DB_PREFIX . "comments(\r\n\t\t\tuser_id,\r\n\t\t\tcid,\r\n\t\t\tcontent,\r\n\t\t\tip,\r\n\t\t\treply_id,\r\n\t\t\treply_user_id,\r\n\t\t\tcreate_time,\r\n\t\t\ttype,\r\n\t\t\tstate \r\n\t\t) VALUES(\r\n\t\t\t" . $info['user_id'] . ",\r\n\t\t\t" . $info['cid'] . ",\r\n\t\t\t'" . $info['content'] . "',\r\n\t\t\t'" . $info['ip'] . "',\r\n\t\t\t" . $info['reply_id'] . ",\r\n\t\t\t" . $info['reply_user_id'] . ",\r\n\t\t\t" . $info['create_time'] . ",\r\n\t\t\t" . $info['type'] . ",\r\n\t\t\t" . $info['state'] . "\r\n\t\t)"; $this->db->query($sql); $info['id'] = $this->db->insert_id(); $info['user'] = $this->mVideo->getUserById($info['user_id']); unset($info['user_id']); switch ($info['type']) { case 0: $sql = "UPDATE " . DB_PREFIX . "video SET comment_count= comment_count+1 \r\n\t\t\t\t\tWHERE id=" . $info['cid']; $this->db->query($sql); break; case 1: $sql = "UPDATE " . DB_PREFIX . "network_station SET comment_count= comment_count+1 \r\n\t\t\t\t\tWHERE id=" . $info['cid']; $this->db->query($sql); break; case 2: $sql = "UPDATE " . DB_PREFIX . "user SET comment_count= comment_count+1 \r\n\t\t\t\t\tWHERE id=" . $info['cid']; $this->db->query($sql); break; case 3: $sql = "UPDATE " . DB_PREFIX . "album SET comment_count= comment_count+1 \r\n\t\t\t\t\tWHERE id=" . $info['cid']; $this->db->query($sql); break; default: break; } $this->setXmlNode('comments', 'info'); $this->addItem($info); $this->output(); }
public function comment() { include_once ROOT_DIR . 'lib/class/settings.class.php'; $setting = new settings(); $result_setttings = $setting->getMark('mblog_comment'); if (!empty($result_setttings) && $result_setttings['state']) { $this->errorOutput('评论已关闭'); } $userinfo = $this->mUser->verify_credentials(); if (!$userinfo['id']) { $this->errorOutput(USENAME_NOLOGIN); } $id = $this->input['id']; $content = urldecode($this->input['content']); include_once ROOT_DIR . 'lib/class/banword.class.php'; $banword = new banword(); $status = 0; $banwords = $banword->banword(urlencode($content)); if ($banwords && $banwords != 'null') { $status = 1; $banwords = implode(',', $banwords); } else { $banwords = ''; } //此ID没有用处 $cid = intval($this->input['cid']); $time = time(); !$cid ? $and = '' : ($and = ' , reply_comment_id = ' . $cid); $sql = 'INSERT INTO ' . DB_PREFIX . 'status_comments SET status_id = ' . $id . ', flag = ' . $status . ',member_id = ' . $userinfo['id'] . ',content = "' . $content . '",comment_time = "' . $time . '",ip = "' . hg_getip() . '"'; $sql .= $and; $this->setXmlNode('comments', 'comment'); /** * 获取该条点滴的用户ID */ $this->curl->setSubmitType('post'); $this->curl->setReturnFormat('json'); $this->curl->addRequestData('status_id', $id); $user_id = $this->curl->request('statuses/getUserIdByStatusId.php'); /** * 获取该用户的权限 */ $this->curl->setSubmitType('post'); $this->curl->setReturnFormat('json'); $this->curl->addRequestData('id', $user_id); $tmp = $this->curl->request('users/get_authority.php'); $authority = $tmp[0]; //评论权限 $comment_authority = intval($authority[18]); /** * 获取与该用户的关系 */ $this->curl->setSubmitType('post'); $this->curl->setReturnFormat('json'); $this->curl->addRequestData('source_id', $userinfo['id']); $this->curl->addRequestData('target_id', $user_id); $relation = $this->curl->request('friendships/show.php'); //任何人可评论 if ($comment_authority == 0) { $this->db->query($sql); } //关注的人可评论 if ($comment_authority == 1) { //关注 if ($relation == 3 || $relation == 1) { $this->db->query($sql); } else { $this->errorOutput(NO_AUTHORITY); } } //任何人不可评论 if ($comment_authority == 2) { $this->errorOutput(NO_AUTHORITY); } // $this->db->query($sql); $insert_id = $this->db->insert_id(); $members = $this->mUser->getUserById($userinfo['id']); //评论者的信息数组 $members = $members[0]; //将点滴的评论次数加1 $sql_str = 'UPDATE ' . DB_PREFIX . 'status_extra SET comment_count = comment_count + 1 WHERE status_id = ' . $id; $this->db->query($sql_str); $status_info = $this->mStatus->show($id); $return_array = array('id' => $insert_id, 'text' => $content, 'create_at' => $time, 'user' => $members, 'status' => $status_info[0]); $this->addItem($return_array); $this->output(); }
/** * 验证内容,是否含有屏蔽词语,是否含有短网址 * @param $text 传入值 * @param $memberid * @param $source * @return $info array */ private function verifyUrlBanword($text, $memberid, $source) { include_once ROOT_DIR . 'lib/class/banword.class.php'; $banword = new banword(); $status = 0; $banwords = $banword->banword(urlencode($text)); if ($banwords && $banwords != 'null') { $status = 1; $banwords = implode(',', $banwords); } else { $banwords = ''; } include_once ROOT_DIR . 'lib/class/shorturl.class.php'; $shorturl = new shorturl(); $text = $shorturl->shorturl($text); /* * 在这里对是否含有媒体信息进行判断 * */ $info = array('member_id' => $memberid, 'text' => $text, 'location' => '地址', 'status' => $status, 'source' => $source, 'bans' => $banwords); return $info; }
public function deal_upload() { $userinfo = $this->mUser->verify_credentials(); if (!$userinfo) { //$this->errorOutput(LOGIN_FAILED); //用户不存在 echo '用户未登录!'; exit; } $video_path = urldecode($this->input['video_path']); //视频的在本地的目录 $file_name = urldecode($this->input['file_name']); //视频的文件 require ROOT_DIR . 'api/video/video_api.php'; //导入流媒体API $tvie_video_api = new TVie_video_api($this->config); if (!$tvie_video_api) { echo '视频上传接口初始化出错!'; exit; } if (!$_FILES['videofile']) { //$this -> errorOutput(UPLOAD_ERR_NO_FILE); //视频文件丢失 echo '视频文件丢失!'; exit; } $file_size = $this->input['file_size'] / 1024 / 1024; if (intval(substr(ini_get("upload_max_filesize"), 0, strlen($s) - 1)) < $file_size) { //$this -> errorOutput(OVER_UPLOAD_SIZE); echo '上传文件过大! '; exit; } //将视频上传到流媒体服务器 $result = $tvie_video_api->upload_video($_FILES['videofile']['tmp_name'], '', '', $file_name); $result = json_decode($result); //判断文件上传到流媒体服务器是否出错 if ($result->error_type == 1) { echo $result->errors; exit; } $return_id = $result->video_id; if ($return_id) { $sever_id = intval($return_id); //服务器上的视频ID $user_id = $userinfo['id']; //用户ID $video_name = trim(urldecode($this->input['video_name'])); //视频名称 $video_brief = trim(urldecode($this->input['video_brief'])); //视频简介 $video_tags = trim(urldecode($this->input['video_tags'])); //视频标签 $video_sort = intval($this->input['video_sort']); //视频分类 $video_copyright = intval($this->input['video_copyright']); //视频版权 $schematic = ''; $time = time(); $ip = hg_getip(); $text = $video_brief . $video_name . $video_tags; $video_tags = str_replace(",", ",", $video_tags); include_once ROOT_DIR . 'lib/class/banword.class.php'; $banword = new banword(); $status = 0; $banwords = $banword->banword(urlencode($text)); //file_put_contents('/data/web/api.hcrt.cn/uploads/d.txt', serialize($banwords)); if ($banwords && $banwords != 'null') { $status = 2; $banwords = implode(',', $banwords); } else { $banwords = ''; } $sql = "INSERT INTO " . DB_PREFIX . "video \r\n\t\t\t\t (sort_id , \r\n\t\t\t\t user_id ,\r\n\t\t\t\t serve_id , \r\n\t\t\t\t title , \r\n\t\t\t\t brief , \r\n\t\t\t\t tags , \r\n\t\t\t\t filename , \r\n\t\t\t\t copyright ,\r\n\t\t\t\t schematic , \r\n\t\t\t\t bans,\r\n\t\t\t\t state,\r\n\t\t\t\t ip , \r\n\t\t\t\t create_time ,\r\n\t\t\t\t update_time ) \r\n\t\t\t\t VALUE\r\n\t\t\t\t ({$video_sort} , \r\n\t\t\t\t\t {$user_id} ,\r\n\t\t\t\t\t {$sever_id} ,\r\n\t\t\t\t '" . $video_name . "' ,\r\n\t\t\t\t '" . $video_brief . "' , \r\n\t\t\t\t '" . $video_tags . "' ,\r\n\t\t\t\t '" . $file_name . "' , \r\n\t\t\t\t {$video_copyright} ,\r\n\t\t\t\t '" . $schematic . "' ,\r\n\t\t\t\t '" . $banwords . "' ,\r\n\t\t\t\t '" . $status . "' ,\r\n\t\t\t\t '" . $ip . "' ,\r\n\t\t\t\t {$time} ,\r\n\t\t\t\t {$time}) "; $this->db->query($sql); //获取返回的ID $video_id = $this->db->insert_id(); if (!$video_id) { echo '视频数据入库出错!'; exit; } //标签 $tags = explode(',', $video_tags); //此处标签数量有限制(最多10个) foreach ($tags as $k => $v) { $sql = "SELECT * FROM " . DB_PREFIX . "tags WHERE tagname = '" . trim($v) . "'"; $r = $this->db->query_first($sql); if ($r) { $sql = "UPDATE " . DB_PREFIX . "tags SET tag_count = tag_count + 1 WHERE tagname = '" . trim($v) . "'"; $this->db->query($sql); $sql = "REPLACE INTO " . DB_PREFIX . "video_tags SET video_id = " . $video_id . ", tag_id = " . $r['id'] . " , type = 0"; $this->db->query($sql); } else { $sql = "INSERT INTO " . DB_PREFIX . "tags SET tagname = '" . trim($v) . "' , tag_count = tag_count + 1"; $this->db->query($sql); $tag_id = $this->db->insert_id(); $sql = "INSERT INTO " . DB_PREFIX . "video_tags SET video_id = " . $video_id . ", tag_id = " . $tag_id . " , type = 0"; $this->db->query($sql); } } /** * 添加上传积分 */ $this->mUser->add_credit_log(UPLOAD_VIDEO); /** * 更新ucenter用户扩展表中的数据 */ $this->mUser->update_video_count($user_id); echo 1; } else { echo '视频未能成功上传到流媒体服务器!'; } }
/** * 增加用户 *@return array 用户信息 */ public function create() { //判断是否允许注册 $rt = $this->mUset->get_desig_uset(array('register', 'noregister', 'emailAction', 'isopeninvite')); if ($rt['result'] == 1) { $rt0 = $rt[0]; //register $rt1 = $rt[1]; //noregister $rt2 = $rt[2]; //emailAction $rt3 = $rt[3]; //isopeninvite $rt3['descripion'] = "请通过邀请进行注册!"; if (!$rt0['status']) { if (!$rt3['status']) { $this->setXmlNode('register', 'result'); $ret['register'] = 1; $ret['reason'] = $rt1['status']; $this->addItem($ret); $this->output(); } else { if (!urldecode($this->input['invite_code'])) { $this->setXmlNode('register', 'result'); $ret['register'] = 1; $ret['reason'] = $rt3['descripion']; $this->addItem($ret); $this->output(); } else { $is_invite = $this->verify_invite_code(urldecode($this->input['invite_code'])); if (!$is_invite) { $this->setXmlNode('register', 'result'); $ret['register'] = 1; $ret['reason'] = $rt3['descripion']; $this->addItem($ret); $this->output(); } } } } else { if (urldecode($this->input['invite_code'])) { $is_invite = $this->verify_invite_code(urldecode($this->input['invite_code'])); } } } if (!$this->input['username']) { $this->errorOutput(OBJECT_NULL); //返回0x0000代码 } $username = urldecode(trim($this->input['username'])); $patten = "/[!@#\$%&()><\\/:;|,,。?!}{‘’“”\\'\"]+/u"; if (preg_match($patten, $username)) { $this->errorOutput(NON_SPECIAL_CHAR); } //判断是否有禁止词 include_once ROOT_PATH . 'lib/class/banword.class.php'; $banword = new banword(); $rt = $banword->banword($username); if ($rt && $rt != 'null') { $this->setXmlNode('userinfo', 'repeat_user'); $rt['banword'] = 1; $this->addItem($rt); $this->output(); exit; } $result = $this->mUser->checkUsername($username); if ($result) { $this->setXmlNode('userinfo', 'repeat_user'); $rt['user_exist'] = 1; $rt['message'] = '用户名已被占用'; $this->addItem($rt); $this->output(); exit; } $email = trim(urldecode($this->input['email'])); if (!hg_clean_email($email)) { $this->errorOutput(EMAIL_ERROR); //返回0x2000代码 } $result = $this->mUser->checkEmail($email); if ($result) { $this->errorOutput(EMAIL_REPEAT); //返回0x2100代码 } $salt = hg_generate_salt(); $password = md5(md5(trim($this->input['password'])) . $salt); $location = trim(urldecode($this->input['location'])); $location_code = trim(urldecode($this->input['location_code'])); $avatar = trim(urldecode($this->input['avatar'])) ? trim(urldecode($this->input['avatar'])) : AVATAR_DEFAULT; //调用头像接口 $userinfo = array('email' => $email, 'username' => $username, 'password' => $password, 'salt' => $salt, 'location' => $location, 'location_code' => $location_code, 'avatar' => $avatar, 'birthday' => urldecode($this->input['birthday']), 'qq' => urldecode($this->input['qq']), 'mobile' => urldecode($this->input['mobile']), 'msn' => urldecode($this->input['msn']), 'source' => intval($this->input['source']), 'digital_tv' => urldecode($this->input['digital_tv']), 'join_time' => TIMENOW, 'last_login' => TIMENOW, 'privacy' => 0); $sql = "\r\n\t\t\tINSERT " . DB_PREFIX . "member\r\n\t\t\t(\r\n\t\t\t\temail,username,password,salt,location,location_code,\r\n\t\t\t\tbirthday,avatar,qq,mobile,msn,join_time,\r\n\t\t\t\tlast_login,digital_tv,source\r\n\t\t\t) \r\n\t\t\tVALUES\r\n\t\t\t(\r\n\t\t\t\t'" . $userinfo['email'] . "','" . $userinfo['username'] . "','" . $userinfo['password'] . "','" . $userinfo['salt'] . "',\r\n\t\t\t\t'" . $userinfo['location'] . "','" . $userinfo['location_code'] . "','" . $userinfo['birthday'] . "',\r\n\t\t\t\t'" . $userinfo['avatar'] . "','" . $userinfo['qq'] . "',\r\n\t\t\t\t'" . $userinfo['mobile'] . "',\r\n\t\t\t\t'" . $userinfo['msn'] . "'," . $userinfo['join_time'] . "," . $userinfo['last_login'] . ",'" . $userinfo['digital_tv'] . "','" . $userinfo['source'] . "'\r\n\t\t\t)"; $this->db->query($sql); $userinfo['id'] = $this->db->insert_id(); if ($is_invite) { $this->update_invite_code($userinfo['id'], urldecode($this->input['invite_code'])); } $credit_info = $this->mCredit->get_single_credit_rule(REGISTER); //获取注册积分 $credit = floatval($credit_info['credit']); $userextra = array('member_id' => $userinfo['id'], 'last_activity' => TIMENOW, 'followers_count' => 0, 'attention_count' => 0, 'ip' => hg_getip()); $sql = "INSERT " . DB_PREFIX . "member_extra\r\n\t\t(\r\n\t\t\tmember_id,\r\n\t\t\tlast_activity,\r\n\t\t\tfollowers_count,\r\n\t\t\tattention_count,\r\n\t\t\treffer_user,\r\n\t\t\tip,\r\n\t\t\tcredit \r\n\t\t) \r\n\t\tVALUES\r\n\t\t(\r\n\t\t\t" . $userextra['member_id'] . ",\r\n\t\t\t" . $userextra['last_activity'] . ",\r\n\t\t\t" . $userextra['followers_count'] . ",\r\n\t\t\t" . $userextra['attention_count'] . ",\r\n\t\t\t" . intval($this->input['reffer_user']) . ",\r\n\t\t\t'" . $userextra['ip'] . "' , \r\n\t\t\t" . $credit . "\r\n\t\t)"; $this->db->query($sql); if ($rt2['status'] == 1) { include_once ROOT_PATH . 'lib/user/email.class.php'; $emailclass = new email(); $data = array('id' => $userinfo['id'], 'username' => $userinfo['username'], 'email' => $userinfo['email']); $rt = $emailclass->send_link($data); if ($rt['done'] == 1) { $userinfo['send_email'] = 1; } else { $userinfo['send_email'] = 0; } $userinfo['email_action'] = 1; } $this->setXmlNode('userinfo', 'user'); $this->addItem($userinfo); return $this->output(); }
public function checkBanword($username) { include_once ROOT_PATH . 'lib/class/banword.class.php'; $banword = new banword(); $rt = $banword->banword($username); if ($rt && $rt != "null") { return 1; } else { return 0; } }
/** * 创建网台 * @param $web_station_name 名称 * @param $brief 简介 * @param $logo logo名称 * @return $info 网台信息 */ function create() { $mInfo = $this->mUser->verify_credentials(); if (!$mInfo) { $this->errorOutput(USENAME_NOLOGIN); } $sql = 'SELECT * FROM ' . DB_PREFIX . 'network_station WHERE user_id = ' . $mInfo['id']; $q = $this->db->query_first($sql); if ($q) { $this->input['sta_id'] = $q['id']; } else { $this->input['sta_id'] = 0; } if ($this->input['sta_id']) { $this->update(); } include_once ROOT_DIR . 'lib/class/banword.class.php'; $banword = new banword(); $status = 1; $banwords = $banword->banword($this->input['web_station_name'] . $this->input['brief'] . $this->input['tags']); $info = array('user_id' => $mInfo['id'], 'web_station_name' => urldecode($this->input['web_station_name']) ? urldecode($this->input['web_station_name']) : '', 'tags' => urldecode($this->input['tags']) ? urldecode($this->input['tags']) : '', 'brief' => urldecode($this->input['brief']) ? urldecode($this->input['brief']) : '', 'logo' => urldecode($this->input['logo']) ? urldecode($this->input['logo']) : '', 'create_time' => time(), 'update_time' => time()); if ($banwords && $banwords != 'null') { $info['web_station_name'] = str_replace($banwords, '***', $info['web_station_name']); $info['tags'] = str_replace($banwords, '***', $info['tags']); $info['brief'] = str_replace($banwords, '***', $info['brief']); } $sql = "INSERT INTO " . DB_PREFIX . "network_station(\r\n\t\t\tuser_id,\r\n\t\t\tweb_station_name,\r\n\t\t\ttags,\r\n\t\t\tbrief,\r\n\t\t\tlogo,\r\n\t\t\tcreate_time,\r\n\t\t\tupdate_time\r\n\t\t)\r\n\t\tVALUES(\r\n\t\t\t" . $info['user_id'] . ",\r\n\t\t\t'" . $info['web_station_name'] . "',\r\n\t\t\t'" . $info['tags'] . "',\r\n\t\t\t'" . $info['brief'] . "',\r\n\t\t\t'" . $info['logo'] . "',\r\n\t\t\t" . $info['create_time'] . ",\r\n\t\t\t" . $info['update_time'] . "\r\n\t\t)"; $this->db->query($sql); $info['id'] = $this->db->insert_id(); $this->tags($info['tags'], $info['id']); include_once ROOT_PATH . 'lib/user/user.class.php'; $this->mUser = new user(); $this->mUser->update_type($mInfo['id']); $this->setXmlNode('user', 'info'); $this->addItem($info); $this->output(); }