This repository was archived by the owner on Apr 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
67 lines (54 loc) · 2.11 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
<?php
$jsonFilePath = './report.json';
$jsonData = file_get_contents($jsonFilePath);
$json = json_decode($jsonData);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new Exception(json_last_error_msg());
}
$stats = new stdClass();
$stats->totalItems = 0;
$stats->totalItemsBySeverity = [];
foreach ($json->categories as $categoryName => $category) {
foreach ($category->items as $item) {
$stats->totalItems++;
$stats->totalItemsBySeverity[$item->severity]++;
switch($item->severity) {
case -1: // Unchecked
$severityIcon = 'minus';
$severityIconColour = '#000000';
break;
case 1:
$severityIcon = 'exclamation-sign';
$severityIconColour = '#c9302c';
break;
case 2:
$severityIcon = 'remove-circle';
$severityIconColour = '#f0ad4e';
break;
case 3:
$severityIcon = 'ok-circle';
$severityIconColour = '#5cb85c';
break;
default:
$severityIconColour = '#B0B0B0';
break;
}
$categoryName = ucwords($categoryName);
$itemToolTip = (empty($item->description) === false) ? ' <span class="glyphicon glyphicon-question-sign" data-toggle="tooltip" title="'.$item->description.'"></span>':'';
$severityText = (empty($item->severity) === false) ? '<span class="glyphicon glyphicon-'.$severityIcon.'" style="color: '.$severityIconColour.';"></span>':'<small style="color: '.$severityIconColour.';">N/A</small>';
$item->severity = empty($item->severity) ? '1000':$item->severity;
$item->severity = $item->severity <= 0 ? '500':$item->severity;
$itemRowsHTML .= <<<HTML
<tr class="table-danger">
<td data-sort="{$item->severity}">{$severityText}</td>
<td>{$categoryName}</td>
<td>
{$item->name}
{$itemToolTip}
</td>
<td>{$item->notes}</td>
</tr>
HTML;
}
}
require 'template.php';