mirror of
https://gitlab.com/JKANetwork/CheckServer.git
synced 2026-02-16 02:01:34 +01:00
Fixing cronchk and adding JSON API check (WIP)
This commit is contained in:
@@ -39,13 +39,17 @@ For finishing it, you have to add a cron in your system for running checks. The
|
||||
|
||||
Decompress folder over your installation folder, and run "updater.php",
|
||||
it will update and say if something goes wrong. Its a good idea to make
|
||||
a backup of your sqlite.db3 database.
|
||||
a backup of your sqlite.db3 database before updating or data may lost.
|
||||
|
||||
## Changelog
|
||||
|
||||
### (WIP) Version 0.9.3
|
||||
|
||||
-TODO: Cleaner code
|
||||
-TODO: New JSON GET/POST check
|
||||
|
||||
-Bugfix in cronchk!
|
||||
|
||||
-A bit cleaner code
|
||||
|
||||
### Version 0.9.2 (Beta)
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
|
||||
{# "Switch" type #}
|
||||
{% if check.ID_TC == 1 or check.ID_TC == 2 or check.ID_TC == 4 %} {# Ping, HttpCode, SQL DB #}
|
||||
{% if check.ID_TC != 3 %} {# Every except Visits that is different #}
|
||||
|
||||
{% if check.uptime != -1 %}{#Only if records exists#}
|
||||
<td>
|
||||
|
||||
@@ -21,14 +21,14 @@
|
||||
action="?page=savenewcheck"
|
||||
{%endif%}>
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-2">Nombre</label>
|
||||
<label class="col-sm-2">{{T_.name}}</label>
|
||||
<div class="col-sm-10">
|
||||
<input name="name" type="text" placeholder="Nombre del check" value="{{check.name}}" class="form-control form-control-success"><small class="form-text">Nombre del checkeo.</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-2 form-control-label">Grupo</label>
|
||||
<label class="col-sm-2 form-control-label">{{T_.group}}</label>
|
||||
<div class="col-sm-10 select">
|
||||
<select name="group" id="group" class="form-control">
|
||||
{% for group in groups %}
|
||||
@@ -54,15 +54,19 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# Aquí empiezan los campos "opcionales" dependiendo del tipo de check #}
|
||||
{# Aquí empiezan los campos "opcionales" dependiendo del tipo de check (Estos vienen de la tabla, al campo) #}
|
||||
{# Sacar variables #}
|
||||
{% if check.ID_TC == 1%}
|
||||
{% set t1 = check.URL|split(':') %}
|
||||
{% set t1 = check.url|split(':') %}
|
||||
{% elseif check.ID_TC == 2%}
|
||||
{% set t2_url = check.URL %}
|
||||
{% set t2_code = check.TCParam %}
|
||||
{% set t2_url = check.url %}
|
||||
{% set t2_code = check.urlParam %}
|
||||
{% elseif check.ID_TC == 4%}
|
||||
{% set t4_url = check.URL %}
|
||||
{% set t4_url = check.url %}
|
||||
{% elseif check.ID_TC == 5 %}
|
||||
{% set t5_url = check.url %}
|
||||
{% set t5_params = check.urlParam|split('|') %}
|
||||
{% set t5_exceptedRes = check.exceptedRes %}
|
||||
{% endif %}
|
||||
|
||||
{# Trozos de formulario #}
|
||||
@@ -119,7 +123,36 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{# Tipo 5 - Json API #}
|
||||
<div id="t5" style="display:none;">
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-2">JSON</label>
|
||||
<div class="col-sm-10">
|
||||
<input name="t5url" type="text" placeholder="URL" value="{{t5_url}}" class="form-control form-control-success"><small class="form-text">URL de la API</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-2">Tipo de request</label>
|
||||
<div class="col-sm-10">
|
||||
<select name="t5type" class="form-control">
|
||||
<option value="GET" {%if t5_params[0] == 'GET' %} selected="selected" {%endif%}>GET</option>
|
||||
<option value="POST" {%if t5_params[0] == 'POST' %} selected="selected" {%endif%}>POST</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-2">Parametros enviados</label>
|
||||
<div class="col-sm-10">
|
||||
<input name="t5params" type="text" placeholder="?params" value="{{t5_params[1]}}" class="form-control form-control-success"><small class="form-text">Parametros de la API (Si es GET, empezar con ? o /)</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-2">Respuesta esperada</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea name="t5exceptedRes" placeholder="Respuesta en formato JSON" class="form-control form-control-success">{{t5_exceptedRes}}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col-sm-10 offset-sm-2">
|
||||
<button type="submit" class="btn btn-primary">Guardar cambios</button>
|
||||
@@ -135,28 +168,23 @@
|
||||
|
||||
<script>
|
||||
function showOptData(valSel){
|
||||
document.getElementById("t1").style.display = "none";
|
||||
document.getElementById("t2").style.display = "none";
|
||||
document.getElementById("t3").style.display = "none";
|
||||
document.getElementById("t4").style.display = "none";
|
||||
document.getElementById("t5").style.display = "none";
|
||||
optVal = valSel.value;
|
||||
|
||||
if(optVal == '1'){
|
||||
document.getElementById("t1").style.display = "block";
|
||||
document.getElementById("t2").style.display = "none";
|
||||
document.getElementById("t3").style.display = "none";
|
||||
document.getElementById("t4").style.display = "none";
|
||||
}else if(optVal == '2'){
|
||||
document.getElementById("t1").style.display = "none";
|
||||
document.getElementById("t2").style.display = "block";
|
||||
document.getElementById("t3").style.display = "none";
|
||||
document.getElementById("t4").style.display = "none";
|
||||
}else if(optVal == '3'){
|
||||
document.getElementById("t1").style.display = "none";
|
||||
document.getElementById("t2").style.display = "none";
|
||||
document.getElementById("t3").style.display = "block";
|
||||
document.getElementById("t4").style.display = "none";
|
||||
}else {
|
||||
document.getElementById("t1").style.display = "none";
|
||||
document.getElementById("t2").style.display = "none";
|
||||
document.getElementById("t3").style.display = "none";
|
||||
}else if(optVal == '4'){
|
||||
document.getElementById("t4").style.display = "block";
|
||||
}else {
|
||||
document.getElementById("t5").style.display = "block";
|
||||
}
|
||||
}
|
||||
showOptData(document.getElementById("tcheck"))
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
{% set beforegroup = check.ID_G %}
|
||||
<tr>
|
||||
<td>{{check.name}}</td>
|
||||
<td>{{check.nameTCheck}} - {{check.URL}}</td>
|
||||
<td>{{check.nameTCheck}} - {{check.url}}</td>
|
||||
<td>
|
||||
<a href="?page=viewhist&ID_C={{check.ID_C}}" class="btn btn-info">{{T_.view_hist}}</a>
|
||||
{% if you.fullRights == 1 %}
|
||||
|
||||
@@ -5,6 +5,7 @@ define('T_ENGVERSION',1);
|
||||
//(indexpage.twig) In index, title
|
||||
$T_['statdif1'] = 'Status of different checks';
|
||||
$T_['name'] = 'Name';
|
||||
$T_['group'] = 'Group';
|
||||
$T_['status'] = 'Status';
|
||||
$T_['status_uptime'] = 'Status (Uptime)';
|
||||
$T_['failed'] = 'Failed';
|
||||
@@ -31,11 +32,12 @@ $T_['groups'] = 'Groups';
|
||||
$T_['news'] = 'News';
|
||||
$T_['settings'] = 'Settings';
|
||||
$T_['users'] = 'Users';
|
||||
//[NEXT 4]Check texts
|
||||
//[NEXT 5]Check texts
|
||||
$T_['PING_IP'] = 'Ping to IP:Port';
|
||||
$T_['HTTP_CODE'] = 'Http code';
|
||||
$T_['VISIT_COUNT'] = 'Visit counter';
|
||||
$T_['DATABASE'] = 'Database check';
|
||||
$T_['JSON_API'] = 'JSON API';
|
||||
$T_['add_grp_to_add_chk'] = 'Add a group for start adding checks';
|
||||
$T_['view_hist'] = 'View history';
|
||||
$T_['lastest_fails'] = 'Lastest fails';
|
||||
|
||||
@@ -5,6 +5,7 @@ define('T_VERSION',1);
|
||||
//(indexpage.twig) In index, title
|
||||
$T_['statdif1'] = 'Estado de los diferentes servicios';
|
||||
$T_['name'] = 'Nombre';
|
||||
$T_['group'] = 'Grupo';
|
||||
$T_['status'] = 'Estado';
|
||||
$T_['status_uptime'] = 'Estado (Uptime)';
|
||||
$T_['failed'] = 'Erróneo';
|
||||
@@ -31,11 +32,12 @@ $T_['groups'] = 'Grupos';
|
||||
$T_['news'] = 'Noticias';
|
||||
$T_['settings'] = 'Opciones';
|
||||
$T_['users'] = 'Usuarios';
|
||||
//[NEXT 4]Check texts
|
||||
//[NEXT 5]Check texts
|
||||
$T_['PING_IP'] = 'Ping a IP:Puerto';
|
||||
$T_['HTTP_CODE'] = 'Código HTTP';
|
||||
$T_['VISIT_COUNT'] = 'Contador de visitas';
|
||||
$T_['DATABASE'] = 'Conexión a base de datos';
|
||||
$T_['JSON_API'] = 'JSON API';
|
||||
$T_['add_grp_to_add_chk'] = 'Añade un grupo para empezar a añadir checks';
|
||||
$T_['view_hist'] = 'Ver histórico';
|
||||
$T_['lastest_fails'] = 'Ultimos errores';
|
||||
|
||||
52
cronchk.php
52
cronchk.php
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
require_once "functions.php";
|
||||
require_once "load.php";
|
||||
|
||||
function PING_IP($db_conn,$ID_C,$URL){
|
||||
function PING_IP($ID_C,$URL){
|
||||
if (strpos($URL, ":")){ //Si usa un puerto, dividir
|
||||
$host = explode(":", $URL)[0];
|
||||
$port = explode(":", $URL)[1];
|
||||
@@ -10,7 +10,7 @@ function PING_IP($db_conn,$ID_C,$URL){
|
||||
return $result; //Returns result
|
||||
}
|
||||
|
||||
function HTTP_CODE($db_conn,$ID_C,$URL,$Param){
|
||||
function HTTP_CODE($ID_C,$URL,$Param){
|
||||
$httpCode = httpCode($URL); //Code
|
||||
|
||||
$code = (int)$Param != 0 ? $Param : 200; //Establish the code test want to see
|
||||
@@ -23,7 +23,7 @@ function HTTP_CODE($db_conn,$ID_C,$URL,$Param){
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function DATABASE_CONN($db_conn,$ID_C,$URL){
|
||||
function DATABASE_CONN($ID_C,$URL){
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $URL);
|
||||
curl_setopt($ch, CURLOPT_HEADER, FALSE);
|
||||
@@ -39,10 +39,41 @@ function DATABASE_CONN($db_conn,$ID_C,$URL){
|
||||
}
|
||||
}
|
||||
|
||||
//WIP, doesnt compare right!
|
||||
function JSON_API($ID_C,$URL,$params,$exceptedRes){
|
||||
$type = explode('|',$params)[0];
|
||||
$JSONParams = explode('|',$params)[1];
|
||||
|
||||
$ch = curl_init();
|
||||
if ($type == 'GET'){
|
||||
curl_setopt($ch, CURLOPT_URL, $URL . $JSONParams);
|
||||
}else if ($type == 'POST'){
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $JSONParams);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_URL, $URL);
|
||||
curl_setopt($ch, CURLOPT_HEADER, FALSE);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 4); //timeout in seconds
|
||||
$body = curl_exec($ch); //All file
|
||||
curl_close($ch);
|
||||
|
||||
$json_ret = json_decode($body,true);
|
||||
$json_param = json_decode($exceptedRes,true);
|
||||
$comp_ret =serialize($json_ret);
|
||||
$comp_param =serialize($json_param);
|
||||
if ($comp_ret == $comp_param){
|
||||
return 0;
|
||||
}else{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
$db_conn = getconn();
|
||||
$sites = dbw_query($db_conn,"SELECT * FROM CHECKS");
|
||||
while ($site = dbw_fetch_array($db_conn,$sites)){
|
||||
$try = 0;
|
||||
$extitC = 0;
|
||||
$ID_C= $site['ID_C'];
|
||||
do {
|
||||
$try++; //This is for avoiding posible "second" problems in some checks that are working but doesn't answer to first time
|
||||
@@ -50,15 +81,19 @@ while ($site = dbw_fetch_array($db_conn,$sites)){
|
||||
|
||||
switch ($site['ID_TC']) {
|
||||
case '1': //Ping to IP:Port
|
||||
$exitC = PING_IP($db_conn,$ID_C,$site['URL']);
|
||||
$exitC = PING_IP($ID_C,$site['url']);
|
||||
break;
|
||||
|
||||
case '2': //HttpCode
|
||||
$exitC = HTTP_CODE($db_conn,$ID_C,$site['URL'],$site['TCParam']);
|
||||
$exitC = HTTP_CODE($ID_C,$site['url'],$site['urlParam']);
|
||||
break;
|
||||
|
||||
case '4': //MySQL|Database connect
|
||||
$exitC = DATABASE_CONN($db_conn,$ID_C,$site['URL']);
|
||||
$exitC = DATABASE_CONN($ID_C,$site['url']);
|
||||
break;
|
||||
|
||||
case '5': //JSON GET | POST
|
||||
$exitC = JSON_API($ID_C,$site['url'],$site['urlParam'],$site['exceptedRes']);
|
||||
break;
|
||||
}
|
||||
}while($try <= 2 && $exitC == 1);
|
||||
@@ -71,12 +106,11 @@ while ($site = dbw_fetch_array($db_conn,$sites)){
|
||||
dbw_query($db_conn, "INSERT INTO `CHKHIST` (`ID_C`,`code`,`errorText`,`timestamp`) VALUES ('$ID_C','1','$exitC','$timestamp')");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Delete old Checks (Based on time to save, put in secs)
|
||||
$mintime = time()-(getSystemOpt($db_conn,"maxTimeSave")*24*3600);
|
||||
$mintime = time()-(getSystemOpt("maxTimeSave")*24*3600);
|
||||
dbw_query($db_conn,"DELETE FROM CHKHIST WHERE `timestamp` < $mintime");
|
||||
|
||||
//Delete Checks stored for pages that not exist
|
||||
|
||||
@@ -74,7 +74,7 @@ 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 */
|
||||
/** Return HttpCode of page. Returns false if page is not found (Used in cron) */
|
||||
function httpCode($url, $wait = 5)
|
||||
{
|
||||
$ch = curl_init();
|
||||
@@ -127,7 +127,7 @@ function nameFromIDC($ID_C){
|
||||
}
|
||||
|
||||
function nameGroupFromIDG($ID_G){
|
||||
return dbw_query_fetch_array(getconn(),"SELECT * FROM GROUPS WHERE ID_G='$ID_G'")['name'];
|
||||
return dbw_query_fetch_array(getconn(),"SELECT ID_G,name FROM GROUPS WHERE ID_G='$ID_G'")['name'];
|
||||
}
|
||||
|
||||
function IDGFromIDC($ID_C){
|
||||
@@ -137,19 +137,22 @@ function IDGFromIDC($ID_C){
|
||||
/* This funtion returns the array with type of checks */
|
||||
function arrayTypeChk(){
|
||||
return array(
|
||||
'1' => 'PING_IP',
|
||||
'2' => 'HTTP_CODE',
|
||||
'3' => 'VISIT_COUNT',
|
||||
'4' => 'DATABASE');
|
||||
1 => 'PING_IP',
|
||||
2 => 'HTTP_CODE',
|
||||
3 => 'VISIT_COUNT',
|
||||
4 => 'DATABASE',
|
||||
5 => 'JSON_API');
|
||||
}
|
||||
/* This funtion returns the translated text of a type check */
|
||||
function textTypeChk($typeChk){
|
||||
$T_ = loadLang();
|
||||
$arr = array(
|
||||
'1' => $T_['PING_IP'],
|
||||
'2' => $T_['HTTP_CODE'],
|
||||
'3' => $T_['VISIT_COUNT'],
|
||||
'4' => $T_['DATABASE']);
|
||||
1 => $T_['PING_IP'],
|
||||
2 => $T_['HTTP_CODE'],
|
||||
3 => $T_['VISIT_COUNT'],
|
||||
4 => $T_['DATABASE'],
|
||||
5 => $T_['JSON_API']
|
||||
);
|
||||
return $arr[$typeChk];
|
||||
}
|
||||
|
||||
|
||||
@@ -17,10 +17,11 @@ while ($onechk = dbw_fetch_array($db_conn,$results)){
|
||||
$ID_TC = $chks[$idchk]['ID_TC']; //Type of Check
|
||||
|
||||
switch ($ID_TC){
|
||||
// Case 1 and 2 are normal status, case 3 (Visits) is numeric, not status
|
||||
// Case 3 (Visits) is numeric, not status
|
||||
case 1: //Ping
|
||||
case 2: //HttpCode
|
||||
case 4: //MySQL
|
||||
case 5: //JSON GET|POST
|
||||
|
||||
//To enter or not, check if has history (Instead of count > 0, only see if there is any timestamp, is faster)
|
||||
if (dbw_query_fetch_array($db_conn, "SELECT `timestamp` FROM CHKHIST WHERE ID_C = '$idchk' LIMIT 1")[0] != 0){
|
||||
|
||||
10
install.php
10
install.php
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
define('VERSION','0.9.2');
|
||||
define('VERSION','0.9.3');
|
||||
//define('INSTALLER_MODE','1');
|
||||
require_once 'lib/loadTwig.php';
|
||||
|
||||
@@ -63,16 +63,17 @@ CREATE TABLE "CHECKS" (
|
||||
`ID_C` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`ID_G` INTEGER,
|
||||
`name` TEXT NOT NULL,
|
||||
`URL` TEXT,
|
||||
`url` TEXT,
|
||||
`manStatus` INTEGER,
|
||||
`ID_TC` INTEGER,
|
||||
`TCParam` TEXT,
|
||||
`urlParam` TEXT,
|
||||
`exceptedRes` TEXT,
|
||||
FOREIGN KEY(`ID_G`) REFERENCES `GROUPS`(`ID_G`),
|
||||
FOREIGN KEY(`ID_TC`) REFERENCES `TYPECHK`(`ID_TC`)
|
||||
);
|
||||
COMMIT;';
|
||||
dbw_multi_query($db_conn,$sqlcreate); //Create scheme
|
||||
$user = $_POST[username];
|
||||
$user = $_POST['username'];
|
||||
$pass = hash("sha256",$_POST['passw1']);
|
||||
dbw_query($db_conn,"INSERT INTO USERS (nick,passw,fullRights) VALUES('$user','$pass',1)"); //Create user
|
||||
|
||||
@@ -81,6 +82,7 @@ COMMIT;';
|
||||
dbw_query($db_conn,"INSERT INTO SYS VALUES ('lang','$_POST[lang]')");
|
||||
dbw_query($db_conn,"INSERT INTO SYS VALUES ('websiteTitle','Status')");
|
||||
dbw_query($db_conn,"INSERT INTO SYS VALUES ('version','".VERSION."')");
|
||||
dbw_query($db_conn,"INSERT INTO SYS VALUES ('maintenance','0')");
|
||||
|
||||
echo $twig->render('install.twig', array('part' => 2));
|
||||
}
|
||||
|
||||
5
load.php
5
load.php
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
require_once 'functions.php'; //Preloads functions
|
||||
require_once 'lib/dbwrapper.php';
|
||||
define('VERSION','0.9.2');
|
||||
define('VERSION','0.9.3');
|
||||
session_start(); //Session in all page
|
||||
//Preload file
|
||||
//This function loads all things needed, with optional db things if needed
|
||||
@@ -35,4 +35,7 @@ define('LANG', getSystemOpt('lang'));
|
||||
if (getSystemOpt('version') != VERSION){
|
||||
die("<p>Please run updater.php to update before using page");
|
||||
}
|
||||
if (getSystemOpt('maintenance') == '1'){
|
||||
die("<p>CheckStatus is in maintenance mode, wait for admin to disable maintenance mode</p>");
|
||||
}
|
||||
|
||||
|
||||
33
panel.php
33
panel.php
@@ -18,7 +18,7 @@ if (in_array($page,$arrPagesFullRigths) && $you['fullRights'] != 1){
|
||||
|
||||
switch($page){
|
||||
case 'notperm':
|
||||
echo $twig->render('panel/p_notperm.twig', array('T_' => $T_, 'you' => $you));
|
||||
renderPage('panel/p_notperm.twig', array('you' => $you));
|
||||
break;
|
||||
case 'checks':
|
||||
//Groups (For "fast-change-group option in html")
|
||||
@@ -90,18 +90,29 @@ switch($page){
|
||||
$ID_G = $_POST['group'];
|
||||
$ID_TC = $_POST['tcheck'];
|
||||
//Datos que dependen del tipo de check
|
||||
if ($ID_TC == 1){
|
||||
$URL = $_POST['t1url'] . ':' . $_POST['t1port'];
|
||||
dbw_query($db_conn,"UPDATE CHECKS SET URL='$URL' WHERE ID_C='$ID_C'");
|
||||
}elseif ($ID_TC == 2){
|
||||
$URL = $_POST['t2url'];
|
||||
$TCParam = isset($_POST['t2code']) ? $_POST['t2code'] : '';
|
||||
dbw_query($db_conn,"UPDATE CHECKS SET URL='$URL',TCParam = '$TCParam' WHERE ID_C='$ID_C'");
|
||||
}elseif ($ID_TC == 4){
|
||||
$URL = $_POST['t4url'];
|
||||
dbw_query($db_conn,"UPDATE CHECKS SET URL='$URL' WHERE ID_C='$ID_C'");
|
||||
switch ($ID_TC){
|
||||
case 1:
|
||||
$url = $_POST['t1url'] . ':' . $_POST['t1port'];
|
||||
dbw_query($db_conn,"UPDATE CHECKS SET url='$url' WHERE ID_C='$ID_C'");
|
||||
break;
|
||||
case 2:
|
||||
$url = $_POST['t2url'];
|
||||
$urlParam = isset($_POST['t2code']) ? $_POST['t2code'] : '';
|
||||
dbw_queryurl($db_conn,"UPDATE CHECKS SET url='$url',urlParam = '$urlParam' WHERE ID_C='$ID_C'");
|
||||
break;
|
||||
case 4:
|
||||
$url = $_POST['t4url'];
|
||||
dbw_query($db_conn,"UPDATE CHECKS SET url='$url' WHERE ID_C='$ID_C'");
|
||||
break;
|
||||
case 5:
|
||||
$url = $_POST['t5url'];
|
||||
$urlParam = dbw_escape_string($db_conn,$_POST['t5type'].'|'.$_POST['t5params']);
|
||||
$exceptedRes = dbw_escape_string($db_conn,$_POST['t5exceptedRes']);
|
||||
dbw_query($db_conn,"UPDATE CHECKS SET url='$url', urlParam='$urlParam',exceptedRes='$exceptedRes' WHERE ID_C='$ID_C'");
|
||||
break;
|
||||
}//Si es 3 no hay datos que guardar (de momento)
|
||||
|
||||
|
||||
//Guardamos el resto de datos
|
||||
dbw_query($db_conn,"UPDATE CHECKS SET name='$name', ID_G='$ID_G', ID_TC='$ID_TC' WHERE ID_C='$ID_C'");
|
||||
|
||||
|
||||
36
updater.php
36
updater.php
@@ -8,7 +8,7 @@ if (!is_file($db_file)){ //Go to install if not.
|
||||
die();
|
||||
}
|
||||
$db_conn = dbw_connect("sqlite",$db_file); //Database
|
||||
|
||||
dbw_query($db_conn,"UPDATE SYS SET value='1' WHERE option='maintenance'");
|
||||
$version = dbw_query_fetch_array($db_conn,"SELECT value FROM SYS WHERE option = 'version'")[0];
|
||||
echo "<p>Your version: ".$version;
|
||||
echo "<p>Updating to lastest</p>";
|
||||
@@ -18,12 +18,34 @@ switch ($version){
|
||||
dbw_query($db_conn,"DELETE FROM SYS WHERE option='maxChecksSave'");
|
||||
dbw_query($db_conn,"INSERT INTO SYS VALUES('maxTimeSave',14)");
|
||||
//Can not delete USERS.SessionID because sqlite3 not supports it, but doesn't do any harm.
|
||||
dbw_query($db_conn,"UPDATE SYS SET value='0.9.1' WHERE option='version'");
|
||||
case '0.9.1': //No db updates
|
||||
echo "<p>0.9.1->0.9.2<p>";
|
||||
dbw_query($db_conn,"UPDATE SYS SET value='0.9.2' WHERE option='version'");
|
||||
case '0.9.1':
|
||||
echo "<p>0.9.1->0.9.2</p>";
|
||||
case '0.9.2':
|
||||
echo "0.9.2-Lastest";
|
||||
echo "<p>0.9.2->0.9.3</p>";
|
||||
dbw_query($db_conn,'ALTER TABLE CHECKS RENAME TO CHECKS_orig;');
|
||||
dbw_query($db_conn,'
|
||||
CREATE TABLE "CHECKS" (
|
||||
`ID_C` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`ID_G` INTEGER,
|
||||
`ID_TC` INTEGER,
|
||||
`name` TEXT NOT NULL,
|
||||
`url` TEXT,
|
||||
`manStatus` INTEGER,
|
||||
`urlParam` TEXT,
|
||||
`exceptedRes` TEXT,
|
||||
FOREIGN KEY(`ID_G`) REFERENCES `GROUPS`(`ID_G`),
|
||||
FOREIGN KEY(`ID_TC`) REFERENCES `TYPECHK`(`ID_TC`)
|
||||
);
|
||||
');
|
||||
dbw_query($db_conn,"INSERT INTO CHECKS(ID_C, ID_G,ID_TC,name,url,manStatus,urlParam) SELECT ID_C,ID_G,ID_TC,name,URL,manStatus,TCParam FROM CHECKS_orig;");
|
||||
dbw_query($db_conn,"DROP TABLE CHECKS_orig");
|
||||
dbw_query($db_conn,"INSERT INTO SYS VALUES ('maintenance','1')"); //New system opt
|
||||
|
||||
case '0.9.3':
|
||||
dbw_query($db_conn,"UPDATE SYS SET value='0.9.3' WHERE option='version'");
|
||||
dbw_query($db_conn,"UPDATE SYS SET value='0' WHERE option='maintenance'");
|
||||
|
||||
echo "0.9.3-Lastest";
|
||||
echo "<p>Updated to lastest. Close this and go to index</p>";
|
||||
echo "<p>Remember to delete updater.php and install.php for security!</p>"
|
||||
echo "<p>Remember to delete updater.php and install.php for security!</p>";
|
||||
}
|
||||
Reference in New Issue
Block a user