2017-08-04 16:28:16 +02:00
< ? php
include_once __DIR__ . '/core.php' ;
$pageTitle = 'Bug' ;
$jscript_modules [] = $js . '/ckeditor.js' ;
if ( filter ( 'op' ) == 'send' ) {
$dati = $post ;
// Parametri e-mail
$replace = [
'Server SMTP' => 'email_host' ,
'Username SMTP' => 'email_username' ,
'Porta SMTP' => 'email_porta' ,
'Sicurezza SMTP' => 'email_secure' ,
'Password SMTP' => 'email_password' ,
];
$rs = $dbo -> fetchArray ( " SELECT * FROM zz_settings WHERE sezione = 'Email' " );
foreach ( $rs as $r ) {
if ( ! empty ( $replace [ $r [ 'nome' ]])) {
$dati [ $replace [ $r [ 'nome' ]]] = $r [ 'valore' ];
}
}
// Preparazione email
$mail = new PHPMailer ();
// Se non specificato l'host uso le impostazioni di invio mail di default del server
if ( ! empty ( $dati [ 'email_host' ])) {
$mail -> IsSMTP ();
$mail -> IsHTML ();
$mail -> SMTPDebug = 2 ;
$mail -> Host = $dati [ 'email_host' ];
$mail -> Port = $dati [ 'email_porta' ];
// Controllo se è necessaria l'autenticazione per il server di posta
if ( ! empty ( $dati [ 'email_username' ])) {
$mail -> SMTPAuth = true ;
$mail -> Username = $dati [ 'email_username' ];
$mail -> Password = $dati [ 'email_password' ];
}
if ( in_array ( strtolower ( $dati [ 'email_secure' ]), [ 'ssl' , 'tls' ])) {
$mail -> SMTPSecure = strtolower ( $dati [ 'email_secure' ]);
}
}
$mail -> WordWrap = 50 ;
// Mittente
$mail -> From = $dati [ 'email_from' ];
$mail -> FromName = $_SESSION [ 'username' ];
$mail -> AddReplyTo ( $dati [ 'email_from' ]);
// Destinatario
$mail -> AddAddress ( $dati [ 'email_to' ]);
// Copia
if ( ! empty ( $dati [ 'email_cc' ])) {
$mail -> AddCC ( $dati [ 'email_cc' ]);
}
// Copia nascosta
if ( ! empty ( $dati [ 'email_bcc' ])) {
$mail -> AddBCC ( $dati [ 'email_bcc' ]);
}
2017-09-04 12:02:29 +02:00
$mail -> Subject = 'Segnalazione bug OSM ' . $version . ' (' . ( ! empty ( $revision ) ? 'R' . $revision : tr ( 'In sviluppo' )) . ')' ;
$mail -> AltBody = tr ( 'Questa email arriva dal modulo bug di segnalazione bug di OSM' );
$body = $dati [ 'body' ] . '<hr><br>' . tr ( 'IP' ) . ': ' . get_client_ip () . " <br> \n " ;
2017-08-04 16:28:16 +02:00
// Se ho scelto di inoltrare i file di log, allego
if ( ! empty ( $post [ 'log' ]) && file_exists ( $docroot . '/logs/error.log' )) {
$mail -> AddAttachment ( $docroot . '/logs/error.log' );
}
// Se ho scelto di inoltrare copia del db
if ( ! empty ( $post [ 'sql' ])) {
2017-09-10 14:35:41 +02:00
$backup_file = $docroot . '/Backup OSM ' . date ( 'Y-m-d' ) . ' ' . date ( 'H_i_s' ) . '.sql' ;
backup_tables ( $backup_file );
2017-08-04 16:28:16 +02:00
2017-09-10 14:35:41 +02:00
$mail -> AddAttachment ( $backup_file );
$_SESSION [ 'infos' ][] = tr ( 'Backup del database eseguito ed allegato correttamente!' );
2017-08-04 16:28:16 +02:00
}
// Se ho scelto di inoltrare le INFO del mio sistema
if ( ! empty ( $post [ 'info' ])) {
$body .= $_SERVER [ 'HTTP_USER_AGENT' ] . ' - ' . getOS ();
}
$mail -> Body = $body ;
// Invio mail
if ( ! $mail -> send ()) {
2017-09-04 12:02:29 +02:00
$_SESSION [ 'errors' ][] = tr ( " Errore durante l'invio della segnalazione " ) . ': ' . $mail -> ErrorInfo ;
2017-08-04 16:28:16 +02:00
} else {
2017-09-04 12:02:29 +02:00
$_SESSION [ 'infos' ][] = tr ( 'Email inviata correttamente!' );
2017-08-04 16:28:16 +02:00
}
$mail -> SmtpClose ();
if ( ! empty ( $post [ 'sql' ])) {
2017-09-11 17:49:03 +02:00
delete ( $backup_file );
2017-08-04 16:28:16 +02:00
}
redirect ( $rootdir . '/bug.php' );
exit ();
}
if ( file_exists ( $docroot . '/include/custom/top.php' )) {
include $docroot . '/include/custom/top.php' ;
} else {
include $docroot . '/include/top.php' ;
}
$email_to = '' ;
$email_from = '' ;
$rs = $dbo -> fetchArray ( " SELECT * FROM zz_settings WHERE sezione = 'Email' " );
foreach ( $rs as $r ) {
if (( $r [ 'nome' ] == 'Server SMTP' || $r [ 'nome' ] == 'Indirizzo per le email in uscita' || $r [ 'nome' ] == 'Destinatario' ) && $r [ 'valore' ] == '' ) {
$alert = true ;
}
if ( $r [ 'nome' ] == 'Destinatario' ) {
$email_to = $r [ 'valore' ];
} elseif ( $r [ 'nome' ] == 'Indirizzo per le email in uscita' ) {
$email_from = $r [ 'valore' ];
}
}
if ( ! empty ( $alert )) {
echo '
< div class = " alert alert-warning " >
< i class = " fa fa-warning " ></ i >
2017-09-04 12:02:29 +02:00
< b > '.tr(' Attenzione ! ').' </ b > '.tr(' Per utilizzare correttamente il modulo di segnalazione bug devi configurare alcuni parametri email nella scheda impostazioni ').' .
2017-09-12 09:57:02 +02:00
'.Modules::link(' Impostazioni ', $dbo->fetchArray("SELECT `idimpostazione` FROM `zz_settings` WHERE sezione=' Email '")[0][' idimpostazione '], tr(' Correggi '), null, ' class = " btn btn-warning pull-right " ').'
2017-08-04 16:28:16 +02:00
< div class = " clearfix " ></ div >
</ div > ' ;
}
echo '
< div class = " box " >
< div class = " box-header " >
2017-09-04 12:02:29 +02:00
< h3 class = " box-title " >< i class = " fa fa-bug " ></ i > '.tr(' Segnalazione bug ').' </ h3 ></ h3 >
2017-08-04 16:28:16 +02:00
</ div >
< div class = " box-body " >
< form method = " post " action = " '. $rootdir .'/bug.php?op=send " >
< table class = " table table-bordered table-condensed table-striped table-hover " >
< tr >
2017-09-04 12:02:29 +02:00
< th width = " 150 " class = " text-right " > '.tr(' Da ').' :</ th >
2017-08-04 16:28:16 +02:00
< td >
2017-09-04 12:02:29 +02:00
{[ " type " : " email " , " placeholder " : " '.tr('Mittente').' " , " name " : " email_from " , " value " : " '. $email_from .' " , " required " : 1 ]}
2017-08-04 16:28:16 +02:00
</ td >
</ tr >
<!-- A -->
< tr >
2017-09-04 12:02:29 +02:00
< th class = " text-right " > '.tr(' A ').' :</ th >
2017-08-04 16:28:16 +02:00
< td >
2017-09-04 12:02:29 +02:00
{[ " type " : " email " , " placeholder " : " '.tr('Destinatario').' " , " name " : " email_to " , " value " : " '. $email_to .' " , " required " : 1 ]}
2017-08-04 16:28:16 +02:00
</ td >
</ tr >
<!-- Cc -->
< tr >
2017-09-04 12:02:29 +02:00
< th class = " text-right " > '.tr(' Cc ').' :</ th >
2017-08-04 16:28:16 +02:00
< td >
2017-09-04 12:02:29 +02:00
{[ " type " : " email " , " placeholder " : " '.tr('Copia a').'... " , " name " : " email_cc " ]}
2017-08-04 16:28:16 +02:00
</ td >
</ tr >
<!-- Bcc -->
< tr >
2017-09-04 12:02:29 +02:00
< th class = " text-right " > '.tr(' Bcc ').' :</ th >
2017-08-04 16:28:16 +02:00
< td >
2017-09-04 12:02:29 +02:00
{[ " type " : " email " , " placeholder " : " '.tr('Copia nascosta a').'... " , " name " : " email_bcc " ]}
2017-08-04 16:28:16 +02:00
</ td >
</ tr >
<!-- Versione -->
< tr >
2017-09-04 12:02:29 +02:00
< th class = " text-right " > '.tr(' Versione OSM ').' :</ th >
2017-08-04 16:28:16 +02:00
< td >
2017-09-11 18:50:56 +02:00
{[ " type " : " span " , " placeholder " : " '.tr('Versione OSM').' " , " value " : " '. $version .' ('.(!empty( $revision ) ? $revision : tr('In sviluppo')).') " ]}
2017-08-04 16:28:16 +02:00
</ td >
</ tr >
</ table >
< div class = " row " >
< div class = " col-xs-12 col-md-4 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " checkbox " , " placeholder " : " '.tr('Allega file di log').' " , " name " : " log " , " value " : " 1 " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-xs-12 col-md-4 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " checkbox " , " placeholder " : " '.tr('Allega copia del database').' " , " name " : " sql " , " value " : " 0 " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-xs-12 col-md-4 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " checkbox " , " placeholder " : " '.tr('Allega informazioni sul PC').' " , " name " : " info " , " value " : " 1 " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
< div class = " clearfix " ></ div >
< br >
2017-09-04 12:02:29 +02:00
{[ " type " : " textarea " , " label " : " '.tr('Descrizione del bug').' " , " name " : " body " ]}
2017-08-04 16:28:16 +02:00
<!-- PULSANTI -->
< div class = " row " >
< div class = " col-md-12 text-right " >
2017-09-04 12:02:29 +02:00
< 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 >
</ div >
</ form >
</ div >
</ div >
< script >
$ ( document ) . ready ( function (){
2017-09-04 12:02:29 +02:00
var html = " <p>'.tr('Se hai riscontrato un bug ricordati di specificare').':</p> " +
2017-08-04 16:28:16 +02:00
" <ul> " +
2017-09-04 12:02:29 +02:00
" <li>'.tr('Modulo esatto (o pagina relativa) in cui questi si è verificato').';</li> " +
" <li>'.tr('Dopo quali specifiche operazioni hai notato il malfunzionameto').'.</li> " +
2017-08-04 16:28:16 +02:00
" </ul> " +
2017-09-04 12:02:29 +02:00
" <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> " ;
2017-08-04 16:28:16 +02:00
var firstFocus = 1 ;
CKEDITOR . replace ( " body " , {
toolbar : [
{ name : " document " , items : [ " NewPage " , " Preview " , " - " , " Templates " ] }, // Defines toolbar group with name (used to create voice label) and items in 3 subgroups
[ " Bold " , " Italic " , " Underline " , " Superscript " , " - " , " NumberedList " , " BulletedList " , " Outdent " , " Indent " , " Blockquote " , " - " , " Format " ,], // Defines toolbar group without name
]
});
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 ;
}
});
});
</ script > ' ;
if ( file_exists ( $docroot . '/include/custom/bottom.php' )) {
include $docroot . '/include/custom/bottom.php' ;
} else {
include $docroot . '/include/bottom.php' ;
}