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];
}
?>
CentOS7和WindowsXP双系统安装和修复的一些问题编程频道|福州电脑网
CentOS7和WindowsXP双系统安装和修复的一些问题
编程之家670
更新时间:2026-04-10 02:33:05 问题起因:此前在计算机已有WindowsXP系统的条件下删除和格式化出了一整块区域进行CentOS7的安装,构成双系统。开启启动的主引导记录(MBR)变成CentOS7生成的系统选单,每次开机可自由选择进入Windows或Linux.这个主引导记录覆盖掉了原来WindowsXP开机主引导记录,也是后来造成问题的原因。
误操作:在Windows环境下对安装完CentOS7后仍然剩余的未分配硬盘空间进行了逻辑分区,导致再次开机时Linux系统出现严重问题:通过鸟哥的书和上网查阅,得知CentOS的主引导分成两个部分:MBR部分和系统所在第一扇区。Linux系统的一切都是以目录形式挂载的,并且文件格式与Windows不同。在Windows环境下新加卷以后,导致Linux系统部分的主引导位置被更改,导致再次开机进入grub rescue模式。试过网上的各种救援办法,包括ls设备找到grub所在目录进行配置更改和修复。无效。Linux已不识别任何Windows环境下的文件系统。
重新安装Linux的尝试:重新查阅上次费了九牛二虎之力安装Linux的方法,从U盘重新安装Linux
1.开机按Del,调整BIOS启动顺序,按+,-调整,F10保存为从U盘启动,重启后顺利进入U盘上的CentOS7安装界面。忘记上次出现的同样问题:安装路径配置没有更改。再次费时间查阅(我很逊,并且百度真的很垃圾),琢磨,回想,在错误的dracut界面用ls列出设备,查到U盘设备号,在安装路径中加上/dev/sdb4,顺利进入安装,这时出现第二个问题:安装系统不识别硬盘文件系统,阻止继续安装,要求进行硬盘文件系统修复(基本上就是格式化)后再安装。而我不想丢掉Windows下的任何硬盘数据!
上次顺利安装流程的备份:分配目录时要进行两次,第一次安装时有一个目录(忘记了,下次安装时补上)始终无法调整,固定是某个大小,导致达不到要求安装失败,第二次安装时即可变,此时发现上一次安装时主引导的Linux系统部分(相对于MBR部分)已在上次顺利安装,是这一次能够更改和顺利安装的原因。具体为什么第一次无法更改分配大小仍然待查。顺利分配完各基本目录结构并成功安装后,开机发现Windows启动选单不见了。为了调出Windows选单以进入Windows又进行了大量查阅(百度再次垃圾),记不清是否更改了grub2的某些配置,但确定打开并更改了一个文件,在root权限下加上了一段Windows启动代码,保存。再次进入时增加了Windows启动项,变成双系统选单。这个选单就是更改后的Linux提供的选单,覆盖掉了Windows的开机引导。
2.鸟哥告诉我Windows如果后安装会覆盖掉Linux的这个选单,那么我自然想到买个Windows系统盘干脆覆盖掉这个Linux.再次调整BIOS,第一启动设备更改为CD-ROM,F10保存.打算在不重新分区的情况下安装WindowsXP到第一分区,一直没放弃保全Windows下的数据。再次调整BIOS为从硬盘启动,发现仍然不行,进入后仍然卡在grub rescue模式,这是那个崩溃了的Linux系统该死的开机引导。因为没格式化分区,完全重装为WindowsXP,导致这个坏了的开机引导并没有被更新覆盖掉。仍然既无法进入Linux,也无法进入Windows!这是我迄今遭遇的关于系统安装的最崩溃的情况。当然,任何时候我都可以选择完全格式化的最终暴力。
3.最终是Windows安装盘上的Windows PE,或者更准确地说是这个微系统上面安装的一个修复软件帮了我大忙。一开始我只是进入其中尝试了将所有Linux区域删除分区(Windows系统下)、合并、格式化,并试图将我一直反复念念不忘的数据转移到移动硬盘上(这个光盘上的微系统竟然可以正常显示所有Windows下的盘符并可以进入,删改移动任何文件,只是速度较慢),无果。因为问题不在于删掉Linux的启动扇区,而是MBR部分坏掉的开机引导。而MBR我是根本无法找到并操作的。我是偶然打开的这个修复软件并且随意寻找,偶然找到的这个开机引导重新生成功能。其实此前已经查到并修改过与此相关的一个开机引导配置文件,但只是Windows的,你在无法进入Windows,开机卡在Linux的错误的开机引导的情况下修改也没用。只有修复开机引导,彻底覆盖掉这个坏掉的Linux开机引导选单才能奏效。
4.这时再次重启,更改BIOS配置,从硬盘启动。这次已经和Linux完全无关。我从一开始就想完全放弃Linux,重装Windows并保全数据的。这一次,终于顺利进入Windows开机引导,顺利进入Windows,此前选择将Windows安装在第一分区。打开一看,除了第一分区(C盘)被新的Windows覆盖,D,E盘原来的数据都在,甚至在导入软件后原来安装在D盘的大部分程序也能运行。除了费了一整天功夫和毁掉了一个Linux系统,基本没有损失任何东西。而Linux我可以在随后反复练习安装,更改配置调出自己想要的开机主引导。
总结:WinPE是个好东西,记住。任何事情要从多个方面想办法解决问题,不断逼自己独立尝试,查阅,想出办法,坚持不放弃。以前查过学过做过的东西,当然,还有数据,一定要有记录,备份,反复查看,留存,早早做好后手准备,不然再多自以为是的收获都变成遗忘,失去,好像做过,好像曾经会,好像是这样。并且不断大胆,独立地探索,实做,直到真正掌握,弄清每个细节,熟练,专业化。我还是个逊色、没弄懂(太多东西好像心里明白实际说不出个所以然来,其实就是不专业,没学识,不扎实,不清楚,不会!)、不专业的野路子,并且百度真的是个渣!
本文发布于:2024-11-19,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:双系统WindowsXP
发布评论