This commit is contained in:
Matteo Gheza 2020-05-20 23:07:17 +02:00
commit 641c699702
22 changed files with 84 additions and 70 deletions

View File

@ -37,7 +37,7 @@ define( 'ENABLE_TECHNICAL_SUPPORT', false );
define( 'TECHNICAL_SUPPORT_KEY', '' );
/* Insert your organization name */
define( 'DISTACCAMENTO', 'Distaccamento' );
define( 'owner', 'owner' );
/* Do you want to use a custom error message? (filename: custom-error.mp3) */
define( 'USE_CUSTOM_ERROR_SOUND', false );

View File

@ -144,15 +144,15 @@ class database{
protected $db_dbname = DB_NAME;
protected $db_username = DB_USER;
protected $db_password = DB_PASSWORD;
public $connessione = null;
public $connection = null;
public $query = null;
public $stmt = null;
public function connetti(){
try {
$this->connessione = new PDO("mysql:host=" . $this->db_host . ";dbname=" . $this->db_dbname, $this->db_username, $this->db_password);
$this->connessione->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$this->connessione->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->connection = new PDO("mysql:host=" . $this->db_host . ";dbname=" . $this->db_dbname, $this->db_username, $this->db_password);
$this->connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e)
{
@ -168,27 +168,27 @@ class database{
}
public function close(){
$this->connessione = null;
$this->connection = null;
}
public function esegui($sql, $fetch=false, $param=null){
try{
$this->connessione->beginTransaction();
$this->stmt = $this->connessione->prepare(str_replace("%PREFIX%", DB_PREFIX, $sql));
$this->connection->beginTransaction();
$this->stmt = $this->connection->prepare(str_replace("%PREFIX%", DB_PREFIX, $sql));
if(!is_null($param)){
$this->query = $this->stmt->execute($param);
} else {
$this->query = $this->stmt->execute();
}
bdump($this->query);
$this->connessione->commit();
$this->connection->commit();
if($fetch == true){
return $this->stmt->fetchAll(PDO::FETCH_ASSOC);
}
$this->stmt->closeCursor();
} catch (PDOException $e) {
print "Errore!: " . $e->getMessage() . "<br/>";
$this->connessione->rollBack();
$this->connection->rollBack();
die();
}
}
@ -229,7 +229,7 @@ class user{
}
}
public function richiedilogin(){
public function requirelogin(){
if(!$this->autenticato()){
if(INTRUSION_SAVE){
if(INTRUSION_SAVE_INFO){
@ -268,20 +268,29 @@ class user{
}
public function nome_by_id($id){
$vigile = $this->database->esegui("SELECT nome FROM `%PREFIX%_users` WHERE id = :id;", true, [":id" => $id]);
if(empty($vigile)){
$user = $this->database->esegui("SELECT nome FROM `%PREFIX%_users` WHERE id = :id;", true, [":id" => $id]);
if(empty($user)){
return false;
} else {
return $vigile[0]["nome"];
return $user[0]["nome"];
}
}
<<<<<<< HEAD
public function available($nome){
$vigile = $this->database->esegui("SELECT available FROM `%PREFIX%_users` WHERE nome = :nome;", true, [":nome" => $nome]);
if(empty($vigile)){
return false;
} else {
return $vigile[0]["available"];
=======
public function disponibile($nome){
$user = $this->database->esegui("SELECT disponibile FROM `%PREFIX%_users` WHERE nome = :nome;", true, [":nome" => $nome]);
if(empty($user)){
return false;
} else {
return $user[0]["disponibile"];
>>>>>>> e2b9cf2f49f0254dc8318c9c0021a23c464dd106
}
}

View File

@ -75,9 +75,9 @@ if(true){
$prefixValue = "allerta01";
}
?>
<h1 class="screen-reader-text">Configura la connessione al database</h1>
<h1 class="screen-reader-text">Configura la connection al database</h1>
<form method="post">
<p>Di seguito puoi inserire i dettagli di connessione al database. Se non sei sicuro dei dati da inserire contatta il tuo fornitore di hosting.</p>
<p>Di seguito puoi inserire i dettagli di connection al database. Se non sei sicuro dei dati da inserire contatta il tuo fornitore di hosting.</p>
<table class="form-table" role="presentation">
<tbody>
<tr>
@ -210,8 +210,8 @@ if(true){
<p>Controlla attentamente il tuo indirizzo email prima di continuare.</p></td>
</tr>
<tr>
<th scope="row"><label for="distaccamento">Distaccamento</label></th>
<td><input name="distaccamento" type="text" id="distaccamento" size="100" value="">
<th scope="row"><label for="owner">owner</label></th>
<td><input name="owner" type="text" id="owner" size="100" value="">
<p>Verrà utilizzato nei report.</p></td>
</tr>
</tbody></table>
@ -221,7 +221,7 @@ if(true){
</p>
<?php
} else if ($_POST["step"] == "5") {
initOptions($_POST["user_name"], $_POST["admin_visible"], $_POST["admin_password"], $_POST["admin_email"], $_POST["distaccamento"]);
initOptions($_POST["user_name"], $_POST["admin_visible"], $_POST["admin_password"], $_POST["admin_email"], $_POST["owner"]);
?>
<h1 class="screen-reader-text">Installazione terminata con successo.</h1>
<p>Ottimo lavoro, amico! Hai completato l'installazione. Ora Allerta può funzionare correttamente. Adesso è il momento di…</p>

View File

@ -16,7 +16,7 @@ function checkConnection($host, $user, $password, $database){
} catch (PDOException $e){
$connectionOk = false;
?>
<div class="wp-die-message"><h1>Errore nello stabilire una connessione al database</h1>
<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>
<ul>
<li>Sei sicuro di avere nome utente e password corretti?</li>
@ -250,7 +250,7 @@ INSERT INTO `".$prefix."_dbversion` (`id`, `version`, `timestamp`) VALUES (NULL,
}
}
function initOptions($name, $visible, $password, $report_email, $distaccamento){
function initOptions($name, $visible, $password, $report_email, $owner){
try{
require_once "../config.php";
$connection = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME, DB_USER, DB_PASSWORD,[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
@ -258,12 +258,12 @@ function initOptions($name, $visible, $password, $report_email, $distaccamento){
$prep = $connection->prepare("
INSERT INTO `".$prefix."_users` (`id`, `role`, `hidden`, `disabled`, `nome`, `available`, `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."_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', 'distaccamento', :distaccamento, '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(':distaccamento', $distaccamento, PDO::PARAM_STR);
$prep->bindParam(':owner', $owner, PDO::PARAM_STR);
$prep->execute();
} catch (Exception $e) {
?>

View File

@ -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', 'distaccamento' => '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' => '', 'utente' => $utente->info()]);
bdump($_SESSION['token'], "token");
}
?>

View File

@ -1,7 +1,7 @@
<?php
include_once '../../core.php';
init_class();
$utente->richiedilogin();
$utente->requirelogin();
if(isset($_POST["nomeutenteattivato"]) && isset($_POST["nomeutenteattivatore"]) && $_POST["dispo"] == 1) {
$risultato = $database->esegui("UPDATE `%PREFIX%_users` SET available = 1 WHERE nome = :nome", false, [":nome" => $_POST["nomeutenteattivato"]]);
$utente->log("Attivazione disponibilita'", $_POST["nomeutenteattivato"], $_POST["nomeutenteattivatore"], date("d/m/Y"), date("H:i.s"));

View File

@ -1,7 +1,7 @@
<?php
include_once("../../core.php");
init_class();
$utente->richiedilogin();
$utente->requirelogin();
$risultato = $database->esegui('SELECT * FROM `%PREFIX%_users` WHERE id = :id', true, array(":id" => $_GET['utente'])); // Pesco i dati della tabella
@ -317,8 +317,13 @@ function vero1($text, $img1 = "", $img2 = ""){
foreach($risultato as $row){
$nome = ($row['online']==1) ? '<u>' . $row['nome'] . "</u>" : $row['nome'];
echo("<h1>Dati anagrafici <b>$nome</b></h1><br><br>");
<<<<<<< HEAD
echo('<img alt="VVF" src="./risorse/images/distaccamento.png" width="150" class="img-resposive"><br><br><br>');
$disp = vero1($row['available'], "<i class='fa fa-check' style='color:green' width='22px'></i>", "<i class='fa fa-times' style='color:red' width='22px'></i>");
=======
echo('<img alt="VVF" src="./risorse/images/owner.png" width="150" class="img-resposive"><br><br><br>');
$disp = vero1($row['disponibile'], "<i class='fa fa-check' style='color:green' width='22px'></i>", "<i class='fa fa-times' style='color:red' width='22px'></i>");
>>>>>>> e2b9cf2f49f0254dc8318c9c0021a23c464dd106
$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>");

View File

@ -1,7 +1,7 @@
<?php
include_once("../../core.php");
init_class();
$utente->richiedilogin();
$utente->requirelogin();
$users_sql = "SELECT `id`, `nome`, `available`, `caposquadra`, `autista`, `telefono`, `interventi`, `esercitazioni`, `online`, `minuti_dispo`, `immagine` FROM `%PREFIX%_users` LIMIT 0 , 30";
$users = $database->esegui($users_sql, true);

View File

@ -3,7 +3,7 @@ $start = true;
$minuti = 5;
include_once "../../core.php";
init_class();
$utente->richiedilogin();
$utente->requirelogin();
function arraynum(){
global $database;

View File

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

View File

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

View File

@ -1,7 +1,7 @@
<?php
include_once("../../core.php");
init_class();
$utente->richiedilogin();
$utente->requirelogin();
$risultato = $database->esegui("SELECT * FROM `%PREFIX%_users` ORDER BY available DESC, caposquadra DESC, interventi ASC, minuti_dispo ASC, nome ASC", true);

View File

@ -1,7 +1,7 @@
<?php
include_once("../../core.php");
init_class();
$utente->richiedilogin();
$utente->requirelogin();
$risultato = $database->esegui("SELECT * FROM `%PREFIX%_users` ORDER BY available DESC, caposquadra DESC, interventi ASC, minuti_dispo ASC, nome ASC", true);

View File

@ -1,7 +1,7 @@
<?php
include_once("../../core.php");
init_class();
$utente->richiedilogin();
$utente->requirelogin();
$risultato = $database->esegui("SELECT * FROM `%PREFIX%_log`", true);

View File

@ -2,7 +2,7 @@
<html lang="it">
<head>
{% block head %}
<title>{{ titolo }} - ALLERTA sistema gestionale {{ distaccamento }}</title>
<title>{{ titolo }} - ALLERTA sistema gestionale {{ owner }}</title>
<link href="{{ urlsoftware }}/risorse/images/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon">
<meta name="viewport" content="user-scalable=no, initial-scale=1">
<style>
@ -359,7 +359,7 @@
<footer hidden id="bottom" class="row text-left p-4">
<div class="col-12 col-md-4">
<h5>Copyright &copy; Matteo</h5>
<h4>Applicativo realizzato per {{ distaccamento }}</h4>
<h4>Applicativo realizzato per {{ owner }}</h4>
</div>
</footer>
<!-- /Footer -->

View File

@ -2,7 +2,7 @@
{% block content %}
<br>
<img alt="VVF" src="./risorse/images/distaccamento.png" width="150" style="display: block; margin-left: auto; margin-right: auto;">
<img alt="VVF" src="./risorse/images/owner.png" width="150" style="display: block; margin-left: auto; margin-right: auto;">
<br>
<p style="text-align: center;">
<a id='add' href="esercitazioni/modifica.php?aggiungi">Aggiungi esercitazione</a>

View File

@ -2,7 +2,7 @@
{% block content %}
<br>
<img alt="VVF" src="./risorse/images/distaccamento.png" width="150" style="display: block; margin-left: auto; margin-right: auto;">
<img alt="VVF" src="./risorse/images/owner.png" width="150" style="display: block; margin-left: auto; margin-right: auto;">
<br>
<p style="text-align: center;">
<a id='add' href="interventi/modifica.php?aggiungi">Aggiungi intervento</a>

View File

@ -80,7 +80,7 @@
</script>
<br>
<br>
<img alt="VVF" src="./risorse/images/distaccamento.png" width="150" style="display: block; margin-left: auto; margin-right: auto;">
<img alt="VVF" src="./risorse/images/owner.png" width="150" style="display: block; margin-left: auto; margin-right: auto;">
<br>
<br>
<div id="lista"></div>

View File

@ -2,7 +2,7 @@
{% block content %}
<br>
<img alt="VVF" src="./risorse/images/distaccamento.png" width="150" style="display: block; margin-left: auto; margin-right: auto;">
<img alt="VVF" src="./risorse/images/owner.png" width="150" style="display: block; margin-left: auto; margin-right: auto;">
<br>
<div id="lista"></div>
<script>

View File

@ -225,12 +225,12 @@ textarea {
<br>
<label><b>Caposquadra</b></label>
<br>
{% for vigile in intervento.personale %}
<div {{ vigile.nome == "test" ? "style='display: none'" : "" }} class="checkbox">
{% for user in intervento.personale %}
<div {{ user.nome == "test" ? "style='display: none'" : "" }} class="checkbox">
<label>
<input type="checkbox" name='capo' value='{{ vigile.id }}'>
<input type="checkbox" name='capo' value='{{ user.id }}'>
<span class="cr"><i class="cr-icon glyphicon glyphicon-ok"></i></span>
{{ vigile.nome }}
{{ user.nome }}
</label>
</div>
{% endfor %}
@ -242,13 +242,13 @@ textarea {
<br>
<label><b>Autisti</b></label>
<br>
{% for vigile in intervento.personale %}
{% if vigile.autista == 1 %}
<div {{ vigile.nome == "test" ? "style='display: none'" : "" }} class="checkbox">
{% for user in intervento.personale %}
{% if user.autista == 1 %}
<div {{ user.nome == "test" ? "style='display: none'" : "" }} class="checkbox">
<label>
<input type="checkbox" name='autisti[]' value='{{ vigile.id }}'>
<input type="checkbox" name='autisti[]' value='{{ user.id }}'>
<span class="cr"><i class="cr-icon glyphicon glyphicon-ok"></i></span>
{{ vigile.nome }}
{{ user.nome }}
</label>
</div>
{% endif %}
@ -256,12 +256,12 @@ textarea {
<br>
<label><b>Altro personale</b></label>
<br>
{% for vigile in intervento.personale %}
<div {{ vigile.nome == "test" ? "style='display: none'" : "" }} class="checkbox">
{% for user in intervento.personale %}
<div {{ user.nome == "test" ? "style='display: none'" : "" }} class="checkbox">
<label>
<input type="checkbox" name='personale[]' value='{{ vigile.id }}'>
<input type="checkbox" name='personale[]' value='{{ user.id }}'>
<span class="cr"><i class="cr-icon glyphicon glyphicon-ok"></i></span>
{{ vigile.nome }}
{{ user.nome }}
</label>
</div>
{% endfor %}
@ -324,12 +324,12 @@ $('form').submit(function () {
<br>
<label><b>Caposquadra</b></label>
<br>
{% for vigile in intervento.personale %}
<div {{ vigile.nome == "test" ? "style='display: none'" : "" }} class="checkbox">
{% for user in intervento.personale %}
<div {{ user.nome == "test" ? "style='display: none'" : "" }} class="checkbox">
<label>
<input type="checkbox" name='capo' value='{{ vigile.id }}'>
<input type="checkbox" name='capo' value='{{ user.id }}'>
<span class="cr"><i class="cr-icon glyphicon glyphicon-ok"></i></span>
{{ vigile.nome }}
{{ user.nome }}
</label>
</div>
{% endfor %}
@ -341,13 +341,13 @@ $('form').submit(function () {
<br>
<label><b>Autisti</b></label>
<br>
{% for vigile in intervento.personale %}
{% if vigile.autista == 1 %}
<div {{ vigile.nome == "test" ? "style='display: none'" : "" }} class="checkbox">
{% for user in intervento.personale %}
{% if user.autista == 1 %}
<div {{ user.nome == "test" ? "style='display: none'" : "" }} class="checkbox">
<label>
<input type="checkbox" name='autisti[]' value='{{ vigile.id }}'>
<input type="checkbox" name='autisti[]' value='{{ user.id }}'>
<span class="cr"><i class="cr-icon glyphicon glyphicon-ok"></i></span>
{{ vigile.nome }}
{{ user.nome }}
</label>
</div>
{% endif %}
@ -355,12 +355,12 @@ $('form').submit(function () {
<br>
<label><b>Altro personale</b></label>
<br>
{% for vigile in intervento.personale %}
<div {{ vigile.nome == "test" ? "style='display: none'" : "" }} class="checkbox">
{% for user in intervento.personale %}
<div {{ user.nome == "test" ? "style='display: none'" : "" }} class="checkbox">
<label>
<input type="checkbox" name='personale[]' value='{{ vigile.id }}'>
<input type="checkbox" name='personale[]' value='{{ user.id }}'>
<span class="cr"><i class="cr-icon glyphicon glyphicon-ok"></i></span>
{{ vigile.nome }}
{{ user.nome }}
</label>
</div>
{% endfor %}

View File

@ -18,7 +18,7 @@ class FirstCest
$I->fillField('admin_password', 'password');
$I->checkOption('admin_visible');
$I->fillField('admin_email', 'admin_mail@allertavvf.local');
$I->fillField('distaccamento', 'Distaccamento');
$I->fillField('owner', 'owner');
$I->click('Submit');
$I->see('Eseguire il login');
$I->click('Eseguire il login');

View File

@ -11,12 +11,12 @@ $twig = new \Twig\Environment($loader, [
//'cache' => 'compilation'
]);
$template = NULL;
function loadtemplate($templatename, $data, $richiedilogin=true){
function loadtemplate($templatename, $data, $requirelogin=true){
global $utente, $twig, $template;
if($richiedilogin){
$utente->richiedilogin();
if($requirelogin){
$utente->requirelogin();
}
$data['distaccamento'] = DISTACCAMENTO;
$data['owner'] = owner;
$data['urlsoftware'] = WEB_URL;
$data['utente'] = $utente->info();
$data['enable_technical_support'] = ENABLE_TECHNICAL_SUPPORT;