Example #1
0
 function get_reply($uid, $num = 20)
 {
     $pw_posts = GetPtable($GLOBALS['db_ptable']);
     $array = $tTable = $tids = array();
     $query = $this->_db->query("SELECT DISTINCT tid,pid FROM {$pw_posts} WHERE authorid=" . S::sqlEscape($uid) . " AND ifcheck=1 AND fid!=0 ORDER BY postdate DESC " . S::sqlLimit($num));
     while ($rt = $this->_db->fetch_array($query)) {
         $tids[] = $rt['tid'];
         $pids[$rt[tid]][] = $rt['pid'];
     }
     if ($tids) {
         $query = $this->_db->query("SELECT t.tid,t.subject,t.replies,t.hits,t.postdate,f.fid as forumsid,f.name as forums FROM pw_threads t LEFT JOIN pw_forums f ON t.fid=f.fid WHERE t.tid IN(" . S::sqlImplode($tids) . ") ORDER BY t.tid DESC");
         while ($rt = $this->_db->fetch_array($query)) {
             $rt['subject'] = substrs($rt['subject'], 45);
             $rt['forums'] = substrs(stripWindCode($rt['forums']), 100, 'N');
             list($rt['postdate']) = getLastDate($rt['postdate']);
             $rt['pid'] = $pids[$rt[tid]][0];
             $tTable[getTtable($rt['tid'])][] = $rt['tid'];
             $array[$rt['tid']] = $rt;
         }
         foreach ($tTable as $pw_tmsgs => $ids) {
             $query = $this->_db->query("SELECT tid,content FROM {$pw_tmsgs} WHERE tid IN (" . S::sqlImplode($ids) . ')');
             while ($rt = $this->_db->fetch_array($query)) {
                 $array[$rt['tid']]['content'] = substrs(stripWindCode($rt['content']), 100, 'N');
             }
         }
     }
     return $array;
 }
Example #2
0
function updateForumCount($fid, $topic, $replies, $tpost = 0)
{
    global $db, $db_fcachenum;
    $fm = $db->get_one("SELECT fup,type,password,allowvisit,f_type FROM pw_forums WHERE fid=" . S::sqlEscape($fid));
    if ($fm['type'] == 'category') {
        return false;
    }
    delfcache($fid, $db_fcachenum);
    $topic = intval($topic);
    $article = $topic + intval($replies);
    $tpost = intval($tpost);
    $lastpost = '';
    $lt = $db->get_one("SELECT tid,author,postdate,lastpost,lastposter,subject FROM pw_threads WHERE fid=" . S::sqlEscape($fid) . " AND specialsort='0' AND ifcheck='1' AND lastpost>0 ORDER BY lastpost DESC LIMIT 1");
    if ($lt) {
        if ($lt['postdate'] == $lt['lastpost']) {
            $subject = substrs($lt['subject'], 26);
        } else {
            $subject = 'Re:' . substrs($lt['subject'], 26);
        }
        $lastpost = ",lastpost=" . S::sqlEscape($subject . "\t" . $lt['lastposter'] . "\t" . $lt['lastpost'] . "\t" . "read.php?tid={$lt['tid']}&page=e#a");
    }
    $db->update("UPDATE pw_forumdata SET article=article+'{$article}',topic=topic+'{$topic}',tpost=tpost+'{$tpost}'{$lastpost} WHERE fid=" . S::sqlEscape($fid));
    Perf::gatherInfo('changeForumData', array('fid' => $fid));
    if (($fm['type'] == 'sub' || $fm['type'] == 'sub2') && ($fids = getUpFids($fid))) {
        if ($fm['password'] != '' || $fm['allowvisit'] != '' || $fm['f_type'] == 'hidden') {
            $lastpost = '';
        }
        $db->update("UPDATE pw_forumdata SET article=article+'{$article}',subtopic=subtopic+'{$topic}',tpost=tpost+'{$tpost}'{$lastpost} WHERE fid IN(" . S::sqlImplode($fids) . ')');
        Perf::gatherInfo('changeForumData', array('fid' => $fids));
    }
}
Example #3
0
 /**
  * 根据tids批量删除数据
  * 
  * @param int $tid
  * @return array 
  */
 function deleteByTids($tids)
 {
     if (!S::isArray($tids)) {
         return false;
     }
     return $this->_db->update("DELETE FROM " . $this->_tableName . " WHERE tid IN (" . S::sqlImplode($tids) . ")");
 }
Example #4
0
 /**
  * @param $replies
  * @param $order
  * @param $isDesc
  * @param $page
  * @return unknown_type
  */
 function getThreadsByReplies($replies, $page)
 {
     if (!$replies) {
         return;
     }
     $sql = "SELECT p.tid FROM pw_postsfloor p GROUP BY p.tid ORDER BY p.tid DESC";
     $query = $this->db->query($sql);
     while ($rt = $this->db->fetch_array($query)) {
         $tid[] = $rt['tid'];
     }
     if ($tid) {
         $w_tid = " t.tid NOT IN ( " . S::sqlImplode($tid) . " ) AND ";
     }
     $sql = "SELECT COUNT(*) AS sum FROM pw_threads t WHERE {$w_tid} t.replies > " . S::sqlEscape($replies);
     $rt = $this->db->get_one($sql);
     (!is_numeric($page) || $page < 1) && ($page = 1);
     $limit = S::sqlLimit(($page - 1) * $this->db_perpage, $this->db_perpage);
     $result['pages'] = numofpage($rt['sum'], $page, ceil($rt['sum'] / $this->db_perpage), $this->basename . "&sub=y&action=search&replies={$replies}&");
     $sql = "SELECT t.tid, t.subject, t.replies, t.postdate, t.fid\n\t\t\t\tFROM pw_threads t\n\t\t\t\tWHERE {$w_tid} t.replies > " . S::sqlEscape($replies) . " {$limit}";
     $query = $this->db->query($sql);
     while ($rt = $this->db->fetch_array($query)) {
         list($lastDate) = PostIndexUtility::getLastDate($rt["postdate"]);
         $rt["postdate"] = $lastDate;
         $result['data'][] = $rt;
     }
     return $result;
 }
 function searchAllFriend($uid, $keyword, $offset, $limit)
 {
     list($uid, $keyword, $offset, $limit) = array(intval($uid), trim($keyword), intval($offset), intval($limit));
     if ($uid < 1 || !$keyword) {
         $this->buildResponse(Friend_INVALID_PARAMS);
     }
     $keyword = ACloud_Sys_Core_Common::convert($keyword, ACloud_Sys_Core_Common::getGlobal('g_charset'), 'UTF-8');
     $uids = array();
     $query = $GLOBALS['db']->query("SELECT friendid FROM pw_friends WHERE status='0' AND uid=" . S::sqlEscape($uid));
     while ($rt = $GLOBALS['db']->fetch_array($query)) {
         $uids[] = $rt['friendid'];
     }
     if (!S::isArray($uids)) {
         return $this->buildResponse(0, array());
     }
     list($result, $uids) = array(array(), array_slice($uids, 0, 150));
     $count = $GLOBALS['db']->get_value("SELECT COUNT(*) as count FROM pw_members WHERE username LIKE " . S::sqlEscape("%{$keyword}%") . " AND uid IN (" . S::sqlImplode($uids) . ")");
     if ($count < 1) {
         return $this->buildResponse(0, array());
     }
     $sqlLimit = $offset > 0 ? ' AND uid > ' . S::sqlEscape($offset) : '';
     $query = $GLOBALS['db']->query("SELECT uid,icon,username FROM pw_members WHERE username LIKE " . S::sqlEscape("%{$keyword}%") . " AND uid IN (" . S::sqlImplode($uids) . ") {$sqlLimit} ORDER BY uid ASC LIMIT " . intval($limit));
     require_once R_P . 'require/showimg.php';
     while ($rt = $GLOBALS['db']->fetch_array($query)) {
         $tmpIcon = showfacedesign($rt['icon'], 1, 's');
         $result[] = array('uid' => $rt['uid'], 'username' => $rt['username'], 'icon' => $tmpIcon[0]);
     }
     return $this->buildResponse(0, array('count' => $count, 'friends' => $result));
 }
Example #6
0
 /**
  * 根据多个学院ID获取数据
  * @param array schoolIds
  * @return array
  */
 function getSchoolsBySchoolIds($schoolIds)
 {
     if (!S::isArray($schoolIds)) {
         return array();
     }
     $query = $this->_db->query("SELECT * FROM  {$this->_tableName} WHERE schoolid IN (" . S::sqlImplode($schoolIds) . ")");
     return $this->_getAllResultFromQuery($query, 'schoolid');
 }
Example #7
0
 /**
  * 根据IDs获得记录信息
  * @param array $ids
  * @return multitype:
  */
 function getDataByIds($ids)
 {
     if (empty($ids) || !is_array($ids)) {
         return array();
     }
     $query = $this->_db->query("SELECT w.*, m.* FROM {$this->_tableName} w LEFT JOIN pw_members m \n\t\t\tON w.uid=m.uid WHERE w.id IN (" . S::sqlImplode($ids) . ") ORDER BY w.id DESC");
     return $this->_getAllResultFromQuery($query);
 }
 /**
  * 
  * 检查是否已经关注某些话题
  * @param int $topicIds
  * @param int $userid
  * @return array
  */
 function getAttentionedTopicByTopicIds($topicIds, $userid)
 {
     if (!$userid && !S::isArray($topicIds)) {
         return array();
     }
     $query = $this->_db->query('SELECT userid,topicid FROM ' . $this->_tableName . ' WHERE userid = ' . $this->_addSlashes($userid) . ' AND topicid IN (' . S::sqlImplode($topicIds) . ')');
     return $this->_getAllResultFromQuery($query, 'topicid');
 }
 function getFloorsByPids($pids)
 {
     $query = $this->_db->query("SELECT floor FROM " . $this->_tableName . " WHERE pid IN(" . S::sqlImplode($pids) . ")");
     while ($rt = $this->_db->fetch_array($query)) {
         $robFloors[] = $rt['floor'];
     }
     return $robFloors;
 }
Example #10
0
 function getsByCreateTime($groupIds, $createTime)
 {
     if (!is_array($groupIds)) {
         return false;
     }
     $query = $this->_db->query("SELECT * FROM " . $this->_tableName . " WHERE created_time > " . $this->_addSlashes($createTime) . " AND oid in(" . S::sqlImplode($groupIds) . ")");
     return $this->_getAllResultFromQuery($query);
 }
Example #11
0
 function getsByPostIds($postIds, $table)
 {
     if (!$table) {
         return false;
     }
     $postIds = is_array($postIds) ? S::sqlImplode($postIds) : $postIds;
     $query = $this->_db->query("SELECT * FROM " . $table . " p  WHERE p.pid in(" . $postIds . ") ORDER BY p.postdate DESC");
     return $this->_getAllResultFromQuery($query);
 }
Example #12
0
 /**
  * 
  * 组装搜索条件
  * @param array $modelid 分类信息id
  * @param string $fid 版块id
  * @return string
  */
 function _buildCondition($modelid, $fid)
 {
     $sqlWhere = ' WHERE modelid != 0';
     !empty($modelid) && ($sqlWhere .= ' AND modelid IN (' . S::sqlImplode($modelid) . ')');
     $fid && ($sqlWhere .= ' AND fid IN (' . $fid . ')');
     $blackListedTids = $this->_getBlackListedTids();
     $blackListedTids && ($sqlWhere .= ' AND tid NOT IN (' . $blackListedTids . ')');
     return $sqlWhere;
 }
Example #13
0
 function getsByDids($dids)
 {
     if (!$dids) {
         return false;
     }
     $dids = is_array($dids) ? S::sqlImplode($dids) : $dids;
     $query = $this->_db->query("SELECT * FROM " . $this->_tableName . " WHERE did in(" . $dids . ") ORDER BY postdate DESC ");
     return $this->_getAllResultFromQuery($query);
 }
 function deleteByUids($tid, $pid, $uids)
 {
     $tid = intval($tid);
     $pid = intval($pid);
     if (!$tid || !S::isArray($uids)) {
         return false;
     }
     return $this->_db->update("DELETE FROM {$this->_tableName} WHERE tid={$tid} AND pid={$pid} AND uid IN( " . S::sqlImplode($uids) . ')');
 }
 /**
  * 按照分类、是否有logo查找链接信息
  * 
  * @param int $num 条数
  * @param bool false 是否有logo
  * @param array $sids 链接ID数组
  * @return array 友情链接分类信息
  */
 function getData($num, $sids, $haveLogo = false)
 {
     $num = (int) $num;
     $num && ($limit = $this->_Limit(0, $num));
     $haveLogo && ($_sqlAdd = " AND logo <> '' ");
     is_array($sids) && ($_sqlsids = " AND sid IN(" . S::sqlImplode($sids) . ")");
     $query = $this->_db->query("SELECT * FROM {$this->_tableName} WHERE ifcheck = '1' " . $_sqlsids . $_sqlAdd . " ORDER BY threadorder ASC {$limit}");
     return $this->_getAllResultFromQuery($query);
 }
Example #16
0
 /**
  * 获取个人APP列表
  */
 function userApplist($uids, $appids = '', $arrt = 0)
 {
     if (!$uids) {
         return false;
     }
     $this->_app_array = array();
     $this->_appslist = $this->getApplist();
     $sql_uid = $sql_appid = '';
     if (is_numeric($uids)) {
         $sql_uid .= ' uid=' . S::sqlEscape($uids);
     } elseif (is_array($uids)) {
         $sql_uid .= ' uid IN(' . S::sqlImplode($uids) . ')';
     }
     if (is_numeric($appids)) {
         $sql_appid .= ' AND appid=' . S::sqlEscape($appids);
     } elseif (is_array($appids)) {
         $sql_appid .= ' AND appid IN(' . S::sqlImplode($appids) . ')';
     }
     //$query = $this->_db->query("SELECT uid,appid,appname FROM pw_userapp WHERE $sql_uid $sql_appid");
     if (perf::checkMemcache()) {
         $appids = is_array($appids) ? $appids : array(intval($appids));
         $_cacheService = Perf::gatherCache('pw_userapp');
         $array = $_cacheService->getUserappsCacheByUids($uids);
         foreach ($array as $v) {
             if (in_array($v['appid'], $appids)) {
                 continue;
             }
             if ($this->_appslist[$v['appid']]) {
                 if ($arrt == 1) {
                     $this->_app_array[$v['appid']] = $v['appname'];
                 } elseif ($arrt == 2) {
                     $this->_app_array[$v['uid']][$v['appid']] = $v;
                 } else {
                     $this->_app_array[] = $v;
                 }
             }
         }
     } else {
         $query = $this->_db->query("SELECT uid,appid,appname FROM pw_userapp WHERE {$sql_uid} {$sql_appid}");
         while ($rt = $this->_db->fetch_array($query)) {
             if ($this->_appslist[$rt['appid']]) {
                 if ($arrt == 1) {
                     $this->_app_array[$rt['appid']] = $rt['appname'];
                 } elseif ($arrt == 2) {
                     $this->_app_array[$rt['uid']][$rt['appid']] = $rt;
                 } else {
                     $this->_app_array[] = $rt;
                 }
             }
         }
     }
     if (!$this->_app_array || !$this->appifopen) {
         $this->_app_array = array();
     }
     return $this->_app_array;
 }
Example #17
0
 function updatePageInvokesState($scr, $sign, $invokeNames, $state)
 {
     if ($invokeNames && is_array($invokeNames)) {
         $this->_db->update("UPDATE " . $this->_tableName . " SET state=" . S::sqlEscape($state) . " WHERE scr=" . S::sqlEscape($scr) . " AND sign=" . S::sqlEscape($sign) . " AND invokename IN(" . S::sqlImplode($invokeNames) . ')');
     } elseif ($invokeNames) {
         $this->_db->update("UPDATE " . $this->_tableName . " SET state=" . S::sqlEscape($state) . " WHERE scr=" . S::sqlEscape($scr) . " AND sign=" . S::sqlEscape($sign) . " AND invokename=" . S::sqlEscape($invokeNames));
     } else {
         $this->_db->update("UPDATE " . $this->_tableName . " SET state=" . S::sqlEscape($state) . " WHERE scr=" . S::sqlEscape($scr) . " AND sign=" . S::sqlEscape($sign));
     }
 }
 function deleteCnrelationsByMid($mids)
 {
     if (empty($mids)) {
         return false;
     }
     $mids = is_array($mids) ? $mids : array($mids);
     $sql = 'DELETE FROM ' . $this->_tableName . ' WHERE mid IN (' . S::sqlImplode($mids) . ') ';
     $this->_db->query($sql);
     return true;
 }
Example #19
0
 /** 
  *  通过上级ID获取分类
  * 
  *  @param  $upids   array 上级分类ID数组
  *  @return $styledb array 分类的数组 
  */
 function getGradeStylesByUpid($upids)
 {
     if (empty($upids)) {
         return array();
     }
     $query = $this->db->query("SELECT * FROM pw_cnstyles WHERE upid IN (" . S::sqlImplode($upids) . ") ORDER BY vieworder ASC");
     while ($rt = $this->db->fetch_array($query)) {
         //if($rt['ifopen'] == 0) continue;
         $styledb[$rt['upid']][$rt['id']] = $rt;
     }
     return $styledb;
 }
Example #20
0
 function _getTidsByPid($tableName, $pids)
 {
     $pids = (array) $pids;
     $tids = array();
     if (!$pids) {
         return $tids;
     }
     $query = $GLOBALS['db']->query("SELECT DISTINCT tid FROM {$tableName} WHERE pid IN(" . S::sqlImplode($pids) . ")");
     while ($rt = $GLOBALS['db']->fetch_array($query)) {
         $tids[] = $rt['tid'];
     }
     return $tids;
 }
 function gets($array)
 {
     $temp = array();
     if (!$array) {
         return array();
     }
     $rs = $this->_db->query('SELECT * FROM ' . $this->_tableName . ' WHERE sign IN (' . S::sqlImplode($array) . ')');
     while ($rt = $this->_db->fetch_array($rs)) {
         $rt['data'] = $this->_unserialize($rt['data']);
         $temp[$rt['sign']] = $rt;
     }
     return $temp;
 }
Example #22
0
 function getImgAttachesByTids($tids)
 {
     if (!S::isArray($tids)) {
         return $this->buildResponse(ATTACH_INVALID_PARAMS);
     }
     $result = array();
     $query = $GLOBALS['db']->query("SELECT tid, attachurl FROM pw_attachs WHERE tid IN (" . S::sqlImplode($tids) . ") AND pid=0 AND did=0 AND type='img'");
     $utilityService = $this->getCommonUtilityService();
     while ($rt = $GLOBALS['db']->fetch_array($query)) {
         list($attachurl, $attachThumbUrl) = $utilityService->getThumbAttach($rt['attachurl'], false);
         $result[$rt['tid']][] = $attachurl;
     }
     return $this->buildResponse(0, $result);
 }
Example #23
0
 function commonGetDatas($invokepieceids)
 {
     if (!is_array($invokepieceids) || !$invokepieceids) {
         return array();
     }
     $temp = array();
     //print_r("SELECT * FROM ".$this->_tableName." WHERE invokepieceid IN(".S::sqlImplode($invokepieceids).")");exit;
     $query = $this->_db->query("SELECT * FROM " . $this->_tableName . " WHERE invokepieceid IN(" . S::sqlImplode($invokepieceids) . ")");
     while ($rt = $this->_db->fetch_array($query)) {
         $rt = $this->_unserializeData($rt);
         //$key = $rt['loopid'] ? $rt['invokepieceid']."_".$rt['loopid'] : $rt['invokepieceid'];
         $temp[$rt['invokepieceid']] = $rt;
     }
     return $temp;
 }
Example #24
0
 function _getUserappsCacheDataByUidsNoCache($uids)
 {
     global $db;
     if (is_numeric($uids)) {
         $uids = array(intval($uids));
     }
     if (!is_array($uids)) {
         return false;
     }
     $apps = array();
     $query = $db->query("SELECT * FROM pw_userapp WHERE uid IN (" . S::sqlImplode($uids) . ')');
     while ($rt = $db->fetch_array($query)) {
         $apps[$rt['uid']] = $rt;
     }
     return $apps;
 }
Example #25
0
 function insertApp($fids, $appid, $appinfo = '')
 {
     //更新版块APP信息
     if (!$fids) {
         return new ApiResponse(false);
     }
     if (is_numeric($fids)) {
         $sql = ' fid=' . S::sqlEscape($fids);
     } else {
         $sql = ' fid IN(' . S::sqlImplode(explode(",", $fids)) . ')';
     }
     $query = $this->db->query("SELECT fid,appinfo FROM pw_forumsextra WHERE appinfo!=''");
     while ($rt = $this->db->fetch_array($query)) {
         $appdb = array();
         $appdb = unserialize($rt['appinfo']);
         unset($appdb[$appid]);
         $appdb = serialize($appdb);
         $this->db->update("UPDATE pw_forumsextra SET appinfo=" . S::sqlEscape($appdb) . " WHERE fid=" . S::sqlEscape($rt['fid']));
     }
     $oldfids = array();
     $query = $this->db->query("SELECT fid,appinfo FROM pw_forumsextra WHERE {$sql}");
     while ($rt = $this->db->fetch_array($query)) {
         $appdb = array();
         $appdb = unserialize($rt['appinfo']);
         $appdb[$appid] = $appinfo;
         $appdb = serialize($appdb);
         $oldfids[$rt['fid']] = $rt['fid'];
         $this->db->update("UPDATE pw_forumsextra SET appinfo=" . S::sqlEscape($appdb) . " WHERE fid=" . S::sqlEscape($rt['fid']));
     }
     $forumset = array('lock' => 0, 'cutnums' => 0, 'threadnum' => 0, 'readnum' => 0, 'newtime' => 0, 'orderway' => 'lastpost', 'asc' => 'DESC', 'allowencode' => 0, 'anonymous' => 0, 'rate' => 0, 'dig' => 0, 'inspect' => 0, 'watermark' => 0, 'commend' => 0, 'autocommend' => 0, 'commendlist' => '', 'commendnum' => 0, 'commendlength' => 0, 'commendtime' => 0, 'addtpctype' => 0, 'ifrelated' => 0, 'relatednums' => 0, 'relatedcon' => 'ownpost', 'relatedcustom' => array(), 'rvrcneed' => 0, 'moneyneed' => 0, 'creditneed' => 0, 'postnumneed' => 0, 'sellprice' => array(), 'uploadset' => 'money 0', 'rewarddb' => '', 'allowtime' => '');
     $forumset = serialize($forumset);
     foreach (explode(",", $fids) as $key => $value) {
         if (!$oldfids[$value]) {
             $appdb = array();
             $appdb[$appid] = $appinfo;
             $appdb = serialize($appdb);
             $this->db->update("INSERT INTO pw_forumsextra SET " . S::sqlSingle(array('fid' => $value, 'forumset' => $forumset, 'appinfo' => $appdb)));
         }
     }
     require_once R_P . 'admin/cache.php';
     updatecache_f();
     return new ApiResponse(true);
 }
 function getThreadDataWithTmsgs($query)
 {
     $threads = $tmsgsTables = array();
     while ($rt = $GLOBALS['db']->fetch_array($query)) {
         $threads[$rt['tid']] = $rt;
         $tmsgsTableName = GetTtable($rt['tid']);
         $tmsgsTables[$tmsgsTableName][] = $rt['tid'];
     }
     if (!S::isArray($threads)) {
         return array();
     }
     foreach ($tmsgsTables as $tableName => $tids) {
         $tmsgsQuery = $GLOBALS['db']->query("SELECT * FROM " . S::sqlMetaData($tableName) . " WHERE tid IN(" . S::sqlImplode($tids) . ")");
         while ($rt = $GLOBALS['db']->fetch_array($tmsgsQuery)) {
             $rt['threadurl'] = $GLOBALS['db_bbsurl'] . '/read.php?tid=' . $rt['tid'];
             $rt['forumurl'] = $GLOBALS['db_bbsurl'] . '/thread.php?fid=' . $threads[$rt['tid']]['fid'];
             $threads[$rt['tid']] = array_merge($threads[$rt['tid']], $rt);
         }
     }
     return $threads;
 }
Example #27
0
 function _getClassidAdd($classID)
 {
     $classID = (int) $classID;
     if (!$classID) {
         return '';
     }
     $o_styledb = L::config('o_styledb', 'o_config');
     if (!isset($o_styledb[$classID])) {
         return '';
     }
     if ($o_styledb[$classID]['upid'] != '0') {
         return ' AND c.styleid=' . S::sqlEscape($classID);
     }
     $array = array();
     foreach ($o_styledb as $k => $v) {
         if ($v['upid'] == $classID) {
             $array[] = $k;
         }
     }
     return $array ? ' AND c.styleid IN(' . S::sqlImplode($array) . ')' : ' AND c.styleid=' . S::sqlEscape($classID);
 }
Example #28
0
 function getAppUsers($appid, $uid, $num, $start = 0)
 {
     if ($num == 'all') {
         $num = 500;
     } elseif (!is_numeric($num) || $num < 1) {
         $num = 20;
     } elseif ($num > 500) {
         $num = 500;
     }
     (!is_numeric($start) || $start < 0) && ($start = 0);
     $users = $appusers = array();
     $query = $this->db->query("SELECT friendid FROM pw_friends WHERE status='0' AND uid=" . S::sqlEscape($uid) . S::sqlLimit($start, $num));
     while ($rt = $this->db->fetch_array($query)) {
         $users[] = $rt['friendid'];
     }
     $query = $this->db->query("SELECT uid FROM pw_userapp WHERE uid IN (" . S::sqlImplode($users) . ") AND appid=" . S::sqlEscape($appid));
     while ($rt = $this->db->fetch_array($query)) {
         $appusers[] = $rt['uid'];
     }
     return new ApiResponse($appusers);
 }
Example #29
0
function get_pinglogs($tid, $pingIdArr)
{
    if (empty($pingIdArr)) {
        return;
    }
    global $db, $fid, $creditnames;
    $pingIds = array();
    $pingLogs = array();
    foreach ($pingIdArr as $pid => $markInfo) {
        list($count, $ids, $creditCount) = explode(":", $markInfo);
        $pingLogs[$pid]['count'] = $count;
        $pingLogs[$pid]['creditCount'] = parseCreditCount($creditCount);
        $pingIds = array_merge($pingIds, explode(",", $ids));
    }
    if (!count($pingIds)) {
        return array();
    }
    $query = $db->query("SELECT a.*,b.uid,b.icon FROM pw_pinglog a LEFT JOIN pw_members b ON a.pinger=b.username WHERE a.id IN (" . S::sqlImplode($pingIds) . ") ");
    while ($rt = $db->fetch_array($query)) {
        $rt['pid'] = $rt['pid'] ? $rt['pid'] : 'tpc';
        list($rt['pingtime'], $rt['pingdate']) = getLastDate($rt['pingdate']);
        $rt['record'] = $rt['record'] ? $rt['record'] : "-";
        if ($rt['point'] > 0) {
            $rt['point'] = "+" . $rt['point'];
        }
        $tmp = showfacedesign($rt['icon'], true, 's');
        $rt['icon'] = $tmp[0];
        isset($creditnames[$rt['name']]) && ($rt['name'] = $creditnames[$rt['name']]);
        $pingLogs[$rt['pid']]['data'][$rt['id']] = $rt;
    }
    foreach ($pingLogs as $pid => $data) {
        if (is_array($pingLogs[$pid]['data'])) {
            krsort($pingLogs[$pid]['data']);
        }
    }
    return $pingLogs;
}
 function updateGroupSmsNumberByUserIds($userIds, $number)
 {
     $this->_db->update("UPDATE " . $this->_tableName . " SET groupsms_num = groupsms_num+" . $this->_addSlashes($number) . " WHERE uid in(  " . S::sqlImplode($userIds) . ")");
     return $this->_db->affected_rows();
 }