mirror of
https://gitlab.com/JKANetwork/CheckServer.git
synced 2026-02-22 04:54:06 +01:00
Delete global vars, better standarized things
This commit is contained in:
@@ -13,13 +13,12 @@ require_once 'lib/loadTwig.php';
|
||||
4-In maintenance
|
||||
255-Not results recolected (grey)
|
||||
*/
|
||||
function checkStatus($ID_C){
|
||||
global $db_conn;
|
||||
function checkStatus($db_conn,$ID_C){
|
||||
//First, check if the status is marked to any manual value
|
||||
$manualPage = dbw_query_fetch_array($db_conn,"SELECT ID_C,manStatus FROM CHECKS WHERE ID_C='$ID_C'")['manStatus'];
|
||||
if ($manualPage != NULL){return $manualPage;}
|
||||
//If it's not manual-setted, see real status
|
||||
$result = checkUptime($ID_C);
|
||||
$result = checkUptime($db_conn,$ID_C);
|
||||
//Return status
|
||||
if ($result == 255){return 255;}
|
||||
if ($result > 95 && $result <= 100){return 0;}
|
||||
@@ -28,8 +27,7 @@ function checkStatus($ID_C){
|
||||
if ($result >= 0 && $result <= 10){return 3;} //If test fail much (90% fail)
|
||||
}
|
||||
|
||||
function checkUptime($ID_C,$precision = 0){
|
||||
global $db_conn;
|
||||
function checkUptime($db_conn,$ID_C,$precision = 0){
|
||||
$time = $precision;
|
||||
if ($precision != 0){
|
||||
$good = dbw_query_fetch_array($db_conn,"SELECT COUNT(*) FROM CHKHIST WHERE ID_C = '$ID_C' AND code == 0 AND `timestamp` > $time")[0];
|
||||
@@ -61,10 +59,8 @@ function webRoot(){
|
||||
}
|
||||
|
||||
/** Returns a system option */
|
||||
function getSystemOpt($sysopt){
|
||||
global $db_conn;
|
||||
function getSystemOpt($db_conn,$sysopt){
|
||||
return dbw_query_fetch_array($db_conn,"SELECT * FROM SYS WHERE option = '$sysopt'")['value'];
|
||||
|
||||
}
|
||||
|
||||
/** Return HttpCode of page. Returns false if page is not found */
|
||||
@@ -116,18 +112,15 @@ function requireLogin(){
|
||||
}
|
||||
}
|
||||
|
||||
function nameFromIDC($ID_C){
|
||||
global $db_conn;
|
||||
function nameFromIDC($db_conn,$ID_C){
|
||||
return dbw_query_fetch_array($db_conn,"SELECT name FROM CHECKS WHERE ID_C='$ID_C'")[0];
|
||||
}
|
||||
|
||||
function nameGroupFromIDG($ID_G){
|
||||
global $db_conn;
|
||||
function nameGroupFromIDG($db_conn,$ID_G){
|
||||
return dbw_query_fetch_array($db_conn,"SELECT * FROM GROUPS WHERE ID_G='$ID_G'")['name'];
|
||||
}
|
||||
|
||||
function IDGFromIDC($ID_C){
|
||||
global $db_conn;
|
||||
function IDGFromIDC($db_conn,$ID_C){
|
||||
return dbw_query_fetch_array($db_conn,"SELECT ID_G FROM CHECKS WHERE ID_C='$ID_C'")['ID_G'];
|
||||
}
|
||||
|
||||
@@ -140,8 +133,7 @@ function arrayTypeChk(){
|
||||
'4' => 'DATABASE');
|
||||
}
|
||||
/* This funtion returns the translated text of a type check */
|
||||
function textTypeChk($typeChk){
|
||||
global $T_;
|
||||
function textTypeChk($T_,$typeChk){
|
||||
$arr = array(
|
||||
'1' => $T_['PING_IP'],
|
||||
'2' => $T_['HTTP_CODE'],
|
||||
|
||||
Reference in New Issue
Block a user