supress warnings, improved PHP formatting, use XML-based syntax, hardcode banner width, delete older statuses
This commit is contained in:
@@ -23,7 +23,7 @@
|
|||||||
$pings = array(); $i = 0;
|
$pings = array(); $i = 0;
|
||||||
foreach ($data['ports'] as $port) {
|
foreach ($data['ports'] as $port) {
|
||||||
$starttime = microtime(true);
|
$starttime = microtime(true);
|
||||||
if ($fp = fsockopen($data['hostname'],$port,$errno,$errstr,15)) {
|
if ($fp = @fsockopen($data['hostname'],$port,$errno,$errstr,15)) {
|
||||||
$stoptime = microtime(true);
|
$stoptime = microtime(true);
|
||||||
$newping = ($stoptime - $starttime) * 1000;
|
$newping = ($stoptime - $starttime) * 1000;
|
||||||
$pings[$i++] = $newping;
|
$pings[$i++] = $newping;
|
||||||
@@ -69,42 +69,49 @@
|
|||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
}
|
}
|
||||||
$services[$id]['status'] = array_reverse($services[$id]['status']);
|
$services[$id]['status'] = array_reverse($services[$id]['status']);
|
||||||
|
|
||||||
|
if ($stmt = $SQL->prepare('DELETE FROM service_status WHERE service = :service AND timestamp NOT IN ( SELECT timestamp FROM service_status WHERE service = :service ORDER BY timestamp DESC LIMIT :limit )')) {
|
||||||
|
$stmt->bindParam('service', $id);
|
||||||
|
$stmt->bindParam('limit', $CONFIG['max_slices']);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->closeCursor();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title><?=$CONFIG['page_name'];?></title>
|
<title><?=$CONFIG['page_name'];?></title>
|
||||||
<meta property='og:site_name' content='<?=$CONFIG['site_name'];?>'>
|
<meta property='og:site_name' content='<?=$CONFIG['site_name'];?>' />
|
||||||
<meta property='og:image' content='favicon.png'>
|
<meta property='og:image' content='favicon.png' />
|
||||||
<meta property='og:title' content='<?=$CONFIG['page_name'];?>'>
|
<meta property='og:title' content='<?=$CONFIG['page_name'];?>' />
|
||||||
<meta property='og:description' content='<?=$CONFIG['site_description'];?>'>
|
<meta property='og:description' content='<?=$CONFIG['site_description'];?>' />
|
||||||
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
<meta name='viewport' content='width=device-width, initial-scale=1' />
|
||||||
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
|
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
|
||||||
<link rel='icon' href='favicon.png' type='image/png' sizes='64x64'>
|
<link rel='icon' href='favicon.png' type='image/png' sizes='64x64' />
|
||||||
<link rel='icon' href='favicon.ico' type='image/x-icon' sizes='64x64'>
|
<link rel='icon' href='favicon.ico' type='image/x-icon' sizes='64x64' />
|
||||||
<link rel='stylesheet' href='style.css'>
|
<link rel='stylesheet' href='style.css' />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<center class='page'>
|
<center class='page'>
|
||||||
<div class='banner'><img src='banner.png'><br><h3>Status Page</h3><a><?=$CONFIG['site_message'];?></a></div>
|
<div class='banner'><img src='banner.png' width="640" /><br /><h3>Status Page</h3><a><?=$CONFIG['site_message'];?></a></div>
|
||||||
<?php
|
<?php foreach ($services as $id=>$service): ?>
|
||||||
foreach ($services as $id=>$service) {
|
<table class='status' id='<?=$id;?>'>
|
||||||
echo '<table class=\'status\' id=\''.$id.'\'>';
|
<tr class='title'>
|
||||||
echo '<tr class=\'title\'><td colspan=\''.count($service['status']).'\'>';
|
<td colspan='<?=count($service['status']);?>'>
|
||||||
if (!empty($service['message'])) {
|
<?php if (!empty($service['message'])): ?>
|
||||||
echo '<details><summary><b>';
|
<details>
|
||||||
if (!empty($service['icon']))
|
<summary><b><?php if (!empty($service['icon'])): ?><img src='<?=$service['icon'];?>' height='16' /> <?php endif ?><?=$service['name'];?></b></summary>
|
||||||
echo '<img src=\''.$service['icon'].'\' height=\'16\'> ';
|
<?=$service['message'];?>
|
||||||
echo $service['name'].'</b></summary>'.$service['message'].'</details>';
|
</details>
|
||||||
} else {
|
<?php else: ?>
|
||||||
if (!empty($service['icon']))
|
<b><?php if (!empty($service['icon'])): ?><img src='<?=$service['icon'];?>' height='16' /> <?php endif ?><?=$service['name'];?></b>
|
||||||
echo '<img src=\''.$service['icon'].'\' height=\'16\'> ';
|
<?php endif ?>
|
||||||
echo '<b>'.$service['name'].'</b>';
|
</td
|
||||||
}
|
</tr>
|
||||||
echo '</td></tr>';
|
<tr>
|
||||||
echo '<tr>';
|
<?php foreach ($service['status'] as $slice): ?>
|
||||||
foreach ($service['status'] as $slice) {
|
<?php
|
||||||
$cell_status; $bgclrstyle = '';
|
$cell_status; $bgclrstyle = '';
|
||||||
$_time = date($CONFIG['timestamp_format'], strtotime($slice['timestamp']));
|
$_time = date($CONFIG['timestamp_format'], strtotime($slice['timestamp']));
|
||||||
$_ping = $slice['ping'].'ms';
|
$_ping = $slice['ping'].'ms';
|
||||||
@@ -124,13 +131,14 @@
|
|||||||
0
|
0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
echo '<td class=\''.$cell_status.'\' bgcolor=\''.$bgclrstyle.'\' value=\''.$_ping."\n".strtoupper($cell_status).' - '.$_time.'\'></td>';
|
<td class='<?=$cell_status;?>' bgcolor='<?=$bgclrstyle;?>' value='<?=$_ping."\n".strtoupper($cell_status).' - '.$_time;?>'></td>
|
||||||
}
|
<?php endforeach ?>
|
||||||
echo '</tr></table>'."\n";
|
</tr>
|
||||||
}
|
</table>
|
||||||
?>
|
<?php endforeach ?>
|
||||||
<hr>
|
<hr />
|
||||||
</center>
|
</center>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user