forked from IvanHanloth/Easy-Send
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cron.php
32 lines (32 loc) · 1006 Bytes
/
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
<?php
/*
By Ivan Hanloth
本文件为易传数据监控文件
2022/4/4
*/
require "config.php";
$db = mysqli_connect($dbpath, $dbaccount, $dbpassword, $dbname);
if (mysqli_connect_errno($db)){
echo "连接 MySQL 失败: " . mysqli_connect_error();
};
$now=time();
$num=mysqli_query($db,"SELECT * FROM `data`");
$num=mysqli_num_rows($num);
$result=mysqli_query($db,"SELECT * FROM `data` ORDER BY `id`");
$result=mysqli_fetch_all($result,MYSQLI_BOTH);
for($i=0;$i<=$num;$i++){
if($result[$i]["tillday"]<=$now){
if($result[$i]["type"]==1){
$delete_file=unlink($result[$i]["path"]);
if($delete_file==TRUE){
mysqli_query($db,"DELETE FROM `{$dbname}`.`data` WHERE `data`.`id`='{$result[$i]['id']}'");
}else{
echo"Wrong";
};
}elseif($result[$i]["type"]==2){
mysqli_query($db,"DELETE FROM `{$dbname}`.`data` WHERE `data`.`id`='{$result[$i]['id']}'");
}
};
};
echo "Finish";
?>