-
Notifications
You must be signed in to change notification settings - Fork 5
/
clear.php
45 lines (45 loc) · 1.21 KB
/
clear.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
<?php
$stime=microtime(true);
if(file_exists("config.php")) {
require "config.php";
} else {
define("storage",dirname(__FILE__)."/storage/");
define("chatfile","chat.log");
define("history",dirname(__FILE__)."/history/");
define("password","admin");
};
if(!defined("storage")){
define("storage",dirname(__FILE__)."/storage/");
};
if(!defined("chatfile")){
define("chatfile","chat.log");
};
if(!defined("history")){
define("history",dirname(__FILE__)."/history/");
};
if(!defined("password")){
define("password","admin");
};
if(!file_exists(storage.''.chatfile)) {
$etime=microtime(true);
$totaltime=$etime-$stime;
echo "File does not exist, needn't to operate.</br>Total time: ".$totaltime."s.";
exit;
};
$time = time();
$filename = "chat_".$time.".log";
if($_GET['password'] == password) {
rename(storage.''.chatfile,$filename);
copy($filename,history.$filename);
unlink($filename);
file_put_contents(storage.''.chatfile, "");
$etime=microtime(true);
$totaltime=$etime-$stime;
echo "Success.</br>Total time: ".$totaltime."s.";
} else {
$etime=microtime(true);
$totaltime=$etime-$stime;
echo "Password not match.</br>Total time: ".$totaltime."s.";
exit;
};
?>