Fixed Expiry Alerts
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
use function PHPSTORM_META\type;
|
||||
|
||||
|
||||
$weblist_file=file_get_contents(JSON_WEB_LIST);
|
||||
$weblist_json=json_decode($weblist_file, true);
|
||||
if (file_exists(JSON_WEB_CHECK)){
|
||||
@@ -19,26 +20,67 @@ use function PHPSTORM_META\type;
|
||||
}
|
||||
}
|
||||
|
||||
function status_class_bg($ssl, $word){
|
||||
$yellow = "alert_yellow";
|
||||
function status_class_bg($ssl, $word, $expiry, $retcol=null){
|
||||
|
||||
// CSS CLASS
|
||||
$red = "alert_red";
|
||||
$orange = "alert_orange";
|
||||
$yellow = "alert_yellow";
|
||||
$green = "alert_green";
|
||||
$check = 0;
|
||||
|
||||
if ($ssl == 0){
|
||||
$check = 1;
|
||||
// CSS COLOR
|
||||
$col_red = "#ff4747";
|
||||
$col_orange = "#ff830f";
|
||||
$col_yellow = "#ffd70f";
|
||||
$col_green = "#42c500";
|
||||
$style="style='font-weight:bold; color:";
|
||||
|
||||
|
||||
$days = ssl_days_left($expiry);
|
||||
|
||||
if ($ssl != 1 || $word != 1) {
|
||||
echo $red;
|
||||
return;
|
||||
}
|
||||
|
||||
if ($word == 0){
|
||||
$check = 1;
|
||||
|
||||
|
||||
|
||||
if ($days !== null) {
|
||||
|
||||
if ($days <= SSL_CRITICAL_DAYS) {
|
||||
|
||||
if ($retcol){ // CRITICAL
|
||||
echo $style . $col_orange . ";'";
|
||||
}else{
|
||||
echo $red;
|
||||
return;
|
||||
}
|
||||
}elseif ($days <= SSL_WARNING_DAYS) {
|
||||
|
||||
if ($retcol){
|
||||
echo $style . $col_yellow . ";'";
|
||||
|
||||
}else{
|
||||
echo $yellow;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($check == 1){
|
||||
echo $red;
|
||||
|
||||
if ($retcol){
|
||||
echo $style . $col_green . ";'";
|
||||
return ;
|
||||
}else{
|
||||
echo $green;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function word_col_status($input){
|
||||
$col="#f7ce5f";
|
||||
@@ -87,7 +129,7 @@ use function PHPSTORM_META\type;
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="alert-container <?php status_class_bg($sslcheck_ok, $checkword_ok)?>">
|
||||
<div class="alert-container <?php status_class_bg($sslcheck_ok, $checkword_ok, $ssl_expiry)?>">
|
||||
<div class="alert-info">
|
||||
<div><b>HOST: </b><span><?= $host ?></span></div>
|
||||
<div><b>DOMAIN: </b><span><?= $domain ?></span></div>
|
||||
@@ -97,7 +139,7 @@ use function PHPSTORM_META\type;
|
||||
<div class="alert-details">
|
||||
<div><b>WORD TO CHECK: </b> <span><?= $wordtocheck ?></span></div>
|
||||
<div><b>SSL RELEASED: </b> <span><?= $ssl_released ?></span></div>
|
||||
<div><b>SSL EXPIRY: </b> <span><?= $ssl_expiry ?></span></div>
|
||||
<div><b>SSL EXPIRY: </b> <span <?php echo status_class_bg($sslcheck_ok, $checkword_ok, $ssl_expiry, true)?>> <?= $ssl_expiry ?></span></div>
|
||||
<div><b>SSL COMPANY: </b> <span><?= $ssl_company ?></span></div>
|
||||
<div><b>PATH: </b> <span><?= $path ?></span></div>
|
||||
<div><b>ERROR CODE: </b> <span><?= $http_error ?></span></div>
|
||||
@@ -159,4 +201,21 @@ use function PHPSTORM_META\type;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function ssl_days_left($expiry_date) {
|
||||
|
||||
if (empty($expiry_date)) return null;
|
||||
|
||||
$expiry = DateTime::createFromFormat('d/m/Y', $expiry_date);
|
||||
if (!$expiry) return null;
|
||||
|
||||
$now = new DateTime();
|
||||
|
||||
$interval = $now->diff($expiry);
|
||||
$days = (int)$interval->format('%r%a'); // giorni con segno
|
||||
|
||||
return $days;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user