function poll_upload() { global $_G; $this->uid = intval($_G['gp_uid']); $swfhash = md5(substr(md5($_G['config']['security']['authkey']), 8) . $this->uid); if (!$_FILES['Filedata']['error'] && $_G['gp_hash'] == $swfhash && $this->uid) { $this->aid = 0; $this->simple = 0; $this->user = getuserbyuid($this->uid); if (empty($this->user['adminid'])) { $this->uploadmsg(9); } $_G['uid'] = $this->uid; $this->pollid = !empty($_G['gp_pollid']) ? intval($_G['gp_pollid']) : 0; if ($this->pollid <= 0 || !intval(DB::result_first("SELECT contenttype FROM " . DB::table('poll_item') . " WHERE itemid='{$this->pollid}'"))) { $this->uploadmsg(9); } $attach = upload_images($_FILES['Filedata'], 'poll', 176, 176); $caption = dhtmlspecialchars(trim($attach['name'])); $caption = substr($caption, 0, -(strlen(fileext($caption)) + 1)); $data = array('itemid' => $this->pollid, 'caption' => $caption, 'displayorder' => 0, 'imageurl' => $attach['attachment'], 'aid' => $attach['aid']); DB::insert('poll_choice', $data); $this->aid = $this->pollid; $this->uploadmsg(0); } }
public function count_by_ip_dateline($ctrlip, $dateline) { if (!empty($ctrlip)) { return DB::result_first('SELECT COUNT(*) FROM %t WHERE ' . DB::field('ip', $ctrlip, 'like') . ' AND count=-1 AND dateline>%d LIMIT 1', array($this->_table, $dateline)); } return 0; }
function get_subject_by_tid($tid) { $sql = 'select subject from %t where tid=%d'; $array1 = array('forum_thread', $tid); $data = DB::result_first($sql, $array1); return $data; }
public function count_by_search($tid = null, $pid = null, $authorid = null, $starttime = null, $endtime = null, $ip = null, $message = null) { $sql = ''; $tid && ($sql .= ' AND ' . DB::field('tid', $tid)); $pid && ($sql .= ' AND ' . DB::field('pid', $pid)); $authorid && ($sql .= ' AND ' . DB::field('authorid', $authorid)); $starttime && ($sql .= ' AND ' . DB::field('dateline', $starttime, '>=')); $endtime && ($sql .= ' AND ' . DB::field('dateline', $endtime, '<')); $ip && ($sql .= ' AND ' . DB::field('useip', str_replace('*', '%', $ip), 'like')); if ($message) { $sqlmessage = ''; $or = ''; $message = explode(',', str_replace(' ', '', $message)); for ($i = 0; $i < count($message); $i++) { if (preg_match("/\\{(\\d+)\\}/", $message[$i])) { $message[$i] = preg_replace("/\\\\{(\\d+)\\\\}/", ".{0,\\1}", preg_quote($message[$i], '/')); $sqlmessage .= " {$or} comment REGEXP '" . $message[$i] . "'"; } else { $sqlmessage .= " {$or} " . DB::field('comment', '%' . $message[$i] . '%', 'like'); } $or = 'OR'; } $sql .= " AND ({$sqlmessage})"; } return DB::result_first('SELECT COUNT(*) FROM %t WHERE authorid>-1 %i', array($this->_table, $sql)); }
function usesubmit() { global $_G; if (empty($_G['gp_tid'])) { showmessage(lang('magic/sofa', 'sofa_info_nonexistence')); } $thread = getpostinfo($_G['gp_tid'], 'tid', array('fid', 'authorid', 'dateline', 'subject')); $this->_check($thread); $firstsofa = DB::result_first("SELECT COUNT(*) FROM " . DB::table('forum_threadmod') . " WHERE magicid='" . $this->magic['magicid'] . "' AND tid='{$_G['gp_tid']}'"); if ($firstsofa >= 1) { showmessage(lang('magic/sofa', 'sofa_info_sofaexistence'), '', array(), array('login' => 1)); } $sofamessage = lang('magic/sofa', 'sofa_text', array('actor' => $_G['member']['username'], 'time' => dgmdate(TIMESTAMP), 'magicname' => $this->magic['name'])); $dateline = $thread['dateline'] + 1; insertpost(array('fid' => $thread['fid'], 'tid' => $_G['gp_tid'], 'first' => '0', 'author' => $_G['username'], 'authorid' => $_G['uid'], 'dateline' => $dateline, 'message' => $sofamessage, 'useip' => $_G['clientip'], 'usesig' => '1')); DB::query("UPDATE " . DB::table('forum_thread') . " SET replies=replies+1, moderated='1' WHERE tid='{$_G['tid']}'", 'UNBUFFERED'); DB::query("UPDATE " . DB::table('forum_forum') . " SET posts=posts+1, todayposts=todayposts+1 WHERE fid='{$post['fid']}'", 'UNBUFFERED'); usemagic($this->magic['magicid'], $this->magic['num']); updatemagiclog($this->magic['magicid'], '2', '1', '0', 0, 'tid', $_G['gp_tid']); updatemagicthreadlog($_G['gp_tid'], $this->magic['magicid']); if ($thread['authorid'] != $_G['uid']) { notification_add($thread['authorid'], 'magic', lang('magic/sofa', 'sofa_notification'), array('tid' => $_G['gp_tid'], 'subject' => $thread['subject'], 'magicname' => $this->magic['name'])); } showmessage(lang('magic/sofa', 'sofa_succeed'), dreferer(), array(), array('showdialog' => 1, 'locationtime' => 1)); }
function build_cache_usergroups_single() { $pluginvalue = pluginsettingvalue('groups'); $allowthreadplugin = unserialize(DB::result_first("SELECT svalue FROM " . DB::table('common_setting') . " WHERE skey='allowthreadplugin'")); $query = DB::query("SELECT * FROM " . DB::table('common_usergroup') . " u\r\n\t\tLEFT JOIN " . DB::table('common_usergroup_field') . " uf ON u.groupid=uf.groupid\r\n\t\tLEFT JOIN " . DB::table('common_admingroup') . " a ON u.groupid=a.admingid"); while ($data = DB::fetch($query)) { $ratearray = array(); if ($data['raterange']) { foreach (explode("\n", $data['raterange']) as $rating) { $rating = explode("\t", $rating); $ratearray[$rating[0]] = array('isself' => $rating[1], 'min' => $rating[2], 'max' => $rating[3], 'mrpd' => $rating[4]); } } $data['raterange'] = $ratearray; $data['grouptitle'] = $data['color'] ? '<font color="' . $data['color'] . '">' . $data['grouptitle'] . '</font>' : $data['grouptitle']; $data['grouptype'] = $data['type']; $data['grouppublic'] = $data['system'] != 'private'; $data['groupcreditshigher'] = $data['creditshigher']; $data['groupcreditslower'] = $data['creditslower']; $data['maxspacesize'] = intval($data['maxspacesize']) * 1024 * 1024; $data['allowthreadplugin'] = !empty($allowthreadplugin[$data['groupid']]) ? $allowthreadplugin[$data['groupid']] : array(); $data['plugin'] = $pluginvalue[$data['groupid']]; unset($data['type'], $data['system'], $data['creditshigher'], $data['creditslower'], $data['groupavatar'], $data['admingid']); save_syscache('usergroup_' . $data['groupid'], $data); } }
function DoList() { $qid = intval($this->Get['qid']); if (!$qid) { widget_error('Id is empty', 102); } $page = intval($this->Get['page']); $page_size = intval($this->Get['page_size']); $page_size = $page_size == 0 ? 10 : $page_size; if (!$this->QunLogic->is_exists($qid)) { widget_error('Id is invalid', 103); } $where_sql = " tq.item_id='{$qid}' "; $order_sql = " t.dateline DESC "; $total_record = DB::result_first("SELECT COUNT(*)\r\n\t\t\t\t\t\t\t\t \t\t FROM " . DB::table('topic') . " AS t\r\n\t\t\t\t\t\t\t\t \t\t LEFT JOIN " . DB::table('topic_qun') . " AS tq\r\n\t\t\t\t\t\t\t\t \t\t USING(tid)\r\n\t\t\t\t\t\t\t\t \t\t WHERE {$where_sql}"); if ($total_record > 0) { $page_arr = $this->_page($total_record, $page_size); $query = DB::query("SELECT t.*\r\n\t\t\t\t\t\t\t\tFROM " . DB::table('topic') . " AS t\r\n\t\t\t\t\t\t\t\tLEFT JOIN " . DB::table('topic_qun') . " AS tq\r\n\t\t\t\t\t\t\t\tUSING(tid)\r\n\t\t\t\t\t\t\t\tWHERE {$where_sql}\r\n\t\t\t\t\t\t\t\tORDER BY {$order_sql}\r\n\t\t\t\t\t\t\t\tLIMIT {$page_arr['offset']},{$page_arr['limit']}"); $topic_list = array(); while ($value = DB::fetch($query)) { $topic_list[] = $value; } $topic_list = $this->TopicLogic->MakeAll($topic_list); $data = array('total_record' => $total_record, 'topic_list' => $topic_list, 'page_arr' => $page_arr); widget_output($data); } else { widget_error('List is empty', 104); } }
public function count_by_uid($uid, $new, $type = '') { $new = intval($new); $type = $type ? ' AND ' . DB::field('type', $type) : ''; $new = ' AND ' . DB::field('new', $new); return DB::result_first("SELECT COUNT(*) FROM %t WHERE uid=%d %i %i", array($this->_table, $uid, $type, $new)); }
public function insert_by_sid($arr) { $arr['uid'] = getglobal('uid'); $arr['username'] = getglobal('username'); $arr['status'] = 0; if (empty($arr['path'])) { return false; } $sid = self::getSid($arr['path'] . '&uid=' . getglobal('uid')); if (DB::result_first("select COUNT(*) from %t where sid=%s", array($this->_table, $sid))) { parent::update($sid, $arr); if (!is_file(getglobal('setting/attachurl') . './qrcode/' . $sid[0] . '/' . $sid . '.png')) { self::getQRcodeBySid($sid); } return array('sid' => $sid, 'shareurl' => getglobal('siteurl') . 's.php?sid=' . $sid, 'qrcode' => getglobal('setting/attachurl') . './qrcode/' . $sid[0] . '/' . $sid . '.png'); } else { $arr['sid'] = $sid; $arr['dateline'] = TIMESTAMP; if (parent::insert($arr, 1, 1)) { self::getQRcodeBySid($sid); return array('sid' => $sid, 'shareurl' => getglobal('siteurl') . 's.php?sid=' . $sid, 'qrcode' => getglobal('setting/attachurl') . './qrcode/' . $sid[0] . '/' . $sid . '.png'); } } return false; }
function build_cache_stamps() { $data = array(); $query = DB::query("SELECT id, url, displayorder FROM " . DB::table('common_smiley') . " WHERE type IN ('stamp','stamplist') ORDER BY displayorder"); $fillarray = range(0, 99); $count = 0; $repeats = $stampicon = array(); while ($stamp = DB::fetch($query)) { if (isset($fillarray[$stamp['displayorder']])) { unset($fillarray[$stamp['displayorder']]); } else { $repeats[] = $stamp['id']; } $count++; } foreach ($repeats as $id) { reset($fillarray); $displayorder = current($fillarray); unset($fillarray[$displayorder]); DB::query("UPDATE " . DB::table('common_smiley') . " SET displayorder='{$displayorder}' WHERE id='{$id}'"); } $query = DB::query("SELECT typeid, displayorder FROM " . DB::table('common_smiley') . " WHERE type='stamplist' AND typeid>'0' ORDER BY displayorder"); while ($stamp = DB::fetch($query)) { $stamporder = DB::result_first("SELECT displayorder FROM " . DB::table('common_smiley') . " WHERE id='{$stamp['typeid']}' AND type='stamp'"); $stampicon[$stamporder] = $stamp['displayorder']; } $query = DB::query("SELECT * FROM " . DB::table('common_smiley') . " WHERE type IN ('stamp','stamplist') ORDER BY displayorder"); while ($stamp = DB::fetch($query)) { $icon = $stamp['type'] == 'stamp' ? isset($stampicon[$stamp['displayorder']]) ? $stampicon[$stamp['displayorder']] : 0 : ($stamp['type'] == 'stamplist' && !in_array($stamp['displayorder'], $stampicon) ? 1 : 0); $data[$stamp['displayorder']] = array('url' => $stamp['url'], 'text' => $stamp['code'], 'type' => $stamp['type'], 'icon' => $icon); } save_syscache('stamps', $data); }
function usesubmit() { global $_G; if (empty($_G['gp_pid'])) { showmessage(lang('magic/repent', 'repent_info_nonexistence')); } $_G['tid'] = $_G['gp_ptid']; $post = getpostinfo($_G['gp_pid'], 'pid', array('p.first', 'p.tid', 'p.fid', 'p.authorid', 'p.replycredit', 't.status as thread_status')); $this->_check($post); require_once libfile('function/post'); require_once libfile('function/delete'); if ($post['first']) { if ($have_replycredit = DB::fetch_first("SELECT * FROM " . DB::table('forum_replycredit') . " WHERE tid ='{$post['tid']}' LIMIT 1")) { if ($replycredit = DB::result_first("SELECT replycredit FROM " . DB::table('forum_thread') . " WHERE tid = '{$post['tid']}'")) { updatemembercount($post['authorid'], array($_G['setting']['creditstransextra'][10] => $replycredit)); } DB::delete('forum_replycredit', "tid = '{$post['tid']}'"); DB::delete('common_credit_log', "operation IN ('RCT', 'RCA', 'RCB') AND relatedid IN({$post['tid']})"); } deletethread(array($post['tid'])); updateforumcount($post['fid']); } else { if ($post['replycredit'] > 0) { updatemembercount($post['authorid'], array($_G['setting']['creditstransextra'][10] => -$post['replycredit'])); DB::delete('common_credit_log', "uid = '{$post['authorid']}' AND operation = 'RCA' AND relatedid IN({$post['tid']})"); } deletepost(array($_G['gp_pid'])); updatethreadcount($post['tid']); } usemagic($this->magic['magicid'], $this->magic['num']); updatemagiclog($this->magic['magicid'], '2', '1', '0', 0, 'tid', $_G['tid']); showmessage(lang('magic/repent', 'repent_succeed'), $post['first'] ? 'forum.php?mod=forumdisplay&fid=' . $post['fid'] : dreferer(), array(), array('showdialog' => 1, 'locationtime' => true)); }
function on_load() { if ($_GET['action'] != 'register') { return; } if (!$_POST) { return; } list($a, $b, $c, $d) = explode('.', $_SERVER['REMOTE_ADDR']); $a = intval($a); $b = intval($b); $c = intval($c); $d = intval($d); $count = DB::result_first("SELECT count FROM kk_ip_limit WHERE a='{$a}' AND b='{$b}' AND c='{$c}' AND d='{$d}'"); $time = TIMESTAMP; DB::query("DELETE FROM kk_ip_limit WHERE lastact<{$time}-86400"); if ($count > 0) { DB::query("UPDATE kk_ip_limit SET lastact='{$time}' WHERE a='{$a}' AND b='{$b}' AND c='{$c}' AND d='{$d}'"); } if ($count >= getSetting('ip_reglimit')) { showmessage('达到单 IP 注册上限,禁止注册。', dreferer()); } if ($count > 0) { DB::query("UPDATE kk_ip_limit SET count=count+1 WHERE a='{$a}' AND b='{$b}' AND c='{$c}' AND d='{$d}'"); } else { DB::query("INSERT INTO kk_ip_limit SET count=1, lastact='{$time}', a='{$a}', b='{$b}', c='{$c}', d='{$d}'"); } }
public function count_by_uid($uid) { if (!$uid) { return null; } return DB::result_first('SELECT count(*) FROM %t WHERE %i', array($this->_table, DB::field('uid', $uid))); }
function usesubmit() { global $_G; if (empty($_G['gp_pid'])) { showmessage(lang('magic/namepost', 'namepost_info_nonexistence')); } $_G['tid'] = $_G['gp_ptid']; $post = getpostinfo($_G['gp_pid'], 'pid', array('p.first', 'p.tid', 'p.fid', 'p.authorid', 'p.dateline', 'p.anonymous')); $this->_check($post); $query = DB::query("SELECT username FROM " . DB::table('common_member') . " WHERE uid='{$post['authorid']}'"); $author = daddslashes(DB::result($query, 0), 1); $thread = getpostinfo($post['tid'], 'tid', array('tid', 'subject', 'author', 'replies', 'lastposter')); $posttable = getposttablebytid($post['tid']); if ($post['first']) { $lastposter = $thread['replies'] > 0 ? $thread['lastposter'] : $author; DB::query("UPDATE " . DB::table($posttable) . " SET anonymous='0' WHERE tid='{$post['tid']}' AND first='1'"); } else { $lastposter = $author; $author = $thread['author']; DB::query("UPDATE " . DB::table($posttable) . " SET anonymous='0' WHERE pid='{$_G['gp_pid']}'"); } $forum['lastpost'] = explode("\t", DB::result_first("SELECT lastpost FROM " . DB::table('forum_forum') . " WHERE fid='{$post['fid']}'")); if ($thread['subject'] == $forum['lastpost'][1] && ($forum['lastpost'][3] == '' && $post['anonymous'])) { $lastpost = "{$thread['tid']}\t{$thread['subject']}\t{$_G['timestamp']}\t{$lastposter}"; DB::query("UPDATE " . DB::table('forum_forum') . " SET lastpost='{$lastpost}' WHERE fid='{$post['fid']}'", 'UNBUFFERED'); } DB::query("UPDATE " . DB::table('forum_thread') . " SET author='{$author}', lastposter='{$lastposter}' WHERE tid='{$post['tid']}'"); usemagic($this->magic['magicid'], $this->magic['num']); updatemagiclog($this->magic['magicid'], '2', '1', '0', 0, 'tid', $_G['gp_tid']); if ($post['authorid'] != $_G['uid']) { notification_add($post['authorid'], 'magic', lang('magic/namepost', 'namepost_notification'), array('pid' => $_G['gp_pid'], 'tid' => $_G['gp_tid'], 'subject' => $thread['subject'], 'magicname' => $this->magic['name'])); } showmessage(lang('magic/namepost', 'namepost_succeed'), dreferer(), array(), array('showdialog' => 1, 'locationtime' => true)); }
public function fetch_all_by_type($type, $keyword = '', $available = 0, $limit = 0, $iscount) { $limitsql = ''; if ($limit) { $limit = explode('-', $limit); if (count($limit) > 1) { $limitsql .= " limit " . intval($limit[0]) . "," . intval($limit[1]); } else { $limitsql .= " limit " . intval($limit[0]); } } $sql = ''; $param = array($this->_table, $type); if ($available) { $sql .= " and available>0"; } if ($keyword) { $sql .= ' and tpname like %s'; $param[] = '%' . $keyword . '%'; } if ($iscount) { return DB::result_first("SELECT COUNT(*) from %t WHERE type=%s {$sql}", $param); } return DB::fetch_all("SELECT tpid,tpname,type,dateline,disp,available FROM %t WHERE type=%s {$sql} ORDER BY disp {$limitsql}", $param); }
function updategroupcreditlog($fid, $uid) { global $_G; if (empty($fid) || empty($uid)) { return false; } $today = date('Ymd', TIMESTAMP); $updategroupcredit = getcookie('groupcredit_' . $fid); if ($updategroupcredit < $today) { $status = DB::result_first("SELECT logdate FROM " . DB::table('forum_groupcreditslog') . " WHERE fid='{$fid}' AND uid='{$uid}' AND logdate='{$today}'"); if (empty($status)) { DB::query("UPDATE " . DB::table('forum_forum') . " SET commoncredits=commoncredits+1 WHERE fid='{$fid}'"); DB::query("REPLACE INTO " . DB::table('forum_groupcreditslog') . " (fid, uid, logdate) VALUES ('{$fid}', '{$uid}', '{$today}')"); if (empty($_G['forum']) || empty($_G['forum']['level'])) { $forum = DB::fetch_first("SELECT name, level, commoncredits FROM " . DB::table('forum_forum') . " WHERE fid='{$fid}'"); } else { $_G['forum']['commoncredits']++; $forum =& $_G['forum']; } if (empty($_G['grouplevels'])) { loadcache('grouplevels'); } $grouplevel = $_G['grouplevels'][$forum['level']]; if ($grouplevel['type'] == 'default' && !($forum['commoncredits'] >= $grouplevel['creditshigher'] && $forum['commoncredits'] < $grouplevel['creditslower'])) { $levelid = DB::result_first("SELECT levelid FROM " . DB::table('forum_grouplevel') . " WHERE type='default' AND creditshigher<='{$forum['commoncredits']}' AND creditslower>'{$forum['commoncredits']}' LIMIT 1"); if (!empty($levelid)) { DB::query("UPDATE " . DB::table('forum_forum') . " SET level='{$levelid}' WHERE fid='{$fid}'"); $groupfounderuid = DB::result_first("SELECT founderuid FROM " . DB::table('forum_forumfield') . " WHERE fid='{$fid}' LIMIT 1"); notification_add($groupfounderuid, 'system', 'grouplevel_update', array('groupname' => '<a href="forum.php?mod=group&fid=' . $fid . '">' . $forum['name'] . '</a>', 'newlevel' => $_G['grouplevels'][$levelid]['leveltitle'])); } } } dsetcookie('groupcredit_' . $fid, $today, 86400); } }
public function count_by_access($access) { if (!is_numeric($access) && !is_array($access)) { return 0; } return DB::result_first('SELECT COUNT(*) FROM %t WHERE ' . DB::field('access', $access), array($this->_table)); }
public function count_by_fid($fids) { if (empty($fids)) { return 0; } return DB::result_first('SELECT COUNT(*) FROM %t WHERE ' . DB::field('fid', $fids), array($this->_table)); }
public function fetch_groupnum_by_founderuid($uid) { if (empty($uid)) { return false; } return DB::result_first("SELECT COUNT(*) FROM " . DB::table($this->_table) . " WHERE founderuid=%d", array($uid)); }
public function sum_amount_by_uid_submitdate_status($uid, $submitdate, $status) { if (empty($status)) { return 0; } return DB::result_first('SELECT SUM(amount) FROM %t WHERE uid=%d AND submitdate>=%d AND ' . DB::field('status', $status), array($this->_table, $uid, $submitdate)); }
function csc($task = array()) { global $_G; $taskvars = array('num' => 0); $num = 0; $query = DB::query("SELECT variable, value FROM " . DB::table('common_taskvar') . " WHERE taskid='{$task['taskid']}'"); while ($taskvar = DB::fetch($query)) { if ($taskvar['value']) { $taskvars[$taskvar['variable']] = $taskvar['value']; } } $taskvars['time'] = floatval($taskvars['time']); if ($taskvars['act'] == 'buddy') { loaducenter(); $num = uc_friend_totalnum($_G['uid'], 1) + uc_friend_totalnum($_G['uid'], 3) - DB::result_first("SELECT value FROM " . DB::table('forum_spacecache') . " WHERE uid='{$_G['uid']}' AND variable='buddy{$task['taskid']}'"); } elseif ($taskvars['act'] == 'magic') { $num = DB::result_first("SELECT COUNT(*) FROM " . DB::table('forum_magiclog') . " WHERE action='2' AND uid='{$_G['uid']}'" . ($taskvars['time'] ? " AND dateline BETWEEN {$task['applytime']} AND {$task['applytime']}+3600*{$taskvars['time']}" : " AND dateline>{$task['applytime']}")); } if ($num && $num >= $taskvars['num']) { if (in_array($taskvars['act'], array('buddy', 'favorite'))) { DB::query("DELETE FROM " . DB::table('forum_spacecache') . " WHERE uid='{$_G['uid']}' AND variable='{$taskvars['act']}{$task['taskid']}'"); } return TRUE; } elseif ($taskvars['time'] && TIMESTAMP >= $task['applytime'] + 3600 * $taskvars['time'] && (!$num || $num < $taskvars['num'])) { return FALSE; } else { return array('csc' => $num > 0 && $taskvars['num'] ? sprintf("%01.2f", $num / $taskvars['num'] * 100) : 0, 'remaintime' => $taskvars['time'] ? $task['applytime'] + $taskvars['time'] * 3600 - TIMESTAMP : 0); } }
function cleartaskstatus() { global $_G; if (!DB::result_first("SELECT COUNT(*) FROM " . DB::table('common_mytask') . " WHERE uid='{$_G['uid']}' AND status='0'")) { dsetcookie('taskdoing_' . $_G['uid']); } }
function index() { $per_page_num = min(500, max(20, (int) (isset($_GET['pn']) ? $_GET['pn'] : $_GET['per_page_num']))); $gets = array('mod' => 'recdtopic', 'pn' => $this->Get['pn'], 'per_page_num' => $this->Get['per_page_num'], 'keyword' => $this->Get['keyword'], 'nickname' => $this->Get['nickname']); $page_url = 'admin.php?' . url_implode($gets); $where_sql = ' 1 AND tr.tid>0 '; $keyword = trim($this->Get['keyword']); if ($keyword) { $_GET['highlight'] = $keyword; $where_sql .= " AND " . build_like_query('t.content,t.content2', $keyword) . " "; } $nickname = trim($this->Get['nickname']); if ($nickname) { $sql = "select `username`,`nickname` from `" . TABLE_PREFIX . "members` where `nickname`='{$nickname}' limit 0,1"; $query = $this->DatabaseHandler->Query($sql); $members = $query->GetRow(); $where_sql .= " AND `username`='{$members['username']}' "; } $count = DB::result_first("SELECT COUNT(*)\r\n\t\t\t\t\t\t\t\t FROM " . DB::table('topic') . " AS t\r\n\t\t\t\t\t\t\t\t LEFT JOIN " . DB::table('topic_recommend') . " AS tr\r\n\t\t\t\t\t\t\t\t ON t.tid=tr.tid\r\n\t\t\t\t\t\t\t\t WHERE {$where_sql}"); $topic_list = array(); if ($count) { $page_arr = page($count, $per_page_num, $page_url, array('return' => 'array')); $query = DB::query("SELECT t.*,tr.dateline AS recd_time,tr.expiration,tr.r_nickname\r\n\t\t\t\t\t\t\t\tFROM " . DB::table('topic') . " AS t\r\n\t\t\t\t\t\t\t\tLEFT JOIN " . DB::table('topic_recommend') . " AS tr\r\n\t\t\t\t\t\t\t\tON t.tid=tr.tid\r\n\t\t\t\t\t\t\t\tWHERE {$where_sql}\r\n\t\t\t\t\t\t\t\tORDER BY tr.dateline DESC\r\n\t\t\t\t\t\t\t\t{$page_arr['limit']} "); while ($value = DB::fetch($query)) { $value['recd_time'] = my_date_format2($value['recd_time']); $topic_list[] = $value; } $topic_list = $this->TopicLogic->MakeAll($topic_list); } include template('admin/recdtopic'); }
function userlogin($username, $password, $questionid, $answer, $loginfield = 'username') { $return = array(); if ($loginfield == 'uid') { $isuid = 1; } elseif ($loginfield == 'email') { $isuid = 2; } elseif ($loginfield == 'auto') { $isuid = 3; } else { $isuid = 0; } if (!function_exists('uc_user_login')) { loaducenter(); } if ($isuid == 3) { if (preg_match('/^[1-9]\\d*$/', $username)) { $return['ucresult'] = uc_user_login($username, $password, 1, 1, $questionid, $answer); } elseif (isemail($username)) { $return['ucresult'] = uc_user_login($username, $password, 2, 1, $questionid, $answer); } if ($return['ucresult'][0] <= 0) { $return['ucresult'] = uc_user_login($username, $password, 0, 1, $questionid, $answer); } } else { $return['ucresult'] = uc_user_login($username, $password, $isuid, 1, $questionid, $answer); } $tmp = array(); $duplicate = ''; list($tmp['uid'], $tmp['username'], $tmp['password'], $tmp['email'], $duplicate) = daddslashes($return['ucresult'], 1); $return['ucresult'] = $tmp; if ($duplicate && $return['ucresult']['uid'] > 0) { if ($olduid = DB::result_first("SELECT uid FROM " . DB::table('common_member') . " WHERE username='******'ucresult']['username']) . "'")) { require_once libfile('function/membermerge'); if ($olduid != $return['ucresult']['uid']) { membermerge($olduid, $return['ucresult']['uid']); } uc_user_merge_remove($return['ucresult']['username']); } else { $return['status'] = 0; return $return; } } if ($return['ucresult']['uid'] <= 0) { $return['status'] = 0; return $return; } $member = DB::fetch_first("SELECT * FROM " . DB::table('common_member') . " WHERE uid='" . $return['ucresult']['uid'] . "'"); if (!$member) { $return['status'] = -1; return $return; } $return['member'] = $member; $return['status'] = 1; if (addslashes($member['email']) != $return['ucresult']['email']) { DB::query("UPDATE " . DB::table('common_member') . " SET email='" . $return['ucresult']['email'] . "' WHERE uid='" . $return['ucresult']['uid'] . "'"); } return $return; }
public function fetch_by_mkcount($mokuai) { $mokuai_count = 0; if ($mokuai) { $mokuai_count = DB::result_first('SELECT count(*) FROM %t WHERE biaoshi=%s', array($this->_table, $mokuai)); } return $mokuai_count; }
public function count_by_field($field, $val, $glue = '=') { $allowedfield = array('allowposttrade'); if (!in_array($field, $allowedfield)) { return null; } return DB::result_first('SELECT count(*) FROM %t WHERE %i', array($this->_table, DB::field($field, $val, $glue))); }
public function count_by_email($email) { $count = 0; if ($email) { $count = DB::result_first('SELECT COUNT(*) FROM %t WHERE email=%s', array($this->_table, $email)); } return $count; }
public function count_by_field($field, $val) { $count = 0; if (in_array($field, $this->_fields, true)) { $count = DB::result_first('SELECT COUNT(*) as cnt FROM ' . DB::table('common_member_profile') . ' WHERE ' . DB::field($field, $val)); } return $count; }
public function update($time, $num) { if (DB::fetch_first('SELECT 1 FROM %t WHERE ctime=%d LIMIT 1', array($this->_table, $time))) { return DB::query('UPDATE %t SET urlnum=urlnum+%d, urlcount=urlcount+%d WHERE ctime=%d', array($this->_table, $num, $num, $time)); } $precount = DB::result_first('SELECT urlcount FROM %t ORDER BY ctime DESC LIMIT 1', array($this->_table)); return DB::query('INSERT INTO %t(ctime, urlnum, urlcount) values(%d, %d, %d)', array($this->_table, $time, $num, $precount+$num)); }
public function check_exists($uid, $daytime, $type) { $setarr = array('uid' => intval($uid), 'daytime' => intval($daytime), 'type' => $type); if (DB::result_first('SELECT COUNT(*) FROM ' . DB::table($this->_table) . ' WHERE ' . DB::implode_field_value($setarr, ' AND '))) { return true; } else { return false; } }