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
|
<? //---------------------------------------------------------------------------// // Author: Marc Hanlon <marc@rushland.net> // Date: 19-Oct-02 // Web: http://www.rushland.net // Info: Server Status // Version: 2.0b2 // Copyright (c) 2002. Marc Hanlon. //---------------------------------------------------------------------------// // License //---------------------------------------------------------------------------// // This file is part of Server Status. // // Server Status is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // Server Status is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Server Status; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // //---------------------------------------------------------------------------// function do_group($servers,$ports) { global $config,$phemplate,$portnames; $ports = preg_split("/[,]/",$ports); sort($ports); for ($i=0;$i<count($servers);$i++) { if ($servers[$i]["ip"] == "0") { $servers[$i]["ip"] = gethostbyname($servers[$i]["hostname"]); } if ($servers[$i]["hostname"] == "0") { $servers[$i]["hostname"] = gethostbyaddr($servers[$i]["ip"]); } foreach($ports as $thisport) { if (isset($portnames[$thisport]["name"])) { $theseports[$thisport]["name"] = $portnames[$thisport]["name"]; } else { $theseports[$thisport]["name"] = "Port " . $thisport; } $tcpconn = @fsockopen($servers[$i]["ip"],$thisport,$errno,$errstr,$config["timeout"]); if ($tcpconn) { $servers[$i]["stats"] .= '<td class="serviceup" align="center">' . $config["serviceup"] . '</td>'; fclose($tcpconn); } else { $servers[$i]["stats"] .= '<td class="servicedown" align="center">' . $config["servicedown"] . '</td>'; } } } $phemplate->set_file('groups','templates/groups.htm'); $phemplate->set_loop('heads',$theseports); $phemplate->set_loop('servers',$servers); return $phemplate->process('proc_groups','groups',2); }
function admin_output($buffer) { global $adminmsgs; $phemplate = new phemplate(); $phemplate->set_file("admin","../templates/admin.htm",1); $phemplate->set_var('content',$buffer); if (count($adminmsgs) < 1) { $phemplate->set_var('messages',''); } else { $phemplate->set_var('messages',join("<br />",$adminmsgs)); } return $phemplate->process("adminout","admin"); }
function genOptions($passedarray,$default="") { while ($thiskey = key($passedarray)) { $returnval .= "<option value=\"$thiskey\""; if ($thiskey == $default) { $returnval .= " selected"; } $returnval .= ">" . $passedarray[$thiskey] . "</option>"; next($passedarray); } return $returnval; }
function cachepage($buffer) { global $config; if ($config["cache"] > 0) { $cacheto = fopen($config["cachefile"],"w"); fwrite($cacheto,$buffer); fclose($cacheto); } return $buffer; } ?>
|