servers-ping

Gesponsorde koppelingen

PHP script bestanden

  1. servers-ping

« Lees de omschrijving en reacties

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Server status</title>
<style>
td.rood { border: 0px solid #000000; background: #FF2501; color: #000000; font-family: "verdana"; font-size: 11pt; text-align: center; height: 25px;}
td.groen { border: 0px solid #000000; background: #07FD1E; color: #000000; font-family: "verdana"; font-size: 11pt; text-align: center; height: 25px;}
body { background: #D6D3D2; color: #D6D3D2; font-family: "verdana"; font-size: 10pt; cursor: default; text-align: center; z-index: -1;}
p { color: #000000; font-family: "verdana"; font-size: 10pt; cursor: default; }
a:link,visited,acive { color: #000000; font-family: "verdana"; font-size: 11pt; text-decoration: none; }
a:hover { color: #000000; font-family: "verdana"; font-size: 11pt; text-decoration: underline;}
table { color: #0312D5; font-family: "verdana"; font-size: 11pt; border: 1px solid #000000;}
tr.tit { background: #FFD50F; color: #000000; font-family: "verdana"; font-size: 10pt; border: 1px solid #000000; text-align: center;}
input.text { background: #FFD50Fl color: #00000; font-family: "verdana"; }


</style>
<META HTTP-EQUIV="Refresh" CONTENT="900;URL=server.php">
</head>
<body>

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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?PHP
set_time_limit(120);
$cfg['server']         = 'server.txt';
$cfg['eigenserv']     = 'servers.txt';
$cfg['switch']        = 'switch.txt';
$cfg['switchrest']    = 'switchrest.txt';
function
add($addr,$naam,$bestand) { // server toevoegen
//==========================

$fp = fopen($bestand,'a+'); // open
$get = fgets($fp,filesize($bestand)+1024); // data halen
//========================== variables

$var = (filesize($bestand) < 5) ? '' : '|';
$post = $var.$addr.','.$naam;
// ================ schrijven
if(is_writable($bestand)) { // kan hij schrijven?
if(fwrite($fp,$post)) { // scrhijven
return true;
}
else { return false; } // fout als hij niet schrijft
} else { return false; } // fout als hij niet kan schrijven
fclose($fp);
clearstatcache();
}

// status functie
function status($ip) {
ob_start();
$last_line = system('ping '.$ip.' -n 1');
$out = ob_get_contents();
ob_end_clean();
if(preg_match_all('{Packets:(.+?),(.+?),(.+?),(.+?)}',$out,$all)) {
$ex = explode("=",$all[2][0]);
$ex1 = explode("=",$all[3][0]);
    if($ex[1] == '1') {
        return true;
    }
else {
        return false;
    }
}
}

//---------
function open($bes) {
$op = file_get_contents($bes);
$explode = explode("|",$op);
foreach($explode as $name) {
$expl = explode(",",$name);
if(status($expl[0])) { $rg = 'groen'; } else { $rg = 'rood'; }
$var[$expl[0]] = $rg.','.$expl[1];
}

return $var;
}

if($_GET['x'] == 'add') {
echo '<form method="post" action="'.$_SERVER['PHP_SELF'].'?x=add">';
echo '<table width=300><tr><td><b>Server toevoegen</b></td></tr></table>';
if(isset($_POST['submit'])) {
if(!empty($_POST['ip'])) {
$explode = explode(".",$_POST['ip']);
if(count($explode) == 4) {
$naam = (!empty($_POST['naam'])) ? $_POST['naam'] : $_POST['ip'];
if($_POST['type'] == 0) {
$bes = $cfg['eigenserv'];
}
elseif($_POST['type'] == 1) {
$bes = $cfg['server'];
}
elseif($_POST['type'] == 2) {
$bes = $cfg['switch'];
}
else {
$bes = $cfg['switchrest'];
}

if(add($_POST['ip'],$naam,$bes)) {
echo "<table width='300'><tr><td>".$_POST['ip']." is toegevoegt</td></tr></table>";
}
}
else
echo "<table width='300'><tr><td>U hebt geen geldig ip adres ingevult</td></tr></table>";
}
else
echo "<table width='300'><tr><td>U hebt geen ip ingevult</td></tr></table>";
}

echo '<table width=300><tr><td>Ip:</td><td><input type="text" name="ip" value="'.$_REQUEST['ip'].'"></td></tr><tr><td>Naam:</td><td><input type="text" name="naam"></td></tr>';
echo "<tr><td>Type:</td><td><select name='type'><option name='0'>Eigen servers</option><option name='1'>Server</option><option name='2'>Switch zwolle</option><option name='3'>Switch rest</option></select></td></tr>";
echo '<tr><td></td><td><input type="submit" name="submit" value="Toevoegen"></td></tr>';
echo "<tr><td></td><td style='text-align: right;'><a style='font-size: 9px;' href='javascript:window.close()'>Close</a></td></tr>";
echo '</table>';
}
else {
//--------------------------------
echo "<table width='100%' style='font-size: 20pt; text-align: center;
'><tr><td><strong>Servers</strong></td></tr></table>"
;
echo "<table width='100%' cellspacing=1 cellpadding=0><tr class='tit'><td>Servers</td></tr></table>";
echo "<table width='100%'><tr>";
$open = open($cfg['server']);
$i=0;
foreach($open as $line => $ip) {
$expl = explode(",",$ip);
echo "<td class=".$expl[0]." width='20%'><a target='_new' href='http://".$line."'>".$expl[1]."</a></td>";
$i++;
    if($i == 5) {
echo "</tr><tr>";
$i=0;
    }
}

echo "</tr></table>";

echo "<table width='100%' cellspacing=1 cellpadding=0><tr class='tit'><td>Switch zwolle</td></tr></table>";
echo "<table width='100%'><tr>";
$open = open($cfg['switch']);
$i=0;
foreach($open as $line => $ip) {
$expl = explode(",",$ip);
echo "<td class=".$expl[0]." width='25%'><a target='_new' href='http://".$line."'>".$expl[1]."</a></td>";
$i++;
    if($i == 4) {
echo "</tr><tr>";
$i=0;
    }
}

echo "</tr></table>";
//-------------------- rest
echo "<table width='100%' cellspacing=1 cellpadding=0><tr class='tit'><td>Switch  rest</td></tr></table>";
echo "<table width='100%'><tr>";
$open = open($cfg['switchrest']);
$i=0;
foreach($open as $line => $ip) {
$expl = explode(",",$ip);
echo "<td class=".$expl[0]." width='20%'><a target='_new' href='http://".$line."'>".$expl[1]."</a></td>";
$i++;
    if($i == 5) {
echo "</tr><tr>";
$i=0;
    }
}

echo "</tr></table>";
//============  servers
$open = open($cfg['eigenserv']);
if(count($open)  > 1) {
echo "<table width='100%'><tr><td><b>Eigen toegevoegde servers</b></td></tr></table>";
echo "<table width='100%'><tr>";
$i=0;
foreach($open as $line => $ip) {
$expl = explode(",",$ip);
echo "<td class=".$expl[0]." width='25%'><a target='_new' href='http://".$line."'>".$expl[1]."</a></td>";
$i++;
    if($i == 4) {
echo "</tr><tr>";
$i=0;
    }
}

echo "</tr>";
}

//--------------------------------
echo "<tr><td></td><td></td><td></td><td align='right'><a href='#' onclick=\"javascript:window.open('server.php?x=add','Ip toevoegen','width=320,height=160,scrollbars=no,toolbar=no,location=no')\">Ip toevoegen</a></td></tr></table>";
}

?>

 
 

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.