forked from filipi/onde
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigura.php
378 lines (357 loc) · 14.4 KB
/
configura.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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
<?PHP
/**
* Pagina para configuracao do sistema.
* $Id: configura.php,v 1.49 2018/12/19 20:27:09 filipi Exp $
*/
$headerTitle = "Página de configuração do sistema";
$useSessions = 1; $ehXML = 0;
$myPATH = ini_get('include_path') . ':./include:../include:../../include';
ini_set('include_path', $myPATH);
include "page_header.inc";
if (trim($_POST['banco'])){
/* Salva as configuracoes */
$arquivo_de_configuracao = fopen("./include/conf.new.buffer.inc", "w"); /* w trunca o arquivo para 0 e c nao trunca */
//fclose($arquivo_de_configuracao);
if (!$arquivo_de_configuracao){
Warning("Impossíel abrir arquivo de configuração
para escrita!<BR>Verifique as permissões.");
include "page_footer.inc";
exit(1);
}
$developer_array = explode(",", $_POST['developer']);
$confStr = "<?PHP\n";
$confStr .= " \$banco = \"" . pg_escape_string(trim($_POST['banco'])) . "\";\n";
$confStr .= " \$banco_cadastro = \"" . pg_escape_string(trim($_POST['banco_cadastro'])) . "\";\n";
$confStr .= " \$usuario_banco = \"" . pg_escape_string(trim($_POST['usuario_banco'])) . "\";\n";
$confStr .= " \$senha_banco = \"" . pg_escape_string(trim($_POST['senha_banco'])) . "\";\n";
$confStr .= " \$system_mail_from = \"" . pg_escape_string(trim($_POST['system_mail_from'])) . "\";\n";
$confStr .= " \$system_mail_from_name = \"" . pg_escape_string(trim($_POST['system_mail_from_name'])) . "\";\n";
$confStr .= " \$system_mail_host = \"" . pg_escape_string(trim($_POST['system_mail_host'])) . "\";\n";
$confStr .= " \$system_mail_mailer = \"" . pg_escape_string(trim($_POST['system_mail_mailer'])) . "\";\n";
$confStr .= " \$debug_mail_recipient = \"" . pg_escape_string(trim($_POST['debug_mail_recipient'])) . "\";\n";
$confStr .= " \$URL = \"" . pg_escape_string(trim($_POST['URL'])) . "\";\n";
$confStr .= " \$email = \"" . pg_escape_string(trim($_POST['email'])) . "\";\n";
$confStr .= " \$fone = \"" . pg_escape_string(trim($_POST['fone'])) . "\";\n";
$confStr .= " \$organizationWebSiteURL = \"" . pg_escape_string(trim($_POST['organizationWebSiteURL'])) . "\";\n";
reset($developer_array);
while (list($key, $val) = each($developer_array)){
$confStr .= " \$developer[" . $key . "] = \"";
$confStr .= pg_escape_string(trim($developer_array[$key])) . "\";\n";
}
$confStr .= " \$_menu_from_db = " . intval( (boolean) trim($_POST['menu_from_db']) ) . ";\n";
$confStr .= " \$_debug = " . (integer) trim($_POST['debug']) . ";\n";
$confStr .= " \$_singleQueue = " . (integer) trim($_POST['singleQueue']) . ";\n";
$confStr .= " \$_remoteAssets = " . (integer) trim($_POST['remoteAssets']) . ";\n";
$confStr .= " \$_theme = \"" . pg_escape_string(trim($_POST['theme'])) . "\";\n";
$confStr .= " \$verificaEmail = " . (integer) trim($_POST['verificaEmail']) . ";\n";
$confStr .= " \$encoding = \"" . pg_escape_string(trim($_POST['encoding'])) . "\";\n";
$confStr .= " \$mem_limit = \"" . (integer) trim($_POST['mem_limit']) . "\";\n";
$confStr .= " \$max_execution_time = \"" . (integer) trim($_POST['max_execution_time']) . "\";\n";
foreach($deps as $dep){
$dep = trim(str_replace("-", "_", $dep));
$confStr .= " \$path_to_" . $dep . " = \"" . pg_escape_string(trim($_POST['path_to_' . $dep])) . "\";\n";
}
$confStr .= "?>\n";
fputs($arquivo_de_configuracao, $confStr);
if (fclose($arquivo_de_configuracao)){
$command_to_copy_files = $path_to_cp . " ./include/conf.new.buffer.inc ./include/conf.inc";
$error = `$command_to_copy_files`;
echo "<PRE>\n";
echo htmlentities($error);
echo "\n</PRE>\n";
echo "<DIV class=\"message\">Configurações salvas";
echo " com sucesso!</DIV>\n";
}
else
Warning("Erro gravando configurações!");
if (PHP_VERSION_ID >= 50500) opcache_invalidate("conf.inc");
// Da um include apos salvar para recarregar os valores no FORM
include_once("escapeConfVars.inc");
include "conf.inc"; escapeConfVars();
///////////////////////////////////////////
$query_adm = "SELECT * \n";
$query_adm .= " FROM usuarios\n";
$query_adm .= " WHERE login='" . $_POST['matricula'] . "'\n";
$exec_adm = pg_exec($conn,$query_adm);
$nro_linhas = pg_NumRows($exec_adm);
if ($nro_linhas > 0){
$linha = pg_fetch_row($exec_adm,0);
$h_log = date("Y-m-d H:i:s");
$matricula = $linha[0];
$senha_crypt = $linha[1];
$nome = $linha[2];
$email = $linha[3];
$last_login = $linha[4];
$first = $linha[5];
$_SESSION['h_log'] = $h_log;
$_SESSION['matricula'] = $matricula;
$_SESSION['senha_crypt'] = $senha_crypt;
$_SESSION['nome'] = $nome;
$_SESSION['email'] = $email;
$_SESSION['last_login'] = $last_login;
$_SESSION['first'] = $first;
$_SESSION['ip'] = $ip;
}
/////////////////////////////////////////
}
//echo (integer) isset($_POST['remoteAssets']);
?>
<FORM NAME="configuracao" ACTION="" METHOD="POST">
<BR>
<?PHP
//
// <INPUT TYPE="SUBMIT" CLASS="SUBMIT" VALUE="Salvar...">
// <BR>
togglePoint("visuais", "Configurações visuais da fLameWork O.N.D.E.", 1, false, NULL);
?>
<B>URL do sistema:</B><BR>
<INPUT TYPE="TEXT" CLASS="TEXT" NAME="URL" SIZE="40"
VALUE="<?PHP echo $URL; ?>"><BR><BR>
<B>E-mail mostrado no rodapé do sistema:</B><BR>
<INPUT TYPE="TEXT" CLASS="TEXT" NAME="email" SIZE="40"
VALUE="<?PHP echo $email; ?>"><BR><BR>
<B>Telefone mostrado no rodapé do sistema:</B><BR>
<INPUT TYPE="TEXT" CLASS="TEXT" NAME="fone" SIZE="40"
VALUE="<?PHP echo $fone; ?>"><BR><BR>
<B>URL do website da organização:</B><BR>
<INPUT TYPE="TEXT" CLASS="TEXT" NAME="organizationWebSiteURL" SIZE="40"
VALUE="<?PHP echo $organizationWebSiteURL; ?>"><BR><BR>
<B>Encoding:</B><BR>
<INPUT TYPE="TEXT" CLASS="TEXT" NAME="encoding" SIZE="40"
VALUE="<?PHP echo $encoding; ?>"><BR>
<BR>
<?PHP
// Note that !== did not exist until 4.0.0-RC2
$i = 0;
if ($handle = opendir('themeAssets')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." &&
$file != ".htaccess" && $file != "CVS") {
$themes[] = "$file";
}
}
closedir($handle);
}
echo " \n";
echo " <B>Tema visual:</B><BR>\n";
echo " \n";
echo " <SELECT NAME=\"theme\" SIZE=\"1\" >\n";
foreach($themes as $val){
$dep = trim(str_replace("-", "_", $dep));
if (isset($_POST['theme'])){
if ($_POST['theme']==$val){
echo " <OPTION SELECTED VALUE=\"" . $val . "\">";
echo $val . "</OPTION>\n";
}
else{
echo " <OPTION VALUE=\"" . $val . "\">";
echo $val . "</OPTION>\n";
}
}
else{
if ($_theme == $val){
echo " <OPTION SELECTED VALUE=\"" . $val . "\">";
echo $val . "</OPTION>\n";
}
else{
echo " <OPTION VALUE=\"" . $val . "\">";
echo $val . "</OPTION>\n";
}
}
}
echo " </SELECT><BR><BR>\n";
$label = " <B>Remote assets:</B> (para os temas visuais)<BR>\n";
$label .= " \n";
$label .= " <I>Alguns temas visuais utilizam elementos carregados de sites remotos.<BR>\n";
$label .= " \n";
$label .= " Quando habilitado o “Remote assets”, esses elementos são carregados<BR>\n";
$label .= " \n";
$label .= " do servidor de aplicação.</I><BR>\n";
togglePoint("remoteAssets", $label, 1, true, $_remoteAssets);
?>
<B>Endereço do servidor:</B><BR>
<INPUT TYPE="TEXT" CLASS="TEXT" NAME="host_site" SIZE="40"
VALUE="<?PHP echo $host_site; ?>"><BR>
<BR>
<?PHP
echo $closeDIV;
echo $closeDIV;
echo "<BR>\n";
togglePoint("mailing", "Configurações de envio de e-mail", 1, false, NULL);
?>
<B>Endereço do remetente:</B><BR>
<INPUT TYPE="TEXT" CLASS="TEXT" NAME="system_mail_from" SIZE="40"
VALUE="<?PHP echo $system_mail_from; ?>"><BR>
<BR>
<B>Nome do remetente:</B><BR>
<INPUT TYPE="TEXT" CLASS="TEXT" NAME="system_mail_from_name" SIZE="40"
VALUE="<?PHP echo $system_mail_from_name; ?>"><BR>
<BR>
<B>Endereço do servidor de e-mail:</B><BR>
<INPUT TYPE="TEXT" CLASS="TEXT" NAME="system_mail_host" SIZE="40"
VALUE="<?PHP echo $system_mail_host; ?>"><BR>
<BR>
<B>Protocolo de email utilizado:</B><BR>
<INPUT TYPE="TEXT" CLASS="TEXT" NAME="system_mail_mailer" SIZE="10"
VALUE="<?PHP echo $system_mail_mailer; ?>"><BR>
<BR>
<B>Destinário do e-mail de debug:</B><BR>
<INPUT TYPE="TEXT" CLASS="TEXT" NAME="debug_mail_recipient" SIZE="40"
VALUE="<?PHP echo $debug_mail_recipient; ?>"><BR>
<BR>
<?PHP
echo $closeDIV;
echo "<BR>\n";
togglePoint("avancado", "Configurações avançadas", 1, false, NULL);
?>
<B>Matrícula do usuário desenvolvedor:</B><BR>
<INPUT TYPE="TEXT" CLASS="TEXT" NAME="developer" SIZE="40"
VALUE="<?PHP
reset($developer);
while (list($key, $val) = each($developer)){
echo $developer[$key];
if (isset($developer[$key+1])) echo ", ";
}
?>"><BR><BR>
<B>Carregar menu a partir do banco de dados:</B><br>
Habilitar:
<INPUT TYPE="CHECKBOX" <?PHP if (intval($_menu_from_db)!=0) echo "CHECKED"; ?>
NAME="menu_from_db"><br><br>
<B>Nível de debug:</B><BR>
<INPUT TYPE="RADIO" <?PHP if ($_debug==0) echo "CHECKED"; ?>
NAME="debug" VALUE="0">0
<INPUT TYPE="RADIO" <?PHP if ($_debug==1) echo "CHECKED"; ?>
NAME="debug" VALUE="1">1
<INPUT TYPE="RADIO" <?PHP if ($_debug==2) echo "CHECKED"; ?>
NAME="debug" VALUE="2">2
<INPUT TYPE="RADIO" <?PHP if ($_debug==3) echo "CHECKED"; ?>
NAME="debug" VALUE="3">3 <BR><BR>
<?PHP
echo " \n";
if (strpos($_SESSION['grupos'], 'manuten')){
echo "<B>USUÁRIO LOGADO:</B><BR>\n";
echo " ";
if (isset($_SESSION['nome']))
dbcombo("usuarios", "login", "nome", $conn, "matricula", 100, $_SESSION['nome'], $submit, NULL, NULL, NULL);
else
dbcombo("usuarios", "login", "nome", $conn, "matricula", 100, "selecione o usuario", $submit, NULL, NULL, NULL);
echo "<BR>\n";
echo "<BR>\n";
}
if ($_debug){ // Aqui eh pra criar quando jah vem preenchido
echo "<BR><BR>\n<PRE>\n";
var_dump($_SESSION);
echo "</PRE><BR>\n";
}
echo $closeDIV;
echo "<BR>\n";
togglePoint("DEPENCENDIAS", "Dependências", 1, false, NULL);
foreach($deps as $dep){
$depp = $dep;
$dep = trim(str_replace("-", "_", $dep));
echo "<BR>\n";
echo " \n";
echo " <B>Caminho para o " . $dep . ":</B><BR>\n";
echo " \n";
echo " <INPUT TYPE=\"TEXT\" CLASS=\"TEXT\" NAME=\"path_to_" . $dep . "\" SIZE=\"40\"\n";
$variable = "path_to_" . $dep;
echo " VALUE=\"";
if (isset($$variable))
echo $$variable;
else
echo "/usr/bin/" . $depp;
echo "\"><BR>\n";
}
echo $closeDIV;
echo "<BR>\n";
togglePoint("banco", "Configurações de acesso ao banco de dados interno do sistema", 1, false, NULL);
?>
<B>Banco de dados utilizado:</B><BR>
<INPUT TYPE="TEXT" CLASS="TEXT" NAME="banco" SIZE="40"
VALUE="<?PHP echo $banco; ?>"><BR><BR>
<B>Banco de dados do cadastro de alunos:</B><BR>
<INPUT TYPE="TEXT" CLASS="TEXT" NAME="banco_cadastro" SIZE="40"
VALUE="<?PHP echo $banco_cadastro; ?>"><BR><BR>
<B>Usuário do banco:</B><BR>
<INPUT TYPE="TEXT" CLASS="TEXT" NAME="usuario_banco" SIZE="40"
VALUE="<?PHP echo $usuario_banco; ?>"><BR><BR>
<B>Senha do banco:</B><BR>
<INPUT TYPE="PASSWORD" CLASS="PASSWORD" NAME="senha_banco" SIZE="40"
VALUE="<?PHP echo $senha_banco; ?>"><BR><BR>
<?PHP
echo $closeDIV;
echo "<BR>\n";
togglePoint("deprecated", "Opções de retrocompatibilidade da fLameWork O.N.D.E.", 1, false, NULL);
?>
<B>URL do Sipesq:</B><BR>
<INPUT TYPE="TEXT" CLASS="TEXT" NAME="URL_sipesq" SIZE="40"
VALUE="<?PHP echo $URL_sipesq; ?>"><BR>
<BR>
<B>Uso de uma única fila para os projetos:</B><BR>
Habilitar: <INPUT TYPE="CHECKBOX" NAME="singleQueue"
VALUE="1" <?PHP if($_singleQueue) echo "CHECKED"; ?>><BR><BR>
<B>Executa validação de e-mail:</B><BR>
Habilitar: <INPUT TYPE="CHECKBOX" NAME="verificaEmail"
VALUE="1" <?PHP if($verificaEmail) echo "CHECKED"; ?>><BR><BR>
<B>Memory limit:</B><BR>
<INPUT TYPE="TEXT" CLASS="TEXT" NAME="mem_limit" SIZE="4"
VALUE="<?PHP echo $mem_limit; ?>"><BR>
<BR>
<B>Max execution time:</B><BR>
<INPUT TYPE="TEXT" CLASS="TEXT" NAME="max_execution_time" SIZE="3"
VALUE="<?PHP echo $max_execution_time; ?>"><BR>
<BR>
<?PHP echo $closeDIV; ?>
<BR>
<INPUT TYPE="SUBMIT" CLASS="SUBMIT" VALUE="Salvar...">
</FORM>
<BR><BR>
<?PHP
include "page_footer.inc";
?>