示例#1
0
 public static function useractionlog($uid, $action)
 {
     $uid = intval($uid);
     if (empty($uid) || empty($action)) {
         return false;
     }
     $action = getuseraction($action);
     C::t('common_member_action_log')->insert(array('uid' => $uid, 'action' => $action, 'dateline' => TIMESTAMP));
     return true;
 }
 public static function sendpm($toid, $subject, $message, $fromid = '', $replypmid = 0, $isusername = 0, $type = 0)
 {
     global $_G;
     if ($fromid === '') {
         $fromid = $_G['uid'];
     }
     $author = '';
     if ($fromid) {
         if ($fromid == $_G['uid']) {
             $sendpmmaxnum = $_G['group']['allowsendpmmaxnum'];
             $author = $_G['username'];
         } else {
             $user = getuserbyuid($fromid);
             $author = $user['username'];
             loadcache('usergroup_' . $user['groupid']);
             $sendpmmaxnum = $_G['cache']['usergroup_' . $user['groupid']]['allowsendpmmaxnum'];
         }
         $currentnum = C::t('common_member_action_log')->count_day_hours(getuseraction('pmid'), $fromid);
         if ($sendpmmaxnum && $currentnum >= $sendpmmaxnum) {
             return -16;
         }
     }
     loaducenter();
     $return = uc_pm_send($fromid, $toid, addslashes($subject), addslashes($message), 1, $replypmid, $isusername, $type);
     if ($return > 0 && $fromid) {
         if ($_G['setting']['cloud_status']) {
             $msgService = Cloud::loadClass('Cloud_Service_Client_Message');
             if (is_numeric($toid)) {
                 $tospace = getuserbyuid($toid);
                 if ($tospace['conisbind']) {
                     $msgService->add($toid, $fromid, $author, $_G['timestamp']);
                 }
             } else {
                 $senduids = array();
                 foreach (C::t('common_member')->fetch_all_by_username(explode(',', $toid)) as $touser) {
                     if ($touser['conisbind']) {
                         $senduids[$touser['uid']] = $touser['uid'];
                     }
                 }
                 if ($senduids) {
                     $msgService->add($senduids, $fromid, $author, $_G['timestamp']);
                 }
             }
         }
         foreach (explode(',', $fromid) as $v) {
             useractionlog($fromid, 'pmid');
         }
     }
     return $return;
 }
示例#3
0
function checkmaxpostsperhour()
{
    global $_G;
    $morepostsperhour = false;
    if (!$_G['group']['disablepostctrl'] && $_G['uid']) {
        if ($_G['group']['maxpostsperhour']) {
            $timestamp = $_G['timestamp'] - 3600;
            $userposts = DB::result_first('SELECT COUNT(*) FROM ' . DB::table('common_member_action_log') . " WHERE dateline>{$timestamp} AND (`action`='" . getuseraction('tid') . "' OR `action`='" . getuseraction('pid') . "') AND uid='{$_G['uid']}'");
            $isflood = $userposts && $userposts >= $_G['group']['maxpostsperhour'];
            if ($isflood) {
                $morepostsperhour = true;
            }
        }
    }
    return $morepostsperhour;
}
示例#4
0
 function getdata($style, $parameter)
 {
     global $_G;
     $parameter = $this->cookparameter($parameter);
     $uids = !empty($parameter['uids']) ? explode(',', $parameter['uids']) : array();
     $groupid = !empty($parameter['groupid']) && !in_array(0, $parameter['groupid']) ? $parameter['groupid'] : array();
     $startrow = !empty($parameter['startrow']) ? intval($parameter['startrow']) : 0;
     $items = !empty($parameter['items']) ? intval($parameter['items']) : 10;
     $orderby = isset($parameter['orderby']) && in_array($parameter['orderby'], array('credits', 'extcredits', 'threads', 'posts', 'digestposts', 'regdate', 'show', 'blogs', 'albums', 'doings', 'sharings', 'special', 'todayposts')) ? $parameter['orderby'] : '';
     $special = isset($parameter['special']) && strlen($parameter['special']) ? intval($parameter['special']) : null;
     $lastpost = !empty($parameter['lastpost']) ? intval($parameter['lastpost']) : '';
     $avatarstatus = !empty($parameter['avatarstatus']) ? 1 : 0;
     $emailstatus = !empty($parameter['emailstatus']) ? 1 : 0;
     $verifystatus = !empty($parameter['verifystatus']) ? $parameter['verifystatus'] : array();
     $profiles = array();
     $profiles['gender'] = !empty($parameter['gender']) ? intval($parameter['gender']) : 0;
     $profiles['resideprovince'] = !empty($parameter['xresideprovince']) ? $parameter['xresideprovince'] : '';
     $profiles['residecity'] = !empty($parameter['xresidecity']) ? $parameter['xresidecity'] : '';
     $profiles['residedist'] = !empty($parameter['xresidedist']) ? $parameter['xresidedist'] : '';
     $profiles['residecommunity'] = !empty($parameter['xresidecommunity']) ? $parameter['xresidecommunity'] : '';
     $profiles['birthprovince'] = !empty($parameter['xbirthprovince']) ? $parameter['xbirthprovince'] : '';
     $profiles['birthcity'] = !empty($parameter['xbirthcity']) ? $parameter['xbirthcity'] : '';
     $bannedids = !empty($parameter['bannedids']) ? explode(',', $parameter['bannedids']) : array();
     $list = $todayuids = $todayposts = array();
     $tables = $wheres = array();
     $sqlorderby = '';
     $olditems = $items;
     $tables[] = DB::table('common_member') . ' m';
     if ($groupid) {
         $wheres[] = 'm.groupid IN (' . dimplode($groupid) . ')';
     }
     if ($bannedids) {
         $wheres[] = 'm.uid NOT IN (' . dimplode($bannedids) . ')';
     }
     if ($avatarstatus) {
         $wheres[] = "m.avatarstatus='1'";
     }
     if ($emailstatus) {
         $wheres[] = "m.emailstatus='1'";
     }
     if (!empty($verifystatus)) {
         $flag = false;
         foreach ($verifystatus as $value) {
             if (isset($_G['setting']['verify'][$value])) {
                 $flag = true;
                 $wheres[] = "cmv.verify{$value}='1'";
             }
         }
         if ($flag) {
             $tables[] = DB::table('common_member_verify') . ' cmv';
             $wheres[] = 'cmv.uid=m.uid';
         }
     }
     $tables[] = DB::table('common_member_count') . ' mc';
     $wheres[] = 'mc.uid=m.uid';
     foreach ($profiles as $key => $value) {
         if ($value) {
             $tables[] = DB::table('common_member_profile') . ' mp';
             $wheres[] = 'mp.uid=m.uid';
             $wheres[] = "mp.{$key}='{$value}'";
         }
     }
     $reason = $show = '';
     if ($special !== null) {
         $special = in_array($special, array(-1, 0, 1)) ? $special : -1;
         $tables[] = DB::table('home_specialuser') . ' su';
         if ($special != -1) {
             $wheres[] = "su.status='{$special}'";
         }
         $wheres[] = 'su.uid=m.uid';
         $reason = ', su.reason';
     }
     if ($lastpost && $orderby != 'todayposts') {
         $time = TIMESTAMP - $lastpost;
         $tables[] = DB::table('common_member_status') . " ms";
         $wheres[] = "ms.uid=m.uid";
         $wheres[] = "ms.lastpost>'{$time}'";
     }
     switch ($orderby) {
         case 'credits':
         case 'regdate':
             $sqlorderby = " ORDER BY m.{$orderby} DESC";
             break;
         case 'extcredits':
             $extcredits = 'extcredits' . (in_array($parameter['extcredit'], range(1, 8)) ? $parameter['extcredit'] : '1');
             $sqlorderby = " ORDER BY mc.{$extcredits} DESC";
             break;
         case 'threads':
         case 'posts':
         case 'blogs':
         case 'albums':
         case 'doings':
         case 'sharings':
         case 'digestposts':
             $sqlorderby = " ORDER BY mc.{$orderby} DESC";
             break;
         case 'show':
             $show = ', s.unitprice, s.credit as showcredit, s.note as shownote';
             $tables[] = DB::table('home_show') . " s";
             $wheres[] = 's.uid=m.uid';
             $sqlorderby = ' ORDER BY s.unitprice DESC, s.credit DESC';
             break;
         case 'special':
             $sqlorderby = $special !== null ? ' ORDER BY su.displayorder, dateline DESC' : '';
             break;
         case 'todayposts':
             $todaytime = strtotime(dgmdate(TIMESTAMP, 'Ymd'));
             $inuids = $uids ? ' AND uid IN (' . dimplode($uids) . ')' : '';
             $items = $items * 5;
             $query = DB::query('SELECT uid, count(*) as sum FROM ' . DB::table('common_member_action_log') . "\r\n\t\t\t\t\t\tWHERE dateline>={$todaytime} AND action='" . getuseraction('pid') . "'{$inuids} GROUP BY uid ORDER BY sum DESC LIMIT {$items}");
             while ($value = DB::fetch($query)) {
                 $todayposts[$value['uid']] = $value['sum'];
                 $todayuids[] = $value['uid'];
             }
             if (empty($todayuids)) {
                 $todayuids = array(0);
             }
             $uids = $todayuids;
             break;
     }
     if ($uids) {
         $wheres[] = 'm.uid IN (' . dimplode($uids) . ')';
     }
     $wheres[] = '(m.groupid < 4 OR m.groupid > 8)';
     $tables = array_unique($tables);
     $wheres = array_unique($wheres);
     $tablesql = implode(',', $tables);
     $wheresql = implode(' AND ', $wheres);
     $query = DB::query("SELECT m.*, mc.*{$reason}{$show} FROM {$tablesql} WHERE {$wheresql} {$sqlorderby} LIMIT {$startrow},{$items}");
     $resultuids = array();
     while ($data = DB::fetch($query)) {
         $resultuids[] = intval($data['uid']);
         $list[] = array('id' => $data['uid'], 'idtype' => 'uid', 'title' => $data['username'], 'url' => 'home.php?mod=space&uid=' . $data['uid'], 'pic' => '', 'picflag' => 0, 'summary' => '', 'fields' => array('avatar' => avatar($data['uid'], 'small', true, false, false, $_G['setting']['ucenterurl']), 'avatar_middle' => avatar($data['uid'], 'middle', true, false, false, $_G['setting']['ucenterurl']), 'avatar_big' => avatar($data['uid'], 'big', true, false, false, $_G['setting']['ucenterurl']), 'credits' => $data['credits'], 'extcredits1' => $data['extcredits1'], 'extcredits2' => $data['extcredits2'], 'extcredits3' => $data['extcredits3'], 'extcredits4' => $data['extcredits4'], 'extcredits5' => $data['extcredits5'], 'extcredits6' => $data['extcredits6'], 'extcredits7' => $data['extcredits7'], 'extcredits8' => $data['extcredits8'], 'regdate' => $data['regdate'], 'posts' => empty($todayposts[$data['uid']]) ? $data['posts'] : $todayposts[$data['uid']], 'threads' => $data['threads'], 'digestposts' => $data['digestposts'], 'reason' => isset($data['reason']) ? $data['reason'] : '', 'unitprice' => isset($data['unitprice']) ? $data['unitprice'] : '', 'showcredit' => isset($data['showcredit']) ? $data['showcredit'] : '', 'shownote' => isset($data['shownote']) ? $data['shownote'] : ''));
     }
     if ($resultuids) {
         include_once libfile('function/profile');
         $profiles = array();
         $query = DB::query('SELECT * FROM ' . DB::table('common_member_profile') . " WHERE uid IN (" . dimplode($resultuids) . ")");
         while ($data = DB::fetch($query)) {
             $profile = array();
             foreach ($data as $fieldid => $fieldvalue) {
                 $fieldvalue = profile_show($fieldid, $data);
                 if (false !== $fieldvalue) {
                     $profile[$fieldid] = $fieldvalue;
                 }
             }
             $profiles[$data['uid']] = $profile;
         }
         for ($i = 0, $L = count($list); $i < $L; $i++) {
             $uid = $list[$i]['id'];
             if ($profiles[$uid]) {
                 $list[$i]['fields'] = array_merge($list[$i]['fields'], $profiles[$uid]);
             }
         }
         if (!empty($todayuids)) {
             $datalist = array();
             foreach ($todayuids as $uid) {
                 foreach ($list as $user) {
                     if ($user['id'] == $uid) {
                         $datalist[] = $user;
                         break;
                     }
                 }
                 if (count($datalist) >= $olditems) {
                     break;
                 }
             }
             $list = $datalist;
         }
     }
     return array('html' => '', 'data' => $list);
 }
示例#5
0
function addguestfile($offset)
{
    global $timestamp, $onlineip, $tid, $fid, $wind_in, $db_olsize;
    if (strlen($fid) > 4) {
        $fidwt = '';
    } else {
        $fidwt = $fid;
    }
    if (strlen($tid) > 7) {
        $tidwt = '';
    } else {
        $tidwt = $tid;
    }
    $wherebbsyou = getuseraction($fid, $wind_in);
    $acttime = get_date($timestamp, 'm-d H:i');
    $newonline = "{$onlineip}\t{$timestamp}\t<FiD>{$fidwt}\t{$tidwt}\t{$wherebbsyou}\t{$acttime}\t";
    //<FiD>主要用于thread.php里快速找到指定的版块游客
    $newonline = str_pad($newonline, $db_olsize) . "\n";
    $D_name = "data/bbscache/guest.php";
    if (!file_exists(D_P . $D_name)) {
        pwCache::setData(D_P . $D_name, str_pad("<?php die;?>", 96) . "\n");
    }
    if (checkinline(D_P . $D_name, $offset, $onlineip)) {
        $isModify = 0;
        writeinline(D_P . $D_name, $newonline, $offset);
    } else {
        list($offset, $isModify) = GetInsertOffset(D_P . $D_name);
        writeinline(D_P . $D_name, $newonline, $offset);
    }
    if ($isModify === 1) {
        //频度可控制性
        ModifySelectFile(D_P . "data/bbscache/online.php");
        if ($GLOBALS['userinbbs'] === 0) {
            $GLOBALS['userinbbs']--;
            ModifySelectFile(D_P . $D_name, 1);
        }
    }
    return array($offset, $isModify);
}
 public function count_per_hour($uid, $type)
 {
     return DB::result_first('SELECT COUNT(*) FROM %t WHERE dateline>%d AND `action`=%d AND uid=%d', array($this->_table, TIMESTAMP - 3600, getuseraction($type), $uid));
 }
示例#7
0
function useractionlog($uid, $action)
{
    $uid = intval($uid);
    if (empty($uid) || empty($action)) {
        return false;
    }
    $action = getuseraction($action);
    $timestamp = TIMESTAMP;
    DB::query("INSERT INTO " . DB::table('common_member_action_log') . " (`uid`, `action`, `dateline`) VALUES ('{$uid}', '{$action}', '{$timestamp}')");
    return true;
}