function __construct() { parent::__construct(); if (!CheckTaskSwitch()) { $this->error('该页面不存在!'); } }
public function render($var) { if (!CheckTaskSwitch()) { return; } $uid = $GLOBALS['ts']['mid']; $data = model('Cache')->get('check_info_' . $uid . '_' . date('Ymd')); if (!$data) { $map['uid'] = $uid; $map['ctime'] = array('gt', strtotime(date('Ymd'))); $res = D('check_info')->where($map)->find(); // 是否签到 $data['ischeck'] = $res ? true : false; $checkinfo = D('check_info')->where('uid=' . $uid)->order('ctime desc')->limit(1)->find(); if ($checkinfo) { if ($checkinfo['ctime'] > strtotime(date('Ymd')) - 86400) { $data['con_num'] = $checkinfo['con_num']; } else { $data['con_num'] = 0; } $data['total_num'] = $checkinfo['total_num']; } else { $data['con_num'] = 0; $data['total_num'] = 0; } $data['day'] = date('m.d'); model('Cache')->set('check_info_' . $uid . '_' . date('Ymd'), $data); } $data['tpl'] = 'index'; $var['tpl'] && ($data['tpl'] = $var['tpl']); $week = date('w'); switch ($week) { case '0': $week = '周日'; break; case '1': $week = '周一'; break; case '2': $week = '周二'; break; case '3': $week = '周三'; break; case '4': $week = '周四'; break; case '5': $week = '周五'; break; case '6': $week = '周六'; break; } $data['week'] = $week; $data['credit'] = M('credit_setting')->where("`name`='check_in'")->find(); $content = $this->renderFile(dirname(__FILE__) . "/" . $data['tpl'] . '.html', $data); return $content; }
public function render($data) { if (!CheckTaskSwitch()) { return; } // TODO Auto-generated method stub $map['uid'] = $data['uid'] ? $data['uid'] : $GLOBALS['ts']['mid']; $user_info = model('User')->getUserInfo($map['uid']); $medals = $user_info['medals']; if (!$medals) { return; } $medalids = getSubByKey($medals, 'id'); $map['medal_id'] = array('in', $medalids); //加入缓存 如果勋章数目有变化的话 重新获取在缓存 $key = 'medal_user_' . $map['uid'] . '_' . count($medalids); $usermedal = model('Cache')->get($key); if (!$usermedal) { $umedal = D('medal_user')->where($map)->field('medal_id,`desc`,ctime')->findAll(); $usermedal = array(); foreach ($umedal as $u) { $usermedal[$u['medal_id']]['desc'] = $u['desc']; $usermedal[$u['medal_id']]['ctime'] = $u['ctime']; } model('Cache')->set($key, $usermedal); } foreach ($medals as &$m) { $usermedal[$m['id']]['desc'] && ($m['desc'] = $usermedal[$m['id']]['desc']); $m['ctime'] = date('Y-m-d H:i:s', $usermedal[$m['id']]['ctime']); } $var['medals'] = $medals; $var['isme'] = $map['uid'] == $GLOBALS['ts']['mid'] ? true : false; $var['uid'] = $map['uid']; $content = $this->renderFile(dirname(__FILE__) . '/list.html', $var); return $content; }
<div model-node="drop_menu_list" class="dropmenu" style="opacity:0;display:none;width:100px"> <i class="arrow-mes"></i> <dl class="acc-list"> <dd><a href="<?php echo U('public/Profile/index', array('uid' => $mid)); ?> "><i class="ico-myhome"></i>我的主页</a></dd> <dd><a href="<?php echo U('public/Account/index'); ?> "><i class="ico-mysetup"></i>个人设置</a></dd> <dd><a href="<?php echo U('public/Rank/index', 'type=2'); ?> "><i class="ico-mypoints"></i>排行榜</a></dd> <?php if (CheckTaskSwitch()) { ?> <dd><a href="<?php echo U('public/Task/index'); ?> "><i class="ico-mytask"></i>任务中心</a></dd> <dd><a href="<?php echo U('public/Medal/index'); ?> "><i class="ico-mymedal"></i>勋章馆</a></dd> <?php } ?> <?php if (!isVerified($user['uid'])) {
/** * 发布排行榜到我的分享 */ public function postRank() { $type = $_POST['type'] ? intval($_POST['type']) : 1; $typename = $type == 1 ? '好友' : '全站'; $ranList = model('Cache')->get('ranklist_' . $this->mid . '_' . $type); if (!$ranList) { //1为好友排行 if ($type == 1) { $followGroupList = model('Follow')->getFriendsData($this->mid); $fids = getSubByKey($followGroupList, 'fid'); $fids[] = $this->mid; } $ranList = $this->_getRankList($type, $fids); } //基本排名 $str = "我的{$typename}排行榜:粉丝数第{$ranList['followerrank']};经验值第{$ranList['experiencerank']};积分值第{$ranList['scorerank']};"; //任务排名 if (CheckTaskSwitch()) { $str .= "勋章数第{$ranList['medalrank']};连续签到第{$ranList['checkconrank']};累计签到第{$ranList['checktotalrank']};"; } $str .= '快来查看你的排名吧。' . U('public/Rank/index', 'type=' . $type); $data['body'] = $str; model('Feed')->put($this->mid, 'public', 'post', $data); echo 1; }