Fixed Expiry Alerts

This commit is contained in:
2026-02-12 18:00:34 +00:00
parent 5de6b80794
commit 4864cd6a3e
4 changed files with 90 additions and 14 deletions

View File

@@ -106,6 +106,19 @@ header{
animation: bumping_green_bg 4s linear 2s infinite; animation: bumping_green_bg 4s linear 2s infinite;
} }
.alert_orange{
background-color: #e26e00;
color:#ffd2a8;
box-shadow: 0 0 10px 1px black inset;;
}
.alert_yellow{
background-color: #d1ce00;
color:#fffebf;
box-shadow: 0 0 10px 1px black inset;;
}
footer{ footer{
position:fixed; position:fixed;
display:flex; display:flex;

View File

@@ -38,6 +38,10 @@
define("JSON_WEB_LIST", ROOT_DIR . "web_list.json"); define("JSON_WEB_LIST", ROOT_DIR . "web_list.json");
define("JSON_WEB_CHECK", ROOT_DIR . "web_check.json"); define("JSON_WEB_CHECK", ROOT_DIR . "web_check.json");
//SSL CONFIG
define('SSL_WARNING_DAYS', 10);
define('SSL_CRITICAL_DAYS', 5);
include(MAIN_FUNCTION); include(MAIN_FUNCTION);

View File

@@ -2,6 +2,7 @@
use function PHPSTORM_META\type; use function PHPSTORM_META\type;
$weblist_file=file_get_contents(JSON_WEB_LIST); $weblist_file=file_get_contents(JSON_WEB_LIST);
$weblist_json=json_decode($weblist_file, true); $weblist_json=json_decode($weblist_file, true);
if (file_exists(JSON_WEB_CHECK)){ if (file_exists(JSON_WEB_CHECK)){
@@ -19,27 +20,68 @@ use function PHPSTORM_META\type;
} }
} }
function status_class_bg($ssl, $word){ function status_class_bg($ssl, $word, $expiry, $retcol=null){
$yellow = "alert_yellow";
// CSS CLASS
$red = "alert_red"; $red = "alert_red";
$orange = "alert_orange";
$yellow = "alert_yellow";
$green = "alert_green"; $green = "alert_green";
$check = 0;
if ($ssl == 0){ // CSS COLOR
$check = 1; $col_red = "#ff4747";
} $col_orange = "#ff830f";
$col_yellow = "#ffd70f";
$col_green = "#42c500";
$style="style='font-weight:bold; color:";
if ($word == 0){
$check = 1;
}
if ($check == 1){ $days = ssl_days_left($expiry);
if ($ssl != 1 || $word != 1) {
echo $red; echo $red;
return;
}
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 ($retcol){
echo $style . $col_green . ";'";
return ;
}else{ }else{
echo $green; echo $green;
return;
} }
} }
function word_col_status($input){ function word_col_status($input){
$col="#f7ce5f"; $col="#f7ce5f";
$style = " style='color: ". $col . "; text-decoration: underline; text-shadow: 0 0 0 yellow; animation: bumping 3s linear 2s infinite;' "; $style = " style='color: ". $col . "; text-decoration: underline; text-shadow: 0 0 0 yellow; animation: bumping 3s linear 2s infinite;' ";
@@ -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 class="alert-info">
<div><b>HOST: </b><span><?= $host ?></span></div> <div><b>HOST: </b><span><?= $host ?></span></div>
<div><b>DOMAIN: </b><span><?= $domain ?></span></div> <div><b>DOMAIN: </b><span><?= $domain ?></span></div>
@@ -97,7 +139,7 @@ use function PHPSTORM_META\type;
<div class="alert-details"> <div class="alert-details">
<div><b>WORD TO CHECK: </b> <span><?= $wordtocheck ?></span></div> <div><b>WORD TO CHECK: </b> <span><?= $wordtocheck ?></span></div>
<div><b>SSL RELEASED: </b> <span><?= $ssl_released ?></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>SSL COMPANY: </b> <span><?= $ssl_company ?></span></div>
<div><b>PATH: </b> <span><?= $path ?></span></div> <div><b>PATH: </b> <span><?= $path ?></span></div>
<div><b>ERROR CODE: </b> <span><?= $http_error ?></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;
}
?> ?>

View File

@@ -33,9 +33,9 @@
"path": "/doku.php?id=start", "path": "/doku.php?id=start",
"wordtocheck": "Benvenuto", "wordtocheck": "Benvenuto",
"wordcheck_ok": 1, "wordcheck_ok": 1,
"sslcheck_ok": 1, "sslcheck_ok": 0,
"ssl-released": "24/12/2025", "ssl-released": "24/12/2025",
"ssl-expiry": "24/03/2026", "ssl-expiry": "15/02/2026",
"ssl-company": "Cloudflare TLS Issuing ECC CA 3", "ssl-company": "Cloudflare TLS Issuing ECC CA 3",
"content_http_code": 200, "content_http_code": 200,
"content_error": null, "content_error": null,