-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
99 lines (85 loc) · 4 KB
/
index.php
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
<?php
require_once('functions.php');
$start = microtime(true);
$servers = getListFromCSV();
$tests = array();
foreach($servers as $server) {
$test = getServerInfo($server[0], $server[2], $server[1]);
$time = time();
if($test["status"] != 0) {
$cellColor = "active";
} elseif($test["cert"]["validFrom_time_t"] > $time) {
$cellColor = "warning";
} elseif($test["cert"]["validTo_time_t"] < $time) {
$cellColor = "danger";
} elseif(($test["cert"]["validTo_time_t"] - 30*24*3600) < $time) {
$cellColor = "warning";
} else {
$cellColor = "success";
}
$tests[] = array("server" => $server, "test" => $test, "cellColor" => $cellColor);
}
$end = microtime(true);
$elapsed = round(($end - $start)*10)/10;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Certificate monitor</title>
<link rel="icon" href="favicon.ico">
<!-- Bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
</head>
<body>
<div class="container">
<h1>Certificate monitor</h1>
<table class="table">
<tr>
<th>Server</th>
<th>Služba (port)</th>
<th data-toggle="tooltip" data-placement="bottom" data-container="body" title="Obsah pole CN= jména certifikátu. Pro podrobnosti najeďte na buňku tabulky.">Jméno certifikátu <span style="color: blue;">?</span></th>
<th>Hash</th>
<th>Platnost od</th>
<th>Platnost do</th>
</tr>
<?php
foreach($tests as $test) {
?>
<tr class="<?php echo($test["cellColor"]); ?>">
<td><?php echo($test["server"][0]); ?></td>
<td><?php echo($test["server"][1]); ?> (<?php echo($test["server"][2]); ?>)</td>
<?php
if($test["test"]["status"] == 0) {
?>
<td data-toggle="tooltip" data-placement="left" data-container="body" title="<?php echo($test["test"]["cert"]["name"]); ?>"><?php echo($test["test"]["cert"]["short_name"]); ?></td>
<td><?php echo($test["test"]["cert"]["hash"]); ?></td>
<td><?php echo(date("j. n. Y", $test["test"]["cert"]["validFrom_time_t"])); ?></td>
<td><?php echo(date("j. n. Y", $test["test"]["cert"]["validTo_time_t"])); ?></td>
<?php } else { ?>
<td colspan="4">Chyba - <?php echo(getErrorText($test["test"]["status"])); ?>.</td>
<?php } ?>
</tr>
<?php
}
?>
</table>
<hr>
Vygenerováno v <?php echo(date("G:i j. n. Y")); ?> za <?php echo($elapsed); ?> sekund. Napsal <a href="mailto:bkralik@hkfree.org">bkralik</a> v roce 2016. Zdrojové kódy dostupné na <a href="https://github.com/bkralik/CertMon">GitHubu</a>.
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script>
$(function () {
$('[data-toggle="tooltip"]').tooltip();
})
</script>
</body>
</html>