2017-08-04 16:28:16 +02:00
< ? php
2020-09-07 15:04:06 +02:00
/*
* OpenSTAManager : il software gestionale open source per l ' assistenza tecnica e la fatturazione
* Copyright ( C ) DevCode s . n . c .
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < https :// www . gnu . org / licenses />.
*/
2017-08-04 16:28:16 +02:00
2019-09-28 10:43:41 +02:00
use Modules\Emails\Account ;
2019-08-26 18:02:05 +02:00
use Notifications\EmailNotification ;
2017-08-04 16:28:16 +02:00
include_once __DIR__ . '/core.php' ;
2019-09-28 10:43:41 +02:00
$account = Account :: where ( 'predefined' , true ) -> first ();
2018-03-02 20:27:22 +01:00
$bug_email = 'info@openstamanager.com' ;
$user = Auth :: user ();
2017-08-04 16:28:16 +02:00
if ( filter ( 'op' ) == 'send' ) {
// Preparazione email
2019-09-28 10:43:41 +02:00
$mail = new EmailNotification ();
2017-08-04 16:28:16 +02:00
// Destinatario
2018-03-02 20:27:22 +01:00
$mail -> AddAddress ( $bug_email );
2017-08-04 16:28:16 +02:00
2018-03-02 20:27:22 +01:00
// Oggetto
$mail -> Subject = 'Segnalazione bug OSM ' . $version ;
2017-08-04 16:28:16 +02:00
2018-03-02 20:27:22 +01:00
// Aggiunta dei file di log (facoltativo)
2020-09-23 13:36:37 +02:00
if ( ! empty ( post ( 'log' )) && file_exists ( base_dir () . '/logs/error.log' )) {
$mail -> AddAttachment ( base_dir () . '/logs/error.log' );
2017-08-04 16:28:16 +02:00
}
2018-03-02 20:27:22 +01:00
// Aggiunta della copia del database (facoltativo)
2018-07-19 15:33:32 +02:00
if ( ! empty ( post ( 'sql' ))) {
2020-09-23 13:36:37 +02:00
$backup_file = base_dir () . '/Backup OSM ' . date ( 'Y-m-d' ) . ' ' . date ( 'H_i_s' ) . '.sql' ;
2018-03-03 15:03:28 +01:00
Backup :: database ( $backup_file );
2017-08-04 16:28:16 +02:00
2017-09-10 14:35:41 +02:00
$mail -> AddAttachment ( $backup_file );
2018-07-19 17:29:21 +02:00
flash () -> info ( tr ( 'Backup del database eseguito ed allegato correttamente!' ));
2017-08-04 16:28:16 +02:00
}
2018-03-02 20:27:22 +01:00
// Aggiunta delle informazioni di base sull'installazione
$infos = [
'Utente' => $user [ 'username' ],
'IP' => get_client_ip (),
'Versione OSM' => $version . ' (' . ( ! empty ( $revision ) ? $revision : 'In sviluppo' ) . ')' ,
'PHP' => phpversion (),
];
2017-09-14 11:40:13 +02:00
2018-03-02 20:27:22 +01:00
// Aggiunta delle informazioni sul sistema (facoltativo)
2018-07-19 15:33:32 +02:00
if ( ! empty ( post ( 'info' ))) {
2018-03-02 20:27:22 +01:00
$infos [ 'Sistema' ] = $_SERVER [ 'HTTP_USER_AGENT' ] . ' - ' . getOS ();
}
// Completamento del body
2018-07-19 15:33:32 +02:00
$body = post ( 'body' ) . '<hr>' ;
2018-03-02 20:27:22 +01:00
foreach ( $infos as $key => $value ) {
$body .= '<p>' . $key . ': ' . $value . '</p>' ;
2017-08-04 16:28:16 +02:00
}
$mail -> Body = $body ;
2017-09-14 11:40:13 +02:00
$mail -> AltBody = 'Questa email arriva dal modulo bug di segnalazione bug di OSM' ;
2017-08-04 16:28:16 +02:00
// Invio mail
if ( ! $mail -> send ()) {
2018-07-19 17:29:21 +02:00
flash () -> error ( tr ( " Errore durante l'invio della segnalazione " ) . ': ' . $mail -> ErrorInfo );
2017-08-04 16:28:16 +02:00
} else {
2018-07-19 17:29:21 +02:00
flash () -> info ( tr ( 'Email inviata correttamente!' ));
2017-08-04 16:28:16 +02:00
}
2018-03-02 20:27:22 +01:00
// Rimozione del dump del database
2018-07-19 15:33:32 +02:00
if ( ! empty ( post ( 'sql' ))) {
2017-09-11 17:49:03 +02:00
delete ( $backup_file );
2017-08-04 16:28:16 +02:00
}
2020-09-23 13:36:37 +02:00
redirect ( base_link () . '/bug.php' );
2017-08-04 16:28:16 +02:00
exit ();
}
2018-03-02 20:27:22 +01:00
$pageTitle = tr ( 'Bug' );
2018-06-26 09:41:43 +02:00
include_once App :: filepath ( 'include|custom|' , 'top.php' );
2017-08-04 16:28:16 +02:00
2019-09-28 10:43:41 +02:00
if ( empty ( $account [ 'from_address' ]) || empty ( $account [ 'server' ])) {
2018-03-02 20:27:22 +01:00
echo '
< div class = " alert alert-warning " >
< i class = " fa fa-warning " ></ i >
< b > '.tr(' Attenzione ! ').' </ b > '.tr(' Per utilizzare correttamente il modulo di segnalazione bug devi configurare alcuni parametri riguardanti le impostazione delle email ').' .
2017-08-04 16:28:16 +02:00
2019-09-28 10:43:41 +02:00
'.Modules::link(' Account email ', $account[' id '], tr(' Correggi account '), null, ' class = " btn btn-warning pull-right " ').'
2018-03-02 20:27:22 +01:00
< div class = " clearfix " ></ div >
</ div > ' ;
}
2017-08-04 16:28:16 +02:00
2018-03-02 20:27:22 +01:00
echo '
< div class = " box " >
< div class = " box-header " >
< h3 class = " box-title " >< i class = " fa fa-bug " ></ i > '.tr(' Segnalazione bug ').' </ h3 >
</ div >
< div class = " box-body " >
< form method = " post " action = " " >
< input type = " hidden " name = " op " value = " send " >
< table class = " table table-bordered table-condensed table-striped table-hover " >
< tr >
< th width = " 150 " class = " text-right " > '.tr(' Da ').' :</ th >
2019-09-28 10:43:41 +02:00
< td > '.$account[' from_address '].' </ td >
2018-03-02 20:27:22 +01:00
</ tr >
<!-- A -->
< tr >
< th class = " text-right " > '.tr(' A ').' :</ th >
< td > '.$bug_email.' </ td >
</ tr >
<!-- Versione -->
< tr >
< th class = " text-right " > '.tr(' Versione OSM ').' :</ th >
< td > '.$version.' ( '.(!empty($revision) ? $revision : tr(' In sviluppo ')).' ) </ td >
</ tr >
</ table >
< div class = " row " >
< div class = " col-md-4 " >
{[ " type " : " checkbox " , " placeholder " : " '.tr('Allega file di log').' " , " name " : " log " , " value " : " 1 " ]}
</ div >
2017-09-22 15:16:56 +02:00
2018-03-02 20:27:22 +01:00
< div class = " col-md-4 " >
{[ " type " : " checkbox " , " placeholder " : " '.tr('Allega copia del database').' " , " name " : " sql " ]}
</ div >
2017-09-22 15:16:56 +02:00
2018-03-02 20:27:22 +01:00
< div class = " col-md-4 " >
{[ " type " : " checkbox " , " placeholder " : " '.tr('Allega informazioni sul PC').' " , " name " : " info " , " value " : " 1 " ]}
</ div >
</ div >
2017-09-22 15:16:56 +02:00
2018-03-02 20:27:22 +01:00
< div class = " clearfix " ></ div >
< br >
2017-08-04 16:28:16 +02:00
2018-09-07 17:43:52 +02:00
{[ " type " : " ckeditor " , " label " : " '.tr('Descrizione del bug').' " , " name " : " body " ]}
2018-03-02 20:27:22 +01:00
<!-- PULSANTI -->
< div class = " row " >
< div class = " col-md-12 text-right " >
< button type = " submit " class = " btn btn-primary " id = " send " disabled >
< i class = " fa fa-envelope " ></ i > '.tr(' Invia segnalazione ').'
</ button >
2017-08-04 16:28:16 +02:00
</ div >
2018-03-02 20:27:22 +01:00
</ div >
</ form >
</ div >
</ div >
< script >
$ ( document ) . ready ( function (){
var html = " <p>'.tr('Se hai riscontrato un bug ricordati di specificare').':</p> " +
" <ul> " +
" <li>'.tr('Modulo esatto (o pagina relativa) in cui questi si è verificato').';</li> " +
2018-09-28 09:57:25 +02:00
" <li>'.tr('Dopo quali specifiche operazioni hai notato il malfunzionamento').'.</li> " +
2018-03-02 20:27:22 +01:00
" </ul> " +
" <p>'.tr('Assicurati inoltre di controllare che il checkbox relativo ai file di log sia contrassegnato, oppure riporta qui l \ 'errore visualizzato').'.</p> " +
" <p>'.tr('Ti ringraziamo per il tuo contributo').',<br> " +
" '.tr('Lo staff di OSM').'</p> " ;
var firstFocus = 1 ;
CKEDITOR . instances . body . on ( " key " , function () {
setTimeout ( function (){
if ( CKEDITOR . instances . body . getData () == " " ){
$ ( " #send " ) . prop ( " disabled " , true );
}
else $ ( " #send " ) . prop ( " disabled " , false );
}, 10 );
});
CKEDITOR . instances . body . setData ( html , function () {});
CKEDITOR . instances . body . on ( " focus " , function () {
if ( firstFocus ){
CKEDITOR . instances . body . setData ( " " , function () {
CKEDITOR . instances . body . focus ();
});
firstFocus = 0 ;
}
});
});
2018-06-23 15:41:32 +02:00
</ script >
< script type = " text/javascript " charset = " utf-8 " src = " '.App::getPaths()['js'].'/ckeditor/ckeditor.js'.' " ></ script > ' ;
2017-08-04 16:28:16 +02:00
2018-06-26 09:41:43 +02:00
include_once App :: filepath ( 'include|custom|' , 'bottom.php' );