-
Notifications
You must be signed in to change notification settings - Fork 56
/
cron.php
80 lines (74 loc) · 1.99 KB
/
cron.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/*
By Ivan Hanloth
Easy-Send
Github:https://github.com/IvanHanloth/Easy-Send
Gitee:https://gitee.com/IvanHanloth/Easy-Send
2022/10/16
*/
include dirname(__FILE__)."/./common.php";
/*
定期删除过期文件
*/
$now=time();
$result=mysqli_query($db,"SELECT * FROM `data` ORDER BY `id`");
$result=mysqli_fetch_all($result,MYSQLI_BOTH);
$success=0;
$faile=0;
$total=0;
foreach($result as $data){
$total++;
if(strtotime($data["tillday"])<=$now){
$res=delete_data_by_id($data["id"]);
if($res){
$success++;
}else{
$faile++;
}
};
};
echo "Totally checked ".$total." data , deleted ".$success." data , failed ".$faile." times";
/*
定期删除房间
*/
$result=mysqli_query($db,"SELECT * FROM `room` ORDER BY `rid`");
$result=mysqli_fetch_all($result,MYSQLI_BOTH);
$success=0;
$faile=0;
$total=0;
foreach($result as $data){
$total++;
for($i=1;$i<3;$i++){
session_write_close();
if($i==1){
$type="send";
}elseif($i==2){
$type="receive";
}
session_id($data[$type]);
session_start();
if($_SESSION["roomtype".$data["rid"]]!=$type or !isset($_SESSION["roomtype".$data["rid"]])){
$my_stmt=$db->prepare("UPDATE `room` SET `{$type}`='',`state`='waiting' WHERE `rid`=? ");
$my_stmt->bind_param("s",$data['rid']);
$my_stmt->execute();
$my_stmt->close();
}
session_write_close();
};
if($data["state"]=="finish" and $data["receive"]==""){
$res=delete_roomdata($data["rid"],true);
$success++;
}
if($data["send"]=="" and $data["receive"]==""){
$res=delete_roomdata($data["rid"],true);
$success++;
}
if($data['starttime']!=""){
if($data['starttime']+3600*24<=$now){
$res=delete_roomdata($data["rid"],true);
$success++;
}
}
};
echo "<br>Totally checked ".$total." rooms , deleted ".$success." rooms , failed ".$faile." times";
?>