f (!empty($uidarr)) {
$uids = array();
$update = array();
foreach ($uidarr as $_uid => $n) {
$uids[] = $_uid;
$update[$_uid] = array('articles-' => $n);
'mysql' != $conf['cache']['type'] and cache_delete('user-' . $_uid);
}
user_big_update(array('uid' => $uids), $update);
}
!empty($operate_create) && function_exists('operate_big_insert') and operate_big_insert($operate_create);
return TRUE;
}
// 大数据量容易超时 删除用户时使用,删除主题 回复 栏目统计 附件 全站统计
function well_thread_delete_all_by_uid($uid)
{
// 用户主题数
$user = user_read_cache($uid);
set_time_limit(0);
// 删除所有回复
if ($user['comments']) {
$postist = comment_pid_find_by_uid($uid, 1, $user['comments'], FALSE);
$pidarr = array();
foreach ($postist as $val) {
$pidarr[] = $val['pid'];
}
unset($postist);
!empty($pidarr) and comment_delete_by_pids($pidarr);
}
if ($user['articles']) {
// 如果主题、附件和回复数量太大会超时
$tidlist = thread_tid_find_by_uid($uid, 1, $user['articles'], FALSE, 'tid', array('tid'));
$tidarr = array();
foreach ($tidlist as $val) {
$tidarr[] = $val['tid'];
}
unset($tidlist);
!empty($tidarr) and well_thread_delete_all($tidarr);
}
return TRUE;
}
// 搜索标题
function well_thread_find_by_keyword($keyword, $d = NULL)
{
if (empty($keyword)) return NULL;
$db = $_SERVER['db'];
$d = $d ? $d : $db;
if (!$d) return FALSE;
$threadlist = db_sql_find("SELECT * FROM `{$d->tablepre}website_thread` WHERE subject LIKE '%$keyword%' LIMIT 60;", 'tid', $d);
if ($threadlist) {
$threadlist = arrlist_multisort($threadlist, 'tid', FALSE);
foreach ($threadlist as &$thread) {
well_thread_format($thread);
// 关键词标色
//$thread['subject'] = comment_highlight_keyword($thread['subject'], $keyword);
}
}
return $threadlist;
}
// 查找 最后评论 lastpid
function well_thread_find_lastpid($tid)
{
$arr = comment_pid_read(array('tid' => $tid), array('pid' => -1), array('pid'));
$lastpid = empty($arr) ? 0 : $arr['pid'];
return $lastpid;
}
// 更新最后的 uid
function well_thread_update_last($tid)
{
if (empty($tid)) return FALSE;
$lastpid = well_thread_find_lastpid($tid);
if (empty($lastpid)) return FALSE;
$lastpost = comment_read($lastpid);
if (empty($lastpost)) return FALSE;
$r = well_thread_update($tid, array('lastuid' => $lastpost['uid']));
return $r;
}
function well_thread_maxid()
{
$n = db_maxid('website_thread', 'tid');
return $n;
}
// 主题状态 0:通过 1~9 审核:1待审核 10~19:10退稿 11逻辑删除
function well_thread_format(&$thread)
{
global $gid, $uid, $forumlist;
$conf = _SERVER('conf');
if (empty($thread)) return;
$thread['create_date_fmt'] = humandate($thread['create_date']);
$thread['last_date_fmt'] = humandate($thread['last_date']);
$thread['create_date_fmt_ymd'] = date('Y-m-d', $thread['create_date']);
$thread['last_date_fmt_ymd'] = date('Y-m-d', $thread['last_date']);
$user = user_read_cache($thread['uid']);
$onlinelist = online_user_list_cache();
$user['online_status'] = isset($onlinelist[$user['uid']]) ? 1 : 0;
$thread['username'] = $user['username'];
$thread['user_avatar_url'] = array_value($user, 'avatar_url');
$thread['user'] = user_safe_info($user);
unset($user);
$forum = array_value($forumlist, $thread['fid']);
$thread['forum_name'] = array_value($forum, 'name');
$thread['forum_url'] = array_value($forum, 'url');
if ($thread['last_date'] == $thread['create_date']) {
$thread['last_date_fmt'] = '';
$thread['lastuid'] = 0;
$thread['lastusername'] = '';
} else {
$lastuser = $thread['lastuid'] ? user_read_cache($thread['lastuid']) : array();
$thread['lastusername'] = $thread['lastuid'] ? $lastuser['username'] : lang('guest');
$thread['lastuser'] = $thread['lastuid'] ? user_safe_info($lastuser) : array();
unset($lastuser);
}
$thread['url'] = url('read-' . $thread['tid'], '', FALSE);
if ($conf['url_rewrite_on'] > 1) {
!empty($forum['well_alias']) and $thread['url'] = url(urlencode($forum['well_alias'])."-$thread[create_date]a$thread[tid]", '', FALSE);
} else {
$thread['url'] = url("read-$thread[create_date]a$thread[tid]", '', FALSE);
}
$thread['user_url'] = url('user-' . $thread['uid']);
$thread['sticky_class'] = '';
if ($thread['sticky'] > 0) {
if (1 == $thread['sticky']) {
$thread['sticky_class'] = 'success';
} elseif (2 == $thread['sticky']) {
$thread['sticky_class'] = 'warning';
} elseif (3 == $thread['sticky']) {
$thread['sticky_class'] = 'danger';
}
}
$nopic = view_path() . 'img/nopic.png';
if ($thread['icon']) {
$attach_dir_save_rule = array_value($conf, 'attach_dir_save_rule', 'Ym');
$day = date($attach_dir_save_rule, $thread['icon']);
$thread_format_icon_default = 1;
if (1 == $thread_format_icon_default) {
// 本地文件绝对路径
$destfile = $conf['upload_path'] . 'thumbnail/' . $day . '/' . $thread['uid'] . '_' . $thread['tid'] . '_' . $thread['icon'] . '.jpeg';
// 本地
$thread['icon_fmt'] = is_file($destfile) ? file_path($thread['attach_on']) . 'thumbnail/' . $day . '/' . $thread['uid'] . '_' . $thread['tid'] . '_' . $thread['icon'] . '.jpeg' : $nopic;
if (1 == $conf['attach_on'] && 1 == $thread['attach_on']) {
// 云储存
$thread['icon_fmt'] = file_path($thread['attach_on']) . 'thumbnail/' . $day . '/' . $thread['uid'] . '_' . $thread['tid'] . '_' . $thread['icon'] . '.jpeg';
} elseif (2 == $conf['attach_on'] && 2 == $thread['attach_on']) {
// 图床 未上传成功 本地图片在的话使用本地,不在则默认
$thread['icon_fmt'] = $thread['image_url'] ? $thread['image_url'] : $thread['icon_fmt'];
}
}
} else {
$thread['icon_fmt'] = $nopic;
}
// 回复页面
$thread['pages'] = ceil($thread['posts'] / $conf['comment_pagesize']);
$thread['tag_fmt'] = $thread['tag'] ? xn_json_decode($thread['tag']) : '';
// 权限判断
$thread['allowupdate'] = ($uid == $thread['uid']) || forum_access_mod($thread['fid'], $gid, 'allowupdate');
$thread['allowdelete'] = (group_access($gid, 'allowuserdelete') and $uid == $thread['uid']) || forum_access_mod($thread['fid'], $gid, 'allowdelete');
$thread['allowtop'] = forum_access_mod($thread['fid'], $gid, 'allowtop');
$thread = well_thread_safe_info($thread);
}
function well_thread_format_last_date(&$thread)
{
if ($thread['last_date'] != $thread['create_date']) {
$thread['last_date_fmt'] = humandate($thread['last_date']);
} else {
$thread['create_date_fmt'] = humandate($thread['create_date']);
}
}
// 对 $threadlist 权限过滤
function well_thread_list_access_filter(&$threadlist, $gid)
{
global $forumlist;
if (empty($threadlist)) return NULL;
foreach ($threadlist as $tid => $thread) {
if (empty($forumlist[$thread['fid']]['accesson'])) continue;
if ($thread['sticky'] > 0) continue;
if (!forum_access_user($thread['fid'], $gid, 'allowread')) {
unset($threadlist[$tid]);
}
}
}
function well_thread_safe_info($thread)
{
unset($thread['userip'], $thread['user']['threads'], $thread['user']['posts'], $thread['user']['credits'], $thread['user']['golds'], $thread['user']['money']);
empty($thread['user']) || $thread['user'] = user_safe_info($thread['user']);
return $thread;
}
// 过滤安全数据
function well_thread_filter(&$val)
{
unset($val['userip'], $val['fid'], $val['flagid'], $val['type'], $val['user'], $val['create_date']);
}
//------------------------ 其他方法 ------------------------
// 集合主题tid,统一拉取,避免多次查询thread表
function thread_unified_pull($arr)
{
global $gid, $fid;
$stickylist = array_value($arr, 'stickylist', array());
$tidlist = array_value($arr, 'tidlist', array());
//$fid = array_value($arr, 'fid');
// 合并过滤空数组
//$tidlist = array_filter($stickylist + $tidlist);
$tidarrlist = $tidlist = $stickylist + $tidlist;
// 版块自定义
list($flaglist, $flagtids) = flag_thread_by_fid($fid);
empty($flagtids) || $tidarrlist += $flagtids;
unset($flagtids);
// 在这之前合并所有二维数组 tid值为键/array('tid值' => tid值)
$tidarr = empty($tidarrlist) ? array() : arrlist_values($tidarrlist, 'tid');
// 在这之前使用array_merge()前合并所有一维数组 tid/array(1,2,3)
if (empty($tidarr)) return NULL;
$tidarr = array_unique($tidarr);
// 主题相关统一遍历后再归类
$arrlist = well_thread_find($tidarr, count($tidarr));
// 过滤没有权限访问的主题 / filter no permission thread
well_thread_list_access_filter($arrlist, $gid);
$threadlist = array();
foreach ($arrlist as $_tid => &$_thread) {
$_thread = well_thread_safe_info($_thread);
// 归类列表数据
isset($tidlist[$_thread['tid']]) and $threadlist[$_tid] = $_thread;
// flag thread
if (!empty($flaglist)) {
foreach ($flaglist as $key => $val) {
if (isset($val['tids']) && in_array($_thread['tid'], $val['tids'])) {
$flaglist[$key]['list'][array_search($_thread['tid'], $val['tids'])] = $_thread;
ksort($flaglist[$key]['list']);
}
}
}
}
// 按之前tidlist排序
$threadlist = array2_sort_key($threadlist, $tidlist, 'tid');
unset($arrlist, $tidlist);
$arr = array('threadlist' => $threadlist, 'flaglist' => $flaglist);
return $arr;
}
// read.php 详情页其他主题调用,集合tid统一拉取数据,最后归类
function thread_other_pull($thread)
{
global $forumlist, $gid;
$fid = array_value($thread, 'fid');
$forum = array_value($forumlist, $fid);
if (empty($forum)) return NULL;
//$tid = array_value($thread, 'tid');
//$tag_fmt = array_value($thread, 'tag_fmt');
$arrlist = array();
$tidlist = array();
// 版块自定义
list($flaglist, $flagtids) = flag_thread_by_fid($fid);
empty($flagtids) || $tidlist += $flagtids;
unset($flagtids);
// 在这之前合并所有二维数组 tid值为键/array('tid值' => tid值)
$tidarr = empty($tidlist) ? array() : arrlist_values($tidlist, 'tid');
// 在这之前使用array_merge()前合并所有一维数组 tid/array(1,2,3)
if (empty($tidarr)) return NULL;
$tidarr = array_unique($tidarr);
// 主题相关统一遍历后再归类
$threadlist = well_thread_find($tidarr, count($tidarr));
// 过滤没有权限访问的主题 / filter no permission thread
well_thread_list_access_filter($threadlist, $gid);
foreach ($threadlist as &$_thread) {
$_thread = well_thread_safe_info($_thread);
// flag thread
if (!empty($flaglist)) {
foreach ($flaglist as $key => $val) {
if (isset($val['tids']) && in_array($_thread['tid'], $val['tids'])) {
$flaglist[$key]['list'][array_search($_thread['tid'], $val['tids'])] = $_thread;
ksort($flaglist[$key]['list']);
}
}
}
}
unset($threadlist);
if (!empty($flaglist)) {
foreach ($flaglist as &$val) {
$i = 0;
if (!isset($val['list'])) continue;
foreach ($val['list'] as &$v) {
++$i;
$v['i'] = $i;
}
}
$arrlist['flaglist'] = $flaglist;
unset($flaglist);
}
return $arrlist;
}
//--------------------------cache--------------------------
// 已格式化 从缓存中读取,避免重复从数据库取数据
function well_thread_read_cache($tid)
{
global $conf;
$key = 'website_thread_' . $tid;
static $cache = array(); // 用静态变量只能在当前 request 生命周期缓存,跨进程需要再加一层缓存:redis/memcached/xcache/apc
if (isset($cache[$key])) return $cache[$key];
if ('mysql' == $conf['cache']['type']) {
$r = well_thread_read($tid);
} else {
$r = cache_get($key);
if (NULL === $r) {
$r = well_thread_read($tid);
$r and cache_set($key, $r, 1800);
}
}
$cache[$key] = $r ? $r : NULL;
return $cache[$key];
}
?>
福州电脑网_福州电脑维修_福州电脑之家_福州iThome
双击噩梦?试试这款让鼠标重新听话的秘密武器
5天前550
告别混乱点击!三步搞定让鼠标由双击转回单击的操作指南
用鼠标点击一次却出现点击两次的效果,每次鼠标出现这样情况,都严重影响到正常使用,怎么办? 鼠标单击变成了双击的原因很多: 1、鼠标坏了:鼠标的微动开关出现问题。鼠标摁键都有设计寿命,因为经常击打,很多时候会造成微动开关
5天前530
掌握CST:电路监视专家之路,电流到GPU提速全程指导
1. 电流监视器基础与设置步骤 电流监视器是CST电磁仿真中监测导体电流分布的核心工具,它通过磁场积分原理实现非接触式电流测量。与电压监视器不同,电流监视器需要闭合路径才能完成安培环路积分,这种设计使其特别适合分析天线辐射电流
5天前530
CST软件中的A求解器电场监控实战 - 从入门到精通全攻略
作者 | Wang Yuanteng 通常,我们在微波工作室中可以直接设置monitor观察电场或磁场在整个计算空间的场分布情况。但当使用A求解器时,我们会发现直接设置的E-field monitor好像不起作用了。因
5天前510
玩转 FDTD 技能包:源监视器和 TE 运用技巧详解
adddipole : 添加偶极子光源addplane : 添加平面波 addindex : 添加折射率监视器addmovie :添加电影监视器addpower : 添加功率监视器
5天前520
轻松玩转SAP警报体系:设置阈值及4.x警报监视器使用技巧
SAP系统警报监控阈值设置与4.x警报监视器使用指南 1. 警报阈值设置概述 在SAP系统中,合理设置警报阈值对于系统的稳定运行至关重要。不同类型的警报阈值涵盖了文件系统、性能、系统日志、缓冲区以及其他系统组件等多个方
5天前530
如何在CST软件里搞定电流监视器?
在时域求解器中,可以设置电流监视器来得到电流值。首先在模型中创建一条曲线(curve),再基于这条曲线定义电流监视器;需要注意的是目前仅支持为时域计算定义电流监视器。 电流监视器通过沿定义的曲线路径对磁场H进行积分
5天前550
Win2003中的多重显示器设置秘籍,提升工作效率
随着计算机技术的发展,多屏幕设置在工作和娱乐中越来越受欢迎。Windows操作系统提供了强大的多重监视器支持,使用户能够同时使用多个显示器来扩展工作区域或增强视觉体验。本文将介绍如何在Windows系统中配置和管理多重监视器,并提供相
5天前500
Windows磁盘空间不足了咋办?用性能监视器设置告警吧!
Windows性能监视器自定义警报阈值设置指南一、性能监视器警报设置基础Windows性能监视器(PerfMon)是系统内置的强大性能监控工具,支持通过自定义警报来监控系统资源使用情况。以下是基本设置步骤:
5天前530
打造个性化浏览体验:浏览器监视器高级设置指南
19.浏览器监视器高级设置 MON-SYN-220_Browser Monitor Advanced SetupAdvanced setup options allow you to fine tune the b
5天前480
Adobe Flash Player迷踪:从入门到精通的电压监视器攻略
在CST软件时域求解器中,可以设置电压监视器来得到电压值。首先在模型中创建一条曲线(curve),再基于这条曲线定义电压监视器(Voltage Monitor);需要注意的是目前仅支持为时域计算定义电压监视器。 电压监视器通过
5天前510
从菜鸟到高手:解锁监视器选项卡的强大功能
第十八章 使用系统监视器 - 设置系统监视器选项 设置系统监视器选项 要更改全局系统监视器设置或将它们恢复为默认值,请停止系统监视器(如果它正在运行),然后在主菜单中输入 2: 1)SetSa
5天前540
一文搞定CST电磁仿真监视器:从设置到优化全解析
使用场源功能 提取和调用Near Field Source! Simulation > Sources and Loads > Field Source 对安装在汽车或飞机等大型平台的天线而言,天线相
5天前510
解锁电路监视器潜力:电流监测与GPU提速全面解析
1. 电流监视器基础与设置步骤 电流监视器是CST电磁仿真中监测导体电流分布的核心工具,它通过磁场积分原理实现非接触式电流测量。与电压监视器不同,电流监视器需要闭合路径才能完成安培环路积分,这种设计使其特别适合分析天线辐射电流
5天前520
CST与A求解器联用,掌握电场监视技巧
作者 | Wang Yuanteng 通常,我们在微波工作室中可以直接设置monitor观察电场或磁场在整个计算空间的场分布情况。但当使用A求解器时,我们会发现直接设置的E-field monitor好像不起作用了。因
5天前540
驾驭FDTD:如何在SWF世界中利用监视器和TE工具
adddipole : 添加偶极子光源addplane : 添加平面波 addindex : 添加折射率监视器addmovie :添加电影监视器addpower : 添加功率监视器
5天前530
实战案例:从新手到大师,探索SAP 52阈值设置与4.x监视器使用指南
SAP系统警报监控阈值设置与4.x警报监视器使用指南 1. 警报阈值设置概述 在SAP系统中,合理设置警报阈值对于系统的稳定运行至关重要。不同类型的警报阈值涵盖了文件系统、性能、系统日志、缓冲区以及其他系统组件等多个方
5天前520
CST电磁仿真监视器入门教程:让操作流程一目了然
使用场源功能 提取和调用Near Field Source! Simulation > Sources and Loads > Field Source 对安装在汽车或飞机等大型平台的天线而言,天线相
5天前500
想要随时开机用,教你搞定Win10笔记本的自动关机问题!
引子 本系列一共三篇文章,之所以放在一起是因为大家可能对自己电脑出现的睡眠、休眠、无法唤醒、自动关机等描述的不清楚或者有误解。 本文章仅供参考,不承担任何责任! 请阅读这个引子,然后选择合适的文章查看解
5天前540
开机瞬间卡壳:笔记本自动关机循环启动,应急方案速递!
现象 笔记本按了开关键之后,电源指示灯亮,硬盘开始运转几秒后卡住然后关机自动重启并不断重复上述现象. 重启期间并没有进到bios并且笔记本屏幕不亮. 初步怀疑是磁盘坏了. 可能原因磁盘坏了 电源
5天前530