/**
  * 获取用户模块缓存数据
  * @param $uid int 用户id
  * @param $modes array 获取模块数据及数量 array('article' => 1, 'write' => 2, ...)或数组  array('aritcle' => array('num'=>1,'expire'=>1234))
  * return array
  */
 function getByModes($uid, $modes)
 {
     $array = array();
     $query = $this->_db->query("SELECT type,num,value FROM " . $this->_tableName . " WHERE uid=" . S::sqlEscape($uid) . ' AND type IN(' . S::sqlImplode(array_keys($modes)) . ') AND expire>' . S::sqlEscape($this->now, false));
     while ($rt = $this->_db->fetch_array($query)) {
         $num = S::isArray($modes[$rt['type']]) ? S::int($modes[$rt['type']]['num']) : $modes[$rt['type']];
         if ($num < $rt['num']) {
             $array[$rt['type']] = PwArraySlice($this->_unserialize($rt['value']), 0, $num, true);
         } elseif ($num == $rt['num']) {
             $array[$rt['type']] = $this->_unserialize($rt['value']);
         }
     }
     return $array;
 }
示例#2
0
 }
 if (empty($_POST['operateStep'])) {
     require_once R_P . 'require/showimg.php';
     S::gp(array('group', 'orderby'));
     $group && ($tmpUrlAdd .= '&group=' . $group);
     $lang_no_member = array('2' => '没有普通成员', '3' => '没有未验证会员', '4' => '没有最近访客');
     $order_lastpost = $order_lastvisit = '';
     if ($group && $group == 4) {
         $visitor = $newColony->getVisitor();
         $total = count($visitor);
         $numofpage = ceil($total / $db_perpage);
         $numofpage = $db_maxpage && $numofpage > $db_maxpage ? $db_maxpage : $numofpage;
         $page < 1 ? $page = 1 : ($page > $numofpage ? $page = $numofpage : null);
         $pageurl = "{$basename}a=member&group=4&";
         $pages = numofpage($total, $page, $numofpage, $pageurl, $db_maxpage);
         $visitor = PwArraySlice($visitor, ($page - 1) * $db_perpage, $db_perpage, true);
         $visitorids = array_keys($visitor);
         if ($visitorids) {
             $userService = L::loadClass('UserService', 'user');
             /* @var $userService PW_UserService */
             foreach ($userService->getByUserIds($visitorids) as $rt) {
                 $rt['lastvisit'] = $visitor[$rt['uid']];
                 list($rt['icon']) = showfacedesign($rt['icon'], 1);
                 $memdb[] = $rt;
             }
         } else {
             $memdb = array();
         }
     } else {
         S::gp(array('page'), GP, 2);
         $sqlsel = '';
示例#3
0
 function setAtUsers($users = array())
 {
     if (!$this->_G['allowat']) {
         return false;
     }
     if (is_array($users)) {
         $userService = L::loadClass('UserService', 'user');
         $users = $userService->getByUserNames($users);
         $tmpUsers = array();
         foreach ((array) $users as $v) {
             $tmpUsers[$v[uid]] = $v['username'];
         }
     }
     $this->data['contentAtUsers'] && ($tmpUsers = (array) $tmpUsers + (array) $this->data['contentAtUsers']);
     $this->_G['atnum'] > 0 && count($tmpUsers) > $this->_G['atnum'] && ($tmpUsers = PwArraySlice($tmpUsers, 0, $this->_G['atnum'], true));
     $this->data['atusers'] = $tmpUsers;
 }
示例#4
0
 /**
  * 获取最近访客
  * return array
  */
 function getVisitor($nums = null, $start = 0)
 {
     if (!is_array($this->info['visitor'])) {
         $this->info['visitor'] = $this->info['visitor'] ? (array) unserialize($this->info['visitor']) : array();
     }
     return $nums ? PwArraySlice($this->info['visitor'], $start, $nums, true) : $this->info['visitor'];
 }