This repository was archived by the owner on Feb 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverCheck.php
More file actions
108 lines (104 loc) · 3.04 KB
/
serverCheck.php
File metadata and controls
108 lines (104 loc) · 3.04 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
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
include("inc/ys_protocol.php");
//include("inc/queue.php");
//DEBUG ON!!!!! AND DELAY=1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
function ys_params ($ip, $port, $timeout=1, $sf, $ver=20110207)
{
log2("start: ".$ip.":".$port." version: ".$sf->version,"access_");
$timer1 = new Timer("serverCheck_".$ip);
$sff = new Serversf();// is a back-up
$delay = time() - ($sf->timestamp);
$sf->setIsOnline("Pending");
$sf->setTimestamp(); // so that a second client doesn't send a query to the same server while the first is running its querry.
$sf->write();
/*if (can_go())
{
take_lock($ip.":".$port);
echo $ip.":".$port." true"; */
$ys=new YS_protocol(true); //true: Your host enables fsockopen() false: Your host disabled it, but allows sockets
//$ys->setDebug(true);// true: display the debug messages
$ys->setVersion($sf->version);
//echo "VERSION ".$ys->version."<br>";
$state = $ys->YSconnect($ip, $port, $timeout);
$sf->setVersion ($ys->version);
log2("end: ".$ip.":".$port." state: ".$state." version: ".$ys->version,"access_");
if ($state == "Online")
{
$sf->setOpenedLast();
if ($ys->getIsLaggy())
{
$sf->setIsOnline("Laggy");
}
else
{
$ys->packetDecode();
//echo "<br>VERSION: ".$ys->version."<br>";
$sf->setMissile ($ys->missile);
$sf->setWeapon ($ys->weapon);
$show = $ys->showUser;
$radar = $ys->radar;
$radar = $ys->extview;
$sf->setMap ($ys->map);
$a = $ys->userlist;
$sf->setUsera ($a);
if (count($a) >= 0)
{
$sf->users = $ys->users; //($a[count($a)-2]);//
$sf->flying = $ys->flying; //($a[count($a)-1]);
log2("<name>".$sf->serverName."</name> <ip>".$sf->ip."</ip> <port>".$sf->port."</port> <users>".$sf->users."</users> <flying>".$sf->flying."</flying>","stats_");
$sf->setPopularity($delay);
//log2($ip." set pop");
$sf->setWeather ($ys->weather);
$sf->setIsOnline("Online");
$sf->setOpenTime($delay);
$sf->radar = $ys->radar;
$sf->extview = $ys->extview;
$sf->showUser = $ys->showUser;
//$ys->YSdisconnect();
}
if ($ys->getIsLaggy())
{
$sff->readf($sf->fileName);
$sf->setOpenedLast();
$sff->setIsOnline("Laggy2");
}
}
}
else
{
$sf->setIsOnline($state);
if ($state != "Offline")
{
$sf->setOpenTime($delay);
$sf->setOpenedLast();
}
elseif ($state == "Offline")
{
$sf->setFlying(0);
$sf->setUsers(0);
if ($sf->delOnExit == 1)
{
@unlink("servers/".$ip."_".$port.".txt");
@unlink("servers/".$ip."_".$port.".txt.flock");
journal ('<p> <img src="im/del_server.png" width="20" height="20" border="1"> '.date("d").' - The server '.$sf->serverName.' was deleted because it came offline.</p>');
}
}
}
$sf->setTimestamp();
if (($sf->delOnExit == 0)||($state != "Offline"))
$sf->write();
//release_lock();
/*}
else
{
echo $ip.":".$port." false\n";
$sw = new SafeWriter;
$lock = $sw->readData("queue_lock.txt");
echo $lock[0];
echo "\n";
echo $lock[0]=="";
echo "\n";
}*/
$timer1->stop();
}
?>