public function show($condition = '', $orderby = '', $limit = '') { $sql = "SELECT * FROM " . DB_PREFIX . "section WHERE 1 " . $condition . $orderby . $limit; $q = $this->db->query($sql); $info = array(); while ($r = $this->db->fetch_array($q)) { //此处根据情况做一些格式化的处理,如:date('Y-m-d',TIMENOW); $r['name'] = seekhelp_clean_value($r['name']); $info[] = $r; } return $info; }
/** * comment详情 */ public function comment_detail($id) { $info = array(); $member_ids = array(); $sql = 'SELECT * FROM ' . DB_PREFIX . 'comment WHERE 1 AND id IN(' . $id . ')'; $query = $this->db->query($sql); while ($row = $this->db->fetch_array($query)) { $member_ids[] = $row['member_id']; $row['content'] = seekhelp_clean_value(stripcslashes(urldecode($row['content']))); $info[] = $row; } if (!empty($member_ids)) { $member_ids = implode(',', $member_ids); //新旧会员处理 if (defined('SEEKHELP_NEW_MEMBER') && SEEKHELP_NEW_MEMBER) { if ($this->settings['App_members']) { $userInfor = array(); $temp_members = $this->members->get_newUserInfo_by_ids($member_ids); if ($temp_members && !empty($temp_members) && is_array($temp_members)) { foreach ($temp_members as $val) { $userInfor[$val['member_id']] = $val; } } //hg_pre($members);exit(); } } else { $userInfor = $this->get_userinfo_by_id($member_ids); } } if (!empty($info)) { foreach ($info as $key => $val) { //新旧会员处理 if (defined('SEEKHELP_NEW_MEMBER') && SEEKHELP_NEW_MEMBER) { if ($userInfor[$val['member_id']]['member_name']) { $info[$key]['member_name'] = IS_HIDE_MOBILE ? hg_hide_mobile($userInfor[$val['member_id']]['nick_name']) : $userInfor[$val['member_id']]['nick_name']; } if ($userInfor[$val['member_id']]['avatar']['host']) { $info[$key]['member_avatar'] = array('host' => $userInfor[$val['member_id']]['avatar']['host'], 'dir' => $userInfor[$val['member_id']]['avatar']['dir'], 'filepath' => $userInfor[$val['member_id']]['avatar']['filepath'], 'filename' => $userInfor[$val['member_id']]['avatar']['filename']); $info[$key]['member_level'] = intval($userInfor[$val['member_id']]['digital']); } } else { if ($userInfor[$val['member_id']]['nick_name']) { $info[$key]['member_name'] = IS_HIDE_MOBILE ? hg_hide_mobile($userInfor[$val['member_id']]['nick_name']) : $userInfor[$val['member_id']]['nick_name']; } if ($userInfor[$val['member_id']]['host']) { $info[$key]['member_avatar'] = array('host' => $userInfor[$val['member_id']]['host'], 'dir' => $userInfor[$val['member_id']]['dir'], 'filepath' => $userInfor[$val['member_id']]['filepath'], 'filename' => $userInfor[$val['member_id']]['filename']); } } } } return $info; }
/** * 创建评论 * cid * @see outerUpdateBase::create() */ public function create() { if ($this->input['app_id']) { //检查社区黑名单 $blackInfo = $this->blacklist->check_blackByappId($this->input['app_id']); if ($blackInfo && $blackInfo['deadline'] == -1) { $this->errorOutput(SEEKHELP_IS_BLACK); } } $data = array('cid' => intval($this->input['cid']), 'member_id' => intval($this->user['user_id']), 'comment_type' => trim($this->input['comment_type']), 'comment_fid' => intval($this->input['comment_fid']), 'location' => trim($this->input['location']), 'status' => 0, 'content' => $this->input['content'], 'create_time' => TIMENOW, 'ip' => $this->user['ip']); //comment_type默认值 此处兼容老社区 if (!$this->input['comment_type']) { $data['comment_type'] = 'main'; } if (defined('SEEKHELP_COMMENT_STATUS') && SEEKHELP_COMMENT_STATUS) { $data['status'] = 1; } if ($this->input['app_id'] && $data['comment_type'] == 'main') { $app_id = $this->input['app_id']; $appconfig = $this->appconfig->detail($app_id); if ($appconfig['comment_audit'] == 0) { $data['status'] = 1; } else { $data['status'] = 0; } } if (!$data['cid'] || !$data['member_id'] || !$data['content']) { $this->errorOutput(NOID); } // if(!$data['comment_type']) // { // $this->errorOutput(NO_COMMENT_TYPE); // } //会员黑名单验证 include_once ROOT_PATH . 'lib/class/members.class.php'; $obj = new members(); $res = $obj->check_blacklist($data['member_id']); if ($res[$data['member_id']]['isblack']) { //$this->addItem_withkey('error', "您的评论被屏蔽,请联系管理员!"); //$this->addItem_withkey('msg', "您的评论被屏蔽,请联系管理员!"); //$this->output(); $this->errorOutput(IS_BLACK_MEMBER); } $sql = "SELECT * FROM " . DB_PREFIX . "seekhelp WHERE id = " . $data['cid']; $seekhelp = $this->db->query_first($sql); $sort_id = $seekhelp['sort_id']; $data['sort_id'] = $sort_id; //屏蔽字验证 if ($this->settings['App_banword']) { require_once ROOT_PATH . 'lib/class/banword.class.php'; $this->banword = new banword(); $str = $data['content']; $banword = $this->banword->exists($str); if ($banword && is_array($banword)) { $banword_content = ''; foreach ($banword as $key => $val) { $banword_content .= $val['banname'] . ','; } $data['banword'] = $banword_content ? rtrim($banword_content, ',') : ''; $data['status'] = 0; } } $data['content'] = urlencode($data['content']); $ret = $this->comment->create($data); if ($ret) { if ($data['status']) { if ($data['comment_type'] == 'vice') { $sql = "SELECT * FROM " . DB_PREFIX . "comment WHERE id = " . $data['comment_fid']; $comment = $this->db->query_first($sql); $this->SetCommentNum($data['comment_type'], $ret); $this->SetTimeline($ret['id'], $comment, 'comment'); $this->SetMemberInfo($comment); } else { $this->SetCommentNum($data['comment_type'], $ret); $this->SetTimeline($ret['id'], $seekhelp, 'seekhelp'); $this->SetMemberInfo($seekhelp); } //更新会员统计 if ($data['comment_type'] == 'main') { $this->updateMemberCount($data['member_id'], 'create'); } } } if ($this->settings['App_members']) { $memberInfo = $this->members->get_newUserInfo_by_ids($data['member_id']); } $ret['member_avatar'] = $memberInfo[0]['avatar']; $ret['member_name'] = IS_HIDE_MOBILE ? hg_hide_mobile($memberInfo[0]['nick_name']) : $memberInfo[0]['nick_name']; $ret['content'] = seekhelp_clean_value(stripcslashes(urldecode($ret['content']))); $this->addItem($ret); $this->output(); }
/** * 更新版块 */ public function update() { $data = $this->get_condition(); $avatar = $this->uploadimg('avatar'); if ($avatar) { $data['avatar'] = $avatar; } if (!$data['id']) { $this->errorOutput(PARAM_WRONG); } if ($data['type']) { $data['type'] = $data['type']; } else { unset($data['type']); } $result = $this->api->update($data['id'], $data); if (!$result) { $this->errorOutput(UPDATE_FAIL); } if ($avatar) { $data['avatar'] = unserialize($data['avatar']); } else { $sectionInfo = $this->api->detail($data['id']); $data['avatar'] = unserialize($sectionInfo['avatar']); } if ($data['name']) { $data['name'] = seekhelp_clean_value($data['name']); } $this->addItem($data); $this->output(); }
public function detail($id, $member_id = 0) { $sql = 'SELECT sh.*, c.content, a.name AS account_name, a.avatar AS account_avatar, s.name AS sort_name, r.content AS reply, r.create_time AS reply_time, r.user_id AS reply_user_id FROM ' . DB_PREFIX . 'seekhelp sh LEFT JOIN ' . DB_PREFIX . 'content c ON sh.id = c.id LEFT JOIN ' . DB_PREFIX . 'account a ON sh.account_id = a.id LEFT JOIN ' . DB_PREFIX . 'sort s ON sh.sort_id = s.id LEFT JOIN ' . DB_PREFIX . 'reply r ON sh.reply_id = r.id WHERE sh.id = ' . $id; $ret = $this->db->query_first($sql); if (!$ret) { $sql = 'SELECT * FROM ' . DB_PREFIX . 'content WHERE id=' . $id . ''; $ret = $this->db->query_first($sql); } $ret['format_create_time'] = date('Y-m-d', $ret['create_time']); $ret['account_avatar'] = $ret['account_avatar'] ? unserialize($ret['account_avatar']) : ''; $ret['title'] = stripcslashes($ret['title']); $ret['content'] = seekhelp_clean_value(stripcslashes(urldecode($ret['content']))); $ret['banword'] = $ret['banword'] ? unserialize($ret['banword']) : ''; //初始化变量 $ret['is_joint'] = 0; $ret['is_attention'] = 0; $ret['comment_num'] = 0; $ret['attention_num'] = 0; $ret['joint_num'] = 0; $ret['pic'] = ''; $ret['video'] = ''; $ret['vodeo_audio'] = ''; $ret['member_name'] = ''; $ret['member_avatar'] = ''; $ret['reply_user_name'] = ''; $ret['reply_avatar'] = ''; $ret['reply_pass_time'] = ''; $ret['reply_pic'] = ''; $ret['reply_video'] = ''; $ret['reply_video_audio'] = ''; $ret['recommend_answer'] = ''; $ret['recommend_user_id'] = ''; $ret['recommend_user_name'] = ''; $ret['recommend_avatar'] = ''; $ret['recommend_time'] = ''; $ret['recommend_pass_time'] = ''; $comment_num = $this->comment_num($id); $attention_num = $this->attention_num($id); $joint_num = $this->joint_num($id); $ret['comment_num'] = $comment_num[$id] ? $comment_num[$id] : 0; $ret['attention_num'] = $attention_num[$id] ? $attention_num[$id] : 0; $ret['joint_num'] = $joint_num[$id] ? $joint_num[$id] : 0; //取系统用户 if ($ret['reply_user_id'] && $this->settings['App_auth']) { $curl = new curl($this->settings['App_auth']['host'], $this->settings['App_auth']['dir']); $curl->setSubmitType('post'); $curl->setReturnFormat('json'); $curl->initPostData(); $curl->addRequestData('a', 'getMemberById'); $curl->addRequestData('id', $ret['reply_user_id']); $userInfor = $curl->request('member.php'); //print_r($userInfor);exit(); $userInfor = $userInfor[0][0]; if ($userInfor) { $ret['reply_user_name'] = IS_HIDE_MOBILE ? hg_hide_mobile($userInfor['user_name']) : $userInfor['user_name']; $ret['reply_avatar'] = $userInfor['avatar']; } } if ($ret['is_reply']) { $ret['comment_num'] += 1; //如果有金牌回复,则评论数+1 if ($ret['reply']) { $ret['reply_pass_time'] = TIMENOW - $ret['reply_time']; } } //联名、关注状态判断 if ($member_id) { $is_joint = $this->check_is_joint($member_id, $id); $is_attention = $this->check_is_attention($member_id, $id); $ret['is_joint'] = $is_joint ? 1 : 0; $ret['is_attention'] = $is_attention ? 1 : 0; } //用户信息处理 $memberIds = array(); $memberIds[] = $ret['member_id']; if ($ret['is_recommend'] && $ret['comment_id']) { $sql = 'SELECT * FROM ' . DB_PREFIX . 'comment WHERE id = ' . $ret['comment_id'] . ' AND status = 1 AND is_recommend = 1'; $commentInfor = $this->db->query_first($sql); if ($commentInfor) { $ret['recommend_answer'] = $commentInfor['content']; $ret['recommend_user_id'] = $commentInfor['member_id']; $ret['recommend_time'] = $commentInfor['create_time']; $ret['recommend_pass_time'] = TIMENOW - $commentInfor['create_time']; $memberIds[] = $commentInfor['member_id']; } } //新旧会员处理 if (defined('SEEKHELP_NEW_MEMBER') && SEEKHELP_NEW_MEMBER) { if ($this->settings['App_members'] && !empty($memberIds)) { $memberIds = implode(',', $memberIds); $member = array(); $temp_members = $this->members->get_newUserInfo_by_ids($memberIds); if ($temp_members && !empty($temp_members) && is_array($temp_members)) { foreach ($temp_members as $val) { $member[$val['member_id']] = $val; } } } if ($member && $ret['member_id']) { $ret['member_name'] = IS_HIDE_MOBILE ? hg_hide_mobile($member[$ret['member_id']]['nick_name']) : $member[$ret['member_id']]['nick_name']; $ret['member_avatar'] = array('host' => $member[$ret['member_id']]['avatar']['host'], 'dir' => $member[$ret['member_id']]['avatar']['dir'], 'filepath' => $member[$ret['member_id']]['avatar']['filepath'], 'filename' => $member[$ret['member_id']]['avatar']['filename']); } if ($member && $ret['recommend_user_id']) { $ret['recommend_user_name'] = IS_HIDE_MOBILE ? hg_hide_mobile($member[$ret['recommend_user_id']]['member_name']) : $member[$ret['recommend_user_id']]['member_name']; $ret['recommend_avatar'] = array('host' => $member[$ret['recommend_user_id']]['avatar']['host'], 'dir' => $member[$ret['recommend_user_id']]['avatar']['dir'], 'filepath' => $member[$ret['recommend_user_id']]['avatar']['filepath'], 'filename' => $member[$ret['recommend_user_id']]['avatar']['filename']); } } else { if ($this->settings['App_member'] && !empty($memberIds)) { $memberIds = implode(',', $memberIds); $member = $this->member->getMemberByIds($memberIds); $member = $member[0]; } if ($member && $ret['member_id']) { $ret['member_name'] = IS_HIDE_MOBILE ? hg_hide_mobile($member[$ret['member_id']]['nick_name']) : $member[$ret['member_id']]['nick_name']; $ret['member_avatar'] = array('host' => $member[$ret['member_id']]['host'], 'dir' => $member[$ret['member_id']]['dir'], 'filepath' => $member[$ret['member_id']]['filepath'], 'filename' => $member[$ret['member_id']]['filename']); } if ($member && $ret['recommend_user_id']) { $ret['recommend_user_name'] = IS_HIDE_MOBILE ? hg_hide_mobile($member[$ret['recommend_user_id']]['nick_name']) : $member[$ret['recommend_user_id']]['nick_name']; $ret['recommend_avatar'] = array('host' => $member[$ret['recommend_user_id']]['host'], 'dir' => $member[$ret['recommend_user_id']]['dir'], 'filepath' => $member[$ret['recommend_user_id']]['filepath'], 'filename' => $member[$ret['recommend_user_id']]['filename']); } } //获取素材 /* if ($ret['reply_id']) { $sql = 'SELECT * FROM '.DB_PREFIX.'materials WHERE cid = '.$id.' OR rid = '.$ret['reply_id']; } else { $sql = 'SELECT * FROM '.DB_PREFIX.'materials WHERE cid = '.$id; } */ //排除异常数据 $sql = 'DELETE FROM ' . DB_PREFIX . 'materials WHERE flag = 1'; $this->db->query($sql); $sql = 'SELECT * FROM ' . DB_PREFIX . 'materials WHERE cid = ' . $id . ' ORDER BY id DESC'; $query = $this->db->query($sql); $content_materials = array(); $reply_materials = array(); $vodIds = array(); $id_original_id = array(); while ($row = $this->db->fetch_array($query)) { if ($row['mark'] == 'video') { $vodIds[] = $row['original_id']; $id_original_id[$row['original_id']] = $row['id']; } if ($row['cid'] == $id && !$row['rid']) { if ($row['mark'] == 'img') { $content_materials['pic'][] = array('id' => $row['id'], 'host' => $row['host'], 'dir' => $row['dir'], 'filepath' => $row['filepath'], 'filename' => $row['filename'], 'imgwidth' => $row['imgwidth'], 'imgheight' => $row['imgheight']); } if ($row['mark'] == 'video') { $content_materials['vodid'][] = $row['original_id']; } } if ($ret['reply_id'] && $row['rid'] == $ret['reply_id']) { if ($row['mark'] == 'img') { $reply_materials['pic'][] = array('id' => $row['id'], 'host' => $row['host'], 'dir' => $row['dir'], 'filepath' => $row['filepath'], 'filename' => $row['filename'], 'imgwidth' => $row['imgwidth'], 'imgheight' => $row['imgheight']); } if ($row['mark'] == 'video') { $reply_materials['vodid'][] = $row['original_id']; } } } if (!empty($content_materials['pic'])) { $ret['pic'] = $content_materials['pic']; } if (!empty($reply_materials['pic'])) { $ret['reply_pic'] = $reply_materials['pic']; } if (!empty($vodIds)) { $vod_ids = implode(',', $vodIds); $vodInfor = $this->livmedia->get_video($vod_ids); if ($vodInfor) { if (!empty($content_materials['vodid']) && is_array($content_materials['vodid'])) { foreach ($content_materials['vodid'] as $vodid) { if ($vodInfor[$vodid]['is_audio'] == 0) { $vodInfor[$vodid]['id'] = $id_original_id[$vodid]; $ret['video'][] = $vodInfor[$vodid]; } if ($vodInfor[$vodid]['is_audio']) { $vodInfor[$vodid]['id'] = $id_original_id[$vodid]; $ret['vodeo_audio'][] = $vodInfor[$vodid]; } } } if (!empty($reply_materials['vodid']) && is_array($reply_materials['vodid'])) { foreach ($reply_materials['vodid'] as $vodid) { if ($vodInfor[$vodid]['is_audio'] == 0) { $vodInfor[$vodid]['id'] = $id_original_id[$vodid]; $ret['reply_video'][] = $vodInfor[$vodid]; } if ($vodInfor[$vodid]['is_audio']) { $vodInfor[$vodid]['id'] = $id_original_id[$vodid]; $ret['reply_video_audio'][] = $vodInfor[$vodid]; } } } } } //输出常量 $ret['show_other_data'] = false; if (defined('SHOW_OTHER_DATA')) { $ret['show_other_data'] = SHOW_OTHER_DATA; } return $ret; }