First commit

This commit is contained in:
2025-06-18 10:24:27 +08:00
commit ebc39cd5dd
3873 changed files with 412712 additions and 0 deletions

View File

View File

@@ -0,0 +1,59 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_admincp_cmenu.php 27806 2012-02-15 03:20:46Z svn_project_zhangjie $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_admincp_cmenu extends discuz_table
{
public function __construct() {
$this->_table = 'common_admincp_cmenu';
$this->_pk = 'id';
parent::__construct();
}
public function count_by_uid($uid) {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE uid=%d AND sort=1', array($this->_table, $uid));
}
public function fetch_all_by_uid($uid, $start = 0, $limit = 0) {
return DB::fetch_all('SELECT * FROM %t WHERE uid=%d AND sort=1 ORDER BY displayorder, dateline DESC, clicks DESC '.DB::limit($start, $limit),
array($this->_table, $uid));
}
public function delete($val, $unbuffered = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::delete($val, $unbuffered);
} else {
return $this->delete_cmenu($val, $unbuffered);
}
}
public function delete_cmenu($id, $uid = 0) {
if(empty($id)) {
return false;
}
return DB::query('DELETE FROM %t WHERE '.DB::field('id', $id).' %i', array($this->_table, ($uid ? ' AND '.DB::field('uid', $uid) : '')));
}
public function fetch_id_by_uid_sort_url($uid, $sort, $url) {
return DB::result_first('SELECT id FROM %t WHERE uid=%d AND sort=%d AND url=%s', array($this->_table, $uid, $sort, $url));
}
public function increase_clicks($id) {
return DB::query('UPDATE %t SET clicks=clicks+1 WHERE id=%d', array($this->_table, $id));
}
}
?>

View File

@@ -0,0 +1,29 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_admincp_group.php 27449 2012-02-01 05:32:35Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_admincp_group extends discuz_table
{
public function __construct() {
$this->_table = 'common_admincp_group';
$this->_pk = 'cpgroupid';
parent::__construct();
}
public function fetch_by_cpgroupname($name) {
return $name ? DB::fetch_first('SELECT * FROM %t WHERE cpgroupname=%s', array($this->_table, $name)) : null;
}
}
?>

View File

@@ -0,0 +1,44 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_admincp_member.php 27740 2012-02-13 10:05:22Z chenmengshu $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_admincp_member extends discuz_table
{
public function __construct() {
$this->_table = 'common_admincp_member';
$this->_pk = 'uid';
parent::__construct();
}
public function update_cpgroupid_by_cpgroupid($val, $data) {
if(!is_array($data)) {
return null;
}
return DB::update('common_admincp_member', $data, DB::field('cpgroupid', $val));
}
public function count_by_uid($uid) {
return DB::result_first("SELECT count(*) FROM %t WHERE uid=%d", array($this->_table, $uid));
}
public function fetch_all_uid_by_gid_perm($gid, $perm) {
return DB::fetch_all("SELECT uid FROM %t am LEFT JOIN %t ap ON am.cpgroupid=ap.cpgroupid WHERE am.cpgroupid=%d OR ap.perm=%s", array($this->_table, 'common_admincp_perm', $gid, $perm));
}
public function fetch_perm_by_uid_perm($uid, $perm) {
return DB::result_first("SELECT ap.perm FROM %t am LEFT JOIN %t ap ON ap.cpgroupid=am.cpgroupid WHERE am.uid=%d AND ap.perm=%s", array($this->_table, 'common_admincp_perm', $uid, $perm));
}
}
?>

View File

@@ -0,0 +1,37 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_admincp_perm.php 27773 2012-02-14 06:49:55Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_admincp_perm extends discuz_table
{
public function __construct() {
$this->_table = 'common_admincp_perm';
$this->_pk = '';
parent::__construct();
}
public function fetch_all_by_cpgroupid($cpgroupid) {
return $cpgroupid ? DB::fetch_all('SELECT * FROM %t WHERE cpgroupid=%d', array($this->_table, $cpgroupid)) : array();
}
public function delete_by_cpgroupid_perm($cpgroupid, $perm = null) {
return $cpgroupid ? DB::delete($this->_table, DB::field('cpgroupid', $cpgroupid).($perm ? ' AND '.DB::field('perm', $perm) : '')) : false;
}
public function fetch_all_by_perm($perm) {
return $perm ? DB::fetch_all('SELECT * FROM %t WHERE `perm`=%s', array($this->_table, $perm), 'cpgroupid') : array();
}
}
?>

View File

@@ -0,0 +1,73 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_admincp_session.php 27803 2012-02-15 02:39:36Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_admincp_session extends discuz_table
{
public function __construct() {
$this->_table = 'common_admincp_session';
$this->_pk = 'uid';
parent::__construct();
}
public function fetch($id, $force_from_db = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::fetch($id, $force_from_db);
} else {
return $this->fetch_session($id, $force_from_db);
}
}
public function delete($val, $unbuffered = false, $null = 3600) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::delete($val, $unbuffered);
} else {
return $this->delete_session($val, $unbuffered, $null);
}
}
public function update($val, $data, $unbuffered = false, $low_priority = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::update($val, $data, $unbuffered, $low_priority);
} else {
return $this->update_session($val, $data, $unbuffered);
}
}
public function fetch_session($uid, $panel) {
$sql = 'SELECT * FROM %t WHERE uid=%d AND panel=%d';
return DB::fetch_first($sql, array($this->_table, $uid, $panel));
}
public function fetch_all_by_panel($panel) {
return DB::fetch_all('SELECT * FROM %t WHERE panel=%d', array($this->_table, $panel), 'uid');
}
public function delete_session($uid, $panel, $ttl = 3600) {
$sql = 'DELETE FROM %t WHERE (uid=%d AND panel=%d) OR dateline<%d';
DB::query($sql, array($this->_table, $uid, $panel, TIMESTAMP-intval($ttl)));
}
public function update_session($uid, $panel, $data) {
if(!empty($data) && is_array($data)) {
DB::update($this->_table, $data, array('uid'=>$uid, 'panel'=>$panel));
}
}
}
?>

View File

@@ -0,0 +1,38 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_admingroup.php 27449 2012-02-01 05:32:35Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_admingroup extends discuz_table
{
public function __construct() {
$this->_table = 'common_admingroup';
$this->_pk = 'admingid';
parent::__construct();
}
public function fetch_all_merge_usergroup($gids = array()) {
$admingroups = empty($gids) ? $this->range() : $this->fetch_all($gids);
$data = array();
foreach(C::t('common_usergroup')->fetch_all_usergroup(array_keys($admingroups)) as $gid=>$value) {
$data[$gid] = array_merge($admingroups[$gid], $value);
}
return $data;
}
public function fetch_all_order() {
return DB::fetch_all("SELECT u.radminid, u.groupid, u.grouptitle FROM ".DB::table('common_admingroup')." a LEFT JOIN ".DB::table('common_usergroup')." u ON u.groupid=a.admingid ORDER BY u.radminid, a.admingid");
}
}
?>

View File

@@ -0,0 +1,57 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_adminnote.php 31558 2012-09-10 03:22:31Z liulanbo $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_adminnote extends discuz_table
{
public function __construct() {
$this->_table = 'common_adminnote';
$this->_pk = 'id';
parent::__construct();
}
public function delete($val, $unbuffered = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::delete($val, $unbuffered);
} else {
$unbuffered = $unbuffered === false ? '' : $unbuffered;
return $this->delete_note($val, $unbuffered);
}
}
public function delete_note($id, $admin = '') {
if(empty($id)) {
return false;
}
return DB::query('DELETE FROM %t WHERE '.DB::field('id', $id).' %i', array($this->_table, ($admin ? ' AND '.DB::field('admin', $admin) : '')));
}
public function fetch_all_by_access($access) {
if(!is_numeric($access) && !is_array($access)) {
return array();
}
return DB::fetch_all('SELECT * FROM %t WHERE '.DB::field('access', $access).' ORDER BY dateline DESC', array($this->_table));
}
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));
}
}
?>

View File

@@ -0,0 +1,72 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_advertisement.php 33658 2013-07-29 06:25:15Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_advertisement extends discuz_table
{
public function __construct() {
$this->_table = 'common_advertisement';
$this->_pk = 'advid';
parent::__construct();
}
public function fetch_all_type() {
return DB::fetch_all("SELECT type, COUNT(type) AS count FROM %t GROUP BY type", array($this->_table));
}
public function fetch_all_by_type($type) {
return DB::fetch_all("SELECT * FROM %t WHERE type=%s", array($this->_table, $type));
}
public function fetch_all_old() {
return DB::fetch_all("SELECT * FROM %t WHERE available>0 AND starttime<=%d ORDER BY displayorder", array($this->_table, TIMESTAMP));
}
public function close_endtime() {
$return = DB::result_first("SELECT COUNT(*) FROM %t WHERE endtime>0 AND endtime<='".TIMESTAMP."'", array($this->_table));
DB::update($this->_table, array('available' => 0), "endtime>0 AND endtime<='".TIMESTAMP."'", 'UNBUFFERED');
return $return;
}
public function fetch_all_endtime($endtime) {
return DB::fetch_all("SELECT * FROM %t WHERE endtime=%s", array($this->_table, $endtime));
}
private function _search_conditions($title, $starttime, $endtime, $type, $target) {
$conditions = '';
$conditions .= $title ? " AND ".DB::field('title', '%'.$title.'%', 'like') : '';
$conditions .= $starttime > 0 ? " AND starttime>='".(TIMESTAMP - intval($starttime))."'" : ($starttime == -1 ? " AND starttime='0'" : '');
$conditions .= $endtime > 0 ? " AND endtime>0 AND endtime<'".(TIMESTAMP + intval($endtime))."'" : ($endtime == -1 ? " AND endtime='0'" : '');
$conditions .= $type ? " AND ".DB::field('type', $type) : '';
$conditions .= $target ? " AND ".DB::field('targets', '%'.$target.'%', 'like') : '';
return $conditions;
}
public function fetch_all_search($title, $starttime, $endtime, $type, $target, $orderby, $start_limit, $advppp) {
$conditions = $this->_search_conditions($title, $starttime, $endtime, $type, $target);
$order_by = $orderby == 'starttime' ? 'starttime' : ($orderby == 'type' ? 'type' : ($orderby == 'displayorder' ? 'displayorder' : 'advid DESC'));
$start_limit = intval($start_limit);
$advppp = intval($advppp);
return DB::fetch_all("SELECT * FROM ".DB::table('common_advertisement')." WHERE 1 $conditions ORDER BY available DESC, $order_by LIMIT $start_limit, $advppp");
}
public function count_search($title, $starttime, $endtime, $type, $target) {
$conditions = $this->_search_conditions($title, $starttime, $endtime, $type, $target);
return DB::result_first("SELECT COUNT(*) FROM ".DB::table('common_advertisement')." WHERE 1 $conditions");
}
}
?>

View File

@@ -0,0 +1,38 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_advertisement_custom.php 27449 2012-02-01 05:32:35Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_advertisement_custom extends discuz_table
{
public function __construct() {
$this->_table = 'common_advertisement_custom';
$this->_pk = 'id';
parent::__construct();
}
public function fetch_all_data() {
return DB::fetch_all("SELECT * FROM %t ORDER BY id", array($this->_table));
}
public function fetch_by_name($name) {
return DB::fetch_first("SELECT * FROM %t WHERE name=%s", array($this->_table, $name));
}
public function get_id_by_name($name) {
$result = $this->fetch_by_name($name);
return $result['id'];
}
}
?>

View File

@@ -0,0 +1,99 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_banned.php 27876 2012-02-16 04:28:02Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_banned extends discuz_table
{
public function __construct() {
$this->_table = 'common_banned';
$this->_pk = 'id';
$this->_pre_cache_key = 'common_banned_';
$this->_cache_ttl = 600;
parent::__construct();
$this->_allowmem = $this->_allowmem && C::memory()->gotsortedset;
}
public function fetch_by_ip($ip) {
return DB::fetch_first('SELECT * FROM %t WHERE ip=%s', array($this->_table, $ip));
}
public function fetch_all_order_dateline() {
return DB::fetch_all('SELECT * FROM %t ORDER BY dateline DESC', array($this->_table));
}
public function fetch_all($ids = array(), $force_from_db = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::fetch_all($ids, $force_from_db);
} else {
return $this->fetch_all_banned();
}
}
public function fetch_all_banned() {
return DB::fetch_all('SELECT * FROM %t', array($this->_table));
}
public function delete_by_id($ids, $adminid, $adminname) {
$ids = array_map('intval', (array)$ids);
if($ids) {
if ($this->_allowmem) memory('rm', 'index', $this->_pre_cache_key);
return DB::query('DELETE FROM %t WHERE id IN(%n) AND (1=%d OR `admin`=%s)', array($this->_table, $ids, $adminid, $adminname));
}
return 0;
}
public function update_expiration_by_id($id, $expiration, $isadmin, $admin) {
if ($this->_allowmem) memory('rm', 'index', $this->_pre_cache_key);
return DB::query('UPDATE %t SET expiration=%d WHERE id=%d AND (1=%d OR `admin`=%s)', array($this->_table, $expiration, $id, $isadmin, $admin));
}
public function insert($data, $return_insert_id = false, $replace = false, $silent = false) {
$cmd = $replace ? 'REPLACE INTO' : 'INSERT INTO';
if (substr($data['lowerip'], 0, 2) !== '0x') $data['lowerip'] = '0x' . $data['lowerip'];
if (substr($data['upperip'], 0, 2) !== '0x') $data['upperip'] = '0x' . $data['upperip'];
if ($this->_allowmem) memory('rm', 'index', $this->_pre_cache_key);
return DB::query(
$cmd . ' %t SET `ip`=%s, `lowerip`=%i, `upperip`=%i, `admin`=%s, `dateline`=%d, `expiration`=%d',
array($this->_table, $data['ip'], $data['lowerip'], $data['upperip'], $data['admin'], $data['dateline'], $data['expiration']),
$silent, !$return_insert_id
);
}
public function check_banned($time_to_check, $ip) {
$iphex = ip::ip_to_hex_str($ip);
$banned = true;
if ($this->_allowmem) $banned = memory('zscore', 'index', $iphex, 0, $this->_pre_cache_key);
if ($banned === false || !$this->_allowmem) {
$iphex_val = '0x' . $iphex;
$ret = DB::result_first(
"SELECT id from %t WHERE expiration > %d AND lowerip <= %i AND upperip >= %i",
array($this->_table, $time_to_check, $iphex_val, $iphex_val)
);
if ($ret) {
if ($this->_allowmem) memory('zadd', 'index', $iphex, 1, $this->_pre_cache_key);
return true;
}
if ($this->_allowmem) memory('zadd', 'index', $iphex, 0, $this->_pre_cache_key);
return false;
}
return $banned === 1;
}
}
?>

View File

@@ -0,0 +1,124 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_block.php 29175 2012-03-28 04:02:34Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_block extends discuz_table
{
public $cache_ttl;
public $allowmem;
public function __construct() {
$this->_table = 'common_block';
$this->_pk = 'bid';
parent::__construct();
$this->_allowmem = null;
$this->cache_ttl = $this->_cache_ttl = getglobal('setting/memory/diyblock');
$this->allowmem = $this->_cache_ttl !== null && memory('check');
}
public function fetch($bid, $force_from_db = false) {
if(($block = parent::fetch(dintval($bid), $force_from_db))) {
$block['param'] = $block['param'] ? dunserialize($block['param']) : array();
}
return $block;
}
public function count_by_admincpwhere($wheresql) {
$wheresql = $wheresql ? ' WHERE '.(string)$wheresql : '';
return DB::result_first('SELECT COUNT(*) FROM '.DB::table($this->_table).' b LEFT JOIN '.DB::table('common_template_block').' tb ON tb.bid=b.bid'.$wheresql);
}
public function fetch_all_by_admincpwhere($wheresql, $ordersql, $start, $limit) {
$wheresql = $wheresql ? ' WHERE '.(string)$wheresql : '';
return DB::fetch_all('SELECT b.*, tb.targettplname FROM '.DB::table($this->_table).' b LEFT JOIN '.DB::table('common_template_block').' tb ON tb.bid=b.bid'.$wheresql.' '.(string)$ordersql.DB::limit($start, $limit), null, $this->_pk ? $this->_pk : '');
}
public function update_by_styleid($styleid, $data) {
return ($styleid = dintval($styleid, true)) && !empty($data) && is_array($data) ? DB::update($this->_table, $data, DB::field('styleid', $styleid)) : false;
}
public function fetch_by_styleid($styleid) {
return ($styleid = dintval($styleid, true)) ? DB::fetch_first('SELECT * FROM '.DB::table($this->_table).' WHERE '.DB::field('styleid', $styleid).' LIMIT 1') : array();
}
public function fetch_all_bid_by_blocktype($blocktype, $limit = 1000) {
$data = array();
if ($blocktype !== null && ($data = DB::fetch_all('SELECT bid FROM '.DB::table($this->_table).' WHERE '.DB::field('blocktype', $blocktype).' ORDER BY bid DESC'.DB::limit($limit), null, $this->_pk))) {
$data = array_keys($data);
}
return $data;
}
public function update_dateline_to_expired($bids, $timestamp) {
return ($bids = dintval($bids, true)) && ($timestamp = dintval($timestamp)) ? DB::query('UPDATE '.DB::table($this->_table).' SET `dateline`='.$timestamp.'-cachetime WHERE bid IN ('.dimplode($bids).') AND cachetime>0') : false;
}
public function fetch_all_recommended_block($id, $idtype, $wherearr = array(), $leftjoin = '', $fields = '') {
$data = array();
if(($id = dintval($id)) && $idtype) {
$where = $wherearr ? ' AND '.implode(' AND ', $wherearr) : '';
$data = DB::fetch_all("SELECT bi.dataid,bi.uid,bi.username,bi.dateline,bi.isverified,bi.verifiedtime,b.bid,b.blockclass,b.name,b.script$fields FROM ".DB::table('common_block').' b
LEFT JOIN '.DB::table('common_block_item_data')." bi ON b.bid=bi.bid $leftjoin WHERE bi.id='$id' AND bi.idtype='$idtype'$where ORDER BY b.bid DESC", null, 'bid');
}
return $data;
}
public function count_by_where($wheresql, $leftjoin = '') {
return DB::result_first("SELECT COUNT(*) FROM ".DB::table($this->_table).' b'." $leftjoin $wheresql");
}
public function fetch_all_by_where($wheresql, $start = 0, $limit = 0, $leftjoin = '', $fields = '') {
return DB::fetch_all("SELECT b.bid,b.blockclass,b.name,b.script,b.param$fields FROM ".DB::table($this->_table).' b'." $leftjoin $wheresql ORDER BY b.bid DESC ".DB::limit($start, $limit));
}
public function update($val, $data, $unbuffered = false, $low_priority = false) {
if(($val = dintval($val, true)) && $data && is_array($data)) {
$ret = parent::update($val, $data, $unbuffered, $low_priority);
$this->clear_cache($val);
return $ret;
}
return false;
}
public function delete($val, $unbuffered = false) {
if(($val = dintval($val, true))) {
$ret = parent::delete($val, $unbuffered);
$this->clear_cache($val);
return $ret;
}
return false;
}
public function clear_cache($ids, $pre_cache_key = null) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::clear_cache($ids, $pre_cache_key);
} else {
return $this->clear_blockcache($ids);
}
}
public function clear_blockcache($bids) {
if($this->allowmem) {
memory('rm', $bids,'blockcache_');
memory('rm', $bids, 'blockcache_htm_');
memory('rm', $bids, 'blockcache_js_');
}
}
}
?>

View File

@@ -0,0 +1,41 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_block_favorite.php 27846 2012-02-15 09:04:33Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_block_favorite extends discuz_table
{
public function __construct() {
$this->_table = 'common_block_favorite';
$this->_pk = 'favid';
parent::__construct();
}
public function delete_by_uid_bid($uid, $bid) {
return ($uid = dintval($uid)) && ($bid = dintval($bid)) ? DB::delete($this->_table, DB::field('uid', $uid).' AND '.DB::field('bid', $bid)) : false;
}
public function delete_by_bid($bid) {
return ($bid = dintval($bid)) ? DB::delete($this->_table, DB::field('bid', $bid)) : false;
}
public function count_by_uid_bid($uid, $bid){
return ($uid = dintval($uid)) && ($bid = dintval($bid)) ? DB::result_first('SELECT count(*) FROM %t WHERE uid=%d AND bid=%d', array($this->_table, $uid, $bid)) : false;
}
public function fetch_all_by_uid($uid) {
return ($uid = dintval($uid)) ? DB::fetch_all('SELECT * FROM %t WHERE uid=%d ORDER BY dateline DESC', array($this->_table, $uid), 'bid') : array();
}
}
?>

View File

@@ -0,0 +1,61 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_block_item.php 27937 2012-02-17 02:51:31Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_block_item extends discuz_table
{
public function __construct() {
$this->_table = 'common_block_item';
$this->_pk = 'itemid';
parent::__construct();
}
public function delete_by_bid($bid) {
if(($bid = dintval($bid, true))) {
return DB::delete($this->_table, DB::field('bid', $bid));
}
return false;
}
public function delete_by_bid_displayorder($bid, $displayorder) {
return ($bid = dintval($bid)) ? DB::delete($this->_table, DB::field('bid', $bid).' AND '.DB::field('displayorder', dintval($displayorder))) : false;
}
public function fetch_all_by_bid($bids, $sort = false) {
return ($bids = dintval($bids, true)) ? DB::fetch_all('SELECT * FROM '.DB::table($this->_table).' WHERE '.DB::field('bid', $bids).($sort ? ' ORDER BY displayorder, itemtype DESC' : ''), null, $this->_pk) : array();
}
public function delete_by_itemid_bid($itemid, $bid) {
return ($itemid = dintval($itemid, true)) && ($bid = dintval($bid)) ? DB::delete($this->_table, DB::field('itemid', $itemid).' AND '.DB::field('bid', $bid)) : false;
}
public function insert_batch($bid, $itemlist) {
$inserts = array();
if(($bid = dintval($bid))) {
foreach($itemlist as $value) {
if($value) {
$value = daddslashes($value);
$inserts[] = "('{$value['itemid']}', '$bid', '{$value['itemtype']}', '{$value['id']}', '{$value['idtype']}', '{$value['title']}',
'{$value['url']}', '{$value['pic']}', '{$value['picflag']}', '{$value['makethumb']}', '{$value['thumbpath']}', '{$value['summary']}',
'{$value['showstyle']}', '{$value['related']}', '{$value['fields']}', '{$value['displayorder']}', '{$value['startdate']}', '{$value['enddate']}')";
}
}
}
if($inserts) {
DB::query('REPLACE INTO '.DB::table($this->_table).'(itemid, bid, itemtype, id, idtype, title, url, pic, picflag, makethumb, thumbpath, summary, showstyle, related, `fields`, displayorder, startdate, enddate) VALUES '.implode(',', $inserts));
}
}
}
?>

View File

@@ -0,0 +1,70 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_block_item_data.php 31958 2012-10-26 05:11:05Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_block_item_data extends discuz_table
{
public function __construct() {
$this->_table = 'common_block_item_data';
$this->_pk = 'dataid';
parent::__construct();
}
public function fetch_all_by_bid($bid, $isverified = 1, $start = 0, $limit = 0, $bannedids = array(), $format = true) {
$data = array();
if(($bid = dintval($bid, true))) {
$addsql = $bannedids = dintval($bannedids, true) ? ' AND id NOT IN ('.dimplode($bannedids).')' : '';
$query = DB::query('SELECT * FROM %t WHERE '.DB::field('bid', $bid).' AND isverified=%d'.$addsql.' ORDER BY stickgrade DESC, displayorder DESC, verifiedtime DESC, dataid DESC '.DB::limit($start, $limit), array($this->_table, $isverified));
while($value = DB::fetch($query)) {
if($format) {
$value['fields'] = dunserialize($value['fields']);
$value['fields']['timestamp'] = $value['fields']['dateline'];
$value['fields']['dateline'] = dgmdate($value['fields']['dateline']);
$value['pic'] = $value['pic'] !== STATICURL.'image/common/nophoto.gif' ? $value['pic'] : '';
if($value['pic'] && $value['picflag'] == '1') {
$value['pic'] = getglobal('setting/attachurl').$value['pic'];
} elseif ($value['picflag'] == '2') {
$value['pic'] = getglobal('setting/ftp/attachurl').$value['pic'];
}
$value['dateline'] = dgmdate($value['dateline'], 'u');
$value['verifiedtime'] = dgmdate($value['verifiedtime'], 'u');
}
$data[$value['id']] = $value;
}
}
return $data;
}
public function count_by_bid($bid, $isverified = 1) {
return ($bid = dintval($bid, true)) ? DB::result_first('SELECT COUNT(*) FROM %t WHERE '.DB::field('bid', $bid).' AND isverified=%d', array($this->_table, $isverified)) : 0;
}
public function delete_by_bid($bid) {
if(($bid = dintval($bid, true))) {
DB::delete($this->_table, DB::field('bid', $bid));
}
}
public function delete_by_dataid_bid($dataids, $bid) {
if(($dataids = dintval($dataids, true)) && ($dataids = DB::fetch_all('SELECT dataid FROM %t WHERE dataid IN (%n) AND bid=%d', array($this->_table, $dataids, $bid), $this->_pk))) {
$this->delete(array_keys($dataids));
}
}
public function fetch_by_bid_id_idtype($bid, $id, $idtype) {
return $bid && $id && $idtype ? DB::fetch_first('SELECT * FROM %t WHERE bid=%d AND id=%d AND idtype=%s', array($this->_table, $bid, $id, $idtype)) : array();
}
}
?>

View File

@@ -0,0 +1,144 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_block_permission.php 27846 2012-02-15 09:04:33Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_block_permission extends discuz_table
{
public function __construct() {
$this->_table = 'common_block_permission';
$this->_pk = '';
parent::__construct();
}
public function fetch($id, $force_from_db = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::fetch($id, $force_from_db);
} else {
$force_from_db = $force_from_db === false ? 0 : $force_from_db;
return $this->fetch_by_bid_uid($id, $force_from_db);
}
}
public function fetch_by_bid_uid($bid, $uid){
return ($bid = dintval($bid)) && ($uid = dintval($uid)) ? DB::fetch_first('SELECT * FROM %t WHERE bid=%d AND uid=%d', array($this->_table, $bid, $uid)) : array();
}
public function fetch_all_by_bid($bid, $uid = 0) {
return ($bid = dintval($bid, true)) ? DB::fetch_all('SELECT * FROM %t WHERE bid=%d'.($uid ? ' AND '.DB::field('uid', $uid) : '').' ORDER BY inheritedtplname', array($this->_table, $bid), 'uid') : array();
}
public function fetch_all_by_uid($uids, $flag = true, $sort = 'ASC', $start = 0, $limit = 0) {
$wherearr = array();
$sort = $sort === 'ASC' ? 'ASC' : 'DESC';
if(($uids = dintval($uids))) {
$wherearr[] = DB::field('uid', $uids);
}
if(!$flag) {
$wherearr[] = 'inheritedtplname = \'\'';
}
$where = $wherearr ? ' WHERE '.implode(' AND ', $wherearr) : '';
return DB::fetch_all('SELECT * FROM '.DB::table($this->_table).$where.' ORDER BY uid '.$sort.', inheritedtplname'.DB::limit($start, $limit), NULL, ($uids && !is_array($uids)) ? 'bid' : '');
}
public function count_by_uids($uids, $flag) {
$wherearr = array();
if(($uids = dintval($uids, true))) {
$wherearr[] = DB::field('uid', $uids);
}
if(!$flag) {
$wherearr[] = 'inheritedtplname = \'\'';
}
$where = $wherearr ? ' WHERE '.implode(' AND ', $wherearr) : '';
return DB::result_first('SELECT COUNT(*) FROM '.DB::table($this->_table).$where);
}
public function fetch_permission_by_uid($uids) {
return ($uids = dintval($uids, true)) ? DB::fetch_all('SELECT uid, sum(allowmanage) as allowmanage, sum(allowrecommend) as allowrecommend, sum(needverify) as needverify FROM '.DB::table($this->_table)." WHERE ".DB::field('uid', $uids)." GROUP BY uid", null, 'uid') : array();
}
public function delete_by_bid_uid_inheritedtplname($bid = false, $uids = false, $inheritedtplname = false) {
$wherearr = array();
if(($bid = dintval($bid, true))) {
$wherearr[] = DB::field('bid', $bid);
}
if(($uids = dintval($uids, true))) {
$wherearr[] = DB::field('uid', $uids);
}
if($inheritedtplname === true) {
$wherearr[] = "inheritedtplname!=''";
} elseif($inheritedtplname !== false && is_string($inheritedtplname)) {
$wherearr[] = DB::field('inheritedtplname', $inheritedtplname);
}
return $wherearr ? DB::delete($this->_table, implode(' AND ', $wherearr)) : false;
}
public function insert_batch($users, $bids, $tplname = '') {
$blockperms = array();
if(!empty($users) && $bids = dintval($bids, true)){
$uids = $notinherit = array();
foreach($users as &$user) {
if(($user['uid'] = dintval($user['uid']))) {
$uids[] = $user['uid'];
}
}
if(!empty($uids)) {
foreach($this->fetch_all_by_uid($uids, false) as $value) {
if(in_array($value['bid'], $bids)) {
$notinherit[$value['bid']][$value['uid']] = true;
}
}
}
foreach($users as $user) {
if($user['uid']) {
$tplname = !empty($user['inheritedtplname']) ? $user['inheritedtplname'] : $tplname;
foreach ($bids as $bid) {
if(empty($notinherit[$bid][$user['uid']])) {
$blockperms[] = "('$bid','{$user['uid']}','{$user['allowmanage']}','{$user['allowrecommend']}','{$user['needverify']}','$tplname')";
}
}
}
}
if($blockperms) {
DB::query('REPLACE INTO '.DB::table($this->_table).' (bid,uid,allowmanage,allowrecommend,needverify,inheritedtplname) VALUES '.implode(',', $blockperms));
return $uids;
} else {
return FALSE;
}
}
return false;
}
public function insert_by_bid($bid, $users) {
$sqlarr = $uids = array();
$bid = intval($bid);
if(!empty($bid) && !empty($users)) {
foreach ($users as $v) {
if(($v['uid'] = dintval($v['uid']))) {
$sqlarr[] = "('$bid','{$v['uid']}','{$v['allowmanage']}','{$v['allowrecommend']}','{$v['needverify']}','')";
$uids[] = $v['uid'];
}
}
if(!empty($sqlarr)) {
DB::query('REPLACE INTO '.DB::table($this->_table).' (bid,uid,allowmanage,allowrecommend,needverify,inheritedtplname) VALUES '.implode(',', $sqlarr));
}
}
return $uids;
}
}
?>

View File

@@ -0,0 +1,46 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_block_pic.php 27802 2012-02-15 02:34:36Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_block_pic extends discuz_table
{
public function __construct() {
$this->_table = 'common_block_pic';
$this->_pk = 'picid';
parent::__construct();
}
public function fetch_all_by_bid_itemid($bid, $itemid = array()) {
return $bid ? DB::fetch_all('SELECT * FROM '.DB::table($this->_table).' WHERE '.DB::field('bid', $bid).($itemid ? ' AND '.DB::field('itemid', $itemid) : '')) : array();
}
public function insert_by_bid($bid, $data) {
if($bid && $data && is_array($data)) {
$data = daddslashes($data);
$str = array();
foreach($data as $value) {
$str[] = "('{$value['bid']}', '{$value['pic']}', '{$value['picflag']}', '{$value['type']}')";
}
if($str) {
DB::query('INSERT INTO '.DB::table($this->_table).' (bid, pic, picflag, `type`) VALUES '.implode(',', $str));
}
}
}
public function count_by_bid_pic($bid, $pic) {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE bid=%d AND pic=%s', array($this->_table, $bid, $pic));
}
}
?>

View File

@@ -0,0 +1,77 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_block_style.php 31736 2012-09-26 02:23:48Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_block_style extends discuz_table
{
public function __construct() {
$this->_table = 'common_block_style';
$this->_pk = 'styleid';
parent::__construct();
}
public function fetch_all_by_blockclass($blockclass) {
return $blockclass ? DB::fetch_all('SELECT * FROM %t WHERE blockclass=%s', array($this->_table, $blockclass), $this->_pk) : array();
}
public function fetch_all_by_hash($hash) {
return $hash ? DB::fetch_all('SELECT * FROM %t WHERE `hash` IN (%n)', array($this->_table, $hash), $this->_pk) : array();
}
public function count_by_where($wheresql) {
$wheresql = $wheresql ? ' WHERE '.(string)$wheresql : '';
return DB::result_first('SELECT COUNT(*) FROM '.DB::table($this->_table).$wheresql);
}
public function fetch_all_by_where($wheresql, $ordersql, $start, $limit) {
$wheresql = $wheresql ? ' WHERE '.(string)$wheresql : '';
return DB::fetch_all('SELECT * FROM '.DB::table($this->_table).$wheresql.' '.(string)$ordersql.DB::limit($start, $limit), null, $this->_pk ? $this->_pk : '');
}
public function insert_batch($styles) {
$inserts = array();
foreach($styles as $value) {
if(!empty($value['blockclass'])) {
$value = daddslashes($value);
$inserts[] = "('{$value['blockclass']}', '{$value['name']}', '{$value['template']}', '{$value['hash']}', '{$value['getpic']}', '{$value['getsummary']}', '{$value['settarget']}', '{$value['fields']}', '{$value['moreurl']}')";
}
}
if(!empty($inserts)) {
DB::query('INSERT INTO '.DB::table($this->_table)."(`blockclass`, `name`, `template`, `hash`, `getpic`, `getsummary`, `settarget`, `fields`, `moreurl`) VALUES ".implode(',',$inserts));
}
}
public function update($val, $data, $unbuffered = false, $low_priority = false) {
if(($val = dintval($val, true)) && $data && is_array($data)) {
$this->_pre_cache_key = 'blockstylecache_';
$this->_cache_ttl = getglobal('setting/memory/diyblock');
$this->_allowmem = getglobal('setting/memory/diyblock') && memory('check');
$this->clear_cache($val);
return parent::update($val, $data, $unbuffered, $low_priority);
}
return false;
}
public function delete($val, $unbuffered = false) {
if(($val = dintval($val, true))) {
$this->_pre_cache_key = 'blockstylecache_';
$this->_cache_ttl = getglobal('setting/memory/diyblock');
$this->_allowmem = getglobal('setting/memory/diyblock') && memory('check');
return parent::delete($val, $unbuffered);
}
return false;
}
}
?>

View File

@@ -0,0 +1,26 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_block_xml.php 27449 2012-02-01 05:32:35Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_block_xml extends discuz_table
{
public function __construct() {
$this->_table = 'common_block_xml';
$this->_pk = 'id';
parent::__construct();
}
}
?>

View File

@@ -0,0 +1,26 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_cache.php 27449 2012-02-01 05:32:35Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_cache extends discuz_table
{
public function __construct() {
$this->_table = 'common_cache';
$this->_pk = 'cachekey';
parent::__construct();
}
}
?>

View File

@@ -0,0 +1,51 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_card.php 27846 2012-02-15 09:04:33Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_card extends discuz_table
{
public function __construct() {
$this->_table = 'common_card';
$this->_pk = 'id';
parent::__construct();
}
public function update_by_typeid($typeid, $data) {
if(($typeid = dintval($typeid, true)) && !empty($data) && is_array($data)) {
return DB::update($this->_table, $data, DB::field('typeid', $typeid));
}
return false;
}
public function count_by_where($where) {
return ($where = (string)$where) ? DB::result_first('SELECT COUNT(*) FROM '.DB::table('common_card').' WHERE '.$where) : 0;
}
public function fetch_all_by_where($where, $start = 0, $limit = 0) {
$where = $where ? ' WHERE '.(string)$where : '';
return DB::fetch_all('SELECT * FROM '.DB::table($this->_table).$where.' ORDER BY dateline DESC'.DB::limit($start, $limit));
}
public function update_to_overdue($timestamp) {
return ($timestamp = dintval($timestamp)) ? DB::query('UPDATE '.DB::table('common_card')." SET status = 9 WHERE status = '1' AND cleardateline <= '$timestamp'") : false;
}
public function update_to_used($id) {
global $_G;
return DB::query('UPDATE '.DB::table('common_card')." SET status = '2', uid = '".$_G['uid']."', useddateline = '".$_G['timestamp']."' WHERE id = '".daddslashes($id)."' AND status = '1'");
}
}
?>

View File

@@ -0,0 +1,37 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_card_log.php 31076 2012-07-13 03:30:58Z zhangjie $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_card_log extends discuz_table_archive
{
public function __construct() {
$this->_table = 'common_card_log';
$this->_pk = 'id';
parent::__construct();
}
public function fetch_by_operation($operation) {
return DB::fetch_first('SELECT * FROM %t WHERE operation=%d ORDER BY dateline DESC LIMIT 1', array($this->_table, $operation));
}
public function fetch_all_by_operation($operation, $start = 0, $limit = 0) {
return DB::fetch_all('SELECT * FROM %t WHERE operation=%d ORDER BY dateline DESC '.DB::limit($start, $limit), array($this->_table, $operation));
}
public function count_by_operation($operation) {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE operation=%d', array($this->_table, $operation));
}
}
?>

View File

@@ -0,0 +1,26 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_card_type.php 27449 2012-02-01 05:32:35Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_card_type extends discuz_table
{
public function __construct() {
$this->_table = 'common_card_type';
$this->_pk = 'id';
parent::__construct();
}
}
?>

View File

@@ -0,0 +1,197 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_credit_log.php 31381 2012-08-21 07:56:35Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_credit_log extends discuz_table
{
public function __construct() {
$this->_table = 'common_credit_log';
$this->_pk = 'logid';
parent::__construct();
}
public function fetch_by_operation_relatedid($operation, $relatedid) {
$relatedid = dintval($relatedid, true);
$parameter = array($this->_table, $operation, $relatedid);
$wherearr = array();
$wherearr[] = is_array($operation) && $operation ? 'operation IN(%n)' : 'operation=%s';
$wherearr[] = is_array($relatedid) && $relatedid ? 'relatedid IN(%n)' : 'relatedid=%d';
return DB::fetch_all('SELECT * FROM %t WHERE '.implode(' AND ', $wherearr), $parameter);
}
public function fetch_all_by_operation($operation, $start = 0, $limit = 0) {
return DB::fetch_all('SELECT * FROM %t WHERE operation=%s ORDER BY dateline DESC '.DB::limit($start, $limit), array($this->_table, $operation));
}
public function fetch_all_by_uid_operation_relatedid($uid, $operation, $relatedid) {
$parameter = array($this->_table);
$wherearr = array();
if($uid) {
$uid = dintval($uid, true);
$wherearr[] = is_array($uid) && $uid ? 'uid IN(%n)' : 'uid=%d';
$parameter[] = $uid;
}
$relatedid = dintval($relatedid, true);
$wherearr[] = is_array($operation) && $operation ? 'operation IN(%n)' : 'operation=%s';
$wherearr[] = is_array($relatedid) && $relatedid ? 'relatedid IN(%n)' : 'relatedid=%d';
$parameter[] = $operation;
$parameter[] = $relatedid;
return DB::fetch_all('SELECT * FROM %t WHERE '.implode(' AND ', $wherearr).' ORDER BY dateline', $parameter);
}
public function fetch_all_by_uid($uid, $start = 0, $limit = 0) {
$array = DB::fetch_all('SELECT * FROM %t WHERE uid=%d ORDER BY dateline DESC '.DB::limit($start, $limit), array($this->_table, $uid), 'logid');
if(!$array) {
return array();
}
$fieldids = array();
foreach($array as $key => $value) {
if(!in_array($value['operation'], lang('spacecp', 'logs_credit_update_INDEX'))) {
$fieldids[] = $key;
}
}
if($fieldids) {
$arrayfield = DB::fetch_all('SELECT * FROM %t WHERE logid IN(%n)', array('common_credit_log_field', $fieldids), 'logid');
foreach($arrayfield as $key => $value) {
$array[$key] += $value;
}
}
return $array;
}
public function fetch_all_by_search($uid, $optype, $begintime = 0, $endtime = 0, $exttype = 0, $income = 0, $extcredits = array(), $start = 0, $limit = 0, $relatedid = 0) {
$condition = $this->make_query_condition($uid, $optype, $begintime, $endtime, $exttype, $income, $extcredits, $relatedid);
$array = DB::fetch_all('SELECT * FROM %t '.$condition[0].' ORDER BY dateline DESC '.DB::limit($start, $limit), $condition[1], 'logid');
if(!$array) {
return array();
}
$fieldids = array();
foreach($array as $key => $value) {
if(!in_array($value['operation'], lang('spacecp', 'logs_credit_update_INDEX'))) {
$fieldids[] = $key;
}
}
if($fieldids) {
$arrayfield = DB::fetch_all('SELECT * FROM %t WHERE logid IN(%n)', array('common_credit_log_field', $fieldids), 'logid');
foreach($arrayfield as $key => $value) {
$array[$key] += $value;
}
}
return $array;
}
public function delete_by_operation_relatedid($operation, $relatedid) {
$relatedid = dintval($relatedid, true);
if($operation && $relatedid) {
return DB::delete($this->_table, DB::field('operation', $operation).' AND '.DB::field('relatedid', $relatedid));
}
return 0;
}
public function delete_by_uid_operation_relatedid($uid, $operation, $relatedid) {
$relatedid = dintval($relatedid, true);
$uid = dintval($uid, true);
if($relatedid && $uid && $operation) {
return DB::delete($this->_table, DB::field('uid', $uid).' AND '.DB::field('operation', $operation).' AND '.DB::field('relatedid', $relatedid));
}
return 0;
}
public function update_by_uid_operation_relatedid($uid, $operation, $relatedid, $data) {
$relatedid = dintval($relatedid, true);
$uid = dintval($uid, true);
if(!empty($data) && is_array($data) && $relatedid && $uid && $operation) {
return DB::update($this->_table, $data, DB::field('uid', $uid).' AND '.DB::field('operation', $operation).' AND '.DB::field('relatedid', $relatedid));
}
return 0;
}
public function count_by_uid_operation_relatedid($uid, $operation, $relatedid) {
$relatedid = dintval($relatedid, true);
$uid = dintval($uid, true);
if($relatedid && $uid && $operation) {
$wherearr = array();
$wherearr[] = is_array($uid) && $uid ? 'uid IN(%n)' : 'uid=%d';
$wherearr[] = is_array($operation) && $operation ? 'operation IN(%n)' : 'operation=%s';
$wherearr[] = is_array($relatedid) && $relatedid ? 'relatedid IN(%n)' : 'relatedid=%d';
return DB::result_first('SELECT COUNT(*) FROM %t WHERE '.implode(' AND ', $wherearr), array($this->_table, $uid, $operation, $relatedid));
}
return 0;
}
public function count_by_uid($uid) {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE uid=%d', array($this->_table, $uid));
}
public function count_by_operation($operation) {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE operation=%s', array($this->_table, $operation));
}
public function count_stc_by_relatedid($relatedid, $creditid, $operation = 'STC') {
$creditid = intval($creditid);
if($creditid) {
return DB::fetch_first("SELECT COUNT(*) AS payers, SUM(extcredits%d) AS income FROM %t WHERE relatedid=%d AND operation=%s", array($creditid, $this->_table, $relatedid, $operation));
}
return 0;
}
public function count_credit_by_uid_operation_relatedid($uid, $operation, $relatedid, $creditid) {
$creditid = intval($creditid);
if($creditid) {
$relatedid = dintval($relatedid, true);
$uid = dintval($uid, true);
$wherearr = array();
$wherearr[] = is_array($uid) && $uid ? 'uid IN(%n)' : 'uid=%d';
$wherearr[] = is_array($operation) && $operation ? 'operation IN(%n)' : 'operation=%s';
$wherearr[] = is_array($relatedid) && $relatedid ? 'relatedid IN(%n)' : 'relatedid=%d';
return DB::result_first('SELECT SUM(extcredits%d) AS credit FROM %t WHERE '.implode(' AND ', $wherearr), array($creditid, $this->_table, $uid, $operation, $relatedid));
}
return 0;
}
public function count_by_search($uid, $optype, $begintime = 0, $endtime = 0, $exttype = 0, $income = 0, $extcredits = array(), $relatedid = 0) {
$condition = $this->make_query_condition($uid, $optype, $begintime, $endtime, $exttype, $income, $extcredits, $relatedid);
return DB::result_first('SELECT COUNT(*) FROM %t '.$condition[0], $condition[1]);
}
private function make_query_condition($uid, $optype, $begintime = 0, $endtime = 0, $exttype = 0, $income = 0, $extcredits = array(), $relatedid = 0) {
$wherearr = array();
$parameter = array($this->_table);
if($uid) {
$uid = dintval($uid, true);
$wherearr[] = is_array($uid) && $uid ? 'uid IN(%n)' : 'uid=%d';
$parameter[] = $uid;
}
if($optype) {
$wherearr[] = is_array($optype) && $optype ? 'operation IN(%n)' : 'operation=%s';
$parameter[] = $optype != -1 ? $optype : '';
}
if($relatedid) {
$relatedid = dintval($relatedid, true);
$wherearr[] = is_array($relatedid) && $relatedid ? 'relatedid IN(%n)' : 'relatedid=%d';
$parameter[] = $relatedid;
}
if($begintime) {
$wherearr[] = 'dateline>%d';
$parameter[] = $begintime;
}
if($endtime) {
$wherearr[] = 'dateline<%d';
$parameter[] = $endtime;
}
if($exttype && $extcredits[$exttype]) {
$wherearr[] = "extcredits{$exttype}!=0";
}
if($income && $extcredits) {
$incomestr = $income < 0 ? '<' : '>';
$incomearr = array();
foreach(array_keys($extcredits) as $id) {
$incomearr[] = 'extcredits'.$id.$incomestr.'0';
}
if($incomearr) {
$wherearr[] = '('.implode(' OR ', $incomearr).')';
}
}
$wheresql = !empty($wherearr) && is_array($wherearr) ? ' WHERE '.implode(' AND ', $wherearr) : '';
return array($wheresql, $parameter);
}
}
?>

View File

@@ -0,0 +1,25 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_credit_log_field.php 31380 2012-08-21 07:25:54Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_credit_log_field extends discuz_table
{
public function __construct() {
$this->_table = 'common_credit_log_field';
$this->_pk = '';
parent::__construct();
}
}
?>

View File

@@ -0,0 +1,49 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_credit_rule.php 27900 2012-02-16 07:50:00Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_credit_rule extends discuz_table
{
public function __construct() {
$this->_table = 'common_credit_rule';
$this->_pk = 'rid';
parent::__construct();
}
public function fetch_all_by_rid($rid = 0) {
$parameter = array($this->_table);
$wherearr = array();
if($rid) {
$rid = dintval($rid, true);
$parameter[] = $rid;
$wherearr[] = is_array($rid) ? 'rid IN(%n)' : 'rid=%d';
}
$wheresql = !empty($wherearr) && is_array($wherearr) ? ' WHERE '.implode(' AND ', $wherearr) : '';
return DB::fetch_all("SELECT * FROM %t $wheresql ORDER BY rid DESC", $parameter, $this->_pk);
}
public function fetch_all_rule() {
return DB::fetch_all('SELECT * FROM %t ORDER BY rid DESC', array($this->_table));
}
public function fetch_all_by_action($action) {
if(!empty($action)) {
return DB::fetch_all('SELECT * FROM %t WHERE action IN(%n)', array($this->_table, $action), $this->_pk);
}
return array();
}
}
?>

View File

@@ -0,0 +1,83 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_credit_rule_log.php 27876 2012-02-16 04:28:02Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_credit_rule_log extends discuz_table
{
private $_rids = array();
public function __construct() {
$this->_table = 'common_credit_rule_log';
$this->_pk = 'clid';
parent::__construct();
}
public function increase($clid, $logarr) {
if($clid && !empty($logarr) && is_array($logarr)) {
return DB::query('UPDATE %t SET %i WHERE clid=%d', array($this->_table, implode(',', $logarr), $clid));
}
return 0;
}
public function fetch_ids_by_rid_fid($rid, $fid) {
$lids = array();
if($rid && $fid) {
$query = DB::query('SELECT clid FROM %t WHERE rid=%d AND fid=%d', array($this->_table, $rid, $fid));
while($value = DB::fetch($query)) {
$lids[$value['clid']] = $value['clid'];
}
}
return $lids;
}
public function fetch_rule_log($rid, $uid, $fid = 0){
$log = array();
if($rid && $uid) {
$sql = '';
$para = array($this->_table, $uid, $rid);
if($fid) {
$sql = ' AND fid=%d';
$para[] = $fid;
}
$log = DB::fetch_first('SELECT * FROM %t WHERE uid=%d AND rid=%d'.$sql, $para);
}
return $log;
}
public function count_by_uid($uid) {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE uid=%d', array($this->_table, $uid));
}
public function fetch_all_by_uid($uid, $start = 0, $limit = 0) {
$data = array();
$query = DB::query("SELECT * FROM %t WHERE uid=%d ORDER BY dateline DESC ".DB::limit($start, $limit), array($this->_table, $uid));
while($value = DB::fetch($query)) {
$data[$value['clid']] = $value;
$this->_rids[$value['rid']] = $value['rid'];
}
return $data;
}
public function delete_by_uid($uids) {
$uids = dintval((array)$uids, true);
if(!empty($uids)) {
return DB::delete($this->_table, DB::field('uid', $uids));
}
return 0;
}
public function get_rids() {
return $this->_rids;
}
}
?>

View File

@@ -0,0 +1,66 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_credit_rule_log_field.php 27777 2012-02-14 07:07:26Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_credit_rule_log_field extends discuz_table
{
public function __construct() {
$this->_table = 'common_credit_rule_log_field';
$this->_pk = '';
parent::__construct();
}
public function delete_clid($val) {
DB::delete($this->_table, DB::field('clid', $val));
}
public function delete_by_uid($uids) {
return DB::delete($this->_table, DB::field('uid', $uids));
}
public function update($val, $data, $unbuffered = false, $low_priority = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::update($val, $data, $unbuffered, $low_priority);
} else {
return $this->update_field($val, $data, $unbuffered);
}
}
public function fetch($id, $force_from_db = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::fetch($id, $force_from_db);
} else {
return $this->fetch_field($id, $force_from_db);
}
}
public function update_field($uid, $clid, $data) {
if(!empty($data) && is_array($data)) {
return DB::update($this->_table, $data, array('uid'=>$uid, 'clid'=>$clid));
}
return 0;
}
public function fetch_field($uid, $clid) {
$logarr = array();
if($uid && $clid) {
$logarr = DB::fetch_first('SELECT * FROM %t WHERE uid=%d AND clid=%d', array($this->_table, $uid, $clid));
}
return !empty($logarr) ? $logarr : array();
}
}
?>

View File

@@ -0,0 +1,40 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_cron.php 30314 2012-05-22 03:12:44Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_cron extends discuz_table
{
public function __construct() {
$this->_table = 'common_cron';
$this->_pk = 'cronid';
parent::__construct();
}
public function fetch_nextrun($timestamp) {
$timestamp = intval($timestamp);
return DB::fetch_first('SELECT * FROM '.DB::table($this->_table)." WHERE available>'0' AND nextrun<='$timestamp' ORDER BY nextrun LIMIT 1");
}
public function fetch_nextcron() {
return DB::fetch_first('SELECT * FROM '.DB::table($this->_table)." WHERE available>'0' ORDER BY nextrun LIMIT 1");
}
public function get_cronid_by_filename($filename) {
return DB::result_first('SELECT cronid FROM '.DB::table($this->_table)." WHERE filename='$filename'");
}
}
?>

View File

@@ -0,0 +1,42 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_district.php 28647 2012-03-07 02:03:00Z chenmengshu $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_district extends discuz_table
{
public function __construct() {
$this->_table = 'common_district';
$this->_pk = 'id';
parent::__construct();
}
public function fetch_all_by_upid($upid, $order = null, $sort = 'DESC') {
$upid = is_array($upid) ? array_map('intval', (array)$upid) : dintval($upid);
if($upid !== null) {
$ordersql = $order !== null && !empty($order) ? ' ORDER BY '.DB::order($order, $sort) : '';
return DB::fetch_all('SELECT * FROM %t WHERE '.DB::field('upid', $upid)." $ordersql", array($this->_table), $this->_pk);
}
return array();
}
public function fetch_all_by_name($name) {
if(!empty($name)) {
return DB::fetch_all('SELECT * FROM %t WHERE '.DB::field('name', $name), array($this->_table));
}
return array();
}
}
?>

View File

@@ -0,0 +1,97 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_diy_data.php 27827 2012-02-15 07:03:43Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_diy_data extends discuz_table
{
public function __construct() {
$this->_table = 'common_diy_data';
$this->_pk = '';
parent::__construct();
}
public function fetch($id, $force_from_db = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::fetch($id, $force_from_db);
} else {
return $this->fetch_diy($id, $force_from_db);
}
}
public function delete($val, $unbuffered = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::delete($val, $unbuffered);
} else {
return $this->delete_diy($val, $unbuffered);
}
}
public function update($val, $data, $unbuffered = false, $low_priority = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::update($val, $data, $unbuffered, $low_priority);
} else {
return $this->update_diy($val, $data, $unbuffered);
}
}
public function fetch_all($ids, $force_from_db = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::fetch_all($ids, $force_from_db);
} else {
$force_from_db = $force_from_db === false ? null : $force_from_db;
return $this->fetch_all_diy($ids, $force_from_db);
}
}
public function fetch_diy($targettplname, $tpldirectory) {
return !empty($targettplname) ? DB::fetch_first('SELECT * FROM '.DB::table($this->_table).' WHERE '.DB::field('targettplname', $targettplname).' AND '.DB::field('tpldirectory', $tpldirectory)) : array();
}
public function delete_diy($targettplname, $tpldirectory = null) {
foreach($this->fetch_all_diy($targettplname, $tpldirectory) as $value) {
$file = ($value['tpldirectory'] ? $value['tpldirectory'].'/' : '').$value['targettplname'];
@unlink(DISCUZ_ROOT.'./data/diy/'.$file.'.htm');
@unlink(DISCUZ_ROOT.'./data/diy/'.$file.'.htm.bak');
@unlink(DISCUZ_ROOT.'./data/diy/'.$file.'_diy_preview.htm');
}
return DB::delete($this->_table, DB::field('targettplname', $targettplname).($tpldirectory !== null ? ' AND '.DB::field('tpldirectory', $tpldirectory) : ''));
}
public function update_diy($targettplname, $tpldirectory, $data) {
if(!empty($targettplname) && !empty($data) && is_array($data)) {
return DB::update($this->_table, $data, DB::field('targettplname', $targettplname).' AND '.DB::field('tpldirectory', $tpldirectory));
}
return false;
}
public function fetch_all_diy($targettplname, $tpldirectory = null) {
return !empty($targettplname) ? DB::fetch_all('SELECT * FROM '.DB::table($this->_table).' WHERE '.DB::field('targettplname', $targettplname).($tpldirectory !== null ? ' AND '.DB::field('tpldirectory', $tpldirectory) : '')) : array();
}
public function count_by_where($wheresql) {
$wheresql = $wheresql ? ' WHERE '.$wheresql : '';
return DB::result_first('SELECT COUNT(*) FROM '.DB::table($this->_table).$wheresql);
}
public function fetch_all_by_where($wheresql, $ordersql, $start, $limit) {
$wheresql = $wheresql ? ' WHERE '.$wheresql : '';
return DB::fetch_all('SELECT * FROM '.DB::table($this->_table).$wheresql.' '.$ordersql.DB::limit($start, $limit), null, $this->_pk ? $this->_pk : '');
}
}
?>

View File

@@ -0,0 +1,56 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_domain.php 27860 2012-02-16 02:32:58Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_domain extends discuz_table
{
public function __construct() {
$this->_table = 'common_domain';
$this->_pk = '';
parent::__construct();
}
public function update_by_idtype($idtype, $data) {
if($idtype && !empty($data) && is_array($data)) {
return DB::update($this->_table, $data, DB::field('idtype', $idtype));
}
return 0;
}
public function fetch_all_by_idtype($idtype) {
if(!empty($idtype)) {
return DB::fetch_all('SELECT * FROM %t WHERE '.DB::field('idtype', $idtype), array($this->_table));
}
return array();
}
public function fetch_by_domain_domainroot($domain, $droot) {
return DB::fetch_first('SELECT * FROM %t WHERE domain=%s AND domainroot=%s', array($this->_table, $domain, $droot));
}
public function delete_by_id_idtype($id, $idtype) {
$parameter = array($this->_table, $id, $idtype);
$wherearr = array();
$wherearr[] = is_array($id) ? 'id IN(%n)' : 'id=%d';
$wherearr[] = is_array($idtype) ? 'idtype IN(%n)' : 'idtype=%s';
$wheresql = !empty($wherearr) && is_array($wherearr) ? ' WHERE '.implode(' AND ', $wherearr) : '';
return DB::query("DELETE FROM %t $wheresql", $parameter);
}
public function count_by_domain_domainroot($domain, $droot) {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE domain=%s AND domainroot=%s', array($this->_table, $domain, $droot));
}
}
?>

View File

@@ -0,0 +1,39 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_failedip.php 33692 2013-08-02 10:26:20Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_failedip extends discuz_table
{
public function __construct() {
$this->_table = 'common_failedip';
$this->_pk = '';
parent::__construct();
}
public function get_ip_count($ip, $time) {
return DB::result_first("SELECT SUM(`count`) FROM %t WHERE ip=%s AND lastupdate>%d", array($this->_table, $ip, $time));
}
public function insert_ip($ip) {
if(DB::result_first("SELECT COUNT(*) FROM %t WHERE ip=%s AND lastupdate=%d", array($this->_table, $ip, TIMESTAMP))) {
DB::query("UPDATE %t SET `count`=`count`+1 WHERE ip=%s AND lastupdate=%d", array($this->_table, $ip, TIMESTAMP));
} else {
DB::query("INSERT INTO %t VALUES (%s, %d, 1)", array($this->_table, $ip, TIMESTAMP));
}
DB::query("DELETE FROM %t WHERE lastupdate<%d", array($this->_table, TIMESTAMP - 3600));
}
}
?>

View File

@@ -0,0 +1,41 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_failedlogin.php 36284 2016-12-12 00:47:50Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_failedlogin extends discuz_table
{
public function __construct() {
$this->_table = 'common_failedlogin';
$this->_pk = '';
parent::__construct();
}
public function fetch_username($ip, $username) {
return DB::fetch_first("SELECT * FROM %t WHERE ip=%s AND username=%s", array($this->_table, $ip, $username));
}
public function fetch_ip($ip) {
return DB::fetch_first("SELECT * FROM %t WHERE ip=%s", array($this->_table, $ip));
}
public function delete_old($time) {
DB::query("DELETE FROM %t WHERE lastupdate<%d", array($this->_table, TIMESTAMP - intval($time)), 'UNBUFFERED');
}
public function update_failed($ip) {
DB::query("UPDATE %t SET count=count+1, lastupdate=%d WHERE ip=%s", array($this->_table, TIMESTAMP, $ip));
}
}
?>

View File

@@ -0,0 +1,36 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_friendlink.php 27449 2012-02-01 05:32:35Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_friendlink extends discuz_table
{
public function __construct() {
$this->_table = 'common_friendlink';
$this->_pk = 'id';
parent::__construct();
}
public function fetch_all_by_displayorder($type = '')
{
$args = array($this->_table);
if($type) {
$sql = 'WHERE (`type` & %s > 0)';
$args[] = $type;
}
return DB::fetch_all("SELECT * FROM %t $sql ORDER BY displayorder", $args, $this->_pk);
}
}
?>

View File

@@ -0,0 +1,58 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_grouppm.php 27876 2012-02-16 04:28:02Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_grouppm extends discuz_table
{
private $_uids = array();
public function __construct() {
$this->_table = 'common_grouppm';
$this->_pk = 'id';
parent::__construct();
}
public function fetch_all_by_id_authorid($id = 0, $authorid = 0) {
$wherearr = $data = array();
$parameter = array($this->_table);
if($id) {
$id = is_array($id) ? array_map('intval', (array)$id) : dintval($id);
$wherearr[] = is_array($id) ? 'id IN(%n)' : 'id=%d';
$parameter[] = $id;
}
if($authorid) {
$authorid = dintval($authorid);
$wherearr[] = 'authorid=%d';
$parameter[] = $authorid;
}
$wheresql = !empty($wherearr) ? ' WHERE '.implode(' AND ', $wherearr) : '';
$query = DB::query("SELECT * FROM %t $wheresql ORDER BY id DESC", $parameter);
while($row = DB::fetch($query)) {
$data[$row['id']] = $row;
$this->_uids[$row['authorid']] = $row['authorid'];
}
return $data;
}
public function count_by_id_authorid($id, $authorid) {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE id=%d AND authorid=%d', array($this->_table, $id, $authorid));
}
public function get_uids() {
return $this->_uids;
}
}
?>

View File

@@ -0,0 +1,114 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_invite.php 31197 2012-07-25 06:05:16Z chenmengshu $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_invite extends discuz_table
{
private $_uids = array();
public function __construct() {
$this->_table = 'common_invite';
$this->_pk = 'id';
parent::__construct();
}
public function fetch_by_id_uid($id, $uid) {
return DB::fetch_first('SELECT * FROM %t WHERE id=%d AND uid=%d', array($this->_table, $id, $uid));
}
public function fetch_by_code($code) {
return DB::fetch_first('SELECT * FROM %t WHERE code=%s', array($this->_table, $code));
}
public function fetch_all_by_uid($uid) {
return DB::fetch_all('SELECT * FROM %t WHERE uid=%d ORDER BY dateline DESC', array($this->_table, $uid), $this->_pk);
}
public function fetch_all_invitenum_group_by_uid($dateline = 0, $start = 0, $limit = 0) {
$sql = '';
$parameter = array($this->_table);
if($dateline) {
$sql = ' AND dateline>%d';
$parameter[] = $dateline;
}
return DB::fetch_all("SELECT count(*) AS invitenum ,uid FROM %t WHERE status=2 $sql GROUP BY uid ORDER BY invitenum DESC ".DB::limit($start, $limit), $parameter);
}
public function fetch_all_orderid($orderid) {
return DB::fetch_all('SELECT * FROM %t WHERE orderid=%s', array($this->_table, $orderid));
}
public function fetch_all_by_search($uid = 0, $fuid = 0, $fusername = '', $buydatestart = 0, $buydateend = 0, $inviteip = '', $code = '', $start = 0, $limit = 0) {
$condition = $this->make_query_condition($uid, $fuid, $fusername, $buydatestart, $buydateend, $inviteip, $code);
$data = array();
$query = DB::query("SELECT * FROM %t $condition[0] ORDER BY id DESC ".DB::limit($start, $limit), $condition[1]);
while($value = DB::fetch($query)) {
$this->_uids[$value['uid']] = $value['uid'];
$data[] = $value;
}
return $data;
}
public function count_by_uid_fuid($uid, $fuid) {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE uid=%d AND fuid=%d', array($this->_table, $uid, $fuid));
}
public function count_by_uid_dateline($uid, $dateline) {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE uid=%d AND dateline>%d', array($this->_table, $uid, $dateline));
}
public function count_by_search($uid = 0, $fuid = 0, $fusername = '', $buydatestart = 0, $buydateend = 0, $inviteip = '', $code = '') {
$condition = $this->make_query_condition($uid, $fuid, $fusername, $buydatestart, $buydateend, $inviteip, $code);
return DB::result_first('SELECT COUNT(*) FROM %t '.$condition[0], $condition[1]);
}
public function delete_by_uid_or_fuid($uids) {
$uids = dintval($uids, true);
if(!$uids) {
return null;
}
DB::delete($this->_table, DB::field('uid', $uids).' OR '.DB::field('fuid', $uids));
}
public function get_uids() {
return $this->_uids;
}
private function make_query_condition($uid = 0, $fuid = 0, $fusername = '', $buydatestart = 0, $buydateend = 0, $inviteip = '', $code = '') {
$parameter = array($this->_table);
$wherearr = array();
if(!empty($uid)) {
$parameter[] = $uid;
$wherearr[] = 'uid=%d';
}
if(!empty($fuid)) {
$parameter[] = $fuid;
$wherearr[] = 'fuid=%d';
}
if(!empty($fusername)) {
$parameter[] = $fusername;
$wherearr[] = "fusername=%s";
}
if(!empty($code)) {
$parameter[] = $code;
$wherearr[] = 'code=%s';
}
if($buydatestart) {
$parameter[] = $buydatestart;
$wherearr[] = "dateline>%d";
}
if($buydateend) {
$parameter[] = $buydateend;
$wherearr[] = 'dateline<%d';
}
if(!empty($inviteip)) {
$parameter[] = '%'.$inviteip.'%';
$wherearr[] = "inviteip LIKE %s";
}
$wheresql = !empty($wherearr) && is_array($wherearr) ? ' WHERE '.implode(' AND ', $wherearr) : '';
return array($wheresql, $parameter);
}
}
?>

View File

@@ -0,0 +1,67 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_magic.php 27449 2012-02-01 05:32:35Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_magic extends discuz_table
{
public function __construct() {
$this->_table = 'common_magic';
$this->_pk = 'magicid';
parent::__construct();
}
public function fetch_all_data($available = false) {
$available = $available !== false ? ' WHERE available='.intval($available) : '';
return DB::fetch_all('SELECT * FROM %t %i ORDER BY displayorder', array($this->_table, $available));
}
public function check_identifier($identifier, $magicid) {
return DB::result_first("SELECT COUNT(*) FROM %t WHERE identifier=%s AND magicid!=%d", array($this->_table, $identifier, $magicid));
}
public function count_page($operation) {
$salevolume = $operation == 'index' ? '' : 'AND salevolume>0';
return DB::result_first('SELECT COUNT(*) FROM %t WHERE available=1 %i', array($this->_table, $salevolume));
}
public function fetch_all_page($operation, $start, $limit) {
if($operation == 'index') {
$salevolume = '';
$orderby = "displayorder, magicid";
} else {
$salevolume = 'AND salevolume>0';
$orderby = "salevolume DESC, magicid";
}
return DB::fetch_all('SELECT * FROM %t WHERE available=1 %i ORDER BY %i LIMIT %d,%d', array($this->_table, $salevolume, $orderby, $start, $limit));
}
public function fetch_all_name_by_available($available = 1) {
return DB::fetch_all('SELECT magicid, name FROM %t WHERE available=%d ORDER BY displayorder', array($this->_table, $available), $this->_pk);
}
public function fetch_by_identifier($identifier) {
return DB::fetch_first('SELECT * FROM %t WHERE identifier=%s', array($this->_table, $identifier));
}
public function update_salevolume($magicid, $number) {
DB::query("UPDATE %t SET num=num+('-%d'), salevolume=salevolume+'%d' WHERE magicid=%d", array($this->_table, $number, $number, $magicid));
}
public function fetch_member_magic($uid, $identifier) {
return DB::fetch_first('SELECT mm.* FROM %t cm INNER JOIN %t mm ON mm.uid=%d AND mm.magicid=cm.magicid WHERE cm.identifier=%s', array($this->_table, 'common_member_magic', $uid, $identifier));
}
}
?>

View File

@@ -0,0 +1,89 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_magiclog.php 31034 2012-07-11 04:03:30Z zhangjie $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_magiclog extends discuz_table_archive
{
public function __construct() {
$this->_table = 'common_magiclog';
$this->_pk = '';
parent::__construct();
}
public function fetch_all_by_magicid_action($magicid, $action, $start = 0, $limit = 0) {
$sql = array();
if($magicid) {
$magicid = dintval($magicid, true);
$sql[] = DB::field('magicid', $magicid);
}
if($action) {
$sql[] = DB::field('action', $action);
}
$wheresql = ($sql ? 'WHERE ' : '').implode(' AND ', $sql);
return DB::fetch_all('SELECT * FROM %t %i ORDER BY dateline DESC '.DB::limit($start, $limit), array($this->_table, $wheresql));
}
public function fetch_all_by_magicid_action_uid($mid, $action, $uid, $start = 0, $limit = 0) {
return DB::fetch_all('SELECT * FROM %t WHERE magicid=%d AND action=%d AND uid!=%d ORDER BY dateline DESC '.DB::limit($start, $limit), array($this->_table, $mid, $action, $uid));
}
public function fetch_all_by_uid_action($uid, $action, $start, $limit, $order = 'DESC') {
return DB::fetch_all('SELECT * FROM %t WHERE uid=%d AND action=%d '.($order ? 'ORDER BY '.DB::order('dateline', $order) : '').' '.($limit ? DB::limit($start, $limit) : ''), array($this->_table, $uid, $action));
}
public function fetch_all_by_targetuid_action($uid, $action, $start, $limit, $order = 'DESC') {
return DB::fetch_all('SELECT * FROM %t WHERE targetuid=%d AND action=%d '.($order ? 'ORDER BY '.DB::order('dateline', $order) : '').' '.($limit ? DB::limit($start, $limit) : ''), array($this->_table, $uid, $action));
}
public function count_by_targetuid_action($uid, $action) {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE targetuid=%d AND action=%d', array($this->_table, $uid, $action));
}
public function count_by_magicid_action($magicid, $action) {
$sql = array();
if($magicid) {
$magicid = dintval($magicid, true);
$sql[] = DB::field('magicid', $magicid);
}
if($action) {
$sql[] = DB::field('action', $action);
}
$wheresql = ($sql ? 'WHERE ' : '').implode(' AND ', $sql);
return DB::result_first('SELECT COUNT(*) FROM %t %i', array($this->_table, $wheresql));
}
public function count_by_action_uid_targetid_idtype_magicid($action, $uid, $targetid, $idtype, $magicid) {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE action=%d AND uid=%d AND targetid=%d AND idtype=%d AND magicid=%d', array($this->_table, $action, $uid, $targetid, $idtype, $magicid));
}
public function count_by_uid_magicid_action_dateline($uid, $magicid, $action, $dateline) {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE uid=%d AND magicid=%d AND action=%d AND dateline>%d', array($this->_table, $uid, $magicid, $action, $dateline));
}
public function count_by_uid_action($uid, $action) {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE uid=%d AND action=%d', array($this->_table, $uid, $action));
}
public function count_by_action_uid_dateline($action, $uid, $dateline, $maxdateline = 0) {
$wherearr = array();
$wherearr[] = 'action=%d';
$wherearr[] = 'uid=%d';
$wherearr[] = $maxdateline ? 'dateline BETWEEN %d AND %d' : 'dateline>%d';
$parameter = array($this->_table, $action, $uid, $dateline);
if($maxdateline) {
$parameter[] = $maxdateline;
}
return DB::result_first('SELECT COUNT(*) FROM %t WHERE '.implode(' AND ', $wherearr), $parameter);
}
public function delete_by_magicid($ids) {
$ids = dintval($ids, true);
if($ids) {
return DB::delete($this->_table, DB::field('magicid', $ids));
}
return 0;
}
}
?>

View File

@@ -0,0 +1,45 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_mailcron.php 27806 2012-02-15 03:20:46Z svn_project_zhangjie $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_mailcron extends discuz_table
{
public function __construct() {
$this->_table = 'common_mailcron';
$this->_pk = 'cid';
parent::__construct();
}
public function delete_by_touid($touids) {
if(empty($touids)) {
return false;
}
return DB::query('DELETE FROM mc, mq USING %t AS mc, %t AS mq WHERE mc.'.DB::field('touid', $touids).' AND mc.cid=mq.cid',
array($this->_table, 'common_mailqueue'), false, true);
}
public function fetch_all_by_email($email, $start, $limit) {
return DB::fetch_all('SELECT * FROM %t WHERE email=%s '.DB::limit($start, $limit), array($this->_table, $email));
}
public function fetch_all_by_touid($touid, $start, $limit) {
return DB::fetch_all('SELECT * FROM %t WHERE touid=%d '.DB::limit($start, $limit), array($this->_table, $touid));
}
public function fetch_all_by_sendtime($sendtime, $start, $limit) {
return DB::fetch_all('SELECT * FROM %t WHERE sendtime<=%d ORDER BY sendtime '.DB::limit($start, $limit), array($this->_table, $sendtime));
}
}
?>

View File

@@ -0,0 +1,39 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_mailqueue.php 27806 2012-02-15 03:20:46Z svn_project_zhangjie $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_mailqueue extends discuz_table
{
public function __construct() {
$this->_table = 'common_mailqueue';
$this->_pk = 'qid';
parent::__construct();
}
public function fetch_all_by_cid($cids) {
if(empty($cids)) {
return array();
}
return DB::fetch_all('SELECT * FROM %t WHERE '.DB::field('cid', $cids), array($this->_table));
}
public function delete_by_cid($cids) {
if(empty($cids)) {
return false;
}
return DB::query('DELETE FROM %t WHERE '.DB::field('cid', $cids), array($this->_table));
}
}
?>

View File

@@ -0,0 +1,536 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_member.php 31849 2012-10-17 04:39:16Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member extends discuz_table_archive
{
public function __construct() {
$this->_table = 'common_member';
$this->_pk = 'uid';
$this->_pre_cache_key = 'common_member_';
parent::__construct();
}
public function update_credits($uid, $credits) {
if($uid) {
$data = array('credits'=>intval($credits));
DB::update($this->_table, $data, array('uid' => intval($uid)), 'UNBUFFERED');
$this->update_cache($uid, $data);
}
}
public function update_by_groupid($groupid, $data) {
$uids = array();
$groupid = dintval($groupid, true);
if($groupid && $this->_allowmem) {
$uids = array_keys($this->fetch_all_by_groupid($groupid));
}
if($groupid && !empty($data) && is_array($data)) {
DB::update($this->_table, $data, DB::field('groupid', $groupid), 'UNBUFFERED');
}
if($uids) {
$this->update_cache($uids, $data);
}
}
public function increase($uids, $setarr) {
$uids = dintval((array)$uids, true);
$sql = array();
$allowkey = array('credits', 'newpm', 'newprompt');
foreach($setarr as $key => $value) {
if(($value = intval($value)) && in_array($key, $allowkey)) {
$sql[] = "`$key`=`$key`+'$value'";
}
}
if(!empty($sql)){
DB::query("UPDATE ".DB::table($this->_table)." SET ".implode(',', $sql)." WHERE uid IN (".dimplode($uids).")", 'UNBUFFERED');
$this->increase_cache($uids, $setarr);
}
}
public function fetch_by_username($username, $fetch_archive = 0) {
$user = array();
if($username) {
$user = DB::fetch_first('SELECT * FROM %t WHERE username=%s', array($this->_table, $username));
if(isset($this->membersplit) && $fetch_archive && empty($user)) {
$user = C::t($this->_table.'_archive')->fetch_by_username($username, 0);
}
}
return $user;
}
public function fetch_all_by_username($usernames, $fetch_archive = 1) {
$users = array();
if(!empty($usernames)) {
$users = DB::fetch_all('SELECT * FROM %t WHERE username IN (%n)', array($this->_table, (array)$usernames), 'username');
if(isset($this->membersplit) && $fetch_archive && count($usernames) !== count($users)) {
$users += C::t($this->_table.'_archive')->fetch_all_by_username($usernames, 0);
}
}
return $users;
}
public function fetch_uid_by_username($username, $fetch_archive = 0) {
$uid = 0;
if($username) {
$uid = DB::result_first('SELECT uid FROM %t WHERE username=%s', array($this->_table, $username));
if(isset($this->membersplit) && $fetch_archive && empty($uid)) {
$uid = C::t($this->_table.'_archive')->fetch_uid_by_username($username, 0);
}
}
return $uid;
}
public function fetch_all_uid_by_username($usernames, $fetch_archive = 1) {
$uids = array();
if($usernames) {
foreach($this->fetch_all_by_username($usernames, $fetch_archive) as $username => $value) {
$uids[$username] = $value['uid'];
}
}
return $uids;
}
public function fetch_all_by_adminid($adminids, $fetch_archive = 1) {
$users = array();
$adminids = dintval((array)$adminids, true);
if($adminids) {
$users = DB::fetch_all('SELECT * FROM %t WHERE adminid IN (%n) ORDER BY adminid, uid', array($this->_table, (array)$adminids), $this->_pk);
if(isset($this->membersplit) && $fetch_archive) {
$users += C::t($this->_table.'_archive')->fetch_all_by_adminid($adminids, 0);
}
}
return $users;
}
public function fetch_all_username_by_uid($uids) {
$users = array();
if(($uids = dintval($uids, true))) {
foreach($this->fetch_all($uids) as $uid => $value) {
$users[$uid] = $value['username'];
}
}
return $users;
}
public function count_by_groupid($groupid) {
return $groupid ? DB::result_first('SELECT COUNT(*) FROM %t WHERE '.DB::field('groupid', $groupid), array($this->_table)) : 0;
}
public function fetch_all_by_groupid($groupid, $start = 0, $limit = 0) {
$users = array();
if(($groupid = dintval($groupid, true))) {
$users = DB::fetch_all('SELECT * FROM '.DB::table($this->_table).' WHERE '.DB::field('groupid', $groupid).' '.DB::limit($start, $limit), null, 'uid');
}
return $users;
}
public function fetch_all_groupid() {
return DB::fetch_all('SELECT DISTINCT(groupid) FROM '.DB::table($this->_table), null, 'groupid');
}
public function fetch_all_by_allowadmincp($val, $glue = '=') {
return DB::fetch_all('SELECT * FROM '.DB::table($this->_table).' WHERE '.DB::field('allowadmincp', intval($val), $glue), NULL, 'uid');
}
public function update_admincp_manage($uids) {
if(($uids = dintval($uids, true))) {
$data = DB::query('UPDATE '.DB::table($this->_table).' SET allowadmincp=allowadmincp | 1 WHERE uid IN ('.dimplode($uids).')');
$this->reset_cache($uids);
return $data;
}
return false;
}
public function clean_admincp_manage($uids) {
if(($uids = dintval($uids, true))) {
$data = DB::query('UPDATE '.DB::table($this->_table).' SET allowadmincp=allowadmincp & 0xFE WHERE uid IN ('.dimplode($uids).')');
$this->reset_cache($uids);
return $data;
}
return false;
}
public function fetch_all_ban_by_groupexpiry($timestamp) {
return ($timestamp = intval($timestamp)) ? DB::fetch_all("SELECT uid, groupid, credits FROM ".DB::table($this->_table)." WHERE groupid IN ('4', '5') AND groupexpiry>'0' AND groupexpiry<'$timestamp'", array(), 'uid') : array();
}
public function count($fetch_archive = 1) {
$count = DB::result_first('SELECT COUNT(*) FROM %t', array($this->_table));
if(isset($this->membersplit) && $fetch_archive) {
$count += C::t($this->_table.'_archive')->count(0);
}
$count += intval(DB::result_first('SELECT COUNT(*) FROM '.DB::table('common_connect_guest'), null, true));
return $count;
}
public function fetch_by_email($email, $fetch_archive = 0) {
$user = array();
if($email) {
$user = DB::fetch_first('SELECT * FROM %t WHERE email=%s', array($this->_table, $email));
if(isset($this->membersplit) && $fetch_archive && empty($user)) {
$user = C::t($this->_table.'_archive')->fetch_by_email($email, 0);
}
}
return $user;
}
public function fetch_all_by_email($emails, $fetch_archive = 1) {
$users = array();
if(!empty($emails)) {
$users = DB::fetch_all('SELECT * FROM %t WHERE %i', array($this->_table, DB::field('email', $emails)), 'email');
if(isset($this->membersplit) && $fetch_archive && count($emails) !== count($users)) {
$users += C::t($this->_table.'_archive')->fetch_all_by_email($emails, 0);
}
}
return $users;
}
public function count_by_email($email, $fetch_archive = 0) {
$count = 0;
if($email) {
$count = DB::result_first('SELECT COUNT(*) FROM %t WHERE email=%s', array($this->_table, $email));
if(isset($this->membersplit) && $fetch_archive) {
$count += C::t($this->_table.'_archive')->count_by_email($email, 0);
}
}
return $count;
}
public function fetch_all_by_like_username($username, $start = 0, $limit = 0) {
$data = array();
if($username) {
$data = DB::fetch_all('SELECT * FROM %t WHERE username LIKE %s'.DB::limit($start, $limit), array($this->_table, stripsearchkey($username).'%'), 'uid');
}
return $data;
}
public function count_by_like_username($username) {
return !empty($username) ? DB::result_first('SELECT COUNT(*) FROM %t WHERE username LIKE %s', array($this->_table, stripsearchkey($username).'%')) : 0;
}
public function fetch_runtime() {
return DB::result_first("SELECT (MAX(regdate)-MIN(regdate))/86400 AS runtime FROM ".DB::table($this->_table));
}
public function count_admins() {
return DB::result_first("SELECT COUNT(*) FROM ".DB::table($this->_table)." WHERE adminid<>'0' AND adminid<>'-1'");
}
public function count_by_regdate($timestamp) {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE regdate>%d', array($this->_table, $timestamp));
}
public function fetch_all_stat_memberlist($username, $orderby = '', $sort = '', $start = 0, $limit = 0) {
$orderby = in_array($orderby, array('uid','credits','regdate', 'gender','username','posts','lastvisit'), true) ? $orderby : 'uid';
$sql = '';
$sql = !empty($username) ? " WHERE username LIKE '".addslashes(stripsearchkey($username))."%'" : '';
$memberlist = array();
$query = DB::query("SELECT m.uid, m.username, mp.gender, m.email, m.regdate, ms.lastvisit, mc.posts, m.credits
FROM ".DB::table($this->_table)." m
LEFT JOIN ".DB::table('common_member_profile')." mp ON mp.uid=m.uid
LEFT JOIN ".DB::table('common_member_status')." ms ON ms.uid=m.uid
LEFT JOIN ".DB::table('common_member_count')." mc ON mc.uid=m.uid
$sql ORDER BY ".DB::order($orderby, $sort).DB::limit($start, $limit));
while($member = DB::fetch($query)) {
$member['usernameenc'] = rawurlencode($member['username']);
$member['regdate'] = dgmdate($member['regdate']);
$member['lastvisit'] = dgmdate($member['lastvisit']);
$memberlist[$member['uid']] = $member;
}
return $memberlist;
}
public function delete_no_validate($uids) {
if(($uids = dintval($uids, true))) {
$delnum = $this->delete($uids);
C::t('common_member_field_forum')->delete($uids);
C::t('common_member_field_home')->delete($uids);
C::t('common_member_status')->delete($uids);
C::t('common_member_count')->delete($uids);
C::t('common_member_profile')->delete($uids);
C::t('common_member_validate')->delete($uids);
return $delnum;
}
return false;
}
public function insert($data, $return_insert_id = false, $replace = false, $silent = false, $null1 = null, $null2 = null, $null3 = null, $null4 = 0, $null5 = 0) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::insert($data, $return_insert_id, $replace, $silent);
} else {
if ($return_insert_id === false || $replace === false || $silent === false || $null1 === null || $null2 === null || $null3 === null) {
throw new Exception("Invalid Use C:t('common_member')->insert Function.");
}
return $this->insert_user($data, $return_insert_id, $replace, $silent, $null1, $null2, $null3, $null4, $null5);
}
}
public function insert_user($uid, $username, $password, $email, $ip, $groupid, $extdata, $adminid = 0, $port = 0) {
if(($uid = dintval($uid))) {
$credits = isset($extdata['credits']) ? $extdata['credits'] : array();
$profile = isset($extdata['profile']) ? $extdata['profile'] : array();
$profile['uid'] = $uid;
$base = array(
'uid' => $uid,
'username' => (string)$username,
'password' => (string)$password,
'email' => (string)$email,
'adminid' => intval($adminid),
'groupid' => intval($groupid),
'regdate' => TIMESTAMP,
'emailstatus' => intval($extdata['emailstatus']),
'credits' => dintval($credits[0]),
'timeoffset' => 9999
);
$status = array(
'uid' => $uid,
'regip' => (string)$ip,
'lastip' => (string)$ip,
'port' => (string)$port,
'regport' => (string)$port,
'lastvisit' => TIMESTAMP,
'lastactivity' => TIMESTAMP,
'lastpost' => 0,
'lastsendmail' => 0
);
$count = array(
'uid' => $uid,
'extcredits1' => dintval($credits[1]),
'extcredits2' => dintval($credits[2]),
'extcredits3' => dintval($credits[3]),
'extcredits4' => dintval($credits[4]),
'extcredits5' => dintval($credits[5]),
'extcredits6' => dintval($credits[6]),
'extcredits7' => dintval($credits[7]),
'extcredits8' => dintval($credits[8])
);
$ext = array('uid' => $uid);
parent::insert($base, false, true);
C::t('common_member_status')->insert($status, false, true);
C::t('common_member_count')->insert($count, false, true);
C::t('common_member_profile')->insert($profile, false, true);
C::t('common_member_field_forum')->insert($ext, false, true);
C::t('common_member_field_home')->insert($ext, false, true);
}
}
public function delete($val, $unbuffered = false, $fetch_archive = 0) {
$ret = false;
if(($val = dintval($val, true))) {
$ret = parent::delete($val, $unbuffered, $fetch_archive);
if($this->_allowmem) {
$data = ($data = memory('get', 'deleteuids')) === false ? array() : $data;
foreach((array)$val as $uid) {
$data[$uid] = $uid;
}
memory('set', 'deleteuids', $data, 86400*2);
}
}
return $ret;
}
public function count_zombie() {
$dateline = TIMESTAMP - 31536000;//60*60*24*365
return DB::result_first('SELECT count(*) FROM %t mc, %t ms WHERE mc.posts<5 AND ms.lastvisit<%d AND ms.uid=mc.uid', array('common_member_count', 'common_member_status', $dateline));
}
public function split($splitnum, $iscron = false) {
loadcache('membersplitdata');
@set_time_limit(0);
discuz_database_safecheck::setconfigstatus(0);
$dateline = TIMESTAMP - 31536000;//60*60*24*365
$temptablename = DB::table('common_member_temp___');
if(!DB::fetch_first("SHOW TABLES LIKE '$temptablename'")) {
$engine = strtolower(getglobal("config/db/common/engine")) !== 'innodb' ? 'MyISAM' : 'InnoDB';
DB::query("CREATE TABLE $temptablename (`uid` int(10) NOT NULL DEFAULT 0,PRIMARY KEY (`uid`)) ENGINE=" . $engine . ";");
}
$splitnum = max(0, intval($splitnum));
if(!DB::result_first('SELECT COUNT(*) FROM '.$temptablename)) {
DB::query('INSERT INTO '.$temptablename.' (`uid`) SELECT ms.uid AS uid FROM %t mc, %t ms WHERE mc.posts<5 AND ms.lastvisit<%d AND mc.uid=ms.uid ORDER BY ms.uid DESC LIMIT %d', array('common_member_count', 'common_member_status', $dateline, $splitnum));
}
if(DB::result_first('SELECT COUNT(*) FROM '.$temptablename) > 1) {
if(!$iscron && getglobal('setting/memberspliting') === null) {
$this->switch_keys('disable');
}
$uidlist = DB::fetch_all('SELECT uid FROM '.$temptablename.' ORDER BY uid DESC', null, 'uid');
unset($uidlist[key($uidlist)]);
$uids = dimplode(array_keys($uidlist));
$movesql = 'REPLACE INTO %t SELECT * FROM %t WHERE uid IN ('.$uids.')';
$deletesql = 'DELETE FROM %t WHERE uid IN ('.$uids.')';
if(DB::query($movesql, array('common_member_archive', 'common_member'), false, true)) {
DB::query($deletesql, array('common_member'), false, true);
}
if(DB::query($movesql, array('common_member_profile_archive', 'common_member_profile'), false, true)) {
DB::query($deletesql, array('common_member_profile'), false, true);
}
if(DB::query($movesql, array('common_member_field_forum_archive', 'common_member_field_forum'), false, true)) {
DB::query($deletesql, array('common_member_field_forum'), false, true);
}
if(DB::query($movesql, array('common_member_field_home_archive', 'common_member_field_home'), false, true)) {
DB::query($deletesql, array('common_member_field_home'), false, true);
}
if(DB::query($movesql, array('common_member_status_archive', 'common_member_status'), false, true)) {
DB::query($deletesql, array('common_member_status'), false, true);
}
if(DB::query($movesql, array('common_member_count_archive', 'common_member_count'), false, true)) {
DB::query($deletesql, array('common_member_count'), false, true);
}
DB::query('DROP TABLE '.$temptablename);
$membersplitdata = getglobal('cache/membersplitdata');
$zombiecount = $membersplitdata['zombiecount'] - $splitnum;
if($zombiecount < 0) {
$zombiecount = 0;
}
savecache('membersplitdata', array('membercount' => $membersplitdata['membercount'], 'zombiecount' => $zombiecount, 'dateline' => TIMESTAMP));
C::t('common_setting')->delete('memberspliting');
return true;
} else {
DB::query('DROP TABLE '.$temptablename);
if(!$iscron) {
$this->switch_keys('enable');
C::t('common_member_profile')->optimize();
C::t('common_member_field_forum')->optimize();
C::t('common_member_field_home')->optimize();
}
return false;
}
}
public function switch_keys($type) {
if($type === 'disable') {
$type = 'DISABLE';
C::t('common_setting')->update_batch(array('memberspliting'=>1, 'membersplit'=>1));
} else {
$type = 'ENABLE';
C::t('common_setting')->delete('memberspliting');
}
require_once libfile('function/cache');
updatecache('setting');
}
public function count_by_credits($credits) {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE credits>%d', array($this->_table, $credits));
}
public function fetch_all_for_spacecp_search($wherearr, $fromarr, $start = 0, $limit = 100) {
if(!$start && !$limit) {
$start = 100;
}
if(!$wherearr) {
$wherearr[] = '1';
}
if(!$fromarr) {
$fromarr[] = DB::table($this->_table);
}
return DB::fetch_all("SELECT s.* FROM ".implode(',', $fromarr)." WHERE ".implode(' AND ', $wherearr).DB::limit($start, $limit));
}
public function fetch_all_girls_for_ranklist($offset = 0, $limit = 20, $orderby = 'ORDER BY s.unitprice DESC, s.credit DESC') {
$members = array();
$query = DB::query("SELECT m.uid, m.username, mc.*, mp.gender
FROM ".DB::table('common_member')." m
LEFT JOIN ".DB::table('home_show')." s ON s.uid=m.uid
LEFT JOIN ".DB::table('common_member_profile')." mp ON mp.uid=m.uid
LEFT JOIN ".DB::table('common_member_count')." mc ON mc.uid=m.uid
WHERE mp.gender='2'
ORDER BY $orderby
LIMIT $offset, $limit");
while($member = DB::fetch($query)) {
$member['avatar'] = avatar($member['uid'], 'small');
$members[] = $member;
}
return $members;
}
public function fetch_all_order_by_credit_for_ranklist($num, $orderby) {
$data = array();
if(!($num = intval($num))) {
return $data;
}
if($orderby === 'all') {
$sql = "SELECT m.uid,m.username,m.groupid,m.credits,field.spacenote FROM ".DB::table('common_member')." m
LEFT JOIN ".DB::table('common_member_field_home')." field ON field.uid=m.uid
ORDER BY m.credits DESC LIMIT 0, $num";
} else {
$orderby = intval($orderby);
$orderby = in_array($orderby, array(1, 2, 3, 4, 5, 6, 7, 8)) ? $orderby : 1;
$sql = "SELECT m.uid,m.username,m.groupid, mc.extcredits$orderby AS extcredits
FROM ".DB::table('common_member')." m
LEFT JOIN ".DB::table('common_member_count')." mc ON mc.uid=m.uid WHERE mc.extcredits$orderby>0
ORDER BY extcredits$orderby DESC LIMIT 0, $num";
}
$query = DB::query($sql);
while($result = DB::fetch($query)) {
$data[] = $result;
}
return $data;
}
public function fetch_all_order_by_friendnum_for_ranklist($num) {
$num = intval($num);
$num = $num ? $num : 20;
$data = $users = $oldorder = array();
$query = DB::query('SELECT uid, friends FROM '.DB::table('common_member_count').' WHERE friends>0 ORDER BY friends DESC LIMIT '.$num);
while($user = DB::fetch($query)) {
$users[$user['uid']] = $user;
$oldorder[] = $user['uid'];
}
$uids = array_keys($users);
if($uids) {
$query = DB::query('SELECT m.uid, m.username, m.groupid, field.spacenote
FROM '.DB::table('common_member')." m
LEFT JOIN ".DB::table('common_member_field_home')." field ON m.uid=field.uid
WHERE m.uid IN (".dimplode($uids).")");
while($value = DB::fetch($query)) {
$users[$value['uid']] = array_merge($users[$value['uid']], $value);
}
foreach($oldorder as $uid) {
$data[] = $users[$uid];
}
}
return $data;
}
public function max_uid() {
return DB::result_first('SELECT MAX(uid) FROM %t', array($this->_table));
}
public function range_by_uid($from, $limit) {
return DB::fetch_all('SELECT * FROM %t WHERE uid >= %d ORDER BY uid LIMIT %d', array($this->_table, $from, $limit), $this->_pk);
}
public function update_groupid_by_groupid($source, $target) {
return DB::query('UPDATE %t SET groupid=%d WHERE adminid <= 0 AND groupid=%d', array($this->_table, $target, $source));
}
}
?>

View File

@@ -0,0 +1,41 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_member_action_log.php 28389 2012-02-28 10:27:38Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member_action_log extends discuz_table
{
public function __construct() {
$this->_table = 'common_member_action_log';
$this->_pk = 'id';
parent::__construct();
}
public function delete_by_dateline($timestamp) {
DB::delete($this->_table, 'dateline < '.dintval($timestamp));
}
public function count_day_hours($action, $uid) {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE dateline>%d AND action=%d AND uid=%d', array($this->_table, TIMESTAMP - 86400, $action, $uid));
}
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));
}
public function delete_by_uid($uids) {
DB::delete($this->_table, 'uid IN ('.dimplode($uids).')');
}
}
?>

View File

@@ -0,0 +1,242 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_member_archive.php 29613 2012-04-23 04:19:05Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member_archive extends table_common_member
{
public function __construct() {
parent::__construct();
$this->_table = 'common_member_archive';
$this->_pk = 'uid';
}
public function fetch($id, $force_from_db = true, $fetch_archive = 1){
$data = array();
if(isset($this->membersplit) && ($id = dintval($id)) && ($data = DB::fetch_first('SELECT * FROM '.DB::table($this->_table).' WHERE '.DB::field($this->_pk, $id)))) {
$data['_inarchive'] = true;
}
return $data;
}
public function fetch_by_username($username, $fetch_archive = 1) {
$user = array();
if(isset($this->membersplit) && $username && ($user = DB::fetch_first('SELECT * FROM %t WHERE username=%s', array($this->_table, $username)))) {
$user['_inarchive'] = true;
}
return $user;
}
public function fetch_uid_by_username($username, $fetch_archive = 1) {
$uid = 0;
if(isset($this->membersplit) && $username) {
$uid = DB::result_first('SELECT uid FROM %t WHERE username=%s', array($this->_table, $username));
}
return $uid;
}
public function count($fetch_archive = 1) {
return isset($this->membersplit) ? DB::result_first('SELECT COUNT(*) FROM %t', array($this->_table)) : 0;
}
public function fetch_by_email($email, $fetch_archive = 1) {
$user = array();
if(isset($this->membersplit) && $email && ($user = DB::fetch_first('SELECT * FROM %t WHERE email=%s', array($this->_table, $email)))) {
$user['_inarchive'] = true;
}
return $user;
}
public function count_by_email($email, $fetch_archive = 1) {
$count = 0;
if(isset($this->membersplit) && $email) {
$count = DB::result_first('SELECT COUNT(*) FROM %t WHERE email=%s', array($this->_table, $email));
}
return $count;
}
public function fetch_all($ids, $force_from_db = false, $fetch_archive = 1) {
$data = array();
if(isset($this->membersplit) && ($ids = dintval($ids, true))) {
$query = DB::query('SELECT * FROM '.DB::table($this->_table).' WHERE '.DB::field($this->_pk, $ids));
while($value = DB::fetch($query)) {
$value['_inarchive'] = true;
$data[$value[$this->_pk]] = $value;
}
}
return $data;
}
public function move_to_master($uid){
if(isset($this->membersplit) && ($uid = intval($uid)) && ($member = $this->fetch($uid))) {
unset($member['_inarchive']);
DB::insert('common_member',$member);
C::t('common_member_count')->insert(C::t('common_member_count_archive')->fetch($uid));
C::t('common_member_status')->insert(C::t('common_member_status_archive')->fetch_status($uid));
C::t('common_member_profile')->insert(C::t('common_member_profile_archive')->fetch_profile($uid));
C::t('common_member_field_home')->insert(C::t('common_member_field_home_archive')->fetch($uid));
C::t('common_member_field_forum')->insert(C::t('common_member_field_forum_archive')->fetch($uid));
$this->delete($uid);
C::t('common_member_count_archive')->delete($uid);
C::t('common_member_status_archive')->delete_status($uid);
C::t('common_member_profile_archive')->delete_profile($uid);
C::t('common_member_field_home_archive')->delete($uid);
C::t('common_member_field_forum_archive')->delete($uid);
}
}
public function delete($val, $unbuffered = false, $fetch_archive = 1) {
return isset($this->membersplit) && ($val = dintval($val, true)) && DB::delete($this->_table, DB::field($this->_pk, $val), null, $unbuffered);
}
public function check_table() {
if(DB::fetch_first("SHOW TABLES LIKE '".DB::table('common_member_archive')."'")){
return false;
} else {
$mastertables = array('common_member', 'common_member_count', 'common_member_status', 'common_member_profile', 'common_member_field_home', 'common_member_field_forum');
foreach($mastertables as $tablename) {
$createtable = DB::fetch_first('SHOW CREATE TABLE '.DB::table($tablename));
DB::query(str_replace(DB::table($tablename), DB::table("{$tablename}_archive"), $createtable['Create Table']));
}
return true;
}
}
public function rebuild_table($step) {
$mastertables = array('common_member', 'common_member_count', 'common_member_status', 'common_member_profile', 'common_member_field_home', 'common_member_field_forum');
if(!isset($mastertables[$step])) {
return false;
}
$updates = array();
$mastertable = DB::table($mastertables[$step]);
$archivetable = DB::table($mastertables[$step].'_archive');
$mastercols = DB::fetch_all('SHOW COLUMNS FROM '.$mastertable, null, 'Field');
$archivecols = DB::fetch_all('SHOW COLUMNS FROM '.$archivetable, null, 'Field');
foreach(array_diff(array_keys($archivecols), array_keys($mastercols)) as $field) {
$updates[] = "DROP `$field`";
}
$createtable = DB::fetch_first('SHOW CREATE TABLE '.$mastertable);
$mastercols = $this->getcolumn($createtable['Create Table']);
$archivecreatetable = DB::fetch_first('SHOW CREATE TABLE '.$archivetable);
$oldcols = $this->getcolumn($archivecreatetable['Create Table']);
$indexmastercols =array_keys($mastercols);
foreach ($mastercols as $key => $value) {
if($key == 'PRIMARY') {
if($value != $oldcols[$key]) {
if(!empty($oldcols[$key])) {
$usql = "RENAME TABLE ".$archivetable." TO ".$archivetable.'_bak';
if(!DB::query($usql, 'SILENT')) {
return $mastertable;
}
}
$updates[] = "ADD PRIMARY KEY $value";
}
} elseif ($key == 'KEY') {
foreach ($value as $subkey => $subvalue) {
if(!empty($oldcols['KEY'][$subkey])) {
if($subvalue != $oldcols['KEY'][$subkey]) {
$updates[] = "DROP INDEX `$subkey`";
$updates[] = "ADD INDEX `$subkey` $subvalue";
}
} else {
$updates[] = "ADD INDEX `$subkey` $subvalue";
}
}
} elseif ($key == 'UNIQUE') {
foreach ($value as $subkey => $subvalue) {
if(!empty($oldcols['UNIQUE'][$subkey])) {
if($subvalue != $oldcols['UNIQUE'][$subkey]) {
$updates[] = "DROP INDEX `$subkey`";
$updates[] = "ADD UNIQUE INDEX `$subkey` $subvalue";
}
} else {
$usql = "ALTER TABLE ".$archivetable." DROP INDEX `$subkey`";
DB::query($usql, 'SILENT');
$updates[] = "ADD UNIQUE INDEX `$subkey` $subvalue";
}
}
} else {
if(!empty($oldcols[$key])) {
if(strtolower($value) != strtolower($oldcols[$key])) {
$updates[] = "CHANGE `$key` `$key` $value";
}
} else {
$i = array_search($key, $indexmastercols);
$fieldposition = $i > 0 ? 'AFTER '.$indexmastercols[$i-1] : 'FIRST';
$updates[] = "ADD `$key` $value $fieldposition";
}
}
}
$ret = true;
if(!empty($updates)) {
if(!DB::query("ALTER TABLE ".$archivetable." ".implode(', ', $updates), 'SILENT')) {
$ret = $mastertable;
} else {
}
}
return $ret;
}
private function getcolumn($creatsql) {
$creatsql = preg_replace("/ COMMENT '.*?'/i", '', $creatsql);
$matchs = array();
preg_match("/\((.+)\)\s*(ENGINE|TYPE)\s*\=/is", $creatsql, $matchs);
$cols = explode("\n", $matchs[1]);
$newcols = array();
foreach ($cols as $value) {
$value = trim($value);
if(empty($value)) continue;
$value = $this->remakesql($value);
if(substr($value, -1) == ',') $value = substr($value, 0, -1);
$vs = explode(' ', $value);
$cname = $vs[0];
if($cname == 'KEY' || $cname == 'INDEX' || $cname == 'UNIQUE') {
$name_length = strlen($cname);
if($cname == 'UNIQUE') $name_length = $name_length + 4;
$subvalue = trim(substr($value, $name_length));
$subvs = explode(' ', $subvalue);
$subcname = $subvs[0];
$newcols[$cname][$subcname] = trim(substr($value, ($name_length+2+strlen($subcname))));
} elseif($cname == 'PRIMARY') {
$newcols[$cname] = trim(substr($value, 11));
} else {
$newcols[$cname] = trim(substr($value, strlen($cname)));
}
}
return $newcols;
}
private function remakesql($value) {
$value = trim(preg_replace("/\s+/", ' ', $value));
$value = str_replace(array('`',', ', ' ,', '( ' ,' )', 'mediumtext'), array('', ',', ',','(',')','text'), $value);
return $value;
}
}
?>

View File

@@ -0,0 +1,108 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_member_count.php 31022 2012-07-10 03:16:07Z chenmengshu $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member_count extends discuz_table_archive
{
public function __construct() {
$this->_table = 'common_member_count';
$this->_pk = 'uid';
$this->_pre_cache_key = 'common_member_count_';
parent::__construct();
}
public function increase($uids, $creditarr) {
$uids = dintval((array)$uids, true);
$sql = array();
$allowkey = array('extcredits1', 'extcredits2', 'extcredits3', 'extcredits4', 'extcredits5', 'extcredits6', 'extcredits7', 'extcredits8',
'friends', 'posts', 'threads', 'oltime', 'digestposts', 'doings', 'blogs', 'albums', 'sharings', 'attachsize', 'views',
'todayattachs', 'todayattachsize', 'follower', 'following', 'newfollower', 'feeds', 'blacklist');
foreach($creditarr as $key => $value) {
if(($value = intval($value)) && $value && in_array($key, $allowkey)) {
$sql[] = "`$key`=`$key`+'$value'";
}
}
if(!empty($sql)){
DB::query("UPDATE ".DB::table($this->_table)." SET ".implode(',', $sql)." WHERE uid IN (".dimplode($uids).")", 'UNBUFFERED');
$this->increase_cache($uids, $creditarr);
}
}
public function clear_extcredits($uids, $extcredits) {
$uids = dintval((array)$uids, true);
$sql = $data = array();
$allowkey = array('extcredits1', 'extcredits2', 'extcredits3', 'extcredits4', 'extcredits5', 'extcredits6', 'extcredits7', 'extcredits8');
foreach($extcredits as $value) {
if(in_array($value, $allowkey, true)) {
$sql[] = "`$value`='0'";
$data[$value] = 0;
}
}
if(!empty($sql)) {
DB::query("UPDATE ".DB::table($this->_table)." SET ".implode(',', $sql)." WHERE uid IN (".dimplode($uids).")", 'UNBUFFERED');
$this->update_batch_cache($uids, $data);
}
}
public function count_by_posts($num) {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE posts=%d', array($this->_table, $num));
}
public function range_by_field($start = 0, $limit = 0, $orderby = '', $sort = '') {
$orderby = in_array($orderby, array(
'extcredits1', 'extcredits2', 'extcredits3', 'extcredits4', 'extcredits5', 'extcredits6', 'extcredits7', 'extcredits8',
'friends', 'posts', 'threads', 'oltime', 'digestposts', 'doings', 'blogs', 'albums', 'sharings', 'attachsize', 'views',
'todayattachs', 'todayattachsize', 'follower', 'following', 'newfollower', 'feeds', 'blacklist'), true) ? $orderby : '';
return DB::fetch_all('SELECT * FROM '.DB::table($this->_table).($orderby ? ' ORDER BY '.DB::order($orderby, $sort) : '').DB::limit($start, $limit), null, $this->_pk);
}
public function clear_digestposts() {
$uids = array();
if($this->_allowmem) {
$uids = DB::fetch_all('SELECT uid FROM '.DB::table($this->_table).' WHERE digestposts<>0', null, $this->_pk);
}
$data = DB::query("UPDATE ".DB::table($this->_table)." SET digestposts=0", 'UNBUFFERED');
if(!empty($uids)) {
$this->update_batch_cache(array_keys($uids), array('digestposts' => 0));
}
return $data;
}
public function clear_today_data() {
$uids = array();
if($this->_allowmem) {
$uids = DB::fetch_all('SELECT uid FROM '.DB::table($this->_table).' WHERE todayattachs<>0 OR todayattachsize<>0', null, $this->_pk);
}
$data = DB::query("UPDATE ".DB::table($this->_table)." SET todayattachs='0',todayattachsize='0'", 'UNBUFFERED');
if(!empty($uids)) {
$this->update_batch_cache(array_keys($uids), array('todayattachs' => 0, 'todayattachsize' => 0));
}
return $data;
}
public function count_by_extcredits($extcredits, $credits) {
$count = 0;
if(in_array($extcredits, array(1,2,3,4,5,6,7,8))) {
$count = DB::result_first('SELECT COUNT(*) FROM %t WHERE extcredits'.$extcredits.'>%d', array($this->_table, $credits));
}
return $count;
}
public function count_by_friends($friends) {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE friends>%d', array($this->_table, $friends));
}
}
?>

View File

@@ -0,0 +1,43 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_member_count_archive.php 28589 2012-03-05 09:54:11Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member_count_archive extends table_common_member_count
{
public function __construct() {
parent::__construct();
$this->_table = 'common_member_count_archive';
$this->_pk = 'uid';
}
public function fetch($id, $force_from_db = true, $fetch_archive = 1){
return ($id = dintval($id)) ? DB::fetch_first('SELECT * FROM '.DB::table($this->_table).' WHERE '.DB::field($this->_pk, $id)) : array();
}
public function fetch_all($ids, $force_from_db = true, $fetch_archive = 1) {
$data = array();
if(($ids = dintval($ids, true))) {
$query = DB::query('SELECT * FROM '.DB::table($this->_table).' WHERE '.DB::field($this->_pk, $ids));
while($value = DB::fetch($query)) {
$data[$value[$this->_pk]] = $value;
}
}
return $data;
}
public function delete($val, $unbuffered = false, $fetch_archive = 1) {
return ($val = dintval($val, true)) && DB::delete($this->_table, DB::field($this->_pk, $val), null, $unbuffered);
}
}
?>

View File

@@ -0,0 +1,60 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_member_crime.php 34074 2013-10-08 01:30:38Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member_crime extends discuz_table
{
public function __construct() {
$this->_table = 'common_member_crime';
$this->_pk = 'cid';
parent::__construct();
}
public function fetch_all_by_uid($uid) {
return $uid ? DB::fetch_all('SELECT * FROM %t WHERE uid=%d ORDER BY dateline DESC', array($this->_table, $uid), $this->_pk) : array();
}
public function count_by_uid_action($uid, $action) {
return $uid ? DB::result_first('SELECT COUNT(*) FROM %t WHERE uid=%d AND action=%d', array($this->_table, $uid, $action)) : 0;
}
public function count_by_where($where) {
return $where ? DB::result_first('SELECT COUNT(*) FROM %t %i ', array($this->_table, $where)) : $this->count();
}
public function fetch_all_by_where($where, $start = 0, $limit = 0) {
return DB::fetch_all('SELECT * FROM %t %i ORDER BY dateline DESC '.DB::limit($start, $limit), array($this->_table, $where));
}
public function fetch_all_by_uid_action($uid, $action) {
return DB::fetch_all('SELECT * FROM %t WHERE '.DB::field('uid', $uid).' AND '.DB::field('action', $action).' ORDER BY dateline', array($this->_table));
}
public function fetch_all_by_cid($cid, $action, $limit) {
if(!$cid) {
return DB::fetch_all('SELECT * FROM %t '.($action ? 'WHERE '.DB::field('action', $action) : '').' ORDER BY cid DESC '.DB::limit($limit), array($this->_table), $this->_pk);
} else {
return DB::fetch_all('SELECT * FROM %t WHERE '.DB::field('cid', $cid, '<').($action ? ' AND '.DB::field('action', $action) : '').' ORDER BY cid DESC '.DB::limit($limit), array($this->_table), $this->_pk);
}
}
public function delete_by_uid($uids) {
if(!$uids){
return null;
}
DB::delete($this->_table, DB::field('uid', $uids));
}
}
?>

View File

@@ -0,0 +1,27 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_member_field_forum.php 28405 2012-02-29 03:47:50Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member_field_forum extends discuz_table_archive
{
public function __construct() {
$this->_table = 'common_member_field_forum';
$this->_pk = 'uid';
$this->_pre_cache_key = 'common_member_field_forum_';
parent::__construct();
}
}
?>

View File

@@ -0,0 +1,43 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_member_field_forum_archive.php 28589 2012-03-05 09:54:11Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member_field_forum_archive extends table_common_member_field_forum
{
public function __construct() {
parent::__construct();
$this->_table = 'common_member_field_forum_archive';
$this->_pk = 'uid';
}
public function fetch($id, $force_from_db = true, $fetch_archive = 1){
return ($id = dintval($id)) ? DB::fetch_first('SELECT * FROM '.DB::table($this->_table).' WHERE '.DB::field($this->_pk, $id)) : array();
}
public function fetch_all($ids, $force_from_db = true, $fetch_archive = 1) {
$data = array();
if(($ids = dintval($ids, true))) {
$query = DB::query('SELECT * FROM '.DB::table($this->_table).' WHERE '.DB::field($this->_pk, $ids));
while($value = DB::fetch($query)) {
$data[$value[$this->_pk]] = $value;
}
}
return $data;
}
public function delete($val, $unbuffered = false, $fetch_archive = 1) {
return ($val = dintval($val, true)) && DB::delete($this->_table, DB::field($this->_pk, $val), null, $unbuffered);
}
}
?>

View File

@@ -0,0 +1,41 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_member_field_home.php 28405 2012-02-29 03:47:50Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member_field_home extends discuz_table_archive
{
public function __construct() {
$this->_table = 'common_member_field_home';
$this->_pk = 'uid';
$this->_pre_cache_key = 'common_member_field_home_';
parent::__construct();
}
public function increase($uids, $creditarr) {
$uids = array_map('intval', (array)$uids);
$sql = array();
$allowkey = array('addsize', 'addfriend');
foreach($creditarr as $key => $value) {
if(($value = intval($value)) && in_array($key, $allowkey)) {
$sql[] = "`$key`=`$key`+'$value'";
}
}
if(!empty($sql)){
DB::query("UPDATE ".DB::table($this->_table)." SET ".implode(',', $sql)." WHERE uid IN (".dimplode($uids).")", 'UNBUFFERED');
$this->increase_cache($uids, $creditarr);
}
}
}
?>

View File

@@ -0,0 +1,43 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_member_field_home_archive.php 28589 2012-03-05 09:54:11Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member_field_home_archive extends table_common_member_field_home
{
public function __construct() {
parent::__construct();
$this->_table = 'common_member_field_home_archive';
$this->_pk = 'uid';
}
public function fetch($id, $force_from_db = true, $fetch_archive = 1){
return ($id = dintval($id)) ? DB::fetch_first('SELECT * FROM '.DB::table($this->_table).' WHERE '.DB::field($this->_pk, $id)) : array();
}
public function fetch_all($ids, $force_from_db = true, $fetch_archive = 1) {
$data = array();
if(($ids = dintval($ids, true))) {
$query = DB::query('SELECT * FROM '.DB::table($this->_table).' WHERE '.DB::field($this->_pk, $ids));
while($value = DB::fetch($query)) {
$data[$value[$this->_pk]] = $value;
}
}
return $data;
}
public function delete($val, $unbuffered = false, $fetch_archive = 1) {
return ($val = dintval($val, true)) && DB::delete($this->_table, DB::field($this->_pk, $val), null, $unbuffered);
}
}
?>

View File

@@ -0,0 +1,52 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_member_security.php 27449 2012-02-01 05:32:35Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member_forum_buylog extends discuz_table
{
public function __construct() {
$this->_table = 'common_member_forum_buylog';
$this->_pk = 'uid';
$this->_pre_cache_key = 'common_member';
$this->_allowmem = memory('check');
$this->_cache_ttl = 86400;
parent::__construct();
}
public function get_credits($uid, $fid) {
$credits = $this->fetch_cache($uid.'_'.$fid, 'common_member_forum_buylog_');
if(!$credits) {
$credits = DB::result_first('SELECT credits FROM %t WHERE uid=%d AND fid=%d', array($this->_table, $uid, $fid));
$this->store_cache($uid.'_'.$fid, $credits, $this->_cache_ttl, 'common_member_forum_buylog_');
return $credits;
} else {
return $credits;
}
}
public function update_credits($uid, $fid, $credits) {
C::t('common_member_forum_buylog')->insert(array('uid' => $uid, 'fid' => $fid, 'credits' => $credits), false, true);
$this->store_cache($uid.'_'.$fid, $credits, $this->_cache_ttl, 'common_member_forum_buylog_');
}
public function delete_by_uid($uids) {
DB::delete($this->_table, DB::field('uid', $uids));
}
public function delete_by_fid($fids) {
DB::delete($this->_table, DB::field('fid', $fids));
}
}
?>

View File

@@ -0,0 +1,71 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_member_grouppm.php 31733 2012-09-26 02:07:47Z zhangjie $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member_grouppm extends discuz_table
{
public function __construct() {
$this->_table = 'common_member_grouppm';
$this->_pk = '';
parent::__construct();
}
public function delete_by_gpmid($gpmid) {
return ($gpmid = dintval($gpmid))? DB::delete('common_member_grouppm', 'gpmid='.$gpmid) : false;
}
public function count_by_gpmid($gpmid, $type) {
return $gpmid ? DB::result_first('SELECT COUNT(*) FROM %t WHERE gpmid=%d AND dateline'.($type ? '>' : '=').'0', array($this->_table, $gpmid)) : 0;
}
public function fetch($id, $force_from_db = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::fetch($id, $force_from_db);
} else {
return $this->fetch_gpm($id, $force_from_db);
}
}
public function fetch_gpm($uid, $gpmid) {
return $uid && $gpmid ? DB::fetch_first('SELECT * FROM %t WHERE uid=%d AND gpmid=%d', array($this->_table, $uid, $gpmid)) : '';
}
public function fetch_all_by_gpmid($gpmid, $type, $start = 0, $limit = 0) {
return $gpmid ? DB::fetch_all('SELECT * FROM %t WHERE gpmid=%d AND dateline'.($type ? '>' : '=').'0'.DB::limit($start, $limit), array($this->_table, $gpmid), 'uid') : array();
}
public function fetch_all_by_uid($uid, $type) {
return $uid ? DB::fetch_all('SELECT * FROM %t WHERE uid=%d AND `status`'.($type ? '>=' : '=').'0', array($this->_table, $uid), 'gpmid') : array();
}
public function update($val, $data, $unbuffered = false, $low_priority = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::update($val, $data, $unbuffered, $low_priority);
} else {
return $this->update_gpm($val, $data, $unbuffered);
}
}
public function update_gpm($uid, $gpmid, $data) {
return ($uid = dintval($uid)) && ($gpmid = dintval($gpmid, true)) && $data && is_array($data) ? DB::update($this->_table, $data, DB::field('gpmid', $gpmid).' AND '.DB::field('uid', $uid)) : false;
}
public function update_to_read_by_unread($uid, $gpmid) {
return ($uid = dintval($uid)) && ($gpmid = dintval($gpmid, true)) ? DB::update($this->_table, array('status' => 1), DB::field('gpmid', $gpmid).' AND '.DB::field('uid', $uid).' AND status=0') : false;
}
}
?>

View File

@@ -0,0 +1,159 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_member_magic.php 27757 2012-02-14 03:08:15Z chenmengshu $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member_magic extends discuz_table
{
public function __construct() {
$this->_table = 'common_member_magic';
$this->_pk = '';
parent::__construct();
}
public function delete($val = null, $unbuffered = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::delete($val, $unbuffered);
} else {
$unbuffered = $unbuffered === false ? null : $unbuffered;
return $this->delete_magic($val, $unbuffered);
}
}
public function delete_magic($uid = null, $magicid = null) {
$para = array();
if($uid) {
$para[] = DB::field('uid', $uid);
}
if($magicid) {
$para[] = DB::field('magicid', $magicid);
}
if(!($where = $para ? implode(' AND ', $para) : '')) {
return null;
}
return DB::delete($this->_table, $where);
}
public function fetch_all($ids, $force_from_db = false, $null1 = 0, $null2 = 0) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::fetch_all($ids, $force_from_db);
} else {
$force_from_db = $force_from_db === false ? '' : $force_from_db;
return $this->fetch_all_magic($ids, $force_from_db, $null1, $null2);
}
}
public function fetch($id, $force_from_db = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::fetch($id, $force_from_db);
} else {
return $this->fetch_magic($id, $force_from_db);
}
}
public function count($null1 = null, $null2 = null) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::count();
} else {
if ($null1 === null || $null2 === null) {
throw new Exception("Invalid Use C:t('common_member_magic')->count Function.");
}
return $this->count_magic($null1, $null2);
}
}
public function fetch_all_magic($uid, $magicid = '', $start = 0, $limit = 0) {
$para = array();
if($uid) {
$para[] = DB::field('uid', $uid);
}
if($magicid) {
$para[] = DB::field('magicid', $magicid);
}
if($limit) {
$sql = DB::limit($start, $limit);
}
if(!count($para)) {
return null;
}
$para = implode(' AND ', $para);
return DB::fetch_all('SELECT * FROM %t WHERE %i', array($this->_table, $para.$sql));
}
public function fetch_magic($uid, $magicid) {
$para = array();
if($uid) {
$para[] = DB::field('uid', $uid);
}
if($magicid) {
$para[] = DB::field('magicid', $magicid);
}
if(!count($para)) {
return null;
}
$sql = implode(' AND ', $para);
return DB::fetch_first('SELECT * FROM %t WHERE %i', array($this->_table, $sql));
}
public function count_magic($uid, $magicid) {
$para = array();
if($uid) {
$para[] = DB::field('uid', $uid);
}
if($magicid) {
$para[] = DB::field('magicid', $magicid);
}
if(!count($para)) {
return null;
}
$sql = implode(' AND ', $para);
return (int) DB::result_first('SELECT count(*) FROM %t WHERE %i', array($this->_table, $sql));
}
public function increase($uid, $magicid, $setarr, $slient = false, $unbuffered = false) {
$para = array();
$setsql = array();
$allowkey = array('num');
foreach($setarr as $key => $value) {
if(($value = intval($value)) && in_array($key, $allowkey)) {
$setsql[] = "`$key`=`$key`+'$value'";
}
}
if($uid) {
$para[] = DB::field('uid', $uid);
}
if($magicid) {
$para[] = DB::field('magicid', $magicid);
}
if(!count($para) || !count($setsql)) {
return null;
}
$sql = implode(' AND ', $para);
return DB::query('UPDATE %t SET %i WHERE %i', array($this->_table, implode(',', $setsql), $sql), $slient, $unbuffered);
}
public function count_by_uid($uid) {
return DB::result_first('SELECT COUNT(*) FROM %t mm, %t m WHERE mm.uid=%d AND mm.magicid=m.magicid', array($this->_table, 'common_magic', $uid));
}
public function fetch_magicid_by_identifier($uid, $identifier) {
return DB::result_first('SELECT m.magicid FROM %t mm,%t m WHERE mm.uid=%d AND m.identifier=%s AND mm.magicid=m.magicid', array($this->_table, 'common_magic', $uid, $identifier));
}
}
?>

View File

@@ -0,0 +1,37 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_member_medal.php 27772 2012-02-14 06:48:34Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member_medal extends discuz_table
{
public function __construct() {
$this->_table = 'common_member_medal';
$this->_pk = '';
parent::__construct();
}
public function fetch_all_by_uid($uid) {
return !empty($uid) ? DB::fetch_all('SELECT * FROM '.DB::table($this->_table).' WHERE '.DB::field('uid', $uid), '', 'medalid') : array();
}
public function delete_by_uid_medalid($uid, $medalid) {
return !empty($uid) && !empty($medalid) ? DB::delete($this->_table, DB::field('uid', $uid).' AND '.DB::field('medalid', $medalid)) : false;
}
public function count_by_uid_medalid($uid, $medalid) {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE uid=%d AND medalid=%d', array($this->_table, $uid, $medalid));
}
}
?>

View File

@@ -0,0 +1,43 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_member_newprompt.php 27449 2012-06-28 05:32:35Z liulanbo $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member_newprompt extends discuz_table
{
public function __construct() {
$this->_table = 'common_member_newprompt';
$this->_pk = 'uid';
$this->_pre_cache_key = 'common_member_newprompt_';
$this->_cache_ttl = 60;
parent::__construct();
}
public function insert($data, $return_insert_id = false, $replace = false, $silent = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::insert($data, $return_insert_id, $replace, $silent);
} else {
return $this->insert_newprompt($data, $return_insert_id);
}
}
public function insert_newprompt($uid, $data) {
if(empty($uid) || empty($data)) {
return false;
}
DB::insert($this->_table, array('uid' => intval($uid), 'data' => serialize($data)));
}
}
?>

View File

@@ -0,0 +1,100 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_member_profile.php 31536 2012-09-06 06:32:03Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member_profile extends discuz_table_archive
{
private $_fields;
public function __construct() {
$this->_table = 'common_member_profile';
$this->_pk = 'uid';
$this->_pre_cache_key = 'common_member_profile_';
$this->_fields = array('uid', 'realname', 'gender', 'birthyear', 'birthmonth', 'birthday', 'constellation',
'zodiac', 'telephone', 'mobile', 'idcardtype', 'idcard', 'address', 'zipcode', 'nationality', 'birthcountry', 'birthprovince', 'birthcity', 'birthdist',
'birthcommunity', 'residecountry', 'resideprovince', 'residecity', 'residedist', 'residecommunity', 'residesuite', 'graduateschool', 'education', 'company',
'occupation', 'position', 'revenue', 'affectivestatus', 'lookingfor', 'bloodtype', 'height', 'weight', 'alipay', 'icq', 'qq',
'yahoo', 'msn', 'taobao', 'site', 'bio', 'interest', 'field1', 'field2', 'field3', 'field4', 'field5', 'field6', 'field7', 'field8');
parent::__construct();
}
public function fetch_all($uids, $force_from_db = false, $fetch_archive = 1) {
$data = array();
if(!empty($uids)) {
if($force_from_db || ($data = $this->fetch_cache($uids)) === false || count($uids) != count($data)) {
if(is_array($data) && !empty($data)) {
$uids = array_diff($uids, array_keys($data));
}
if($data === false) $data =array();
if(!empty($uids)) {
$query = DB::query('SELECT '.implode(',', $this->_fields).' FROM '.DB::table($this->_table).' WHERE '.DB::field($this->_pk, $uids));
while($value = DB::fetch($query)) {
$data[$value[$this->_pk]] = $value;
$this->store_cache($value[$this->_pk], $value);
}
}
}
if(isset($this->membersplit) && $fetch_archive && count($data) != count($uids)) {
$data = $data + C::t($this->_table.'_archive')->fetch_all(array_diff($uids, array_keys($data)), null, 0);
}
}
return $data;
}
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 fetch_all_field_value($field) {
return in_array($field, $this->_fields, true) ? DB::fetch_all('SELECT DISTINCT(`'.$field.'`) FROM '.DB::table($this->_table), null, $field) : array();
}
public function fetch_all_will_birthday_by_uid($uids) {
$birthlist = array();
if(!empty($uids)) {
$uids = explode(',', (string)$uids);
$uids = dimplode(dintval($uids, true));
list($s_month, $s_day) = explode('-', dgmdate(TIMESTAMP-3600*24*3, 'n-j'));
list($n_month, $n_day) = explode('-', dgmdate(TIMESTAMP, 'n-j'));
list($e_month, $e_day) = explode('-', dgmdate(TIMESTAMP+3600*24*7, 'n-j'));
if($e_month == $s_month) {
$wheresql = "sf.birthmonth='$s_month' AND sf.birthday>='$s_day' AND sf.birthday<='$e_day'";
} else {
$wheresql = "(sf.birthmonth='$s_month' AND sf.birthday>='$s_day') OR (sf.birthmonth='$e_month' AND sf.birthday<='$e_day' AND sf.birthday>'0')";
}
$query = DB::query("SELECT sf.uid,sf.birthyear,sf.birthmonth,sf.birthday,s.username
FROM ".DB::table('common_member_profile')." sf
LEFT JOIN ".DB::table('common_member')." s USING(uid)
WHERE (sf.uid IN ($uids)) AND ($wheresql)");
while ($value = DB::fetch($query)) {
$value['istoday'] = 0;
if($value['birthmonth'] == $n_month && $value['birthday'] == $n_day) {
$value['istoday'] = 1;
}
$key = sprintf("%02d", $value['birthmonth']).sprintf("%02d", $value['birthday']);
$birthlist[$key][] = $value;
ksort($birthlist);
}
}
return $birthlist;
}
}
?>

View File

@@ -0,0 +1,72 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_member_profile_archive.php 28589 2012-03-05 09:54:11Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member_profile_archive extends table_common_member_profile
{
protected $_fields;
public function __construct() {
parent::__construct();
$this->_table = 'common_member_profile_archive';
$this->_pk = 'uid';
}
public function fetch($id, $force_from_db = false, $fetch_archive = 0) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::fetch($id, $force_from_db, $fetch_archive);
} else {
return $this->fetch_profile($id);
}
}
public function fetch_all($ids, $force_from_db = false, $fetch_archive = 1) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::fetch_all($ids, $force_from_db, $fetch_archive);
} else {
return $this->fetch_all_profile($ids);
}
}
public function delete($val, $unbuffered = false, $fetch_archive = 0) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::delete($val, $unbuffered, $fetch_archive);
} else {
return $this->delete_profile($val, $unbuffered);
}
}
public function fetch_profile($id) {
return ($id = dintval($id)) ? DB::fetch_first('SELECT * FROM '.DB::table($this->_table).' WHERE '.DB::field($this->_pk, $id)) : array();
}
public function fetch_all_profile($ids) {
$data = array();
if(($ids = dintval($ids, true))) {
$query = DB::query('SELECT * FROM '.DB::table($this->_table).' WHERE '.DB::field($this->_pk, $ids));
while($value = DB::fetch($query)) {
$data[$value[$this->_pk]] = $value;
}
}
return $data;
}
public function delete_profile($val, $unbuffered = false) {
return ($val = dintval($val, true)) && DB::delete($this->_table, DB::field($this->_pk, $val), null, $unbuffered);
}
}
?>

View File

@@ -0,0 +1,27 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id$
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member_profile_history extends discuz_table
{
public function __construct() {
$this->_table = 'common_member_profile_history';
$this->_pk = 'hid';
parent::__construct();
}
public function fetch_all_by_uid($uid) {
return DB::fetch_all('SELECT * FROM %t WHERE uid=%d ORDER BY dateline', array($this->_table, $uid), $this->_pk);
}
}

View File

@@ -0,0 +1,64 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_member_profile_setting.php 27449 2012-02-01 05:32:35Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member_profile_setting extends discuz_table
{
public function __construct() {
$this->_table = 'common_member_profile_setting';
$this->_pk = 'fieldid';
parent::__construct();
}
public function range($start = 0, $limit = 0, $sort = '') {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::range($start, $limit, $sort);
} else {
return $this->range_setting($start, $limit);
}
}
public function range_setting($start = 0, $limit = 0) {
return DB::fetch_all('SELECT * FROM '.DB::table($this->_table).' ORDER BY available DESC, displayorder'.DB::limit($start, $limit), null, $this->_pk);
}
public function fetch_all_by_available_unchangeable($available, $unchangeable) {
return DB::fetch_all('SELECT * FROM %t WHERE available=%d AND unchangeable=%d ORDER BY displayorder', array($this->_table, $available, $unchangeable), $this->_pk);
}
public function fetch_all_by_available($available) {
return DB::fetch_all('SELECT * FROM %t WHERE available=%d ORDER BY displayorder', array($this->_table, $available), $this->_pk);
}
public function fetch_all_by_available_formtype($available, $formtype) {
return DB::fetch_all('SELECT * FROM %t WHERE available=%d AND formtype=%s', array($this->_table, $available, $formtype), $this->_pk);
}
public function fetch_all_by_available_required($available, $required) {
return DB::fetch_all('SELECT * FROM %t WHERE available=%d AND required=%d', array($this->_table, $available, $required), $this->_pk);
}
public function fetch_all_by_available_showinregister($available, $showinregister) {
return DB::fetch_all('SELECT * FROM %t WHERE available=%d AND showinregister=%d', array($this->_table, $available, $showinregister), $this->_pk);
}
public function fetch_all_by_available_showinthread($available, $showinthread) {
return DB::fetch_all('SELECT * FROM %t WHERE available=%d AND showinthread=%d', array($this->_table, $available, $showinthread), $this->_pk);
}
public function clear_showinthread() {
DB::update($this->_table, array('showinthread' => 0));
}
}
?>

View File

@@ -0,0 +1,26 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_member_security.php 27449 2012-02-01 05:32:35Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member_security extends discuz_table
{
public function __construct() {
$this->_table = 'common_member_security';
$this->_pk = 'securityid';
parent::__construct();
}
}
?>

View File

@@ -0,0 +1,46 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_seccheck.php 33625 2013-07-19 06:03:49Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member_secwhite extends discuz_table
{
public function __construct() {
$this->_table = 'common_member_secwhite';
$this->_pk = 'uid';
$this->_pre_cache_key = 'common_member_secwhite_';
$this->_cache_ttl = 86400;
parent::__construct();
}
public function check($uid) {
if ($this->_allowmem) {
return $this->fetch_cache($uid);
} else {
DB::delete($this->_table, "dateline<".(TIMESTAMP-86400));
return DB::result_first("SELECT COUNT(*) FROM %t WHERE uid=%d", array($this->_table, $uid));
}
}
public function add($uid) {
if ($this->_allowmem) {
$this->store_cache($uid, 1);
} else {
DB::insert($this->_table, array('uid' => $uid, 'dateline' => TIMESTAMP), false, true);
}
}
}
?>

View File

@@ -0,0 +1,45 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_member_stat_field.php 27774 2012-02-14 06:55:13Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member_stat_field extends discuz_table
{
public function __construct() {
$this->_table = 'common_member_stat_field';
$this->_pk = 'optionid';
parent::__construct();
}
public function count_by_fieldid($fieldid) {
return $fieldid ? DB::result_first('SELECT COUNT(*) FROM %t WHERE fieldid=%s', array($this->_table, $fieldid)) : 0;
}
public function fetch_all_by_fieldid($fieldid, $start = 0, $limit = 0) {
return DB::fetch_all('SELECT * FROM %t WHERE fieldid=%s'.DB::limit($start, $limit), array($this->_table, $fieldid));
}
public function insert_batch($inserts) {
$sql = array();
foreach($inserts as $value) {
if($value['fieldid']) {
$sql[] = "('{$value['fieldid']}', '".addslashes($value['fieldvalue'])."')";
}
}
if($sql) {
DB::query('INSERT INTO '.DB::table($this->_table)."(fieldid, fieldvalue) VALUES ".implode(', ', $sql));
}
}
}
?>

View File

@@ -0,0 +1,109 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_member_status.php 28405 2012-02-29 03:47:50Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member_status extends discuz_table_archive
{
public function __construct() {
$this->_table = 'common_member_status';
$this->_pk = 'uid';
$this->_pre_cache_key = 'common_member_status_';
parent::__construct();
}
public function increase($uids, $setarr) {
$uids = array_map('intval', (array)$uids);
$sql = array();
$allowkey = array('buyercredit', 'sellercredit', 'favtimes', 'sharetimes');
foreach($setarr as $key => $value) {
if(($value = intval($value)) && in_array($key, $allowkey)) {
$sql[] = "`$key`=`$key`+'$value'";
}
}
if(!empty($sql)){
DB::query("UPDATE ".DB::table($this->_table)." SET ".implode(',', $sql)." WHERE uid IN (".dimplode($uids).")", 'UNBUFFERED');
$this->increase_cache($uids, $setarr);
}
}
public function count_by_ip($ips) {
return !empty($ips) ? DB::result_first('SELECT COUNT(*) FROM %t WHERE regip IN(%n) OR lastip IN (%n)', array($this->_table, $ips, $ips)) : 0;
}
public function fetch_all_by_ip($ips, $start, $limit) {
$data = array();
if(!empty($ips) && $limit) {
$data = DB::fetch_all('SELECT * FROM %t WHERE regip IN(%n) OR lastip IN (%n) LIMIT %d, %d', array($this->_table, $ips, $ips, $start, $limit), 'uid');
}
return $data;
}
public function fetch_all_orderby_lastpost($uids, $start, $limit) {
$uids = dintval($uids, true);
if($uids) {
return DB::fetch_all('SELECT * FROM %t WHERE uid IN(%n) ORDER BY lastpost DESC '.DB::limit($start, $limit), array($this->_table, $uids), $this->_pk);
}
return array();
}
public function count_by_lastactivity_invisible($timestamp, $invisible = 0) {
$addsql = '';
if($invisible === 1) {
$addsql = ' AND invisible = 1';
} elseif($invisible === 2) {
$addsql = ' AND invisible = 0';
}
return $timestamp ? DB::result_first('SELECT COUNT(*) FROM %t WHERE lastactivity >= %d'.$addsql, array($this->_table, $timestamp)) : 0;
}
public function fetch_all_by_lastactivity_invisible($timestamp, $invisible = 0, $start = 0, $limit = 0) {
$data = array();
if($timestamp) {
$addsql = '';
if($invisible === 1) {
$addsql = ' AND invisible = 1';
} elseif($invisible === 2) {
$addsql = ' AND invisible = 0';
}
$data = DB::fetch_all('SELECT * FROM %t WHERE lastactivity >= %d'.$addsql.' ORDER BY lastactivity DESC'.DB::limit($start, $limit), array($this->_table, $timestamp), $this->_pk);
}
return $data;
}
public function fetch_all_onlines($uids, $lastactivity, $start = 0, $limit = 0) {
$data = array();
$uids = dintval($uids, true);
if(!empty($uids)) {
$ppp = ($ppp = getglobal('ppp')) ? $ppp + 30 : 100;
if(count($uids) > $ppp) {
$uids = array_slice($uids, 0, $ppp);
}
$length = $limit ? $limit : $start;
$i = 0;
foreach($this->fetch_all($uids) as $uid => $member) {
if($member['lastactivity'] >= $lastactivity) {
$data[$uid] = $member;
if($length && $i >= $length) {
break;
}
$i++;
}
}
}
return $data;
}
}
?>

View File

@@ -0,0 +1,71 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_member_status_archive.php 28589 2012-03-05 09:54:11Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member_status_archive extends table_common_member_status
{
public function __construct() {
parent::__construct();
$this->_table = 'common_member_status_archive';
$this->_pk = 'uid';
}
public function fetch($id, $force_from_db = false, $fetch_archive = 0) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::fetch($id, $force_from_db, $fetch_archive);
} else {
return $this->fetch_status($id);
}
}
public function fetch_all($ids, $force_from_db = false, $fetch_archive = 1) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::fetch_all($ids, $force_from_db, $fetch_archive);
} else {
return $this->fetch_all_status($ids);
}
}
public function delete($val, $unbuffered = false, $fetch_archive = 0) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::delete($val, $unbuffered, $fetch_archive);
} else {
return $this->delete_status($val, $unbuffered);
}
}
public function fetch_status($id){
return ($id = dintval($id)) ? DB::fetch_first('SELECT * FROM '.DB::table($this->_table).' WHERE '.DB::field($this->_pk, $id)) : array();
}
public function fetch_all_status($ids) {
$data = array();
if(($ids = dintval($ids, true))) {
$query = DB::query('SELECT * FROM '.DB::table($this->_table).' WHERE '.DB::field($this->_pk, $ids));
while($value = DB::fetch($query)) {
$data[$value[$this->_pk]] = $value;
}
}
return $data;
}
public function delete_status($val, $unbuffered = false) {
return ($val = dintval($val, true)) && DB::delete($this->_table, DB::field($this->_pk, $val), null, $unbuffered);
}
}
?>

View File

@@ -0,0 +1,59 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_member_validate.php 27848 2012-02-15 09:07:27Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member_validate extends discuz_table
{
public function __construct() {
$this->_table = 'common_member_validate';
$this->_pk = 'uid';
parent::__construct();
}
public function fetch_all_validate_uid($submittimes = '', $regdate = '', $moddate = '', $regip = '') {
$sql = 'm.groupid=8';
$sql .= $submittimes ? ' AND v.submittimes>'.intval($submittimes) : '';
$sql .= $regdate ? ' AND m.regdate<'.(TIMESTAMP - intval($regdate) * 86400) : '';
$sql .= $moddate ? ' AND v.moddate<'.(TIMESTAMP - intval($moddate) * 86400) : '';
$sql .= ($regip = stripsearchkey(addslashes((string)$regip))) ? " AND m.regip LIKE '".$regip."%'" : '';
return DB::fetch_all("SELECT v.uid FROM ".DB::table('common_member_validate')." v, ".DB::table('common_member')." m
WHERE $sql AND m.uid=v.uid", null, 'uid');
}
public function fetch_all_invalidate($start, $limit) {
return DB::fetch_all('SELECT mvi.field, v.message, v.submittimes, v.submitdate, v.moddate, v.admin, v.remark, v.uid as vuid
FROM '.DB::table('common_member_validate').' v
LEFT JOIN '.DB::table('common_member_verify_info').' mvi ON mvi.uid=v.uid AND mvi.verifytype=0
WHERE v.status=0 ORDER BY v.submitdate DESC '.DB::limit($start, $limit), '', 'vuid');
}
public function count_by_status($status) {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE status=%d', array($this->_table, $status));
}
public function fetch_all_status_by_count() {
$count = array();
$query = DB::query("SELECT status, COUNT(*) AS count FROM ".DB::table('common_member_validate')." GROUP BY status");
while($num = DB::fetch($query)) {
$count[$num['status']] = $num['count'];
}
return $count;
}
public function fetch_all_by_status($status, $start = 0, $limit = 0) {
return DB::fetch_all('SELECT * FROM %t WHERE status=%d ORDER BY submitdate DESC'.DB::limit($start, $limit), array($this->_table, $status), $this->_pk);
}
}
?>

View File

@@ -0,0 +1,79 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_member_verify.php 28405 2012-02-29 03:47:50Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member_verify extends discuz_table
{
public function __construct() {
$this->_table = 'common_member_verify';
$this->_pk = 'uid';
$this->_pre_cache_key = 'common_member_verify_';
parent::__construct();
}
public function fetch_all_by_vid($vid, $flag, $uids = array()) {
$parameter = array($this->_table);
if($vid > 0 && $vid < 8) {
$wherearr = array();
if($uids) {
$wherearr[] = is_array($uids) ? 'uid IN(%n)' : 'uid=%d';
$parameter[] = $uids;
}
$parameter[] = $flag;
$wherearr[] = "verify{$vid}=%d";
return DB::fetch_all("SELECT * FROM %t WHERE ".implode(' AND ', $wherearr), $parameter, $this->_pk);
} else {
return array();
}
}
public function fetch_all_search($uid, $vid, $username = '', $order = 'dateline', $start = 0, $limit = 0, $sort = 'DESC') {
$condition = $this->search_condition($uid, $vid, $username);
$ordersql = !empty($order) ? ' ORDER BY '.$order.' '.$sort : '';
return DB::fetch_all("SELECT * FROM %t v, %t m $condition[0] $ordersql ".DB::limit($start, $limit), $condition[1], $this->_pk);
}
public function count_by_uid($uid) {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE uid=%d', array($this->_table, $uid));
}
public function count_by_search($uid, $vid, $username = '') {
$condition = $this->search_condition($uid, $vid, $username);
return DB::result_first('SELECT COUNT(*) FROM %t v, %t m '.$condition[0], $condition[1]);
}
public function search_condition($uid, $vid, $username) {
$parameter = array($this->_table, 'common_member');
$wherearr = array();
if($uid) {
$parameter[] = $uid;
$wherearr[] = 'v.uid=%d';
}
if($vid > 0 && $vid < 8) {
$parameter[] = $vid;
$wherearr[] = 'v.verify%d=1';
}
if(!empty($username)) {
$parameter[] = '%'.$username.'%';
$wherearr[] = "m.username LIKE %s";
}
$wherearr[] = "v.uid=m.uid";
$wheresql = !empty($wherearr) && is_array($wherearr) ? ' WHERE '.implode(' AND ', $wherearr) : '';
return array($wheresql, $parameter);
}
}
?>

View File

@@ -0,0 +1,87 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_member_verify_info.php 31799 2012-10-11 02:36:34Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_member_verify_info extends discuz_table
{
public function __construct() {
$this->_table = 'common_member_verify_info';
$this->_pk = 'vid';
parent::__construct();
}
public function fetch_by_uid_verifytype($uid, $verifytype) {
return DB::fetch_first('SELECT * FROM %t WHERE uid=%d AND verifytype=%d', array($this->_table, $uid, $verifytype));
}
public function fetch_all_search($uid, $vid, $flag = null, $username = '', $starttime = 0, $endtime = 0, $order = 'dateline', $start = 0, $limit = 0, $sort = 'DESC') {
$condition = $this->search_condition($uid, $vid, $flag, $username, $starttime, $endtime);
$ordersql = !empty($order) ? ' ORDER BY '.DB::order($order, $sort) : '';
return DB::fetch_all("SELECT * FROM %t $condition[0] $ordersql ".DB::limit($start, $limit), $condition[1], $this->_pk);
}
public function group_by_verifytype_count() {
return DB::fetch_all('SELECT verifytype, COUNT(*) AS num FROM %t WHERE flag=0 GROUP BY verifytype', array($this->_table));
}
public function delete_by_uid($uid, $verifytype = null) {
if($uid) {
$addsql = '';
if($verifytype !== null) {
$verifytype = dintval($verifytype, is_array($verifytype) ? true : false);
$addsql = ' AND '.DB::field('verifytype', $verifytype);
}
return DB::query('DELETE FROM %t WHERE '.(is_array($uid) ? 'uid IN(%n)' : 'uid=%d').$addsql, array($this->_table, $uid));
}
return false;
}
public function count_by_search($uid, $vid, $flag = null, $username = '', $starttime = 0, $endtime = 0) {
$condition = $this->search_condition($uid, $vid, $flag, $username, $starttime, $endtime);
return DB::result_first('SELECT COUNT(*) FROM %t '.$condition[0], $condition[1]);
}
public function search_condition($uid, $vid, $flag, $username, $starttime, $endtime) {
$parameter = array($this->_table);
$wherearr = array();
if($uid) {
$parameter[] = $uid;
$wherearr[] = 'uid=%d';
}
if($vid >= 0 && $vid < 8) {
$parameter[] = $vid;
$wherearr[] = 'verifytype=%d';
}
if($flag !== null) {
$parameter[] = $flag;
$wherearr[] = 'flag=%d';
}
if($starttime){
$parameter[] = $starttime;
$wherearr[] = 'dateline>=%d';
}
if($endtime){
$parameter[] = $endtime;
$wherearr[] = 'dateline<=%d';
}
if(!empty($username)) {
$parameter[] = '%'.$username.'%';
$wherearr[] = "username LIKE %s";
}
$wheresql = !empty($wherearr) && is_array($wherearr) ? ' WHERE '.implode(' AND ', $wherearr) : '';
return array($wheresql, $parameter);
}
}
?>

View File

@@ -0,0 +1,541 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_moderate.php 31513 2012-09-04 08:47:57Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_moderate extends discuz_table
{
var $_tables = array();
public function __construct() {
$this->_table = '';
$this->_pk = '';
$this->_tables = array(
'tid' => 'forum_thread_moderate',
'pid' => 'forum_post_moderate',
'blogid' => 'home_blog_moderate',
'picid' => 'home_pic_moderate',
'doid' => 'home_doing_moderate',
'sid' => 'home_share_moderate',
'aid' => 'portal_article_moderate',
'aid_cid' => 'portal_comment_moderate',
'topicid_cid' => 'portal_comment_moderate',
'uid_cid' => 'home_comment_moderate',
'blogid_cid' => 'home_comment_moderate',
'sid_cid' => 'home_comment_moderate',
'picid_cid' => 'home_comment_moderate',
);
parent::__construct();
}
private function _get_table($idtype) {
return $this->_tables[$idtype];
}
private function _is_comment_table($idtype) {
return in_array($this->_get_table($idtype), array('portal_comment_moderate', 'home_comment_moderate'));
}
public function count_by_idtype($idtype, $status = 0, $dateline = 0) {
return $this->query_data(1, $idtype, $status, $dateline);
}
public function fetch_all_by_idtype($idtype, $status = 0, $dateline = 0) {
return $this->query_data(0, $idtype, $status, $dateline);
}
private function query_data($type, $idtype, $status = 0, $dateline = 0) {
if(!isset($this->_tables[$idtype])) {
return $type ? 0 : array();
}
$parameter = array($this->_get_table($idtype), $this->_is_comment_table($idtype) ? "idtype='$idtype' AND" : '', $status);
$othersql = '';
if($dateline) {
$othersql = " AND dateline>=%d";
$parameter[] = $dateline;
}
if($type) {
return DB::result_first("SELECT COUNT(*) FROM %t WHERE %i `status`=%d $othersql ORDER BY dateline DESC", $parameter);
} else {
return DB::fetch_all("SELECT * FROM %t WHERE %i `status`=%d $othersql ORDER BY dateline DESC", $parameter, 'id');
}
}
public function fetch_all_for_article($status, $catid = 0, $username = '', $dateline = 'all', $count = 0, $start = 0, $limit = 0) {
$sqlwhere = '';
$status = dintval($status);
if(($catid = dintval($catid))) {
$sqlwhere .= " AND a.catid='$catid'";
}
if(!empty($username)) {
$sqlwhere .= " AND a.username='".addslashes($username)."'";
}
if($dateline != 'all') {
$sqlwhere .= " AND a.dateline>'".(TIMESTAMP - dintval($dateline))."'";
}
if($count) {
return DB::result_first("SELECT COUNT(*)
FROM ".DB::table('portal_article_moderate')." m
LEFT JOIN ".DB::table('portal_article_title')." a ON a.aid=m.id
WHERE m.status='$status' $sqlwhere");
}
return DB::fetch_all("SELECT a.aid, a.catid, a.uid, a.username, a.title, a.summary, a.dateline, cat.catname
FROM ".DB::table('portal_article_moderate')." m
LEFT JOIN ".DB::table('portal_article_title')." a ON a.aid=m.id
LEFT JOIN ".DB::table('portal_category')." cat ON cat.catid=a.catid
WHERE m.status='$status' $sqlwhere
ORDER BY m.dateline DESC".DB::limit($start, $limit));
}
public function fetch_all_for_portalcomment($idtype, $tablename, $status, $catid = 0, $username = '', $dateline = 'all', $count = 0, $keyword = '', $start = 0, $limit = 0) {
if(!isset($this->_tables[$idtype.'_cid'])) {
return $count ? 0 : array();
}
if(!empty($catid)) {
$sqlwhere .= " AND a.catid='$catid'";
}
if(!empty($username)) {
$sqlwhere .= " AND a.username='$username'";
}
if($dateline != 'all') {
$sqlwhere .= " AND a.dateline>'".(TIMESTAMP - $dateline)."'";
}
if(!empty($keyword)) {
$sqlwhere .= " AND c.message LIKE '%$keyword%'";
}
$sqlwhere .= "AND c.idtype='$idtype'";
if($count) {
return DB::result_first("SELECT COUNT(*)
FROM ".DB::table($this->_get_table($idtype.'_cid'))." m
LEFT JOIN ".DB::table('portal_comment')." c ON c.cid=m.id
LEFT JOIN ".DB::table($tablename)." a ON a.$idtype=c.id
WHERE m.".DB::field('idtype', $idtype.'_cid')." AND m.status='$status' $sqlwhere");
}
return DB::fetch_all("SELECT c.cid, c.uid, c.username, c.id, c.postip, c.dateline, c.message, a.title
FROM ".DB::table($this->_get_table($idtype.'_cid'))." m
LEFT JOIN ".DB::table('portal_comment')." c ON c.cid=m.id
LEFT JOIN ".DB::table($tablename)." a ON a.$idtype=c.id
WHERE m.".DB::field('idtype', $idtype.'_cid')." AND m.status='$status' $sqlwhere
ORDER BY m.dateline DESC".DB::limit($start, $limit));
}
public function count_group_idtype_by_status($status) {
$return = array();
foreach($this->_tables as $idtype => $table) {
if($this->_is_comment_table($idtype)) {
$return[] = array('idtype' => $idtype, 'count' => DB::result_first('SELECT COUNT(*) FROM %t WHERE idtype=%s AND status=%d', array($table, $idtype, $status)));
} else {
$return[] = array('idtype' => $idtype, 'count' => DB::result_first('SELECT COUNT(*) FROM %t WHERE status=%d', array($table, $status)));
}
}
return $return;
}
public function delete($val, $unbuffered = false, $null = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::delete($val, $unbuffered);
} else {
return $this->delete_moderate($val, $unbuffered, $null);
}
}
public function insert($data, $return_insert_id = false, $replace = false, $silent = false, $null = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::insert($data, $return_insert_id, $replace, $silent);
} else {
return $this->insert_moderate($data, $return_insert_id, $replace, $silent, $null);
}
}
public function update($val, $data, $unbuffered = false, $low_priority = false, $null = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::update($val, $data, $unbuffered, $low_priority);
} else {
return $this->update_moderate($val, $data, $unbuffered, $low_priority, $null);
}
}
public function delete_moderate($id, $idtype, $unbuffered = false) {
if(!isset($this->_tables[$idtype])) {
return false;
}
$table = $this->_get_table($idtype);
$wheresql = array();
$id && $wheresql[] = DB::field('id', $id);
$this->_is_comment_table($idtype) && $wheresql[] = DB::field('idtype', $idtype);
return DB::delete($table, implode(' AND ', $wheresql), 0, $unbuffered);
}
public function insert_moderate($idtype, $data, $return_insert_id = false, $replace = false, $silent = false) {
if(!isset($this->_tables[$idtype]) || empty($data)) {
return false;
}
$table = $this->_get_table($idtype);
$this->_is_comment_table($idtype) && $data['idtype'] = $idtype;
return DB::insert($table, $data, $return_insert_id, $replace, $silent);
}
public function update_moderate($id, $idtype, $data, $unbuffered = false, $low_priority = false) {
if(!isset($this->_tables[$idtype]) || empty($data)) {
return false;
}
$table = $this->_get_table($idtype);
$wheresql = array();
$id && $wheresql[] = DB::field('id', $id);
$this->_is_comment_table($idtype) && $wheresql[] = DB::field('idtype', $idtype);
return DB::update($table, $data, implode(' AND ', $wheresql), $unbuffered, $low_priority);
}
public function count_by_idtype_status_fid($idtype, $status, $fids) {
if($idtype == 'tid') {
$innertable = 'forum_thread';
} elseif($idtype == 'pid') {
$innertable = 'forum_post';
} else {
return 0;
}
return DB::result_first('SELECT COUNT(*) FROM %t m INNER JOIN %t t ON m.id=t.%i AND t.'.DB::field('fid', $fids).' WHERE m.status=%d',
array($this->_get_table($idtype), $innertable, $idtype, $status));
}
public function count_by_search_for_post($posttable, $status = null, $first = null, $fids = null, $author = null, $dateline = null, $subject = null) {
$wheresql = array();
if($status !== null) {
$wheresql[] = 'm.'.DB::field('status', $status);
}
if($first !== null) {
$wheresql[] = 'p.'.DB::field('first', $first);
}
if($fids) {
$wheresql[] = 'p.'.DB::field('fid', $fids);
}
if($author) {
$wheresql[] = 'p.'.DB::field('author', $author);
}
if($dateline) {
$wheresql[] = 'p.'.DB::field('dateline', $dateline, '>');
}
if($subject) {
$wheresql[] = 'p.'.DB::field('message', '%'.$subject.'%', 'like');
}
return DB::result_first('SELECT COUNT(*) FROM %t m LEFT JOIN %t p ON p.pid=m.id WHERE %i',
array($this->_get_table('pid'), $posttable, implode(' AND ', $wheresql)));
}
public function fetch_all_by_search_for_post($posttable, $status = null, $first = null, $fids = null, $author = null, $dateline = null, $subject = null, $start = 0, $limit = 0) {
$wheresql = array();
if($status !== null) {
$wheresql[] = 'm.'.DB::field('status', $status);
}
if($first !== null) {
$wheresql[] = 'p.'.DB::field('first', $first);
}
if($fids) {
$wheresql[] = 'p.'.DB::field('fid', $fids);
}
if($author) {
$wheresql[] = 'p.'.DB::field('author', $author);
}
if($dateline) {
$wheresql[] = 'p.'.DB::field('dateline', $dateline, '>');
}
if($subject) {
$wheresql[] = 'p.'.DB::field('message', '%'.$subject.'%', 'like');
}
return DB::fetch_all('SELECT p.pid, p.fid, p.tid,
p.author, p.authorid, p.subject, p.dateline, p.message, p.useip, p.attachment, p.htmlon, p.smileyoff, p.bbcodeoff, p.status
FROM %t m
LEFT JOIN %t p on p.pid=m.id
WHERE %i
ORDER BY m.dateline DESC '.DB::limit($start, $limit),
array($this->_get_table('pid'), $posttable, implode(' AND ', $wheresql)));
}
public function count_by_seach_for_thread($status = null, $fids = null) {
$wheresql = array();
if($status !== null) {
$wheresql[] = 'm.'.DB::field('status', $status);
}
if($fids) {
$wheresql[] = 't.'.DB::field('fid', $fids);
}
return DB::result_first('SELECT COUNT(*) FROM %t m LEFT JOIN %t t ON t.tid=m.id WHERE %i',
array($this->_get_table('tid'), 'forum_thread', implode(' AND ', $wheresql)));
}
public function fetch_all_by_search_for_thread($status = null, $fids = null, $start = 0, $limit = 0) {
$wheresql = array();
if($status !== null) {
$wheresql[] = 'm.'.DB::field('status', $status);
}
if($fids) {
$wheresql[] = 't.'.DB::field('fid', $fids);
}
return DB::fetch_all('SELECT t.tid, t.fid, t.posttableid, t.author, t.sortid, t.authorid, t.subject as tsubject, t.dateline, t.attachment
FROM %t m
LEFT JOIN %t t ON t.tid=m.id
WHERE %i
ORDER BY m.dateline DESC '.DB::limit($start, $limit),
array($this->_get_table('tid'), 'forum_thread', implode(' AND ', $wheresql)));
}
public function count_by_search_for_blog($status = null, $username = null, $dateline = null, $subject = null) {
$wheresql = array();
if($status !== null && !(is_array($status) && empty($status))) {
$wheresql[] = 'm.'.DB::field('status', $status);
}
if($username) {
$wheresql[] = 'b.'.DB::field('username', $username);
}
if($dateline) {
$wheresql[] = 'b.'.DB::field('dateline', $dateline, '>');
}
if($subject) {
$wheresql[] = 'b.'.DB::field('subject', '%'.$subject.'%', 'like');
}
return DB::result_first('SELECT COUNT(*)
FROM %t m
LEFT JOIN %t b ON b.blogid=m.id
LEFT JOIN %t bf ON bf.blogid=b.blogid
LEFT JOIN %t c ON b.classid=c.classid
WHERE %i',
array($this->_get_table('blogid'), 'home_blog', 'home_blogfield', 'home_class', implode(' AND ', $wheresql)));
}
public function fetch_all_by_search_for_blog($status = null, $username = null, $dateline = null, $subject = null, $start = 0, $limit = 0) {
$wheresql = array();
if($status !== null && !(is_array($status) && empty($status))) {
$wheresql[] = 'm.'.DB::field('status', $status);
}
if($username) {
$wheresql[] = 'b.'.DB::field('username', $username);
}
if($dateline) {
$wheresql[] = 'b.'.DB::field('dateline', $dateline, '>');
}
if($subject) {
$wheresql[] = 'b.'.DB::field('subject', '%'.$subject.'%', 'like');
}
return DB::fetch_all('SELECT b.blogid, b.uid, b.username, b.classid, b.subject, b.dateline, bf.message, bf.postip, c.classname
FROM %t m
LEFT JOIN %t b ON b.blogid=m.id
LEFT JOIN %t bf ON bf.blogid=b.blogid
LEFT JOIN %t c ON b.classid=c.classid
WHERE %i
ORDER BY m.dateline DESC '.DB::limit($start, $limit),
array($this->_get_table('blogid'), 'home_blog', 'home_blogfield', 'home_class', implode(' AND ', $wheresql)));
}
public function count_by_search_for_commnet($idtype = null, $status = null, $author = null, $dateline = null, $message = null) {
$wheresql = array();
if($idtype) {
$table = $this->_get_table($idtype.'_cid');
$wheresql[] = 'm.'.DB::field('idtype', $idtype.'_cid');
} else {
$table = 'home_comment_moderate';
}
if($status !== null && !(is_array($status) && empty($status))) {
$wheresql[] = 'm.'.DB::field('status', $status);
}
if($author) {
$wheresql[] = 'c.'.DB::field('author', $author);
}
if($dateline) {
$wheresql[] = 'c.'.DB::field('dateline', $dateline, '>');
}
if($message) {
$message = str_replace(array('_', '%'), array('\_', '\%'), $message);
$wheresql[] = 'c.'.DB::field('message', '%'.$message.'%', 'like');
}
return DB::result_first('SELECT COUNT(*) FROM %t m LEFT JOIN %t c ON c.cid=m.id WHERE %i',
array($table, 'home_comment', implode(' AND ', $wheresql)));
}
public function fetch_all_by_search_for_comment($idtype = null, $status = null, $author = null, $dateline = null, $message = null, $start = 0, $limit = 0) {
$wheresql = array();
if($idtype) {
$table = $this->_get_table($idtype.'_cid');
$wheresql[] = 'm.'.DB::field('idtype', $idtype.'_cid');
} else {
$table = 'home_comment_moderate';
}
if($status !== null && !(is_array($status) && empty($status))) {
$wheresql[] = 'm.'.DB::field('status', $status);
}
if($author) {
$wheresql[] = 'c.'.DB::field('author', $author);
}
if($dateline) {
$wheresql[] = 'c.'.DB::field('dateline', $dateline, '>');
}
if($message) {
$message = str_replace(array('_', '%'), array('\_', '\%'), $message);
$wheresql[] = 'c.'.DB::field('message', '%'.$message.'%', 'like');
}
return DB::fetch_all('SELECT c.cid, c.uid, c.id, c.idtype, c.authorid, c.author, c.message, c.dateline, c.ip
FROM %t m
LEFT JOIN %t c ON c.cid=m.id
WHERE %i
ORDER BY c.dateline DESC '.DB::limit($start, $limit),
array($table, 'home_comment', implode(' AND ', $wheresql)));
}
public function count_by_search_for_doing($status = null, $username = null, $dateline = null, $message = null) {
$wheresql = array();
if($status !== null && !(is_array($status) && empty($status))) {
$wheresql[] = 'm.'.DB::field('status', $status);
}
if($username) {
$wheresql[] = 'd.'.DB::field('username', $username);
}
if($dateline) {
$wheresql[] = 'd.'.DB::field('dateline', $dateline, '>');
}
if($message) {
$message = str_replace(array('_', '%'), array('\_', '\%'), $message);
$wheresql[] = 'd.'.DB::field('message', '%'.$message.'%', 'like');
}
return DB::result_first('SELECT COUNT(*)
FROM %t m
LEFT JOIN %t d ON d.doid=m.id
WHERE %i',
array($this->_get_table('doid'), 'home_doing', implode(' AND ', $wheresql)));
}
public function fetch_all_by_search_for_doing($status = null, $username = null, $dateline = null, $message = null, $start = 0, $limit = 0) {
$wheresql = array();
if($status !== null && !(is_array($status) && empty($status))) {
$wheresql[] = 'm.'.DB::field('status', $status);
}
if($username) {
$wheresql[] = 'd.'.DB::field('username', $username);
}
if($dateline) {
$wheresql[] = 'd.'.DB::field('dateline', $dateline, '>');
}
if($message) {
$message = str_replace(array('_', '%'), array('\_', '\%'), $message);
$wheresql[] = 'd.'.DB::field('message', '%'.$message.'%', 'like');
}
return DB::fetch_all('SELECT d.doid, d.uid, d.username, d.dateline, d.message, d.ip
FROM %t m
LEFT JOIN %t d ON d.doid=m.id
WHERE %i
ORDER BY m.dateline DESC '.DB::limit($start, $limit),
array($this->_get_table('doid'), 'home_doing', implode(' AND ', $wheresql)));
}
public function count_by_search_for_pic($status = null, $username = null, $dateline = null, $title = null) {
$wheresql = array();
if($status !== null && !(is_array($status) && empty($status))) {
$wheresql[] = 'm.'.DB::field('status', $status);
}
if($username) {
$wheresql[] = 'p.'.DB::field('username', $username);
}
if($dateline) {
$wheresql[] = 'p.'.DB::field('dateline', $dateline, '>');
}
if($title) {
$wheresql[] = 'p.'.DB::field('title', '%'.$title.'%', 'like');
}
return DB::result_first('SELECT COUNT(*)
FROM %t m
LEFT JOIN %t p ON p.picid=m.id
WHERE %i',
array($this->_get_table('picid'), 'home_pic', implode(' AND ', $wheresql)));
}
public function fetch_all_by_search_for_pic($status = null, $username = null, $dateline = null, $title = null, $start = 0, $limit = 0) {
$wheresql = array();
if($status !== null && !(is_array($status) && empty($status))) {
$wheresql[] = 'm.'.DB::field('status', $status);
}
if($username) {
$wheresql[] = 'p.'.DB::field('username', $username);
}
if($dateline) {
$wheresql[] = 'p.'.DB::field('dateline', $dateline, '>');
}
if($title) {
$wheresql[] = 'p.'.DB::field('title', '%'.$title.'%', 'like');
}
return DB::fetch_all('SELECT p.picid, p.albumid, p.uid, p.username, p.title, p.dateline, p.filepath, p.thumb, p.remote, p.postip, a.albumname
FROM %t m
LEFT JOIN %t p ON p.picid=m.id
LEFT JOIN %t a ON p.albumid=a.albumid
WHERE %i
ORDER BY m.dateline DESC '.DB::limit($start, $limit),
array($this->_get_table('picid'), 'home_pic', 'home_album', implode(' AND ', $wheresql)));
}
public function delete_by_status_idtype($status, $idtype) {
if(!isset($this->_tables[$idtype])) {
return false;
}
$table = $this->_get_table($idtype);
$idtype = $table == 'home_comment_moderate' ? DB::field('idtype', $idtype).' AND' : '';
return DB::query('DELETE FROM %t WHERE %i status=%d', array($table, $idtype, $status));
}
public function count_by_search_for_share($status = null, $username = null, $dateline = null, $body_general = null) {
$wheresql = array();
if($status !== null && !(is_array($status) && empty($status))) {
$wheresql[] = 'm.'.DB::field('status', $status);
}
if($username) {
$wheresql[] = 's.'.DB::field('username', $username);
}
if($dateline) {
$wheresql[] = 's.'.DB::field('dateline', $dateline, '>');
}
if($body_general) {
$body_general = str_replace(array('%', '_'), array('\%', '\_'), $body_general);
$wheresql[] = 's.'.DB::field('body_general', '%'.$body_general.'%', 'like');
}
return DB::result_first('SELECT COUNT(*)
FROM %t m
LEFT JOIN %t s ON s.sid=m.id
WHERE %i',
array($this->_get_table('sid'), 'home_share', implode(' AND ', $wheresql)));
}
public function fetch_all_by_search_for_share($status = null, $username = null, $dateline = null, $body_general = null, $start = 0, $limit = 0) {
$wheresql = array();
if($status !== null && !(is_array($status) && empty($status))) {
$wheresql[] = 'm.'.DB::field('status', $status);
}
if($username) {
$wheresql[] = 's.'.DB::field('username', $username);
}
if($dateline) {
$wheresql[] = 's.'.DB::field('dateline', $dateline, '>');
}
if($body_general) {
$wheresql[] = 's.'.DB::field('body_general', '%'.$body_general.'%', 'like');
}
return DB::fetch_all('SELECT s.sid, s.type, s.uid, s.username, s.dateline, s.body_general, s.itemid, s.fromuid
FROM %t m
LEFT JOIN %t s ON s.sid=m.id
WHERE %i
ORDER BY m.dateline DESC '.DB::limit($start, $limit),
array($this->_get_table('sid'), 'home_share', implode(' AND ', $wheresql)));
}
}
?>

View File

@@ -0,0 +1,109 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_mytask.php 27777 2012-02-14 07:07:26Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_mytask extends discuz_table
{
public function __construct() {
$this->_table = 'common_mytask';
$this->_pk = '';
parent::__construct();
}
public function delete($val, $unbuffered = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::delete($val, $unbuffered);
} else {
return $this->delete_mytask($val, $unbuffered);
}
}
public function update($val, $data, $unbuffered = false, $low_priority = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::update($val, $data, $unbuffered, $low_priority);
} else {
return $this->update_mytask($val, $data, $unbuffered);
}
}
public function count($null1 = null, $null2 = false, $null3 = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::count();
} else {
return $this->count_mytask($null1, $null2, $null3);
}
}
public function fetch($id, $force_from_db = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::fetch($id, $force_from_db);
} else {
return $this->fetch_mytask($id, $force_from_db);
}
}
public function delete_mytask($uid, $taskid) {
$condition = array();
if($uid) {
$condition[] = DB::field('uid', $uid);
}
if($taskid) {
$condition[] = DB::field('taskid', $taskid);
}
DB::delete($this->_table, implode(' AND ', $condition));
}
public function update_mytask($uid, $taskid, $data) {
if(!$data || !is_array($data)) {
return;
}
$condition = array();
if($uid) {
$condition[] = DB::field('uid', $uid);
}
if($taskid) {
$condition[] = DB::field('taskid', $taskid);
}
DB::update($this->_table, $data, implode(' AND ', $condition));
}
public function count_mytask($uid, $taskid = false, $status = false) {
$taskid = $taskid !== false ? 'AND taskid='.intval($taskid) : '';
$status = $status !== false ? 'AND status='.intval($status) : '';
return DB::result_first("SELECT COUNT(*) FROM %t WHERE uid=%d %i %i", array($this->_table, $uid, $taskid, $status));
}
public function delete_exceed($exceedtime) {
DB::query("DELETE FROM %t WHERE status='-1' AND dateline<%d", array($this->_table, TIMESTAMP - intval($exceedtime)), false, true);
}
public function fetch_all_by_taskid($taskid, $limit) {
return DB::fetch_all("SELECT * FROM %t WHERE taskid=%d ORDER BY dateline DESC LIMIT 0, %d", array($this->_table, $taskid, $limit));
}
public function fetch_mytask($uid, $taskid) {
return DB::fetch_first("SELECT * FROM %t WHERE uid=%d AND taskid=%d", array($this->_table, $uid, $taskid));
}
public function update_to_success($uid, $taskid, $timestamp) {
return DB::query('UPDATE '.DB::table($this->_table)." SET status = '1', csc = '100', dateline = '".intval($timestamp)."' WHERE taskid = '".intval($taskid)."' AND uid = '".intval($uid)."' AND status != '1'");
}
}
?>

View File

@@ -0,0 +1,135 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_nav.php 36278 2016-12-09 07:52:35Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_nav extends discuz_table
{
public function __construct() {
$this->_table = 'common_nav';
$this->_pk = 'id';
parent::__construct();
}
public function fetch_by_id_navtype($id, $navtype) {
return DB::fetch_first('SELECT * FROM %t WHERE id=%d AND navtype=%d', array($this->_table, $id, $navtype));
}
public function fetch_by_type_identifier($type, $identifier) {
return DB::fetch_first('SELECT * FROM %t WHERE type=%d AND identifier=%s', array($this->_table, $type, $identifier));
}
public function fetch_all_by_navtype($navtype = null) {
$parameter = array($this->_table);
$wheresql = '';
if($navtype !== null) {
$parameter[] = $navtype;
$wheresql = ' WHERE navtype=%d';
}
return DB::fetch_all('SELECT * FROM %t '.$wheresql.' ORDER BY available DESC, displayorder', $parameter, $this->_pk);
}
public function fetch_all_by_navtype_parentid($navtype, $parentid) {
return DB::fetch_all('SELECT * FROM %t WHERE navtype=%d AND parentid=%d ORDER BY displayorder', array($this->_table, $navtype, $parentid), $this->_pk);
}
public function fetch_all_by_navtype_type($navtype, $type) {
return DB::fetch_all('SELECT * FROM %t WHERE navtype=%d AND type=%d', array($this->_table, $navtype, $type), $this->_pk);
}
public function fetch_all_mainnav() {
return DB::fetch_all('SELECT * FROM %t WHERE navtype=0 AND (available=1 OR type=0) AND parentid=0 ORDER BY displayorder', array($this->_table), $this->_pk);
}
public function fetch_all_subnav($parentid) {
return DB::fetch_all('SELECT * FROM %t WHERE navtype=0 AND parentid=%d AND available=1 ORDER BY displayorder', array($this->_table, $parentid), $this->_pk);
}
public function fetch_all_by_navtype_type_identifier($navtype, $type, $identifier) {
$navtype = dintval($navtype, true);
$type = dintval($type, true);
if($navtype && $type) {
$wherearr[] = DB::field('navtype', $navtype);
$wherearr[] = DB::field('type', $type);
$wherearr[] = DB::field('identifier', $identifier);
return DB::fetch_all('SELECT * FROM %t WHERE %i', array($this->_table, implode(' AND ', $wherearr)), 'identifier');
}
return array();
}
public function update_by_identifier($identifier, $data) {
if(is_array($identifier) && empty($identifier)) {
return 0;
}
if(!empty($data) && is_array($data)) {
return DB::update($this->_table, $data, DB::field('identifier', $identifier));
}
return 0;
}
public function update_by_navtype_type_identifier($navtype, $type, $identifier, $data) {
if(!empty($data) && is_array($data)) {
$navtype = dintval($navtype, true);
$type = dintval($type, true);
if(is_array($navtype) && empty($navtype) || is_array($type) && empty($type) || is_array($identifier) && empty($identifier)) {
return 0;
}
$wherearr[] = DB::field('navtype', $navtype);
$wherearr[] = DB::field('type', $type);
$wherearr[] = DB::field('identifier', $identifier);
return DB::update($this->_table, $data, implode(' AND ', $wherearr));
}
return 0;
}
public function update_by_type_identifier($type, $identifier, $data) {
$type = dintval($type, is_array($type) ? true : false);
if(is_array($identifier) && empty($identifier)) {
return 0;
}
if(!empty($data) && is_array($data)) {
return DB::update($this->_table, $data, DB::field('type', $type).' AND '.DB::field('identifier', $identifier));
}
return 0;
}
public function delete_by_navtype_id($navtype, $ids) {
$ids = dintval($ids, is_array($ids) ? true : false);
$navtype = dintval($navtype, is_array($navtype) ? true : false);
if($ids) {
return DB::delete($this->_table, DB::field('id', $ids).' AND '.DB::field('navtype', $navtype));
}
return 0;
}
public function delete_by_navtype_parentid($navtype, $parentid) {
$navtype = dintval($navtype, is_array($navtype) ? true : false);
$parentid = dintval($parentid, is_array($parentid) ? true : false);
return DB::delete($this->_table, DB::field('navtype', $navtype).' AND '.DB::field('parentid', $parentid));
}
public function delete_by_type_identifier($type, $identifier) {
if(is_array($identifier) && empty($identifier)) {
return 0;
}
$type = dintval($type, is_array($type) ? true : false);
return DB::delete($this->_table, DB::field('type', $type).' AND '.DB::field('identifier', $identifier));
}
public function delete_by_parentid($id) {
$id = dintval($id, is_array($id) ? true : false);
if($id) {
return DB::delete($this->_table, DB::field('parentid', $id));
}
return 0;
}
public function count_by_navtype_type_identifier($navtype, $type, $identifier) {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE navtype=%d AND type=%d AND identifier=%s', array($this->_table, $navtype, $type, $identifier));
}
}
?>

View File

@@ -0,0 +1,44 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_onlinetime.php 27449 2012-02-01 05:32:35Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_onlinetime extends discuz_table
{
public function __construct() {
$this->_table = 'common_onlinetime';
$this->_pk = 'uid';
parent::__construct();
}
public function update_onlinetime($uid, $total, $thismonth, $lastupdate) {
if(($uid = intval($uid))) {
DB::query("UPDATE ".DB::table('common_onlinetime')."
SET total=total+'$total', thismonth=thismonth+'$thismonth', lastupdate='".$lastupdate."' WHERE ".DB::field($this->_pk, $uid));
return DB::affected_rows();
}
return false;
}
public function range_by_field($start = 0, $limit = 0, $orderby = '', $sort = '') {
$orderby = in_array($orderby, array('thismonth', 'total', 'lastupdate'), true) ? $orderby : '';
return DB::fetch_all('SELECT * FROM '.DB::table($this->_table).($orderby ? ' WHERE '.$orderby.' >0 ORDER BY '.DB::order($orderby, $sort) : '').' '.DB::limit($start, $limit), null, $this->_pk);
}
public function update_thismonth() {
return DB::update($this->_table, array('thismonth'=>0));
}
}
?>

View File

@@ -0,0 +1,52 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_optimizer.php 31034 2012-07-11 04:03:30Z zhangjie $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_optimizer extends discuz_table {
public function __construct() {
$this->_table = 'common_optimizer';
$this->_pk = 'k';
parent::__construct();
}
public function fetch($id, $force_from_db = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::fetch($id, $force_from_db);
} else {
return $this->fetch_optimizer($id, $force_from_db);
}
}
public function update($val, $data, $unbuffered = false, $low_priority = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::update($val, $data, $unbuffered, $low_priority);
} else {
return $this->update_optimizer($val, $data);
}
}
public function fetch_optimizer($skey, $auto_unserialize = false) {
$data = DB::result_first('SELECT v FROM '.DB::table($this->_table).' WHERE '.DB::field($this->_pk, $skey));
return $auto_unserialize ? (array)dunserialize($data) : $data;
}
public function update_optimizer($skey, $svalue){
return DB::insert($this->_table, array($this->_pk => $skey, 'v' => is_array($svalue) ? serialize($svalue) : $svalue), false, true);
}
}
?>

View File

@@ -0,0 +1,54 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_patch.php 27449 2012-02-01 05:32:35Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_patch extends discuz_table
{
public function __construct() {
$this->_table = 'common_patch';
$this->_pk = 'serial';
parent::__construct();
}
public function fetch_all($ids = array(), $force_from_db = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::fetch_all($ids, $force_from_db);
} else {
return $this->fetch_all_patch();
}
}
public function fetch_all_patch() {
return DB::fetch_all("SELECT * FROM ".DB::table($this->_table));
}
public function fetch_max_serial() {
return DB::result_first("SELECT serial FROM ".DB::table($this->_table)." ORDER BY serial DESC LIMIT 1");
}
public function update_status_by_serial($status, $serial, $condition = '') {
return DB::query("UPDATE ".DB::table($this->_table)." SET ".DB::field('status', $status)." WHERE ".DB::field('serial', $serial, $condition));
}
public function fetch_needfix_patch($serials) {
return DB::fetch_all("SELECT * FROM ".DB::table($this->_table)." WHERE ".DB::field('serial', $serials)." AND status<=0");
}
public function fetch_patch_by_status($status) {
return DB::fetch_all("SELECT * FROM ".DB::table($this->_table)." WHERE ".DB::field('status', $status));
}
}
?>

View File

@@ -0,0 +1,96 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_payment_order.php 36342 2021-05-17 15:14:35Z dplugin $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_payment_order extends discuz_table
{
public function __construct() {
$this->_table = 'common_payment_order';
$this->_pk = 'id';
parent::__construct();
}
public function update_order_finish($id, $trade_no, $payment_time, $channel) {
DB::query("UPDATE %t SET `trade_no` = %s,`payment_time` = %d, `channel` = %s, `status` = %d WHERE `id` = %d AND `status` = 0", array($this->_table, $trade_no, $payment_time, $channel, 1, $id));
return DB::affected_rows();
}
public function count_by_search($uid, $optype, $begintime, $endtime, $out_biz_no = '', $channel = '', $status = '') {
$condition = $this->make_query_condition($uid, $optype, $begintime, $endtime, $out_biz_no, $channel, $status);
return DB::result_first('SELECT COUNT(*) FROM %t ' . $condition[0], $condition[1]);
}
public function fetch_by_biz_no($out_biz_no) {
return DB::fetch_first("SELECT * FROM %t WHERE out_biz_no = %s", array($this->_table, $out_biz_no));
}
public function fetch_type_all($uid = 0) {
$wherestr = '';
if($uid) {
$wherestr = 'WHERE `uid` = ' . intval($uid);
}
$query = DB::query("SELECT `type`, `type_name` FROM %t $wherestr GROUP BY `type`", array($this->_table));
$result = array();
while($item = DB::fetch($query)) {
$result[$item['type']] = $item['type_name'];
}
return $result;
}
public function fetch_all_by_search($uid, $optype, $begintime = 0, $endtime = 0, $out_biz_no = '', $channel = '', $status = '', $start = 0, $limit = 0) {
$condition = $this->make_query_condition($uid, $optype, $begintime, $endtime, $out_biz_no, $channel, $status);
return DB::fetch_all('SELECT * FROM %t ' . $condition[0] . ' ORDER BY id DESC ' . DB::limit($start, $limit), $condition[1], 'id');
}
private function make_query_condition($uid, $optype, $begintime = 0, $endtime = 0, $out_biz_no = '', $channel = '', $status = '') {
$wherearr = array();
$parameter = array($this->_table);
if($out_biz_no) {
$wherearr[] = 'out_biz_no = %s';
$parameter[] = $out_biz_no;
}
if($uid) {
$uid = dintval($uid, true);
$wherearr[] = is_array($uid) && $uid ? 'uid IN (%n)' : 'uid = %d';
$parameter[] = $uid;
}
if($optype) {
$wherearr[] = is_array($optype) && $optype ? '`type` IN (%n)' : '`type` = %s';
$parameter[] = $optype != -1 ? $optype : '';
}
if($channel) {
$wherearr[] = 'channel = %s';
$parameter[] = $channel;
}
if($status !== '') {
if($status == 2) {
$wherearr[] = '`status` = 0 AND `expire_time` < %d';
$parameter[] = time();
} else {
$wherearr[] = '`status` = %d';
$parameter[] = $status;
}
}
if($begintime) {
$wherearr[] = 'dateline > %d';
$parameter[] = dmktime($begintime);
}
if($endtime) {
$wherearr[] = 'dateline < %d';
$parameter[] = dmktime($endtime);
}
$wheresql = !empty($wherearr) && is_array($wherearr) ? ' WHERE ' . implode(' AND ', $wherearr) : '';
return array($wheresql, $parameter);
}
}
?>

View File

@@ -0,0 +1,35 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_payment_refund.php 36342 2021-05-17 15:17:15Z dplugin $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_payment_refund extends discuz_table
{
public function __construct() {
$this->_table = 'common_payment_refund';
$this->_pk = 'id';
parent::__construct();
}
public function fetch_by_no($refund_no) {
return DB::fetch_first("SELECT * FROM %t WHERE out_biz_no = %s", array($this->_table, $refund_no));
}
public function update_refund_by_no($refund_no, $data) {
DB::update($this->_table, $data, DB::field('out_biz_no', $refund_no));
}
public function sum_by_orders($ids) {
return DB::fetch_all("SELECT `order_id`, sum(`amount`) as `amount` FROM %t WHERE `order_id` in (%n) AND `status` = 2 GROUP BY `order_id`", array($this->_table, $ids), 'order_id');
}
}
?>

View File

@@ -0,0 +1,73 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_payment_transfer.php 36342 2021-05-17 15:17:43Z dplugin $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_payment_transfer extends discuz_table
{
public function __construct() {
$this->_table = 'common_payment_transfer';
$this->_pk = 'id';
parent::__construct();
}
public function fetch_by_no($transfer_no) {
return DB::fetch_first("SELECT * FROM %t WHERE out_biz_no = %s", array($this->_table, $transfer_no));
}
public function update_transfer_by_no($transfer_no, $data) {
DB::update($this->_table, $data, DB::field('out_biz_no', $transfer_no));
}
public function count_by_search($uid, $begintime, $endtime, $out_biz_no = '', $channel = '', $status = '') {
$condition = $this->make_query_condition($uid, $begintime, $endtime, $out_biz_no, $channel, $status);
return DB::result_first('SELECT COUNT(*) FROM %t ' . $condition[0], $condition[1]);
}
public function fetch_all_by_search($uid, $begintime = 0, $endtime = 0, $out_biz_no = '', $channel = '', $status = '', $start = 0, $limit = 0) {
$condition = $this->make_query_condition($uid, $begintime, $endtime);
return DB::fetch_all('SELECT * FROM %t ' . $condition[0] . ' ORDER BY id DESC ' . DB::limit($start, $limit), $condition[1], 'id');
}
private function make_query_condition($uid, $begintime = 0, $endtime = 0, $out_biz_no = '', $channel = '', $status = '') {
$wherearr = array();
$parameter = array($this->_table);
if($out_biz_no) {
$wherearr[] = 'out_biz_no = %s';
$parameter[] = $out_biz_no;
}
if($uid) {
$uid = dintval($uid, true);
$wherearr[] = is_array($uid) && $uid ? 'uid IN (%n)' : 'uid = %d';
$parameter[] = $uid;
}
if($channel) {
$wherearr[] = 'channel = %s';
$parameter[] = $channel;
}
if($status !== '') {
$wherearr[] = 'status = %d';
$parameter[] = $status;
}
if($begintime) {
$wherearr[] = 'dateline > %d';
$parameter[] = dmktime($begintime);
}
if($endtime) {
$wherearr[] = 'dateline < %d';
$parameter[] = dmktime($endtime);
}
$wheresql = !empty($wherearr) && is_array($wherearr) ? ' WHERE ' . implode(' AND ', $wherearr) : '';
return array($wheresql, $parameter);
}
}
?>

View File

@@ -0,0 +1,58 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_plugin.php 32122 2012-11-14 01:55:46Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_plugin extends discuz_table
{
public function __construct() {
$this->_table = 'common_plugin';
$this->_pk = 'pluginid';
parent::__construct();
}
public function fetch_by_identifier($identifier) {
return DB::fetch_first('SELECT * FROM %t WHERE identifier=%s', array($this->_table, $identifier));
}
public function fetch_all_identifier($identifier) {
return DB::fetch_all('SELECT * FROM %t WHERE identifier IN (%n)', array($this->_table, $identifier), 'identifier');
}
public function fetch_all_data($available = false) {
$available = $available !== false ? 'WHERE available='.intval($available) : '';
return DB::fetch_all('SELECT * FROM %t %i ORDER BY available DESC, pluginid DESC', array($this->_table, $available));
}
public function fetch_all_by_identifier($identifier) {
if(!$identifier) {
return;
}
return DB::fetch_all('SELECT * FROM %t WHERE %i', array($this->_table, DB::field('identifier', $identifier)));
}
public function fetch_by_pluginvarid($pluginid, $pluginvarid) {
return DB::fetch_first("SELECT * FROM %t p, %t pv WHERE p.pluginid=%d AND pv.pluginid=p.pluginid AND pv.pluginvarid=%d",
array($this->_table, 'common_pluginvar', $pluginid, $pluginvarid));
}
public function delete_by_identifier($identifier) {
if(!$identifier) {
return;
}
DB::delete('common_plugin', DB::field('identifier', $identifier));
}
}
?>

View File

@@ -0,0 +1,65 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_pluginvar.php 31830 2012-10-15 06:57:05Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_pluginvar extends discuz_table
{
public function __construct() {
$this->_table = 'common_pluginvar';
$this->_pk = 'pluginvarid';
parent::__construct();
}
public function fetch_all_by_pluginid($pluginid) {
return DB::fetch_all("SELECT * FROM %t WHERE pluginid=%d ORDER BY displayorder", array($this->_table, $pluginid));
}
public function count_by_pluginid($pluginid) {
return DB::result_first("SELECT COUNT(*) FROM %t WHERE pluginid=%d %i", array($this->_table, $pluginid, "AND (`type` NOT LIKE 'forum\_%' AND `type` NOT LIKE 'group\_%')"));
}
public function update_by_variable($pluginid, $variable, $data) {
if(!$pluginid || !$variable || !$data || !is_array($data)) {
return;
}
DB::update($this->_table, $data, DB::field('pluginid', $pluginid).' AND '.DB::field('variable', $variable));
}
public function update_by_pluginvarid($pluginid, $pluginvarid, $data) {
if(!$pluginid || !$pluginvarid || !$data || !is_array($data)) {
return;
}
DB::update($this->_table, $data, DB::field('pluginid', $pluginid).' AND '.DB::field('pluginvarid', $pluginvarid));
}
public function check_variable($pluginid, $variable) {
return DB::result_first("SELECT COUNT(*) FROM %t WHERE pluginid=%d AND variable=%s", array($this->_table, $pluginid, $variable));
}
public function delete_by_pluginid($pluginid) {
if(!$pluginid) {
return;
}
DB::delete($this->_table, DB::field('pluginid', $pluginid));
}
public function delete_by_variable($pluginid, $variable) {
if(!$pluginid || !$variable) {
return;
}
DB::delete($this->_table, DB::field('pluginid', $pluginid).' AND '.DB::field('variable', $variable));
}
}
?>

View File

@@ -0,0 +1,30 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_process.php 27449 2012-02-01 05:32:35Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_process extends discuz_table
{
public function __construct() {
$this->_table = 'common_process';
$this->_pk = 'processid';
parent::__construct();
}
public function delete_process($name, $time) {
$name = addslashes($name);
return DB::delete('common_process', "processid='$name' OR expiry<".intval($time));
}
}
?>

View File

@@ -0,0 +1,45 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_regip.php 28771 2012-03-12 09:13:43Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_regip extends discuz_table
{
public function __construct() {
$this->_table = 'common_regip';
$this->_pk = '';
parent::__construct();
}
public function fetch_by_ip_dateline($clientip, $dateline) {
return DB::fetch_first('SELECT count FROM %t WHERE ip=%s AND count>0 AND dateline>%d', array($this->_table, $clientip, $dateline));
}
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;
}
public function update_count_by_ip($clientip) {
return DB::query('UPDATE %t SET count=count+1 WHERE ip=%s AND count>0', array($this->_table, $clientip));
}
public function delete_by_dateline($dateline) {
return DB::query('DELETE FROM %t WHERE dateline<=%d', array($this->_table, $dateline), false, true);
}
}
?>

View File

@@ -0,0 +1,26 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_relatedlink.php 27449 2012-02-01 05:32:35Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_relatedlink extends discuz_table
{
public function __construct() {
$this->_table = 'common_relatedlink';
$this->_pk = 'id';
parent::__construct();
}
}
?>

View File

@@ -0,0 +1,57 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_report.php 27449 2012-02-01 05:32:35Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_report extends discuz_table
{
public function __construct() {
$this->_table = 'common_report';
$this->_pk = 'id';
parent::__construct();
}
public function fetch_count($operated = 0, $id = 0, $fid = 0) {
$where = empty($operated) ? 'opuid=0' : 'opuid>0';
$idsql = $id ? DB::field('id', $id).' AND ' : '';
$fidsql = $fid ? ' AND '.DB::field('fid', $fid) : '';
return DB::result_first('SELECT count(*) FROM '.DB::table('common_report').' WHERE '.$idsql.$where.$fidsql);
}
public function fetch_all($ids = null, $force_from_db = false, $null1 = 0, $null2 = 0) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::fetch_all($ids, $force_from_db);
} else {
$ids = $ids === null ? 0 : $ids;
$force_from_db = $force_from_db === false ? 100 : $force_from_db;
return $this->fetch_all_report($ids, $force_from_db, $null1, $null2);
}
}
public function fetch_all_report($start = 0, $limit = 100, $operated = 0, $fid = 0) {
$where = empty($operated) ? 'opuid=0' : 'opuid>0';
$order = empty($operated) ? 'num' : 'optime';
$fidsql = $fid ? ' AND '.DB::field('fid', $fid) : '';
return DB::fetch_all("SELECT * FROM %t WHERE $where.$fidsql ORDER BY $order DESC, dateline DESC LIMIT %d, %d", array($this->_table, $start, $limit));
}
public function fetch_by_urlkey($urlkey) {
return DB::result_first("SELECT id FROM %t WHERE urlkey=%s AND opuid='0'", array($this->_table, $urlkey));
}
public function update_num($id, $message) {
DB::query("UPDATE %t SET message=CONCAT_WS('<br>', message, %s), num=num+1 WHERE id=%d", array($this->_table, $message, $id));
}
}
?>

View File

@@ -0,0 +1,53 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_searchindex.php 28041 2012-02-21 07:33:55Z chenmengshu $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_searchindex extends discuz_table
{
public function __construct() {
$this->_table = 'common_searchindex';
$this->_pk = 'searchid';
parent::__construct();
}
public function fetch_by_searchid_srchmod($searchid, $srchmod) {
return DB::fetch_first('SELECT * FROM %t WHERE searchid=%d AND srchmod=%d', array($this->_table, $searchid, $srchmod));
}
public function count_by_dateline($timestamp, $srchmod = '') {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE '.($srchmod ? 'srchmod='.dintval($srchmod).' AND ' : '').'dateline>%d-60', array($this->_table, $timestamp));
}
public function fetch_all_search($searchctrl, $useip, $uid, $timestamp, $searchstring, $srchmod = '') {
if(!$searchctrl || !$timestamp) {
return null;
}
$timestamp = dintval($timestamp);
$uid = dintval($uid);
$srchmod = dintval($srchmod);
$useip = daddslashes($useip);
$searchctrl = dintval($searchctrl);
$searchstring = daddslashes($searchstring);
return DB::fetch_all("SELECT searchid, dateline,
('".$searchctrl."'<>'0' AND ".(empty($uid) ? "useip='$useip'" : "uid='$uid'")." AND $timestamp-dateline<'".$searchctrl."') AS flood,
(searchstring='$searchstring' AND expiration>'$timestamp') AS indexvalid
FROM ".DB::table($this->_table)."
WHERE ".($srchmod ? "srchmod='$srchmod' AND " : '')."('".$searchctrl."'<>'0' AND ".(empty($uid) ? "useip='$useip'" : "uid='$uid'")." AND $timestamp-dateline<".$searchctrl.") OR (searchstring='$searchstring' AND expiration>'$timestamp')
ORDER BY flood");
}
}
?>

View File

@@ -0,0 +1,115 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_seccheck.php 33625 2013-07-19 06:03:49Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_seccheck extends discuz_table
{
private $_uids = array();
public function __construct() {
$this->_table = 'common_seccheck';
$this->_pk = 'ssid';
$this->_pre_cache_key = 'common_seccheck_';
$this->_cache_ttl = 600;
parent::__construct();
}
public function delete_expiration($ssid = 0) {
if ($this->_allowmem) {
if ($ssid) {
$ssid = dintval($ssid);
memory('rm', $ssid . "_verified", $this->_pre_cache_key);
memory('rm', $ssid . "_succeed", $this->_pre_cache_key);
memory('rm', $ssid . "_code", $this->_pre_cache_key);
memory('rm', $ssid . "_dateline", $this->_pre_cache_key);
}
} else {
if($ssid) {
$ssid = dintval($ssid);
DB::delete($this->_table, "ssid='$ssid'");
}
DB::delete($this->_table, TIMESTAMP."-dateline>600");
DB::delete($this->_table, "verified>4");
DB::delete($this->_table, "succeed>1");
}
}
public function update_verified($ssid) {
if ($this->_allowmem) {
memory('inc', $ssid . "_verified", 1, 0, $this->_pre_cache_key);
} else {
DB::query("UPDATE %t SET verified=verified+1 WHERE ssid=%d", array($this->_table, $ssid));
}
}
public function update_succeed($ssid) {
if (!$this->_allowmem) {
return DB::query("UPDATE %t SET verified=verified+1,succeed=succeed+1 WHERE ssid=%d", array($this->_table, $ssid));
}
memory('inc', $ssid . "_verified", 1, 0, $this->_pre_cache_key);
memory('inc', $ssid . "_succeed", 1, 0, $this->_pre_cache_key);
return 1; // simulate 1 row changed
}
public function truncate() {
if ($this->_allowmem) {
} else {
DB::query("TRUNCATE %t", array($this->_table));
}
}
public function insert($data, $return_insert_id = false, $replace = false, $silent = false) {
if (!$this->_allowmem) {
return parent::insert($data, $return_insert_id, $replace, $silent);
}
$ssid = memory("inc", 'pk', 1, 0, $this->_pre_cache_key);
foreach ($data as $key => $value) {
memory('set', $ssid . "_" . $key, $value, $this->_cache_ttl, $this->_pre_cache_key);
}
if ($return_insert_id) {
return $ssid;
}
return TRUE;
}
public function fetch($id, $force_from_db = false) {
if (!$this->_allowmem) {
return parent::fetch($id, $force_from_db);
}
$data = array();
$data['ssid'] = $id;
$data['code'] = memory('get', $id . "_code", $this->_pre_cache_key);
$data['dateline'] = memory('get', $id . "_dateline", $this->_pre_cache_key);
$data['succeed'] = memory('get', $id . "_succeed", $this->_pre_cache_key);
$data['verified'] = memory('get', $id . "_verified", $this->_pre_cache_key);
return $data;
}
public function delete($ssid, $force_from_db = false) {
if (!$this->_allowmem || $force_from_db) {
return parent::delete($ssid, $force_from_db);
}
$ssid = dintval($ssid);
memory('rm', $ssid . "_verified", $this->_pre_cache_key);
memory('rm', $ssid . "_succeed", $this->_pre_cache_key);
memory('rm', $ssid . "_code", $this->_pre_cache_key);
memory('rm', $ssid . "_dateline", $this->_pre_cache_key);
return true;
}
}
?>

View File

@@ -0,0 +1,45 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_secquestion.php 27449 2012-02-01 05:32:35Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_secquestion extends discuz_table
{
public function __construct() {
$this->_table = 'common_secquestion';
$this->_pk = 'id';
parent::__construct();
}
public function fetch_all($ids = null, $force_from_db = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::fetch_all($ids, $force_from_db);
} else {
$ids = $ids === null ? 0 : $ids;
$force_from_db = $force_from_db === false ? 0 : $force_from_db;
return $this->fetch_all_secquestion($ids, $force_from_db);
}
}
public function fetch_all_secquestion($start = 0, $limit = 0) {
return DB::fetch_all('SELECT * FROM %t'.DB::limit($start, $limit), array($this->_table));
}
public function delete_by_type($type) {
DB::query('DELETE FROM %t WHERE type=%d', array($this->_table, $type));
}
}
?>

View File

@@ -0,0 +1,140 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_session.php 28051 2012-02-21 10:36:56Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_session extends discuz_table
{
public function __construct() {
$this->_table = 'common_session';
$this->_pk = 'sid';
parent::__construct();
}
public function fetch($id, $force_from_db = false, $null = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::fetch($id, $force_from_db);
} else {
return $this->fetch_session($id, $force_from_db, $null);
}
}
public function fetch_session($sid, $ip = false, $uid = false) {
if(empty($sid)) {
return array();
}
$this->checkpk();
$session = parent::fetch($sid);
if($session && $ip !== false && $ip != "{$session['ip']}") {
$session = array();
}
if($session && $uid !== false && $uid != $session['uid']) {
$session = array();
}
return $session;
}
public function fetch_member($ismember = 0, $invisible = 0, $start = 0, $limit = 0) {
$sql = array();
if($ismember === 1) {
$sql[] = 'uid > 0';
} elseif($ismember === 2) {
$sql[] = 'uid = 0';
}
if($invisible === 1) {
$sql[] = 'invisible = 1';
} elseif($invisible === 2) {
$sql[] = 'invisible = 0';
}
$wheresql = !empty($sql) && is_array($sql) ? ' WHERE '.implode(' AND ', $sql) : '';
$sql = 'SELECT * FROM %t '.$wheresql.' ORDER BY lastactivity DESC'.DB::limit($start, $limit);
return DB::fetch_all($sql, array($this->_table), $this->_pk);
}
public function count_invisible($type = 1) {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE invisible=%d', array($this->_table, $type));
}
public function count($type = 0) {
$condition = $type == 1 ? ' WHERE uid>0 ' : ($type == 2 ? ' WHERE uid=0 ' : '');
return DB::result_first("SELECT count(*) FROM ".DB::table($this->_table).$condition);
}
public function delete_by_session($session, $onlinehold, $guestspan) {
if(empty($session) || !is_array($session)) return;
$onlinehold = time() - $onlinehold;
$guestspan = time() - $guestspan;
$session = daddslashes($session);
$condition = " sid='{$session['sid']}' ";
$condition .= " OR lastactivity<$onlinehold ";
$condition .= " OR (uid='0' AND ".DB::field('ip', $session['ip'])." AND lastactivity>$guestspan) ";
$condition .= $session['uid'] ? " OR (uid='{$session['uid']}') " : '';
DB::delete('common_session', $condition);
}
public function fetch_by_uid($uid) {
return !empty($uid) ? DB::fetch_first('SELECT * FROM %t WHERE uid=%d', array($this->_table, $uid)) : false;
}
public function fetch_all_by_uid($uids, $start = 0, $limit = 0) {
$data = array();
if(!empty($uids)) {
$data = DB::fetch_all('SELECT * FROM %t WHERE '.DB::field('uid', $uids).DB::limit($start, $limit), array($this->_table), null, 'uid');
}
return $data;
}
public function update_max_rows($max_rows) {
return DB::query('ALTER TABLE '.DB::table('common_session').' MAX_ROWS='.dintval($max_rows));
}
public function clear() {
return DB::query('DELETE FROM '.DB::table('common_session'));
}
public function count_by_fid($fid) {
return ($fid = dintval($fid)) ? DB::result_first('SELECT COUNT(*) FROM '.DB::table('common_session')." WHERE uid>'0' AND fid='$fid' AND invisible='0'") : 0;
}
public function fetch_all_by_fid($fid, $limit = 12) {
return ($fid = dintval($fid)) ? DB::fetch_all('SELECT uid, groupid, username, invisible, lastactivity FROM '.DB::table('common_session')." WHERE uid>'0' AND fid='$fid' AND invisible='0' ORDER BY lastactivity DESC".DB::limit($limit)) : array();
}
public function update_by_uid($uid, $data){
if(($uid = dintval($uid)) && !empty($data) && is_array($data)) {
return DB::update($this->_table, $data, DB::field('uid', $uid));
}
return 0;
}
public function count_by_ip($ip) {
$count = 0;
if(!empty($ip)) {
$count = DB::result_first('SELECT COUNT(*) FROM '.DB::table('common_session')." WHERE ".DB::field('ip', $ip));
}
return $count;
}
public function fetch_all_by_ip($ip, $start = 0, $limit = 0) {
$data = array();
if(!empty($ip)) {
$data = DB::fetch_all('SELECT * FROM %t WHERE ip=%s ORDER BY lastactivity DESC'.DB::limit($start, $limit), array($this->_table, $ip), null);
}
return $data;
}
}
?>

View File

@@ -0,0 +1,105 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_setting.php 30476 2012-05-30 07:05:06Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_setting extends discuz_table
{
public function __construct() {
$this->_table = 'common_setting';
$this->_pk = 'skey';
parent::__construct();
}
public function fetch($id, $force_from_db = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::fetch($id, $force_from_db);
} else {
return $this->fetch_setting($id, $force_from_db);
}
}
public function fetch_all($ids, $force_from_db = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::fetch_all($ids, $force_from_db);
} else {
return $this->fetch_all_setting($ids, $force_from_db);
}
}
public function update($val, $data, $unbuffered = false, $low_priority = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::update($val, $data, $unbuffered, $low_priority);
} else {
return $this->update_setting($val, $data);
}
}
public function fetch_setting($skey, $auto_unserialize = false) {
$data = DB::result_first('SELECT svalue FROM '.DB::table($this->_table).' WHERE '.DB::field($this->_pk, $skey));
return $auto_unserialize ? (array)dunserialize($data) : $data;
}
public function fetch_all_setting($skeys = array(), $auto_unserialize = false){
$data = array();
$where = !empty($skeys) ? ' WHERE '.DB::field($this->_pk, $skeys) : '';
$query = DB::query('SELECT * FROM '.DB::table($this->_table).$where);
while($value = DB::fetch($query)) {
$data[$value['skey']] = $auto_unserialize ? (array)dunserialize($value['svalue']) : $value['svalue'];
}
return $data;
}
public function update_setting($skey, $svalue){
return DB::insert($this->_table, array($this->_pk => $skey, 'svalue' => is_array($svalue) ? serialize($svalue) : $svalue), false, true);
}
public function update_batch($array) {
$settings = array();
foreach($array as $key => $value) {
$key = addslashes($key);
$value = addslashes(is_array($value) ? serialize($value) : $value);
$settings[] = "('$key', '$value')";
}
if($settings) {
return DB::query("REPLACE INTO ".DB::table('common_setting')." (`skey`, `svalue`) VALUES ".implode(',', $settings));
}
return false;
}
public function skey_exists($skey) {
return DB::result_first('SELECT skey FROM %t WHERE skey=%s LIMIT 1', array($this->_table, $skey)) ? true : false;
}
public function fetch_all_not_key($skey) {
return DB::fetch_all('SELECT * FROM '.DB::table($this->_table).' WHERE skey NOT IN('.dimplode($skey).')');
}
public function fetch_all_table_status() {
return DB::fetch_all('SHOW TABLE STATUS');
}
public function get_tablepre() {
return DB::object()->tablepre;
}
public function update_count($skey, $num) {
return DB::query("UPDATE %t SET svalue = svalue + %d WHERE skey = %s", array($this->_table, $num, $skey), false, true);
}
}
?>

View File

@@ -0,0 +1,111 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_smiley.php 28700 2012-03-08 06:23:29Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_smiley extends discuz_table
{
private $allowtype = array('smiley','stamp','stamplist');
public function __construct() {
$this->_table = 'common_smiley';
$this->_pk = 'id';
parent::__construct();
}
public function fetch_all_by_type($type) {
$type = $this->checktype($type);
if(empty($type)) {
return array();
}
$typesql = is_array($type) ? 'type IN(%n)' : 'type=%s';
return DB::fetch_all("SELECT * FROM %t WHERE $typesql ORDER BY displayorder", array($this->_table, $type), $this->_pk);
}
public function fetch_all_by_typeid_type($typeid, $type, $start = 0, $limit = 0) {
return DB::fetch_all('SELECT * FROM %t WHERE typeid=%d AND type=%s ORDER BY displayorder '.DB::limit($start, $limit), array($this->_table, $typeid, $type), $this->_pk);
}
public function fetch_all_by_type_code_typeid($type, $typeid) {
return DB::fetch_all("SELECT * FROM %t WHERE type=%s AND code<>'' AND typeid=%d ORDER BY displayorder ", array($this->_table, $type, $typeid), $this->_pk);
}
public function fetch_all_cache() {
return DB::fetch_all("SELECT s.id, s.code, s.url, t.typeid FROM %t s INNER JOIN %t t ON t.typeid=s.typeid WHERE s.type='smiley' AND s.code<>'' AND t.available='1' ORDER BY LENGTH(s.code) DESC", array($this->_table, 'forum_imagetype'));
}
public function fetch_by_id_type($id, $type) {
return DB::fetch_first('SELECT * FROM %t WHERE id=%d AND type=%s', array($this->_table, $id, $type), $this->_pk);
}
public function update_by_type($type, $data) {
if(!empty($data) && is_array($data) && in_array($type, $this->allowtype)) {
return DB::update($this->_table, $data, DB::field('type', $type));
}
return 0;
}
public function update_by_id_type($id, $type, $data) {
$id = dintval($id, true);
if(!empty($data) && is_array($data) && $id && in_array($type, $this->allowtype)) {
return DB::update($this->_table, $data, DB::field('id', $id).' AND '.DB::field('type', $type));
}
return 0;
}
public function update_code_by_typeid($typeid) {
$typeid = dintval($typeid, true);
if(empty($typeid)) {
return 0;
}
$typeidsql = is_array($typeid) ? 'typeid IN(%n)' : 'typeid=%d';
return DB::query("UPDATE %t SET code=CONCAT('{:', typeid, '_', id, ':}') WHERE $typeidsql", array($this->_table, $typeid));
}
public function update_code_by_id($ids) {
$ids = dintval($ids, true);
if(empty($ids)) {
return 0;
}
$idssql = is_array($ids) ? 'id IN(%n)' : 'id=%d';
return DB::query("UPDATE %t SET code=CONCAT('{:', typeid, '_', id, ':}') WHERE $idssql", array($this->_table, $ids));
}
public function count_by_type($type) {
$type = $this->checktype($type);
if(empty($type)) {
return 0;
}
return DB::result_first('SELECT COUNT(*) FROM %t WHERE type IN(%n)', array($this->_table, $type));
}
public function count_by_typeid($typeid) {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE typeid=%d', array($this->_table, $typeid));
}
public function count_by_type_typeid($type, $typeid) {
$typeid = dintval($typeid, true);
if(!empty($typeid) && in_array($type, $this->allowtype)) {
return DB::result_first('SELECT COUNT(*) FROM %t WHERE type=%s AND typeid IN(%n)', array($this->_table, $type, $typeid));
}
return 0;
}
public function count_by_type_code_typeid($type, $typeid) {
return DB::result_first("SELECT COUNT(*) FROM %t WHERE type=%s AND code<>'' AND typeid=%d", array($this->_table, $type, $typeid));
}
private function checktype($type) {
if(is_array($type)) {
foreach($type as $key => $val) {
if(!in_array($val, $this->allowtype)) {
unset($type[$key]);
}
}
} else {
$type = in_array($type, $this->allowtype) ? $type : '';
}
return $type;
}
}
?>

View File

@@ -0,0 +1,34 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id$
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_smsgw extends discuz_table
{
public function __construct() {
$this->_table = 'common_smsgw';
$this->_pk = 'smsgwid';
parent::__construct();
}
public function fetch_all_gw_order_id() {
return DB::fetch_all("SELECT * FROM %t ORDER BY `order`, $this->_pk", array($this->_table));
}
public function fetch_all_gw_avaliable() {
return DB::fetch_all("SELECT * FROM %t WHERE available > %d ORDER BY `order`, $this->_pk", array($this->_table, 0));
}
}
?>

View File

@@ -0,0 +1,66 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id$
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_smslog extends discuz_table
{
private $_archiver_table = 'common_smslog_archive';
public function __construct() {
$this->_table = 'common_smslog';
$this->_pk = 'smslogid';
parent::__construct();
}
public function get_lastsms_by_uumm($uid, $svctype, $secmobicc, $secmobile) {
return DB::fetch_first("SELECT * FROM %t WHERE uid = %d AND svctype = %d AND secmobicc = %d AND secmobile = %d ORDER BY dateline DESC", array($this->_table, $uid, $svctype, $secmobicc, $secmobile));
}
public function get_sms_by_ut($uid, $time) {
$dateline = time() - $time;
return DB::fetch_all("SELECT dateline FROM %t WHERE uid = %d AND dateline > %d", array($this->_table, $uid, $dateline));
}
public function get_sms_by_mmt($secmobicc, $secmobile, $time) {
$dateline = time() - $time;
return DB::fetch_all("SELECT dateline FROM %t WHERE secmobicc = %d AND secmobile = %d AND dateline > %d", array($this->_table, $secmobicc, $secmobile, $dateline));
}
public function count_sms_by_milions_mmt($secmobicc, $secmobile, $time) {
$dateline = time() - $time;
$secmobile = substr($secmobile, 0, -4);
return DB::result_first("SELECT COUNT(*) FROM %t WHERE secmobicc = %d AND secmobile LIKE %d AND dateline > %d", array($this->_table, $secmobicc, $secmobile, $dateline));
}
public function count_sms_by_time($time) {
$dateline = time() - $time;
return DB::result_first("SELECT COUNT(*) FROM %t WHERE dateline > %d", array($this->_table, $dateline));
}
public function fetch_all_by_dateline($dateline, $glue = '>=') {
$glue = helper_util::check_glue($glue);
return DB::fetch_all("SELECT * FROM %t WHERE dateline{$glue}%d ORDER BY dateline", array($this->_table, $dateline), $this->_pk);
}
public function insert_archiver($data) {
if(!empty($data) && is_array($data)) {
return DB::insert($this->_archiver_table, $data, false, true);
}
return 0;
}
}
?>

View File

@@ -0,0 +1,26 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_sphinxcounter.php 27449 2012-02-01 05:32:35Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_sphinxcounter extends discuz_table
{
public function __construct() {
$this->_table = 'common_sphinxcounter';
$this->_pk = 'indexid';
parent::__construct();
}
}
?>

View File

@@ -0,0 +1,80 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_stat.php 28051 2012-02-21 10:36:56Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_stat extends discuz_table
{
public function __construct() {
$this->_table = 'common_stat';
$this->_pk = 'daytime';
parent::__construct();
}
public function updatestat($uid, $type, $primary = 0, $num = 1) {
$nowdaytime = dgmdate(TIMESTAMP, 'Ymd');
$type = addslashes($type);
if($primary) {
$setarr = array(
'uid' => intval($uid),
'daytime' => $nowdaytime,
'type' => $type
);
if(C::t('common_statuser')->check_exists($uid, $nowdaytime, $type)) {
return false;
} else {
C::t('common_statuser')->insert($setarr);
}
}
$num = abs(intval($num));
if(DB::result_first('SELECT COUNT(*) FROM '.DB::table($this->_table)." WHERE `daytime` = '$nowdaytime'")){
DB::query('UPDATE '.DB::table($this->_table)." SET `$type`=`$type`+$num WHERE `daytime` = '$nowdaytime'");
} else {
DB::query("INSERT INTO ".DB::table($this->_table)." (`daytime`, `$type`) VALUES ('$nowdaytime', '$num') ON DUPLICATE KEY UPDATE `$type` = `$type` + '$num'");
C::t('common_statuser')->clear_by_daytime($nowdaytime);
}
}
public function fetch_post_avg() {
return DB::result_first("SELECT AVG(post) FROM ".DB::table($this->_table));
}
public function fetch_all($ids, $force_from_db = false, $null = '*') {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::fetch_all($ids, $force_from_db);
} else {
return $this->fetch_all_stat($ids, $force_from_db, $null);
}
}
public function fetch_all_stat($begin, $end, $field = '*') {
$data = array();
$query = DB::query('SELECT %i FROM %t WHERE daytime>=%d AND daytime<=%d ORDER BY daytime', array($field, $this->_table, $begin, $end));
while($value = DB::fetch($query)) {
$data[$value['daytime']] = $value;
}
return $data;
}
public function fetch_all_by_daytime($daytime, $start = 0, $limit = 0, $sort = 'ASC') {
$wheresql = '';
$parameter = array($this->_table);
if($daytime) {
$wheresql = 'WHERE daytime>=%d';
$parameter[] = $daytime;
}
return DB::fetch_all("SELECT * FROM %t $wheresql ORDER BY daytime $sort".DB::limit($start, $limit), $parameter);
}
}
?>

View File

@@ -0,0 +1,44 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_statuser.php 27449 2012-02-01 05:32:35Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_statuser extends discuz_table
{
public function __construct() {
$this->_table = 'common_statuser';
$this->_pk = '';
parent::__construct();
}
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;
}
}
public function clear_by_daytime($daytime) {
$daytime = intval($daytime);
DB::delete('common_statuser', "`daytime` != '$daytime'");
}
}
?>

View File

@@ -0,0 +1,52 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_style.php 29200 2012-03-28 09:11:54Z monkey $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_style extends discuz_table
{
public function __construct() {
$this->_table = 'common_style';
$this->_pk = 'styleid';
parent::__construct();
}
public function fetch_all_data($withtemplate = false, $available = false) {
if($withtemplate) {
$available = $available !== false ? 'WHERE s.available='.intval($available) : '';
return DB::fetch_all('SELECT s.*, t.name AS tplname, t.directory, t.copyright FROM %t s LEFT JOIN %t t ON t.templateid=s.templateid %i ORDER BY s.styleid ASC', array($this->_table, 'common_template', $available));
} else {
$available = $available !== false ? 'WHERE available='.intval($available) : '';
return DB::fetch_all('SELECT * FROM %t %i', array($this->_table, $available));
}
}
public function fetch_by_styleid($styleid) {
return DB::fetch_first("SELECT s.*, t.name AS tplname, t.directory, t.copyright FROM %t s LEFT JOIN %t t ON s.templateid=t.templateid WHERE s.styleid=%d", array($this->_table, 'common_template', $styleid));
}
public function check_stylename($stylename) {
return DB::result_first("SELECT COUNT(*) FROM %t WHERE name=%s", array($this->_table, $stylename));
}
public function fetch_by_stylename_templateid($stylename, $templateid = 0) {
if($templateid) {
return DB::fetch_first("SELECT * FROM %t WHERE name=%s AND templateid=%d ORDER BY styleid ASC LIMIT 1", array($this->_table, $stylename, $templateid));
}else{
return DB::fetch_first("SELECT * FROM %t WHERE name=%s ORDER BY styleid ASC LIMIT 1", array($this->_table, $stylename));
}
}
}
?>

View File

@@ -0,0 +1,52 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_stylevar.php 28934 2012-03-20 04:00:22Z chenmengshu $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_stylevar extends discuz_table
{
public function __construct() {
$this->_table = 'common_stylevar';
$this->_pk = 'stylevarid';
parent::__construct();
}
public function fetch_all_by_styleid($styleid, $available = false) {
if($available !== false) {
return DB::fetch_all("SELECT sv.* FROM %t sv INNER JOIN %t s ON s.styleid = sv.styleid AND (s.available=%d OR s.styleid=%d)", array($this->_table, 'common_style', $available, $styleid));
} else {
return DB::fetch_all("SELECT * FROM %t WHERE styleid=%d", array($this->_table, $styleid));
}
}
public function check_duplicate($styleid, $variable) {
return DB::result_first("SELECT COUNT(*) FROM %t WHERE styleid=%d AND variable=%s", array($this->_table, $styleid, $variable));
}
public function update_substitute_by_styleid($substitute, $id, $stylevarids = array()) {
if(!is_string($substitute) || !$id) {
return;
}
DB::update($this->_table, array('substitute' => $substitute), ($stylevarids ? DB::field('stylevarid', $stylevarids).' AND ' : '').DB::field('styleid', $id));
}
public function delete_by_styleid($id, $stylevarids = array()) {
if(!$id) {
return;
}
DB::delete($this->_table,($stylevarids ? DB::field('stylevarid', $stylevarids).' AND ' : '').DB::field('styleid', $id));
}
}
?>

View File

@@ -0,0 +1,184 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_syscache.php 31119 2012-07-18 04:21:20Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_syscache extends discuz_table
{
private $_isfilecache;
public function __construct() {
$this->_table = 'common_syscache';
$this->_pk = 'cname';
$this->_pre_cache_key = '';
$this->_isfilecache = getglobal('config/cache/type') == 'file';
$this->_allowmem = memory('check');
parent::__construct();
}
public function fetch($id, $force_from_db = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::fetch($id, $force_from_db);
} else {
return $this->fetch_syscache($id);
}
}
public function fetch_all($ids, $force_from_db = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::fetch_all($ids, $force_from_db);
} else {
return $this->fetch_all_syscache($ids);
}
}
public function insert($data, $return_insert_id = false, $replace = false, $silent = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::insert($data, $return_insert_id, $replace, $silent);
} else {
return $this->insert_syscache($data, $return_insert_id);
}
}
public function update($val, $data, $unbuffered = false, $low_priority = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::update($val, $data, $unbuffered, $low_priority);
} else {
return $this->update_syscache($val, $data);
}
}
public function delete($val, $unbuffered = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::delete($val, $unbuffered);
} else {
return $this->delete_syscache($val);
}
}
public function fetch_syscache($cachename) {
$data = $this->fetch_all_syscache(array($cachename));
return isset($data[$cachename]) ? $data[$cachename] : false;
}
public function fetch_all_syscache($cachenames) {
$data = array();
$cachenames = is_array($cachenames) ? $cachenames : array($cachenames);
if ($this->_allowmem) {
if (($index = array_search('setting', $cachenames)) !== FALSE) {
if (memory('exists', 'setting')) {
unset($cachenames[$index]);
$settings = new memory_setting_array();
}
}
$data = memory('get', $cachenames);
if (isset($settings)) {
$data['setting'] = $settings;
}
$newarray = $data !== false ? array_diff($cachenames, array_keys($data)) : $cachenames;
if (empty($newarray)) {
return $data;
} else {
$cachenames = $newarray;
}
}
if($this->_isfilecache) {
$lostcaches = array();
foreach($cachenames as $cachename) {
if(!@include_once(DISCUZ_ROOT.'./data/cache/cache_'.$cachename.'.php')) {
$lostcaches[] = $cachename;
} elseif($this->_allowmem) {
$cachename === 'setting' ? memory_setting_array::save($data[$cachename]) : memory('set', $cachename, $data[$cachename]);
}
}
if(!$lostcaches) {
return $data;
}
$cachenames = $lostcaches;
unset($lostcaches);
}
$query = DB::query('SELECT * FROM '.DB::table($this->_table).' WHERE '.DB::field('cname', $cachenames));
while($syscache = DB::fetch($query)) {
$data[$syscache['cname']] = $syscache['ctype'] ? dunserialize($syscache['data']) : $syscache['data'];
if ($this->_allowmem) {
if ($syscache['cname'] === 'setting') {
memory_setting_array::save($data[$syscache['cname']]);
} else {
memory('set', $syscache['cname'], $data[$syscache['cname']]);
}
}
if($this->_isfilecache) {
$cachedata = '$data[\''.$syscache['cname'].'\'] = '.var_export($data[$syscache['cname']], true).";\n\n";
$cachedata_save = "<?php\n//Discuz! cache file, DO NOT modify me!\n//Identify: ".md5($syscache['cname'].$cachedata.getglobal('config/security/authkey'))."\n\n$cachedata?>";
$fp = fopen(DISCUZ_ROOT.'./data/cache/cache_'.$syscache['cname'].'.php', 'cb');
if(!($fp && flock($fp, LOCK_EX) && ftruncate($fp, 0) && fwrite($fp, $cachedata_save) && fflush($fp) && flock($fp, LOCK_UN) && fclose($fp))) {
flock($fp, LOCK_UN);
fclose($fp);
unlink(DISCUZ_ROOT.'./data/cache/cache_'.$syscache['cname'].'.php');
}
}
}
foreach($cachenames as $name) {
if(!isset($data[$name]) || $data[$name] === null) {
$data[$name] = null;
$this->_allowmem && (memory('set', $name, array()));
}
}
return $data;
}
public function insert_syscache($cachename, $data) {
parent::insert(array(
'cname' => $cachename,
'ctype' => is_array($data) ? 1 : 0,
'dateline' => TIMESTAMP,
'data' => is_array($data) ? serialize($data) : $data,
), false, true);
if ($this->_allowmem && memory('exists', $cachename) !== false) {
if ($cachename === 'setting') {
memory_setting_array::save($data);
} else {
memory('set', $cachename, $data);
}
}
$this->_isfilecache && @unlink(DISCUZ_ROOT.'./data/cache/cache_'.$cachename.'.php');
}
public function update_syscache($cachename, $data) {
$this->insert_syscache($cachename, $data);
}
public function delete_syscache($cachenames) {
parent::delete($cachenames);
if($this->_allowmem || $this->_isfilecache) {
foreach((array)$cachenames as $cachename) {
$this->_allowmem && memory('rm', $cachename);
$this->_isfilecache && @unlink(DISCUZ_ROOT.'./data/cache/cache_'.$cachename.'.php');
}
}
}
}
?>

View File

@@ -0,0 +1,99 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_tag.php 36284 2016-12-12 00:47:50Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_tag extends discuz_table
{
public function __construct() {
$this->_table = 'common_tag';
$this->_pk = 'tagid';
parent::__construct();
}
public function fetch_all_by_status($status = NUll, $tagname = '', $startlimit = 0, $count = 0, $returncount = 0, $order = '') {
if($status === NULL) {
$statussql = 'status<>3';
} else {
$statussql = 'status='.intval($status);
}
$data = array($this->_table);
if($tagname) {
$namesql = " AND tagname LIKE %s";
$data[] = '%'.$tagname.'%';
}
if($returncount) {
return DB::result_first("SELECT count(*) FROM %t WHERE $statussql $namesql", $data);
}
return DB::fetch_all("SELECT * FROM %t WHERE $statussql $namesql ORDER BY ".DB::order('tagid', $order)." ".DB::limit($startlimit, $count), $data);
}
public function insert($data, $return_insert_id = false, $replace = false, $silent = false) {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::insert($data, $return_insert_id, $replace, $silent);
} else {
$return_insert_id = $return_insert_id === false ? 0 : $return_insert_id;
return $this->insert_tag($data, $return_insert_id);
}
}
public function insert_tag($tagname, $status = 0) {
DB::query('INSERT INTO %t (tagname, status) VALUES (%s, %d)', array($this->_table, $tagname, $status));
return DB::insert_id();
}
public function get_byids($ids) {
if(empty($ids)) {
return array();
}
if(!is_array($ids)) {
$ids = array($ids);
}
return DB::fetch_all('SELECT * FROM %t WHERE tagid IN (%n)', array($this->_table, $ids), 'tagid');
}
public function get_bytagname($tagname, $type) {
if(empty($tagname)) {
return array();
}
$statussql = $type != 'uid' ? ' AND status<\'3\'' : ' AND status=\'3\'';
return DB::fetch_first('SELECT * FROM %t WHERE tagname=%s '.$statussql, array($this->_table, $tagname));
}
public function fetch_info($tagid, $tagname = '') {
if(empty($tagid) && empty($tagname)) {
return array();
}
$addsql = $sqlglue = '';
if($tagid) {
$addsql = " tagid=".intval($tagid);
$sqlglue = ' AND ';
}
if($tagname) {
$addsql .= $sqlglue.' '.DB::field('tagname', $tagname);
}
return DB::fetch_first("SELECT tagid,tagname,status FROM ".DB::table('common_tag')." WHERE $addsql");
}
public function delete_byids($ids) {
if(empty($ids)) {
return false;
}
if(!is_array($ids)) {
$ids = array($ids);
}
return DB::query('DELETE FROM %t WHERE tagid IN (%n)', array($this->_table, $ids));
}
}
?>

View File

@@ -0,0 +1,104 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_tagitem.php 27769 2012-02-14 06:29:36Z liulanbo $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_tagitem extends discuz_table
{
public function __construct() {
$this->_table = 'common_tagitem';
$this->_pk = '';
parent::__construct();
}
public function replace($tagid, $itemid, $idtype) {
return DB::query('REPLACE INTO %t (tagid, itemid, idtype) VALUES (%d, %d, %s)', array($this->_table, $tagid, $itemid, $idtype));
}
public function select($tagid = 0, $itemid = 0, $idtype = '', $orderfield = '', $ordertype = 'DESC', $limit = 0, $count = 0, $itemidglue = '=', $returnnum = 0) {
$data = $this->make_where($tagid, $itemid, $idtype, $itemidglue);
$ordersql = $limitsql = '';
if($orderfield) {
$ordersql = ' ORDER BY '.DB::order($orderfield, $ordertype);
}
if($limit || $count) {
$limitsql = DB::limit($limit, $count);
}
if($data) {
if($returnnum) {
return DB::result_first('SELECT count(*) FROM %t WHERE '.$data['where'], $data['data']);
}
return DB::fetch_all('SELECT * FROM %t WHERE '.$data['where'].$ordersql.$limitsql, $data['data']);
} else {
return false;
}
}
public function delete($val, $unbuffered = false, $null = '') {
if (defined('DISCUZ_DEPRECATED')) {
throw new Exception('NotImplementedException');
return parent::delete($val, $unbuffered);
} else {
$unbuffered = $unbuffered === false ? 0 : $unbuffered;
return $this->delete_tagitem($val, $unbuffered, $null);
}
}
public function delete_tagitem($tagid = 0, $itemid = 0, $idtype = '') {
$data = $this->make_where($tagid, $itemid, $idtype);
if($data) {
return DB::query('DELETE FROM %t WHERE '.$data['where'], $data['data']);
} else {
return false;
}
}
private function make_where($tagid = 0, $itemid = 0, $idtype = '', $itemidglue = '=') {
$wheresql = ' 1';
$data = array();
$data['data'][] = $this->_table;
if($tagid) {
$wheresql .= !is_array($tagid) ? " AND tagid=%d" : " AND tagid IN (%n)";
$data['data'][] = $tagid;
}
if($itemid) {
$wheresql .= !is_array($itemid) ? " AND ".DB::field('itemid', $itemid, $itemidglue) : " AND ".DB::field('itemid', $itemid);
}
if($idtype) {
$wheresql .= " AND idtype=%s";
$data['data'][] = $idtype;
}
if($wheresql == ' 1') {
return false;
}
$data['where'] = $wheresql;
return $data;
}
public function unique($tagid, $itemid, $idtype) {
DB::query('DELETE FROM %t WHERE tagid<>%d AND itemid=%d AND idtype=%s', array($this->_table, $tagid, $itemid, $idtype));
}
public function merge_by_tagids($newid, $tagidarray) {
if(!is_array($tagidarray)) {
$tagidarray = array($tagidarray);
}
DB::query('UPDATE %t SET tagid=%d WHERE tagid IN (%n)', array($this->_table, $newid, $tagidarray));
}
public function count_by_tagid($tagid) {
return DB::result_first("SELECT count(*) FROM ".DB::table('common_tagitem')." WHERE tagid='".intval($tagid)."'");
}
}
?>

View File

@@ -0,0 +1,100 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: table_common_task.php 27777 2012-02-14 07:07:26Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class table_common_task extends discuz_table
{
public function __construct() {
$this->_table = 'common_task';
$this->_pk = 'taskid';
parent::__construct();
}
public function fetch_all_by_available($available) {
return DB::fetch_all("SELECT * FROM %t WHERE available=%d", array($this->_table, $available), $this->_pk);
}
public function fetch_all_data() {
return DB::fetch_all("SELECT * FROM %t ORDER BY displayorder, taskid DESC", array($this->_table));
}
public function count_by_scriptname($scriptname) {
return DB::result_first("SELECT COUNT(*) FROM %t WHERE scriptname=%s", array($this->_table, $scriptname));
}
public function fetch_all_by_scriptname($scriptname) {
return DB::fetch_all("SELECT * FROM %t WHERE scriptname=%s", array($this->_table, $scriptname));
}
public function update_by_scriptname($scriptname, $data) {
if(!$data || !is_array($data)) {
return;
}
DB::update($this->_table, $data, DB::field('scriptname', $scriptname));
}
public function update_applicants($taskid, $v) {
DB::query("UPDATE %t SET applicants=applicants+%s WHERE taskid=%d", array($this->_table, $v, $taskid));
}
public function update_achievers($taskid, $v) {
return DB::query("UPDATE %t SET achievers=achievers+%s WHERE taskid=%d", array($this->_table, $v, $taskid));
}
public function update_available($available = 2) {
if($available == 2) {
DB::query("UPDATE %t SET available='2' WHERE available='1' AND starttime<=%d AND (endtime='0' OR endtime>%d)", array($this->_table, TIMESTAMP, TIMESTAMP), false, true);
} else {
DB::query("UPDATE %t SET available='1' WHERE available='2' AND (starttime>%d || (endtime<=%d && endtime>'0'))", array($this->_table, TIMESTAMP, TIMESTAMP), false, true);
}
}
public function fetch_next_starttime() {
return DB::result_first("SELECT starttime FROM %t WHERE available='1' AND starttime>'0' AND (endtime='0' OR endtime>%d) ORDER BY starttime ASC", array($this->_table, TIMESTAMP, TIMESTAMP));
}
public function fetch_next_endtime() {
return DB::result_first("SELECT endtime FROM %t WHERE available='2' AND endtime>'0' ORDER BY endtime ASC", array($this->_table));
}
public function fetch_all_by_status($uid, $status) {
switch($status) {
case 'doing':
$status = "mt.status='0'";
break;
case 'done':
$status = "mt.status='1'";
break;
case 'failed':
$status = "mt.status='-1'";
break;
case 'canapply':
case 'new':
default:
$status = "'".TIMESTAMP."' > starttime AND (endtime=0 OR endtime>'".TIMESTAMP."') AND (mt.taskid IS NULL OR (ABS(mt.status)='1' AND t.period>0))";
break;
}
return DB::fetch_all("SELECT t.*, mt.csc, mt.dateline FROM %t t
LEFT JOIN %t mt ON mt.taskid=t.taskid AND mt.uid=%d
WHERE %i AND t.available='2' ORDER BY t.displayorder, t.taskid DESC", array($this->_table, 'common_mytask', $uid, $status));
}
public function fetch_by_uid($uid, $taskid) {
return DB::fetch_first("SELECT t.*, mt.dateline, mt.dateline AS applytime, mt.status, mt.csc FROM %t t LEFT JOIN %t mt ON mt.uid=%d AND mt.taskid=t.taskid
WHERE t.taskid=%d AND t.available='2'", array($this->_table, 'common_mytask', $uid, $taskid));
}
}
?>

Some files were not shown because too many files have changed in this diff Show More