diff --git a/assets/css/style.css b/assets/css/style.css index d8e0293..b414925 100755 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -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; diff --git a/config/init.php b/config/init.php index 88ac335..d9c19bf 100644 --- a/config/init.php +++ b/config/init.php @@ -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); diff --git a/functions/main.php b/functions/main.php index bf5f24f..bea4b56 100644 --- a/functions/main.php +++ b/functions/main.php @@ -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; } ?> -
+
HOST:
DOMAIN:
@@ -97,7 +139,7 @@ use function PHPSTORM_META\type;
WORD TO CHECK:
SSL RELEASED:
-
SSL EXPIRY:
+
SSL EXPIRY: >
SSL COMPANY:
PATH:
ERROR CODE:
@@ -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; + } + + ?> \ No newline at end of file diff --git a/web_check.json b/web_check.json index db2cbb2..07f7206 100644 --- a/web_check.json +++ b/web_check.json @@ -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,