Fixed Expiry Alerts
This commit is contained in:
@@ -106,6 +106,19 @@ header{
|
||||
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{
|
||||
position:fixed;
|
||||
display:flex;
|
||||
|
||||
@@ -38,6 +38,10 @@
|
||||
define("JSON_WEB_LIST", ROOT_DIR . "web_list.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);
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -33,9 +33,9 @@
|
||||
"path": "/doku.php?id=start",
|
||||
"wordtocheck": "Benvenuto",
|
||||
"wordcheck_ok": 1,
|
||||
"sslcheck_ok": 1,
|
||||
"sslcheck_ok": 0,
|
||||
"ssl-released": "24/12/2025",
|
||||
"ssl-expiry": "24/03/2026",
|
||||
"ssl-expiry": "15/02/2026",
|
||||
"ssl-company": "Cloudflare TLS Issuing ECC CA 3",
|
||||
"content_http_code": 200,
|
||||
"content_error": null,
|
||||
|
||||
Reference in New Issue
Block a user