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; } ?> -