mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-24 23:37:51 +01:00
Introduzione inizializzazione di OSM
Introduzione della sezione di inizializzazione delle informazioni di base per il funzionamento del gestionale.
This commit is contained in:
parent
317dd56549
commit
6c6a370757
152
actions.php
152
actions.php
@ -40,156 +40,20 @@ if (filter('op') == 'link_file' || filter('op') == 'unlink_file') {
|
||||
else {
|
||||
// UPLOAD
|
||||
if (filter('op') == 'link_file' && !empty($_FILES) && !empty($_FILES['blob']['name'])) {
|
||||
$nome = filter('nome_allegato');
|
||||
$nome = !empty($nome) ? $nome : $_FILES['blob']['name'];
|
||||
|
||||
$src = $_FILES['blob']['tmp_name'];
|
||||
$f = pathinfo($_FILES['blob']['name']);
|
||||
|
||||
/*
|
||||
$allowed = [
|
||||
// Image formats
|
||||
'jpg' => 'image/jpeg',
|
||||
'jpeg' => 'image/jpeg',
|
||||
'jpe' => 'image/jpeg',
|
||||
'gif' => 'image/gif',
|
||||
'png' => 'image/png',
|
||||
'bmp' => 'image/bmp',
|
||||
'tif' => 'image/tiff',
|
||||
'tiff' => 'image/tiff',
|
||||
'ico' => 'image/x-icon',
|
||||
// Video formats
|
||||
'asx' => 'video/asf',
|
||||
'asf' => 'video/asf',
|
||||
'wax' => 'video/asf',
|
||||
'wmv' => 'video/asf',
|
||||
'wmx' => 'video/asf',
|
||||
'avi' => 'video/avi',
|
||||
'divx' => 'video/divx',
|
||||
'flv' => 'video/x-flv',
|
||||
'mov' => 'video/quicktime',
|
||||
'qt' => 'video/quicktime',
|
||||
'mpg' => 'video/mpeg',
|
||||
'mpeg' => 'video/mpeg',
|
||||
'mpe' => 'video/mpeg',
|
||||
'mp4' => 'video/mp4',
|
||||
'm4v' => 'video/mp4',
|
||||
'ogv' => 'video/ogg',
|
||||
'mkv' => 'video/x-matroska',
|
||||
// Text formats
|
||||
'txt' => 'text/plain',
|
||||
'csv' => 'text/csv',
|
||||
'tsv' => 'text/tab-separated-values',
|
||||
'ics' => 'text/calendar',
|
||||
'rtx' => 'text/richtext',
|
||||
'css' => 'text/css',
|
||||
'htm' => 'text/html',
|
||||
'html' => 'text/html',
|
||||
// Audio formats
|
||||
'mp3' => 'audio/mpeg',
|
||||
'm4a' => 'audio/mpeg',
|
||||
'm4b' => 'audio/mpeg',
|
||||
'mp' => 'audio/mpeg',
|
||||
'm4b' => 'audio/mpeg',
|
||||
'ra' => 'audio/x-realaudio',
|
||||
'ram' => 'audio/x-realaudio',
|
||||
'wav' => 'audio/wav',
|
||||
'ogg' => 'audio/ogg',
|
||||
'oga' => 'audio/ogg',
|
||||
'mid' => 'audio/midi',
|
||||
'midi' => 'audio/midi',
|
||||
'wma' => 'audio/wma',
|
||||
'mka' => 'audio/x-matroska',
|
||||
// Misc application formats
|
||||
'rtf' => 'application/rtf',
|
||||
'js' => 'application/javascript',
|
||||
'pdf' => 'application/pdf',
|
||||
'swf' => 'application/x-shockwave-flash',
|
||||
'class' => 'application/java',
|
||||
'tar' => 'application/x-tar',
|
||||
'zip' => 'application/zip',
|
||||
'gz' => 'application/x-gzip',
|
||||
'gzip' => 'application/x-gzip',
|
||||
'rar' => 'application/rar',
|
||||
'7z' => 'application/x-7z-compressed',
|
||||
// MS Office formats
|
||||
'doc' => 'application/msword',
|
||||
'pot' => 'application/vnd.ms-powerpoint',
|
||||
'pps' => 'application/vnd.ms-powerpoint',
|
||||
'ppt' => 'application/vnd.ms-powerpoint',
|
||||
'wri' => 'application/vnd.ms-write',
|
||||
'xla' => 'application/vnd.ms-excel',
|
||||
'xls' => 'application/vnd.ms-excel',
|
||||
'xlt' => 'application/vnd.ms-excel',
|
||||
'xlw' => 'application/vnd.ms-excel',
|
||||
'mdb' => 'application/vnd.ms-access',
|
||||
'mpp' => 'application/vnd.ms-project',
|
||||
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'docm' => 'application/vnd.ms-word.document.macroEnabled.12',
|
||||
'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
|
||||
'dotm' => 'application/vnd.ms-word.template.macroEnabled.12',
|
||||
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12',
|
||||
'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
|
||||
'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
|
||||
'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12',
|
||||
'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12',
|
||||
'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
|
||||
'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
|
||||
'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12',
|
||||
'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
|
||||
'potm' => 'application/vnd.ms-powerpoint.template.macroEnabled.12',
|
||||
'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12',
|
||||
'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
|
||||
'sldm' => 'application/vnd.ms-powerpoint.slide.macroEnabled.12',
|
||||
'onetoc' => 'application/onenote',
|
||||
'onetoc2' => 'application/onenote',
|
||||
'onetmp' => 'application/onenote',
|
||||
'onepkg' => 'application/onenote',
|
||||
// OpenOffice formats
|
||||
'odt' => 'application/vnd.oasis.opendocument.text',
|
||||
'odp' => 'application/vnd.oasis.opendocument.presentation',
|
||||
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
|
||||
'odg' => 'application/vnd.oasis.opendocument.graphics',
|
||||
'odc' => 'application/vnd.oasis.opendocument.chart',
|
||||
'odb' => 'application/vnd.oasis.opendocument.database',
|
||||
'odf' => 'application/vnd.oasis.opendocument.formula',
|
||||
// WordPerfect formats
|
||||
'wp' => 'application/wordperfect',
|
||||
'wpd' => 'application/wordperfect',
|
||||
];
|
||||
|
||||
|
||||
if (in_array($f['extension'], array_keys($allowed))) {
|
||||
*/
|
||||
do {
|
||||
$filename = random_string().'.'.$f['extension'];
|
||||
} while (file_exists($upload_dir.'/'.$filename));
|
||||
$upload = Uploads::upload($_FILES['blob']['tmp_name'], $_FILES['blob']['name'], $upload_dir, [
|
||||
'name' => filter('nome_allegato'),
|
||||
'category' => filter('categoria'),
|
||||
'id_module' => $id_module,
|
||||
'id_record' => $id_record,
|
||||
'id_plugin' => $id_plugin,
|
||||
]);
|
||||
|
||||
// Creazione file fisico
|
||||
if (move_uploaded_file($src, $upload_dir.'/'.$filename)) {
|
||||
$categoria = filter('categoria');
|
||||
|
||||
$dbo->insert('zz_files', [
|
||||
'nome' => $nome,
|
||||
'filename' => $filename,
|
||||
'original' => $_FILES['blob']['name'],
|
||||
'category' => !empty($categoria) ? $categoria : null,
|
||||
'id_module' => !empty($id_module) ? $id_module : null,
|
||||
'id_record' => $id_record,
|
||||
'id_plugin' => !empty($id_plugin) ? $id_plugin : null,
|
||||
]);
|
||||
|
||||
if ($upload) {
|
||||
$_SESSION['infos'][] = tr('File caricato correttamente!');
|
||||
} else {
|
||||
$_SESSION['errors'][] = tr('Errore durante il caricamento del file!');
|
||||
}
|
||||
/*
|
||||
} else {
|
||||
$_SESSION['errors'][] = tr('Tipologia di file non permessa!');
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// DELETE
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
include_once __DIR__.'/../core.php';
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
$valid_config = isset($db_host) && isset($db_name) && isset($db_username) && isset($db_password);
|
||||
|
||||
@ -243,7 +243,7 @@ if (empty($creation) && (!file_exists('config.inc.php') || !$valid_config)) {
|
||||
$("#install").prop(\'disabled\', true);
|
||||
$("#test").prop(\'disabled\', true);
|
||||
|
||||
$("#config_form").submit();
|
||||
$("#config-form").submit();
|
||||
}
|
||||
|
||||
});
|
||||
@ -345,8 +345,6 @@ if (empty($creation) && (!file_exists('config.inc.php') || !$valid_config)) {
|
||||
$username = !empty($db_username) ? $db_username : '';
|
||||
$password = !empty($db_password) ? $db_password : '';
|
||||
$name = !empty($db_name) ? $db_name : '';
|
||||
$osm_password = !empty($_SESSION['osm_password']) ? $_SESSION['osm_password'] : '';
|
||||
$osm_email = !empty($_SESSION['osm_email']) ? $_SESSION['osm_email'] : '';
|
||||
|
||||
// PARAMETRI
|
||||
echo '
|
||||
@ -360,7 +358,7 @@ if (empty($creation) && (!file_exists('config.inc.php') || !$valid_config)) {
|
||||
|
||||
// Form dei parametri
|
||||
echo '
|
||||
<form action="?action=updateconfig&firstuse=true" method="post" id="config_form">
|
||||
<form action="?action=updateconfig&firstuse=true" method="post" id="config-form">
|
||||
<div class="row">';
|
||||
|
||||
// db_host
|
||||
@ -389,21 +387,6 @@ if (empty($creation) && (!file_exists('config.inc.php') || !$valid_config)) {
|
||||
<div class="col-md-4">
|
||||
{[ "type": "text", "label": "'.tr('Nome del database').'", "name": "db_name", "placeholder": "'.tr('Nome del database').'", "value": "'.$name.'", "help": "'.tr('Esempio').': openstamanager", "show-help": 0, "required": 1 ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">';
|
||||
|
||||
// Password utente admin
|
||||
echo '
|
||||
<div class="col-md-6">
|
||||
{[ "type": "password", "label": "'.tr("Password dell'amministratore").'", "name": "osm_password", "placeholder": "'.tr('Scegli la password di amministratore').'", "value": "'.$osm_password.'", "help": "'.tr('Valore di default').': admin", "show-help": 1 ]}
|
||||
</div>';
|
||||
|
||||
// Email utente admin
|
||||
echo '
|
||||
<div class="col-md-6">
|
||||
{[ "type": "email", "label": "'.tr("Email dell'amministratore").'", "name": "osm_email", "placeholder": "'.tr("Digita l'indirizzo email dell'amministratore").'", "value": "'.$osm_email.'" ]}
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
echo '
|
171
include/init/init.php
Normal file
171
include/init/init.php
Normal file
@ -0,0 +1,171 @@
|
||||
<?php
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
$has_azienda = $dbo->fetchNum('SELECT * FROM `an_anagrafiche` LIMIT 1') != 0;
|
||||
$has_user = $dbo->fetchNum('SELECT * FROM `zz_users` LIMIT 1') != 0;
|
||||
|
||||
if (Update::isUpdateAvailable() || ($has_azienda && $has_user)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$pageTitle = tr('Inizializzazione');
|
||||
|
||||
include_once App::filepath('include|custom|', 'top.php');
|
||||
|
||||
// Controllo sull'esistenza di nuovi parametri di configurazione
|
||||
if (post('action') == 'init') {
|
||||
// Azienda predefinita
|
||||
if (!$has_azienda) {
|
||||
Filter::set('post', 'op', 'add');
|
||||
$id_module = Modules::get('Anagrafiche')['id'];
|
||||
include DOCROOT.'/modules/anagrafiche/actions.php';
|
||||
|
||||
// Logo stampe
|
||||
if (!empty($_FILES) && !empty($_FILES['blob']['name'])) {
|
||||
$file_id = Uploads::upload($_FILES['blob']['tmp_name'], $_FILES['blob']['name'], DOCROOT.'/files/anagrafiche', [
|
||||
'name' => 'Logo stampe',
|
||||
'id_module' => $id_module,
|
||||
'id_record' => $id_record,
|
||||
]);
|
||||
|
||||
$file = $dbo->selectOne('zz_files', ['filename'], [
|
||||
'id' => $file_id,
|
||||
]);
|
||||
|
||||
Settings::set('Logo stampe', $file['filename']);
|
||||
}
|
||||
}
|
||||
|
||||
// Utente amministratore
|
||||
if (!$has_user) {
|
||||
$admin = $dbo->selectOne('zz_groups', ['id'], [
|
||||
'nome' => 'Amministratori',
|
||||
]);
|
||||
|
||||
$dbo->insert('zz_users', [
|
||||
'username' => post('admin_username'),
|
||||
'password' => Auth::hashPassword(post('admin_password')),
|
||||
'email' => post('admin_email'),
|
||||
'idgruppo' => $admin['id'],
|
||||
'idanagrafica' => isset($id_record) ? $id_record : 0,
|
||||
'enabled' => 1,
|
||||
]);
|
||||
}
|
||||
|
||||
redirect(ROOTDIR, 'js');
|
||||
exit();
|
||||
}
|
||||
|
||||
$img = App::getPaths()['img'];
|
||||
|
||||
// Visualizzazione dell'interfaccia di impostazione iniziale, nel caso il file di configurazione sia mancante oppure i paramentri non siano sufficienti
|
||||
echo '
|
||||
<div class="box box-center-large box-warning">
|
||||
<div class="box-header with-border text-center">
|
||||
<img src="'.$img.'/logo.png" alt="'.tr('OSM Logo').'">
|
||||
<h3 class="box-title">'.tr('OpenSTAManager').'</h3>
|
||||
</div>
|
||||
|
||||
<div class="box-body">
|
||||
<form action="" method="post" id="init-form" enctype="multipart/form-data">
|
||||
<input type="hidden" name="action" value="init">';
|
||||
|
||||
if (!$has_user) {
|
||||
echo '
|
||||
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">'.tr('Amministrazione').'</h3>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{[ "type": "text", "label": "'.tr('Username').'", "name": "admin_username", "value": "'.$osm_password.'", "placeholder": "'.tr("Digita l'username dell'amministratore").'", "required": 1 ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
{[ "type": "password", "label": "'.tr('Password').'", "name": "admin_password", "value": "'.$osm_password.'", "placeholder": "'.tr("Digita la password dell'amministratore").'", "required": 1 ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
{[ "type": "email", "label": "'.tr('Email').'", "name": "admin_email", "value": "'.$osm_email.'", "placeholder": "'.tr("Digita l'indirizzo email dell'amministratore").'" ]}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
if (!$has_azienda) {
|
||||
echo '
|
||||
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">'.tr('Azienda predefinita').'</h3>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">';
|
||||
|
||||
$idtipoanagrafica = $dbo->fetchArray("SELECT idtipoanagrafica FROM an_tipianagrafiche WHERE descrizione='Azienda'")[0]['idtipoanagrafica'];
|
||||
$readonly_tipo = true;
|
||||
|
||||
ob_start();
|
||||
include DOCROOT.'/modules/anagrafiche/add.php';
|
||||
$anagrafica = ob_get_clean();
|
||||
|
||||
echo str_replace('</form>', '', $anagrafica);
|
||||
|
||||
echo '
|
||||
<div class="box box-success collapsed-box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">'.tr('Logo stampe').'</h3>
|
||||
<div class="box-tools pull-right">
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse">
|
||||
<i class="fa fa-plus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-body collapse">
|
||||
|
||||
<div class="col-md-12">
|
||||
{[ "type": "file", "placeholder": "'.tr('File').'", "name": "blob" ]}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
echo '
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
echo '
|
||||
<!-- PULSANTI -->
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<span>*<small><small>'.tr('Campi obbligatori').'</small></small></span>
|
||||
</div>
|
||||
<div class="col-md-4 text-right">
|
||||
<button type="submit" id="config" class="btn btn-success btn-block">
|
||||
<i class="fa fa-cog"></i> '.tr('Configura').'
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
echo '
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$("button[type=submit]").not("#config").remove();
|
||||
});
|
||||
</script>
|
||||
<script src="'.$rootdir.'/lib/functions.js"></script>
|
||||
<script src="'.$rootdir.'/lib/init.js"></script>';
|
||||
|
||||
include_once App::filepath('include|custom|', 'bottom.php');
|
||||
|
||||
exit();
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
include_once __DIR__.'/../core.php';
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
$updateRate = 20;
|
||||
$scriptValue = $updateRate * 5;
|
||||
@ -75,41 +75,16 @@ if (filter('action') == 'do_update') {
|
||||
echo '
|
||||
<p><strong>'.tr('Aggiornamento completato!!!').'</strong> <i class="fa fa-smile-o"></i></p>';
|
||||
|
||||
// Rimostro la finestra di login
|
||||
echo '
|
||||
<script>
|
||||
$(".login-box").fadeIn();
|
||||
</script>';
|
||||
|
||||
// Istruzioni per la prima installazione
|
||||
if ($_GET['firstuse'] == 'true') {
|
||||
if (!empty($_SESSION['osm_password'])) {
|
||||
$password = $_SESSION['osm_password'];
|
||||
} else {
|
||||
$password = 'admin';
|
||||
}
|
||||
|
||||
echo '
|
||||
<p>'.tr('Puoi procedere al login con i seguenti dati').':</p>
|
||||
<p>'.tr('Username').': <i>admin</i></p>
|
||||
<p>'.tr('Password').': <i> '.$password.'</i></p>
|
||||
<p class="text-danger">'.tr("E' fortemente consigliato rimuovere i permessi di scrittura dal file _FILE_", [
|
||||
'_FILE_' => '<b>config.inc.php</b>',
|
||||
]).'.</p>';
|
||||
]).'.</p>
|
||||
|
||||
// Imposto la password di admin che l'utente ha selezionato all'inizio
|
||||
if (isset($_SESSION['osm_password'])) {
|
||||
$dbo->query('UPDATE `zz_users` SET `password`='.prepare(Auth::hashPassword($password))." WHERE `username`='admin'");
|
||||
|
||||
unset($_SESSION['osm_password']);
|
||||
}
|
||||
|
||||
if (isset($_SESSION['osm_email'])) {
|
||||
if (!empty($_SESSION['osm_email'])) {
|
||||
$dbo->query('UPDATE `zz_users` SET `email`='.prepare($_SESSION['osm_email'])." WHERE `username`='admin' ");
|
||||
}
|
||||
unset($_SESSION['osm_email']);
|
||||
}
|
||||
<a class="btn btn-success btn-block" href="'.ROOTDIR.'">
|
||||
<i class="fa fa-check"></i> '.tr('Continua').'
|
||||
</a>';
|
||||
}
|
||||
}
|
||||
|
@ -135,6 +135,14 @@ if (Auth::check()) {
|
||||
tempo_attesa_ricerche: '.get_var('Tempo di attesa ricerche in secondi').',
|
||||
};
|
||||
</script>';
|
||||
} else {
|
||||
echo '
|
||||
<script>
|
||||
globals = {
|
||||
locale: \''.$lang.'\',
|
||||
full_locale: \''.$lang.'_'.strtoupper($lang).'\',
|
||||
};
|
||||
</script>';
|
||||
}
|
||||
|
||||
// JS
|
||||
|
@ -52,10 +52,13 @@ if (Auth::check() && isset($dbo) && $dbo->isConnected() && $dbo->isInstalled())
|
||||
}
|
||||
|
||||
// Procedura di installazione
|
||||
include_once $docroot.'/include/configuration.php';
|
||||
include_once $docroot.'/include/init/configuration.php';
|
||||
|
||||
// Procedura di aggiornamento
|
||||
include_once $docroot.'/include/update.php';
|
||||
include_once $docroot.'/include/init/update.php';
|
||||
|
||||
// Procedura di inizializzazione
|
||||
include_once $docroot.'/include/init/init.php';
|
||||
|
||||
$pageTitle = tr('Login');
|
||||
|
||||
|
@ -270,7 +270,7 @@ switch (post('op')) {
|
||||
}
|
||||
|
||||
// Operazioni aggiuntive per il logo
|
||||
if (filter('op') == 'link_file'){
|
||||
if (filter('op') == 'link_file') {
|
||||
$nome = 'Logo stampe';
|
||||
|
||||
if (Settings::get('Azienda predefinita') == $id_record && filter('nome_allegato') == $nome) {
|
||||
|
@ -5,8 +5,6 @@ include_once __DIR__.'/../../core.php';
|
||||
if (get('tipoanagrafica') != '') {
|
||||
$rs = $dbo->fetchArray('SELECT idtipoanagrafica FROM an_tipianagrafiche WHERE descrizione='.prepare(get('tipoanagrafica')));
|
||||
$idtipoanagrafica = $rs[0]['idtipoanagrafica'];
|
||||
} else {
|
||||
$idtipoanagrafica = '';
|
||||
}
|
||||
|
||||
echo '
|
||||
@ -20,12 +18,12 @@ echo '
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
{[ "type": "select", "label": "'.tr('Tipo di anagrafica').'", "name": "idtipoanagrafica[]", "multiple": "1", "required": 1, "values": "query=SELECT idtipoanagrafica AS id, descrizione FROM an_tipianagrafiche WHERE idtipoanagrafica NOT IN (SELECT DISTINCT(x.idtipoanagrafica) FROM an_tipianagrafiche_anagrafiche x INNER JOIN an_tipianagrafiche t ON x.idtipoanagrafica = t.idtipoanagrafica INNER JOIN an_anagrafiche ON an_anagrafiche.idanagrafica = x.idanagrafica WHERE t.descrizione = \'Azienda\' AND deleted = 0) ORDER BY descrizione", "value": "'.$idtipoanagrafica.'" ]}
|
||||
{[ "type": "select", "label": "'.tr('Tipo di anagrafica').'", "name": "idtipoanagrafica[]", "multiple": "1", "required": 1, "values": "query=SELECT idtipoanagrafica AS id, descrizione FROM an_tipianagrafiche WHERE idtipoanagrafica NOT IN (SELECT DISTINCT(x.idtipoanagrafica) FROM an_tipianagrafiche_anagrafiche x INNER JOIN an_tipianagrafiche t ON x.idtipoanagrafica = t.idtipoanagrafica INNER JOIN an_anagrafiche ON an_anagrafiche.idanagrafica = x.idanagrafica WHERE t.descrizione = \'Azienda\' AND deleted = 0) ORDER BY descrizione", "value": "'.(isset($idtipoanagrafica) ? $idtipoanagrafica : null).'", "readonly": '.(!empty($readonly_tipo) ? 1 : 0).' ]}
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
echo
|
||||
'<div class="box box-info collapsed-box">
|
||||
echo '
|
||||
<div class="box box-info collapsed-box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">'.tr('Dati anagrafici').'</h3>
|
||||
<div class="box-tools pull-right">
|
||||
|
@ -36,11 +36,9 @@ switch (filter('op')) {
|
||||
} elseif ($password != $password_rep) {
|
||||
$_SESSION['errors'][] = tr('Le password non coincidono');
|
||||
} else {
|
||||
$idanag = explode('-', filter('idanag'));
|
||||
$idtipoanagrafica = $idanag[0];
|
||||
$idanagrafica = $idanag[1];
|
||||
$idanagrafica = filter('idanag');
|
||||
|
||||
$dbo->query('UPDATE zz_users SET password='.prepare(Auth::hashPassword($password)).', idanagrafica='.prepare($idanagrafica).', idtipoanagrafica='.prepare($idtipoanagrafica).' WHERE id='.prepare($id_utente));
|
||||
$dbo->query('UPDATE zz_users SET password='.prepare(Auth::hashPassword($password)).', idanagrafica='.prepare($idanagrafica).' WHERE id='.prepare($id_utente));
|
||||
|
||||
$_SESSION['infos'][] = tr('Password aggiornata!');
|
||||
}
|
||||
@ -78,9 +76,7 @@ switch (filter('op')) {
|
||||
$password = filter('password1');
|
||||
$password_rep = filter('password2');
|
||||
|
||||
$idanag = explode('-', filter('idanag'));
|
||||
$idtipoanagrafica = $idanag[0];
|
||||
$idanagrafica = $idanag[1];
|
||||
$idanagrafica = filter('idanag');
|
||||
|
||||
// Verifico che questo username non sia già stato usato
|
||||
$n = $dbo->fetchNum('SELECT * FROM zz_users WHERE username='.prepare($username));
|
||||
@ -94,7 +90,7 @@ switch (filter('op')) {
|
||||
} elseif ($password != $password_rep) {
|
||||
$_SESSION['errors'][] = tr('Le password non coincidono');
|
||||
} else {
|
||||
if ($dbo->query('INSERT INTO zz_users(idgruppo, username, password, idanagrafica, idtipoanagrafica, enabled, email) VALUES('.prepare($id_record).', '.prepare($username).', '.prepare(Auth::hashPassword($password)).', '.prepare($idanagrafica).', '.prepare($idtipoanagrafica).", 1, '')")) {
|
||||
if ($dbo->query('INSERT INTO zz_users(idgruppo, username, password, idanagrafica, enabled, email) VALUES('.prepare($id_record).', '.prepare($username).', '.prepare(Auth::hashPassword($password)).', '.prepare($idanagrafica).", 1, '')")) {
|
||||
$dbo->query('INSERT INTO `zz_tokens` (`id_utente`, `token`) VALUES ('.prepare($dbo->lastInsertedID()).', '.prepare(secure_random_string()).')');
|
||||
|
||||
$_SESSION['infos'][] = tr('Utente aggiunto!');
|
||||
|
@ -4,7 +4,7 @@ include_once __DIR__.'/../../../core.php';
|
||||
|
||||
switch ($resource) {
|
||||
case 'anagrafiche_utenti':
|
||||
$query = 'SELECT CONCAT(`an_tipianagrafiche`.`idtipoanagrafica`, "-", `an_anagrafiche`.`idanagrafica`) AS id, `ragione_sociale` AS "descrizione", `descrizione` AS optgroup FROM `an_tipianagrafiche` INNER JOIN `an_tipianagrafiche_anagrafiche` ON `an_tipianagrafiche`.`idtipoanagrafica`=`an_tipianagrafiche_anagrafiche`.`idtipoanagrafica` INNER JOIN `an_anagrafiche` ON `an_anagrafiche`.`idanagrafica`=`an_tipianagrafiche_anagrafiche`.`idanagrafica` |where| ORDER BY `optgroup` ASC';
|
||||
$query = 'SELECT `an_anagrafiche`.`idanagrafica` AS id, `an_anagrafiche`.`ragione_sociale` AS "descrizione", `an_tipianagrafiche`.`descrizione` AS optgroup FROM `an_tipianagrafiche` INNER JOIN `an_tipianagrafiche_anagrafiche` ON `an_tipianagrafiche`.`idtipoanagrafica`=`an_tipianagrafiche_anagrafiche`.`idtipoanagrafica` INNER JOIN `an_anagrafiche` ON `an_anagrafiche`.`idanagrafica`=`an_tipianagrafiche_anagrafiche`.`idanagrafica` |where| ORDER BY `optgroup` ASC';
|
||||
|
||||
$where[] = 'an_anagrafiche.deleted= 0';
|
||||
|
||||
|
@ -4,7 +4,7 @@ include_once __DIR__.'/../../core.php';
|
||||
|
||||
$record = $records[0];
|
||||
|
||||
$utenti = $dbo->fetchArray('SELECT *, (SELECT ragione_sociale FROM an_anagrafiche INNER JOIN an_tipianagrafiche_anagrafiche ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE an_anagrafiche.idanagrafica=zz_users.idanagrafica AND an_tipianagrafiche_anagrafiche.idtipoanagrafica=zz_users.idtipoanagrafica) AS ragione_sociale, (SELECT descrizione FROM an_tipianagrafiche INNER JOIN an_tipianagrafiche_anagrafiche ON an_tipianagrafiche.idtipoanagrafica=an_tipianagrafiche_anagrafiche.idtipoanagrafica WHERE idanagrafica=zz_users.idanagrafica AND an_tipianagrafiche.idtipoanagrafica=zz_users.idtipoanagrafica) AS tipo FROM zz_users WHERE idgruppo='.prepare($record['id']));
|
||||
$utenti = $dbo->fetchArray('SELECT *, (SELECT ragione_sociale FROM an_anagrafiche WHERE an_anagrafiche.idanagrafica=zz_users.idanagrafica ) AS ragione_sociale, (SELECT GROUP_CONCAT(descrizione SEPARATOR ", ") FROM an_tipianagrafiche INNER JOIN an_tipianagrafiche_anagrafiche ON an_tipianagrafiche.idtipoanagrafica=an_tipianagrafiche_anagrafiche.idtipoanagrafica WHERE idanagrafica=zz_users.idanagrafica GROUP BY idanagrafica) AS tipo FROM zz_users WHERE idgruppo='.prepare($record['id']));
|
||||
|
||||
echo '
|
||||
<div class="panel panel-primary">
|
||||
|
@ -31,9 +31,9 @@ if (!empty($id_utente)) {
|
||||
$op = 'change_pwd';
|
||||
$message = tr('Modifica');
|
||||
|
||||
$rs = $dbo->fetchArray('SELECT idanagrafica, idtipoanagrafica, username FROM zz_users WHERE id='.prepare($id_utente));
|
||||
$rs = $dbo->fetchArray('SELECT idanagrafica, username FROM zz_users WHERE id='.prepare($id_utente));
|
||||
$username = $rs[0]['username'];
|
||||
$id_anagrafica = $rs[0]['idtipoanagrafica'].'-'.$rs[0]['idanagrafica'];
|
||||
$id_anagrafica = $rs[0]['idanagrafica'];
|
||||
} else {
|
||||
$op = 'adduser';
|
||||
$message = tr('Aggiungi');
|
||||
@ -127,7 +127,7 @@ echo '
|
||||
'_MIN_' => $min_length_username,
|
||||
]).'",
|
||||
type: "error",
|
||||
});
|
||||
});
|
||||
else
|
||||
$("#link_form").submit();
|
||||
}
|
||||
|
@ -160,4 +160,20 @@ class Filter
|
||||
|
||||
return self::$purifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Imposta una proprietà specifica a un valore personalizzato.
|
||||
*
|
||||
* @param string $method
|
||||
* @param string $property
|
||||
* @param mixed $value
|
||||
*/
|
||||
public static function set($method, $property, $value)
|
||||
{
|
||||
if (strtolower($method) == 'post') {
|
||||
self::$post['data'][$property] = $value;
|
||||
} elseif (strtolower($method) == 'get') {
|
||||
self::$get['data'][$property] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,4 +58,17 @@ class Settings
|
||||
|
||||
return self::$values[$sezione.'.'.$nome];
|
||||
}
|
||||
|
||||
public static function set($name, $value)
|
||||
{
|
||||
$database = Database::getConnection();
|
||||
|
||||
$database->update('zz_settings', [
|
||||
'valore' => $value,
|
||||
], [
|
||||
'nome' => $name,
|
||||
]);
|
||||
|
||||
self::get($nome, null, null, true);
|
||||
}
|
||||
}
|
||||
|
175
src/Uploads.php
Normal file
175
src/Uploads.php
Normal file
@ -0,0 +1,175 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Classe per la gestione degli upload del progetto.
|
||||
*
|
||||
* @since 2.4.1
|
||||
*/
|
||||
class Uploads
|
||||
{
|
||||
protected static $allowed_types = [
|
||||
// Image formats
|
||||
'jpg' => 'image/jpeg',
|
||||
'jpeg' => 'image/jpeg',
|
||||
'jpe' => 'image/jpeg',
|
||||
'gif' => 'image/gif',
|
||||
'png' => 'image/png',
|
||||
'bmp' => 'image/bmp',
|
||||
'tif' => 'image/tiff',
|
||||
'tiff' => 'image/tiff',
|
||||
'ico' => 'image/x-icon',
|
||||
// Video formats
|
||||
'asx' => 'video/asf',
|
||||
'asf' => 'video/asf',
|
||||
'wax' => 'video/asf',
|
||||
'wmv' => 'video/asf',
|
||||
'wmx' => 'video/asf',
|
||||
'avi' => 'video/avi',
|
||||
'divx' => 'video/divx',
|
||||
'flv' => 'video/x-flv',
|
||||
'mov' => 'video/quicktime',
|
||||
'qt' => 'video/quicktime',
|
||||
'mpg' => 'video/mpeg',
|
||||
'mpeg' => 'video/mpeg',
|
||||
'mpe' => 'video/mpeg',
|
||||
'mp4' => 'video/mp4',
|
||||
'm4v' => 'video/mp4',
|
||||
'ogv' => 'video/ogg',
|
||||
'mkv' => 'video/x-matroska',
|
||||
// Text formats
|
||||
'txt' => 'text/plain',
|
||||
'csv' => 'text/csv',
|
||||
'tsv' => 'text/tab-separated-values',
|
||||
'ics' => 'text/calendar',
|
||||
'rtx' => 'text/richtext',
|
||||
'css' => 'text/css',
|
||||
'htm' => 'text/html',
|
||||
'html' => 'text/html',
|
||||
// Audio formats
|
||||
'mp3' => 'audio/mpeg',
|
||||
'm4a' => 'audio/mpeg',
|
||||
'm4b' => 'audio/mpeg',
|
||||
'mp' => 'audio/mpeg',
|
||||
'm4b' => 'audio/mpeg',
|
||||
'ra' => 'audio/x-realaudio',
|
||||
'ram' => 'audio/x-realaudio',
|
||||
'wav' => 'audio/wav',
|
||||
'ogg' => 'audio/ogg',
|
||||
'oga' => 'audio/ogg',
|
||||
'mid' => 'audio/midi',
|
||||
'midi' => 'audio/midi',
|
||||
'wma' => 'audio/wma',
|
||||
'mka' => 'audio/x-matroska',
|
||||
// Misc application formats
|
||||
'rtf' => 'application/rtf',
|
||||
'js' => 'application/javascript',
|
||||
'pdf' => 'application/pdf',
|
||||
'swf' => 'application/x-shockwave-flash',
|
||||
'class' => 'application/java',
|
||||
'tar' => 'application/x-tar',
|
||||
'zip' => 'application/zip',
|
||||
'gz' => 'application/x-gzip',
|
||||
'gzip' => 'application/x-gzip',
|
||||
'rar' => 'application/rar',
|
||||
'7z' => 'application/x-7z-compressed',
|
||||
// MS Office formats
|
||||
'doc' => 'application/msword',
|
||||
'pot' => 'application/vnd.ms-powerpoint',
|
||||
'pps' => 'application/vnd.ms-powerpoint',
|
||||
'ppt' => 'application/vnd.ms-powerpoint',
|
||||
'wri' => 'application/vnd.ms-write',
|
||||
'xla' => 'application/vnd.ms-excel',
|
||||
'xls' => 'application/vnd.ms-excel',
|
||||
'xlt' => 'application/vnd.ms-excel',
|
||||
'xlw' => 'application/vnd.ms-excel',
|
||||
'mdb' => 'application/vnd.ms-access',
|
||||
'mpp' => 'application/vnd.ms-project',
|
||||
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'docm' => 'application/vnd.ms-word.document.macroEnabled.12',
|
||||
'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
|
||||
'dotm' => 'application/vnd.ms-word.template.macroEnabled.12',
|
||||
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12',
|
||||
'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
|
||||
'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
|
||||
'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12',
|
||||
'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12',
|
||||
'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
|
||||
'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
|
||||
'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12',
|
||||
'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
|
||||
'potm' => 'application/vnd.ms-powerpoint.template.macroEnabled.12',
|
||||
'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12',
|
||||
'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
|
||||
'sldm' => 'application/vnd.ms-powerpoint.slide.macroEnabled.12',
|
||||
'onetoc' => 'application/onenote',
|
||||
'onetoc2' => 'application/onenote',
|
||||
'onetmp' => 'application/onenote',
|
||||
'onepkg' => 'application/onenote',
|
||||
// OpenOffice formats
|
||||
'odt' => 'application/vnd.oasis.opendocument.text',
|
||||
'odp' => 'application/vnd.oasis.opendocument.presentation',
|
||||
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
|
||||
'odg' => 'application/vnd.oasis.opendocument.graphics',
|
||||
'odc' => 'application/vnd.oasis.opendocument.chart',
|
||||
'odb' => 'application/vnd.oasis.opendocument.database',
|
||||
'odf' => 'application/vnd.oasis.opendocument.formula',
|
||||
// WordPerfect formats
|
||||
'wp' => 'application/wordperfect',
|
||||
'wpd' => 'application/wordperfect',
|
||||
];
|
||||
|
||||
/**
|
||||
* Effettua l'upload di un file nella cartella indicata.
|
||||
*
|
||||
* @param string $src
|
||||
* @param string $original
|
||||
* @param string $upload_dir
|
||||
* @param array $data
|
||||
*
|
||||
* @return int|bool
|
||||
*/
|
||||
public static function upload($src, $original, $upload_dir, $data = [])
|
||||
{
|
||||
$extension = pathinfo($original)['extension'];
|
||||
|
||||
$ok = self::isSupportedType($extension);
|
||||
|
||||
do {
|
||||
$filename = random_string().'.'.$extension;
|
||||
} while (file_exists($upload_dir.'/'.$filename));
|
||||
|
||||
// Creazione file fisico
|
||||
if (!directory($upload_dir) || !move_uploaded_file($src, $upload_dir.'/'.$filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$database = Database::getConnection();
|
||||
|
||||
// Registrazione del file
|
||||
$database->insert('zz_files', [
|
||||
'nome' => !empty($data['name']) ? $data['name'] : $original,
|
||||
'filename' => $filename,
|
||||
'original' => $original,
|
||||
'category' => !empty($data['category']) ? $data['category'] : null,
|
||||
'id_module' => !empty($data['id_module']) ? $data['id_module'] : null,
|
||||
'id_record' => !empty($data['id_record']) ? $data['id_record'] : null,
|
||||
'id_plugin' => !empty($data['id_plugin']) ? $data['id_plugin'] : null,
|
||||
]);
|
||||
|
||||
return $database->lastInsertedID();
|
||||
}
|
||||
|
||||
/**
|
||||
* Controlla se l'estensione è supportata dal sistema di upload.
|
||||
*
|
||||
* @param string $extension
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected static function isSupportedType($extension)
|
||||
{
|
||||
return in_array($extension, array_keys(self::$allowed_types));
|
||||
}
|
||||
}
|
@ -2339,13 +2339,6 @@ CREATE TABLE IF NOT EXISTS `zz_utenti` (
|
||||
PRIMARY KEY (`idutente`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
--
|
||||
-- Dump dei dati per la tabella `zz_utenti`
|
||||
--
|
||||
|
||||
INSERT INTO `zz_utenti` (`idutente`, `username`, `password`, `email`, `idanagrafica`, `idtipoanagrafica`, `idgruppo`, `enabled`) VALUES
|
||||
(1, 'admin', '21232f297a57a5a743894a0e4a801fc3', '', 0, 0, 1, 1);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
|
@ -363,3 +363,6 @@ ALTER TABLE `zz_files` ADD `category` varchar(100) AFTER `original`;
|
||||
|
||||
-- Impostazione "Abilita esportazione Excel e PDF"
|
||||
INSERT INTO `zz_settings` (`idimpostazione`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES (NULL, 'Abilita esportazione Excel e PDF', '0', 'boolean', '1', 'Generali', 18);
|
||||
|
||||
-- Rimozione idtipoanagrafica da zz_users
|
||||
ALTER TABLE `zz_users` DROP `idtipoanagrafica`;
|
||||
|
Loading…
x
Reference in New Issue
Block a user