Merge pull request #14 from allerta-vvf/master

Pull from master
This commit is contained in:
MatteoGheza 2020-05-30 19:58:47 +02:00 committed by GitHub
commit cfd8e047fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
62 changed files with 8714 additions and 488 deletions

View File

@ -1,10 +0,0 @@
# This is an example with only required properties:
version: 1
update_configs:
- package_manager: "php:composer"
directory: "/server"
update_schedule: "live"
default_labels:
- "dependencies"
- "dependabot"
- "update"

82
.github/workflows/php.yml vendored Normal file
View File

@ -0,0 +1,82 @@
name: PHP Code Testing
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
tests:
if: "! contains(toJSON(github.event.commits.*.message), '[skip-ci]')"
env:
working-directory: ./server
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.3', '7.4']
name: PHP ${{ matrix.php-versions }}
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl
ini-values: post_max_size=256M, short_open_tag=On
coverage: xdebug, pcov
#tools: php-cs-fixer, phpunit
- name: Shutdown Ubuntu MySQL (SUDO)
run: sudo service mysql stop
- name: Start MariaDB
uses: getong/mariadb-action@v1.1
with:
mysql root password: password
mysql database: allerta
mysql user: user
mysql password: password
- name: Validate composer.json and composer.lock
run: composer validate
working-directory: ${{env.working-directory}}
- name: Install dependencies
run: composer install --prefer-dist --no-progress
working-directory: ${{env.working-directory}}
- name: Run test suite
run: vendor/bin/codecept run --steps
working-directory: ${{env.working-directory}}
- name: Upload Tests Artifact
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: tests output (php ${{ matrix.php-versions }})
path: ./server/tests/_output
- name: Remove devs files and dirs
if: "${{ success() }}"
run: |
rm server/codeception.yml
sudo rm server/tests -r
sudo rm server/vendor -r
composer install --no-dev --no-progress --no-suggest -o -n -d server
- name: Upload prod build
if: "${{ success() }}"
uses: actions/upload-artifact@v2
with:
name: prod build (php ${{ matrix.php-versions }})
path: ./server/

7
.gitignore vendored
View File

@ -497,7 +497,14 @@ composer.phar
/server/error-log/*
!/server/error-log/index.html
/server/tests/_output/*
!/server/tests/_output/.gitkeep
/server/tests/_data/*
!/server/tests/_data/.gitkeep
config.php
config.old.php
*password*

18
LICENSE
View File

@ -93,7 +93,7 @@ on the Program.
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
distribution (with or without modification), making avaible to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
@ -125,7 +125,7 @@ than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
implementation is avaible to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
@ -135,7 +135,7 @@ produce the work, or an object code interpreter used to run it.
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
System Libraries, or general-purpose tools or generally avaible free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
@ -283,7 +283,7 @@ in one of these ways:
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
avaible for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
@ -336,7 +336,7 @@ protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
documented (and with an implementation avaible to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
@ -497,11 +497,11 @@ party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
and the Corresponding Source of the work is not avaible for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
publicly avaible network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
avaible, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
@ -535,7 +535,7 @@ or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
otherwise be avaible to you under applicable patent law.
12. No Surrender of Others' Freedom.

View File

@ -1,2 +1,25 @@
# allerta-vvf
A open source management software for "Associazione VVF Volontari Darfo"
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fallerta-vvf%2Fallerta-vvf.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fallerta-vvf%2Fallerta-vvf?ref=badge_shield) ![PHP Code Testing](https://github.com/allerta-vvf/allerta-vvf/workflows/PHP%20Code%20Testing/badge.svg) ![Languages count](https://img.shields.io/github/languages/count/allerta-vvf/allerta-vvf) ![Top language](https://img.shields.io/github/languages/top/allerta-vvf/allerta-vvf) ![GitHub issues](https://img.shields.io/github/issues-raw/allerta-vvf/allerta-vvf) ![GitHub pull requests](https://img.shields.io/github/issues-pr-raw/allerta-vvf/allerta-vvf) ![GitHub contributors](https://img.shields.io/github/contributors/allerta-vvf/allerta-vvf) ![GitHub stars](https://img.shields.io/github/stars/allerta-vvf/allerta-vvf?style=social)
Allerta VVF is an unofficial **open source firefighters' management software** for "Associazione VVF Volontari Darfo"
This is only a **development version**.
||it works :heavy_check_mark:|it's in beta :clock8:|it doesn't work :x:|
|:-:|:-:|:-:|:-:|
|Availability|:heavy_check_mark:|||
|"Interventi"||:clock8:||
|"Esercitazioni"|||:x:|
|Installation|:heavy_check_mark:|||
|CLI Installation|:heavy_check_mark:|||
|Translation|||:x:|
|User managament|||:x:|
|Logs|:heavy_check_mark:|||
|Graphs|||:x:|
|Images||:clock8:||
## License
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fallerta-vvf%2Fallerta-vvf.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fallerta-vvf%2Fallerta-vvf?ref=badge_large)
<!--stackedit_data:
eyJoaXN0b3J5IjpbMTQ0NDg5MTI1OV19
-->

48
publiccode.yml.txt Normal file
View File

@ -0,0 +1,48 @@
publiccodeYmlVersion: "0.2"
name: Allerta VVF
url: "https://github.com/allerta-vvf/allerta-vvf.git"
softwareVersion: "dev" # Optional
releaseDate: "2020-04-15"
platforms:
- web
categories:
- fleet-management
developmentStatus: development
softwareType: "standalone/desktop"
description:
en:
localisedName: Allerta VVF # Optional
genericName: Allerta
shortDescription: >
Open source firefighter management software
longDescription: >
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nec congue augue. Nam blandit mollis mi sed eleifend. Etiam massa dolor, pulvinar sollicitudin ante vel, tristique pellentesque lectus. Donec sit amet varius leo. Nulla sagittis consequat justo in ornare. Donec eget congue dui, eu venenatis dolor. Proin tempus arcu risus, et pellentesque lorem pretium sed. Proin laoreet lacinia dolor, id cursus purus iaculis at. Morbi finibus sollicitudin dui a venenatis. Suspendisse potenti. Etiam semper convallis viverra. Donec condimentum libero non eros ornare convallis. Morbi at magna metus. Nullam vestibulum dapibus sapien, eget tincidunt mauris euismod vel. In vel nunc id nisi luctus tincidunt non nec justo.
Curabitur pretium, lacus accumsan tincidunt commodo, turpis est pharetra justo, vel faucibus lorem elit nec sapien. Fusce semper aliquam nisl ultricies molestie. Cras sagittis semper magna in interdum. Cras mattis euismod laoreet. Pellentesque sed gravida nisi. Pellentesque pharetra risus vel elementum viverra. Suspendisse id consectetur enim. Praesent a blandit est.
Nullam suscipit arcu arcu, accumsan pellentesque ipsum dapibus id. In vitae magna scelerisque, tincidunt elit ut, posuere neque. Sed ut tempus justo. Aenean id diam et leo sagittis mattis. Morbi mattis sit amet nulla a hendrerit. Donec gravida tortor augue, non rhoncus metus imperdiet ac. Nam sed arcu a tortor efficitur consectetur. Sed lobortis ut augue id tempor.
Mauris sed mollis ligula, a auctor ante. Quisque eget gravida magna. In porttitor fermentum urna quis consectetur. Donec non nulla feugiat, molestie eros et, feugiat justo. Aliquam venenatis, massa ac tristique malesuada, metus erat eleifend augue, vel ultrices urna leo sit amet diam. Nulla facilisi. Nullam erat enim, efficitur laoreet diam ac, blandit convallis elit. Sed feugiat libero at massa faucibus cursus.
Vestibulum imperdiet est at erat dapibus aliquet. Vestibulum elementum in libero quis elementum. Sed tincidunt lobortis mattis. Aliquam nisl quam, vulputate vel lacus eu, ornare tempor est. Donec ultricies nunc vitae varius pharetra. Morbi eu ipsum scelerisque, tempor orci commodo, mollis orci. Mauris vulputate sem vel congue pellentesque.
features:
- Just one feature
- Just feature two
legal:
license: AGPL-3.0-or-later
maintenance:
type: "community"
contacts:
- name: Matteo Gheza
localisation:
localisationReady: yes
avaibleLanguages:
- en
- it

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'])))]);
?>

10
server/codeception.yml Normal file
View File

@ -0,0 +1,10 @@
paths:
tests: tests
output: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
actor_suffix: Tester
extensions:
enabled:
- Codeception\Extension\RunFailed

View File

@ -3,12 +3,10 @@
"description": "Un software di allertamento per i vvf",
"type": "project",
"require": {
"cmfcmf/openweathermap-php-api": "dev-master",
"doctrine/lexer": "^1.3@dev",
"egulias/email-validator": "^2.1@dev",
"fzaninotto/faker": "^1.9@dev",
"twig/twig": "3.x-dev",
"tracy/tracy": "^2.7@dev"
"tracy/tracy": "^2.7@dev",
"delight-im/auth": "dev-master",
"ulrichsg/getopt-php": "dev-master"
},
"license": "GPL-3.0-or-later",
"authors": [
@ -17,5 +15,19 @@
"email": "matteo@matteogheza.it"
}
],
"minimum-stability": "dev"
"minimum-stability": "dev",
"require-dev": {
"codeception/codeception": "4.x-dev",
"codeception/module-asserts": "*",
"codeception/module-phpbrowser": "^1.0.0",
"codeception/phpbuiltinserver": "*",
"phpunit/phpunit": "6.*",
"captbaritone/mailcatcher-codeception-module": "*",
"nathanmac/datetime-codeception-module": "~1.0"
},
"scripts": {
"test": [
"codecept run --steps"
]
}
}

4374
server/composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +1,19 @@
<?php
// ** Database settings ** //
/* The name of the database for Allerta-vvf */
define( 'DB_NAME', 'allerta' );
define( 'DB_NAME', '@@db@@' );
/* Database username */
define( 'DB_USER', 'root' );
define( 'DB_USER', '@@user@@' );
/* Database password */
define( 'DB_PASSWORD', '' );
define( 'DB_PASSWORD', '@@password@@' );
/* Database hostname */
define( 'DB_HOST', 'localhost' );
define( 'DB_HOST', '@@host@@' );
/* Database hostname */
define( 'DB_PREFIX', '@@prefix@@' );
// ** Url settings ** //
/* The url that you use to reach Allerta */
@ -34,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

@ -12,7 +12,7 @@ class tools{
define("TOOLS", "OK");
}
public function validazione_form($data, $noempty=true, $valore=null){
public function validate_form_data($data, $noempty=true, $value=null){
if(!is_array($data) && isset($data) && !empty($data)){
if(substr($data, 0, 6) == '$post-'){
$data = substr($data, 6);
@ -23,45 +23,42 @@ class tools{
}
if(is_array($data)){
if(empty($data)){
$continuo = false;
$continue = false;
return false;
} else {
$continuo = true;
$continue = true;
}
if($continuo){
foreach($data as $chiave=>$valore){
if(!is_array($valore) && isset($valore) && !empty($valore)){
if(substr($valore, 0, 6) == '$post-'){
$valore = substr($valore, 6);
if(isset($_POST[$valore])){
$valore = $_POST[$valore];
if($continue){
foreach($data as $key=>$value){
if(!is_array($value) && isset($value) && !empty($value)){
if(substr($value, 0, 6) == '$post-'){
$value = substr($value, 6);
if(isset($_POST[$value])){
$value = $_POST[$value];
}
}
}
if($continuo){
if(!is_array($valore)){
bdump($valore);
if($continue){
if(!is_array($value)){
bdump($value);
bdump("_");
$validazione = $this->validazione_form($valore, $noempty, $valore);
$validazione = $this->validate_form_data($value, $noempty, $value);
if(!$validazione){
$continuo = false;
$continue = false;
return false;
}
}
}
}
if($continuo){
bdump("passato con");
bdump($data);
if($continue){
return true;
}
}
} else if(isset($data)) {
if(!empty($data)){
if(!is_null($valore)){
return $valore == $data;
if(!is_null($value)){
return $value == $data;
} else {
bdump("non dovrebbe succedere");
bdump($data);
return true;
}
@ -144,15 +141,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(){
public function connect(){
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)
{
@ -164,208 +161,228 @@ class database{
if(!defined("DATABASE")){
define("DATABASE", "OK");
}
$this->connetti();
$this->connect();
}
public function close(){
$this->connessione = null;
$this->connection = null;
}
public function esegui($sql, $fetch=false, $param=null){
public function exec($sql, $fetch=false, $param=null){
try{
$this->connessione->beginTransaction();
$this->stmt = $this->connessione->prepare($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();
print "Error!: " . $e->getMessage() . "<br/>";
$this->connection->rollBack();
die();
}
}
public function esiste($tabella, $id){
$risultato = $this->esegui("SELECT :tabella FROM interventi WHERE id = :id;", true, [":tabella" => $tabella, ":id" => $id]);
public function exists($table, $id){
$risultato = $this->exec("SELECT :table FROM `%PREFIX%_interventi` WHERE id = :id;", true, [":table" => $table, ":id" => $id]);
return !empty($risultato);
}
public function aggiungi_intervento($data, $codice, $uscita, $rientro, $capo, $autisti, $personale, $luogo, $note, $tipo, $incrementa, $inseritoda){
public function add_intervento($data, $codice, $uscita, $rientro, $capo, $autisti, $personale, $luogo, $note, $tipo, $incrementa, $inseritoda){
$autisti = implode(",", $autisti);
bdump($autisti);
$personale = implode(",", $personale);
bdump($personale);
$incrementa = implode(",", $incrementa);
bdump($incrementa);
$sql = "INSERT INTO `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 `vigili` 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
$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%_profiles` SET `interventi`= interventi + 1 WHERE id IN (:incrementa);";
$this->exec($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 execre 2 query pdo con salvate le query nella classe dalla classe. Devo execrne 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;
}
public function authenticated(){
return $this->auth->isLoggedIn();
}
public function richiedilogin(){
if(!$this->autenticato()){
public function requirelogin(){
if(!$this->authenticated()){
if(INTRUSION_SAVE){
if(INTRUSION_SAVE_INFO){
$parametri = [":pagina" => $this->tools->get_page_url(), ":ip" => $this->tools->get_ip(), ":data" => date("d/m/Y"), ":ora" => date("H:i.s"), ":servervar" => json_encode($_SERVER)];
$params = [":pagina" => $this->tools->get_page_url(), ":ip" => $this->tools->get_ip(), ":data" => date("d/m/Y"), ":ora" => date("H:i.s"), ":servervar" => json_encode($_SERVER)];
} else {
$parametri = [":pagina" => $this->tools->get_page_url(), ":ip" => "redacted", ":data" => date("d/m/Y"), ":ora" => date("H:i.s"), ":servervar" => json_encode(["redacted" => "true"])];
$params = [":pagina" => $this->tools->get_page_url(), ":ip" => "redacted", ":data" => date("d/m/Y"), ":ora" => date("H:i.s"), ":servervar" => json_encode(["redacted" => "true"])];
}
$sql = "INSERT INTO `intrusioni` (`id`, `pagina`, `data`, `ora`, `ip`, `servervar`) VALUES (NULL, :pagina, :data, :ora, :ip, :servervar)";
$this->database->esegui($sql, false, $parametri);
$sql = "INSERT INTO `%PREFIX%_intrusions` (`id`, `pagina`, `data`, `ora`, `ip`, `servervar`) VALUES (NULL, :pagina, :data, :ora, :ip, :servervar)";
$this->database->exec($sql, false, $params);
}
$this->tools->redirect(WEB_URL);
}
}
public function admin(){
if(isset($_SESSION['admin'])){
if($_SESSION['admin'] == 1){
return true;
} else {
return false;
}
} else {
return false;
public function requireRole($role, $adminGranted=true){
return $this->auth->hasRole($role) || $this->auth->hasRole(Role::SUPER_ADMIN) || ($this->auth->hasRole(Role::ADMIN) && $adminGranted);
}
}
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";
return "not authenticated";
}
}
public function nome_by_id($id){
$vigile = $this->database->esegui("SELECT nome FROM vigili WHERE id = :id;", true, [":id" => $id]);
if(empty($vigile)){
return false;
} else {
return $vigile[0]["nome"];
}
}
public function disponibile($nome){
$vigile = $this->database->esegui("SELECT disponibile FROM vigili WHERE nome = :nome;", true, [":nome" => $nome]);
if(empty($vigile)){
return false;
} else {
return $vigile[0]["disponibile"];
}
}
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());
}
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)){
if(!empty($password)){
$vigili = $this->database->esegui("SELECT * FROM vigili WHERE nome = :nome AND password = :password;", true, [":nome" => $nome, ":password" => $password]);
if(!empty($vigili)){
$_SESSION["accesso"] = "autenticato";
$_SESSION["nome"] = $vigili[0]["nome"];
$_SESSION["admin"] = $vigili[0]["caposquadra"];
return true;
//return $vigili;
public function nameById($id){
$profiles = $this->database->exec("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->exec("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 ["status" => "errore", "codice" => 003, "spiegazione" => "Dati di login non corretti"];
return false;
}
}
} else {
return false;
}
}
public function hidden(){
$profiles = $this->database->exec("SELECT `name` FROM `%PREFIX%_profiles` WHERE hidden = 1;", true);
return $profiles;
}
public function avaible($name){
$user = $this->database->exec("SELECT avaible FROM `%PREFIX%_users` WHERE name = :name;", true, [":name" => $name]);
if(empty($user)){
return false;
} else {
return $user[0]["avaible"];
}
}
public function info(){
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 login($name, $password, $twofa=null){
if(!empty($name)){
if(!empty($password)){
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()){
$this->log("Login", $this->auth->getUserId(), $this->auth->getUserId(), date("d/m/Y"), date("H:i.s"));
$user = $this->database->exec("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){
$parametri = [":azione" => $azione, ":subisce" => $subisce, ":agisce" => $agisce, ":data" => $data, ":ora" => $ora];
$sql = "INSERT INTO `log` (`id`, `azione`, `subisce`, `agisce`, `data`, `ora`) VALUES (NULL, :azione, :subisce, :agisce, :data, :ora)";
$this->database->esegui($sql, false, $parametri);
}
public function lista($tutti=false){
$vigili = $this->database->esegui("SELECT * FROM vigili;", true);
public function log($action, $changed, $editor, $date, $time){
$params = [":action" => $action, ":changed" => $changed, ":editor" => $editor, ":date" => $date, ":time" => $time];
$sql = "INSERT INTO `%PREFIX%_log` (`id`, `action`, `changed`, `editor`, `date`, `time`) VALUES (NULL, :action, :changed, :editor, :date, :time)";
$this->database->exec($sql, false, $params);
}
public function logout(){
unset($_SESSION["accesso"]);
unset($_SESSION["nome"]);
unset($_SESSION["admin"]);
try {
$this->log("Logout", $this->auth->getUserId(), $this->auth->getUserId(), date("d/m/Y"), date("H:i.s"));
$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,17 +1,3 @@
<!DOCTYPE html>
<html>
<head>
<title>Sito in Manutenzione</title>
<meta charset="UTF-8">
<style>
h1 { font-size: 50px; }
body { text-align:center; font: 20px Helvetica, sans-serif; color: #333; }
</style>
</head>
<body>
<h1>Pagina in Manutenzione</h1>
<p>Scusaci per l'incoveniente. Stiamo lavorando per migliorare il servizio.</p>
<p>Saremo di nuovo attivi entro breve. Puoi utilizzare il resto del sito</p>
<p style="margin-top: 40px; font-size: 14px; color: #666"><em>il Webmaster</em></p>
</body>
</html>
<?php
require_once 'ui.php';
loadtemplate('grafici.html', ['titolo' => 'Grafici']);

View File

@ -1,16 +1,16 @@
<?php
require_once 'ui.php';
if($utente->autenticato()){
if($user->authenticated()){
$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 {
$errore = $login;
bdump($errore);
}
}
loadtemplate('index.html', ['errore' => $errore, 'titolo' => 'Login'], false);

2
server/install/buttons.min.css vendored Normal file

File diff suppressed because one or more lines are too long

2
server/install/dashicons.min.css vendored Normal file

File diff suppressed because one or more lines are too long

2
server/install/forms.min.css vendored Normal file

File diff suppressed because one or more lines are too long

386
server/install/install.min.css vendored Normal file
View File

@ -0,0 +1,386 @@
/*! This file is auto-generated */
html {
background: #f1f1f1;
margin: 0 20px
}
body {
background: #fff;
color: #444;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
margin: 140px auto 25px;
padding: 20px 20px 10px 20px;
max-width: 700px;
-webkit-font-smoothing: subpixel-antialiased;
box-shadow: 0 1px 3px rgba(0, 0, 0, .13)
}
a {
color: #0073aa
}
a:active,
a:hover {
color: #00a0d2
}
a:focus {
color: #124964;
box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, .8)
}
.ie8 a:focus {
outline: #5b9dd9 solid 1px
}
h1,
h2 {
border-bottom: 1px solid #ddd;
clear: both;
color: #666;
font-size: 24px;
padding: 0;
padding-bottom: 7px;
font-weight: 400
}
h3 {
font-size: 16px
}
dd,
dt,
li,
p {
padding-bottom: 2px;
font-size: 14px;
line-height: 1.5
}
.code,
code {
font-family: Consolas, Monaco, monospace
}
dl,
ol,
ul {
padding: 5px 5px 5px 22px
}
a img {
border: 0
}
abbr {
border: 0;
font-variant: normal
}
fieldset {
border: 0;
padding: 0;
margin: 0
}
label {
cursor: pointer
}
#logo {
margin: 6px 0 14px 0;
padding: 0 0 7px 0;
border-bottom: none;
text-align: center
}
#logo a {
background-image: url(logo.png);
background-size: 84px;
background-position: center top;
background-repeat: no-repeat;
color: #444;
height: 84px;
font-size: 20px;
font-weight: 400;
line-height: 1.3;
margin: -130px auto 25px;
padding: 0;
text-decoration: none;
width: 84px;
text-indent: -9999px;
outline: 0;
overflow: hidden;
display: block
}
.step {
margin: 20px 0 15px
}
.step,
th {
text-align: left;
padding: 0
}
.language-chooser.wp-core-ui .step .button.button-large {
font-size: 14px
}
textarea {
border: 1px solid #ddd;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
width: 100%;
box-sizing: border-box
}
.form-table {
border-collapse: collapse;
margin-top: 1em;
width: 100%
}
.form-table td {
margin-bottom: 9px;
padding: 10px 20px 10px 0;
font-size: 14px;
vertical-align: top
}
.form-table th {
font-size: 14px;
text-align: left;
padding: 10px 20px 10px 0;
width: 140px;
vertical-align: top
}
.form-table code {
line-height: 1.28571428;
font-size: 14px
}
.form-table p {
margin: 4px 0 0 0;
font-size: 11px
}
.form-table input {
line-height: 1.33333333;
font-size: 15px;
padding: 3px 5px;
border: 1px solid #ddd;
box-shadow: inset 0 1px 2px rgba(0, 0, 0, .07)
}
input,
submit {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif
}
#pass-strength-result,
.form-table input[type=email],
.form-table input[type=password],
.form-table input[type=text],
.form-table input[type=url] {
width: 218px
}
.form-table th p {
font-weight: 400
}
.form-table.install-success td,
.form-table.install-success th {
vertical-align: middle;
padding: 16px 20px 16px 0
}
.form-table.install-success td p {
margin: 0;
font-size: 14px
}
.form-table.install-success td code {
margin: 0;
font-size: 18px
}
#error-page {
margin-top: 50px
}
#error-page p {
font-size: 14px;
line-height: 1.28571428;
margin: 25px 0 20px
}
#error-page code,
.code {
font-family: Consolas, Monaco, monospace
}
.message {
border-left: 4px solid #dc3232;
padding: .7em .6em;
background-color: #fbeaea
}
#admin_email,
#dbhost,
#dbname,
#pass1,
#pass2,
#prefix,
#pwd,
#uname,
#user_login {
direction: ltr
}
.rtl input,
.rtl submit,
.rtl textarea,
body.rtl {
font-family: Tahoma, sans-serif
}
:lang(he-il) .rtl input,
:lang(he-il) .rtl submit,
:lang(he-il) .rtl textarea,
:lang(he-il) body.rtl {
font-family: Arial, sans-serif
}
@media only screen and (max-width:799px) {
body {
margin-top: 115px
}
#logo a {
margin: -125px auto 30px
}
}
@media screen and (max-width:782px) {
.form-table {
margin-top: 0
}
.form-table td,
.form-table th {
display: block;
width: auto;
}
.form-table th {
padding: 20px 0 0
}
.form-table td {
padding: 5px 0;
border: 0;
margin: 0
}
input,
textarea {
font-size: 16px
}
.form-table span.description,
.form-table td input[type=email],
.form-table td input[type=password],
.form-table td input[type=text],
.form-table td input[type=url],
.form-table td select,
.form-table td textarea {
width: 100%;
font-size: 16px;
line-height: 1.5;
padding: 7px 10px;
display: block;
max-width: none;
box-sizing: border-box
}
.wp-pwd #pass1 {
padding-right: 50px
}
.wp-pwd .button.wp-hide-pw {
right: 0
}
#pass-strength-result {
width: 100%
}
}
body.language-chooser {
max-width: 300px
}
.language-chooser select {
padding: 8px;
width: 100%;
display: block;
border: 1px solid #ddd;
background: #fff;
color: #32373c;
font-size: 16px;
font-family: Arial, sans-serif;
font-weight: 400
}
.language-chooser select:focus {
color: #32373c
}
.language-chooser select option:focus,
.language-chooser select option:hover {
color: #016087
}
.language-chooser p {
text-align: right
}
.screen-reader-input,
.screen-reader-text {
border: 0;
clip: rect(1px, 1px, 1px, 1px);
-webkit-clip-path: inset(50%);
clip-path: inset(50%);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
word-wrap: normal!important
}
.spinner {
background: url(spinner.gif) no-repeat;
background-size: 20px 20px;
visibility: hidden;
opacity: .7;
filter: alpha(opacity=70);
width: 20px;
height: 20px;
margin: 2px 5px 0
}
.step .spinner {
display: inline-block;
vertical-align: middle;
margin-right: 15px
}
.button.hide-if-no-js,
.hide-if-no-js {
display: none
}
@media print,
(-webkit-min-device-pixel-ratio:1.25),
(min-resolution:120dpi) {
.spinner {
background-image: url(spinner-2x.gif)
}
}

240
server/install/install.php Normal file
View File

@ -0,0 +1,240 @@
<?php
if (file_exists("installHelper.php")) {
try {
require('installHelper.php');
} catch (Exception $e) {
die("Please re-download Allerta. Installation corrupted (".$e);
}
} else {
die("Please re-download Allerta. Installation corrupted");
}
if (!file_exists("runInstall.php")) {
die("Already installed");
}
if(!is_cli()){
?>
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta name="viewport" content="width=device-width">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="robots" content="noindex,nofollow">
<title>Allerta installazione</title>
<link rel="stylesheet" id="dashicons-css" href="dashicons.min.css?installation" type="text/css" media="all">
<link rel="stylesheet" id="buttons-css" href="buttons.min.css?installation" type="text/css" media="all">
<link rel="stylesheet" id="forms-css" href="forms.min.css?installation" type="text/css" media="all">
<link rel="stylesheet" id="install-css" href="install.min.css?installation" type="text/css" media="all">
<?php if(isset($_POST["step"])){ if($_POST["step"] == "4"){ ?><script async src="zxcvbn.js"></script><?php } } ?>
</head>
<body class="wp-core-ui">
<p id="logo"><a href="javascript:alert('TODO: add docs');">Allerta</a></p>
<?php if(!isset($_POST["step"])){ ?>
<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>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 execre più Allerta con un solo database)</li>
</ol>
<p>
Utilizzeremo queste informazioni per creare un file <code>config.php</code>. <strong>
Se per qualsiasi motivo la creazione automatica dei file non funziona, non ti preoccupare. Tutto questo non fa altro che inserire le informazioni nel database e in un file di configurazione. Puoi aprire <code>config-sample.php</code> in un editor di testo, inserire i tuoi dati, e salvarlo come <code>config.php</code>. </strong>
<p>Con ogni probabilità, queste informazioni ti sono state già fornite dal tuo fornitore di hosting. Se non disponi di queste informazioni, dovrai contattare il tuo fornitore prima di poter proseguire. Se invece è tutto pronto…</p>
<p class="step">
<form method="POST">
<input type="hidden" name="step" value="2">
<input type="submit" value="Invia" class="button button-large">
</form>
</p>
<?php
} else if ($_POST["step"] == "2") {
if (file_exists("../config.php")) {
try {
require('../config.php');
$dbnameValue = DB_NAME;
$unameValue = DB_USER;
$pwdValue = DB_PASSWORD;
$dbhostValue = DB_HOST;
$prefixValue = DB_PREFIX;
} catch (Exception $e) {
$dbnameValue = "allerta";
$unameValue = "user";
$pwdValue = "password";
$dbhostValue = "localhost";
$prefixValue = "allerta01";
}
} else {
$dbnameValue = "allerta";
$unameValue = "user";
$pwdValue = "password";
$dbhostValue = "localhost";
$prefixValue = "allerta01";
}
?>
<h1 class="screen-reader-text">Configura la connection al database</h1>
<form method="post">
<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>
<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 name del database che vuoi utilizzare con Allerta.</td>
</tr>
<tr>
<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 name user del database.</td>
</tr>
<tr>
<th scope="row"><label for="pwd">Password</label></th>
<td><input name="pwd" id="pwd" type="text" aria-describedby="pwd-desc" size="25" value="<?php echo $pwdValue; ?>" autocomplete="off"></td>
<td id="pwd-desc">La tua password del database.</td>
</tr>
<tr>
<th scope="row"><label for="dbhost">Host del database</label></th>
<td><input name="dbhost" id="dbhost" type="text" aria-describedby="dbhost-desc" size="25" value="<?php echo $dbhostValue; ?>"></td>
<td id="dbhost-desc">
Se <code>localhost</code> non funziona, puoi ottenere queste informazioni dal tuo provider di hosting.
</td>
</tr>
<tr>
<th scope="row"><label for="prefix">Prefisso table</label></th>
<td><input name="prefix" id="prefix" type="text" aria-describedby="prefix-desc" value="<?php echo $prefixValue; ?>" size="25"></td>
<td id="prefix-desc">Modifica questa voce se desideri execre più installazioni di Allerta su un singolo database.</td>
</tr>
</tbody>
</table>
<input type="hidden" name="step" value="3">
<p class="step"><input name="submit" type="submit" value="Invia" class="button button-large"></p>
</form>
<?php
} else if ($_POST["step"] == "3") {
checkConnection($_POST["dbhost"],$_POST["uname"],$_POST["pwd"],$_POST["dbname"]);
generateConfig($_POST["dbhost"],$_POST["uname"],$_POST["pwd"],$_POST["dbname"],$_POST["prefix"]);
?>
<h1 class="screen-reader-text">File di configurazione creato con successo!</h1>
<p>Ottimo lavoro, amico! Hai completato questa parte dell'installazione. Ora WordPress può comunicare con il database. Se sei pronto, ora è il momento di…</p>
<p class="step">
<form method="POST">
<input type="hidden" name="step" value="4">
<input type="submit" class="button button-large" value="Popolare il database">
</form>
</p>
<?php
} else if ($_POST["step"] == "4") {
initDB();
?>
<h1 class="screen-reader-text">Evviva!</h1>
<p>Hai <b>quasi terminato</b> l'installazione di Allerta, devi solo inserire alcune informazioni.</p>
<h2>Informazioni necessarie</h2>
<p class="step">
<form id="setup" method="post">
<script>
function validatePwd(){
var pwd = document.getElementById("pass1").value;
result = zxcvbn(pwd);
switch(result.score) {
case 1:
document.getElementById("pass1").className = "short";
document.getElementById("pass-strength-result").className = "short";
document.getElementById("pass-strength-result").innerHTML = "Molto debole";
break;
case 2:
document.getElementById("pass1").className = "bad";
document.getElementById("pass-strength-result").className = "bad";
document.getElementById("pass-strength-result").innerHTML = "Debole";
break;
case 3:
document.getElementById("pass1").className = "good";
document.getElementById("pass-strength-result").className = "good";
document.getElementById("pass-strength-result").innerHTML = "Media";
break;
case 4:
document.getElementById("pass1").className = "strong";
document.getElementById("pass-strength-result").className = "strong";
document.getElementById("pass-strength-result").innerHTML = "Forte";
break;
case 5:
document.getElementById("pass1").className = "strong";
document.getElementById("pass-strength-result").className = "strong";
document.getElementById("pass-strength-result").innerHTML = "Forte";
break;
default:
// code block
}
}
</script>
<table class="form-table" role="presentation">
<tbody>
<tr>
<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 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">
<th scope="row">
<label for="pass1">
Password</label>
</th>
<td>
<div class="wp-pwd">
<input type="text" name="admin_password" id="pass1" class="regular-text short" autocomplete="off" aria-describedby="pass-strength-result" onkeyup="validatePwd()">
<div id="pass-strength-result" aria-live="polite" class="short">Molto debole</div>
</div>
<p><span class="description important">
<strong>Importante:</strong>
Avrai bisogno di questa password per accedere. Conservala in un posto sicuro.</span></p>
</td>
</tr>
<tr>
<th scope="row">Rendi user admin visibile</th>
<td>
<fieldset>
<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'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>
<tr>
<th scope="row"><label for="admin_email">La tua email</label></th>
<td><input name="admin_email" type="email" id="admin_email" size="50" value="">
<p>Controlla attentamente il tuo indirizzo email prima di continuare.</p></td>
</tr>
<tr>
<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>
<p class="step"><input type="submit" name="Submit" id="submit" class="button button-large" value="Installa Allerta"></p>
<input type="hidden" name="step" value="5">
</form>
</p>
<?php
} else if ($_POST["step"] == "5") {
initOptions($_POST["user_name"], isset($_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>
<p class="step">
<a href="../index.php">execre il login</a>
</p>
<?php
unlink("runInstall.php");
}
?>
</div>
</body>
</html>
<?php
} else {
run_cli();
}
?>

View File

@ -0,0 +1,544 @@
<?php
use GetOpt\GetOpt as Getopt;
use GetOpt\Option;
function is_cli() //https://www.binarytides.com/php-check-running-cli/
{
if( defined('STDIN') )
{
return true;
}
if( empty($_SERVER['REMOTE_ADDR']) and !isset($_SERVER['HTTP_USER_AGENT']) and count($_SERVER['argv']) > 0)
{
return true;
}
return false;
}
if (file_exists('../vendor/autoload.php')) {
try {
require '../vendor/autoload.php';
} catch (Exception $e) {
if(is_cli()){
echo($e);
exit(1);
}
die("Please install composer and run composer install (".$e);
}
} else {
if(is_cli()){
echo($e);
exit(1);
}
die("Please install composer and run composer install");
}
define('NAME', 'AllertaVVF');
define('VERSION', '0.1-alpha');
function checkConnection($host, $user, $password, $database){
try{
$connection = new PDO("mysql:host=$host", $user, $password,[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
$connectionOk = true;
} catch (PDOException $e){
if(is_cli()){
echo($e);
exit(8);
}
$connectionOk = false;
?>
<div class="wp-die-message"><h1>Errore nello stabilire una connection al database</h1>
<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 è irraddbile.</p>
<ul>
<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>
<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>
<pre><?php echo($e); ?></pre>
</details>
<p class="step"><a href="#" onclick="javascript:history.go(-1);return false;" class="button button-large">Riprova</a></p>
</div>
<?php
exit();
}
if($connectionOk){
try{
try{
$connection->exec("CREATE DATABASE IF NOT EXISTS " . preg_replace('/[^a-zA-Z0-9]/', '', trim($database)));
} catch(Exception $e) {
//nothing
}
$connection->exec("use " . preg_replace('/[^a-zA-Z0-9]/', '', trim($database)));
} catch (PDOException $e){
if(is_cli()){
echo($e);
exit(7);
}
?>
<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 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'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>
<summary>Informazioni avanzate</summary>
<pre><?php echo($e); ?></pre>
</details>
<p class="step"><a href="#" onclick="javascript:history.go(-1);return false;" class="button button-large">Riprova</a></p>
</div>
<?php
exit();
}
}
}
function replaceInFile($edits,$file){
$content = file_get_contents($file);
foreach($edits as $edit){
$content = str_replace($edit[0],$edit[1],$content);
}
file_put_contents($file,$content);
}
function generateConfig($host,$user,$password,$db,$prefix,$path=".."){
try{
if (file_exists($path.DIRECTORY_SEPARATOR.'config.php')) {
rename($path.DIRECTORY_SEPARATOR."config.php", $path.DIRECTORY_SEPARATOR."config.old.php");
}
copy($path.DIRECTORY_SEPARATOR."config-sample.php", $path.DIRECTORY_SEPARATOR."config.php");
replaceInFile([["@@db@@", $db],["@@user@@",$user],["@@password@@",$password],["@@host@@",$host],["@@prefix@@",$prefix]],$path.DIRECTORY_SEPARATOR."config.php");
} catch (Exception $e) {
if(is_cli()){
echo($e);
exit(6);
}
?>
<div class="wp-die-message"><h1>Impossibile modificare il file di configurazioni</h1>
<p>Non siamo riusciti a scrivere il file di configurazione <code>config.php</code>, richiesto per il funzionamento del programma.<br>E' tuttavia possibile modificarlo manualmente, seguentdo le seguenti istruzioni:</p>
<ul>
<li>Accedere alla cartella di installazione di allerta (connettersi via FTP in caso di server sul cloud).</li>
<li>Rinominare il file <code>config-sample.php</code> in <code>config.php</code>.</li>
<li>Modificare le prime 16 righe del file con il seguente testo:</li>
<code>
&lt;?php<br>
// ** Database settings ** //<br>
/* The name of the database for Allerta-vvf */<br>
define( 'DB_NAME', '<?php echo $db; ?>' );<br>
<br>
/* Database username */<br>
define( 'DB_USER', '<?php echo $user; ?>' );<br>
<br>
/* Database password */<br>
define( 'DB_PASSWORD', '<?php echo $password; ?>' );<br>
<br>
/* Database hostname */<br>
define( 'DB_HOST', '<?php echo $host; ?>' );<br>
<br>
/* Database hostname */<br>
define( 'DB_PREFIX', '<?php echo $prefix; ?>' );<br>
</code>
</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>
<summary>Informazioni avanzate</summary>
<pre><?php echo($e); ?></pre>
</details>
<p class="step"><a href="#" onclick="javascript:history.go(-1);return false;" class="button button-large">Riprova</a></p>
</div>
<?php
exit();
}
}
function initDB(){
try{
require "../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;
$connection->exec("
CREATE TABLE IF NOT EXISTS `".$prefix."_certificati` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`codice` text NOT NULL,
`name` text NOT NULL,
`interventi` text NOT NULL,
`url` text NOT NULL,
`file` text NOT NULL,
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `".$prefix."_esercitazioni` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`data` date NOT NULL,
`name` varchar(999) NOT NULL,
`inizio` time NOT NULL,
`fine` time NOT NULL,
`personale` text NOT NULL,
`capo` text NOT NULL,
`luogo` text NOT NULL,
`note` text NOT NULL,
`dec` varchar(999) NOT NULL DEFAULT 'test',
`inseritoda` varchar(200) NOT NULL DEFAULT 'test',
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `".$prefix."_interventi` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`data` date NOT NULL,
`codice` text NOT NULL,
`uscita` time NOT NULL,
`rientro` time NOT NULL,
`capo` varchar(999) NOT NULL DEFAULT 'test',
`autisti` varchar(999) NOT NULL DEFAULT 'test',
`personale` varchar(999) NOT NULL DEFAULT 'test',
`luogo` varchar(999) NOT NULL DEFAULT 'test',
`note` varchar(999) NOT NULL DEFAULT 'test',
`tipo` text NOT NULL,
`incrementa` varchar(999) NOT NULL,
`inseritoda` varchar(200) NOT NULL,
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `".$prefix."_intrusions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`pagina` varchar(999) COLLATE utf8mb4_unicode_ci NOT NULL,
`data` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`ora` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`ip` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`servervar` varchar(9999) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `".$prefix."_log` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`action` varchar(100) NOT NULL,
`changed` varchar(100) NOT NULL,
`editor` varchar(100) NOT NULL,
`date` varchar(100) NOT NULL,
`time` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `".$prefix."_minuti` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`mese` enum('gennaio','febbraio','marzo','aprile','maggio','giugno','luglio','agosto','settembre','ottobre','novembre','dicembre') NOT NULL,
`anno` varchar(4) NOT NULL,
`list` mediumtext NOT NULL,
`a1` mediumtext NOT NULL,
`a2` mediumtext NOT NULL,
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `".$prefix."_tipo` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` text NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `nametipologia` (`name`(99))
)ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `".$prefix."_users` (
`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,
`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,
`interventi` int(11) NOT NULL DEFAULT 0,
`esercitazioni` int(11) NOT NULL DEFAULT 0,
`online` tinyint(1) NOT NULL DEFAULT 0,
`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,
`enabled` BOOLEAN NOT NULL DEFAULT TRUE,
`created_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_edit` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`user_id` INT NOT NULL,
PRIMARY KEY (`id`),
KEY `Id` (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `".$prefix."_dbversion` (
`id` INT NOT NULL AUTO_INCREMENT,
`version` INT NOT NULL,
`timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `Id` (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `".$prefix."_dbversion` (`id`, `version`, `timestamp`) VALUES (NULL, '1', current_timestamp());");
} catch (Exception $e) {
if(is_cli()){
echo($e);
exit(10);
}
?>
<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 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>
<pre><?php echo($e); ?></pre>
</details>
<p class="step"><a href="#" onclick="javascript:history.go(-1);return false;" class="button button-large">Riprova</a></p>
</div>
<?php
exit();
}
}
final class Role {
//https://github.com/delight-im/PHP-Auth/blob/master/src/Role.php
const SUPER_ADMIN = \Delight\Auth\Role::SUPER_ADMIN;
public function __construct() {}
}
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]);
$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."_profiles` (`id`, `hidden`) VALUES (NULL, :hidden);
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->bindValue(':hidden', ($visible ? 0 : 1), PDO::PARAM_INT);
$prep->bindValue(':report_email', $report_email, PDO::PARAM_STR);
$prep->bindValue(':owner', $owner, PDO::PARAM_STR);
$prep->execute();
} catch (Exception $e) {
if(is_cli()){
echo($e);
exit(11);
}
?>
<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 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>
<pre><?php echo($e); ?></pre>
</details>
<p class="step"><a href="#" onclick="javascript:history.go(-1);return false;" class="button button-large">Riprova</a></p>
</div>
<?php
exit();
}
}
function validate_arg($options, $name, $default){
return array_key_exists($name, $options) ? $options[$name] : (isset($_ENV[$name]) ? $_ENV[$name] : (isset($_ENV[strtoupper($name)]) ? $_ENV[strtoupper($name)] : $default));
}
function change_dir($directory){
try{
chdir($directory);
} catch(Exception $e){
if(is_cli()){
exit(4);
}
}
}
function cli_helper($action, $options){
switch ($action) {
case "config":
$db_name = validate_arg($options, "db_name", "allerta");
$db_username = validate_arg($options, "db_username", "root");
$db_password = validate_arg($options, "db_password", "");
$db_host = validate_arg($options, "db_host", "127.0.0.1");
$db_prefix = validate_arg($options, "db_prefix", "allerta");
$path = isset($options->getOptions["path"]) ? "." : "..";
checkConnection($db_host, $db_username, $db_password, $db_name);
generateConfig($db_host,$db_username,$db_password,$db_name,$db_prefix,$path);
echo("Config created successful");
exit(0);
case "populate":
$name = validate_arg($options, "name", "admin");
$visible = array_key_exists("visible", $options);
$password = validate_arg($options, "password", "password");
$report_email = validate_arg($options, "report_email", "postmaster@localhost.local");
$owner = validate_arg($options, "owner", "Owner");
initDB();
initOptions($name, $visible, $password, $report_email, $owner);
echo("DB Populated successful");
unlink("runInstall.php");
exit(0);
}
}
function run_cli(){
$_SERVER['REMOTE_ADDR'] = "127.0.0.1";
$getopt = new \GetOpt\GetOpt();
$getopt->addCommands([
\GetOpt\Command::create('config', 'conf', [
\GetOpt\Option::create('n', 'db_name', \GetOpt\GetOpt::OPTIONAL_ARGUMENT)
->setDescription('DB name')
->setArgumentName('DB name'),
\GetOpt\Option::create('u', 'db_username', \GetOpt\GetOpt::OPTIONAL_ARGUMENT)
->setDescription('DB username')
->setArgumentName('DB username'),
\GetOpt\Option::create('a', 'db_password', \GetOpt\GetOpt::OPTIONAL_ARGUMENT)
->setDescription('DB password')
->setArgumentName('DB password'),
\GetOpt\Option::create('o', 'db_host', \GetOpt\GetOpt::OPTIONAL_ARGUMENT)
->setDescription('DB host')
->setArgumentName('DB host'),
\GetOpt\Option::create('r', 'db_prefix', \GetOpt\GetOpt::OPTIONAL_ARGUMENT)
->setDescription('DB prefix')
->setArgumentName('DB prefix')
])->setDescription(
'Creates the config file "config.php".' . PHP_EOL .
PHP_EOL .
'This file is required for running "populate".'
)->setShortDescription('Create a new config file'),
\GetOpt\Command::create('populate', 'Populate', [
\GetOpt\Option::create('m', 'name', \GetOpt\GetOpt::OPTIONAL_ARGUMENT)
->setDescription('Admin name')
->setArgumentName('Admin name'),
\GetOpt\Option::create('b', 'visible', \GetOpt\GetOpt::NO_ARGUMENT)
->setDescription('Is admin visible?')
->setArgumentName('Is admin visible?'),
\GetOpt\Option::create('s', 'password', \GetOpt\GetOpt::OPTIONAL_ARGUMENT)
->setDescription('Admin password')
->setArgumentName('Admin password'),
\GetOpt\Option::create('w', 'owner', \GetOpt\GetOpt::OPTIONAL_ARGUMENT)
->setDescription('Owner')
->setArgumentName('Owner'),
\GetOpt\Option::create('e', 'report_email', \GetOpt\GetOpt::OPTIONAL_ARGUMENT)
->setDescription('Report email')
->setArgumentName('Report email')
])->setDescription(
'Populate Allerta database.' . PHP_EOL .
PHP_EOL .
'This require a working config.php file.'
)->setShortDescription('Populate DB')
]);
$getopt->addOptions([
Option::create('v', 'version', \GetOpt\GetOpt::NO_ARGUMENT)
->setDescription('Show version information and quit'),
Option::create('h', 'help', \GetOpt\GetOpt::NO_ARGUMENT)
->setDescription('Show this help and quit'),
Option::create("p", 'path', \GetOpt\GetOpt::OPTIONAL_ARGUMENT)
->setDescription('Destination path')
->setArgumentName('path')
->setValidation('is_writable', function($operand, $value) {
if(file_exists($value)){
echo($value . ' is not writable. Directory permissions: ' . @fileperms($value));
exit(4);
} else {
echo($value . ' not exists.');
exit(3);
}
})
]);
// process arguments and catch user errors
try {
try {
$getopt->process();
} catch (Missing $exception) {
// catch missing exceptions if help is requested
if (!$getopt->getOption('help')) {
throw $exception;
}
}
} catch (ArgumentException $exception) {
file_put_contents('php://stderr', $exception->getMessage() . PHP_EOL);
echo PHP_EOL . $getopt->getHelpText();
exit;
}
// show version and quit
if ($getopt->getOption('version')) {
echo sprintf('%s: %s' . PHP_EOL, NAME, VERSION);
exit;
}
// show help and quit
$command = $getopt->getCommand();
if (!$command || $getopt->getOption('help')) {
echo $getopt->getHelpText();
exit;
}
if (isset($getopt->getOptions()["path"])) {
chdir($getopt->getOption('path'));
}
$options = $getopt->getOptions();
switch ($command->name()) {
case "config":
cli_helper("config", $options);
case "populate":
cli_helper("populate", $options);
}
}

BIN
server/install/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

28
server/install/zxcvbn.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,4 @@
<?php
require_once 'ui.php';
loadtemplate('lista.html', ['titolo' => 'Disponibilità']);
bdump($_SESSION);

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 $vigili_tot;
global $profiles_tot;
global $database;
$sql = "SELECT * FROM vigili"; // Pesco i dati della tabella e li ordino in base alla disponibilità
$risultato = $database->esegui($sql, true);
$sql = "SELECT * FROM %PREFIX%_profiles"; // Pesco i dati della table e li ordino in base alla disponibilità
$risultato = $database->exec($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>");
@ -38,13 +38,13 @@ function resetminuti(){
echo $mese . " - " . $anno . "<br>";
$sql = "INSERT INTO `minuti` (`id`, `mese`, `anno`, `list`, `a1`, `a2`) VALUES (NULL, '$mese', '$anno', '$list', '$a1', '$a2')"; // Pesco i dati della tabella e li ordino in base alla disponibilità
$risultato = $database->esegui($sql);
$sql = "INSERT INTO `%PREFIX%_minuti` (`id`, `mese`, `anno`, `list`, `a1`, `a2`) VALUES (NULL, '$mese', '$anno', '$list', '$a1', '$a2')"; // Pesco i dati della table e li ordino in base alla disponibilità
$risultato = $database->exec($sql);
foreach($risultato as $row){
$sql = "UPDATE vigili SET minuti_dispo = '0' WHERE nome ='" . $utente . "'";
$risultato = $database->esegui($sql);
echo "reset effettuato: " . $utente . "<br>";
$sql = "UPDATE %PREFIX%_profiles SET minuti_dispo = '0' WHERE name ='" . $user . "'";
$risultato = $database->exec($sql);
echo "reset effettuato: " . $user . "<br>";
}
if($risultato){
@ -56,7 +56,7 @@ EOT;
}
}
//Per quando dovrò (forse) reinserire i valori in tabella o generare un array
//Per quando dovrò (forse) reinserire i valori in table o generare un array
function array_combine_($keys, $values){
$result = array();
foreach ($keys as $i => $k) {
@ -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 vigili ORDER BY disponibile DESC, caposquadra DESC, interventi ASC, nome ASC"; // Pesco i dati della tabella e li ordino in base alla disponibilità
$risultato = $database->esegui($sql, true);
$sql = "SELECT * FROM %PREFIX%_profiles ORDER BY avaible DESC, caposquadra DESC, interventi ASC, name ASC"; // Pesco i dati della table e li ordino in base alla disponibilità
$risultato = $database->exec($sql, true);
$vigili_tot = array();
$profiles_tot = array();
$incremento = array();
$minuti_dispo_old = array();
foreach($risultato as $row){
$vigili_tot[] = $row['nome'];
if($row['disponibile'] == "1"){
$incremento[] = $row['nome'];
$profiles_tot[] = $row['name'];
if($row['avaible'] == "1"){
$incremento[] = $row['name'];
$minuti_dispo_old[] = $row['minuti_dispo'];
}
}
@ -88,16 +88,16 @@ 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 vigili SET minuti_dispo = '" . $minuti_dispo . "' WHERE nome ='" . $utente . "'";
$risultato = $database->esegui($sql, true);
$sql = "UPDATE %PREFIX%_profiles SET minuti_dispo = '" . $minuti_dispo . "' WHERE name ='" . $user . "'";
$risultato = $database->exec($sql, true);
}
$sql = "SELECT * FROM vigili ORDER BY disponibile DESC, caposquadra DESC, interventi ASC, nome ASC"; // Pesco i dati della tabella e li ordino in base alla disponibilità
$risultato = $database->esegui($sql, true);
$sql = "SELECT * FROM %PREFIX%_profiles ORDER BY avaible DESC, caposquadra DESC, interventi ASC, name ASC"; // Pesco i dati della table e li ordino in base alla disponibilità
$risultato = $database->exec($sql, true);
$minuti_dispo = array();
foreach($risultato as $row){
if($row['disponibile'] == "1"){
if($row['avaible'] == "1"){
$minuti_dispo[] = $row['minuti_dispo'];
}
}

View File

@ -1,27 +1,27 @@
<?php
require_once 'ui.php';
if($tools->validazione_form('$post-mod', true, "aggiungi")) {
if($tools->validate_form_data('$post-mod', true, "add")) {
bdump("per poco...");
if($tools->validazione_form(['$post-data', '$post-codice', '$post-uscita', '$post-rientro', '$post-capo', '$post-luogo', '$post-note', '$post-tipo', '$post-token'])) {
if($tools->validate_form_data(['$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->add_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");
}
}
} elseif($tools->validazione_form('$post-mod', true, "modifica")) {
} elseif($tools->validate_form_data('$post-mod', true, "modifica")) {
bdump("per poco...");
if($tools->validazione_form(['$post-id', '$post-data', '$post-codice', '$post-uscita', '$post-rientro', '$post-capo', '$post-luogo', '$post-note', '$post-tipo', '$post-token'])) {
if($tools->validate_form_data(['$post-id', '$post-data', '$post-codice', '$post-uscita', '$post-rientro', '$post-capo', '$post-luogo', '$post-note', '$post-tipo', '$post-token'])) {
if($_POST["token"] == $_SESSION['token']){
bdump("modifico intervento");
} else {
$tools->redirect("nonfareilfurbo.php");
}
}
} elseif($tools->validazione_form('$post-mod', true, "elimina")) {
} elseif($tools->validate_form_data('$post-mod', true, "elimina")) {
bdump("rimuovo intervento");
if($tools->validazione_form(['$post-id', '$post-token'])) {
if($tools->validate_form_data(['$post-id', '$post-token'])) {
if($_POST["token"] == $_SESSION['token']){
bdump("rimuovo intervento");
} else {
@ -34,25 +34,25 @@ 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 vigili ORDER BY nome ASC", true); // Pesco i dati della tabella e li ordino in base al nome
$tipologie = $database->esegui("SELECT nome FROM tipo ORDER BY nome ASC", true); // Pesco le tipologie della tabella
$modalità = (isset($_GET["aggiungi"])) ? "aggiungi" : ((isset($_GET["modifica"])) ? "modifica" : ((isset($_GET["elimina"])) ? "elimina" : "aggiungi"));
$personale = $database->exec("SELECT * FROM `%PREFIX%_profiles` ORDER BY name ASC", true); // Pesco i dati della table e li ordino in base al name
$tipologie = $database->exec("SELECT name FROM `%PREFIX%_tipo` ORDER BY name ASC", true); // Pesco le tipologie della table
$modalità = (isset($_GET["add"])) ? "add" : ((isset($_GET["modifica"])) ? "modifica" : ((isset($_GET["elimina"])) ? "elimina" : "add"));
bdump($modalità, "modalità");
bdump($tipologie, "tipologie");
bdump($personale, "personale");
$id = "";
if(isset($_GET["id"])){
$id = $_GET["id"];
bdump($database->esiste("interventi", $id));
bdump($database->exists("interventi", $id));
}
if($modalità=="modifica" || $modalità=="elimina"){
if(empty($id)){
$tools->redirect("nonfareilfurbo.php");
} elseif (!$database->esiste("interventi", $id)){
} elseif (!$database->exists("interventi", $id)){
$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' => '', '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,16 +7,16 @@ include_once 'core.php';
init_class();
$sql = "SELECT nome, online, online_time FROM vigili";
$risultato = $database->esegui($sql, true);
$sql = "SELECT name, online, online_time FROM `%PREFIX%_profiles`";
$risultato = $database->exec($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 vigili SET online = '1', online_time = '$minuti' WHERE nome = '" . urldecode($_GET['utente']) . "'";
$risultato = $database->esegui($sql, true);
if(isset($_GET) && !is_null($_GET['user'])){
$sql = "UPDATE `%PREFIX%_profiles` SET online = '1', online_time = '$minuti' WHERE name = '" . urldecode($_GET['user']) . "'";
$risultato = $database->exec($sql, true);
var_dump($risultato);
}
?>

View File

@ -7,8 +7,7 @@ include_once 'core.php';
init_class();
$minuti = date('i');
$sql = "UPDATE vigili SET online='0', online_time='0' WHERE online_time < '$minuti';";
#$sql = "UPDATE vigili SET online='0', online_time='0';";
$risultato = $database->esegui($sql);
$sql = "UPDATE `%PREFIX%_users` SET online='0', online_time='0' WHERE online_time < '$minuti';";
$risultato = $database->exec($sql);
echo $sql;
?>

View File

@ -1,12 +1,12 @@
<?php
include_once '../../core.php';
init_class();
$utente->richiedilogin();
if(isset($_POST["nomeutenteattivato"]) && isset($_POST["nomeutenteattivatore"]) && $_POST["dispo"] == 1) {
$risultato = $database->esegui("UPDATE vigili SET disponibile = 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 vigili SET disponibile = 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->exec("UPDATE `%PREFIX%_profiles` SET `avaible` = '1' WHERE `%PREFIX%_profiles`.`id` = :id;", false, [":id" => $_POST["change_id"]]);
$user->log("Attivazione disponibilita'", $_POST["change_id"], $user->auth->getUserId(), date("d/m/Y"), date("H:i.s"));
} else if(isset($_POST["change_id"]) && $_POST["dispo"] == 0){
$risultato = $database->exec("UPDATE `%PREFIX%_profiles` SET `avaible` = '0' WHERE `%PREFIX%_profiles`.`id` = :id;", false, [":id" => $_POST["change_id"]]);
$user->log("Rimozione disponibilita'", $_POST["change_id"], $user->auth->getUserId(), date("d/m/Y"), date("H:i.s"));
}
?>

View File

@ -1,11 +1,11 @@
<?php
include_once("../../core.php");
init_class();
$utente->richiedilogin();
$user->requirelogin();
$risultato = $database->esegui('SELECT * FROM vigili WHERE id = :id', true, array(":id" => $_GET['utente'])); // Pesco i dati della tabella
$risultato = $database->exec('SELECT * FROM `%PREFIX%_profiles` WHERE id = :id', true, array(":id" => $_GET['user'])); // Pesco i dati della table
$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>");
echo('<img alt="VVF" src="./risorse/images/logo.jpg" 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>");
$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,18 +1,18 @@
<?php
include_once("../../core.php");
init_class();
$utente->richiedilogin();
$user->requirelogin();
$vigili_sql = "SELECT `id`, `nome`, `disponibile`, `caposquadra`, `autista`, `telefono`, `interventi`, `esercitazioni`, `online`, `minuti_dispo`, `immagine` FROM `vigili` LIMIT 0 , 30";
$vigili = $database->esegui($vigili_sql, true);
$users_sql = "SELECT `id`, `name`, `avaible`, `caposquadra`, `autista`, `telefono`, `interventi`, `esercitazioni`, `online`, `minuti_dispo`, `immagine` FROM `%PREFIX%_profiles` LIMIT 0 , 30";
$users = $database->exec($users_sql, true);
$interventi_sql="SELECT * FROM `interventi` ORDER BY `interventi`.`id` DESC LIMIT 0 , 30";
$interventi = $database->esegui($interventi_sql, true);
$interventi_sql="SELECT * FROM `%PREFIX%_interventi` ORDER BY `interventi`.`id` DESC LIMIT 0 , 30";
$interventi = $database->exec($interventi_sql, true);
$esercitazioni_sql="SELECT * FROM `esercitazioni` ORDER BY `esercitazioni`.`id` DESC LIMIT 0 , 30";
$esercitazioni = $database->esegui($esercitazioni_sql, true);
$esercitazioni_sql="SELECT * FROM `%PREFIX%_esercitazioni` ORDER BY `esercitazioni`.`id` DESC LIMIT 0 , 30";
$esercitazioni = $database->exec($esercitazioni_sql, true);
$elenco = ["vigili" => $vigili, "interventi" => $interventi, "esercitazioni" => $esercitazioni];
$elenco = ["users" => $users, "interventi" => $interventi, "esercitazioni" => $esercitazioni];
header("Content-Type: application/json; charset=UTF-8");
echo(json_encode($elenco));

View File

@ -3,16 +3,16 @@ $start = true;
$minuti = 5;
include_once "../../core.php";
init_class();
$utente->richiedilogin();
$user->requirelogin();
function arraynum(){
global $database;
$risultato = $database->esegui("SELECT * FROM vigili ORDER BY disponibile DESC, caposquadra DESC, interventi ASC, nome ASC", true); // Pesco i dati della tabella e li ordino in base alla disponibilità
$risultato = $database->exec("SELECT * FROM `%PREFIX%_profiles` ORDER BY avaible DESC, caposquadra DESC, interventi ASC, name ASC", true); // Pesco i dati della table e li ordino in base alla disponibilità
$incremento = array();
$minuti_dispo_old = array();
foreach($risultato as $row){
if($row['disponibile'] == "1"){
$incremento[] = $row['nome'];
if($row['avaible'] == "1"){
$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->richiedilogin();
$user->requirelogin();
function ancora($content, $id) {
$content = substr($content,0,$limit);
@ -13,7 +13,7 @@ return $content;
$impostazioni['modifica'] = false;
$impostazioni['elimina'] = false;
$risultato = $database->esegui("SELECT * FROM esercitazioni ORDER BY data DESC, inizio desc", true); // Pesco i dati della tabella e li ordino in base alla data
$risultato = $database->exec("SELECT * FROM `%PREFIX%_esercitazioni` ORDER BY data DESC, inizio desc", true); // Pesco i dati della table e li ordino in base alla data
?>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
@ -77,7 +77,7 @@ $risultato = $database->esegui("SELECT * FROM esercitazioni ORDER BY data DESC,
<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 esercitazioni ORDER BY data DESC,
<?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->richiedilogin();
$user->requirelogin();
function ancora($content, $id) {
$content = substr($content,0,$limit);
@ -13,7 +13,7 @@ return $content;
$impostazioni['modifica'] = false;
$impostazioni['elimina'] = false;
$risultato = $database->esegui("SELECT * FROM interventi ORDER BY data DESC, uscita desc", true); // Pesco i dati della tabella e li ordino in base alla data
$risultato = $database->exec("SELECT * FROM `%PREFIX%_interventi` ORDER BY data DESC, uscita desc", true); // Pesco i dati della table e li ordino in base alla data
?>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>

View File

@ -1,11 +1,11 @@
<?php
include_once("../../core.php");
init_class();
$utente->richiedilogin();
$user->requirelogin();
$risultato = $database->esegui("SELECT * FROM vigili ORDER BY disponibile DESC, caposquadra DESC, interventi ASC, minuti_dispo ASC, nome ASC", true);
$risultato = $database->exec("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,19 +40,19 @@ th, td {
<div style="overflow-x:auto;">
<table style="width: 90%; text-align:center;">
<tr>
<th>Nome</th>
<th>Disponibile</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['disponibile'] == 1) {echo "<i class='fa fa-check' style='color:green'></i>";} else{echo "<i class='fa fa-times' style='color:red'></i>";};
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->richiedilogin();
$user->requirelogin();
$risultato = $database->esegui("SELECT * FROM vigili ORDER BY disponibile DESC, caposquadra DESC, interventi ASC, minuti_dispo ASC, nome ASC", true);
$risultato = $database->exec("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,8 +38,8 @@ th, td {
<div style="overflow-x:auto;">
<table style="width: 90%; text-align:center;">
<tr>
<th>Nome</th>
<th>Disponibile</th>
<th>name</th>
<th>avaible</th>
<th>Autista</th>
<th>Chiama</th>
<th>Scrivi</th>
@ -48,29 +48,30 @@ 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"];
$disponibile = $row["disponibile"];
if ($row['caposquadra'] == 1) {echo "<a onclick='AttivoAdmin(\"$nome\", \"$disponibile\");'><img src='./risorse/images/cascoRosso.png' width='20px'> ";} else{echo "<a onclick='AttivoAdmin(\"$nome\", \"$disponibile\");'><img src='./risorse/images/cascoNero.png' width='20px'> ";}
$name = $user->nameById($row["id"]);
$callFunction = ($row['avaible'] == 1) ? "NonAttivo" : "Attivo";
$avaible = $row["avaible"];
if ($row['caposquadra'] == 1) {echo "<a onclick='$callFunction(".$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\", \"$disponibile\");'>";
echo "<u>".$name."</u></a></td><td><a onclick='$callFunction(".$row["id"].");'>";
} else {
echo $row["nome"]."</a></td><td><a onclick='AttivoAdmin(\"$nome\", \"$disponibile\");'>";
echo $name."</a></td><td><a onclick='$callFunction(".$row["id"].");'>";
}
if ($row['disponibile'] == 1) {echo "<i class='fa fa-check' style='color:green'></i>";} else{echo "<i class='fa fa-times' style='color:red'></i>";};
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>
<td>";
if ($row['autista'] == 1) {echo "<img src='./risorse/images/volante.png' width='20px'>";} else{echo "";};
echo "</td>
<td><a href='tel:+" . $row['telefono'] . "'><i class='fa fa-phone'></i></a></td><td>";
if ($row['disponibile'] == 1) {echo " <a href='https://api.whatsapp.com/send?phone=" . $row['telefono'] . "&text=ALLERTA IN CORSO.%20Mettiti%20in%20contatto%20con%20Fulvio'><i class='fa fa-whatsapp' style='color:green'></i></td>";} else{echo "";};
if ($row['avaible'] == 1) {echo " <a href='https://api.whatsapp.com/send?phone=" . $row['telefono'] . "&text=ALLERTA IN CORSO.%20Mettiti%20in%20contatto%20con%20Fulvio'><i class='fa fa-whatsapp' style='color:green'></i></td>";} else{echo "";};
$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,53 +1,11 @@
<?php
include_once("../../core.php");
init_class();
$utente->richiedilogin();
/*
function trovanomi() {
include_once '../../connection.php';
$sql = "SELECT nome FROM vigili"; // Pesco i dati della tabella
$result = mysqli_query($connessione, $sql);
while($row = $result->fetch_array())
{
$rows[] = $row;
}
$nome = array();
foreach($rows as $row)
{
$nome[] = $row['nome'];
$user->requirelogin();
}
mysqli_close($connessione);
return $nome;
}
$risultato = $database->exec("SELECT * FROM `%PREFIX%_log` ORDER BY `date` DESC, `time` DESC", true);
function checkbox_vigili() {
$whitelist = $utente->whitelist();
$id = 0;
$checkbox = <<<HTML
<div class="dropdown show">
<a class="btn btn-secondary dropdown-toggle " href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown link
</a>
<select class="form-control" aria-labelledby="dropdownMenuLink">
HTML;
foreach(trovanomi() as $nome) {
$test = "";
if(in_array($nome, $whitelist)){
$test = "hidden='hidden'";
}
$id = $id + 1;
$checkbox = $checkbox . "<option class='dropdown-item' id='checkbox' style='' $test value='$nome'>" . "<label $test>$nome</label><br>";
}
$checkbox = $checkbox . "</select>";
return $checkbox;
}
*/
$risultato = $database->esegui("SELECT * FROM `log`", true);
$whitelist = $utente->whitelist();
$hidden = $user->hidden();
?>
<style>
th, td {
@ -122,8 +80,8 @@ select::-ms-expand {
<tbody>
<?php
foreach($risultato as $row){
if(!in_array($row['subisce'], $whitelist) OR in_array($utente->nome(), $whitelist)){
echo "<tr><td>" . $row["azione"] . "</td><td>" . $row["subisce"] . "</td><td>" . $row["agisce"] ."</td><td>" . $row['data'] . " - ore " . $row['ora'] . "</tr>";
if(!in_array($row['changed'], $hidden) OR in_array($user->name(), $hidden)){
echo "<tr><td>" . $row["action"] . "</td><td>" . $user->nameById($row["changed"]) . "</td><td>" . $user->nameById($row["editor"]) ."</td><td>" . $row['date'] . " - ore " . $row['time'] . "</tr>";
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

View File

@ -1,22 +1,22 @@
$(document).ready(function(){
$.get("risorse/ajax/ajax_cache.php", function(data, status){
console.log(data);
console.log(data.vigili);
console.log(data.users);
console.log(data.interventi);
console.log(data.esercitazioni);
var db = new Dexie("offline");
console.log(db.tables.length);
if(db.tables.length !== 0){
db.vigilil.clear();
db.usersl.clear();
db.interventi.clear();
console.log("cleaned");
}
db.version(1).stores({
vigili: '++id,nome,disponibile,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.vigili, function( key, val ) {
db.vigili.put(val);
$.each( data.users, function( key, val ) {
db.users.put(val);
});
$.each( data.interventi, function( key, val ) {
db.interventi.put(val);

View File

@ -4,7 +4,7 @@
[].map||(Array.prototype.map=function(a,b){for(var c=this,d=c.length,e=new Array(d),f=0;f<d;f++)f in c&&(e[f]=a.call(b,c[f],f,c));return e}),[].filter||(Array.prototype.filter=function(a){if(null==this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;for(var d=[],e=arguments[1],f=0;f<c;f++)if(f in b){var g=b[f];a.call(e,g,f,b)&&d.push(g)}return d}),[].indexOf||(Array.prototype.indexOf=function(a){if(null==this)throw new TypeError;var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=0;if(arguments.length>1&&(d=Number(arguments[1]),d!=d?d=0:0!==d&&d!=1/0&&d!=-1/0&&(d=(d>0||-1)*Math.floor(Math.abs(d)))),d>=c)return-1;for(var e=d>=0?d:Math.max(c-Math.abs(d),0);e<c;e++)if(e in b&&b[e]===a)return e;return-1});/*!
* Cross-Browser Split 1.1.1
* Copyright 2007-2012 Steven Levithan <stevenlevithan.com>
* Available under the MIT License
* avaible under the MIT License
* http://blog.stevenlevithan.com/archives/cross-browser-split
*/
var nativeSplit=String.prototype.split,compliantExecNpcg=void 0===/()??/.exec("")[1];String.prototype.split=function(a,b){var c=this;if("[object RegExp]"!==Object.prototype.toString.call(a))return nativeSplit.call(c,a,b);var d,e,f,g,h=[],i=(a.ignoreCase?"i":"")+(a.multiline?"m":"")+(a.extended?"x":"")+(a.sticky?"y":""),j=0;for(a=new RegExp(a.source,i+"g"),c+="",compliantExecNpcg||(d=new RegExp("^"+a.source+"$(?!\\s)",i)),b=void 0===b?-1>>>0:b>>>0;(e=a.exec(c))&&!((f=e.index+e[0].length)>j&&(h.push(c.slice(j,e.index)),!compliantExecNpcg&&e.length>1&&e[0].replace(d,function(){for(var a=1;a<arguments.length-2;a++)void 0===arguments[a]&&(e[a]=void 0)}),e.length>1&&e.index<c.length&&Array.prototype.push.apply(h,e.slice(1)),g=e[0].length,j=f,h.length>=b));)a.lastIndex===e.index&&a.lastIndex++;return j===c.length?!g&&a.test("")||h.push(""):h.push(c.slice(j)),h.length>b?h.slice(0,b):h};

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

@ -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>
@ -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';">exec il logout</b></a>
<a href="javascript:void(0);" class="icon" onclick="myFunction()"></a>
</div>
<!-- /Menu -->
@ -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,10 +2,10 @@
{% block content %}
<br>
<img alt="VVF" src="./risorse/images/logo.jpg" 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>
<a id='add' href="esercitazioni/modifica.php?add">add esercitazione</a>
</p>
<br>
<div id="lista"></div>

View File

@ -0,0 +1,36 @@
{% extends "base.html" %}
{% block content %}
<br>
<img alt="VVF" src="./risorse/images/owner.png" width="150" style="display: block; margin-left: auto; margin-right: auto;">
<br>
<div id="lista" hidden></div>
<b>TODO</b>
<script>
$.get( "risorse/ajax/ajax_log.php", function( data ) {
$( "#lista" ).html( data );
console.log( "Caricato lista." );
});
$(document).ready(function() {
setInterval(function() {
$.get( "risorse/ajax/ajax_log.php", function( data ) {
$( "#lista" ).html( data );
});
}, 10000);
});
/*
check();
$(document).ready(function() {
setInterval(function() {
check();
}, 10000);
});
*/
</script>
<br>
<br>
{% endblock %}

View File

@ -11,23 +11,20 @@ var sound = new Howl({
src: ['{{ urlsoftware }}/risorse/musiche/{{ error_sound }}'],
autoplay: true,
volume: 0.9,
onend: function() {
console.log('Finito');
}
});
sound.play();
</script>
<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/{{ error_image }}" class="img-resposive"><br><br><br>
<input type="text" name="nome" placeholder="Nome" required autocomplete="username" autofocus><br><br>
<img alt="VVF" src="{{ urlsoftware }}/risorse/images/logo.png" class="img-resposive"><br><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

@ -2,10 +2,10 @@
{% block content %}
<br>
<img alt="VVF" src="./risorse/images/logo.jpg" 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>
<a id='add' href="interventi/modifica.php?add">add intervento</a>
</p>
<br>
<div id="lista"></div>
@ -23,16 +23,6 @@
}, 10000);
});
/*
check();
$(document).ready(function() {
setInterval(function() {
check();
}, 10000);
});
*/
</script>
<br>
<br>

View File

@ -3,88 +3,49 @@
{% block content %}
<br>
<div class="text-center">
<p>Sei disponibile in caso di allerta?</p>
<button class="btn btn-lg btn-success " onclick="Attivo('{{ utente.nome }}')">Attivo</button>
<p>Sei avaible in caso di allerta?</p>
<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>
<img alt="VVF" src="./risorse/images/logo.jpg" 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>
{% 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

@ -2,7 +2,7 @@
{% block content %}
<br>
<img alt="VVF" src="./risorse/images/logo.jpg" 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

@ -204,7 +204,7 @@ textarea {
}
</style>
<body>
{% if intervento.modalità == "aggiungi" %}
{% if intervento.modalità == "add" %}
<form method="post">
<div class="container">
<label><b>Giorno dell' intervento</b></label>
@ -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.name == "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.name }}
</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.name == "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.name }}
</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.name == "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.name }}
</label>
</div>
{% endfor %}
@ -278,11 +278,11 @@ 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>
<input id="modalità" type="hidden" value="aggiungi" name="mod"></input>
<input id="modalità" type="hidden" value="add" name="mod"></input>
<input id="token" type="hidden" value="{{ intervento.token }}" name="token"></input>
<button type="submit">invia</button>
</div>
@ -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.name == "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.name }}
</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.name == "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.name }}
</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.name == "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.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

View File

View File

@ -0,0 +1,26 @@
<?php
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method void pause()
*
* @SuppressWarnings(PHPMD)
*/
class AcceptanceTester extends \Codeception\Actor
{
use _generated\AcceptanceTesterActions;
/**
* Define custom actions here
*/
}

View File

@ -0,0 +1,10 @@
<?php
namespace Helper;
// here you can define custom actions
// all public methods declared in helper class will be avaible in $I
class Acceptance extends \Codeception\Module
{
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,24 @@
# Codeception Test Suite Configuration
#
# Suite for acceptance tests.
# Perform tests in browser using the WebDriver or PhpBrowser.
# If you need both WebDriver and PHPBrowser tests - create a separate suite.
actor: AcceptanceTester
extensions:
enabled:
- Codeception\Extension\PhpBuiltinServer
config:
Codeception\Extension\PhpBuiltinServer:
hostname: localhost
port: 8000
autostart: true
documentRoot: ../server/
directoryIndex: index.php
startDelay: 1
modules:
enabled:
- PhpBrowser:
url: http://localhost:8000/
- \Helper\Acceptance
step_decorators: ~

View File

@ -0,0 +1,32 @@
<?php
class FirstCest
{
public function frontpageWorks(AcceptanceTester $I)
{
$I->amOnPage('/install/install.php');
$I->click('Invia');
$I->seeCurrentURLEquals('/install/install.php');
$I->fillField('dbhost', '127.0.0.1');
$I->fillField('uname', 'root');
$I->fillField('pwd', 'password');
$I->click('submit');
$I->click('Popolare il database');
$I->fillField('user_name', 'admin_user');
$I->fillField('admin_password', 'password');
$I->checkOption('admin_visible');
$I->fillField('admin_email', 'admin_mail@allertavvf.local');
$I->fillField('owner', 'owner');
$I->click('Submit');
$I->see('execre il login');
$I->click('execre il login');
$I->fillField('name', 'admin_user');
$I->fillField('password', 'password');
$I->click('login');
$I->seeCurrentURLEquals('/lista.php');
$I->see('admin_user');
}
}

View File

@ -11,14 +11,14 @@ $twig = new \Twig\Environment($loader, [
//'cache' => 'compilation'
]);
$template = NULL;
function loadtemplate($templatename, $data, $richiedilogin=true){
global $utente, $twig, $template;
if($richiedilogin){
$utente->richiedilogin();
function loadtemplate($templatename, $data, $requirelogin=true){
global $user, $twig, $template;
if($requirelogin){
$user->requirelogin();
}
$data['distaccamento'] = DISTACCAMENTO;
$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"]);