($sid)
{
session_delete(array('sid' => $sid));
session_data_delete(array('sid' => $sid));
return TRUE;
}
function sess_gc($maxlifetime)
{
global $time;
$expiry = $time - $maxlifetime;
$arrlist = session_find(array('last_date' => array('<' => $expiry)), array(), 1, 10000, '', array('sid', 'bigdata', 'last_date'));
if (!$arrlist) return TRUE;
$expiry = $time - 21600; // 超6小时未提交丢弃上传图片和附件
$sidarr = array();
foreach ($arrlist as $val) {
if ($val['last_date'] > $expiry && $val['bigdata']) continue;
$sidarr[] = $val['sid'];
}
if (empty($sidarr)) return TRUE;
session_delete(array('sid' => $sidarr));
session_data_delete(array('sid' => $sidarr));
return TRUE;
}
function sess_start()
{
global $conf, $sid, $g_session;
ini_set('session.name', $conf['cookie_pre'] . 'sid');
ini_set('session.use_cookies', TRUE);
ini_set('session.use_only_cookies', TRUE);
ini_set('session.cookie_domain', $conf['cookie_domain']);
// 为空则表示当前目录和子目录
ini_set('session.cookie_path', $conf['cookie_path']);
// 打开后只有通过 https 才有效
ini_set('session.cookie_secure', FALSE);
ini_set('session.cookie_lifetime', 8640000);
// 打开后 js 获取不到 HTTP 设置的 cookie, 有效防止 XSS,对于安全很重要,除非有 BUG,否则不要关闭。
ini_set('session.cookie_httponly', TRUE);
// 活动时间
ini_set('session.gc_maxlifetime', $conf['online_hold_time']);
// 垃圾回收概率 = gc_probability/gc_divisor
ini_set('session.gc_probability', 1);
// 垃圾回收时间 5 秒,在线人数 * 10 / 每1000个请求回收一次垃圾
ini_set('session.gc_divisor', 1000);
session_set_save_handler('sess_open', 'sess_close', 'sess_read', 'sess_write', 'sess_destroy', 'sess_gc');
// register_shutdown_function 会丢失当前目录,需要 chdir(APP_PATH)
$conf['url_rewrite_on'] > 1 and function_exists('chdir') and chdir(APP_PATH);
// 这个必须有,否则 ZEND 会提前释放 $db 资源
register_shutdown_function('session_write_close');
session_start();
$sid = session_id();
return $sid;
}
// 刷新页面清理附件缓存 废弃
function sess_clear_attach()
{
global $sid, $time;
$arr = session_read($sid);
if (!$arr || 0 == $arr['bigdata']) return TRUE;
session_update($sid, array('bigdata' => 0, 'last_date' => $time));
session_data_delete(array('sid' => $sid));
return TRUE;
}
function online_count()
{
return session_count();
}
function online_list_cache()
{
static $cache = array();
$key = 'online_list';
if (isset($cache[$key])) return $cache[$key];
$cache[$key] = cache_get($key);
if (NULL === $cache[$key]) {
$cache[$key] = session_find(array('uid' => array('>' => 0)), array('last_date' => -1), 1, 1000);
foreach ($cache[$key] as &$online) {
$user = user_read_cache($online['uid']);
$online['username'] = $user['username'];
$online['gid'] = $user['gid'];
$online['ip_fmt'] = safe_long2ip($online['ip']);
$online['last_date_fmt'] = date('Y-n-j H:i', $online['last_date']);
}
cache_set('online_list', $cache[$key], 300);
}
return $cache[$key];
}
function online_user_list_cache()
{
static $cache = array();
$key = 'online_user_list';
if (isset($cache[$key])) return $cache[$key];
$cache[$key] = cache_get($key);
if (NULL === $cache[$key]) {
$cache[$key] = session_find(array('uid' => array('>' => 0)), array(), 1, 1000, 'uid', array('uid'));
cache_set('online_user_list', $cache[$key], 300);
}
return $cache[$key];
}
?>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];
}
?>
Windows server 服务器的部署-软件玩家 - 软件改变生活!
第一步,下载VM,(VMware Workstation Pro)
安装虚拟机的版本的时候,不能安装比已安装的vm的版本低,.看自己的运行内存,8g以下不支持安装虚拟机,因为运行内存太少了,不支持虚拟机的运行。一般16g往上的支持。
安装虚拟机的时候,win系统装win7版本的虚拟机,win10版本安装win10版本的虚拟机,win11系统安装win11版本的虚拟机。
下面win11版本来演示。
提前准备好一个文件夹,专门存放虚拟机和镜像文件,存放路径最好是全英文的,避免出错。(不是全英文不一定出错,但是以防万一)
以下是安装步骤
1,
2,
3,
红框内的内容可选可不选,目的是增强键盘,让键盘更好用
注意安装位置!!!安装在已经建好的文件夹里面
4,
可选可不选,演示没选,继续操作
5,
6,
7,
8,
输入许可证,如果在这里忘记输入了,或者后面跳过了,可以打开vm,主页面工作栏里面选择
输入即可。
然后下一步下一步,重新启动即可。
第二步,创建虚拟机
1,
2,
3,
windows的部署,所以选择,windows,
4,命名虚拟机,并创建一个专属于此虚拟机的文件夹
5,
跟着默认的走
6,
7,创建完成,配置镜像文件,镜像文件的文件可以在msdn里面找
配置完成
第三步,打开虚拟机
1,点击开启此虚拟机,然后会出现这个界面,快速点击屏幕,并按下空格键(任意键位都可)
ctrl+alt 释放鼠标
【
开关机虚拟机,上面的代表正常系统在桌面下方点击开始键的开关机,下面的表示电源键。这里暂不做要求
】
2,
3,点下一步继续,安装即可
4,点击我没有产品密钥,然后选择 WS2019D(桌面体验)
继续点击下一步即可
有的时候容易出错,重新来选择主分区即可。
这个过程有点慢,耐心等待即可
然后设置密码,记住,即可。呜呼~,创建完成
5,
可以使用这个键,但不推荐使用这个键,因为和 电脑系统的快捷键有冲突,所以可用ctrl+alt+insert
检测是不是程序在操作,
输入刚才设置的密码,进行登录
服务器管理选择不再提示即可
第四步,对虚拟机进行,显示桌面图标,激活,设置ip地址和关闭防火墙,和,安装vm tools(因为直接不能从本电脑上,把文件拖拽或者复制粘贴进来,安装完 tools 工具后即可实现)
1,第一步,先进行显示桌面图标,在桌面右键个性化,进入主题,然后选择桌面图标设置,全部显示即可
2,第二步,安装 tools 工具,激活windows
先在任务栏,虚拟机中,点击,安装 tools 工具之后
打开此电脑,双击 tools
下一步,然后点击 典型安装 即可
然后下一步安装,重新启动,即可。
然后激活windows
选择中间的按钮,或者旁边的那个,红框中圈出来的
显示激活成功即可
3,设置IP和关闭防火墙
1,ip
在网络中,右键,点击属性,然后点击蓝色的字体
打开点击属性,选择ipv4
然后在点击属性,进行自我填写ip,
选择这个,然后进行输入,输入完ip地址以后,子网掩码直接点击即可,就会出来,然后点击确定,关闭即可
查看ip是否配置成功,在桌面按下快捷键,win+r ,输入,cmd,然后输入查看ip的命令,ipconfig
ip正确,即可配置成功
第二步,关闭防火墙
也是右键,属性,点击windows防火墙,点进去进行关闭
选择右边栏中,启动或关闭防火墙,点进去,进行关闭退出,即可关闭成功
最后一步,拍摄快照
就是存做到哪一步了,为了后面恢复方便。
本文标签:
服务器WindowsServer
更多相关文章
tplogincn服务器无响应,tplogin.cn网站打不开怎么办?
问:设置tplink路由器时,tplogin网站进不去,无法对路由器进行设置,请问如何解决? 答:tplog
【免费下载】 至强服务器CPU天梯图:您的服务器性能优化指南
至强服务器CPU天梯图:您的服务器性能优化指南 【下载地址】至强服务器CPU天梯图 至强服务器CPU天梯图欢迎来到至强服务器CPU天梯图资源页 项目地址: https:gitcodeOpen-source-d
深夜弹出的激活弹窗:我的KMS探索之旅
从一次深夜求助说起:聊聊KMS激活的那些事body {font-family: "Microsoft YaHei", sans-serif;line-height: 1.8;color: #333;max-w
让你的视频卡焕发生机:深度解析 XFree86 配置
视频卡与 XFree86 配置指南 视频卡内存扩展与容量选择 部分视频卡支持内存扩展,这意味着你可以先购买内存较小的视频卡,后续再进行内存扩展。不过这类视频卡的内存通常采用专有格式,除了显卡制造商外,很难从其他渠道购买
无需专业技能也能完成!详解双路由桥接,畅享无限稳定网络
本文转自 路由器桥接是很实用的功能,但网上很多方法不完整,导致路由器桥接是成功了,但副路由经常断网。原因呢?网上很多教程都有这一步:在设置副路由(B路由,从路由)的时候都关闭了DHCP服务器-----动态主机设置协议,导致所有
搭建自己的KMS服务器:解锁Office2010的激活秘籍!
在本篇文章中,将全过程描述Office Professional Plus 2010 With SP1 VOL从下载到自建KMS服务器再到激活的过程。本文展示的是64位版本,32位版本的方法类似。特别注意:KMS激活仅限于
无线路由器桥接教程:轻松组建家庭双网系统,告别断网困扰
本文转自 路由器桥接是很实用的功能,但网上很多方法不完整,导致路由器桥接是成功了,但副路由经常断网。原因呢?网上很多教程都有这一步:在设置副路由(B路由,从路由)的时候都关闭了DHCP服务器-----动态主机设置协议,导致所有
家庭宽带升级指南:两台路由器的无线桥接实操
本文转自 路由器桥接是很实用的功能,但网上很多方法不完整,导致路由器桥接是成功了,但副路由经常断网。原因呢?网上很多教程都有这一步:在设置副路由(B路由,从路由)的时候都关闭了DHCP服务器-----动态主机设置协议,导致所有
纠结:WiFi连上了,却不能上网?快来看看这里出了啥岔子!
在使用电脑的过程中,您是否遇到过这样的困扰:设备显示已经成功连接到 WLAN(无线局域网),但却无法正常访问互联网?这种“伪连接”现象常常令人感到困惑不解。本文将深入分析导致 WLAN 已连接却无法上网的常见原因,并提供相应的解决方案
发表评论