-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathwrite.php
More file actions
95 lines (95 loc) · 2.71 KB
/
write.php
File metadata and controls
95 lines (95 loc) · 2.71 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
$stime=microtime(true);
if(file_exists("config.php")) {
require "config.php";
} else {
define("storage",dirname(__FILE__)."/storage/");
define("chatfile","chat.log");
define("linkchar1","&");
define("linkchar2","'says'");
define("wpassword","admin");
define("password","admin");
};
if(!defined("storage")){
define("storage",dirname(__FILE__)."/storage/");
};
if(!defined("chatfile")){
define("chatfile","chat.log");
};
if(!defined("linkchar1")){
define("linkchar1","&");
};
if(!defined("linkchar2")){
define("linkchar2","'says'");
};
if(!defined("wpassword")){
define("wpassword","admin");
};
if(!defined("password")){
define("password","admin");
};
if($_GET['password'] == wpassword) {
try{
date_default_timezone_set('PRC');
if (getenv('HTTP_CLIENT_IP')) {
$ip = getenv('HTTP_CLIENT_IP');
} elseif (getenv('HTTP_X_FORWARDED_FOR')) {
$ip = getenv('HTTP_X_FORWARDED_FOR');
} elseif (getenv('HTTP_X_FORWARDED')) {
$ip = getenv('HTTP_X_FORWARDED');
} elseif (getenv('HTTP_FORWARDED_FOR')) {
$ip = getenv('HTTP_FORWARDED_FOR');
} elseif (getenv('HTTP_FORWARDED')) {
$ip = getenv('HTTP_FORWARDED');
} elseif (getenv('REMOTE_ADDR')) {
$ip = getenv('REMOTE_ADDR');
} elseif (!empty($_SERVER['REMOTE_ADDR'])) {
$ip = $_SERVER['REMOTE_ADDR'];
} else {
$ip = "Unknown";
};
if (empty($_GET['message'])){
$etime=microtime(true);
$totaltime=$etime-$stime;
echo "Message empty.</br>Total time: ".$totaltime."s.";
exit;
};
if ($_GET['admin'] != password) {
if (mb_strlen($_GET['message'], 'UTF-8')>64){
$etime=microtime(true);
$totaltime=$etime-$stime;
echo "Message is too long.</br>Total time: ".$totaltime."s.";
exit;
};
};
$get = $_GET['message'];
if (empty($_GET['username'])){
$etime=microtime(true);
$totaltime=$etime-$stime;
echo "User Name empty.</br>Total time: ".$totaltime."s.";
exit;
};
$un = $_GET['username'];
$time = date('H:i',time());
$timehidden = date('Y-m-d H:i:s',time());
if(file_exists(storage.''.chatfile)) {
$myfile = fopen(storage.''.chatfile, "a") or die("Unable to open file!");
fwrite($myfile,$ip . "+" . $timehidden . "" . linkchar1 . "[".$time."] [" . $un . "] " .linkchar2 . "" . $get . "\r\n");
fclose($myfile);
} else {
file_put_contents(storage.''.chatfile, $ip . "+" . $timehidden . "" . linkchar1 . "[".$time."] [" . $un . "] " .linkchar2 . "" . $get . "\r\n");
};
$etime=microtime(true);
$totaltime=$etime-$stime;
echo "Success.</br>Total time: ".$totaltime."s.";
}catch(Exception $e){
echo $e->getMessage();
exit();
}
} else {
$etime=microtime(true);
$totaltime=$etime-$stime;
echo "Password not match.</br>Total time: ".$totaltime."s.";
exit;
};
?>