Files
sld-web-health-check/functions/main.php
2026-02-11 23:08:41 +00:00

137 lines
3.3 KiB
PHP

<?php
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)){
$webcheck_file=file_get_contents(JSON_WEB_CHECK);
$webcheck_json=json_decode($webcheck_file, true);
}
//var_dump($webcheck_json);
function checktoword($wordtochange){
if ( $wordtochange == "1"){
echo "OK";
}else{
echo "PROBLEM";
}
}
function status_class_bg($ssl, $word){
$yellow = "alert_yellow";
$red = "alert_red";
$green = "alert_green";
$check = 0;
if ($ssl == 0){
$check = 1;
}
if ($word == 0){
$check = 1;
}
if ($check == 1){
echo $red;
}else{
echo $green;
}
}
function word_col_status($input){
$col="#f7ce5f";
$style = " style='color: ". $col . "; text-decoration: underline; text-shadow: 0 0 0 yellow; animation: bumping 3s linear 2s infinite;' ";
if ($input != 1){
echo $style;
}
}
function get_checked_list(){
global $webcheck_json;
foreach($webcheck_json as $check_element){
//VARIABLES
$host=$check_element['host'];
$domain=$check_element['domain'];
$checkword_ok=$check_element['wordcheck_ok'];
$sslcheck_ok=$check_element['sslcheck_ok'];
$wordtocheck=$check_element['wordtocheck'];
$ssl_released=$check_element['ssl-released'];
$ssl_expiry=$check_element['ssl-expiry'];
$ssl_company=$check_element['ssl-company'];
?>
<div class="alert-container <?php status_class_bg($sslcheck_ok, $checkword_ok)?>">
<div class="alert-info">
<div><b>HOST: </b><span><?= $host ?></span></div>
<div><b>DOMAIN: </b><span><?= $domain ?></span></div>
<div <?php word_col_status($checkword_ok) ?>><b>CONTENT: </b><span><?= checktoword($checkword_ok) ?></span></div>
<div <?php word_col_status($sslcheck_ok) ?>><b>SSL: </b><span><?= checktoword($sslcheck_ok) ?></span></div>
</div>
<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 COMPANY: </b> <span><?= $ssl_company ?></span></div>
</div>
</div>
<?php
}
}
function get_totals($type){
global $webcheck_json;
$totaldomain=0;
$totalok=0;
$totalssl_p=0;
$totalcheck_p=0;
foreach($webcheck_json as $i => $element){
// Total domain to check
$totaldomain ++;
// Total fine domain
if ($element['sslcheck_ok'] == 1 && $element['wordcheck_ok'] == 1){
$totalok ++;
}
// Total SSL Problem
if ($element['sslcheck_ok'] !== 1){
$totalssl_p ++;
}
// Total Word-check Problem
if ($element['wordcheck_ok'] !== 1){
$totalcheck_p ++;
}
}
switch($type){
case "total":
echo $totaldomain;
break;
case "ok":
echo $totalok;
break;
case "ssl":
echo $totalssl_p;
break;
case "word":
echo $totalcheck_p;
break;
}
}
?>