mirror of
https://gitlab.com/JKANetwork/CheckServer.git
synced 2026-02-17 10:41:34 +01:00
Optimize index and fix delete older checks from hist
This commit is contained in:
18
README.md
18
README.md
@@ -5,19 +5,19 @@ without dependencies and installable only coping repository and ajusting some pa
|
|||||||
|
|
||||||
Also can show stadistics for all sites
|
Also can show stadistics for all sites
|
||||||
|
|
||||||
Demo can be viewed in https://status.jkanetwork.com/
|
Real using index 'demo' can be viewed in https://status.jkanetwork.com/
|
||||||
|
|
||||||
## Disclaimer
|
## Disclaimer
|
||||||
|
|
||||||
This is an beta, opensource, and human made program. **There may be bugs and problems**, and
|
This is an beta, opensource, and a human made program. **There may be bugs and problems**, and
|
||||||
although we can help or fix things, JKANetwork is **not** responsable for derivated problems.
|
although we can update and fix things, JKANetwork is **not** responsable for derivated problems.
|
||||||
|
|
||||||
You can see the master code and tell us any improvment or bug. Plase see indications for installing if you want
|
You can see the master code and tell us any improvment or bug. Plase see indications for installing if you want
|
||||||
to install instead of downloading master and install, that it will not work right. Master is like beta, and tags its like releases.
|
to install without problems. Master is bleeding edge, use tags for versions and not having problems.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
-Modern PHP (5.6+) with SQLite enabled
|
-Modern PHP (5.6+) with SQLite3 enabled
|
||||||
|
|
||||||
-Cron support
|
-Cron support
|
||||||
|
|
||||||
@@ -36,11 +36,15 @@ For finishing it, you have to add a cron in your system for running checks. The
|
|||||||
*/5 * * * * root cd /srv/http/checkserver/ && /usr/bin/php -f cronchk.php >/dev/null 2>&1
|
*/5 * * * * root cd /srv/http/checkserver/ && /usr/bin/php -f cronchk.php >/dev/null 2>&1
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Update
|
||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
### (NEXT) Version 0.9.1 (Beta)
|
### (WIP) Version 0.9.1
|
||||||
|
|
||||||
-TODO: See uptime percent
|
-See uptime percent
|
||||||
|
|
||||||
|
-Optimized index webpage, times went down to half when have a lot of pages
|
||||||
|
|
||||||
-TODO: Better index admin page (More data)
|
-TODO: Better index admin page (More data)
|
||||||
|
|
||||||
|
|||||||
@@ -32,16 +32,16 @@
|
|||||||
{# "Switch" type #}
|
{# "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 == 1 or check.ID_TC == 2 or check.ID_TC == 4 %} {# Ping, HttpCode, SQL DB #}
|
||||||
<td>
|
<td>
|
||||||
{#IF/SWITCH status text#}
|
{#IF/SWITCH uptime to text#}
|
||||||
{%if check.status == 0%}
|
{%if check.uptime <= 100 and check.uptime > 90 %}
|
||||||
<span class='green' data-tooltip='Type of check: {{check.nameCheck}}' data-tooltip-position='top'>{{T_.status_right}}</span>
|
<span class='green' data-tooltip='Type of check: {{check.nameCheck}}' data-tooltip-position='top'>{{T_.status_right}}</span>
|
||||||
{%elseif check.status == 1%}
|
{%elseif check.uptime <= 95 and check.uptime > 60 %}
|
||||||
<span class='blue' data-tooltip='Type of check: {{check.nameCheck}}' data-tooltip-position='top'>{{T_.status_lproblems}}</span>
|
<span class='blue' data-tooltip='Type of check: {{check.nameCheck}}' data-tooltip-position='top'>{{T_.status_lproblems}}</span>
|
||||||
{%elseif check.status == 2%}
|
{%elseif check.uptime <= 60 and check.uptime > 15 %}
|
||||||
<span class='orange' data-tooltip='Type of check: {{check.nameCheck}}' data-tooltip-position='top'>{{T_.status_problems}}</span>
|
<span class='orange' data-tooltip='Type of check: {{check.nameCheck}}' data-tooltip-position='top'>{{T_.status_problems}}</span>
|
||||||
{%elseif check.status == 3%}
|
{%elseif check.uptime <= 15 and check.uptime >= 0 %}
|
||||||
<span class='red' data-tooltip='Type of check: {{check.nameCheck}}' data-tooltip-position='top'>{{T_.status_outofserv}}</span>
|
<span class='red' data-tooltip='Type of check: {{check.nameCheck}}' data-tooltip-position='top'>{{T_.status_outofserv}}</span>
|
||||||
{%elseif check.status == 4%}
|
{%elseif check.uptime == 255 %}
|
||||||
<span class='blue' data-tooltip='Type of check: {{check.nameCheck}}' data-tooltip-position='top'>{{T_.status_maintenance}}</span>
|
<span class='blue' data-tooltip='Type of check: {{check.nameCheck}}' data-tooltip-position='top'>{{T_.status_maintenance}}</span>
|
||||||
{%else%}
|
{%else%}
|
||||||
<span class='grey' data-tooltip='Type of check: {{check.nameCheck}}' data-tooltip-position='top'>{{T_.status_empty}}</span>
|
<span class='grey' data-tooltip='Type of check: {{check.nameCheck}}' data-tooltip-position='top'>{{T_.status_empty}}</span>
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
{#END IF/SWITCH#}
|
{#END IF/SWITCH#}
|
||||||
({{ check.uptime}}%)
|
({{ check.uptime}}%)
|
||||||
</td>
|
</td>
|
||||||
{% if check.status is defined %}{#Only if records exists#}
|
{% if check.uptime != -1 %}{#Only if records exists#}
|
||||||
<td>
|
<td>
|
||||||
{{check.dateLastChk}} -
|
{{check.dateLastChk}} -
|
||||||
{% if check.failedLastChk == 0 %}
|
{% if check.failedLastChk == 0 %}
|
||||||
|
|||||||
@@ -38,10 +38,11 @@
|
|||||||
<td>{{check.name}}</td>
|
<td>{{check.name}}</td>
|
||||||
<td>{{check.nameTCheck}} - {{check.URL}}</td>
|
<td>{{check.nameTCheck}} - {{check.URL}}</td>
|
||||||
<td>
|
<td>
|
||||||
|
<a href="?page=viewhist&ID_C={{check.ID_C}}" class="btn btn-info">{{T_.view_hist}}</a>
|
||||||
{% if you.fullRights == 1 %}
|
{% if you.fullRights == 1 %}
|
||||||
<a href="?page=editcheck&ID_C={{check.ID_C}}" class="btn btn-primary">{{T_.edit}}</a>
|
<a href="?page=editcheck&ID_C={{check.ID_C}}" class="btn btn-primary">{{T_.edit}}</a>
|
||||||
{% if check.ID_TC == 3 %}{#Visitas#}
|
{% if check.ID_TC == 3 %}{#Visitas#}
|
||||||
<button type="button" class="btn btn-info" data-toggle="modal" data-target="#countercode_{{check.ID_C}}">Código del contador</button>
|
<button type="button" class="btn btn-secondary" data-toggle="modal" data-target="#countercode_{{check.ID_C}}">Código del contador</button>
|
||||||
|
|
||||||
{% elseif check.ID_TC == 4 %}{#Database#}
|
{% elseif check.ID_TC == 4 %}{#Database#}
|
||||||
<a href="#" data-toggle="modal" data-target="#dbcode_{{check.ID_C}}" class="btn btn-info">Codigo para check database</a>
|
<a href="#" data-toggle="modal" data-target="#dbcode_{{check.ID_C}}" class="btn btn-info">Codigo para check database</a>
|
||||||
|
|||||||
@@ -10,18 +10,18 @@
|
|||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-block">
|
<div class="card-block">
|
||||||
<form class="form-horizontal" method="POST" action="?page=saveopts">
|
<form class="form-horizontal" method="POST" action="?page=savesettings">
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-sm-2">Nombre de la web</label>
|
<label class="col-sm-2">Nombre de la web</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<input name="name" type="text" placeholder="Nombre del check" value="{{sys.name}}" class="form-control form-control-success"><small class="form-text">Nombre para sacar en titulos.</small>
|
<input name="name" type="text" placeholder="Nombre de la web" value="{{sys.name}}" class="form-control form-control-success"><small class="form-text">Nombre para sacar en titulos.</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-sm-2">Cantidad de resultados (Individuales) a guardar en historial por cada check</label>
|
<label class="col-sm-2">Cantidad de tiempo a guardar historial de resultados en días.</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<input name="maxChecksSave" type="numeric" placeholder="Nombre del check" value="{{sys.maxChecksSave}}" class="form-control form-control-success"><small class="form-text">300 es un buen numero</small>
|
<input name="maxTimeSave" type="numeric" placeholder="Nombre del check" value="{{sys.maxTimeSave}}" class="form-control form-control-success"><small class="form-text">Por defecto, dos semanas</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -37,4 +37,5 @@ $T_['HTTP_CODE'] = 'Http code';
|
|||||||
$T_['VISIT_COUNT'] = 'Visit counter';
|
$T_['VISIT_COUNT'] = 'Visit counter';
|
||||||
$T_['DATABASE'] = 'Database check';
|
$T_['DATABASE'] = 'Database check';
|
||||||
$T_['add_grp_to_add_chk'] = 'Add a group for start adding checks';
|
$T_['add_grp_to_add_chk'] = 'Add a group for start adding checks';
|
||||||
|
$T_['view_hist'] = 'View history';
|
||||||
?>
|
?>
|
||||||
@@ -37,4 +37,5 @@ $T_['HTTP_CODE'] = 'Código HTTP';
|
|||||||
$T_['VISIT_COUNT'] = 'Contador de visitas';
|
$T_['VISIT_COUNT'] = 'Contador de visitas';
|
||||||
$T_['DATABASE'] = 'Conexión a base de datos';
|
$T_['DATABASE'] = 'Conexión a base de datos';
|
||||||
$T_['add_grp_to_add_chk'] = 'Añade un grupo para empezar a añadir checks';
|
$T_['add_grp_to_add_chk'] = 'Añade un grupo para empezar a añadir checks';
|
||||||
|
$T_['view_hist'] = 'Ver histórico';
|
||||||
?>
|
?>
|
||||||
16
connect.php
16
connect.php
@@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
define('VERSION','0.9.1');
|
||||||
|
session_start(); //Session in all page
|
||||||
require_once "lib/dbwrapper.php";
|
require_once "lib/dbwrapper.php";
|
||||||
|
|
||||||
$db_file = __DIR__."/sqlite.db3";
|
$db_file = __DIR__."/sqlite.db3";
|
||||||
@@ -10,19 +12,17 @@ if (!is_file($db_file)){ //Go to install if not.
|
|||||||
$db_conn = dbw_connect("sqlite",$db_file); //Database
|
$db_conn = dbw_connect("sqlite",$db_file); //Database
|
||||||
|
|
||||||
/** In connect.php check if user SessionID exists, if not, delete Cookie */
|
/** In connect.php check if user SessionID exists, if not, delete Cookie */
|
||||||
if (isset($_COOKIE['SessionID'])){
|
if (isset($_SESSION['UserID'])){
|
||||||
$data = dbw_query_fetch_array($db_conn, "SELECT * FROM USERS WHERE SessionID='$_COOKIE[SessionID]'");
|
$data = dbw_query_fetch_array($db_conn, "SELECT * FROM USERS WHERE ID_U='$_SESSION[UserID]'");
|
||||||
if (!isset($data['SessionID'])){
|
if ($data['ID_U'] != $_SESSION['UserID']){
|
||||||
setcookie("SessionID", "", time()-3600,"/");
|
session_destroy();
|
||||||
header("Location: index.php");
|
header("Location: index.php");
|
||||||
}
|
}
|
||||||
|
|
||||||
$you['ID_U'] = $data['ID_U'];
|
$you['ID_U'] = $data['ID_U'];
|
||||||
$you['nick'] = $data['nick'];
|
$you['nick'] = $data['nick'];
|
||||||
$you['fullRights'] = $data['fullRights'];
|
$you['fullRights'] = $data['fullRights'];
|
||||||
$you['SessionID'] = $data['SessionID'];
|
|
||||||
$you['webRoot'] = webRoot();
|
$you['webRoot'] = webRoot();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$lang=getSystemOpt($db_conn,'lang');
|
$lang=getSystemOpt($db_conn,'lang');
|
||||||
@@ -30,4 +30,8 @@ $lang=getSystemOpt($db_conn,'lang');
|
|||||||
require_once __DIR__."/assets/translations/en.php"; //Ever first English, and then your lang (Database)
|
require_once __DIR__."/assets/translations/en.php"; //Ever first English, and then your lang (Database)
|
||||||
require_once __DIR__."/assets/translations/$lang.php";
|
require_once __DIR__."/assets/translations/$lang.php";
|
||||||
|
|
||||||
|
$ver=getSystemOpt($db_conn,'version');
|
||||||
|
if (getSystemOpt($db_conn,'version') != VERSION){
|
||||||
|
die("<p>Please run updater.php to update before using page");
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
14
cronchk.php
14
cronchk.php
@@ -72,16 +72,10 @@ while ($site = dbw_fetch_array($db_conn,$sites)){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Delete old Checks (Based on user input)
|
//Delete old Checks (Based on time to save, put in secs)
|
||||||
$sites = dbw_query($db_conn,"SELECT * FROM CHECKS");
|
$mintime = time()-(getSystemOpt($db_conn,"maxTimeSave")*24*3600);
|
||||||
while ($site = dbw_fetch_array($db_conn,$sites)){
|
dbw_query($db_conn,"DELETE FROM CHKHIST WHERE `timestamp` < $mintime");
|
||||||
$count = dbw_query_fetch_array($db_conn,"SELECT COUNT(*) FROM CHKHIST WHERE ID_C='$site[ID_C]'")[0]; //Count how much checks has a site
|
|
||||||
|
|
||||||
if ($count > getSystemOpt($db_conn,"maxChecksSave")){
|
|
||||||
$todelete = $count - getSystemOpt($db_conn,"maxChecksSave"); //How much to delete
|
|
||||||
dbw_query($db_conn, "DELETE FROM CHKHIST WHERE ID_C='$site[ID_C]' ORDER BY `timestamp` ASC LIMIT $todelete");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Delete Checks stored for pages that not exist
|
//Delete Checks stored for pages that not exist
|
||||||
dbw_query($db_conn, "DELETE FROM CHKHIST WHERE ID_C NOT IN (SELECT ID_C FROM CHECKS)");
|
dbw_query($db_conn, "DELETE FROM CHKHIST WHERE ID_C NOT IN (SELECT ID_C FROM CHECKS)");
|
||||||
|
|
||||||
|
|||||||
@@ -3,49 +3,31 @@
|
|||||||
require_once "connect.php";
|
require_once "connect.php";
|
||||||
require_once 'lib/loadTwig.php';
|
require_once 'lib/loadTwig.php';
|
||||||
|
|
||||||
/** Function checkStatus checks last "Checks" and their return
|
|
||||||
Return can be:
|
|
||||||
A value from 0-1-2 for status. 3 for Out Of Service. 3 and 4 can be turned up manually (
|
|
||||||
0-Perfect
|
|
||||||
1-Little problems
|
|
||||||
2-Problems
|
|
||||||
3-Out of service
|
|
||||||
4-In maintenance
|
|
||||||
255-Not results recolected (grey)
|
|
||||||
*/
|
|
||||||
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($db_conn,$ID_C);
|
|
||||||
//Return status
|
|
||||||
if ($result == 255){return 255;}
|
|
||||||
if ($result > 95 && $result <= 100){return 0;}
|
|
||||||
if ($result > 60 && $result <= 95){return 1;}
|
|
||||||
if ($result > 10 && $result <= 60){return 2;}
|
|
||||||
if ($result >= 0 && $result <= 10){return 3;} //If test fail much (90% fail)
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkUptime($db_conn,$ID_C,$precision = 0){
|
function checkUptime($db_conn,$ID_C,$precision = 0){
|
||||||
if ($precision == 0){
|
if ($precision == 0){
|
||||||
$time = time()-30*24*3600; //Last month
|
$time = time()-30*7*3600; //Last week
|
||||||
}else{
|
}else{
|
||||||
$time = $precision;
|
$time = $precision;
|
||||||
}
|
}
|
||||||
if ($precision != 0){
|
$res = dbw_query($db_conn,"SELECT code FROM CHKHIST WHERE ID_C='$ID_C' AND `timestamp` > $time");
|
||||||
$good = dbw_query_fetch_array($db_conn,"SELECT COUNT(*) FROM CHKHIST WHERE ID_C = '$ID_C' AND code == 0 AND `timestamp` > $time")[0];
|
$count = 0;
|
||||||
$all = dbw_query_fetch_array($db_conn,"SELECT COUNT(*) FROM CHKHIST WHERE ID_C = '$ID_C' AND `timestamp` > $time")[0];
|
$err = 0;
|
||||||
}else{ //Uptime of all time
|
while ($fila = dbw_fetch_array($db_conn,$res)){
|
||||||
$good = dbw_query_fetch_array($db_conn,"SELECT COUNT(*) FROM CHKHIST WHERE ID_C = '$ID_C' AND code == 0")[0];
|
$count++;
|
||||||
$all = dbw_query_fetch_array($db_conn,"SELECT COUNT(*) FROM CHKHIST WHERE ID_C = '$ID_C'")[0];
|
$err += $fila['code'];
|
||||||
}
|
}
|
||||||
if ($all != 0){
|
echo $count."-";
|
||||||
$uptime = round(($good/$all)*100,2);
|
if ($count == 0){
|
||||||
return $uptime;
|
return '-1'; //No registers
|
||||||
}else{
|
}else{
|
||||||
return 100;
|
if ($err != 0){
|
||||||
|
$uptime = (100 - round(($err/$count)*100,2));
|
||||||
|
return $uptime;
|
||||||
|
}else{
|
||||||
|
return 100;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -103,13 +85,12 @@ function RandomString($length)
|
|||||||
|
|
||||||
/** 1 if its logued, 0 if not */
|
/** 1 if its logued, 0 if not */
|
||||||
function isLogued(){
|
function isLogued(){
|
||||||
if (isset($_COOKIE['SessionID'])){
|
if (isset($_SESSION['UserID'])){
|
||||||
return 1;
|
return 1;
|
||||||
}else{
|
}else{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function requireLogin(){
|
function requireLogin(){
|
||||||
if (isLogued() == 0){
|
if (isLogued() == 0){
|
||||||
die('You dont have admin rights'); //This blocks edit or create nothing if its not logued
|
die('You dont have admin rights'); //This blocks edit or create nothing if its not logued
|
||||||
|
|||||||
23
index.php
23
index.php
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
$d_time = microtime(true);
|
||||||
require_once "functions.php";
|
require_once "functions.php";
|
||||||
|
|
||||||
$results = dbw_query($db_conn,"SELECT * FROM GROUPS"); //All groups
|
$results = dbw_query($db_conn,"SELECT * FROM GROUPS"); //All groups
|
||||||
@@ -21,20 +22,28 @@ while ($onechk = dbw_fetch_array($db_conn,$results)){
|
|||||||
case 2: //HttpCode
|
case 2: //HttpCode
|
||||||
case 4: //MySQL
|
case 4: //MySQL
|
||||||
|
|
||||||
if (dbw_query_fetch_array($db_conn, "SELECT COUNT(*) FROM CHKHIST WHERE ID_C = '$idchk'")[0] != 0){
|
if (dbw_query_fetch_array($db_conn, "SELECT COUNT(`ID_CHist`) FROM CHKHIST WHERE ID_C = '$idchk'")[0] != 0){
|
||||||
$chks[$idchk]['status'] = checkStatus($db_conn,$idchk); //Check status of a site
|
|
||||||
$chks[$idchk]['dateLastChk'] = date('d/m H:i',dbw_query_fetch_array($db_conn, "SELECT `timestamp` FROM CHKHIST WHERE ID_C = '$idchk' ORDER BY `timestamp` DESC")['timestamp']);
|
|
||||||
|
|
||||||
$chks[$idchk]['failedLastChk'] = dbw_query_fetch_array($db_conn, "SELECT `code` FROM CHKHIST WHERE ID_C = '$idchk' ORDER BY `timestamp` DESC LIMIT 0,1")['code'];
|
$consul = dbw_query_fetch_array($db_conn, "SELECT `code`,`timestamp` FROM CHKHIST WHERE ID_C = '$idchk' AND (select min(`timestamp`) FROM CHKHIST)");
|
||||||
|
$chks[$idchk]['dateLastChk'] = date('d/m H:i',$consul['timestamp']);
|
||||||
|
|
||||||
$lastErr = dbw_query_fetch_array($db_conn, "SELECT `timestamp` FROM CHKHIST WHERE ID_C = '$idchk' AND code != 0 ORDER BY `timestamp` DESC LIMIT 0,1")['timestamp']; //Record last error, for showing if there are any.
|
$chks[$idchk]['failedLastChk'] = $consul['code'];
|
||||||
|
|
||||||
|
$lastErr = dbw_query_fetch_array($db_conn, "SELECT MIN(`timestamp`) FROM CHKHIST WHERE ID_C = '$idchk' AND code != 0")[0]; //Record last error, for showing if there are any.
|
||||||
if ($lastErr != false){
|
if ($lastErr != false){
|
||||||
$chks[$idchk]['dateLastErr'] = date('d/m H:i',$lastErr);
|
$chks[$idchk]['dateLastErr'] = date('d/m H:i',$lastErr);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ID_TC = $chks[$idchk]['ID_TC'];
|
$ID_TC = $chks[$idchk]['ID_TC'];
|
||||||
$chks[$idchk]['nameCheck'] = textTypeChk($T_,$ID_TC);
|
$chks[$idchk]['nameCheck'] = textTypeChk($T_,$ID_TC);
|
||||||
$chks[$idchk]['uptime'] = checkUptime($db_conn,$ID_C);
|
|
||||||
|
if ($onechk['manStatus'] != ''){
|
||||||
|
$chks[$idchk]['uptime'] = 255;//255 = Maintenance I suppose, not implemented
|
||||||
|
}else{
|
||||||
|
$chks[$idchk]['uptime'] = checkUptime($db_conn,$idchk);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -75,5 +84,5 @@ while ($incident = dbw_fetch_array($db_conn,$incidents)){
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo $twig->render('indexpage.twig', array('T_' => $T_, 'you' => $you, 'checks' => $chks, 'news' => $incs)); //Render
|
echo $twig->render('indexpage.twig', array('T_' => $T_, 'you' => $you, 'checks' => $chks, 'news' => $incs)); //Render
|
||||||
|
echo "<p>Página creada en ".round(microtime(true)-$d_time,2)." segundos</p>";
|
||||||
?>
|
?>
|
||||||
10
install.php
10
install.php
@@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
$ver = '0.9';
|
define('VERSION','0.9.1');
|
||||||
//require "functions.php"; //THIS FILE CAN'T BE USED THERE, BECAUSE IT HAS connect.php dependence
|
|
||||||
require_once 'lib/loadTwig.php';
|
require_once 'lib/loadTwig.php';
|
||||||
|
|
||||||
$db_file = __DIR__."/sqlite.db3";
|
$db_file = __DIR__."/sqlite.db3";
|
||||||
@@ -12,7 +11,7 @@ if (!isset($_POST['websiteName']) && !isset($_POST['username']) && !isset($_POST
|
|||||||
echo $twig->render('install.twig');
|
echo $twig->render('install.twig');
|
||||||
}else{
|
}else{
|
||||||
if ($_POST['passw1'] !== $_POST['passw2']){
|
if ($_POST['passw1'] !== $_POST['passw2']){
|
||||||
die("NONO");
|
die("Passwords didn't match");
|
||||||
}else{
|
}else{
|
||||||
//Creamos toda la base de datos
|
//Creamos toda la base de datos
|
||||||
require_once "lib/dbwrapper.php"; //For using database
|
require_once "lib/dbwrapper.php"; //For using database
|
||||||
@@ -30,7 +29,6 @@ CREATE TABLE "USERS" (
|
|||||||
`ID_U` INTEGER PRIMARY KEY AUTOINCREMENT,
|
`ID_U` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
`nick` TEXT NOT NULL UNIQUE,
|
`nick` TEXT NOT NULL UNIQUE,
|
||||||
`passw` TEXT,
|
`passw` TEXT,
|
||||||
`SessionID` INTEGER UNIQUE,
|
|
||||||
`fullRights` INTEGER NOT NULL
|
`fullRights` INTEGER NOT NULL
|
||||||
);
|
);
|
||||||
CREATE TABLE "TOKENS" (
|
CREATE TABLE "TOKENS" (
|
||||||
@@ -78,10 +76,10 @@ COMMIT;';
|
|||||||
dbw_query($db_conn,"INSERT INTO USERS (nick,passw,fullRights) VALUES('$user','$pass',1)"); //Create user
|
dbw_query($db_conn,"INSERT INTO USERS (nick,passw,fullRights) VALUES('$user','$pass',1)"); //Create user
|
||||||
|
|
||||||
//System opts
|
//System opts
|
||||||
dbw_query($db_conn,"INSERT INTO SYS VALUES ('maxChecksSave',300)");
|
dbw_query($db_conn,"INSERT INTO SYS VALUES ('maxTimeSave',14)");
|
||||||
dbw_query($db_conn,"INSERT INTO SYS VALUES ('lang','$_POST[lang]')");
|
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 ('websiteTitle','Status')");
|
||||||
dbw_query($db_conn,"INSERT INTO SYS VALUES ('version','$ver')");
|
dbw_query($db_conn,"INSERT INTO SYS VALUES ('version','".VERSION."')");
|
||||||
|
|
||||||
echo $twig->render('install.twig', array('part' => 2));
|
echo $twig->render('install.twig', array('part' => 2));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,13 @@
|
|||||||
|
* 2.4.4 (2017-09-27)
|
||||||
|
|
||||||
|
* added Twig_Profiler_Profile::reset()
|
||||||
|
* fixed use TokenParser to return an empty Node
|
||||||
|
* added RuntimeExtensionInterface
|
||||||
|
* added circular reference detection when loading templates
|
||||||
|
* added support for runtime loaders in IntegrationTestCase
|
||||||
|
* fixed deprecation when using Twig_Profiler_Dumper_Html
|
||||||
|
* removed @final from Twig_Profiler_Dumper_Text
|
||||||
|
|
||||||
* 2.4.3 (2017-06-07)
|
* 2.4.3 (2017-06-07)
|
||||||
|
|
||||||
* fixed namespaces introduction
|
* fixed namespaces introduction
|
||||||
@@ -69,9 +79,17 @@
|
|||||||
* improved the performance of the filesystem loader
|
* improved the performance of the filesystem loader
|
||||||
* removed features that were deprecated in 1.x
|
* removed features that were deprecated in 1.x
|
||||||
|
|
||||||
* 1.34.4 (2017-XX-XX)
|
* 1.35.0 (2017-XX-XX)
|
||||||
|
|
||||||
* n/a
|
* added Twig_Profiler_Profile::reset()
|
||||||
|
* fixed use TokenParser to return an empty Node
|
||||||
|
* added RuntimeExtensionInterface
|
||||||
|
* added circular reference detection when loading templates
|
||||||
|
|
||||||
|
* 1.34.4 (2017-07-04)
|
||||||
|
|
||||||
|
* added support for runtime loaders in IntegrationTestCase
|
||||||
|
* fixed deprecation when using Twig_Profiler_Dumper_Html
|
||||||
|
|
||||||
* 1.34.3 (2017-06-07)
|
* 1.34.3 (2017-06-07)
|
||||||
|
|
||||||
@@ -212,7 +230,7 @@
|
|||||||
|
|
||||||
* fixed reserved keywords (forbids true, false, null and none keywords for variables names)
|
* fixed reserved keywords (forbids true, false, null and none keywords for variables names)
|
||||||
* fixed support for PHP7 (Throwable support)
|
* fixed support for PHP7 (Throwable support)
|
||||||
* marked the following methods as being internals on Twig_Environment:
|
* marked the following methods as being internals on Twig_Environment:
|
||||||
getFunctions(), getFilters(), getTests(), getFunction(), getFilter(), getTest(),
|
getFunctions(), getFilters(), getTests(), getFunction(), getFilter(), getTest(),
|
||||||
getTokenParsers(), getTags(), getNodeVisitors(), getUnaryOperators(), getBinaryOperators(),
|
getTokenParsers(), getTags(), getNodeVisitors(), getUnaryOperators(), getBinaryOperators(),
|
||||||
getFunctions(), getFilters(), getGlobals(), initGlobals(), initExtensions(), and initExtension()
|
getFunctions(), getFilters(), getGlobals(), initGlobals(), initExtensions(), and initExtension()
|
||||||
|
|||||||
@@ -16,11 +16,11 @@
|
|||||||
*/
|
*/
|
||||||
class Twig_Environment
|
class Twig_Environment
|
||||||
{
|
{
|
||||||
const VERSION = '2.4.3';
|
const VERSION = '2.4.4';
|
||||||
const VERSION_ID = 20403;
|
const VERSION_ID = 20404;
|
||||||
const MAJOR_VERSION = 2;
|
const MAJOR_VERSION = 2;
|
||||||
const MINOR_VERSION = 4;
|
const MINOR_VERSION = 4;
|
||||||
const RELEASE_VERSION = 3;
|
const RELEASE_VERSION = 4;
|
||||||
const EXTRA_VERSION = '';
|
const EXTRA_VERSION = '';
|
||||||
|
|
||||||
private $charset;
|
private $charset;
|
||||||
@@ -42,6 +42,7 @@ class Twig_Environment
|
|||||||
private $runtimeLoaders = array();
|
private $runtimeLoaders = array();
|
||||||
private $runtimes = array();
|
private $runtimes = array();
|
||||||
private $optionsHash;
|
private $optionsHash;
|
||||||
|
private $loading = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@@ -308,6 +309,10 @@ class Twig_Environment
|
|||||||
*
|
*
|
||||||
* @param string|Twig_TemplateWrapper|Twig_Template $name The template name
|
* @param string|Twig_TemplateWrapper|Twig_Template $name The template name
|
||||||
*
|
*
|
||||||
|
* @throws Twig_Error_Loader When the template cannot be found
|
||||||
|
* @throws Twig_Error_Runtime When a previously generated cache is corrupted
|
||||||
|
* @throws Twig_Error_Syntax When an error occurred during compilation
|
||||||
|
*
|
||||||
* @return Twig_TemplateWrapper
|
* @return Twig_TemplateWrapper
|
||||||
*/
|
*/
|
||||||
public function load($name)
|
public function load($name)
|
||||||
@@ -382,7 +387,19 @@ class Twig_Environment
|
|||||||
// to be removed in 3.0
|
// to be removed in 3.0
|
||||||
$this->extensionSet->initRuntime($this);
|
$this->extensionSet->initRuntime($this);
|
||||||
|
|
||||||
return $this->loadedTemplates[$cls] = new $cls($this);
|
if (isset($this->loading[$cls])) {
|
||||||
|
throw new Twig_Error_Runtime(sprintf('Circular reference detected for Twig template "%s", path: %s.', $name, implode(' -> ', array_merge($this->loading, array($name)))));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->loading[$cls] = $name;
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->loadedTemplates[$cls] = new $cls($this);
|
||||||
|
} finally {
|
||||||
|
unset($this->loading[$cls]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->loadedTemplates[$cls];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1430,8 +1430,6 @@ function twig_array_batch($items, $size, $fill = null)
|
|||||||
*/
|
*/
|
||||||
function twig_get_attribute(Twig_Environment $env, Twig_Source $source, $object, $item, array $arguments = array(), $type = Twig_Template::ANY_CALL, $isDefinedTest = false, $ignoreStrictCheck = false)
|
function twig_get_attribute(Twig_Environment $env, Twig_Source $source, $object, $item, array $arguments = array(), $type = Twig_Template::ANY_CALL, $isDefinedTest = false, $ignoreStrictCheck = false)
|
||||||
{
|
{
|
||||||
static $cache = array();
|
|
||||||
|
|
||||||
// array
|
// array
|
||||||
if (Twig_Template::METHOD_CALL !== $type) {
|
if (Twig_Template::METHOD_CALL !== $type) {
|
||||||
$arrayItem = is_bool($item) || is_float($item) ? (int) $item : $item;
|
$arrayItem = is_bool($item) || is_float($item) ? (int) $item : $item;
|
||||||
@@ -1518,6 +1516,8 @@ function twig_get_attribute(Twig_Environment $env, Twig_Source $source, $object,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static $cache = array();
|
||||||
|
|
||||||
$class = get_class($object);
|
$class = get_class($object);
|
||||||
|
|
||||||
// object method
|
// object method
|
||||||
|
|||||||
62
lib/Twig/lib/Twig/Profiler/Dumper/Base.php
Normal file
62
lib/Twig/lib/Twig/Profiler/Dumper/Base.php
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Twig.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
|
*/
|
||||||
|
abstract class Twig_Profiler_Dumper_Base
|
||||||
|
{
|
||||||
|
private $root;
|
||||||
|
|
||||||
|
public function dump(Twig_Profiler_Profile $profile)
|
||||||
|
{
|
||||||
|
return $this->dumpProfile($profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract protected function formatTemplate(Twig_Profiler_Profile $profile, $prefix);
|
||||||
|
|
||||||
|
abstract protected function formatNonTemplate(Twig_Profiler_Profile $profile, $prefix);
|
||||||
|
|
||||||
|
abstract protected function formatTime(Twig_Profiler_Profile $profile, $percent);
|
||||||
|
|
||||||
|
private function dumpProfile(Twig_Profiler_Profile $profile, $prefix = '', $sibling = false)
|
||||||
|
{
|
||||||
|
if ($profile->isRoot()) {
|
||||||
|
$this->root = $profile->getDuration();
|
||||||
|
$start = $profile->getName();
|
||||||
|
} else {
|
||||||
|
if ($profile->isTemplate()) {
|
||||||
|
$start = $this->formatTemplate($profile, $prefix);
|
||||||
|
} else {
|
||||||
|
$start = $this->formatNonTemplate($profile, $prefix);
|
||||||
|
}
|
||||||
|
$prefix .= $sibling ? '│ ' : ' ';
|
||||||
|
}
|
||||||
|
|
||||||
|
$percent = $this->root ? $profile->getDuration() / $this->root * 100 : 0;
|
||||||
|
|
||||||
|
if ($profile->getDuration() * 1000 < 1) {
|
||||||
|
$str = $start."\n";
|
||||||
|
} else {
|
||||||
|
$str = sprintf("%s %s\n", $start, $this->formatTime($profile, $percent));
|
||||||
|
}
|
||||||
|
|
||||||
|
$nCount = count($profile->getProfiles());
|
||||||
|
foreach ($profile as $i => $p) {
|
||||||
|
$str .= $this->dumpProfile($p, $prefix, $i + 1 !== $nCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class_alias('Twig_Profiler_Dumper_Base', 'Twig\Profiler\Dumper\BaseDumper', false);
|
||||||
|
class_exists('Twig_Profiler_Profile');
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
/**
|
/**
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
*/
|
*/
|
||||||
final class Twig_Profiler_Dumper_Html extends Twig_Profiler_Dumper_Text
|
final class Twig_Profiler_Dumper_Html extends Twig_Profiler_Dumper_Base
|
||||||
{
|
{
|
||||||
private static $colors = array(
|
private static $colors = array(
|
||||||
'block' => '#dfd',
|
'block' => '#dfd',
|
||||||
|
|||||||
@@ -11,18 +11,9 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
*
|
|
||||||
* @final
|
|
||||||
*/
|
*/
|
||||||
class Twig_Profiler_Dumper_Text
|
final class Twig_Profiler_Dumper_Text extends Twig_Profiler_Dumper_Base
|
||||||
{
|
{
|
||||||
private $root;
|
|
||||||
|
|
||||||
public function dump(Twig_Profiler_Profile $profile)
|
|
||||||
{
|
|
||||||
return $this->dumpProfile($profile);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function formatTemplate(Twig_Profiler_Profile $profile, $prefix)
|
protected function formatTemplate(Twig_Profiler_Profile $profile, $prefix)
|
||||||
{
|
{
|
||||||
return sprintf('%s└ %s', $prefix, $profile->getTemplate());
|
return sprintf('%s└ %s', $prefix, $profile->getTemplate());
|
||||||
@@ -37,36 +28,6 @@ class Twig_Profiler_Dumper_Text
|
|||||||
{
|
{
|
||||||
return sprintf('%.2fms/%.0f%%', $profile->getDuration() * 1000, $percent);
|
return sprintf('%.2fms/%.0f%%', $profile->getDuration() * 1000, $percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function dumpProfile(Twig_Profiler_Profile $profile, $prefix = '', $sibling = false)
|
|
||||||
{
|
|
||||||
if ($profile->isRoot()) {
|
|
||||||
$this->root = $profile->getDuration();
|
|
||||||
$start = $profile->getName();
|
|
||||||
} else {
|
|
||||||
if ($profile->isTemplate()) {
|
|
||||||
$start = $this->formatTemplate($profile, $prefix);
|
|
||||||
} else {
|
|
||||||
$start = $this->formatNonTemplate($profile, $prefix);
|
|
||||||
}
|
|
||||||
$prefix .= $sibling ? '│ ' : ' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$percent = $this->root ? $profile->getDuration() / $this->root * 100 : 0;
|
|
||||||
|
|
||||||
if ($profile->getDuration() * 1000 < 1) {
|
|
||||||
$str = $start."\n";
|
|
||||||
} else {
|
|
||||||
$str = sprintf("%s %s\n", $start, $this->formatTime($profile, $percent));
|
|
||||||
}
|
|
||||||
|
|
||||||
$nCount = count($profile->getProfiles());
|
|
||||||
foreach ($profile as $i => $p) {
|
|
||||||
$str .= $this->dumpProfile($p, $prefix, $i + 1 !== $nCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $str;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class_alias('Twig_Profiler_Dumper_Text', 'Twig\Profiler\Dumper\TextDumper', false);
|
class_alias('Twig_Profiler_Dumper_Text', 'Twig\Profiler\Dumper\TextDumper', false);
|
||||||
|
|||||||
@@ -149,6 +149,12 @@ class Twig_Profiler_Profile implements IteratorAggregate, Serializable
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function reset()
|
||||||
|
{
|
||||||
|
$this->starts = $this->ends = $this->profiles = array();
|
||||||
|
$this->enter();
|
||||||
|
}
|
||||||
|
|
||||||
public function getIterator()
|
public function getIterator()
|
||||||
{
|
{
|
||||||
return new ArrayIterator($this->profiles);
|
return new ArrayIterator($this->profiles);
|
||||||
|
|||||||
@@ -24,6 +24,14 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
|
|||||||
*/
|
*/
|
||||||
abstract protected function getFixturesDir();
|
abstract protected function getFixturesDir();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Twig_RuntimeLoaderInterface[]
|
||||||
|
*/
|
||||||
|
protected function getRuntimeLoaders()
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Twig_ExtensionInterface[]
|
* @return Twig_ExtensionInterface[]
|
||||||
*/
|
*/
|
||||||
@@ -143,6 +151,10 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
|
|||||||
), $match[2] ? eval($match[2].';') : array());
|
), $match[2] ? eval($match[2].';') : array());
|
||||||
$twig = new Twig_Environment($loader, $config);
|
$twig = new Twig_Environment($loader, $config);
|
||||||
$twig->addGlobal('global', 'global');
|
$twig->addGlobal('global', 'global');
|
||||||
|
foreach ($this->getRuntimeLoaders() as $runtimeLoader) {
|
||||||
|
$twig->addRuntimeLoader($runtimeLoader);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($this->getExtensions() as $extension) {
|
foreach ($this->getExtensions() as $extension) {
|
||||||
$twig->addExtension($extension);
|
$twig->addExtension($extension);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ final class Twig_TokenParser_Use extends Twig_TokenParser
|
|||||||
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
||||||
|
|
||||||
$this->parser->addTrait(new Twig_Node(array('template' => $template, 'targets' => new Twig_Node($targets))));
|
$this->parser->addTrait(new Twig_Node(array('template' => $template, 'targets' => new Twig_Node($targets))));
|
||||||
|
|
||||||
|
return new Twig_Node();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTag()
|
public function getTag()
|
||||||
|
|||||||
@@ -49,14 +49,20 @@ function dbw_escape_string($conn,$string){
|
|||||||
|
|
||||||
/** Make query */
|
/** Make query */
|
||||||
function dbw_query($conn,$query){
|
function dbw_query($conn,$query){
|
||||||
|
$time = microtime(true);
|
||||||
switch ($conn[1]){
|
switch ($conn[1]){
|
||||||
case "mysqli":
|
case "mysqli":
|
||||||
return mysqli_query($conn[0],$query);
|
$ret = mysqli_query($conn[0],$query);
|
||||||
|
break;
|
||||||
case "sqlite":
|
case "sqlite":
|
||||||
return $conn[0]->query($query);
|
$ret = $conn[0]->query($query);
|
||||||
|
break;
|
||||||
case "PgSQL":
|
case "PgSQL":
|
||||||
return pg_query($query); //Last error (pg_last_error()) not implemented
|
$ret = pg_query($query);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
//echo "<p>".$query."->".(microtime(true)-$time)." milisegundos</p>";
|
||||||
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Fetch array from query */
|
/** Fetch array from query */
|
||||||
@@ -83,23 +89,27 @@ function dbw_fetch_array($conn,$result,$typearray = NULL){
|
|||||||
|
|
||||||
/** Make query and fetch array */
|
/** Make query and fetch array */
|
||||||
function dbw_query_fetch_array($conn,$query){
|
function dbw_query_fetch_array($conn,$query){
|
||||||
|
$time = microtime(true);
|
||||||
|
|
||||||
switch ($conn[1]){
|
switch ($conn[1]){
|
||||||
case "mysqli":
|
case "mysqli":
|
||||||
$query = mysqli_query($conn[0],$query);
|
$result = mysqli_query($conn[0],$query);
|
||||||
if ($query == false || $query == NULL){return false;}
|
if (!$result){return false;}
|
||||||
return mysqli_fetch_array($query);
|
$ret = mysqli_fetch_array($result);
|
||||||
break;
|
break;
|
||||||
case "sqlite":
|
case "sqlite":
|
||||||
$query = $conn[0]->query($query);
|
$result = $conn[0]->query($query);
|
||||||
if ($query == false || $query == NULL){return false;}
|
if (!$result){return false;}
|
||||||
return $query->fetchArray();
|
$ret = $result->fetchArray();
|
||||||
break;
|
break;
|
||||||
case "PgSQL":
|
case "PgSQL":
|
||||||
$query = pg_query($query);
|
$result = pg_query($query);
|
||||||
if ($query == false || $query == NULL){return false;}
|
if (!$result){return false;}
|
||||||
return pg_fetch_array($query); //Last error (pg_last_error()) not implemented
|
$ret = pg_fetch_array($result); //Last error (pg_last_error()) not implemented
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
//echo "<p>".$query."->".(microtime(true)-$time)." milisegundos</p>";
|
||||||
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Goes a query to $row. $row starts in 0 as first row as if not specified */
|
/** Goes a query to $row. $row starts in 0 as first row as if not specified */
|
||||||
@@ -155,7 +165,8 @@ function dbw_num_rows($conn,$result){
|
|||||||
case "mysqli":
|
case "mysqli":
|
||||||
return mysqli_num_rows($result);
|
return mysqli_num_rows($result);
|
||||||
case "sqlite":
|
case "sqlite":
|
||||||
return $result->numRows();
|
die("Sqlite3 not supports numRows, use query with COUNT(*)");
|
||||||
|
return $result->numRows(); //ERROR
|
||||||
case "PgSQL":
|
case "PgSQL":
|
||||||
return pg_num_rows ($result);
|
return pg_num_rows ($result);
|
||||||
}
|
}
|
||||||
|
|||||||
16
login.php
16
login.php
@@ -4,13 +4,13 @@ require "functions.php";
|
|||||||
if (isset($_GET['do'])){
|
if (isset($_GET['do'])){
|
||||||
if ($_GET['do'] == 'logout'){
|
if ($_GET['do'] == 'logout'){
|
||||||
require_once "connect.php";
|
require_once "connect.php";
|
||||||
dbw_query($db_conn, "UPDATE USERS SET SessionID = NULL WHERE SessionID='$_COOKIE[SessionID]'");
|
//dbw_query($db_conn, "UPDATE USERS SET SessionID = NULL WHERE SessionID='$_COOKIE[SessionID]'");
|
||||||
setcookie("SessionID", "", time()-3600,"/");
|
session_destroy();
|
||||||
header('Location: index.php');
|
header('Location: index.php');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_COOKIE['SessionID'])){ //Ya está logueado
|
if (isset($_SESSION['UserID'])){ //Ya está logueado
|
||||||
header('Location: panel.php');
|
header('Location: panel.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,14 +20,12 @@ if (!isset($_POST['nick'])){
|
|||||||
if (isset($_POST['nick'])){
|
if (isset($_POST['nick'])){
|
||||||
$nick=$_POST['nick'];
|
$nick=$_POST['nick'];
|
||||||
$pass= hash("sha256",$_POST['pass']);
|
$pass= hash("sha256",$_POST['pass']);
|
||||||
$finalpass = dbw_query_fetch_array($db_conn,"SELECT `Passw` FROM `USERS` WHERE nick ='$nick'");
|
$resql = dbw_query_fetch_array($db_conn,"SELECT ID_U,`passw` FROM `USERS` WHERE nick ='$nick'");
|
||||||
$passcomprobar = $finalpass[0];
|
$passcomprobar = $resql['passw'];
|
||||||
if ($pass == $passcomprobar)
|
if ($pass == $passcomprobar)
|
||||||
{
|
{
|
||||||
$sesid = RandomString(12);
|
$_SESSION['UserID'] = $resql['ID_U'];
|
||||||
dbw_query($db_conn, "UPDATE USERS SET SessionID = '$sesid' WHERE nick = '$nick'");
|
header('Location: panel.php');
|
||||||
setcookie("SessionID",$sesid,"0","/");
|
|
||||||
header('Location: panel.php');
|
|
||||||
}else{
|
}else{
|
||||||
echo $twig->render('login.twig', array('status' => 'error'));
|
echo $twig->render('login.twig', array('status' => 'error'));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -208,7 +208,10 @@ switch($page){
|
|||||||
header('Location: panel.php?page=news');
|
header('Location: panel.php?page=news');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'savesettings':
|
||||||
|
//All group names and IDs
|
||||||
|
dbw_query($db_conn,"UPDATE SYS SET `value`='$_POST[name]' WHERE `option`='name'");
|
||||||
|
dbw_query($db_conn,"UPDATE SYS SET `value`='$_POST[maxTimeSave]' WHERE `option`='maxTimeSave'");
|
||||||
case 'settings':
|
case 'settings':
|
||||||
//All group names and IDs
|
//All group names and IDs
|
||||||
$results = dbw_query($db_conn,"SELECT * FROM SYS"); //All groups
|
$results = dbw_query($db_conn,"SELECT * FROM SYS"); //All groups
|
||||||
|
|||||||
21
updater.php
Normal file
21
updater.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
echo "<h2>Updater of CheckServer</h2>";
|
||||||
|
echo "<p>Connecting to database</p>";
|
||||||
|
require_once 'connect.php';
|
||||||
|
$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>";
|
||||||
|
switch ($version){
|
||||||
|
case '0.9':
|
||||||
|
echo "<p>0.9->0.9.1<p>";
|
||||||
|
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.
|
||||||
|
|
||||||
|
case '0.9.1':
|
||||||
|
echo "0.9.1-Lastest";
|
||||||
|
echo "<p>Updated to lastest. Close this and go to index</p>";
|
||||||
|
//Remove files on a good update
|
||||||
|
unlink('updater.php');
|
||||||
|
unlink('installer.php');
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user