diff --git a/functions/main.php b/functions/main.php index bea4b56..b35e606 100644 --- a/functions/main.php +++ b/functions/main.php @@ -20,7 +20,7 @@ use function PHPSTORM_META\type; } } -function status_class_bg($ssl, $word, $expiry, $retcol=null){ +function status_class_bg($ssl, $word, $expiry, $retcol=null, $showday="null"){ // CSS CLASS $red = "alert_red"; @@ -38,13 +38,16 @@ function status_class_bg($ssl, $word, $expiry, $retcol=null){ $days = ssl_days_left($expiry); + if ($showday == "on"){ + return $days; + } + if ($ssl != 1 || $word != 1) { echo $red; return; } - - + if ($days !== null) { @@ -53,7 +56,7 @@ function status_class_bg($ssl, $word, $expiry, $retcol=null){ if ($retcol){ // CRITICAL echo $style . $col_orange . ";'"; }else{ - echo $red; + echo $orange; return; } }elseif ($days <= SSL_WARNING_DAYS) { @@ -123,6 +126,21 @@ function status_class_bg($ssl, $word, $expiry, $retcol=null){ $ssl_expiry=$check_element['ssl-expiry']; $ssl_company=$check_element['ssl-company']; $http_error=$check_element['content_http_code']; + $expirying_days=status_class_bg($sslcheck_ok, $checkword_ok, $ssl_expiry, false, 'on'); + $col_red = "#ff4747"; + $col_orange = "#ff830f"; + $col_yellow = "#ffd70f"; + $col_green = "#42c500"; + + if($expirying_days < 0){ + $expiry_col='style="font-weight:bold; color:' . $col_red . ';"'; + }elseif($expirying_days <= SSL_CRITICAL_DAYS ){ + $expiry_col='style="font-weight:bold; color:' . $col_orange . ';"'; + }elseif($expirying_days <= SSL_WARNING_DAYS){ + $expiry_col='style="font-weight:bold; color:' . $col_yellow . ';"'; + }else{ + $expiry_col='style="font-weight:bold; color:' . $col_green . ';"'; + } if ($path == ""){ $path = "/"; @@ -139,12 +157,13 @@ function status_class_bg($ssl, $word, $expiry, $retcol=null){
WORD TO CHECK:
SSL RELEASED:
-
SSL EXPIRY: >
-
SSL COMPANY:
+
SSL EXPIRY: >
+
SSL DAYS LEFT: >
+
SSL COMPANY:
PATH:
ERROR CODE:
+
- diff($expiry); + $days = (int)$interval->format('%r%a'); // giorni con segno + + return $days; +} + function normalizeDomainHost(string $domain): string { // rimuovi schema se presente if (preg_match('#^https?://#i', $domain)) { diff --git a/template/footer.php b/template/footer.php index a26585a..32eeefd 100644 --- a/template/footer.php +++ b/template/footer.php @@ -1,7 +1,8 @@