mirror of
https://gitlab.com/JKANetwork/CheckServer.git
synced 2026-06-13 19:56:18 +02:00
Change connect to load and fix code
This commit is contained in:
+39
-14
@@ -1,9 +1,8 @@
|
||||
<?php
|
||||
/* First, db connection */
|
||||
require_once "connect.php";
|
||||
require_once 'lib/loadTwig.php';
|
||||
//Functions
|
||||
|
||||
function getUptime($db_conn,$ID_C,$precision = 0){
|
||||
function getUptime($ID_C,$precision = 0){
|
||||
$db_conn = getconn();
|
||||
if ($precision == 0){
|
||||
$time = time()-30*7*3600; //Last week
|
||||
}else{
|
||||
@@ -28,7 +27,9 @@ function getUptime($db_conn,$ID_C,$precision = 0){
|
||||
}
|
||||
}
|
||||
|
||||
function getStatus($db_conn,$T_,$ID_C){
|
||||
function getStatus($ID_C){
|
||||
$T_ = loadLang();
|
||||
$db_conn = getconn();
|
||||
$resql = dbw_query($db_conn,"SELECT code FROM CHKHIST WHERE ID_C='$ID_C' ORDER BY `timestamp` DESC LIMIT 5");
|
||||
$err = 0;
|
||||
while ($x = dbw_fetch_array($db_conn,$resql)){
|
||||
@@ -69,8 +70,8 @@ function webRoot(){
|
||||
}
|
||||
|
||||
/** Returns a system option */
|
||||
function getSystemOpt($db_conn,$sysopt){
|
||||
return dbw_query_fetch_array($db_conn,"SELECT * FROM SYS WHERE option = '$sysopt'")['value'];
|
||||
function getSystemOpt($sysopt){
|
||||
return dbw_query_fetch_array(getconn(),"SELECT * FROM SYS WHERE option = '$sysopt'")['value'];
|
||||
}
|
||||
|
||||
/** Return HttpCode of page. Returns false if page is not found */
|
||||
@@ -121,16 +122,16 @@ function requireLogin(){
|
||||
}
|
||||
}
|
||||
|
||||
function nameFromIDC($db_conn,$ID_C){
|
||||
return dbw_query_fetch_array($db_conn,"SELECT name FROM CHECKS WHERE ID_C='$ID_C'")[0];
|
||||
function nameFromIDC($ID_C){
|
||||
return dbw_query_fetch_array(getconn(),"SELECT name FROM CHECKS WHERE ID_C='$ID_C'")[0];
|
||||
}
|
||||
|
||||
function nameGroupFromIDG($db_conn,$ID_G){
|
||||
return dbw_query_fetch_array($db_conn,"SELECT * FROM GROUPS WHERE ID_G='$ID_G'")['name'];
|
||||
function nameGroupFromIDG($ID_G){
|
||||
return dbw_query_fetch_array(getconn(),"SELECT * FROM GROUPS WHERE ID_G='$ID_G'")['name'];
|
||||
}
|
||||
|
||||
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'];
|
||||
function IDGFromIDC($ID_C){
|
||||
return dbw_query_fetch_array(getconn(),"SELECT ID_G FROM CHECKS WHERE ID_C='$ID_C'")['ID_G'];
|
||||
}
|
||||
|
||||
/* This funtion returns the array with type of checks */
|
||||
@@ -142,11 +143,35 @@ function arrayTypeChk(){
|
||||
'4' => 'DATABASE');
|
||||
}
|
||||
/* This funtion returns the translated text of a type check */
|
||||
function textTypeChk($T_,$typeChk){
|
||||
function textTypeChk($typeChk){
|
||||
$T_ = loadLang();
|
||||
$arr = array(
|
||||
'1' => $T_['PING_IP'],
|
||||
'2' => $T_['HTTP_CODE'],
|
||||
'3' => $T_['VISIT_COUNT'],
|
||||
'4' => $T_['DATABASE']);
|
||||
return $arr[$typeChk];
|
||||
}
|
||||
|
||||
//This function is an alias to Twig render, with "standard args" added
|
||||
function renderPage($page,$array){
|
||||
$T_ = loadLang(); //Load transactions
|
||||
//Default params to send
|
||||
$allarray = array(
|
||||
'version' => VERSION,
|
||||
'T_' => $T_,
|
||||
);
|
||||
|
||||
foreach ($array as $key => $value) {
|
||||
$allarray[$key] = $value;
|
||||
}
|
||||
require 'lib/loadTwig.php';
|
||||
echo $twig->render($page, $allarray);
|
||||
}
|
||||
|
||||
function loadLang(){
|
||||
//Translations
|
||||
require __DIR__."/assets/translations/en.php"; //Ever first English, and then your lang (Database)
|
||||
require __DIR__."/assets/translations/".LANG.".php";
|
||||
return $T_;
|
||||
}
|
||||
Reference in New Issue
Block a user