/** * 3G办广场轮播列表 * * @author Medz Seven <*****@*****.**> **/ public function w3gSlideShow() { // # 设置页面字段 $this->pageKeyList = array('image', 'url', 'doaction'); // # 添加tab array_push($this->pageTab, array('title' => '轮播列表', 'tabHash' => 'w3gSlideShow', 'url' => U('admin/Mobile/w3gSlideShow'))); array_push($this->pageTab, array('title' => '添加轮播', 'tabHash' => 'addW3gSlideShow', 'url' => U('admin/Mobile/addW3gSlideShow'))); // # 分页获取数据,20条 $list = D('w3g_slide_show')->findPage(20); // # 加入操作按钮 foreach ($list['data'] as $key => $value) { // # 参数 $aid = $value['image']; $id = $value['id']; // # 添加图片 $value = '<a href="%s" target="_blank"><img src="%s" width="300px" height="140px"></a>'; $value = sprintf($value, getImageUrlByAttachId($aid), getImageUrlByAttachId($aid, 300, 140)); $list['data'][$key]['image'] = $value; // # 添加操作按钮 $value = '[<a href="%s">编辑</a>] - [<a href="%s">删除</a>]'; $value = sprintf($value, U('admin/Mobile/addW3gSlideShow', array('id' => $id, 'tabHash' => 'addW3gSlideShow')), U('admin/Mobile/delW3gSlideShwo', array('id' => $id))); $list['data'][$key]['doaction'] = $value; } // # 设置无选择按钮 $this->allSelected = false; // # 显示列表,并注销list变量 $this->displayList($list); unset($list); }
/** * 频道首页页面 * @return void */ public function index() { // 添加样式 $this->appCssList[] = 'channel.css'; // 获取频道分类列表 $channelCategory = model('CategoryTree')->setTable('channel_category')->getCategoryList(); $this->assign('channelCategory', $channelCategory); // 频道分类选中 $cid = intval($_GET['cid']); $categoryIds = getSubByKey($channelCategory, 'channel_category_id'); if (!in_array($cid, $categoryIds) && !empty($cid)) { $this->error('您请求的频道分类不存在'); return false; } $channelConf = model('Xdata')->get('channel_Admin:index'); if (empty($cid)) { $cid = $channelConf['default_category']; if (empty($cid)) { $cid = array_shift($categoryIds); } } $this->assign('cid', $cid); // 获取用户与频道分类的关注状态 $followStatus = model('ChannelFollow')->getFollowStatus($this->mid, $cid); $this->assign('followStatus', $followStatus); // 获取模板样式 $templete = t($_GET['tpl']); if (empty($templete) || !in_array($templete, array('load', 'list'))) { $categoryConf = model('CategoryTree')->setTable('channel_category')->getCatgoryConf($cid); $templete = empty($categoryConf) ? $channelConf['show_type'] == 1 ? 'list' : 'load' : ($categoryConf['show_type'] == 1 ? 'list' : 'load'); } $templete = 'load'; $this->assign('tpl', $templete); //获取频道信息 //广播数 $channel_count = model('Channel')->where('channel_category_id=' . $cid . ' AND status=1')->count(); $this->assign("channel_count", $channel_count); //收听人数 $channel_follower_count = model("ChannelFollow")->where('channel_category_id=' . $cid)->count(); $this->assign("channel_follower_count", $channel_follower_count); //banner,desc $channel_category = D("channelCategory")->where('channel_category_id=' . $cid)->getField('ext'); $channel_category = unserialize($channel_category); $channel_banner = getImageUrlByAttachId($channel_category['attach'], 1000); $this->assign('channel_banner', $channel_banner); $this->assign('channel_desc', $channel_category['desc']); //排序 $order = $_GET['order'] == null ? 0 : $_GET['order']; $this->assign("order", intval($order)); // 设置页面信息 $titleHash = model('CategoryTree')->setTable('channel_category')->getCategoryHash(); $title = empty($cid) ? '频道首页' : $titleHash[$cid]; $this->setTitle($title); $this->setKeywords($title); $this->setDescription(implode(',', getSubByKey($channelCategory, 'title'))); $this->display(); }
/** * 获取application幻灯数据 * * @return array * @author Medz Seven <*****@*****.**> **/ public function getSlideShow() { $list = D('application_slide')->field('`title`, `image`, `type`, `data`')->select(); foreach ($list as $key => $value) { $value['image'] = getImageUrlByAttachId($value['image']); $list[$key] = $value; } return $list; }
/** * 微吧管理首页-修改微吧信息 * @return void */ public function index() { $weiba_id = intval($_GET['weiba_id']); $this->assign('weiba_id', $weiba_id); $weiba_detail = D('weiba')->where('weiba_id=' . $weiba_id)->find(); if ($weiba_detail['logo']) { $weiba_detail['logo_url'] = getImageUrlByAttachId($weiba_detail['logo']); } $this->assign('weiba_detail', $weiba_detail); $this->display(); }
/** * 获取礼物详细 * * @request int $id 礼物ID * @return array * @author Seven Du <*****@*****.**> **/ public function getInfo() { $id = intval(Common::getInput('id')); $data = GiftModel::getInstance()->getById($id); $data['image'] && ($data['image'] = getImageUrlByAttachId($data['image'])); $data['count'] = LogModel::getInstance()->getUserCount($id); $data['info'] = preg_replace('/\\<img(.*?)src\\=\\"\\/(.*?)\\"(.*?)(\\/?)\\>/is', '<img\\1src="SITE_URL/\\2"\\3\\4>', $data['info']); $data['info'] = str_replace('SITE_URL', parse_url(SITE_URL, PHP_URL_SCHEME) . '://' . parse_url(SITE_URL, PHP_URL_HOST) . '/', $data['info']); /* # 剔除width和height和align,防止宽高溢出 */ $data['info'] = preg_replace('/(width|height|align)\\=\\"(.*?)\\"/is', '', $data['info']); return $data; }
/** * 微吧管理首页-修改微吧信息 * @return void */ public function index() { $weiba_id = intval($_GET['weiba_id']); $weiba_detail = D('weiba')->where('weiba_id=' . $weiba_id)->find(); if ($weiba_detail['logo']) { $weiba_detail['logo_url'] = getImageUrlByAttachId($weiba_detail['logo']); } $weiba_cates = D('WeibaCategory')->getAllWeibaCate(); $this->assign('weiba_cates', $weiba_cates); $this->assign('weiba_detail', $weiba_detail); $this->setTitle('基本信息 ' . $weiba_detail['weiba_name']); $this->setKeywords('基本信息 ' . $weiba_detail['weiba_name']); $this->display(); }
/** * 频道首页页面 * @return void */ public function index() { global $ts; $xdata = M('Xdata'); $tip = $xdata->getConfig('tip', 'config', 'bboard_Admin'); $big_logo = $xdata->getConfig('big_logo', 'config', 'bboard_Admin'); $this->assign('tip', $tip); $this->assign('big_logo', getImageUrlByAttachId($big_logo)); //$path=$attach['save_path'].$attach['save_name']; // dump(getImageUrlByAttachId($big_logo));exit; // 添加样式 $this->appCssList[] = 'bboard/bboard.css'; // 获取频道分类列表 $topic = D('topic')->getData(20); $this->assign('topic', $topic); $this->display(); }
/** * 渲染关注按钮模板 * @example * $data['manage_uid'] integer 用户ID * @param array $data 渲染的相关配置参数 * @return string 渲染后的模板数据 */ public function render($data) { $var = array(); $manage = D('weiba_follow')->where(array('follower_uid' => $data['manage_uid'], 'level' => array('in', array(2, 3))))->findAll(); $map['weiba_id'] = array('in', getSubByKey($manage, 'weiba_id')); $map['is_del'] = 0; $var['manageWeibaList'] = D('weiba')->where($map)->findAll(); $var['manageWeibaListCount'] = D('weiba')->where($map)->count(); foreach ($var['manageWeibaList'] as $k => $v) { $var['manageWeibaList'][$k]['logo'] = getImageUrlByAttachId($v['logo'], 50, 50); } is_array($data) && ($var = array_merge($var, $data)); // 渲染模版 $content = $this->renderFile(dirname(__FILE__) . '/manageWeibaList.html', $var); unset($var, $data); // 输出数据 return $content; }
/** * 渲染关注按钮模板 * @example * $data['follower_uid'] integer 用户ID * @param array $data 渲染的相关配置参数 * @return string 渲染后的模板数据 */ public function render($data) { $var = array(); $var['type'] = 'FollowWeibaList'; $follow = D('weiba_follow')->where('follower_uid=' . $data['follower_uid'])->findAll(); $map['weiba_id'] = array('in', getSubByKey($follow, 'weiba_id')); $map['is_del'] = 0; $var['weibaList'] = D('weiba')->where($map)->findAll(); $var['weibaListCount'] = D('weiba')->where($map)->count(); foreach ($var['weibaList'] as $k => $v) { $var['weibaList'][$k]['logo'] = getImageUrlByAttachId($v['logo'], 30, 30); } is_array($data) && ($var = array_merge($var, $data)); // 渲染模版 $content = $this->renderFile(dirname(__FILE__) . "/followWeibaList.html", $var); unset($var, $data); // 输出数据 return $content; }
/** * 默认登录页 * @return void */ public function login() { // 添加样式 $this->appCssList[] = 'login.css'; if (model('Passport')->isLogged()) { redirect($this->site['home_url']); } // 获取邮箱后缀 $registerConf = model('Xdata')->get('admin_Config:register'); $this->assign('emailSuffix', explode(',', $registerConf['email_suffix'])); $this->assign('register_type', $registerConf['register_type']); $data = model('Xdata')->get("admin_Config:seo_login"); !empty($data['title']) && $this->setTitle($data['title']); !empty($data['keywords']) && $this->setKeywords($data['keywords']); !empty($data['des']) && $this->setDescription($data['des']); $login_bg = getImageUrlByAttachId($this->site['login_bg']); // if(empty($login_bg)) // $login_bg = APP_PUBLIC_URL . '/image/login/banner.png'; $this->assign('login_bg', $login_bg); $this->display('login'); }
/** * 默认登录页 * @return void */ public function login() { // 添加样式 $this->appCssList[] = 'login.css'; if ($GLOBALS['ts']['mid'] > 0) { U('public/Index/index', '', true); } // 获取邮箱后缀 $registerConf = model('Xdata')->get('admin_Config:register'); $this->assign('emailSuffix', explode(',', $registerConf['email_suffix'])); $this->assign('register_type', $registerConf['register_type']); $data = model('Xdata')->get("admin_Config:seo_login"); !empty($data['title']) && $this->setTitle($data['title']); !empty($data['keywords']) && $this->setKeywords($data['keywords']); !empty($data['des']) && $this->setDescription($data['des']); $login_bg = getImageUrlByAttachId($this->site['login_bg']); if (empty($login_bg)) { $login_bg = APP_PUBLIC_URL . '/image/body-bg2.jpg'; } $this->assign('login_bg', $login_bg); $this->display(); }
/** * 轮播列表 * * @return void * @author Medz Seven <*****@*****.**> **/ public function index() { $this->pageKeyList = array('title', 'image', 'type', 'data', 'doAction'); array_push($this->pageTab, array('title' => '轮播列表', 'tabHash' => 'index', 'url' => U('admin/Application/index'))); array_push($this->pageTab, array('title' => '添加轮播', 'tabHash' => 'addSlide', 'url' => U('admin/Application/addSlide'))); $list = D('application_slide')->findPage(20); foreach ($list['data'] as $key => $value) { // # 参数 $aid = $value['image']; $id = $value['id']; $list['data'][$key]['type'] = $this->type[$value['type']]; // # 添加图片 $value = '<a href="%s" target="_blank"><img src="%s" width="300px" height="140px"></a>'; $value = sprintf($value, getImageUrlByAttachId($aid), getImageUrlByAttachId($aid, 300, 140)); $list['data'][$key]['image'] = $value; // # 添加操作按钮 $value = '[<a href="%s">编辑</a>] - [<a href="%s">删除</a>]'; $value = sprintf($value, U('admin/Application/addSlide', array('id' => $id, 'tabHash' => 'addSlide')), U('admin/Application/delSlide', array('id' => $id))); $list['data'][$key]['doAction'] = $value; } $this->allSelected = false; $this->displayList($list); }
public function core_display_tpl() { if (!$this->checkAvailability()) { return; } $config = $config ? $config : model('AddonData')->lget('beautifyLogin'); if (!$config['template']) { $config['template'] = 1; } if (!$config['color']) { $config['color'] = "FFFFFF"; } switch ($config['template']) { case 1: // By Zue $templateFile = dirname(dirname(__FILE__)) . '/html/zue/login.html'; break; case 2: // By Cali $templateFile = dirname(dirname(__FILE__)) . '/html/cali/login.html'; break; } $siteConf = model('Xdata')->get('admin_Config:site'); $config['login_bg'] = getImageUrlByAttachId($siteConf['login_bg']); $config['_title'] = $siteConf['site_slogan']; $config['_keywords'] = $siteConf['site_header_keywords']; $config['_description'] = $siteConf['site_header_description']; $config['site']['site_slogan'] = $siteConf['site_slogan']; $config['site']['site_name'] = $siteConf['site_name']; $config['site']['logo'] = getSiteLogo($siteConf['site_logo']); $config['site']['sys_version'] = $siteConf['sys_version']; // 获取当前Js语言包 $this->langJsList = setLangJavsScript(); $config['langJsList'] = $this->langJsList; echo fetch($templateFile, $config, $param['charset'], $param['contentType']); exit; }
public function index() { $indexList = D('weiba_post')->where('is_del=0 AND top=2')->order('is_index_time desc')->findAll(); foreach ($indexList as &$v) { $imgIds = explode(',', $_POST['imageIds']); if ($imgIds) { $v['index_img_url'] = getImageUrlByAttachId($imgIds[0]); } } $this->assign('indexList', $indexList); $order = '`top` desc,FIELD(recommend+digest,0,1,2) desc,last_reply_time desc'; $map['is_del'] = 0; $map['is_index'] = 0; $list = D('weiba_post')->where($map)->order($order)->limit(20)->select(); $this->assign('list', $list); // 推荐微吧 if (!($weibalist = S('rec_weibalist'))) { $weibalist = D('weiba')->where('is_del=0 and status=1')->order('recommend desc,follower_count desc,thread_count')->limit(4)->select(); S('rec_weibalist', $weibalist); } $this->assign('weibalist', $weibalist); //dump($indexList); $this->display(); }
/** * 微吧审核 * @return void */ public function weibaAudit() { $_REQUEST['tabHash'] = 'weibaAudit'; $this->_initWeibaListAdminMenu(); // 设置列表主键 $this->_listpk = 'weiba_id'; $this->pageButton[] = array('title' => '搜索', 'onclick' => "admin.fold('search_form')"); $this->pageButton[] = array('title' => '通过', 'onclick' => "admin.doWeibaAudit('', 1)"); $this->pageButton[] = array('title' => '驳回', 'onclick' => "admin.doWeibaAudit('', -1)"); $this->searchKey = array('weiba_name'); $this->pageKeyList = array('weiba_id', 'weiba_name', 'weiba_cate', 'info', 'uid', 'uinfo', 'live', 'ctime', 'DOACTION'); if (!empty($_POST['weiba_name'])) { $maps['weiba_name'] = array('like', '%' . t($_POST['weiba_name']) . '%'); $map['weiba_id'] = array('in', getSubByKey(D('weiba')->where($maps)->field('weiba_id')->findAll(), 'weiba_id')); } $map['status'] = 0; // 数据的格式化与listKey保持一致 $listData = D('weiba')->where($map)->order('ctime desc')->findPage(20); $weibacate = D('weiba_category')->findAll(); $cids = array(); foreach ($weibacate as $c) { $cids[$c['id']] = $c['name']; } foreach ($listData['data'] as $k => $v) { $listData['data'][$k]['weiba_name'] = '<a target="_blank" href="' . U('weiba/Index/detail', array('weiba_id' => $v['weiba_id'])) . '">' . $v['weiba_name'] . '</a>'; $listData['data'][$k]['logo'] && ($listData['data'][$k]['logo'] = '<img src="' . getImageUrlByAttachId($v['logo']) . '" width="50" height="50">'); $create_uid = model('User')->getUserInfoByUids($v['uid']); $listData['data'][$k]['uid'] = $create_uid[$v['uid']]['space_link']; $listData['data'][$k]['uinfo'] = $create_uid[$v['uid']]['group_icon']; $listData['data'][$k]['live'] = $create_uid[$v['uid']]['credit_info']['level']['name']; $listData['data'][$k]['ctime'] = friendlyDate($v['ctime']); $listData['data'][$k]['weiba_cate'] = $cids[$v['cid']]; $listData['data'][$k]['DOACTION'] = '<a href="javascript:void(0)" onclick="admin.doWeibaAudit(' . $v['weiba_id'] . ',1);">通过</a> - <a href="javascript:void(0)" onclick="admin.doWeibaAudit(' . $v['weiba_id'] . ',-1);">驳回</a>'; } $this->displayList($listData); }
/** * 执行发布帖子 * * @return void */ public function doPost() { $this->need_login(); if (!CheckPermission('weiba_normal', 'weiba_post')) { $this->error('对不起,您没有权限进行该操作!', true); } $weibaid = intval($_POST['weiba_id']); if (!$weibaid) { $this->error('请选择微吧!', true); } $weiba = D('weiba', 'weiba')->where('weiba_id=' . $weibaid)->find(); if (!CheckPermission('core_admin', 'admin_login')) { switch ($weiba['who_can_post']) { case 1: $map['weiba_id'] = $weibaid; $map['follower_uid'] = $this->mid; $res = D('weiba_follow')->where($map)->find(); if (!$res && !CheckPermission('core_admin', 'admin_login')) { $this->error('对不起,您没有发帖权限,请关注该微吧!', true); } break; case 2: $map['weiba_id'] = $weibaid; $map['level'] = array('in', '2,3'); $weiba_admin = D('weiba_follow')->where($map)->order('level desc')->field('follower_uid')->findAll(); if (!in_array($this->mid, getSubByKey($weiba_admin, 'follower_uid')) && !CheckPermission('core_admin', 'admin_login')) { $this->error('对不起,您没有发帖权限,仅限管理员发帖!', true); } break; case 3: $map['weiba_id'] = $weibaid; $map['level'] = 3; $weiba_admin = D('weiba_follow')->where($map)->order('level desc')->field('follower_uid')->find(); if ($this->mid != $weiba_admin['follower_uid'] && !CheckPermission('core_admin', 'admin_login')) { $this->error('对不起,您没有发帖权限,仅限圈主发帖!', true); } break; } } $checkContent = str_replace(' ', '', $_POST['content']); $checkContent = str_replace('<br />', '', $checkContent); $checkContent = str_replace('<p>', '', $checkContent); $checkContent = str_replace('</p>', '', $checkContent); $checkContents = preg_replace('/<img(.*?)src=/i', 'img', $checkContent); $checkContents = preg_replace('/<embed(.*?)src=/i', 'img', $checkContents); if (strlen(t($_POST['title'])) == 0) { $this->error('帖子标题不能为空', true); } if (strlen(t($checkContents)) == 0) { $this->error('帖子内容不能为空', true); } preg_match_all('/./us', t($_POST['title']), $match); if (count($match[0]) > 30) { // 汉字和字母都为一个字 $this->error('帖子标题不能超过30个字', true); } if ($_POST['attach_ids']) { $attach = explode('|', $_POST['attach_ids']); foreach ($attach as $k => $a) { if (!$a) { unset($attach[$k]); } } $attach = array_map('intval', $attach); $data['attach'] = serialize($attach); } $data['weiba_id'] = $weibaid; $data['title'] = t($_POST['title']); $data['content'] = h($_POST['content']); $data['post_uid'] = $this->mid; $data['post_time'] = time(); $data['last_reply_uid'] = $this->mid; $data['last_reply_time'] = $data['post_time']; $data['tag_id'] = intval($_POST['tag_id']); $imgIds = explode(',', $_POST['imageIds']); foreach ($imgIds as $imgId) { $imgId = intval($imgId); if ($imgId > 0) { $imgsrc = getImageUrlByAttachId($imgId); if ($imgsrc) { $data['content'] .= '<p><img src="' . $imgsrc . '" /></p>'; } } } $res = D('weiba_post')->add($data); if ($res) { refreshWeibaCount($data['weiba_id']); // D('weiba')->where('weiba_id='.$data['weiba_id'])->setInc('thread_count'); // 同步到分享 $feed_id = D('weibaPost', 'weiba')->syncToFeed($res, $data['title'], t($checkContent), $this->mid); D('weiba_post')->where('post_id=' . $res)->setField('feed_id', $feed_id); // $this->assign('jumpUrl', U('weiba/Index/postDetail',array('post_id'=>$res))); // $this->success('发布成功'); // 添加积分 model('Credit')->setUserCredit($this->mid, 'publish_topic'); $map['post_uid'] = $this->mid; $map['is_del'] = 0; $digest_count = intval(M('weiba_post')->where($map)->count()); model('UserData')->setKeyValue($this->mid, 'post_count', $digest_count); return $this->ajaxReturn($res, '发布成功', 1); } else { $this->error('发布失败', true); } }
function catCP($name) { $conf = M('Xdata')->lget('mag_Admin'); foreach ($conf as $v) { if (isset($v[$name])) { return getImageUrlByAttachId($v[$name]); } } }
/** * 获取推荐活动 * * @request int $num 获取的数量,默认5条 * @return array * @author Seven Du <*****@*****.**> **/ public function getTopEvent() { $num = Common::getInput('num'); $num or $num = 5; $data = Event::getInstance()->getRightEvent($num); foreach ($data as $key => $value) { $value['area'] = model('Area')->getAreaById($value['area']); $value['area'] = $value['area']['title']; $value['city'] = model('Area')->getAreaById($value['city']); $value['city'] = $value['city']['title']; $value['image'] = getImageUrlByAttachId($value['image']); $value['cate'] = Cate::getInstance()->getById($value['cid']); $value['cate'] = $value['cate']['name']; $data[$key] = $value; } return $data; }
/** * 用户个人主页 --using * * @param int $user_id * 用户UID * @param varchar $uname * 用户名 * @return array 状态+提示 或 用户信息 */ public function show() { $num = $_REQUEST['num']; $num = intval($num); $num or $num = 10; if (empty($this->user_id) && empty($this->data['uname'])) { $uid = $this->mid; } else { if ($this->user_id) { $uid = intval($this->user_id); } else { $uid = model('User')->where(array('uname' => $this->data['uname']))->getField('uid'); } } if ($this->mid != $uid) { $privacy = model('UserPrivacy')->getPrivacy($this->mid, $uid); if ($privacy['space'] == 1) { return array('status' => 0, 'msg' => '您没有权限进入TA的个人主页'); } } $userInfo = $this->get_user_info($uid); if (!$userInfo['uname']) { return array('status' => 0, 'msg' => '该用户不存在或已被删除'); } // $userInfo['can_'] = CheckPermission('core_normal','feed_del'); $user_info['is_admin'] = CheckPermission('core_admin', 'feed_del') ? '1' : '0'; $user_info['uid'] = $userInfo['uid']; $user_info['uname'] = $userInfo['uname']; $user_info['remark'] = $userInfo['remark']; $user_info['sex'] = $userInfo['sex'] == 1 ? '男' : '女'; $user_info['intro'] = $userInfo['intro'] ? formatEmoji(false, $userInfo['intro']) : ''; $user_info['location'] = $userInfo['location'] ? $userInfo['location'] : ''; $user_info['avatar'] = $userInfo['avatar']['avatar_big']; $user_info['experience'] = t($userInfo['user_credit']['credit']['experience']['value']); $user_info['charm'] = t($userInfo['user_credit']['credit']['charm']['value']); $user_info['weibo_count'] = t(intval($userInfo['user_data']['weibo_count'])); $user_info['follower_count'] = t(intval($userInfo['user_data']['follower_count'])); $user_info['following_count'] = t(intval($userInfo['user_data']['following_count'])); $follower = model('Follow')->where('fid=' . $user_info['uid'])->order('follow_id DESC')->field('uid')->limit($num)->findAll(); $following = model('Follow')->where('uid=' . $user_info['uid'])->order('follow_id DESC')->field('fid')->limit($num)->findAll(); $follower_arr = $following_arr = array(); foreach ($follower as $k => $v) { $follower_info = $this->get_user_info($v['uid']); $follower_arr[$k]['uid'] = $follower_info['uid']; $follower_arr[$k]['uname'] = $follower_info['uname']; $follower_arr[$k]['remark'] = $follower_info['remark']; $follower_arr[$k]['avatar'] = $follower_info['avatar']['avatar_big']; } foreach ($following as $k1 => $v1) { $following_info = $this->get_user_info($v1['fid']); $following_arr[$k1]['uid'] = $following_info['uid']; $following_arr[$k1]['uname'] = $following_info['uname']; $following_arr[$k1]['remark'] = $following_info['remark']; $following_arr[$k1]['avatar'] = $following_info['avatar']['avatar_big']; } $user_info['follower'] = $follower_arr; $user_info['following'] = $following_arr; $user_info['follow_status'] = model('Follow')->getFollowState($this->mid, $uid); $user_info['is_in_blacklist'] = t(D('user_blacklist')->where('uid=' . $this->mid . ' and fid=' . $uid)->count()); $user_info['photo_count'] = model('Attach')->where(array('is_del' => 0, 'attach_type' => 'feed_image', 'uid' => $uid))->count(); $user_info['photo'] = $this->user_photo($uid); $map['uid'] = $uid; $map['type'] = 'postvideo'; $map['is_del'] = 0; $user_info['video_count'] = M('feed')->where($map)->count(); $user_info['video'] = $this->user_video($uid); $user_info['level_src'] = $userInfo['user_credit']['level']['src']; // 用户认证图标 $groupIcon = array(); $userGroup = model('UserGroupLink')->getUserGroupData($uid); foreach ($userGroup[$uid] as $g) { $g['is_authenticate'] == 1 && ($groupArr[] = $g['user_group_name']); } $user_info['authenticate'] = empty($groupArr) ? '无' : implode(' , ', $groupArr); /* # 获取用户认证理由 */ $user_info['certInfo'] = D('user_verified')->where('verified=1 AND uid=' . $uid)->field('info')->getField('info'); /* # 获取用户封面 */ $user_info['cover'] = D('user_data')->where('`key` LIKE "application_user_cover" AND `uid` = ' . $uid)->field('value')->getField('value'); $user_info['cover'] = getImageUrlByAttachId($user_info['cover']); // 用户组 $user_group = model('UserGroupLink')->where('uid=' . $uid)->field('user_group_id')->findAll(); foreach ($user_group as $v) { $user_group_icon = D('user_group')->where('user_group_id=' . $v['user_group_id'])->getField('user_group_icon'); if ($user_group_icon != -1) { $user_info['user_group'][] = THEME_PUBLIC_URL . '/image/usergroup/' . $user_group_icon; } } // 勋章 $list = M()->query('select b.small_src from ' . C('DB_PREFIX') . 'medal_user a inner join ' . C('DB_PREFIX') . 'medal b on a.medal_id=b.id where a.uid=' . $uid . ' order by a.ctime desc limit 10'); foreach ($list as $v) { $smallsrc = explode('|', $v['small_src']); $user_info['medals'][] = $smallsrc[1]; } $user_info['gift_count'] = M('gift_user')->where($map)->count(); $user_info['gift_list'] = $gift_list; $user_info['user_credit'] = $userInfo['user_credit']; $user_info['tags'] = (array) model('Tag')->setAppName('public')->setAppTable('user')->getAppTags($uid, true); // 没登陆过智播没有usid的 直接生成一个 $live_user_mod = M('live_user_info'); if (!($usid = $live_user_mod->where(array('uid' => $userInfo['uid']))->getField('usid'))) { $live_user_info = file_get_contents(SITE_URL . '/api.php?api_version=live&mod=LiveUser&act=postUser&uid=' . $userInfo['uid']); $live_user_info = json_decode($live_user_info, true); $live_user_info['status'] == 1 && ($user_info['usid'] = $live_user_info['data']['usid']); } else { $user_info['usid'] = $usid; } //可查看自己的绑定账户 if ($uid == $this->mid) { $userAccountinfo = D('user_account')->where(array('uid' => $this->mid))->find(); if (!$userAccountinfo) { $user_info['account'] = ''; $user_info['account_type'] = 0; } else { $length = strlen($userAccountinfo['account']); $user_info['account'] = substr_replace($userAccountinfo['account'], '****', 3, $length - 3); $user_info['account_type'] = $userAccountinfo['type']; } } return $user_info; }
/** * 注册流程 - 第四步骤 */ public function step4() { // 未登录 empty($_SESSION['mid']) && $this->redirect('public/Passport/login'); $this->appCssList[] = 'login.css'; $weiba_recommend = D('weiba')->where('recommend=1 and is_del=0')->limit(8)->findAll(); foreach ($weiba_recommend as $k => $v) { $weiba_recommend[$k]['logo'] = getImageUrlByAttachId($v['logo'], 230, 296); } $this->assign('weiba_recommend', $weiba_recommend); //dump($this->_config);exit; //按推荐用户 /* $related_recommend_user = model('RelatedUser')->getRelatedUserByType(5,8); $this->assign('related_recommend_user',$related_recommend_user); //按标签 if(in_array('tag', $this->_config['interester_rule'])){ $related_tag_user = model('RelatedUser')->getRelatedUserByType(4,8); $this->assign('related_tag_user',$related_tag_user); } //按地区 if(in_array('area', $this->_config['interester_rule'])){ $related_city_user = model('RelatedUser')->getRelatedUserByType(3,8); $this->assign('related_city_user',$related_city_user); } */ $userInfo = model('User')->getUserInfo($this->mid); $location = explode(' ', $userInfo['location']); $this->assign('location', $location[0]); $this->setTitle('关注感兴趣的话题'); $this->setKeywords('关注感兴趣的话题'); $this->display(); }
/** * 用户个人主页 --using * * @param integer $user_id * 用户UID * @param varchar $uname * 用户名 * @return array 状态+提示 或 用户信息 */ public function show() { $num = $_REQUEST['num']; $num = intval($num); $num or $num = 5; if (empty($this->user_id) && empty($this->data['uname'])) { $uid = $this->mid; } else { if ($this->user_id) { $uid = intval($this->user_id); } else { $uid = model('User')->where(array('uname' => $this->data['uname']))->getField('uid'); } } if ($this->mid != $uid) { $privacy = model('UserPrivacy')->getPrivacy($this->mid, $uid); if ($privacy['space'] == 1) { return array('status' => 0, 'msg' => '您没有权限进入TA的个人主页'); } } $userInfo = $this->get_user_info($uid); if (!$userInfo['uname']) { return array('status' => 0, 'msg' => '该用户不存在或已被删除'); } // dump ( $userInfo ); $user_info['uid'] = $userInfo['uid']; $user_info['uname'] = $userInfo['uname']; $user_info['realname'] = $userInfo['realname']; $user_info['company'] = $userInfo['company']; $user_info['position'] = $userInfo['position']; $user_info['sex'] = $userInfo['sex'] == 1 ? '男' : '女'; $user_info['intro'] = $userInfo['intro'] ? $userInfo['intro'] : '暂无简介'; $user_info['location'] = $userInfo['location'] ? $userInfo['location'] : ''; $user_info['avatar'] = $userInfo['avatar']['avatar_big']; $user_info['experience'] = t($userInfo['user_credit']['credit']['experience']['value']); $user_info['charm'] = t($userInfo['user_credit']['credit']['charm']['value']); $user_info['weibo_count'] = t(intval($userInfo['user_data']['weibo_count'])); $user_info['favorite_count'] = t(intval($userInfo['user_data']['favorite_count'])); $user_info['follower_count'] = t(intval($userInfo['user_data']['follower_count'])); $user_info['following_count'] = t(intval($userInfo['user_data']['following_count'])); $user_info['realname'] = $userInfo['realname']; $user_info['honor'] = $userInfo['honor']; $follower = model('Follow')->where('fid=' . $user_info['uid'])->order('follow_id DESC')->field('uid')->limit($num)->findAll(); $following = model('Follow')->where('uid=' . $user_info['uid'])->order('follow_id DESC')->field('fid')->limit($num)->findAll(); $follower_arr = $following_arr = array(); foreach ($follower as $k => $v) { $follower_info = $this->get_user_info($v['uid']); $follower_arr[$k]['uid'] = $follower_info['uid']; $follower_arr[$k]['uname'] = $follower_info['uname']; $follower_arr[$k]['avatar'] = $follower_info['avatar']['avatar_big']; } foreach ($following as $k1 => $v1) { $following_info = $this->get_user_info($v1['fid']); $following_arr[$k1]['uid'] = $following_info['uid']; $following_arr[$k1]['uname'] = $following_info['uname']; $following_arr[$k1]['avatar'] = $following_info['avatar']['avatar_big']; } $user_info['follower'] = $follower_arr; $user_info['following'] = $following_arr; $user_info['follow_status'] = model('Follow')->getFollowState($this->mid, $uid); $user_info['is_in_blacklist'] = t(D('user_blacklist')->where('uid=' . $this->mid . ' and fid=' . $uid)->count()); $user_info['photo_count'] = model('Attach')->where(array('is_del' => 0, 'attach_type' => 'feed_image', 'uid' => $uid))->count(); $user_info['photo'] = $this->user_photo($uid); $map['uid'] = $uid; $map['type'] = 'postvideo'; $map['is_del'] = 0; $user_info['video_count'] = M('feed')->where($map)->count(); $user_info['video'] = $this->user_video($uid); $user_info['level_src'] = $userInfo['user_credit']['level']['src']; // 用户认证图标 $groupIcon = array(); $userGroup = model('UserGroupLink')->getUserGroupData($uid); foreach ($userGroup[$uid] as $g) { $g['is_authenticate'] == 1 && ($groupArr[] = $g['user_group_name']); } $user_info['authenticate'] = empty($groupArr) ? '无' : implode(' , ', $groupArr); /* # 获取用户认证理由 */ $verifiedInfo = D('user_verified')->where('verified=1 AND uid=' . $uid)->field('info,realname')->find(); $user_info['certInfo'] = $verifiedInfo['info']; //$user_info['realname'] = $verifiedInfo['realname']; /* # 获取用户封面 */ $user_info['cover'] = D('user_data')->where('`key` LIKE "application_user_cover" AND `uid` = ' . $uid)->field('value')->getField('value'); $user_info['cover'] = getImageUrlByAttachId($user_info['cover']); // 用户组 $user_group = model('UserGroupLink')->where('uid=' . $uid)->field('user_group_id')->findAll(); foreach ($user_group as $v) { $user_group_icon = D('user_group')->where('user_group_id=' . $v['user_group_id'])->getField('user_group_icon'); if ($user_group_icon != -1) { $user_info['user_group'][] = THEME_PUBLIC_URL . '/image/usergroup/' . $user_group_icon; } } // 勋章 $list = M()->query('select b.small_src from ' . C('DB_PREFIX') . 'medal_user a inner join ' . C('DB_PREFIX') . 'medal b on a.medal_id=b.id where a.uid=' . $uid . ' order by a.ctime desc limit 4'); $user_info['medals'] = array(); foreach ($list as $v) { $smallsrc = explode('|', $v['small_src']); $user_info['medals'][] = $smallsrc[1]; } // 礼品 unset($map); $map['toUserId'] = $uid; $map['status'] = 1; $gifts = M('gift_user')->field('id,fromUserId,toUserId,giftPrice,giftImg')->where($map)->limit(4)->order('id DESC')->findAll(); // giftId,giftName,giftNum, $gift_list = array(); foreach ($gifts as $k => $v) { $map3['img'] = $v['giftImg']; $gift_detail = D('gift')->where($map3)->find(); $gift_list[$k]['name'] = $gift_detail['name']; $gift_list[$k]['id'] = $v['id']; $gift_list[$k]['giftId'] = $gift_detail['id']; $gift_list[$k]['giftName'] = $gift_detail['name']; $gift_list[$k]['image'] = api('Gift')->realityImageURL($gift_detail['img']); //SITE_URL . '/apps/gift/Tpl/default/Public/gift/' . $gift_detail ['img']; // http://dev.thinksns.com/t4/apps/gift/Tpl/default/Public/gift } $user_info['gift_count'] = M('gift_user')->where($map)->count(); $user_info['gift_list'] = $gift_list; $user_info['user_credit'] = $userInfo['user_credit']; $user_info['tags'] = model('Tag')->setAppName('public')->setAppTable('user')->getAppTags($uid); // $user_info['honor']=$this->get_honor($uid); return $user_info; }
/** * index * 好友的广场 * * @access public * @return void */ public function index() { $setting = model('Xdata')->lget('square'); $map = array(); if ($setting['channel'] == '1') { //频道 $setting['channelid'] = explode(',', $setting['channelid']); $map['status'] = 1; if (!$setting['channelid']) { $list = D('Channel', 'channel')->where($map)->order('rand()')->limit(8)->findAll(); } else { $map['feed_channel_link_id'] = array('in', $setting['channelid']); $list = D('Channel', 'channel')->where($map)->order('rand()')->limit(8)->findAll(); } $feedIds = getSubByKey($list, 'feed_id'); // 获取分享信息 $feedInfo = model('Feed')->getFeeds($feedIds); $feedInfos = array(); foreach ($feedInfo as $val) { $feedInfos[$val['feed_id']] = $val; } $cmap['c.feed_id'] = array('IN', $feedIds); $categoryInfo = D()->table('`' . C('DB_PREFIX') . 'channel` AS c LEFT JOIN `' . C('DB_PREFIX') . 'channel_category` AS cc ON cc.channel_category_id = c.channel_category_id')->field('c.`feed_id`,c.`feed_channel_link_id`, c.`status`, cc.channel_category_id, cc.`title`')->where($cmap)->findAll(); $categoryInfos = array(); foreach ($categoryInfo as $val) { $categoryInfos[$val['feed_id']][] = $val; } // 组装信息 foreach ($list as &$value) { $info = @unserialize($feedInfos[$value['feed_id']]['feed_data']); $value['uid'] = $feedInfos[$value['feed_id']]['user_info']['uid']; $value['uname'] = $feedInfos[$value['feed_id']]['user_info']['uname']; $image = matchImages($feedInfos[$value['feed_id']]['body']); $value['img'] = ''; if ($feedInfos[$value['feed_id']]['type'] == 'postimage') { if ($info['attach_id']) { $value['img'] = getImageUrlByAttachId($info['attach_id'][0], 236, 177, true); } } $value['content'] = $info['body'] ? t($info['body']) : t($info['content']); $value['comment_count'] = $feedInfos[$value['feed_id']]['comment_count']; $value['digg_count'] = $feedInfos[$value['feed_id']]['digg_count']; $value['categoryInfo'] = $categoryInfos[$value['feed_id']]; } $this->assign('channel', $list); } $map = array(); if ($setting['weiba'] == '1') { $setting['weibaid'] = str_replace(",", ',', $setting['weibaid']); $setting['weibaid'] = explode(',', $setting['weibaid']); $weibaId = array(); foreach ($setting['weibaid'] as $k => $vo) { $vo = intval(trim($vo)); if ($vo > 0 && !in_array($vo, $weibaId)) { $weibaId[] = $vo; } } $weiba = M('weiba'); $map['is_del'] = 0; $map['status'] = 1; if ($weibaId) { $map['weiba_id'] = array('in', $weibaId); $order = 'field(weiba_id,' . implode(',', $weibaId) . ')'; $weiba_recommend = $weiba->where($map)->order($order)->limit(6)->select(); } if (!$weibaId || !$weiba_recommend) { $weiba_recommend = array(); } //当推荐微吧不足3 或 6 时自动补齐 $count = count($weiba_recommend); if ($count < 3 || $count > 3 && $count < 6) { if ($count != 0) { $map['weiba_id'] = array('not in', $weibaId); } elseif (isset($map['weiba_id'])) { unset($map['weiba_id']); } $order = 'recommend DESC,follower_count DESC'; $weiba->where($map)->order($order); $limit = ($count < 3 ? 3 : 6) - $count; $array = $weiba->limit($limit)->select(); $weiba_recommend = array_merge($weiba_recommend, $array); } foreach ($weiba_recommend as $k => $v) { $weiba_recommend[$k]['logo'] = getImageUrlByAttachId($v['logo']); //帖子推荐 $sql = "SELECT post_id,title FROM `" . C('DB_PREFIX') . "weiba_post` WHERE weiba_id=" . $v['weiba_id'] . " AND ( `is_del` = 0 ) ORDER BY recommend desc,recommend_time desc,post_time desc LIMIT 3"; $weiba_post = M('weiba_post')->query($sql); if ($weiba_post) { foreach ($weiba_post as $kk => $vv) { $weiba_post[$kk]['title'] = t($vv['title']); } $weiba_recommend[$k]['post'] = $weiba_post; } } $this->assign('weiba_recommend', $weiba_recommend); //精彩帖子 $maps['is_del'] = 0; //剔除不符合微吧ID $fwid = D('weiba')->where('is_del=1 OR status=0')->order($order)->select(); $fids = getSubByKey($fwid, 'weiba_id'); if ($fids) { $maps['weiba_id'] = array('not in', $fids); } //首页推荐帖子 $order = 'is_index_time desc'; $maps['is_index'] = 1; $list = D('weiba_post')->field("weiba_id,post_id,title,content,index_img")->where($maps)->order($order)->select(); //如果首页推荐帖子不够6个,获取全局置顶,吧内置顶,最新回复帖子 if (count($list) < 6) { $limit = 6 - count($list); $post_ids = getSubByKey($list, 'post_id'); $maps['post_id'] = array('not in', $post_ids); $maps['is_index'] = 0; $order = 'top desc,last_reply_time desc'; $_list = D('weiba_post')->field("post_id,title,content")->where($maps)->order($order)->limit($limit)->select(); } $weiba_hot = array_merge($list, $_list); if ($weiba_hot[0]['index_img'] != null) { //首页帖子图片换成缩略图 $index_img = model('Attach')->getAttachById($weiba_hot[0]['index_img']); $weiba_hot[0]['index_img'] = getImageUrl($index_img['save_path'] . $index_img['save_name'], '290', '100', true, false); } foreach ($weiba_hot as $key => &$value) { $value['content'] = t($value['content']); } $this->assign("weiba_hot", $weiba_hot); } else { $this->assign('weiba_recommend', ''); } if ($setting['relateduser'] == '1') { //最新认证用户 $user_recommend = model('RelatedUser')->getRelatedUserSquare(6); foreach ($user_recommend as $k => $vo) { // 用户兴趣 $tags = model('Tag')->setAppName('public')->setAppTable('user')->getAppTags($vo['userInfo']['uid']); //$user_recommend[$k]['userInfo']['tags'] = implode (',',$tags); $user_recommend[$k]['userInfo']['tags'] = $tags; } $this->assign('user_recommend', $user_recommend); //后台推荐认证用户 $setting = model('Xdata')->lget('square'); $_user_recommend_verified = D('user_verified')->where('verified=1 and uid=' . $setting['user_recommend_uid'])->find(); $setting = model('Xdata')->lget('square'); //用户数据 $_user_recommend = model("User")->getUserInfo($_user_recommend_verified['uid']); $_user_recommend['verified_info'] = $_user_recommend_verified; //用户组图标 $icon = getSubByKey($_user_recommend['user_group'], 'user_group_icon', array('user_group_id', $_user_recommend['verified_info']['usergroup_id'])); $icon = array_pop($icon); $_user_recommend['verified_info']['icon'] = basename(substr($icon, 0, strpos($icon, '.'))); $this->assign('_user_recommend', $_user_recommend); //用户分享配图 $_user_recommend_feedimages = $this->getUserAttachData($_user_recommend_verified['uid']); foreach ($_user_recommend_feedimages as $key => &$value) { $value['src'] = getImageUrl($value['savepath'], '103', '100', true, false); $value['uid'] = $_user_recommend_verified['uid']; } $this->assign('_user_recommend_feedimages', $_user_recommend_feedimages); //用户最新帖子 $pmap['post_uid'] = $_user_recommend_verified['uid']; $pmap['is_del'] = 0; $_user_recommend_posts = D('weiba_post')->field("post_id,title")->where($pmap)->limit(5)->order('post_time desc')->select(); $this->assign('_user_recommend_posts', $_user_recommend_posts); } $this->display(); }
private function login_vars($data) { //登陆配置 $data = model('Xdata')->lget('hook_login_page'); $logo = explode('|', $data['logo']['logo']); $logo[1] && ($data['logo']['logo'] = getImageUrl($logo[1])); $map['is_del'] = 0; $feedlimit = $data['feed']['feed_num'] ? $data['feed']['feed_num'] : 10; switch ($data['feed']['feed_source']) { case 2: $map['uid'] = array('in', explode(',', $data['feed']['feed_user'])); break; case 3: $users = model('UserVerified')->field('uid')->group('uid')->order('id desc')->limit($feedlimit)->findAll(); $map['uid'] = array('in', getSubByKey($users, 'uid')); break; } $feeds = model('Feed')->where($map)->order("feed_id desc")->limit($feedlimit)->field('feed_id')->findAll(); $feedids = getSubByKey($feeds, 'feed_id'); $loginlastfeed = model('Feed')->getFeeds($feedids); foreach ($loginlastfeed as &$v) { switch ($v['app']) { case 'weiba': $v['from'] = getFromClient(0, $v['app'], '微吧'); break; default: $v['from'] = getFromClient($v['from'], $v['app']); break; } } $data['loginlastfeed'] = $loginlastfeed; $limit = $data['user']['user_num'] ? $data['user']['user_num'] : 12; switch ($data['user']['user_source']) { case 1: $users = model('UserData')->where("`key`='follower_count'")->order('`value`+0 desc')->field('uid')->limit($limit)->findAll(); $uids = getSubByKey($users, 'uid'); break; case 2: $uids = explode(',', $data['user']['users']); $uids = array_slice($uids, 0, $limit); break; case 3: $users = model('UserVerified')->field('uid')->group('uid')->order('id desc')->limit($limit)->findAll(); $uids = getSubByKey($users, 'uid'); break; case 4: $feedmap['is_del'] = 0; $feedmap['is_audit'] = 1; $feedmap['is_active'] = 1; $feedmap['is_init'] = 1; $users = model('User')->where($feedmap)->field('uid')->order('ctime desc')->limit($limit)->findAll(); $uids = getSubByKey($users, 'uid'); break; } $uids = array_unique(array_filter($uids)); if ($uids) { $ulist = model('User')->getUserInfoByUids($uids); $data['userlist'] = $ulist; } $data['navilist'] = model('Navi')->getBottomNav(); $announcement = model('Xarticle')->where('type=1')->order('id desc')->limit(1)->findAll(); $data['announcement'] = $announcement; if ($data['logo']['weiba_recommend'] != 2) { $weiba_recommend = D('weiba')->order('follower_count desc')->where('recommend=1 and is_del=0')->limit(5)->findAll(); foreach ($weiba_recommend as $k => $v) { $weiba_recommend[$k]['logo'] = getImageUrlByAttachId($v['logo']); } $data['logo']['weiba_recommend_list'] = $weiba_recommend; } return $data; }
/** * 获取用户积分 * * 返回积分值的数据结构 * <code> * array( * 'score' =>array( * 'credit'=>'1', * 'alias' =>'积分', * ), * 'experience'=>array( * 'credit'=>'2', * 'alias' =>'经验', * ), * '类型' =>array( * 'credit'=>'值', * 'alias' =>'名称', * ), * ) * </code> * * @param int $uid * @return bool array */ public function getUserCredit($uid) { if (empty($uid)) { return false; } $userCredit = S('getUserCredit_' . $uid); if ($userCredit != false) { return $userCredit; } $userCreditInfo = M('credit_user')->where("uid={$uid}")->find(); // 用户积分 if (!$userCreditInfo) { $data['uid'] = $uid; M('credit_user')->add($data); // 用户积分 } foreach ($this->creditType as $v) { $userCredit['credit'][$v['name']] = array('value' => intval($userCreditInfo[$v['name']]), 'alias' => $v['alias']); } $userCredit['creditType'] = $this->getTypeList(); // 获取积分等级规则 $level = $this->getLevel(); $data = $userCredit['credit'][$this->type]['value']; foreach ($level as $k => $v) { if ($data >= $v['start'] && $data <= $v['end']) { $userCredit['level'] = $v; $userCredit['level']['level_type'] = $this->type; $userCredit['level']['nextNeed'] = $v['end'] - $data; $userCredit['level']['nextName'] = $level[$k + 1]['name']; if (is_numeric($userCredit['level']['image'])) { $userCredit['level']['src'] = getImageUrlByAttachId($userCredit['level']['image']); } else { $userCredit['level']['src'] = THEME_PUBLIC_URL . '/image/level/' . $userCredit['level']['image']; } break; } if ($data > $v['end'] && !isset($level[$k + 1])) { $userCredit['level'] = $v; $userCredit['level']['nextNeed'] = ''; $userCredit['level']['nextName'] = ''; if (is_numeric($userCredit['level']['image'])) { $userCredit['level']['src'] = getImageUrlByAttachId($userCredit['level']['image']); } else { $userCredit['level']['src'] = THEME_PUBLIC_URL . '/image/level/' . $userCredit['level']['image']; } break; } } S('getUserCredit_' . $uid, $userCredit, 604800); //缓存一周 return $userCredit; }
/** * 搜索微吧 * * @param * varchar keyword 搜索关键字 * @param * integer limit 每页显示条数 * @param * integer page 第几页 * @param * integer uid 用户UID * @return array 微吧列表 */ public function searchWeibaForApi($keyword, $limit, $page, $uid) { $limit = intval($limit); $page = intval($page); $start = ($page - 1) * $limit; $end = $limit; $map['is_del'] = 0; $where['weiba_name'] = array('like', '%' . $keyword . '%'); $where['intro'] = array('like', '%' . $keyword . '%'); $where['_logic'] = 'or'; $map['_complex'] = $where; $weibaList = D('weiba')->where($map)->limit("{$start},{$end}")->order('follower_count desc,thread_count desc')->findAll(); if ($weibaList) { foreach ($weibaList as $k => $v) { if ($v['logo']) { $weibaList[$k]['logo_url'] = getImageUrlByAttachId($v['logo']); } if (D('weiba_follow')->where('follower_uid=' . $uid . ' AND weiba_id=' . $v['weiba_id'])->find()) { $weibaList[$k]['followstate'] = 1; } else { $weibaList[$k]['followstate'] = 0; } } return $weibaList; } else { return array(); } }
/** * 微吧排行榜 * @return void */ private function _weibaOrder() { $weiba_order = D('weiba')->where('is_del=0 and status=1')->order('follower_count desc,thread_count desc')->limit(10)->findAll(); foreach ($weiba_order as $k => $v) { $weiba_order[$k]['logo'] = getImageUrlByAttachId($v['logo'], 30, 30); } $map['post_uid'] = $this->mid; $postCount = D('weiba_post')->where($map)->count(); $reply = D('weiba_reply')->where('uid=' . $this->mid)->group('post_id')->findAll(); $replyCount = count($reply); $favoriteCount = D('weiba_favorite')->where('uid=' . $this->mid)->count(); $followCount = D('weiba_follow')->where('follower_uid=' . $this->mid)->count(); $data['postCount'] = $postCount ? $postCount : 0; $data['replyCount'] = $replyCount ? $replyCount : 0; $data['favoriteCount'] = $favoriteCount ? $favoriteCount : 0; $data['followCount'] = $followCount ? $followCount : 0; $this->assign($data); //dump($weiba_order);exit; $this->assign('weiba_order', $weiba_order); }
/** * 微吧排行榜 * @return void */ private function _weibaOrder() { $weiba_order = D('weiba')->where('is_del=0')->order('follower_count desc,thread_count desc')->limit(10)->findAll(); foreach ($weiba_order as $k => $v) { $weiba_order[$k]['logo'] = getImageUrlByAttachId($v['logo']); } //dump($weiba_order);exit; $this->assign('weiba_order', $weiba_order); }
public function latelyRoomList() { $limit = floor($_GET['limit']); $limit = $limit <= 0 ? 10 : $limit; $list = model('WebMessage')->getRoomList($limit, false); $data = array(); foreach ($list as $key => $rs) { $data[$key]['room_id'] = $rs['list_id']; $data[$key]['msg_new'] = $rs['msg_new']; if ($rs['type'] == 2) { $data[$key]['title'] = '来自群消息'; if ($rs['title']) { $data[$key]['title'] = '群:' . $rs['title']; } if ($rs['logo'] > 0) { $data[$key]['src'] = getImageUrlByAttachId($rs['logo'], 50, 50); } if (!isset($data[$key]['src']) or !$data[$key]['src']) { $data[$key]['src'] = THEME_PUBLIC_URL . '/image/message/group.png'; } } else { $_uid = intval(trim(str_replace('_' . $this->mid . '_', '_', '_' . $rs['min_max'] . '_'), '_')); $_user = getUserInfo($_uid); $data[$key]['title'] = '联系人:' . $_user['uname']; $data[$key]['src'] = $_user['avatar_small']; $data[$key]['uid'] = $_uid; $data[$key]['min_max'] = $rs['min_max']; } } /* # 评论, 赞, 通知,AT */ $info = array(); /* # 评论 */ $info['comment'] = model('UserData')->where('`uid`=' . $this->mid . " AND `key`='unread_comment'")->getField('value'); /* # 赞 */ $info['digg'] = model('UserData')->where('`uid`=' . $this->mid . " AND `key`='unread_digg'")->getField('value'); /* # 通知 */ $info['notice'] = D('notify_message')->where('`uid` = ' . $this->mid . ' AND `is_read` != 1')->field('`id`')->count(); /* # At me */ $info['at'] = model('UserData')->where('`uid`=' . $this->mid . " AND `key`='unread_atme'")->getField('value'); $this->ajaxReturn($data, $info); }
/** * 获取当前用户积分 --using * * @return array 任务列表 */ function task_list() { $uid = $this->mid; $list = M('task_user')->where(' uid=' . $this->mid)->findAll(); foreach ($list as $u) { $my[$u['tid']] = $u; if ($u['status'] == 1) { if ($u['receive'] == 1) { $my[$u['tid']]['status'] = 2; // 已领取奖励 } else { $my[$u['tid']]['status'] = 1; // 已完成,未领取奖励 } } else { $my[$u['tid']]['status'] = 0; // 未完成 } } $list = M('task')->where('is_del=0')->order('task_type asc, task_level asc')->findAll(); $has_del = false; // 增加用户数据 foreach ($list as $k => $vo) { if (isset($my[$vo['id']])) { // 每日任务数据初始化 $time = strtotime(date('Ymd')); if ($vo['task_type'] == 1 && $my[$vo['id']]['ctime'] < $time && $has_del == false) { // 删除历史 $dmap['task_type'] = 1; $dmap['uid'] = $uid; M('task_user')->where($dmap)->delete(); $has_del = true; $list[$k]['status'] = 0; } else { $list[$k]['status'] = $my[$vo['id']]['status']; } } else { $list[$k]['status'] = 0; // 每日任务数据初始化 if ($vo['task_type'] == 1 && $has_del == false) { // 删除历史 $dmap['task_type'] = 1; $dmap['uid'] = $uid; M('task_user')->where($dmap)->delete(); $has_del = true; } // 初始化新的数据 $udata['uid'] = $uid; $udata['tid'] = $vo['id']; $udata['task_level'] = $vo['task_level']; $udata['task_type'] = $vo['task_type']; $udata['ctime'] = $_SERVER['REQUEST_TIME']; $udata['status'] = 0; $udata['desc'] = ''; $udata['receview'] = 0; // 加入任务表 M('task_user')->add($udata); } } // 更新未完成的任务 $userdata = model('UserData')->getUserData($uid); $model = model('Task'); foreach ($list as $k => $t) { if ($t['status'] != 0) { continue; } $condition = json_decode($t['condition']); $conkey = key($condition); // 判断任务是否完成 $res = $model->_executeTask($conkey, $condition->{$conkey}, $uid, $t['task_type'], $userdata); $list[$k]['conkey'] = array_shift(array_keys((array) json_decode($t['condition']))); $list[$k]['progress_rate'] = $model->getAmountHash($list[$k]['conkey']); if ($res) { // 刷新用户任务执行状态 M('task_user')->setField('status', 1, 'tid=' . $t['id'] . ' and uid=' . $uid); $list[$k]['status'] = 1; } } // dump($list); $task_list = array(); foreach ($list as $vo) { $key = $vo['task_type'] . $vo['task_level']; $task_list[$key]['title'] = $vo['task_name']; $task_list[$key]['task_type'] = $vo['task_type']; $task_list[$key]['task_level'] = $vo['task_level']; $task['task_id'] = $vo['id']; $task['task_name'] = $vo['step_name']; $task['step_desc'] = $vo['step_desc']; $score = json_decode($vo['reward'], true); $task['reward'] = $score['score']; $task['status'] = $vo['status']; $task['conkey'] = $vo['conkey']; $task['progress_rate'] = empty($vo['progress_rate']) ? '0 / 1' : $vo['progress_rate']; $score['medal'] = (array) $score['medal']; if (!empty($vo['headface'])) { $attach = explode('|', $vo['headface']); // $task ['img'] = getImageUrl ( $attach [1] ); $task['img'] = (string) getImageUrlByAttachId($attach[0]); } else { $task['img'] = ''; } $task_list[$key]['list'][] = $task; } $res = array(); foreach ($task_list as $k => $v) { $count = $num = 0; foreach ($v['list'] as $vv) { $num += $vv['status'] > 0 ? 1 : 0; $num2 += $vv['status'] == 2 ? 1 : 0; $count += 1; } $v['receive'] = 0; // 未领取完 $v['status'] = 0; // 未开始 if ($k < 22) { if ($count == $num) { $v['status'] = 2; // 已完成 $num2 == $count && ($v['receive'] = 1); } elseif ($num == 0) { $v['status'] = 0; // 未开始 } else { $v['status'] = 1; // 进行中 } $res[] = $v; } else { $i = count($res) - 1; if ($count == $num) { $v['status'] = 2; // 已完成 $num2 == $count && ($v['receive'] = 1); $res[] = $v; } elseif ($res[$i]['status'] == 2) { $v['status'] = 1; $res[] = $v; } } } return $res; }
/** * 获取频道分类下的微博 --using * * @param * integer channel_category_id 频道分类ID * @param * integer max_id 上次返回的最后一条feed_id * @param * integer count 微博条数 * @param * integer type 微博类型 0-全部 1-原创 2-转发 3-图片 4-附件 5-视频 * @return json 指定分类下的微博 */ public function channel_detail() { $cid = intval($this->data['channel_category_id']); if (!$cid) { return array('status' => 0, 'msg' => '请选择频道'); } $max_id = $this->max_id ? intval($this->max_id) : 0; $count = $this->count ? intval($this->count) : 20; //频道信息 // if(!empty($max_id)){ // $channel_detail = D('channel_category')->where('channel_category_id='.$cid)->field('channel_category_id,title')->find(); // }else{ // $channel_detail = array(); // } /* 频道信息 */ $channel_detail = S('api_channel_info_' . $cid); if (!$channel_detail) { $channel_detail = D('channel_category')->where(array('channel_category_id' => array('eq', $cid)))->find(); $channel_detail = array_merge($channel_detail, unserialize($channel_detail['ext'])); unset($channel_detail['ext']); $channel_detail['banner'] = ''; if ($channel_detail['attach']) { $channel_detail['banner'] = getImageUrlByAttachId($channel_detail['attach']); } S('api_channel_info_' . $cid, $channel_detail); } // 频道下的微博 $where = 'c.status = 1'; $where .= ' AND c.channel_category_id =' . $cid; !empty($max_id) && ($where .= " AND c.feed_id < {$max_id}"); $type = $this->data['type']; if (in_array($type, array('postimage', 'postfile', 'postvideo'))) { $where .= " AND f.type='{$type}' "; } elseif ($type == 'post') { $where .= ' AND f.is_repost=0'; } elseif ($type == 'repost') { $where .= ' AND f.is_repost=1'; } $order = 'c.feed_id DESC'; $sql = 'SELECT distinct c.feed_id FROM `' . C('DB_PREFIX') . 'channel` c LEFT JOIN `' . C('DB_PREFIX') . 'feed` f ON c.feed_id = f.feed_id WHERE ' . $where . ' ORDER BY ' . $order . ' LIMIT ' . $count . ''; $feed_ids = getSubByKey(D()->query($sql), 'feed_id'); $channel_detail['feed_list'] = api('Weibo')->format_feed($feed_ids); return $channel_detail; }