mohaa-server-stats

Gesponsorde koppelingen

PHP script bestanden

  1. mohaa-server-stats

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
if (!$server) {
$server_ip = "0.0.0.0";   // ik typte gewoon wat in
$server_port = "12243"; // ik typte gewoon wat in
} else {
$server = explode(":", $server);
$server_ip = $server[0];
$server_port = $server[1];
}

// Do NOT change anything below this line!

// Creating the URL for the connection:


$server_ip = "udp://" . $server_ip;

// Open the connection:
$connect = fsockopen($server_ip, $server_port, $errno, $errstr, 30);

// Set the timeout:
socket_set_timeout ($connect, 1, 000000);

// Get the information from the server, and put it into the $output array:

$send = "ÿÿÿÿ" . chr (0x02) . "getstatus";
fputs($connect, $send);
fwrite ($connect, $send);
$output = fread ($connect, 1);
if (! empty ($output)) {
   do {
     $status_pre = socket_get_status ($connect);
     $output = $output . fread ($connect, 1);
     $status_post = socket_get_status ($connect);
   }
while ($status_pre[unread_bytes] != $status_post[unread_bytes]);
};


// Close the connection:
fclose($connect);

// Select the variables from the $output array:
$output = explode ("\\", $output);

$max_index = array_search ("sv_maxclients", $output);
$max_clients = $output[$max_index+1];

$max_index = array_search ("mapname", $output);
$mapname = $output[$max_index+1];

$max_index = array_search ("sv_hostname", $output);
$hostname = $output[$max_index+1];

$max_index = array_search ("g_gametypestring", $output);
$gametype = $output[$max_index+1];

$last_value = count($output) - 1;
$players_string = $output[$last_value];
$players_string = explode("\"", $players_string);

$get_first_ping = explode("\n", $players_string[0]);
$players_string[0] = $get_first_ping[1];

$i = 1;
$players = 0;
while (count($players_string) != $i) {
$i++;
$i++;
$players++;
}


// Create the image url:
if (substr($mapname, 0, 3) == "dm/") {
$picture_src = str_replace("dm/", "", $mapname);
}
else {
$picture_src = str_replace("obj/", "", $mapname);
}

$picture_src = "images/" . $picture_src . ".jpg";


// Start the output:
?>

<html>
<head>
      <title><?=$hostname?></title>
</head>
<body>
<table width="600" border="0" align="center">
<caption><b><?=$hostname?></b></caption>
<tr>
    <td width="256" valign="top" bgcolor="#a3a379">
    <table border="0">
         <tr>
             <td bgcolor="#939164" width="256">Game: <?=$gametype?><td>
         </tr>
         <tr>
             <td bgcolor="#939164" width="256">Players: <?=$players?>/<?=$max_clients?></td>
         </tr>
         <tr>
             <td bgcolor="#939164" width="256">Map: <?=$mapname?></td>
         </tr>
         <tr>
             <td bgcolor="#939164" width="256"><img src="<?=$picture_src?>"></td>
         </tr>
    </table>
    </td>
    <td valign="top" bgcolor="#a3a379">
        <table border="0">
        <tr>
            <td bgcolor="#939164" width="300">Player name:</td>
            <td bgcolor="#939164" width="44">Ping:</td>
        </tr>
        <?
        $i
= 1;
        while (count($players_string) != $i) {
        $j = $i -1;
        ?>

        <tr>
            <td bgcolor="#939164" width="300">
                <?=$players_string[$i]?>
            </td>
            <td bgcolor="#939164" width="44">
                <?=$players_string[$j]?>
            </td>
        </tr>
        <?
        $i
= $i + 2;
        }

    ?>

    </table>
    </td>
</tr>
</table>
</body>
</html>
<?
?>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.