forked from devcode-it/openstamanager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bug.php
229 lines (186 loc) · 7.41 KB
/
bug.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<?php
include_once __DIR__.'/core.php';
$pageTitle = 'Bug';
$jscript_modules[] = $js.'/ckeditor.js';
if (filter('op') == 'send') {
// Preparazione email
$mail = new Mail();
// Mittente
$mail->From = $post['email_from'];
$mail->FromName = $_SESSION['username'];
$mail->AddReplyTo($post['email_from']);
// Destinatario
$mail->AddAddress($post['email_to']);
// Copia
if (!empty($post['email_cc'])) {
$mail->AddCC($post['email_cc']);
}
// Copia nascosta
if (!empty($post['email_bcc'])) {
$mail->AddBCC($post['email_bcc']);
}
$mail->Subject = 'Segnalazione bug OSM '.$version.' ('.(!empty($revision) ? 'R'.$revision : tr('In sviluppo')).')';
// 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'])) {
$backup_file = $docroot.'/Backup OSM '.date('Y-m-d').' '.date('H_i_s').'.sql';
backup_tables($backup_file);
$mail->AddAttachment($backup_file);
$_SESSION['infos'][] = tr('Backup del database eseguito ed allegato correttamente!');
}
$body = $post['body'].'<hr><br>'.tr('IP').': '.get_client_ip();
// Se ho scelto di inoltrare le INFO del mio sistema
if (!empty($post['info'])) {
$body .= $_SERVER['HTTP_USER_AGENT'].' - '.getOS();
}
$mail->Body = $body;
$mail->AltBody = 'Questa email arriva dal modulo bug di segnalazione bug di OSM';
// Invio mail
if (!$mail->send()) {
$_SESSION['errors'][] = tr("Errore durante l'invio della segnalazione").': '.$mail->ErrorInfo;
} else {
$_SESSION['infos'][] = tr('Email inviata correttamente!');
}
if (!empty($post['sql'])) {
delete($backup_file);
}
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>
<b>'.tr('Attenzione!').'</b> '.tr('Per utilizzare correttamente il modulo di segnalazione bug devi configurare alcuni parametri email nella scheda Impostazioni').'.
'.Modules::link('Impostazioni', $dbo->fetchArray("SELECT `idimpostazione` FROM `zz_settings` WHERE sezione='Email'")[0]['idimpostazione'], tr('Correggi'), null, 'class="btn btn-warning pull-right"').'
<div class="clearfix"></div>
</div>';
}
echo '
<div class="box">
<div class="box-header">
<h3 class="box-title"><i class="fa fa-bug"></i>'.tr('Segnalazione bug').'</h3></h3>
</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>
<th width="150" class="text-right">'.tr('Da').':</th>
<td>
{[ "type": "email", "placeholder": "'.tr('Mittente').'", "name": "email_from", "value": "'.$email_from.'", "required": 1 ]}
</td>
</tr>
<!-- A -->
<tr>
<th class="text-right">'.tr('A').':</th>
<td>
{[ "type": "email", "placeholder": "'.tr('Destinatario').'", "name": "email_to", "value": "'.$email_to.'", "required": 1 ]}
</td>
</tr>
<!-- Cc -->
<tr>
<th class="text-right">'.tr('Cc').':</th>
<td>
{[ "type": "email", "placeholder": "'.tr('Copia a').'...", "name": "email_cc" ]}
</td>
</tr>
<!-- Bcc -->
<tr>
<th class="text-right">'.tr('Bcc').':</th>
<td>
{[ "type": "email", "placeholder": "'.tr('Copia nascosta a').'...", "name": "email_bcc" ]}
</td>
</tr>
<!-- Versione -->
<tr>
<th class="text-right">'.tr('Versione OSM').':</th>
<td>
{[ "type": "span", "placeholder": "'.tr('Versione OSM').'", "value": "'.$version.' ('.(!empty($revision) ? $revision : tr('In sviluppo')).')" ]}
</td>
</tr>
</table>
<div class="row">
<div class="col-xs-12 col-md-4">
{[ "type": "checkbox", "placeholder": "'.tr('Allega file di log').'", "name": "log", "value": "1" ]}
</div>
<div class="col-xs-12 col-md-4">
{[ "type": "checkbox", "placeholder": "'.tr('Allega copia del database').'", "name": "sql", "value": "0" ]}
</div>
<div class="col-xs-12 col-md-4">
{[ "type": "checkbox", "placeholder": "'.tr('Allega informazioni sul PC').'", "name": "info", "value": "1" ]}
</div>
</div>
<div class="clearfix"></div>
<br>
{[ "type": "textarea", "label": "'.tr('Descrizione del bug').'", "name": "body" ]}
<!-- 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>
</div>
</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>" +
"<li>'.tr('Dopo quali specifiche operazioni hai notato il malfunzionameto').'.</li>" +
"</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.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';
}