Fixes #11.
THIS IS A BETA
This commit is contained in:
Matteo Gheza 2020-05-25 22:43:56 +02:00
parent d957ff4238
commit 106ac2fd17
34 changed files with 522 additions and 302 deletions

View File

@ -1,4 +1,4 @@
<?php
require_once 'ui.php';
loadtemplate('anagrafica.html', ['titolo' => 'Anagrafica utente', 'dacontrollare' => ucwords(str_replace('_', ' ', urldecode($_GET['utente'])))]);
loadtemplate('anagrafica.html', ['titolo' => 'Anagrafica user', 'dacontrollare' => ucwords(str_replace('_', ' ', urldecode($_GET['user'])))]);
?>

View File

@ -5,7 +5,8 @@
"require": {
"egulias/email-validator": "^2.1@dev",
"twig/twig": "3.x-dev",
"tracy/tracy": "^2.7@dev"
"tracy/tracy": "^2.7@dev",
"delight-im/auth": "dev-master"
},
"license": "GPL-3.0-or-later",
"authors": [
@ -30,4 +31,4 @@
"codecept run --steps"
]
}
}
}

203
server/composer.lock generated
View File

@ -4,8 +4,208 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "d6a8aab1a1d5715ce36bfd0fe62afbb2",
"content-hash": "d799678f904e87310cd45507a3d639f6",
"packages": [
{
"name": "delight-im/auth",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/delight-im/PHP-Auth.git",
"reference": "cc6430a83e5b6e4423e5237bfc7a8fd0ffa8dc39"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/delight-im/PHP-Auth/zipball/cc6430a83e5b6e4423e5237bfc7a8fd0ffa8dc39",
"reference": "cc6430a83e5b6e4423e5237bfc7a8fd0ffa8dc39",
"shasum": ""
},
"require": {
"delight-im/base64": "^1.0",
"delight-im/cookie": "^3.1",
"delight-im/db": "^1.3",
"ext-openssl": "*",
"php": ">=5.6.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Delight\\Auth\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Authentication for PHP. Simple, lightweight and secure.",
"homepage": "https://github.com/delight-im/PHP-Auth",
"keywords": [
"Authentication",
"auth",
"login",
"security"
],
"time": "2020-05-11T11:14:14+00:00"
},
{
"name": "delight-im/base64",
"version": "v1.0.0",
"source": {
"type": "git",
"url": "https://github.com/delight-im/PHP-Base64.git",
"reference": "687b2a49f663e162030a8d27b32838bbe7f91c78"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/delight-im/PHP-Base64/zipball/687b2a49f663e162030a8d27b32838bbe7f91c78",
"reference": "687b2a49f663e162030a8d27b32838bbe7f91c78",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Delight\\Base64\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Simple and convenient Base64 encoding and decoding for PHP",
"homepage": "https://github.com/delight-im/PHP-Base64",
"keywords": [
"URL-safe",
"base-64",
"base64",
"decode",
"decoding",
"encode",
"encoding",
"url"
],
"time": "2017-07-24T18:59:51+00:00"
},
{
"name": "delight-im/cookie",
"version": "v3.4.0",
"source": {
"type": "git",
"url": "https://github.com/delight-im/PHP-Cookie.git",
"reference": "67065d34272377d63bab0bd58f984f9b228c803f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/delight-im/PHP-Cookie/zipball/67065d34272377d63bab0bd58f984f9b228c803f",
"reference": "67065d34272377d63bab0bd58f984f9b228c803f",
"shasum": ""
},
"require": {
"delight-im/http": "^2.0",
"php": ">=5.4.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Delight\\Cookie\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Modern cookie management for PHP",
"homepage": "https://github.com/delight-im/PHP-Cookie",
"keywords": [
"cookie",
"cookies",
"csrf",
"http",
"same-site",
"samesite",
"xss"
],
"time": "2020-04-16T11:01:26+00:00"
},
{
"name": "delight-im/db",
"version": "v1.3.1",
"source": {
"type": "git",
"url": "https://github.com/delight-im/PHP-DB.git",
"reference": "7d6f4c7a7e8ba6a297bfc30d65702479fd0b5f7c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/delight-im/PHP-DB/zipball/7d6f4c7a7e8ba6a297bfc30d65702479fd0b5f7c",
"reference": "7d6f4c7a7e8ba6a297bfc30d65702479fd0b5f7c",
"shasum": ""
},
"require": {
"ext-pdo": "*",
"php": ">=5.6.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Delight\\Db\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Safe and convenient SQL database access in a driver-agnostic way",
"homepage": "https://github.com/delight-im/PHP-DB",
"keywords": [
"database",
"mysql",
"pdo",
"pgsql",
"postgresql",
"sql",
"sqlite"
],
"time": "2020-02-21T10:46:03+00:00"
},
{
"name": "delight-im/http",
"version": "v2.0.0",
"source": {
"type": "git",
"url": "https://github.com/delight-im/PHP-HTTP.git",
"reference": "0a19a72a7eac8b1301aa972fb20cff494ac43e09"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/delight-im/PHP-HTTP/zipball/0a19a72a7eac8b1301aa972fb20cff494ac43e09",
"reference": "0a19a72a7eac8b1301aa972fb20cff494ac43e09",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Delight\\Http\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Hypertext Transfer Protocol (HTTP) utilities for PHP",
"homepage": "https://github.com/delight-im/PHP-HTTP",
"keywords": [
"headers",
"http",
"https"
],
"time": "2016-07-21T15:05:01+00:00"
},
{
"name": "doctrine/lexer",
"version": "dev-master",
@ -4238,6 +4438,7 @@
"egulias/email-validator": 20,
"twig/twig": 20,
"tracy/tracy": 20,
"delight-im/auth": 20,
"codeception/codeception": 20
},
"prefer-stable": false,

View File

@ -206,27 +206,42 @@ class database{
$incrementa = implode(",", $incrementa);
bdump($incrementa);
$sql = "INSERT INTO `%PREFIX%_interventi` (`id`, `data`, `codice`, `uscita`, `rientro`, `capo`, `autisti`, `personale`, `luogo`, `note`, `tipo`, `incrementa`, `inseritoda`) VALUES (NULL, :data, :codice, :uscita, :rientro, :capo, :autisti, :personale, :luogo, :note, :tipo, :incrementa, :inseritoda);
UPDATE `%PREFIX%_users` SET `interventi`= interventi + 1 WHERE id IN (:incrementa);";
UPDATE `%PREFIX%_profiles` SET `interventi`= interventi + 1 WHERE id IN (:incrementa);";
$this->esegui($sql, false, [":data" => $data, ":codice" => $codice, "uscita" => $uscita, ":rientro" => $rientro, ":capo" => $capo, ":autisti" => $autisti, ":personale" => $personale, ":luogo" => $luogo, ":note" => $note, ":tipo" => $tipo, ":incrementa" => $incrementa, ":inseritoda" => $inseritoda]); // Non posso eseguire 2 query pdo con salvate le query nella classe dalla classe. Devo eseguirne 1 sola
}
}
final class Role {
//https://github.com/delight-im/PHP-Auth/blob/master/src/Role.php
const GUEST = \Delight\Auth\Role::AUTHOR;
const BASIC_VIEWER = \Delight\Auth\Role::COLLABORATOR;
const FULL_VIEWER = \Delight\Auth\Role::CONSULTANT;
const EDITOR = \Delight\Auth\Role::CONSUMER;
const SUPER_EDITOR = \Delight\Auth\Role::CONTRIBUTOR;
const DEVELOPER = \Delight\Auth\Role::DEVELOPER;
const TESTER = \Delight\Auth\Role::CREATOR;
const EXTERNAL_VIEWER = \Delight\Auth\Role::REVIEWER;
const ADMIN = \Delight\Auth\Role::ADMIN;
const SUPER_ADMIN = \Delight\Auth\Role::SUPER_ADMIN;
public function __construct() {}
}
class user{
private $database = null;
private $tools = null;
public $auth = null;
public function __construct($database, $tools){
$this->database = $database;
$this->tools = $tools;
$this->auth = new \Delight\Auth\Auth($database->connection, $tools->get_ip(), DB_PREFIX."_");
define("LOGIN", "OK");
}
public function autenticato(){
if(isset($_SESSION['accesso'])){
return true;
} else {
return false;
}
return $this->auth->isLoggedIn();
}
public function requirelogin(){
@ -244,40 +259,51 @@ class user{
}
}
public function admin(){
if(isset($_SESSION['admin'])){
if($_SESSION['admin'] == 1){
return true;
} else {
return false;
}
} else {
return false;
public function requireRole($role){
return $this->auth->hasRole($role);
}
}
public function nome($replace=false){
if(isset($_SESSION['nome'])){
public function name($replace=false){
if(isset($_SESSION['_user_name'])){
if($replace){
return str_replace(" ", "_", $_SESSION['nome']);
return str_replace(" ", "_", $_SESSION['_user_name']);
} else {
return $_SESSION['nome'];
return $_SESSION['_user_name'];
}
} else {
return "non autenticato";
}
}
public function nome_by_id($id){
$user = $this->database->esegui("SELECT nome FROM `%PREFIX%_users` WHERE id = :id;", true, [":id" => $id]);
if(empty($user)){
return false;
public function nameById($id){
$profiles = $this->database->esegui("SELECT `name` FROM `%PREFIX%_profiles` WHERE id = :id;", true, [":id" => $id]);
if(!empty($profiles)){
if(!is_null($profiles[0]["name"])){
return($profiles[0]["name"]);
} else {
$user = $this->database->esegui("SELECT `username` FROM `%PREFIX%_users` WHERE id = :id;", true, [":id" => $id]);
if(!empty($user)){
if(!is_null($user[0]["username"])){
return($user[0]["username"]);
} else {
return false;
}
} else {
return false;
}
}
} else {
return $user[0]["nome"];
return false;
}
}
public function avaible($nome){
$user = $this->database->esegui("SELECT avaible FROM `%PREFIX%_users` WHERE nome = :nome;", true, [":nome" => $nome]);
public function hidden(){
$profiles = $this->database->esegui("SELECT `name` FROM `%PREFIX%_profiles` WHERE hidden = 1;", true);
return $profiles;
}
public function avaible($name){
$user = $this->database->esegui("SELECT avaible FROM `%PREFIX%_users` WHERE name = :name;", true, [":name" => $name]);
if(empty($user)){
return false;
} else {
@ -285,58 +311,51 @@ class user{
}
}
public function whitelist($array = true, $str = ", "){
$array_data = array("test", "test2", "test3");
if($array){
return $array_data;
} else if(!$array){
return implode((string) $str, $array_data);
}
}
public function info(){
return array("nome" => $this->nome(), "admin" => $this->admin(), "codice" => "TODO", "tester" => $this->tester());
return array("id" => $this->auth->getUserId(), "name" => $this->name(), "full_viewer" => $this->requireRole(Role::FULL_VIEWER), "tester" => $this->requireRole(Role::TESTER), "developer" => $this->requireRole(Role::DEVELOPER));
}
public function tester($nome="questo"){
if($nome=="questo"){
$nome = $this->nome();
}
if(in_array($nome, $this->whitelist())){
return true;
} else {
return false;
}
}
public function dev($nome="questo"){
if($nome=="questo"){
$nome = $this->nome();
}
if(in_array($nome, $this->whitelist())){
return true;
} else {
return false;
}
}
public function login($nome, $password, $twofa=null){
if(!empty($nome)){
public function login($name, $password, $twofa=null){
if(!empty($name)){
if(!empty($password)){
$users = $this->database->esegui("SELECT * FROM `%PREFIX%_users` WHERE nome = :nome AND password = :password;", true, [":nome" => $nome, ":password" => $password]);
if(!empty($users)){
$_SESSION["accesso"] = "autenticato";
$_SESSION["nome"] = $users[0]["nome"];
$_SESSION["admin"] = $users[0]["caposquadra"];
return true;
//return $users;
} else {
return ["status" => "errore", "codice" => 003, "spiegazione" => "Dati di login non corretti"];
try {
$this->auth->loginWithUsername($name, $password);
}
catch (\Delight\Auth\InvalidEmailException $e) {
return ["status" => "error", "code" => 010, "text" => "Wrong email address"];
die('Wrong email address');
}
catch (\Delight\Auth\InvalidPasswordException $e) {
return ["status" => "error", "code" => 011, "text" => "Wrong password"];
die('Wrong password');
}
catch (\Delight\Auth\EmailNotVerifiedException $e) {
return ["status" => "error", "code" => 012, "text" => "Email not verified"];
die('Email not verified');
}
catch (\Delight\Auth\TooManyRequestsException $e) {
return ["status" => "error", "code" => 020, "text" => "Too many requests"];
die('Too many requests');
}
if($this->auth->isLoggedIn()){
$user = $this->database->esegui("SELECT * FROM `%PREFIX%_profiles` WHERE id = :id;", true, [":id" => $this->auth->getUserId()]);
if(!empty($user)){
if(is_null($user[0]["name"])){
$_SESSION['_user_name'] = $this->auth->getUsername();
} else {
$_SESSION['_user_name'] = $user[0]["name"];
}
$_SESSION['_user_hidden'] = $user[0]["hidden"];
$_SESSION['_user_disabled'] = $user[0]["disabled"];
$_SESSION['_user_caposquadra'] = $user[0]["caposquadra"];
return true;
}
}
} else {
return ["status" => "errore", "codice" => 002];
return ["status" => "error", "code" => 002];
}
} else {
return ["status" => "errore", "codice" => 001];
return ["status" => "error", "code" => 001];
}
}
public function log($azione, $subisce, $agisce, $data, $ora){
@ -345,27 +364,26 @@ class user{
$this->database->esegui($sql, false, $parametri);
}
public function lista($tutti=false){
$users = $this->database->esegui("SELECT * FROM `%PREFIX%_users`;", true);
}
public function logout(){
unset($_SESSION["accesso"]);
unset($_SESSION["nome"]);
unset($_SESSION["admin"]);
try {
$this->auth->destroySession();
}
catch (\Delight\Auth\NotLoggedInException $e) {
die('Not logged in');
}
}
}
function init_class(){
global $utente, $tools, $database;
if(!isset($utente) && !isset($tools) && !isset($database)){
global $user, $tools, $database;
if(!isset($user) && !isset($tools) && !isset($database)){
$tools = new tools();
$database = new database();
$utente = new user($database, $tools);
$user = new user($database, $tools);
}
if($utente->dev()){
//if($user->requireRole(Role::DEVELOPER)){
Debugger::enable(Debugger::DEVELOPMENT, __DIR__ . '/error-log');
} else {
Debugger::enable(Debugger::PRODUCTION, __DIR__ . '/error-log');
}
//} else {
//Debugger::enable(Debugger::PRODUCTION, __DIR__ . '/error-log');
//}
}

View File

@ -1,12 +1,11 @@
<?php
require_once 'ui.php';
if($utente->autenticato()){
if($user->autenticato()){
$tools->redirect("lista.php");
}
$errore = false;
if(isset($_POST['nome']) & isset($_POST['password'])){
$login = $utente->login($_POST['nome'], md5($_POST['password']));
//var_dump($login); exit;
if(isset($_POST['name']) & isset($_POST['password'])){
$login = $user->login($_POST['name'], $_POST['password']);
if($login===true){
$tools->redirect("lista.php");
} else {

File diff suppressed because one or more lines are too long

View File

@ -30,8 +30,8 @@ if (!file_exists("runInstall.php")) {
<h1 class="screen-reader-text">Prima di iniziare</h1>
<p>Benvenuto in Allerta. Prima di iniziare abbiamo bisogno di alcune informazioni sul database. Devi conoscere i seguenti dati prima di procedere.</p>
<ol>
<li>Nome del database</li>
<li>Nome utente del database</li>
<li>name del database</li>
<li>name user del database</li>
<li>Password del database</li>
<li>Host del database</li>
<li>Prefisso tabelle (se desideri eseguire più Allerta con un solo database)</li>
@ -59,14 +59,14 @@ if (!file_exists("runInstall.php")) {
$prefixValue = DB_PREFIX;
} catch (Exception $e) {
$dbnameValue = "allerta";
$unameValue = "utente";
$unameValue = "user";
$pwdValue = "password";
$dbhostValue = "localhost";
$prefixValue = "allerta01";
}
} else {
$dbnameValue = "allerta";
$unameValue = "utente";
$unameValue = "user";
$pwdValue = "password";
$dbhostValue = "localhost";
$prefixValue = "allerta01";
@ -78,14 +78,14 @@ if (!file_exists("runInstall.php")) {
<table class="form-table" role="presentation">
<tbody>
<tr>
<th scope="row"><label for="dbname">Nome database</label></th>
<th scope="row"><label for="dbname">name database</label></th>
<td><input name="dbname" id="dbname" type="text" aria-describedby="dbname-desc" size="25" value="<?php echo $dbnameValue; ?>" autofocus=""></td>
<td id="dbname-desc">Il nome del database che vuoi utilizzare con Allerta.</td>
<td id="dbname-desc">Il name del database che vuoi utilizzare con Allerta.</td>
</tr>
<tr>
<th scope="row"><label for="uname">Nome utente</label></th>
<th scope="row"><label for="uname">name user</label></th>
<td><input name="uname" id="uname" type="text" aria-describedby="uname-desc" size="25" value="<?php echo $unameValue; ?>"></td>
<td id="uname-desc">Il tuo nome utente del database.</td>
<td id="uname-desc">Il tuo name user del database.</td>
</tr>
<tr>
<th scope="row"><label for="pwd">Password</label></th>
@ -169,10 +169,10 @@ if (!file_exists("runInstall.php")) {
<table class="form-table" role="presentation">
<tbody>
<tr>
<th scope="row"><label for="user_login">Nome utente admin</label></th>
<th scope="row"><label for="user_login">name user admin</label></th>
<td>
<input name="user_name" type="text" id="user_login" size="75" value="">
<p>I nomi utente possono essere composti soltanto da caratteri alfanumerici, spazi, trattini bassi, trattini, punti e il simbolo @.</p>
<p>I nomi user possono essere composti soltanto da caratteri alfanumerici, spazi, trattini bassi, trattini, punti e il simbolo @.</p>
</td>
</tr>
<tr class="form-field form-required user-pass1-wrap">
@ -191,13 +191,13 @@ if (!file_exists("runInstall.php")) {
</td>
</tr>
<tr>
<th scope="row">Rendi utente admin visibile</th>
<th scope="row">Rendi user admin visibile</th>
<td>
<fieldset>
<legend class="screen-reader-text"><span>Rendi utente admin visibile </span></legend>
<legend class="screen-reader-text"><span>Rendi user admin visibile </span></legend>
<label for="admin_visible"><input name="admin_visible" type="checkbox" id="admin_visible" value="0">
Rendi l'utente admin visibile agli altri utente</label>
<p class="description">Attivando questa opzione, l'utente che verrà creato sarà visibile negli elenchi e nelle procedure.</p>
Rendi l'user admin visibile agli altri user</label>
<p class="description">Attivando questa opzione, l'user che verrà creato sarà visibile negli elenchi e nelle procedure.</p>
</fieldset>
</td>
</tr>

View File

@ -17,9 +17,9 @@ function checkConnection($host, $user, $password, $database){
$connectionOk = false;
?>
<div class="wp-die-message"><h1>Errore nello stabilire una connection al database</h1>
<p>Questo potrebbe voler dire che nome utente e password nel file <code>config.php</code> sono sbagliate o che non possiamo contattare il database <code><?php echo $database; ?></code>. Potrebbe voler dire che il tuo database è irraggiungibile.</p>
<p>Questo potrebbe voler dire che name user e password nel file <code>config.php</code> sono sbagliate o che non possiamo contattare il database <code><?php echo $database; ?></code>. Potrebbe voler dire che il tuo database è irraggiungibile.</p>
<ul>
<li>Sei sicuro di avere nome utente e password corretti?</li>
<li>Sei sicuro di avere name user e password corretti?</li>
<li>Sei sicuro di aver scritto l'hostname corretto?</li>
<li>Sei sicuro che il server del database sia attivo?</li>
</ul>
@ -44,11 +44,11 @@ function checkConnection($host, $user, $password, $database){
} catch (PDOException $e){
?>
<div class="wp-die-message"><h1>Impossibile selezionare il database</h1>
<p>Siamo riusciti a connetterci al server del database (il che significa che il tuo nome utente e password sono ok), ma non siamo riusciti a selezionare il database <code><?php echo $database; ?></code>.</p>
<p>Siamo riusciti a connetterci al server del database (il che significa che il tuo name user e password sono ok), ma non siamo riusciti a selezionare il database <code><?php echo $database; ?></code>.</p>
<ul>
<li>Sei sicuro che esista?</li>
<li>L'utente <code><?php echo $user; ?></code> ha i permessi per usare il database <code><?php echo $database; ?></code>?</li>
<li>In alcuni sistemi il nome del tuo database ha il tuo nome utente come prefisso, ovvero <code><?php echo $user; ?>_<?php echo $database; ?></code>. Potrebbe essere questo il problema?</li>
<li>L'user <code><?php echo $user; ?></code> ha i permessi per usare il database <code><?php echo $database; ?></code>?</li>
<li>In alcuni sistemi il name del tuo database ha il tuo name user come prefisso, ovvero <code><?php echo $user; ?>_<?php echo $database; ?></code>. Potrebbe essere questo il problema?</li>
</ul>
<p>Se non sei sicuro di cosa vogliano dire questi termini prova a contattare il tuo fornitore di hosting. Prova a fornire le seguenti informazioni:</p>
<details>
@ -126,7 +126,7 @@ function initDB(){
CREATE TABLE IF NOT EXISTS `".$prefix."_certificati` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`codice` text NOT NULL,
`nome` text NOT NULL,
`name` text NOT NULL,
`interventi` text NOT NULL,
`url` text NOT NULL,
`file` text NOT NULL,
@ -135,7 +135,7 @@ PRIMARY KEY (`id`)
CREATE TABLE IF NOT EXISTS `".$prefix."_esercitazioni` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`data` date NOT NULL,
`nome` varchar(999) NOT NULL,
`name` varchar(999) NOT NULL,
`inizio` time NOT NULL,
`fine` time NOT NULL,
`personale` text NOT NULL,
@ -191,31 +191,84 @@ PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `".$prefix."_tipo` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nome` text NOT NULL,
`name` text NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `nometipologia` (`nome`(99))
UNIQUE KEY `nametipologia` (`name`(99))
)ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `".$prefix."_users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`role` INT(50) NOT NULL DEFAULT '0',
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`email` varchar(249) COLLATE utf8mb4_unicode_ci NOT NULL,
`password` varchar(255) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
`username` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`status` tinyint(2) unsigned NOT NULL DEFAULT '0',
`verified` tinyint(1) unsigned NOT NULL DEFAULT '0',
`resettable` tinyint(1) unsigned NOT NULL DEFAULT '1',
`roles_mask` int(10) unsigned NOT NULL DEFAULT '0',
`registered` int(10) unsigned NOT NULL,
`last_login` int(10) unsigned DEFAULT NULL,
`force_logout` mediumint(7) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `Id` (`id`),
UNIQUE KEY `email` (`email`)
)ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `".$prefix."_profiles` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`hidden` BOOLEAN NOT NULL DEFAULT FALSE,
`disabled` BOOLEAN NOT NULL DEFAULT FALSE,
`nome` text CHARACTER SET utf8 NOT NULL,
`name` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`avaible` tinyint(1) NOT NULL DEFAULT 0,
`caposquadra` tinyint(1) NOT NULL DEFAULT 0,
`autista` tinyint(1) NOT NULL DEFAULT 0,
`telefono` varchar(25) DEFAULT NULL,
`password` varchar(200) NOT NULL,
`password_hash` varchar(2000) NOT NULL,
`interventi` int(11) NOT NULL DEFAULT 0,
`esercitazioni` int(11) NOT NULL,
`esercitazioni` int(11) NOT NULL DEFAULT 0,
`online` tinyint(1) NOT NULL DEFAULT 0,
`online_time` int(11) NOT NULL,
`minuti_dispo` int(11) NOT NULL,
`immagine` varchar(1000) NOT NULL,
`online_time` int(11) NOT NULL DEFAULT 0,
`minuti_dispo` int(11) NOT NULL DEFAULT 0,
`immagine` varchar(1000) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `Id` (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `".$prefix."_users_confirmations` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(10) unsigned NOT NULL,
`email` varchar(249) COLLATE utf8mb4_unicode_ci NOT NULL,
`selector` varchar(16) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
`token` varchar(255) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
`expires` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `selector` (`selector`),
KEY `email_expires` (`email`,`expires`),
KEY `user_id` (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS `".$prefix."_users_remembered` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`user` int(10) unsigned NOT NULL,
`selector` varchar(24) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
`token` varchar(255) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
`expires` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `selector` (`selector`),
KEY `user` (`user`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS `".$prefix."_users_resets` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`user` int(10) unsigned NOT NULL,
`selector` varchar(20) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
`token` varchar(255) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
`expires` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `selector` (`selector`),
KEY `user_expires` (`user`,`expires`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS `".$prefix."_users_throttling` (
`bucket` varchar(44) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
`tokens` float unsigned NOT NULL,
`replenished_at` int(10) unsigned NOT NULL,
`expires_at` int(10) unsigned NOT NULL,
PRIMARY KEY (`bucket`),
KEY `expires_at` (`expires_at`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS `".$prefix."_options` (
`id` INT NOT NULL AUTO_INCREMENT,
`name` TEXT NOT NULL, `value` MEDIUMTEXT NOT NULL,
@ -237,7 +290,7 @@ INSERT INTO `".$prefix."_dbversion` (`id`, `version`, `timestamp`) VALUES (NULL,
} catch (Exception $e) {
?>
<div class="wp-die-message"><h1>Impossibile creare le tabelle</h1>
<p>Siamo riusciti a connetterci al server del database (il che significa che il tuo nome utente e password sono ok), ma non siamo riusciti a creare le tabelle.</p>
<p>Siamo riusciti a connetterci al server del database (il che significa che il tuo name user e password sono ok), ma non siamo riusciti a creare le tabelle.</p>
<p>Se non sei sicuro di cosa vogliano dire questi termini prova a contattare il tuo fornitore di hosting. Prova a fornire le seguenti informazioni:</p>
<details>
<summary>Informazioni avanzate</summary>
@ -255,20 +308,20 @@ function initOptions($name, $visible, $password, $report_email, $owner){
require_once "../config.php";
$connection = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME, DB_USER, DB_PASSWORD,[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
$prefix = DB_PREFIX;
$auth = new \Delight\Auth\Auth($connection, $_SERVER['REMOTE_ADDR'], $prefix."_");
$userId = $auth->register($report_email, $password, $name);
$auth->admin()->addRoleForUserById($userId, Role::SUPER_ADMIN);
$prep = $connection->prepare("
INSERT INTO `".$prefix."_users` (`id`, `role`, `hidden`, `disabled`, `nome`, `avaible`, `caposquadra`, `autista`, `telefono`, `password`, `password_hash`, `interventi`, `esercitazioni`, `online`, `online_time`, `minuti_dispo`, `immagine`) VALUES ('1', '5', :hidden, '0', :name, '0', '1', '0', NULL, MD5(:password), '', '0', '0', '0', '0', '0', '');
INSERT INTO `".$prefix."_profiles` (`id`) VALUES (NULL);
INSERT INTO `".$prefix."_options` (`id`, `name`, `value`, `enabled`, `created_time`, `last_edit`, `user_id`) VALUES ('1', 'report_email', :report_email, '1', current_timestamp(), current_timestamp(), '1');
INSERT INTO `".$prefix."_options` (`id`, `name`, `value`, `enabled`, `created_time`, `last_edit`, `user_id`) VALUES ('2', 'owner', :owner, '1', current_timestamp(), current_timestamp(), '1');");
$prep->bindParam(':name', $name, PDO::PARAM_STR);
$prep->bindParam(':hidden', $visible, PDO::PARAM_INT);
$prep->bindParam(':password', $password, PDO::PARAM_STR);
$prep->bindParam(':report_email', $report_email, PDO::PARAM_STR);
$prep->bindParam(':owner', $owner, PDO::PARAM_STR);
$prep->execute();
} catch (Exception $e) {
?>
<div class="wp-die-message"><h1>Impossibile riempire le tabelle</h1>
<p>Siamo riusciti a connetterci al server del database (il che significa che il tuo nome utente e password sono ok), ma non siamo riusciti a riempire le tabelle.</p>
<p>Siamo riusciti a connetterci al server del database (il che significa che il tuo name user e password sono ok), ma non siamo riusciti a riempire le tabelle.</p>
<p>Se non sei sicuro di cosa vogliano dire questi termini prova a contattare il tuo fornitore di hosting. Prova a fornire le seguenti informazioni:</p>
<details>
<summary>Informazioni avanzate</summary>

View File

@ -1,3 +0,0 @@
<?php
return true;
?>

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
<?php
include("core.php");
init_class();
$utente->logout();
$user->logout();
$tools->redirect("index.php");
?>

View File

@ -13,13 +13,13 @@ include_once 'core.php';
init_class();
function resetminuti(){
global $users_tot;
global $profiles_tot;
global $database;
$sql = "SELECT * FROM %PREFIX%_users"; // Pesco i dati della tabella e li ordino in base alla disponibilità
$sql = "SELECT * FROM %PREFIX%_profiles"; // Pesco i dati della tabella e li ordino in base alla disponibilità
$risultato = $database->esegui($sql, true);
$disp = array();
foreach($risultato as $row){
$disp[$row['nome']] = $row['minuti_dispo'];
$disp[$row['name']] = $row['minuti_dispo'];
}
print("<br><pre>" . print_r($disp, true) . "</pre><br>");
@ -42,9 +42,9 @@ function resetminuti(){
$risultato = $database->esegui($sql);
foreach($risultato as $row){
$sql = "UPDATE %PREFIX%_users SET minuti_dispo = '0' WHERE nome ='" . $utente . "'";
$sql = "UPDATE %PREFIX%_profiles SET minuti_dispo = '0' WHERE name ='" . $user . "'";
$risultato = $database->esegui($sql);
echo "reset effettuato: " . $utente . "<br>";
echo "reset effettuato: " . $user . "<br>";
}
if($risultato){
@ -68,16 +68,16 @@ function array_combine_($keys, $values){
//print("<br><pre>" . print_r(array_combine_(explode(" - ", $a1), explode(" - ", $a2)), true) . "</pre><br>");
$sql = "SELECT * FROM %PREFIX%_users ORDER BY avaible DESC, caposquadra DESC, interventi ASC, nome ASC"; // Pesco i dati della tabella e li ordino in base alla disponibilità
$sql = "SELECT * FROM %PREFIX%_profiles ORDER BY avaible DESC, caposquadra DESC, interventi ASC, name ASC"; // Pesco i dati della tabella e li ordino in base alla disponibilità
$risultato = $database->esegui($sql, true);
$users_tot = array();
$profiles_tot = array();
$incremento = array();
$minuti_dispo_old = array();
foreach($risultato as $row){
$users_tot[] = $row['nome'];
$profiles_tot[] = $row['name'];
if($row['avaible'] == "1"){
$incremento[] = $row['nome'];
$incremento[] = $row['name'];
$minuti_dispo_old[] = $row['minuti_dispo'];
}
}
@ -88,12 +88,12 @@ if($start && isset($_POST['reset']) && $_POST['reset'] == "cron-job"){
resetminuti();
}
foreach($incremento as $key=>$utente){
foreach($incremento as $key=>$user){
$minuti_dispo = $minuti_dispo_old[$key] + $minuti;
$sql = "UPDATE %PREFIX%_users SET minuti_dispo = '" . $minuti_dispo . "' WHERE nome ='" . $utente . "'";
$sql = "UPDATE %PREFIX%_profiles SET minuti_dispo = '" . $minuti_dispo . "' WHERE name ='" . $user . "'";
$risultato = $database->esegui($sql, true);
}
$sql = "SELECT * FROM %PREFIX%_users ORDER BY avaible DESC, caposquadra DESC, interventi ASC, nome ASC"; // Pesco i dati della tabella e li ordino in base alla disponibilità
$sql = "SELECT * FROM %PREFIX%_profiles ORDER BY avaible DESC, caposquadra DESC, interventi ASC, name ASC"; // Pesco i dati della tabella e li ordino in base alla disponibilità
$risultato = $database->esegui($sql, true);
$minuti_dispo = array();
foreach($risultato as $row){

View File

@ -5,7 +5,7 @@ if($tools->validazione_form('$post-mod', true, "aggiungi")) {
if($tools->validazione_form(['$post-data', '$post-codice', '$post-uscita', '$post-rientro', '$post-capo', '$post-luogo', '$post-note', '$post-tipo', '$post-token'])) {
if($_POST["token"] == $_SESSION['token']){
bdump("aggiungo intervento");
$database->aggiungi_intervento($_POST["data"], $_POST["codice"], $_POST["uscita"], $_POST["rientro"], $_POST["capo"], $tools->extract_unique($_POST["autisti"]), $tools->extract_unique($_POST["personale"]), $_POST["luogo"], $_POST["note"], $_POST["tipo"], $tools->extract_unique([$_POST["capo"],$_POST["autisti"],$_POST["personale"]]), $utente->nome());
$database->aggiungi_intervento($_POST["data"], $_POST["codice"], $_POST["uscita"], $_POST["rientro"], $_POST["capo"], $tools->extract_unique($_POST["autisti"]), $tools->extract_unique($_POST["personale"]), $_POST["luogo"], $_POST["note"], $_POST["tipo"], $tools->extract_unique([$_POST["capo"],$_POST["autisti"],$_POST["personale"]]), $user->name());
} else {
$tools->redirect("nonfareilfurbo.php");
}
@ -34,8 +34,8 @@ if($tools->validazione_form('$post-mod', true, "aggiungi")) {
$_SESSION['token'] = substr(base_convert(sha1(uniqid(mt_rand())), 16, 36), 0, $length) . "-bfwp64GGbdm";
// 1 hour = 60 seconds * 60 minutes = 3600
$_SESSION['token-expire'] = time() + 3600;
$personale = $database->esegui("SELECT * FROM `%PREFIX%_users` ORDER BY nome ASC", true); // Pesco i dati della tabella e li ordino in base al nome
$tipologie = $database->esegui("SELECT nome FROM `%PREFIX%_tipo` ORDER BY nome ASC", true); // Pesco le tipologie della tabella
$personale = $database->esegui("SELECT * FROM `%PREFIX%_profiles` ORDER BY name ASC", true); // Pesco i dati della tabella e li ordino in base al name
$tipologie = $database->esegui("SELECT name FROM `%PREFIX%_tipo` ORDER BY name ASC", true); // Pesco le tipologie della tabella
$modalità = (isset($_GET["aggiungi"])) ? "aggiungi" : ((isset($_GET["modifica"])) ? "modifica" : ((isset($_GET["elimina"])) ? "elimina" : "aggiungi"));
bdump($modalità, "modalità");
bdump($tipologie, "tipologie");
@ -52,7 +52,7 @@ if($tools->validazione_form('$post-mod', true, "aggiungi")) {
$tools->redirect("nonfareilfurbo.php");
}
}
loadtemplate('modifica_intervento.html', ['intervento' => array('id' => $id, 'token' => $_SESSION['token'], 'modalità' => $modalità, 'personale' => $personale, 'tipologie' => $tipologie), 'titolo' => ucfirst($modalità) . ' intervento', 'owner' => 'VVF Darfo', 'urlsoftware' => '', 'utente' => $utente->info()]);
loadtemplate('modifica_intervento.html', ['intervento' => array('id' => $id, 'token' => $_SESSION['token'], 'modalità' => $modalità, 'personale' => $personale, 'tipologie' => $tipologie), 'titolo' => ucfirst($modalità) . ' intervento', 'owner' => 'VVF Darfo', 'urlsoftware' => '', 'user' => $user->info()]);
bdump($_SESSION['token'], "token");
}
?>

View File

@ -2,7 +2,7 @@
include_once 'core.php';
init_class();
if(isset($_SESSION)){
$user = $_SESSION['nome'];
$user = $user->name();
} else {
$user = "test";
}
@ -14,7 +14,7 @@ function onLine() {
console.log(ciao);
console.log("onLine");
var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://62.171.139.86/allerta/online_check.php?utente=$user');
xhr.open('GET', 'http://62.171.139.86/allerta/online_check.php?user=$user');
xhr.onload = function () {
if (xhr.status === 200) {
console.log('Text ' + xhr.responseText);

View File

@ -7,15 +7,15 @@ include_once 'core.php';
init_class();
$sql = "SELECT nome, online, online_time FROM `%PREFIX%_users`";
$sql = "SELECT name, online, online_time FROM `%PREFIX%_profiles`";
$risultato = $database->esegui($sql, true);
var_dump($risultato);
foreach($risultato as $row){
print("<pre>" . print_r($row, true) . "</pre>");
}
if(isset($_GET) && !is_null($_GET['utente'])){
$sql = "UPDATE `%PREFIX%_users` SET online = '1', online_time = '$minuti' WHERE nome = '" . urldecode($_GET['utente']) . "'";
if(isset($_GET) && !is_null($_GET['user'])){
$sql = "UPDATE `%PREFIX%_profiles` SET online = '1', online_time = '$minuti' WHERE name = '" . urldecode($_GET['user']) . "'";
$risultato = $database->esegui($sql, true);
var_dump($risultato);
}

View File

@ -1,12 +1,12 @@
<?php
include_once '../../core.php';
init_class();
$utente->requirelogin();
if(isset($_POST["nomeutenteattivato"]) && isset($_POST["nomeutenteattivatore"]) && $_POST["dispo"] == 1) {
$risultato = $database->esegui("UPDATE `%PREFIX%_users` SET avaible = 1 WHERE nome = :nome", false, [":nome" => $_POST["nomeutenteattivato"]]);
$utente->log("Attivazione disponibilita'", $_POST["nomeutenteattivato"], $_POST["nomeutenteattivatore"], date("d/m/Y"), date("H:i.s"));
} else if(isset($_POST["nomeutenteattivato"]) && isset($_POST["nomeutenteattivatore"]) && $_POST["dispo"] == 0){
$risultato = $database->esegui("UPDATE `%PREFIX%_users` SET avaible = 0 WHERE nome = :nome", false, [":nome" => $_POST["nomeutenteattivato"]]);
$utente->log("Rimozione disponibilita'", $_POST["nomeutenteattivato"], $_POST["nomeutenteattivatore"], date("d/m/Y"), date("H:i.s"));
$user->requirelogin();
if(isset($_POST["change_id"]) && $_POST["dispo"] == 1){
$risultato = $database->esegui("UPDATE `%PREFIX%_profiles` SET `avaible` = '1' WHERE `allerta04_profiles`.`id` = :id;", false, [":id" => $_POST["change_id"]]);
$user->log("Attivazione disponibilita'", $_POST["change_id"], $user->name(), date("d/m/Y"), date("H:i.s"));
} else if(isset($_POST["change_id"]) && $_POST["dispo"] == 0){
$risultato = $database->esegui("UPDATE `%PREFIX%_profiles` SET `avaible` = '0' WHERE `allerta04_profiles`.`id` = :id;", false, [":id" => $_POST["change_id"]]);
$user->log("Rimozione disponibilita'", $_POST["change_id"], $user->name(), date("d/m/Y"), date("H:i.s"));
}
?>

View File

@ -1,11 +1,11 @@
<?php
include_once("../../core.php");
init_class();
$utente->requirelogin();
$user->requirelogin();
$risultato = $database->esegui('SELECT * FROM `%PREFIX%_users` WHERE id = :id', true, array(":id" => $_GET['utente'])); // Pesco i dati della tabella
$risultato = $database->esegui('SELECT * FROM `%PREFIX%_profiles` WHERE id = :id', true, array(":id" => $_GET['user'])); // Pesco i dati della tabella
$whitelist = $utente->whitelist();
$hidden = $user->hidden();
?>
<style>/*
* Bootstrap v2.2.1
@ -315,13 +315,13 @@ function vero1($text, $img1 = "", $img2 = ""){
}
//var_dump($risultato);
foreach($risultato as $row){
$nome = ($row['online']==1) ? '<u>' . $row['nome'] . "</u>" : $row['nome'];
echo("<h1>Dati anagrafici <b>$nome</b></h1><br><br>");
$name = ($row['online']==1) ? '<u>' . $row['name'] . "</u>" : $row['name'];
echo("<h1>Dati anagrafici <b>$name</b></h1><br><br>");
echo('<img alt="VVF" src="./risorse/images/distaccamento.png" width="150" class="img-resposive"><br><br><br>');
$disp = vero1($row['avaible'], "<i class='fa fa-check' style='color:green' width='22px'></i>", "<i class='fa fa-times' style='color:red' width='22px'></i>");
$caposquadra = vero1($row['caposquadra'], "<img src='./risorse/images/cascoRosso.png' width='22px'>", "<img src='./risorse/images/cascoNero.png' width='22px'>");
$autista = vero1($row['autista'], "<img src='./risorse/images/volante.png' width='22px'>");
echo("<p>Nome: <b>$nome</b></p><br>");
echo("<p>name: <b>$name</b></p><br>");
echo("<p>Disponibilità: <b>{$disp}</b></p><br>");
echo("<p>Caposquadra: <b>{$caposquadra}</b></p><br>");
echo("<p>Autista: <b>{$autista}</b></p><br>");

View File

@ -1,9 +1,9 @@
<?php
include_once("../../core.php");
init_class();
$utente->requirelogin();
$user->requirelogin();
$users_sql = "SELECT `id`, `nome`, `avaible`, `caposquadra`, `autista`, `telefono`, `interventi`, `esercitazioni`, `online`, `minuti_dispo`, `immagine` FROM `%PREFIX%_users` LIMIT 0 , 30";
$users_sql = "SELECT `id`, `name`, `avaible`, `caposquadra`, `autista`, `telefono`, `interventi`, `esercitazioni`, `online`, `minuti_dispo`, `immagine` FROM `%PREFIX%_profiles` LIMIT 0 , 30";
$users = $database->esegui($users_sql, true);
$interventi_sql="SELECT * FROM `%PREFIX%_interventi` ORDER BY `interventi`.`id` DESC LIMIT 0 , 30";

View File

@ -3,16 +3,16 @@ $start = true;
$minuti = 5;
include_once "../../core.php";
init_class();
$utente->requirelogin();
$user->requirelogin();
function arraynum(){
global $database;
$risultato = $database->esegui("SELECT * FROM `%PREFIX%_users` ORDER BY avaible DESC, caposquadra DESC, interventi ASC, nome ASC", true); // Pesco i dati della tabella e li ordino in base alla disponibilità
$risultato = $database->esegui("SELECT * FROM `%PREFIX%_profiles` ORDER BY avaible DESC, caposquadra DESC, interventi ASC, name ASC", true); // Pesco i dati della tabella e li ordino in base alla disponibilità
$incremento = array();
$minuti_dispo_old = array();
foreach($risultato as $row){
if($row['avaible'] == "1"){
$incremento[] = $row['nome'];
$incremento[] = $row['name'];
$minuti_dispo_old[] = $row['minuti_dispo'];
}
}
@ -20,13 +20,13 @@ foreach($risultato as $row){
return $incremento;
}
if(!isset($_GET['nome'])){
if(!isset($_GET['name'])){
print_r(arraynum());
} else {
if(isset($_GET['nome'])){
if(isset($_GET['name'])){
$arr = arraynum();
$nome = str_replace("_", " ", $_GET['nome']);
if(in_array($nome, $arr)){
$name = str_replace("_", " ", $_GET['name']);
if(in_array($name, $arr)){
echo "si";
} else {
echo "no";

View File

@ -1,7 +1,7 @@
<?php
include_once("../../core.php");
init_class();
$utente->requirelogin();
$user->requirelogin();
function ancora($content, $id) {
$content = substr($content,0,$limit);
@ -77,7 +77,7 @@ $risultato = $database->esegui("SELECT * FROM `%PREFIX%_esercitazioni` ORDER BY
<thead>
<tr>
<th>Data</th>
<th>Nome</th>
<th>name</th>
<th>Ora inizio</th>
<th>Ora fine</th>
<th>Capo</th>
@ -92,9 +92,9 @@ $risultato = $database->esegui("SELECT * FROM `%PREFIX%_esercitazioni` ORDER BY
<?php
foreach($risultato as $row){
$persone = base64_encode( $row['dec'] );
echo "<tr><td>" . $row['data'] . "</td><td>" . $row['nome'] . "</td><td>" . $row['inizio'] . "</td><td>" . $row['fine'] . "</td><td>" . $row['capo'] . "</td><td>" . $row['personale'] . "</td><td>" . $row['luogo'] . "</td><td>" . $row['note'] . "</td>";
echo "<tr><td>" . $row['data'] . "</td><td>" . $row['name'] . "</td><td>" . $row['inizio'] . "</td><td>" . $row['fine'] . "</td><td>" . $row['capo'] . "</td><td>" . $row['personale'] . "</td><td>" . $row['luogo'] . "</td><td>" . $row['note'] . "</td>";
if($impostazioni['modifica']) {
echo "<td><a href='modifica.php?modifica&id={$row['id']}&data={$row['data']}&nome={$row['nome']}&inizio={$row['inizio']}&fine={$row['fine']}&luogo={$row['luogo']}&note={$row['note']}'><i style='font-size: 40px' class='fa fa-edit'></i></a></td>";
echo "<td><a href='modifica.php?modifica&id={$row['id']}&data={$row['data']}&name={$row['name']}&inizio={$row['inizio']}&fine={$row['fine']}&luogo={$row['luogo']}&note={$row['note']}'><i style='font-size: 40px' class='fa fa-edit'></i></a></td>";
}
if($impostazioni['elimina']) {
echo "<td><a href='modifica.php?elimina&id={$row['id']}&persone={$persone}'><i style='font-size: 40px' class='fa fa-trash'></i></a></td></tr>";

View File

@ -1,7 +1,7 @@
<?php
include_once("../../core.php");
init_class();
$utente->requirelogin();
$user->requirelogin();
function ancora($content, $id) {
$content = substr($content,0,$limit);

View File

@ -1,11 +1,11 @@
<?php
include_once("../../core.php");
init_class();
$utente->requirelogin();
$user->requirelogin();
$risultato = $database->esegui("SELECT * FROM `%PREFIX%_users` ORDER BY avaible DESC, caposquadra DESC, interventi ASC, minuti_dispo ASC, nome ASC", true);
$risultato = $database->esegui("SELECT * FROM `%PREFIX%_profiles` ORDER BY avaible DESC, caposquadra DESC, interventi ASC, minuti_dispo ASC, name ASC", true);
$whitelist = $utente->whitelist();
$hidden = $user->hidden();
?>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<style>
@ -40,17 +40,17 @@ th, td {
<div style="overflow-x:auto;">
<table style="width: 90%; text-align:center;">
<tr>
<th>Nome</th>
<th>name</th>
<th>avaible</th>
<?php
foreach($risultato as $row){
if(!in_array($row['nome'], $whitelist)){
if(!in_array($row['name'], $hidden)){
echo "<tr><td>";
if ($row['caposquadra'] == 1) {echo "<img src='./risorse/images/cascoRosso.png' width='20px'> ";} else{echo "<img src='./risorse/images/cascoNero.png' width='20px'> ";}
if($row['online'] == 1){
echo "<u>".$row["nome"]."</u></td><td>";
echo "<u>".$user->nameById($row["id"])."</u></td><td>";
} else {
echo "".$row["nome"]."</td><td>";
echo "".$user->nameById($row["id"])."</td><td>";
}
if ($row['avaible'] == 1) {echo "<i class='fa fa-check' style='color:green'></i>";} else{echo "<i class='fa fa-times' style='color:red'></i>";};
echo "</td></tr>";

View File

@ -1,11 +1,11 @@
<?php
include_once("../../core.php");
init_class();
$utente->requirelogin();
$user->requirelogin();
$risultato = $database->esegui("SELECT * FROM `%PREFIX%_users` ORDER BY avaible DESC, caposquadra DESC, interventi ASC, minuti_dispo ASC, nome ASC", true);
$risultato = $database->esegui("SELECT * FROM `%PREFIX%_profiles` ORDER BY avaible DESC, caposquadra DESC, interventi ASC, minuti_dispo ASC, name ASC", true);
$whitelist = $utente->whitelist();
$hidden = $user->hidden();
?>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<style>
@ -38,7 +38,7 @@ th, td {
<div style="overflow-x:auto;">
<table style="width: 90%; text-align:center;">
<tr>
<th>Nome</th>
<th>name</th>
<th>avaible</th>
<th>Autista</th>
<th>Chiama</th>
@ -48,16 +48,16 @@ th, td {
<th>Altro</th>
<?php
foreach($risultato as $row){
if(!in_array($row['nome'], $whitelist) OR in_array($utente->nome(), $whitelist)){
if(!in_array($row['name'], $hidden) OR in_array($user->name(), $hidden)){
echo "<tr>
<td>";
$nome = $row["nome"];
$name = $user->nameById($row["id"]);
$avaible = $row["avaible"];
if ($row['caposquadra'] == 1) {echo "<a onclick='AttivoAdmin(\"$nome\", \"$avaible\");'><img src='./risorse/images/cascoRosso.png' width='20px'> ";} else{echo "<a onclick='AttivoAdmin(\"$nome\", \"$avaible\");'><img src='./risorse/images/cascoNero.png' width='20px'> ";}
if ($row['caposquadra'] == 1) {echo "<a onclick='Attivo(".$row["id"].");'><img src='./risorse/images/cascoRosso.png' width='20px'> ";} else{echo "<a onclick='Attivo(".$row["id"].");'><img src='./risorse/images/cascoNero.png' width='20px'> ";}
if($row['online'] == 1){
echo "<u>".$row["nome"]."</u></a></td><td><a onclick='AttivoAdmin(\"$nome\", \"$avaible\");'>";
echo "<u>".$user->nameById($row["id"])."</u></a></td><td><a onclick='Attivo(".$row["id"].");'>";
} else {
echo $row["nome"]."</a></td><td><a onclick='AttivoAdmin(\"$nome\", \"$avaible\");'>";
echo $user->nameById($row["id"])."</a></td><td><a onclick='Attivo(".$row["id"].");'>";
}
if ($row['avaible'] == 1) {echo "<i class='fa fa-check' style='color:green'></i>";} else{echo "<i class='fa fa-times' style='color:red'></i>";};
echo "</a></td>
@ -70,7 +70,7 @@ th, td {
$interventi = $row['interventi'];
$minuti = $row['minuti_dispo'];
$u = 'anagrafica.php?utente=' . str_replace(' ', '_', urldecode(strtolower($row["id"])));
$u = 'anagrafica.php?user=' . str_replace(' ', '_', urldecode(strtolower($row["id"])));
echo "<td>$interventi</td><td>$minuti</td><td><a href='$u'><p>Altri dettagli</p></a></td></tr>";
}
}

View File

@ -1,11 +1,11 @@
<?php
include_once("../../core.php");
init_class();
$utente->requirelogin();
$user->requirelogin();
$risultato = $database->esegui("SELECT * FROM `%PREFIX%_log`", true);
$whitelist = $utente->whitelist();
$hidden = $user->hidden();
?>
<style>
th, td {
@ -80,7 +80,7 @@ select::-ms-expand {
<tbody>
<?php
foreach($risultato as $row){
if(!in_array($row['subisce'], $whitelist) OR in_array($utente->nome(), $whitelist)){
if(!in_array($row['subisce'], $hidden) OR in_array($user->name(), $hidden)){
echo "<tr><td>" . $row["azione"] . "</td><td>" . $row["subisce"] . "</td><td>" . $row["agisce"] ."</td><td>" . $row['data'] . " - ore " . $row['ora'] . "</tr>";
}

View File

@ -12,7 +12,7 @@ $(document).ready(function(){
console.log("cleaned");
}
db.version(1).stores({
users: '++id,nome,avaible,caposquadra,autista,telefono,interventi,esercitazioni,online,minuti_dispo,immagine',
users: '++id,name,avaible,caposquadra,autista,telefono,interventi,esercitazioni,online,minuti_dispo,immagine',
interventi: '++id,data,codice,uscita,rientro,capo,autisti,personale,luogo,note,tipo,incrementa,inseritoda'
});
$.each( data.users, function( key, val ) {

View File

@ -5,11 +5,11 @@
<div id='lista'>
</div>
<script>
$("#lista").load("risorse/ajax/ajax_anagrafica.php?utente={{ dacontrollare }}");
$("#lista").load("risorse/ajax/ajax_anagrafica.php?user={{ dacontrollare }}");
$(document).ready(function() {
setInterval(function() {
$("#lista").load("risorse/ajax/ajax_anagrafica.php?utente={{ dacontrollare }}");
$("#lista").load("risorse/ajax/ajax_anagrafica.php?user={{ dacontrollare }}");
}, 10000);
});
@ -24,15 +24,15 @@ check();
</script>
<script>
function AttivoAdmin(nomeutente, dispo){
function AttivoAdmin(nameuser, dispo){
dispo = +!dispo;
$.ajax({
url:"ajax_aggiornadispo.php",
method: "POST",
data: {nomeutente: nomeutente, dispo:dispo},
data: {nameuser: nameuser, dispo:dispo},
success: function (data) {
alert("Hai modificato la disponibilità di " + nomeutente + " in caso in allerta.");
$("#lista").load("risorse/ajax/ajax_anagrafica.php?utente={{ dacontrollare }}");
alert("Hai modificato la disponibilità di " + nameuser + " in caso in allerta.");
$("#lista").load("risorse/ajax/ajax_anagrafica.php?user={{ dacontrollare }}");
}
});
};

View File

@ -34,12 +34,12 @@
<script>
// basic info
smartsupp('email', '');
smartsupp('name', '{{ utente.nome }}');
smartsupp('name', '{{ user.name }}');
smartsupp('recording:disable', false);
// extra info
smartsupp('variables', {
Nome: { label: 'Nome utente ', value: '{{ utente.nome }}' },
Admin: { label: 'Admin', value: '{{ utente.admin }}' }
name: { label: 'name user ', value: '{{ user.name }}' },
Admin: { label: 'Admin', value: '{{ user.full_viewer }}' }
});
</script>
{% endif %}
@ -307,7 +307,7 @@
console.log(ciao);
console.log("onLine");
var xhr = new XMLHttpRequest();
xhr.open('GET', '{{ urlsoftware }}online_check.php?utente={{ utente.nome }}');
xhr.open('GET', '{{ urlsoftware }}online_check.php?user={{ user.name }}');
xhr.onload = function () {
if (xhr.status === 200) {
console.log('Text ' + xhr.responseText);
@ -343,7 +343,7 @@
<a href="{{ urlsoftware }}log.php">Log</a>
<a {# href="{{ urlsoftware }}grafici.php" #}>Grafici</a>
<a href="javascript:void(0);" onclick="chat()">Supporto tecnico</a>
<a style="float: right;" id="logout">Ciao {{ utente.nome }}. <b onclick="location.href='{{ urlsoftware }}logout.php';">Esegui il logout</b></a>
<a style="float: right;" id="logout">Ciao {{ user.name }}. <b onclick="location.href='{{ urlsoftware }}logout.php';">Esegui il logout</b></a>
<a href="javascript:void(0);" class="icon" onclick="myFunction()"></a>
</div>
<!-- /Menu -->

View File

@ -17,14 +17,14 @@ sound.play();
<script>
$("#err").delay(5000).fadeOut(300);
</script>
{{ errore.spiegazione }}
{{ errore.text }}
<img src='{{ urlsoftware }}/risorse/images/{{ error_image }}'></img>
</div>
{% endif %}
<div class="container text-center" id="modulogin">
<form method="post">
<img alt="VVF" src="{{ urlsoftware }}/risorse/images/logo.png" class="img-resposive"><br><br><br>
<input type="text" name="nome" placeholder="Nome" required autocomplete="username" autofocus><br><br>
<input type="text" name="name" placeholder="name" required autocomplete="username" autofocus><br><br>
<input type="password" name="password" placeholder="Password" required autocomplete="current-password"><br><br>
<input type="checkbox" name="connesso" value='1' id="connesso" hidden checked><label hidden for='connesso'>Rimani Connesso</label><br>
<input type="submit" name="login" class="btn btn-lg btn-success" value="Accedi">

View File

@ -23,16 +23,6 @@
}, 10000);
});
/*
check();
$(document).ready(function() {
setInterval(function() {
check();
}, 10000);
});
*/
</script>
<br>
<br>

View File

@ -4,79 +4,40 @@
<br>
<div class="text-center">
<p>Sei avaible in caso di allerta?</p>
<button class="btn btn-lg btn-success " onclick="Attivo('{{ utente.nome }}')">Attivo</button>
<button class="btn btn-lg btn-success " onclick="Attivo('{{ user.id }}')">Attivo</button>
<button class="btn btn-lg btn-danger" style="background-color: red" onclick="nonAttivo('{{ utente.nome }}')">Non Attivo</button>
<button class="btn btn-lg btn-danger" style="background-color: red" onclick="NonAttivo('{{ user.id }}')">Non Attivo</button>
</div>
<script defer>
function AttivoAdmin(nomeutenteattivato, dispold){
var nomeutenteattivatore = '{{ utente.nome }}';
var dispo = 1-dispold;
var code = '{{ utente.codice }}';
function Attivo(id){
$.ajax({
url: "risorse/ajax/ajax_aggiornadispo.php",
method: "POST",
data: {
nomeutenteattivato: nomeutenteattivato,
nomeutenteattivatore: nomeutenteattivatore,
dispo: dispo
change_id: id,
dispo: 1
},
success: function(data) {
if(nomeutenteattivatore === nomeutenteattivato){
alert("Grazie, " + nomeutenteattivatore + ", hai dato la tua disponibilità in caso in allerta.");
} else {
alert("Grazie, " + nomeutenteattivatore + ", hai dato la disponibilità di " + nomeutenteattivato + " in caso in allerta.");
}
alert("Grazie, {{ user.name }}, hai dato la tua disponibilità in caso in allerta.");
location.reload();
}
});
};
}
function Attivo(nomeutenteattivato){
var nomeutenteattivatore = '{{ utente.nome }}';
var dispo = 1;
var code = '{{ utente.codice }}';
function NonAttivo(id){
$.ajax({
url: "risorse/ajax/ajax_aggiornadispo.php",
method: "POST",
data: {
nomeutenteattivato: nomeutenteattivato,
nomeutenteattivatore: nomeutenteattivatore,
dispo: dispo
change_id: id,
dispo: 0
},
success: function(data) {
if(nomeutenteattivatore === nomeutenteattivato){
alert("Grazie, " + nomeutenteattivatore + ", hai dato la tua disponibilità in caso in allerta.");
} else {
alert("Grazie, " + nomeutenteattivatore + ", hai dato la disponibilità di " + nomeutenteattivato + " in caso in allerta.");
}
alert("Grazie {{ user.name }}, hai dato la tua disponibilità in caso in allerta.");
location.reload();
}
});
};
function nonAttivo(nomeutenteattivato){
var nomeutenteattivatore = '{{ utente.nome }}';
var dispo = 0;
var code = '{{ utente.codice }}';
$.ajax({
url: "risorse/ajax/ajax_aggiornadispo.php",
method: "POST",
data: {
nomeutenteattivato: nomeutenteattivato,
nomeutenteattivatore: nomeutenteattivatore,
dispo: dispo
},
success: function(data) {
if(nomeutenteattivatore === nomeutenteattivato){
alert("Grazie, " + nomeutenteattivatore + ", hai dato la tua disponibilità in caso in allerta.");
} else {
alert("Grazie, " + nomeutenteattivatore + ", hai dato la disponibilità di " + nomeutenteattivato + " in caso in allerta.");
}
location.reload();
}
});
};
}
</script>
<br>
<br>
@ -84,7 +45,7 @@
<br>
<br>
<div id="lista"></div>
{% if utente.admin == false %}
{% if user.full_viewer == false %}
<script>
$( "#lista" ).load("risorse/ajax/ajax_lista.php");
$(document).ready(function() {
@ -93,7 +54,7 @@ $(document).ready(function() {
}, 10000);
});
</script>
{% elseif utente.admin == true %}
{% elseif user.full_viewer == true %}
<script>
$( "#lista" ).load("risorse/ajax/ajax_lista_admin.php");
$(document).ready(function() {

View File

@ -226,11 +226,11 @@ textarea {
<label><b>Caposquadra</b></label>
<br>
{% for user in intervento.personale %}
<div {{ user.nome == "test" ? "style='display: none'" : "" }} class="checkbox">
<div {{ user.name == "test" ? "style='display: none'" : "" }} class="checkbox">
<label>
<input type="checkbox" name='capo' value='{{ user.id }}'>
<span class="cr"><i class="cr-icon glyphicon glyphicon-ok"></i></span>
{{ user.nome }}
{{ user.name }}
</label>
</div>
{% endfor %}
@ -244,11 +244,11 @@ textarea {
<br>
{% for user in intervento.personale %}
{% if user.autista == 1 %}
<div {{ user.nome == "test" ? "style='display: none'" : "" }} class="checkbox">
<div {{ user.name == "test" ? "style='display: none'" : "" }} class="checkbox">
<label>
<input type="checkbox" name='autisti[]' value='{{ user.id }}'>
<span class="cr"><i class="cr-icon glyphicon glyphicon-ok"></i></span>
{{ user.nome }}
{{ user.name }}
</label>
</div>
{% endif %}
@ -257,11 +257,11 @@ textarea {
<label><b>Altro personale</b></label>
<br>
{% for user in intervento.personale %}
<div {{ user.nome == "test" ? "style='display: none'" : "" }} class="checkbox">
<div {{ user.name == "test" ? "style='display: none'" : "" }} class="checkbox">
<label>
<input type="checkbox" name='personale[]' value='{{ user.id }}'>
<span class="cr"><i class="cr-icon glyphicon glyphicon-ok"></i></span>
{{ user.nome }}
{{ user.name }}
</label>
</div>
{% endfor %}
@ -278,7 +278,7 @@ textarea {
<br>
<select name='tipo'>
{% for tipo in intervento.tipologie %}
<option value='{{ tipo.nome }}'>{{ tipo.nome }}</option>
<option value='{{ tipo.name }}'>{{ tipo.name }}</option>
{% endfor %}
</select>
<br>
@ -325,11 +325,11 @@ $('form').submit(function () {
<label><b>Caposquadra</b></label>
<br>
{% for user in intervento.personale %}
<div {{ user.nome == "test" ? "style='display: none'" : "" }} class="checkbox">
<div {{ user.name == "test" ? "style='display: none'" : "" }} class="checkbox">
<label>
<input type="checkbox" name='capo' value='{{ user.id }}'>
<span class="cr"><i class="cr-icon glyphicon glyphicon-ok"></i></span>
{{ user.nome }}
{{ user.name }}
</label>
</div>
{% endfor %}
@ -343,11 +343,11 @@ $('form').submit(function () {
<br>
{% for user in intervento.personale %}
{% if user.autista == 1 %}
<div {{ user.nome == "test" ? "style='display: none'" : "" }} class="checkbox">
<div {{ user.name == "test" ? "style='display: none'" : "" }} class="checkbox">
<label>
<input type="checkbox" name='autisti[]' value='{{ user.id }}'>
<span class="cr"><i class="cr-icon glyphicon glyphicon-ok"></i></span>
{{ user.nome }}
{{ user.name }}
</label>
</div>
{% endif %}
@ -356,11 +356,11 @@ $('form').submit(function () {
<label><b>Altro personale</b></label>
<br>
{% for user in intervento.personale %}
<div {{ user.nome == "test" ? "style='display: none'" : "" }} class="checkbox">
<div {{ user.name == "test" ? "style='display: none'" : "" }} class="checkbox">
<label>
<input type="checkbox" name='personale[]' value='{{ user.id }}'>
<span class="cr"><i class="cr-icon glyphicon glyphicon-ok"></i></span>
{{ user.nome }}
{{ user.name }}
</label>
</div>
{% endfor %}
@ -377,7 +377,7 @@ $('form').submit(function () {
<br>
<select name='tipo'>
{% for tipo in intervento.tipologie %}
<option value='{{ tipo.nome }}'>{{ tipo.nome }}</option>
<option value='{{ tipo.name }}'>{{ tipo.name }}</option>
{% endfor %}
</select>
<br>

View File

@ -22,7 +22,7 @@ class FirstCest
$I->click('Submit');
$I->see('Eseguire il login');
$I->click('Eseguire il login');
$I->fillField('nome', 'admin_user');
$I->fillField('name', 'admin_user');
$I->fillField('password', 'password');
$I->click('login');
$I->seeCurrentURLEquals('/lista.php');

View File

@ -12,13 +12,13 @@ $twig = new \Twig\Environment($loader, [
]);
$template = NULL;
function loadtemplate($templatename, $data, $requirelogin=true){
global $utente, $twig, $template;
global $user, $twig, $template;
if($requirelogin){
$utente->requirelogin();
$user->requirelogin();
}
$data['owner'] = owner;
$data['urlsoftware'] = WEB_URL;
$data['utente'] = $utente->info();
$data['user'] = $user->info();
$data['enable_technical_support'] = ENABLE_TECHNICAL_SUPPORT;
$data['technical_support_key'] = TECHNICAL_SUPPORT_KEY;
$data['technical_support_open'] = isset($_COOKIE["chat"]);