在房间内离线超过24小时 清理出房间
This commit is contained in:
@@ -18,12 +18,34 @@ class DaySeconds
|
|||||||
echo "清除房间热度值:\n";
|
echo "清除房间热度值:\n";
|
||||||
$this->clear_room_today_hot_value();//0点以后房间热度值清零
|
$this->clear_room_today_hot_value();//0点以后房间热度值清零
|
||||||
echo "\n";
|
echo "\n";
|
||||||
|
|
||||||
|
echo "清除房间离线超24小时的用户:\n";
|
||||||
|
$this->clear_room_offline_user();//0点以后清除房间离线超24小时用户
|
||||||
|
echo "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 0点以后清除房间离线超24小时用户
|
||||||
|
* 配置:定时脚本每天 0点 执行
|
||||||
|
* 配置:
|
||||||
|
*/
|
||||||
|
public function clear_room_offline_user() {
|
||||||
|
$room = db::name('vs_room_visitor')->where(['is_online' => 2])->select();
|
||||||
|
if($room){
|
||||||
|
foreach ($room as $value) {
|
||||||
|
$time = time() - $value['updatetime'];
|
||||||
|
if($time > 86400){
|
||||||
|
model('api/Room')->quit_room($value['user_id'], $value['room_id'],$value['user_id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 0点以后房间热度值清零
|
* 0点以后房间热度值清零
|
||||||
* 配置:定时脚本每天 0点 执行
|
* 配置:定时脚本每天 0点 执行
|
||||||
* 配置:http://vschat.qxmier.com/api/Cron/DaySeconds
|
* 配置:
|
||||||
*/
|
*/
|
||||||
public function clear_room_today_hot_value() {
|
public function clear_room_today_hot_value() {
|
||||||
$where = [];
|
$where = [];
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class RoomPan
|
|||||||
if($is_online['is_online'] == 2){//之前就是离开
|
if($is_online['is_online'] == 2){//之前就是离开
|
||||||
continue;
|
continue;
|
||||||
}else{//之前就是在线则改为离开
|
}else{//之前就是在线则改为离开
|
||||||
db::name('vs_room_visitor')->where('id',$is_online['id'])->update(['is_online'=>2]);
|
db::name('vs_room_visitor')->where('id',$is_online['id'])->update(['is_online'=>2,'updatetime'=>time()]);
|
||||||
db::name('user')->where('id',$value['user_id'])->update(['is_online'=>2]);
|
db::name('user')->where('id',$value['user_id'])->update(['is_online'=>2]);
|
||||||
$text['text'] = '离开';
|
$text['text'] = '离开';
|
||||||
$text['user_id'] = $value['user_id'];
|
$text['user_id'] = $value['user_id'];
|
||||||
@@ -59,7 +59,7 @@ class RoomPan
|
|||||||
if($is_online['is_online'] == 1){//之前就是在线
|
if($is_online['is_online'] == 1){//之前就是在线
|
||||||
continue;
|
continue;
|
||||||
}else{//之前就是离开则改为在线
|
}else{//之前就是离开则改为在线
|
||||||
db::name('vs_room_visitor')->where('id',$is_online['id'])->update(['is_online'=>1]);
|
db::name('vs_room_visitor')->where('id',$is_online['id'])->update(['is_online'=>1,'updatetime' => time()]);
|
||||||
db::name('user')->where('id',$value['user_id'])->update(['is_online'=>1]);
|
db::name('user')->where('id',$value['user_id'])->update(['is_online'=>1]);
|
||||||
$text['text'] = '回到房间';
|
$text['text'] = '回到房间';
|
||||||
$text['user_id'] = $value['user_id'];
|
$text['user_id'] = $value['user_id'];
|
||||||
|
|||||||
Reference in New Issue
Block a user