179 lines
6.2 KiB
PHP
179 lines
6.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* This is NOT a freeware, use is subject to license terms
|
|
* 应用名称: 贴吧楼中楼回复 9.0
|
|
* 下载地址: https://addon.dismall.com/plugins/replyfloor.html
|
|
* 应用开发者: 乘凉
|
|
* 开发者QQ: 594433766
|
|
* 更新日期: 202505310549
|
|
* 授权域名: www.shitangsweet.com
|
|
* 授权码: 2025053105b89RrI3R9n
|
|
* 未经应用程序开发者/所有者的书面许可,不得进行反向工程、反向汇编、反向编译等,不得擅自复制、修改、链接、转载、汇编、发表、出版、发展与之有关的衍生产品、作品等
|
|
*/
|
|
|
|
|
|
/**
|
|
* $author: 乘凉 $
|
|
*/
|
|
|
|
if(!defined('IN_DISCUZ')) {
|
|
exit('Access Denied');
|
|
}
|
|
|
|
class table_replyfloor_message extends discuz_table {
|
|
|
|
public function __construct() {
|
|
$this->_table = 'plugin_replyfloor_message';
|
|
$this->_pk = 'id';
|
|
|
|
parent::__construct();
|
|
}
|
|
|
|
public function count_by_search_where($wherearr) {
|
|
$wheresql = empty($wherearr) ? '' : implode(' AND ', $wherearr);
|
|
return DB::result_first('SELECT COUNT(*) FROM '.DB::table($this->_table).($wheresql ? ' WHERE '.$wheresql : ''));
|
|
}
|
|
|
|
public function count_by_authorid($authorid) {
|
|
return DB::result_first('SELECT COUNT(*) FROM %t WHERE uid=%d', array($this->_table, $authorid));
|
|
}
|
|
|
|
public function fetch_all_by_search_where($wherearr, $ordersql = '', $start = 0, $limit = 0) {
|
|
$wheresql = empty($wherearr) ? '' : implode(' AND ', $wherearr);
|
|
return DB::fetch_all('SELECT * FROM '.DB::table($this->_table).($wheresql ? ' WHERE '.$wheresql : '').' '.$ordersql.DB::limit($start, $limit), null, 'id');
|
|
}
|
|
|
|
public function fetch_by_id($id) {
|
|
return DB::fetch_first('SELECT * FROM %t WHERE id=%d', array($this->_table, $id));
|
|
}
|
|
|
|
public function fetch_all_by_id($ids, $ordersql = '') {
|
|
if(($ids = dintval((array)$ids, true))) {
|
|
return DB::fetch_all('SELECT * FROM %t WHERE id IN(%n) '.$ordersql, array($this->_table, $ids), false, true);
|
|
}
|
|
}
|
|
|
|
public function fetch_message_by_pid($pids, $perpage, $ordersql = '', $setconfig = array()) {
|
|
global $_G;
|
|
$date_convert = $_G['setting']['dateconvert'];
|
|
$_G['setting']['dateconvert'] = $setconfig['date_convert'];
|
|
$wherearr = array();
|
|
if($_G['uid']){
|
|
$wherearr[] = "(status = '0' or (status = '-1' and uid = '".$_G['uid']."'))";
|
|
}else{
|
|
$wherearr[] = "status = '0'";
|
|
}
|
|
$wherearr[] = DB::field('pid', $pids, 'in');
|
|
$wheresql = empty($wherearr) ? '' : implode(' AND ', $wherearr);
|
|
$query = DB::query("SELECT * FROM ".DB::table($this->_table).($wheresql ? ' WHERE '.$wheresql : '').' '.$ordersql);
|
|
$messageinfo = $messagecount = $messagelist = array();
|
|
require_once libfile('function/common', 'plugin/replyfloor');
|
|
$uids = array();
|
|
while($message = DB::fetch($query)) {
|
|
$messagecount[$message['pid']]++;
|
|
if(!isset($messagelist[$message['pid']])) {
|
|
$messagelist[$message['pid']] = array();
|
|
}
|
|
if(count($messagelist[$message['pid']]) < $perpage) {
|
|
$message['avatar'] = avatar($message['uid'], 'small');
|
|
$message['message'] = replyfloor_discuzcode($message['message']);
|
|
if(file_exists(DISCUZ_ROOT.'./source/plugin/replyfloor/extend/extend_hidenum.php')){
|
|
require_once libfile('extend/hidenum', 'plugin/replyfloor');
|
|
$message['message'] = replyfloor_extend_hidenum($message['message']);
|
|
}
|
|
if($setconfig['show_br']) {
|
|
$message['message'] = nl2br($message['message']);
|
|
}
|
|
if($setconfig['show_location']) {
|
|
$message['location'] = replyfloor_location($message['postip']);
|
|
}else{
|
|
$message['location'] = '';
|
|
}
|
|
$message['createtime'] = $setconfig['date_convert'] ? dgmdate($message['createtime'], 'u', 9999, $setconfig['time_format']) : dgmdate($message['createtime'], $setconfig['time_format']);
|
|
$messagelist[$message['pid']][] = $message;
|
|
$uids[] = $message['uid'];
|
|
if($message['ruid']){
|
|
$uids[] = $message['ruid'];
|
|
}
|
|
}
|
|
$messageinfo[$message['pid']]['count'] = $messagecount[$message['pid']];
|
|
$messageinfo[$message['pid']]['list'] = $messagelist[$message['pid']];
|
|
}
|
|
if($uids) {
|
|
loadcache('usergroups');
|
|
foreach(C::t('common_member')->fetch_all($uids) as $uid => $postuser) {
|
|
foreach ($messageinfo as $key => $value) {
|
|
foreach ($value['list'] as $k => $val) {
|
|
if($val['uid'] == $uid) {
|
|
$val['groupcolor'] = $_G['cache']['usergroups'][$postuser['groupid']]['color'];
|
|
}
|
|
if($val['ruid'] == $uid) {
|
|
$val['rgroupcolor'] = $_G['cache']['usergroups'][$postuser['groupid']]['color'];
|
|
}
|
|
$messageinfo[$key]['list'][$k] = $val;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$_G['setting']['dateconvert'] = $date_convert;
|
|
return $messageinfo;
|
|
}
|
|
|
|
public function update_by_id($id, $data) {
|
|
if(($id = dintval($id, true)) && $data && is_array($data)) {
|
|
DB::update($this->_table, $data, DB::field($this->_pk, $id), true);
|
|
}
|
|
}
|
|
|
|
public function update_reportnum($id, $num = 1) {
|
|
return DB::query('UPDATE %t SET reportnum = reportnum + \'%d\' WHERE id = %d', array($this->_table, $num, $id));
|
|
}
|
|
|
|
public function restore_by_id($ids) {
|
|
if(($ids = dintval((array)$ids, true))) {
|
|
DB::update($this->_table, array('status'=>0), DB::field('id', $ids, 'in'), true);
|
|
}
|
|
}
|
|
|
|
public function delete_by_id($ids, $recycle = 0) {
|
|
if(($ids = dintval((array)$ids, true))) {
|
|
if($recycle) {
|
|
DB::update($this->_table, array('status'=>1), DB::field('id', $ids, 'in'), true);
|
|
}else{
|
|
DB::query('DELETE FROM %t WHERE id IN(%n)', array($this->_table, $ids), false, true);
|
|
}
|
|
}
|
|
}
|
|
|
|
public function delete_by_pid($ids, $recycle = 0) {
|
|
if(($ids = dintval((array)$ids, true))) {
|
|
if($recycle) {
|
|
DB::update($this->_table, array('status'=>1), DB::field('pid', $ids, 'in'), true);
|
|
}else{
|
|
DB::query('DELETE FROM %t WHERE pid IN(%n)', array($this->_table, $ids), false, true);
|
|
}
|
|
}
|
|
}
|
|
|
|
public function delete_by_tid($ids, $recycle = 0) {
|
|
if(($ids = dintval((array)$ids, true))) {
|
|
if($recycle) {
|
|
DB::update($this->_table, array('status'=>1), DB::field('tid', $ids, 'in'), true);
|
|
}else{
|
|
DB::query('DELETE FROM %t WHERE tid IN(%n)', array($this->_table, $ids), false, true);
|
|
}
|
|
}
|
|
}
|
|
|
|
public function delete_by_authorid($ids, $recycle = 0) {
|
|
if(($ids = dintval((array)$ids, true))) {
|
|
if($recycle) {
|
|
DB::update($this->_table, array('status'=>1), DB::field('uid', $ids, 'in'), true);
|
|
}else{
|
|
DB::query('DELETE FROM %t WHERE uid IN(%n)', array($this->_table, $ids), false, true);
|
|
}
|
|
}
|
|
}
|
|
|
|
} |