/** * 使用七牛模块 * * @param $type 0=imageView2, 1=imageMogr2 */ function getAtlasQiniuImageById($cover_id, $type = 0, $parameters) { $picture = S('picture_' . $cover_id); if (empty($picture)) { $picture = M('Picture')->where(array('status' => 1))->getById($cover_id); S('picture_' . $cover_id, $picture); } if (empty($picture)) { return getRootUrl() . 'Public/images/nopic.png'; } switch ($picture['type']) { case 'qiniu': $qiniuConfig = C('UPLOAD_QINIU_CONFIG'); if ($type == 0) { //imageView2 $parameters ? $picture['path'] = $picture['path'] . '?imageView/' . $parameters : ''; } else { //imageMogr2 $parameters ? $picture['path'] = $picture['path'] . '?imageMogr2/' . $parameters : ''; } //return $picture['path']; break; } return 'http://' . $qiniuConfig['domain'] . '/' . $picture['path']; }
/** * 根据角色获取默认头像 * @param $role_id * @param $size * @return mixed|string * @author 郑钟良<*****@*****.**> */ private function getImageUrlByRoleId($role_id, $size) { $avatar_id = S('Role_Avatar_Id_' . $role_id); if (!$avatar_id) { $map = getRoleConfigMap('avatar', $role_id); $avatar_id = D('RoleConfig')->where($map)->field('value')->find(); S('Role_Avatar_Id_' . $role_id, $avatar_id, 600); } if ($avatar_id) { if ($size != 0) { $path = getThumbImageById($avatar_id['value'], $size, $size); } else { $path = getThumbImageById($avatar_id['value']); } } else { //角色没有默认 if ($size != 0) { $default_avatar = "Public/images/default_avatar.jpg"; $path = $this->getImageUrlByPath($default_avatar, $size); } else { $path = getRootUrl() . "Public/images/default_avatar.jpg"; } } return $path; }
function getImageUrlByPath($path, $size) { $thumb = getThumbImage($path, $size); $thumb = $thumb['src']; $thumb = substr($thumb, 1); return getRootUrl() . $thumb; }
/** * @param $id * 专辑详情页 */ public function issueDetail($id) { // dump($id);exit; $aPage = I('post.page', 0, 'op_t'); $aCount = I('post.count', 5, 'op_t'); $map['id'] = array('eq', $id); $mapl['row_id'] = array('eq', $id); $issuedetail = D('Issue_content')->where($map)->select(); $issuecomment = D('Local_comment')->where(array('status' => 1, $mapl))->page($aPage, $aCount)->order('create_time desc')->select(); D('IssueContent')->where(array('id' => $id))->setInc('view_count'); //查看数加1 $support['appname'] = 'Issue'; //查找需要判断是否点赞的数据 $support['table'] = 'issue_content'; $support['uid'] = is_login(); $is_zan = D('Support')->where($support)->select(); $is_zan = array_column($is_zan, 'row'); $issue_uid = D('IssueContent')->where(array('status' => 1, 'id' => $id))->find(); //根据微博ID查找专辑发送人的UID foreach ($issuedetail as &$k) { $k['user'] = query_user(array('nickname', 'avatar32'), $k['uid']); $k['cover_url'] = getThumbImageByCoverId($k['cover_id']); //获得原图 $bi = M('Picture')->where(array('status' => 1))->getById($k['cover_id']); if (!is_bool(strpos($bi['path'], 'http://'))) { $k['cover_url'] = $bi['path']; } else { $k['cover_url'] = getRootUrl() . substr($bi['path'], 1); } if (in_array($k['id'], $is_zan)) { //判断是否已经点赞 $k['is_support'] = '1'; } else { $k['is_support'] = '0'; } if (is_administrator(get_uid()) || $issue_uid['uid'] == get_uid()) { //如果是管理员,则可以删除评论 $k['is_admin_or_mine'] = '1'; } else { $k['is_admin_or_mine'] = '0'; } } foreach ($issuecomment as &$v) { $v['user'] = query_user(array('nickname', 'avatar32'), $v['uid']); $v['cover_url'] = getThumbImageByCoverId($v['cover_id']); $v['content'] = parse_weibo_mobile_content($v['content']); } //dump($issuedetail);exit; $this->assign('issuedetail', $issuedetail); $this->assign('issuecomment', $issuecomment); $this->display(); }
/** * 站点头部钩子,加载换肤插件所需样式 * @param array $param 相关参数 * @return bool * @author 郑钟良<*****@*****.**> */ public function pageHeader($param) { $SkinsUrl = getRootUrl() . "Addons/Skin/Skins/"; $config = getAddonConfig(); if ($config['canSet'] == 0 || $config['mandatory'] == 1) { //强制执行管理员设置的默认皮肤 // 载入换肤插件默认样式 echo '<link href="' . $SkinsUrl . $config['defaultSkin'] . '/style.css" data-role="skin_link" rel="stylesheet" type="text/css"/>'; } else { //执行用户设置样式 // 载入换肤插件用户样式 $userSkin = getUserConfig(); echo '<link href="' . $SkinsUrl . $userSkin['skin'] . '/style.css" data-role="skin_link" rel="stylesheet" type="text/css"/>'; } }
/** * 根据皮肤列表,获取皮肤详细信息 * @param $skinList 皮肤列表 * @return array * @author 郑钟良<*****@*****.**> */ function getSkinInfoList($skinList) { $skinInfoList = array(); $skinUrl = getRootUrl() . preg_replace('|^' . ONETHINK_ADDON_PATH . '|', 'Addons/', SKIN_PATH); foreach ($skinList as $path) { $skinConf = (include SKIN_PATH . 'Skins/' . $path . '/config.php'); $skin['value'] = $path; $skin['name'] = $skinConf['name']; $skin['sort'] = $skinConf['sort']; $skin['thumb_url'] = $skinUrl . 'Skins/' . $path . '/thumb.png'; $skinInfoList[] = $skin; } unset($path, $skin); $skinInfoList = list_sort_by($skinInfoList, 'sort', 'asc'); return $skinInfoList; }
/** * fetchImage 渲染图片微博 * @param $weibo * @return string * @author:xjw129xjt(肖骏涛) xjt@ourstu.com */ public function fetchImage($weibo) { $weibo_data = unserialize($weibo['data']); $weibo_data['attach_ids'] = explode(',', $weibo_data['attach_ids']); foreach ($weibo_data['attach_ids'] as $k_i => $v_i) { $weibo_data['image'][$k_i]['small'] = getThumbImageById($v_i, 100, 100); $bi = M('Picture')->where(array('status' => 1))->getById($v_i); if (!is_bool(strpos($bi['path'], 'http://'))) { $weibo_data['image'][$k_i]['big'] = $bi['path']; } else { $weibo_data['image'][$k_i]['big'] = getRootUrl() . substr($bi['path'], 1); } $param['weibo'] = $weibo; $param['weibo']['weibo_data'] = $weibo_data; } $this->assign($param); return $this->fetch(T('Application://Weibo@Type/fetchimage')); }
public function fetchImage($weibo) { $weibo_data = unserialize($weibo['data']); $weibo_data['attach_ids'] = explode(',', $weibo_data['attach_ids']); foreach ($weibo_data['attach_ids'] as $k_i => $v_i) { if (strtolower(C('PICTURE_UPLOAD_DRIVER')) == 'sae') { $weibo_data['image'][$k_i]['small'] = getThumbImageById($v_i, 100, 100); // dump( $weibo_data['image'][$k_i]['small']);exit; $bi = M('Picture')->where(array('status' => 1))->getById($v_i); $weibo_data['image'][$k_i]['big'] = $bi['path']; } else { $weibo_data['image'][$k_i]['small'] = getThumbImageById($v_i, 100, 100); $bi = M('Picture')->where(array('status' => 1))->getById($v_i); $weibo_data['image'][$k_i]['big'] = getRootUrl() . substr($bi['path'], 1); } $param['weibo'] = $weibo; $param['weibo']['weibo_data'] = $weibo_data; } $this->assign($param); return $this->fetch('display'); }
private function _doEditQusetion() { $aId = I('post.id', 0, 'intval'); $need_audit = modC('QUESTION_NEED_AUDIT', 1, 'Question'); if ($aId) { $data['id'] = $aId; $now_data = M('Mob/Question')->getData($aId); $this->checkAuth('Question/Index/edit', $now_data['uid'], '没有编辑该问题权限!'); if ($need_audit) { $data['status'] = 2; } $this->checkActionLimit('edit_question', 'question', $now_data['id'], get_uid()); } else { $this->checkAuth('Question/Index/add', -1, '没有发布问题的权限!'); $this->checkActionLimit('add_question', 'question', 0, get_uid()); $data['uid'] = get_uid(); $data['answer_num'] = $data['good_question'] = 0; if ($need_audit) { $data['status'] = 2; } else { $data['status'] = 1; } } $data['title'] = I('post.title', '', 'text'); $data['category'] = I('post.category', 0, 'intval'); $attach_ids = I('post.attach_ids', '0', 'op_t'); if ($attach_ids) { $data['description'] = I('post.description', '', 'filter_content'); $img_ids = explode(',', $attach_ids); //把图片和内容结合 // dump($img_ids); foreach ($img_ids as &$v) { $v = D('Picture')->where(array('status' => 1))->getById($v); if (!is_bool(strpos($v['path'], 'http://'))) { $v = $v['path']; } else { $v = getRootUrl() . substr($v['path'], 1); } $v = '<p><img src="' . $v . '" style=""/></p><br>'; } $img_ids = implode('', $img_ids); // dump($img_ids); $data['description'] = $img_ids . $data['description']; $contentHandler = new ContentHandlerModel(); $data['description'] = $contentHandler->filterHtmlContent($data['description']); //把图片和内容结合END } else { $data['description'] = I('post.description', '', 'filter_content'); } if (!mb_strlen($data['title'], 'utf-8')) { $this->error('标题不能为空!'); } $res = M('Mob/Question')->editData($data); $title = $aId ? "编辑" : "提"; if ($res) { if (!$aId) { $aId = $res; if ($need_audit) { $data['status'] = 1; $data['info'] = $title . '问题成功!' . ' 请等待审核~'; $this->ajaxReturn($data); } } if (M('Common/Module')->isInstalled('Weibo')) { //安装了轻博客模块 //同步到轻博客 $postUrl = "http://{$_SERVER['HTTP_HOST']}" . U('Mob/Question/questionDetail', array('id' => $aId)); $weiboModel = M('Mob/Weibo'); $weiboModel->addWeibo("我问了一个问题【" . $data['title'] . "】:" . $postUrl); } $data['status'] = 1; $data['info'] = $title . '问题成功!' . ' 请等待审核~'; } else { $data['status'] = 0; $data['info'] = $title . '问题失败!'; } $this->ajaxReturn($data); }
public function doSendBlog() { $aId = I('post.id', 0, 'intval'); $data['category'] = I('post.category', 0, 'intval'); if ($aId) { $data['id'] = $aId; $now_data = M('News/News')->getData($aId); if ($now_data['status'] == 1) { $this->error('该资讯已被审核,不能被编辑!'); } $category = M('News/newsCategory')->where(array('status' => 1, 'id' => $data['category']))->find(); if ($category) { if ($category['can_post']) { if ($category['need_audit']) { $data['status'] = 2; } else { $data['status'] = 1; } } else { $this->error('该分类不能投稿!'); } } else { $this->error('该分类不存在或被禁用!'); } $data['status'] = 2; $data['template'] = $now_data['detail']['template'] ?: ''; } else { $this->checkActionLimit('add_news', 'news', 0, is_login(), true); $data['uid'] = get_uid(); $data['sort'] = $data['position'] = $data['view'] = $data['comment'] = $data['collection'] = 0; $category = M('News/NewsCategory')->where(array('status' => 1, 'id' => $data['category']))->find(); if ($category) { if ($category['can_post']) { if ($category['need_audit']) { $data['status'] = 2; } else { $data['status'] = 1; } } else { $this->error('该分类不能投稿!'); } } else { $this->error('该分类不存在或被禁用!'); } $data['template'] = ''; } $data['title'] = I('post.title', '', 'text'); $data['cover'] = I('post.one_attach_id', 0, 'intval'); $data['description'] = I('post.description', '', 'text'); $data['dead_line'] = I('post.dead_line', '', 'text'); $data['content_img'] = I('post.attach_ids', '', 'text'); if ($data['dead_line'] == '') { $data['dead_line'] = 99999999999; } else { $data['dead_line'] = strtotime($data['dead_line']); } $data['source'] = I('post.source', '', 'text'); $data['content'] = I('post.content', '', 'html'); if (!mb_strlen($data['title'], 'utf-8')) { $this->error('标题不能为空!'); } if (mb_strlen($data['content'], 'utf-8') < 20) { $this->error('内容不能少于20个字!'); } if ($data['content_img']) { $img_ids = explode(',', $data['content_img']); //把图片和内容结合 foreach ($img_ids as &$v) { $v = D('Picture')->where(array('status' => 1))->getById($v); if (!is_bool(strpos($v['path'], 'http://'))) { $v = $v['path']; } else { $v = getRootUrl() . substr($v['path'], 1); } $v = '<p><img src="' . $v . '" style=""/></p><br>'; } $img_ids = implode('', $img_ids); $data['content'] = $img_ids . $data['content']; $contentHandler = new ContentHandlerModel(); $data['content'] = $contentHandler->filterHtmlContent($data['content']); //把图片和内容结合END } // dump($data['content']);exit; $res = M('News/news')->editData($data); // dump(M('News/newsModel')->getLastSql());exit; $title = $aId ? "编辑" : "新增"; if ($res) { if (!$aId) { $aId = $res; if ($category['need_audit']) { $return['status'] = 1; $return['info'] = $title . '资讯成功!请等待审核~'; } } $return['status'] = 1; $return['info'] = $title . '资讯成功!'; } else { $return['status'] = 0; $return['info'] = $title . '资讯失败!'; } $this->ajaxReturn($return); }
function tfu_info($file) { global $use_image_magic; unset($_SESSION['TFU_LAST_UPLOADS']); $_SESSION['TFU_LAST_PREVIEW'] = fixUrl(getRootUrl() . $file); echo '&size=' . filesize($file); // we check if the image can be resized if (is_supported_tfu_image($file)) { set_error_handler('on_error_no_output'); // is needed because error are most likly but we don't care about fields we don't even know $oldsize = @getimagesize($file); set_error_handler('on_error'); if ($oldsize) { if (isMemoryOk($oldsize, "")) { echo '&hasPreview=true&tfu_x=' . $oldsize[0] . '&tfu_y=' . $oldsize[1]; // has preview! } else { echo '&hasPreview=error'; // too big! - same error massage as hasPreview=false } return; } echo '&hasPreview=false'; // no image! } if (preg_match("/.*\\.(p|P)(d|D)(f|F)\$/", $file) && $use_image_magic && file_exists(dirname(__FILE__) . '/thumbs') && is_writable(dirname(__FILE__) . '/thumbs')) { // check if pdf echo '&hasPreview=true&tfu_x=1000&tfu_y=1000'; // has preview! - pdfs are max 1000x1000'; return; } echo '&hasPreview=false'; }
public function getProfile($uid = null) { //默认查看自己的详细资料 if (!$uid) { $this->requireLogin(); $uid = $this->getUid(); } //读取数据库中的用户详细资料 $map = array('uid' => $uid); $user1 = D('Home/Member')->where($map)->find(); $user2 = D('User/UcenterMember')->where(array('id' => $uid))->find(); //获取头像信息 $avatar = new AvatarAddon(); $avatar_path = $avatar->getAvatarPath($uid); $avatar_url = getRootUrl() . $avatar->getAvatarPath($uid); //缩略头像 $avatar128_path = getThumbImage($avatar_path, 128); $avatar128_path = '/' . $avatar128_path['src']; $avatar128_url = getRootUrl() . $avatar128_path; //获取等级 $title = D('Usercenter/Title')->getTitle($user1['score']); //只返回必要的详细资料 $this->apiSuccess("获取成功", null, array('uid' => $uid, 'avatar_url' => $avatar_url, 'avatar128_url' => $avatar128_url, 'signature' => $user1['signature'], 'email' => $user2['email'], 'mobile' => $user2['mobile'], 'score' => $user1['score'], 'name' => $user1['name'], 'sex' => $this->encodeSex($user1['sex']), 'birthday' => $user1['birthday'], 'title' => $title, 'username' => $user2['username'])); }
public function addmoreWeibo() { $aPage = I('post.page', 1, 'op_t'); $aCount = I('post.count', 10, 'op_t'); $uid = I('post.uid', '', 'op_t'); $weibo = D('Weibo')->where(array('status' => 1, 'uid' => $uid))->order('create_time desc')->page($aPage, $aCount)->select(); //我关注的人的微博 $support['appname'] = 'Weibo'; //查找是否点赞 $support['table'] = 'weibo'; $support['uid'] = is_login(); $is_zan = D('Support')->where($support)->select(); $is_zan = array_column($is_zan, 'row'); foreach ($weibo as &$v) { $v['user'] = query_user(array('nickname', 'avatar64', 'space_mob_url'), $v['uid']); $v['rand_title'] = mob_get_head_title($v['uid']); $v['support'] = D('Support')->where(array('appname' => 'Weibo', 'table' => 'weibo', 'row' => $v['id']))->count(); $v['content'] = parse_weibo_mobile_content($v['content']); if (empty($v['from'])) { $v['from'] = "网站端"; } $v['data'] = unserialize($v['data']); //字符串转换成数组,获取微博源ID if ($v['data']['sourceId']) { //判断是否是源微博 $v['sourceId'] = $v['data']['sourceId']; $v['is_sourceId'] = '1'; } else { $v['sourceId'] = $v['id']; $v['is_sourceId'] = '0'; } $v['sourceId_user'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->find(); //源微博用户名 $v['sourceId_user'] = $v['sourceId_user']['uid']; $v['sourceId_user'] = query_user(array('nickname', 'space_mob_url'), $v['sourceId_user']); $v['sourceId_content'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->field('content')->find(); //源微博内容 $v['sourceId_content'] = parse_weibo_mobile_content($v['sourceId_content']['content']); //把表情显示出来。 $v['sourceId_repost_count'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->field('repost_count')->find(); //源微博转发数 $v['sourceId_from'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->field('from')->find(); //源微博来源 if (empty($v['sourceId_from']['from'])) { $v['sourceId_from'] = "网站端"; } else { $v['sourceId_from'] = "手机网页版"; } $v['sourceId_img'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->field('data')->find(); //为了获取源微图片 $v['sourceId_img'] = unserialize($v['sourceId_img']['data']); $v['sourceId_img'] = explode(',', $v['sourceId_img']['attach_ids']); //把attach_ids里的图片ID转出来 foreach ($v['sourceId_img'] as &$b) { $v['sourceId_img_path'][] = getThumbImageById($b, 100, 100); //获得缩略图 //获得原图 $bi = M('Picture')->where(array('status' => 1))->getById($b); if (!is_bool(strpos($bi['path'], 'http://'))) { $v['sourceId_img_big'][] = $bi['path']; } else { $v['sourceId_img_big'][] = getRootUrl() . substr($bi['path'], 1); } } $v['cover_url'] = explode(',', $v['data']['attach_ids']); //把attach_ids里的图片ID转出来 foreach ($v['cover_url'] as &$a) { $v['img_path'][] = getThumbImageById($a, 100, 100); //获得原图 $bi = M('Picture')->where(array('status' => 1))->getById($b); if (!is_bool(strpos($bi['path'], 'http://'))) { $v['sourceId_img_big'][] = $bi['path']; } else { $v['sourceId_img_big'][] = getRootUrl() . substr($bi['path'], 1); } } if (in_array($v['id'], $is_zan)) { //判断是否已经点赞 $v['is_support'] = '1'; } else { $v['is_support'] = '0'; } if (empty($v['data']['attach_ids'])) { //判断是否是图片 $v['is_img'] = '0'; } else { $v['is_img'] = '1'; } if (empty($v['sourceId_img']['0'])) { $v['sourceId_is_img'] = '0'; } else { $v['sourceId_is_img'] = '1'; } } if ($weibo) { $data['html'] = ""; foreach ($weibo as $val) { $this->assign("vo", $val); $data['html'] .= $this->fetch("_myweibo"); $data['status'] = 1; } } else { $data['stutus'] = 0; } $this->ajaxReturn($data); }
function fixAttachUrl($url) { if (is_local()) { return str_replace('//', '/', getRootUrl() . $url); //防止双斜杠的出现 } else { return $url; } }
/** * get_pic_src 渲染图片链接 * @param $path * @return mixed * @author:xjw129xjt(肖骏涛) xjt@ourstu.com */ function get_pic_src($path) { //不存在http:// $not_http_remote = strpos($path, 'http://') === false; //不存在https:// $not_https_remote = strpos($path, 'https://') === false; if ($not_http_remote && $not_https_remote) { //本地url return str_replace('//', '/', getRootUrl() . $path); //防止双斜杠的出现 } else { //远端url return $path; } }
/** * @param $id * 专辑详情页 */ public function issueDetail($id) { // dump($id);exit; $aPage = I('post.page', 1, 'op_t'); $aCount = I('post.count', 10, 'op_t'); $this->setTopTitle('专辑详情'); $map['id'] = array('eq', $id); $mapl['row_id'] = array('eq', $id); $issuedetail = D('Issue_content')->where($map)->find(); $issuedetail['meta']['description'] = mb_substr($issuedetail['content'], 0, 50, 'UTF-8'); //取得前50个字符 $issuedetail['meta']['keywords'] = D('Issue')->where(array('id' => $issuedetail['issue_id']))->field('title')->find(); $totalCount = D('Local_comment')->where(array('status' => 1, $mapl))->count(); if ($totalCount <= $aPage * $aCount) { $pid['count'] = 0; } else { $pid['count'] = 1; } $issuecomment = D('Local_comment')->where(array('status' => 1, $mapl))->page($aPage, $aCount)->order('create_time desc')->select(); D('IssueContent')->where(array('id' => $id))->setInc('view_count'); //查看数加1 $support['appname'] = 'Issue'; //查找需要判断是否点赞的数据 $support['table'] = 'issue_content'; $support['uid'] = is_login(); $is_zan = D('Support')->where($support)->select(); $is_zan = array_column($is_zan, 'row'); $issue_uid = D('IssueContent')->where(array('status' => 1, 'id' => $id))->find(); //根据微博ID查找专辑发送人的UID $issuedetail['user'] = query_user(array('nickname', 'avatar32', 'uid'), $issuedetail['uid']); //获得原图 $bi = M('Picture')->where(array('status' => 1))->getById($issuedetail['cover_id']); if (!is_bool(strpos($bi['path'], 'http://'))) { $issuedetail['cover_url'] = $bi['path']; } else { $issuedetail['cover_url'] = getRootUrl() . substr($bi['path'], 1); } if (in_array($issuedetail['id'], $is_zan)) { //判断是否已经点赞 $issuedetail['is_support'] = '1'; } else { $issuedetail['is_support'] = '0'; } if (is_administrator(get_uid()) || $issue_uid['uid'] == get_uid()) { //如果是管理员,则可以删除评论 $issuedetail['is_admin_or_mine'] = '1'; } else { $issuedetail['is_admin_or_mine'] = '0'; } foreach ($issuecomment as &$v) { $v['user'] = query_user(array('nickname', 'avatar32', 'uid'), $v['uid']); $v['cover_url'] = getThumbImageById($v['cover_id']); $v['content'] = parse_weibo_mobile_content($v['content']); } $this->setMobTitle($issuedetail['user']['nickname'], $issuedetail['title']); $this->setMobDescription($issuedetail['meta']['description']); $this->setMobKeywords($issuedetail['title'], $issuedetail['user']['nickname'], $issuedetail['meta']['keywords']['title']); //dump($issuedetail);exit; $this->assign('issuedetail', $issuedetail); $this->assign('issuecomment', $issuecomment); $this->assign("pid", $pid); $this->display(); }
public function doAddInfo() { unset($_POST['__hash__']); $entity_id = I('post.entity_id', 0, 'intval'); $info_id = I('post.info_id', 0, 'intval'); $aOverTime = I('post.over_time', '', 'op_t'); $entity = D('cat_entity')->find($entity_id); /**权限认证**/ $can_post = CheckCanPostEntity(is_login(), $entity_id); if (!$can_post) { $this->error('对不起,您无权发布。'); } /**权限认证end*/ $info['title'] = I('post.title', '', 'op_t'); if ($info['title'] == '') { $this->error('必须输入标题'); } if (mb_strlen($info['title'], 'utf-8') > 40) { $this->error('标题过长。'); } $info['create_time'] = time(); if ($info_id != 0) { //保存逻辑 $info = D('cat_info')->find($info_id); $this->checkAuth('Cat/Index/editInfo', $info['uid'], '你没有编辑该条信息的权限!'); $this->checkActionLimit('cat_edit_info', 'cat_info', $info['id']); if ($aOverTime != '') { $info['over_time'] = strtotime($aOverTime); } $info['id'] = $info_id; $res = D('cat_info')->save($info); $rs_info = $info['id']; if ($res) { action_log('cat_edit_info', 'cat_info', $info['id']); } } else { $this->checkAuth('Cat/Index/addInfo', -1, '你没有发布信息的权限!'); $this->checkActionLimit('cat_add_info', 'cat_info'); //新增逻辑 $info['entity_id'] = $entity_id; $info['uid'] = is_login(); if ($entity['need_active'] && !is_administrator()) { $info['status'] = 2; } else { $info['status'] = 1; } if (isset($_POST['over_time'])) { $info['over_time'] = strtotime($_POST['over_time']); } $rs_info = D('cat_info')->add($info); if ($rs_info) { action_log('cat_add_info', 'cat_info'); } } $rs_data = 1; if ($rs_info != 0) { if ($info_id != 0) { $map_data['info_id'] = $info_id; D('Data')->where($map_data)->delete(); } $dataModel = D('Data'); //处理房屋的图片 if ($entity_id == 2) { $listl = array('zhaopian1' => "", 'zhaopian2' => "", 'zhaopian3' => "", 'zhaopian4' => "", 'zhaopian5' => ""); $list = $_POST; foreach ($list as $key => &$v) { $array = explode(",", $list['zhaopian']); foreach ($array as $k => $val) { $list['zhaopian' . ($k + 1)] = $val; } unset($k, $val); } unset($list['zhaopian']); $list = array_merge($listl, $list); } else { if ($entity_id == 3) { $list = $_POST; if ($list['zhaopian']) { $img_ids = explode(',', $list['zhaopian']); //把图片和内容结合 foreach ($img_ids as &$v) { $v = M('Picture')->where(array('status' => 1))->getById($v); if (!is_bool(strpos($v['path'], 'http://'))) { $v = $v['path']; } else { $v = getRootUrl() . substr($v['path'], 1); } $v = '<p><img src="' . $v . '" style=""/></p><br>'; } $img_ids = implode('', $img_ids); $list['jieshao'] = $img_ids . $list['jieshao']; $contentHandler = new ContentHandlerModel(); $list['jieshao'] = $data['content'] = $contentHandler->filterHtmlContent($list['jieshao']); //把图片和内容结合END } unset($list['zhaopian']); } else { $list = $_POST; if ($list['zhaopian']) { $img_ids = explode(',', $list['zhaopian']); //把图片和内容结合 foreach ($img_ids as &$v) { $v = M('Picture')->where(array('status' => 1))->getById($v); if (!is_bool(strpos($v['path'], 'http://'))) { $v = $v['path']; } else { $v = getRootUrl() . substr($v['path'], 1); } $v = '<p><img src="' . $v . '" style=""/></p><br>'; } $img_ids = implode('', $img_ids); $list['des'] = $img_ids . $list['des']; $contentHandler = new ContentHandlerModel(); $list['des'] = $data['content'] = $contentHandler->filterHtmlContent($list['des']); //把图片和内容结合END } unset($list['zhaopian']); } } // dump($list);exit; foreach ($list as $key => $v) { if ($key != 'entity_id' && $key != 'over_time' && $key != 'ignore' && $key != 'info_id' && $key != 'title' && $key != '__hash__' && $key != 'file') { if (is_array($v)) { $rs_data = $rs_data && $dataModel->addData($key, implode(',', $v), $rs_info, $entity_id); } else { $v = filter_content($v); $rs_data = $rs_data && $dataModel->addData($key, $v, $rs_info, $entity_id); } } if ($rs_data == 0) { $this->error($dataModel->getError()); } } if ($rs_info && $rs_data) { $this->assign('jumpUrl', U('Cat/Index/info', array('info_id' => $rs_info))); if ($entity['need_active']) { $this->success('发布成功。' . cookie('score_tip') . ' 请耐心等待管理员审核。通过审核后该信息将出现在前台页面中。'); } else { if ($entity['show_nav']) { if (D('Common/Module')->isInstalled('Weibo')) { //安装了微博模块 $postUrl = U('detail', array('info_id' => $rs_info), null, true); $weiboModel = D('Weibo'); $weiboModel->addWeibo(is_login(), "我发布了一个新的 " . $entity['alias'] . "信息 【" . $info['title'] . "】:" . $postUrl); } } $this->success('发布成功。' . cookie('score_tip')); } } } else { $this->error('发布失败。'); } }
/** * 加载更多热门微博 */ public function addMoreHotWeibo() { $aPage = I('post.page', 1, 'op_t'); $aCount = I('post.count', 10, 'op_t'); $hot_left = modC('HOT_LEFT', 3); $time_left = get_some_day($hot_left); $time_left = get_some_day($hot_left); $param['create_time'] = array('gt', $time_left); $param['status'] = 1; $param['is_top'] = 0; $weibo = D('Weibo')->where(array('status' => 1, $param))->page($aPage, $aCount)->order('comment_count desc')->select(); $support['appname'] = 'Weibo'; //查找是否点赞 $support['table'] = 'weibo'; $support['uid'] = is_login(); $is_zan = D('Support')->where($support)->select(); $is_zan = array_column($is_zan, 'row'); foreach ($weibo as &$v) { $v['user'] = query_user(array('nickname', 'avatar64', 'uid'), $v['uid']); $v['rand_title'] = mob_get_head_title($v['uid']); $v['support'] = D('Support')->where(array('appname' => 'Weibo', 'table' => 'weibo', 'row' => $v['id']))->count(); if ($v['type'] === "repost") { $v['content'] = A('Mob/WeiboType')->fetchRepost($v); } else { if ($v['type'] === "xiami" || $v['type'] == "video") { $v['content'] = Hook::exec('Addons\\Insert' . ucfirst($v['type']) . '\\Insert' . ucfirst($v['type']) . 'Addon', 'fetch' . ucfirst($v['type']), $v); } else { $v['content'] = parse_weibo_mobile_content($v['content']); } } if (empty($v['from'])) { $v['from'] = "网站端"; } $v['data'] = unserialize($v['data']); //字符串转换成数组,获取微博源ID if ($v['data']['sourceId']) { //判断是否是源微博 $v['sourceId'] = $v['data']['sourceId']; $v['is_sourceId'] = '1'; } else { $v['sourceId'] = $v['id']; $v['is_sourceId'] = '0'; } $v['sourceId_user'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->find(); //源微博用户名 $v['sourceId_user'] = $v['sourceId_user']['uid']; $v['sourceId_user'] = query_user(array('nickname', 'uid'), $v['sourceId_user']); $v['sourceId_content'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->field('content')->find(); //源微博内容 if (!is_null($v['sourceId_content'])) { $v['sourceId_content'] = parse_weibo_mobile_content($v['sourceId_content']['content']); //把表情显示出来。 } $v['sourceId_repost_count'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->field('repost_count')->find(); //源微博转发数 $v['sourceId_from'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->field('from')->find(); //源微博来源 if (empty($v['sourceId_from']['from'])) { $v['sourceId_from'] = "网站端"; } else { $v['sourceId_from'] = "手机网页版"; } $v['sourceId_img'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->field('data')->find(); //为了获取源微图片 $v['sourceId_img'] = unserialize($v['sourceId_img']['data']); $v['sourceId_img'] = explode(',', $v['sourceId_img']['attach_ids']); //把attach_ids里的图片ID转出来 foreach ($v['sourceId_img'] as &$b) { $v['sourceId_img_path'][] = getThumbImageById($b, 100, 100); //获得缩略图 //获得原图 $bi = M('Picture')->where(array('status' => 1))->getById($b); if (!is_bool(strpos($bi['path'], 'http://'))) { $v['sourceId_img_big'][] = $bi['path']; } else { $v['sourceId_img_big'][] = getRootUrl() . substr($bi['path'], 1); } } $v['cover_url'] = explode(',', $v['data']['attach_ids']); //把attach_ids里的图片ID转出来 foreach ($v['cover_url'] as &$a) { $v['img_path'][] = getThumbImageById($a, 100, 100); //获得原图 $bi = M('Picture')->where(array('status' => 1))->getById($b); if (!is_bool(strpos($bi['path'], 'http://'))) { $v['sourceId_img_big'][] = $bi['path']; } else { $v['sourceId_img_big'][] = getRootUrl() . substr($bi['path'], 1); } } if (in_array($v['id'], $is_zan)) { //判断是否已经点赞 $v['is_support'] = '1'; } else { $v['is_support'] = '0'; } if (empty($v['data']['attach_ids'])) { //判断是否是图片 $v['is_img'] = '0'; } else { $v['is_img'] = '1'; } if (empty($v['sourceId_img']['0'])) { $v['sourceId_is_img'] = '0'; } else { $v['sourceId_is_img'] = '1'; } } if ($weibo) { $data['html'] = ""; foreach ($weibo as $val) { $this->assign("vl", $val); $data['html'] .= $this->fetch("_weibolist"); $data['status'] = 1; } } else { $data['stutus'] = 0; } $this->ajaxReturn($data); }
public function getTempAvatar($uid) { //获取用户上传的临时头像 $model = $this->getAvatarModel(); $avatar = $model->getTempAvatar($uid); if ($avatar) { if (strtolower(APP_MODE) == 'sae') { return $avatar; } return getRootUrl() . "Uploads/Avatar/{$avatar}"; } return ''; }
public function uploadAvatar() { $aUid = I('get.uid', 0, 'intval'); mkdir("./Uploads/Avatar/" . $aUid); $pic_driver = C('PICTURE_UPLOAD_DRIVER'); $files = $_FILES; $setting = C('PICTURE_UPLOAD'); $driver = C('PICTURE_UPLOAD_DRIVER'); $config = C("UPLOAD_{$pic_driver}_CONFIG"); /* 上传文件 */ $setting['rootPath'] = './Uploads/Avatar/'; $setting['saveName'] = '/' . $aUid . '/original'; $setting['savepath'] = ''; $setting['subName'] = ''; $setting['replace'] = true; //sae下 if (strtolower(C('PICTURE_UPLOAD_DRIVER')) == 'sae') { // $config[] C(require_once APP_PATH . 'Common/Conf/config_sae.php'); $Upload = new \Think\Upload($setting, C('PICTURE_UPLOAD_DRIVER'), array(C('UPLOAD_SAE_CONFIG'))); $info = $Upload->upload($files); $config = C('UPLOAD_SAE_CONFIG'); if ($info) { //文件上传成功,记录文件信息 foreach ($info as $key => &$value) { $value['path'] = $config['rootPath'] . 'Avatar/' . $value['savepath'] . $value['savename']; //在模板里的url路径 } /* 设置文件保存位置 */ $this->_auto[] = array('location', 'Ftp' === $driver ? 1 : 0, self::MODEL_INSERT); } } else { $Upload = new \Think\Upload($setting, $driver, $config); $info = $Upload->upload($files); } if ($info) { //文件上传成功,不记录文件 $return['status'] = 1; if ($info['Filedata']) { $return = array_merge($info['Filedata'], $return); } if ($info['download']) { $return = array_merge($info['download'], $return); } /*适用于自动表单的图片上传方式*/ if ($info['file']) { $return['data']['file'] = $info['file']; $return['data']['file']['path'] = getRootUrl() . "Uploads/Avatar" . $info['file']['savename']; $size = getimagesize("./Uploads/Avatar/" . $info['file']['savename']); $return['data']['file']['width'] = $size[0]; $return['data']['file']['height'] = $size[1]; $return['data']['file']['time'] = time(); } } else { $return['status'] = 0; $return['info'] = $Upload->getError(); } $this->ajaxReturn($return); }
restore_split_files($_SESSION['TFU_LAST_UPLOADS']); resize_merged_files($_SESSION['TFU_LAST_UPLOADS'], $size); } // E-mail section // we only send an email for the last item of an upload cycle if ($upload_notification_email != '' && $remaining == 0) { $youremail = $upload_notification_email_from; $email = $upload_notification_email; $submailheaders = "From: {$youremail}\n"; $submailheaders .= "Reply-To: {$youremail}\n"; $submailheaders .= 'Content-Type: text/plain; charset=UTF-8'; $subject = $upload_notification_email_subject; $filestr = "\n\n"; foreach ($_SESSION['TFU_LAST_UPLOADS'] as $filename) { if ($upload_notification_use_full_path) { $filestr = $filestr . tfu_urlencode(fixUrl(getRootUrl() . $path_fix . $filename)) . "\n"; } else { $filestr = $filestr . str_replace('./', '', str_replace('../', '', $filename)) . "\n"; } } if ($filestr == "\n\n") { $filestr .= 'Please check your setup. No files where uploaded.'; } $username = isset($_SESSION['TFU_USER']) ? $_SESSION['TFU_USER'] : $_SERVER['REMOTE_ADDR']; // if we don't have a use we use the IP $mailtext = sprintf($upload_notification_email_text, $username, $filestr); @mail($email, html_entity_decode($subject), html_entity_decode($mailtext), $submailheaders); } // end of e-mail section store_temp_session(); } else {
/** * 转发功能实现 */ public function doForward() { if (!is_login()) { $this->error('请您先登录', U('Mob/index/index'), 1); } $aContent = I('post.content', '', 'op_t'); //说点什么的内容 $aType = I('post.type', '', 'op_t'); //类型 $aSoueseId = I('post.sourseId', 0, 'intval'); //获取该微博源ID $aWeiboId = I('post.weiboId', 0, 'intval'); //要转发的微博的ID $aBeComment = I('post.release', 'false', 'op_t'); //是否作为评论发布 if (empty($aContent)) { $this->error('转发内容不能为空'); } $this->checkAuth('Weibo/Index/doSendRepost', -1, '您无微博转发权限。'); $return = check_action_limit('add_weibo', 'weibo', 0, is_login(), true); if ($return && !$return['state']) { $this->error($return['info']); } $weiboModel = D('Weibo'); $feed_data = ''; $sourse = $weiboModel->getWeiboDetail($aSoueseId); $sourseweibo = $sourse['weibo']; $feed_data['sourse'] = $sourseweibo; $feed_data['sourseId'] = $aSoueseId; $new_id = send_weibo($aContent, $aType, $feed_data); //发布微博 if ($new_id) { D('weibo')->where('id=' . $aSoueseId)->setInc('repost_count'); $aWeiboId != $aSoueseId && D('weibo')->where('id=' . $aWeiboId)->setInc('repost_count'); S('weibo_' . $aWeiboId, null); S('weibo_' . $aSoueseId, null); } // 发送消息 $user = query_user(array('nickname'), is_login()); $toUid = D('weibo')->where(array('id' => $aWeiboId))->getField('uid'); D('Common/Message')->sendMessage($toUid, $user['nickname'] . '转发了您的微博!', '转发提醒', U('Weibo/Index/weiboDetail', array('id' => $new_id)), is_login(), 1); // 发布评论 if ($aBeComment == 'on') { send_comment($aWeiboId, $aContent); } //转发后的微博内容获取 $weibo = D('Weibo')->where(array('status' => 1, 'id' => $new_id))->order('create_time desc')->select(); $support['appname'] = 'Weibo'; //查找是否点赞 $support['table'] = 'weibo'; $support['uid'] = is_login(); $is_zan = D('Support')->where($support)->select(); $is_zan = array_column($is_zan, 'row'); foreach ($weibo as &$v) { $v['user'] = query_user(array('nickname', 'avatar64'), $v['uid']); $v['support'] = D('Support')->where(array('appname' => 'Weibo', 'table' => 'weibo', 'row' => $v['id']))->count(); $v['content'] = parse_weibo_mobile_content($v['content']); $v['data'] = unserialize($v['data']); //字符串转换成数组,获取微博源ID if ($v['data']['sourseId']) { //判断是否是源微博 $v['sourseId'] = $v['data']['sourseId']; $v['is_sourseId'] = '1'; } else { $v['sourseId'] = $v['id']; $v['is_sourseId'] = '0'; } $v['sourseId_user'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourseId']))->find(); //源微博用户名 $v['sourseId_user'] = $v['sourseId_user']['uid']; $v['sourseId_user'] = query_user(array('nickname'), $v['sourseId_user']); $v['sourseId_content'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourseId']))->field('content')->find(); //源微博内容 $v['sourseId_content'] = parse_weibo_mobile_content($v['sourseId_content']['content']); //把表情显示出来。 $v['sourseId_repost_count'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourseId']))->field('repost_count')->find(); //源微博转发数 $v['sourseId_img'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourseId']))->field('data')->find(); //为了获取源微图片 $v['sourseId_img'] = unserialize($v['sourseId_img']['data']); $v['sourseId_img'] = explode(',', $v['sourseId_img']['attach_ids']); //把attach_ids里的图片ID转出来 foreach ($v['sourseId_img'] as &$b) { $v['sourseId_img_path'][] = getThumbImageById($b); //获得缩略图 //获得原图 $bi = M('Picture')->where(array('status' => 1))->getById($b); if (!is_bool(strpos($bi['path'], 'http://'))) { $v['sourseId_img_big'][] = $bi['path']; } else { $v['sourseId_img_big'][] = getRootUrl() . substr($bi['path'], 1); } } $v['cover_url'] = explode(',', $v['data']['attach_ids']); //把attach_ids里的图片ID转出来 foreach ($v['cover_url'] as &$a) { $v['img_path'][] = getThumbImageById($a); //获得原图 $bi = M('Picture')->where(array('status' => 1))->getById($b); if (!is_bool(strpos($bi['path'], 'http://'))) { $v['sourseId_img_big'][] = $bi['path']; } else { $v['sourseId_img_big'][] = getRootUrl() . substr($bi['path'], 1); } } if (in_array($v['id'], $is_zan)) { //判断是否已经点赞 $v['is_support'] = '1'; } else { $v['is_support'] = '0'; } if (empty($v['data']['attach_ids'])) { //判断是否是图片 $v['is_img'] = '0'; } else { $v['is_img'] = '1'; } if (empty($v['sourseId_img']['0'])) { $v['sourseId_is_img'] = '0'; } else { $v['sourseId_is_img'] = '1'; } } if ($weibo) { $data['html'] = ""; foreach ($weibo as $val) { $this->assign("vl", $val); $data['html'] .= $this->fetch("_weibolist"); $data['status'] = 1; } } else { $data['stutus'] = 0; $data['info'] = '转发失败!'; } $this->ajaxReturn($data); }
function fixAttachUrl($url) { if (!is_sae()) { return str_replace('//', '/', getRootUrl() . substr($url, 1)); //防止双斜杠的出现 } else { return $url; } }
} $nrFiles = count($myFiles); // check restrictions like if files can be deleted or folders created or of the folder does exists $status = check_restrictions($dir, $show_root, $myFiles, $fix_utf8, $status); // we check if we have an error in the upload! if (isset($_SESSION["upload_memory_limit"]) && isset($_GET['check_upload'])) { $mem_errors = "&upload_mem_errors=" . $_SESSION["upload_memory_limit"]; unset($_SESSION["upload_memory_limit"]); } else { $mem_errors = ""; } $upload_ok = '&upload_ok=' . (isset($_SESSION["TFU_LAST_UPLOADS"]) ? count($_SESSION['TFU_LAST_UPLOADS']) : '0'); $files = implode('|', $myFiles); $dirs = $enable_folder_browsing == "true" ? implode("|", $myDirs) : ""; $dirsub = create_directory_title($dir, $hide_directory_in_title, $fix_utf8); $baseurl = "&baseurl=" . getRootUrl() . $dir . "/"; // the baseurl if ($fix_utf8 == "") { $baseurl = utf8_encode($baseurl); // the baseurl } store_temp_session(); $size = $nrFiles . " files (" . ceil($size / 1024) . "k)"; // formating of the display can be done here! echo "&files=" . $size . "|" . $files . "&dirs=" . $dirs . $status . "&dirtext=" . $dirsub . $mem_errors . $upload_ok . $baseurl; } else { // shows an error message that the expected index was not send echo '&result=index'; } } }
} ?> <?php if (in_array('RenRen', $config['type'])) { ?> <a href="<?php echo addons_url('SyncLogin://Base/login', array('type' => 'renren')); ?> " class="other_login other_login_renren"></a> <?php } ?> <?php if (in_array('Weixin', $config['type'])) { ?> <a href="<?php echo addons_url('SyncLogin://Base/login', array('type' => 'weixin')); ?> " class="other_login other_login_weixin"></a> <?php } ?> </div> <?php } ?> <link rel="stylesheet" type="text/css" href="<?php echo getRootUrl(); ?> Addons/SyncLogin/_static/css/sync.css">
public function getAvatarPath($uid, $avatarSize) { $model = D('Addons://Avatar/Avatar'); $avatar = $model->getAvatar($uid); if ($avatar) { if (is_sae()) { $avatar_path = $avatar; } else { $avatar_path = "/Uploads/Avatar/{$avatar}"; } return getImageUrlByPath($avatar_path, $avatarSize); } else { //如果没有头像,返回默认头像 if ($avatarSize != 0) { return getRootUrl() . "Addons/Avatar/default_" . $avatarSize . "_" . $avatarSize . ".png"; } else { return getRootUrl() . "Addons/Avatar/default.png"; } } }
function fixAttachUrl($url) { if (!is_sae()) { return getRootUrl() . substr($url, 1); } else { return $url; } }
resize_merged_files($_SESSION['TFU_LAST_UPLOADS'], $size); } // E-mail section // we only send an email for the last item of an upload cycle and if the e-mail plugin is not used. if ($upload_notification_email != '' && $remaining == 0 && !$email_plugin) { $submailheaders = "From: {$upload_notification_email_from}\n"; $submailheaders .= "Reply-To: {$upload_notification_email_from}\n"; $submailheaders .= "Return-Path: {$upload_notification_email_from}\n"; if ($fix_utf8 != '') { $submailheaders .= 'Content-Type: text/plain; charset=' . $fix_utf8; } $subject = fix_decoding($upload_notification_email_subject, $fix_utf8); $filestr = "\n\n"; foreach ($_SESSION['TFU_LAST_UPLOADS'] as $filename) { if ($upload_notification_use_full_path) { $filestr = $filestr . space_enc(fixUrl(getRootUrl() . $path_fix . $filename)) . "\n"; } else { $filestr = $filestr . str_replace('./', '', str_replace('../', '', $filename)) . "\n"; } } if ($filestr == "\n\n") { $filestr .= 'Please check your setup. No files where uploaded.'; } $username = isset($_SESSION['TFU_USER']) ? $_SESSION['TFU_USER'] : $_SERVER['REMOTE_ADDR']; // if we don't have a use we use the IP $mailtext = sprintf(fix_decoding($upload_notification_email_text, $fix_utf8), $username, $filestr); if (isset($_SESSION['TFU_PRE_UPLOAD_DATA'])) { $mailtext .= "\n\n" . $_SESSION['TFU_PRE_UPLOAD_DATA']; } @mail($upload_notification_email, html_entity_decode($subject), html_entity_decode($mailtext), $submailheaders); }
/** * 帖子发布跟编辑。 */ public function doEdit() { $aPostId = I('post.post_id', 0, 'intval'); $aGroupId = I('post.group_id', 0, 'intval'); $aTitle = I('post.title', '', 'text'); $aCategory = I('post.category', 0, 'intval'); $attach_ids = I('post.attach_ids', '', 'text'); if ($attach_ids) { $aContent = I('post.content', '', 'filter_content'); $img_ids = explode(',', $attach_ids); //把图片和内容结合 // dump($img_ids); foreach ($img_ids as &$v) { $v = D('Picture')->where(array('status' => 1))->getById($v); if (!is_bool(strpos($v['path'], 'http://'))) { $v = $v['path']; } else { $v = getRootUrl() . substr($v['path'], 1); } $v = '<p><img src="' . $v . '" style=""/></p><br>'; } $img_ids = implode('', $img_ids); $aContent = $img_ids . $aContent; $contentHandler = new ContentHandlerModel(); $aContent = $contentHandler->filterHtmlContent($aContent); //把图片和内容结合END } else { $aContent = I('post.content', '', 'filter_content'); } if (is_joined($aGroupId) != 1) { $this->error('您无发布帖子权限'); } //判断是不是编辑模式 $isEdit = $aPostId ? true : false; //如果是编辑模式,确认当前用户能编辑帖子 $this->requireLogin(); $this->requireGroupExists($aGroupId); if ($isEdit) { $this->requirePostExists($aPostId); $this->checkActionLimit('edit_group_post', 'GroupPost', $aPostId, is_login(), true); $this->checkAuth('Group/Index/edit', get_post_admin($aPostId), '您无编辑帖子权限'); } else { $this->checkActionLimit('add_group_post', 'GroupPost', 0, is_login(), true); $this->checkAuth('Group/Index/addPost', -1, '您无添加帖子权限'); } if (empty($aGroupId)) { $this->error('请选择帖子所在的群组'); } if (empty($aTitle)) { $this->error('请填写帖子标题'); } if (empty($aContent)) { $this->error('请填写帖子内容'); } $model = M('GroupPost'); $cover = get_pic($aContent); $cover = $cover == null ? '' : $cover; $len = modC('SUMMARY_LENGTH', 50); if ($isEdit) { $data = array('id' => $aPostId, 'title' => $aTitle, 'summary' => mb_substr(text($aContent), 0, $len, 'utf-8'), 'cover' => $cover, 'content' => $aContent, 'parse' => 0, 'group_id' => $aGroupId, 'cate_id' => $aCategory); $result = $model->editPost($data); //添加到最新动态 $dynamic['group_id'] = $aGroupId; $dynamic['uid'] = is_login(); $dynamic['type'] = 'update_post'; $dynamic['row_id'] = $aPostId; M('GroupDynamic')->addDynamic($dynamic); if (!$result) { $this->error('编辑失败:' . $model->getError()); } } else { $data = array('uid' => is_login(), 'title' => $aTitle, 'summary' => mb_substr(text($aContent), 0, $len, 'utf-8'), 'cover' => $cover, 'content' => $aContent, 'parse' => 0, 'group_id' => $aGroupId, 'cate_id' => $aCategory); $result = $model->createPost($data); if (!$result) { $this->error('发表失败。'); } $aPostId = $result; //添加到最新动态 $dynamic['group_id'] = $aGroupId; $dynamic['uid'] = is_login(); $dynamic['type'] = 'post'; $dynamic['row_id'] = $aPostId; M('GroupDynamic')->addDynamic($dynamic); //增加活跃度 M('Group')->where(array('id' => $aGroupId))->setInc('activity'); M('GroupMember')->where(array('group_id' => $aGroupId, 'uid' => is_login()))->setInc('activity'); } //实现发布帖子发布图片轻博客(公共内容) $group = M('Group')->getGroup($aGroupId); $this->sendWeibo($aPostId, $isEdit, $group); //显示成功消息 $message = $isEdit ? '编辑成功。' : '发表成功。' . cookie('score_tip'); $this->success($message, U('Group/Index/detail', array('id' => $aPostId))); }
/** * 支持的字段有 * member表中的所有字段,ucenter_member表中的所有字段 * 等级:title * 头像:avatar32 avatar64 avatar128 avatar256 avatar512 * 个人中心地址:space_url * 认证图标:icons_html * * @param $fields array|string 如果是数组,则返回数组。如果不是数组,则返回对应的值 * @param null $uid * @return array|null */ function query_user($fields, $uid = null) { //如果fields不是数组,则返回值也不是数组 if (!is_array($fields)) { $result = query_user(array($fields), $uid); return $result[$fields]; } //默认获取自己的资料 $uid = $uid ? $uid : is_login(); if (!$uid) { return null; } //查询缓存,过滤掉已缓存的字段 $cachedFields = array(); $cacheResult = array(); foreach ($fields as $field) { if (in_array($field, array('icons_html', 'title', 'score'))) { continue; } $cache = read_query_user_cache($uid, $field); if (!empty($cache)) { $cacheResult[$field] = $cache; $cachedFields[] = $field; } } //去除已经缓存的字段 $fields = array_diff($fields, $cachedFields); //获取两张用户表格中的所有字段 $homeModel = M('Member'); $ucenterModel = M('UcenterMember'); $homeFields = $homeModel->getDbFields(); $ucenterFields = $ucenterModel->getDbFields(); $homeFields = array_intersect($homeFields, $fields); $ucenterFields = array_intersect($ucenterFields, $fields); //查询需要的字段 $homeResult = array(); $ucenterResult = array(); if ($homeFields) { $homeResult = D('Home/Member')->where(array('uid' => $uid))->field($homeFields)->find(); } if ($ucenterFields) { $model = D('User/UcenterMember'); $ucenterResult = $model->where(array('id' => $uid))->field($ucenterFields)->find(); } //读取头像数据 $result = array(); //读取头像数据 if (in_array('avatar', $fields)) { $avatarModel = D('Home/Avatar'); $avatar = $avatarModel->getAvatar($uid); if ($avatar) { $result['avatar'] = $avatar; } else { $result['avatar'] = cdn('default/avatar.jpg'); } } //读取等级数据 if (in_array('title', $fields)) { $titleModel = D('Usercenter/Title'); $title = $titleModel->getTitle($uid); $result['title'] = $title; } //读取用户名拼音 if (in_array('pinyin', $fields)) { $result['pinyin'] = D('Pinyin')->pinYin($result['username']); } //获取个人中心地址 $spaceUrlResult = array(); if (in_array('space_url', $fields)) { $result['space_url'] = U('UserCenter/Index/index', array('uid' => $uid)); } //获取昵称链接 if (in_array('space_link', $fields)) { $result['space_link'] = '<a ucard="' . $uid . '" href="' . U('UserCenter/Index/index', array('uid' => $uid)) . '">' . $ucenterResult['username'] . '</a>'; } //获取用户头衔链接 if (in_array('rank_link', $fields)) { $rank_List = D('rank_user')->where('uid=' . $uid)->select(); $num = 0; foreach ($rank_List as &$val) { $rank = D('rank')->where('id=' . $val['rank_id'])->find(); $val['title'] = $rank['title']; $val['logo_url'] = getRootUrl() . D('picture')->where('id=' . $rank['logo'])->getField('path'); if ($val['is_show']) { $num = 1; } } if ($rank_List) { $rank_List[0]['num'] = $num; $result['rank_link'] = $rank_List; } else { $result['rank_link'] = array(); } } //获取用户认证图标 if (in_array('icons_html', $fields)) { //判断是否有手机图标 $static = C('TMPL_PARSE_STRING.__STATIC__'); $iconUrls = array(); $user = query_user(array('mobile'), $uid); if ($user['mobile']) { $iconUrls[] = "{$static}/oneplus/images/mobile-bind.png"; } //生成结果 $result['icons_html'] = '<span class="usercenter-verify-icon-list">'; foreach ($iconUrls as $e) { $result['icons_html'] .= "<img src=\"{$e}\" title=\"对方已绑定手机\"/>"; } $result['icons_html'] .= '</span>'; } //粉丝数、关注数、微博数 if (in_array('fans', $fields)) { $result['fans'] = D('Follow')->where('follow_who=' . $uid)->count(); } if (in_array('following', $fields)) { $result['following'] = D('Follow')->where('who_follow=' . $uid)->count(); } if (in_array('weibocount', $fields)) { $result['weibocount'] = D('Weibo')->where('uid=' . $uid)->count(); } //是否关注、是否被关注 if (in_array('is_following', $fields)) { $follow = D('Follow')->where(array('who_follow' => get_uid(), 'follow_who' => $uid))->find(); $result['is_following'] = $follow ? true : false; } if (in_array('is_followed', $fields)) { $follow = D('Follow')->where(array('who_follow' => $uid, 'follow_who' => get_uid()))->find(); $result['is_followed'] = $follow ? true : false; } //↑↑↑ 新增字段应该写在在这行注释以上 ↑↑↑ //合并结果,不包括缓存 $result = array_merge($ucenterResult, $homeResult, $spaceUrlResult, $result); //写入缓存 foreach ($result as $field => $value) { if (in_array($field, array('icons_html', 'title', 'score'))) { continue; } if (!in_array($field, array('rank_link', 'icons_html', 'space_link'))) { $value = str_replace('"', '', op_t($value)); } $result[$field] = $value; write_query_user_cache($uid, $field, str_replace('"', '', $value)); } //合并结果,包括缓存 $result = array_merge($result, $cacheResult); //返回结果 return $result; }