-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathindex.php
360 lines (260 loc) · 10.6 KB
/
index.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
<?php
########################################################################
#
# This file is part of VFront.
#
# VFront 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 2 of the License, or
# any later version.
#
# VFront 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 <http://www.gnu.org/licenses/>.
/**
* File di index di VFront.
* Questo file viene richiamato per fare il login e|o come Home per l'utente
* Il file di index mostra il login qualora non ci fosse una sessione valida.
*
* @package VFront
* @author Mario Marcello Verona <marcelloverona@gmail.com>
* @copyright 2007-2008 Mario Marcello Verona
* @version 0.96 $Id: index.php 1170 2017-05-12 18:06:01Z marciuz $
* @license http://www.gnu.org/licenses/gpl.html GNU Public License
* @todo Escape data in external auth
*/
require_once("./inc/conn.php");
require_once("./inc/layouts.php");
$INPUTS = "";
if (isset($_GET['login'])) {
$_dati = $vmreg->recursive_escape($_POST);
$LOGIN = new Auth($_dati['nick'], $_dati['passw']);
exit;
}
else if (isset($_GET['logout'])) {
$_SESSION = array();
header("Location: " . FRONT_DOCROOT . "/index.php");
exit;
}
else if (isset($_GET['nolog'])) {
$_SESSION = array();
$_SESSION['VF_VARS'] = var_frontend('session', 'session');
mostra_login();
exit;
}
else if (User_Session::is_logged()) {
mostra_loggato();
}
else {
mostra_login();
}
##########################################################################################################
/**
* Questa funzione genera la pagina di login nel caso il file index sia stato richiamato senza
* la presenza di una sessione valida.
* Pu� presentare il link per il recupero della password se l'opzione � stata definita tra le variabili
* di VFront e se l'autenticazione non avviene mediante strumenti esterni.
*
*/
function mostra_login() {
global $conf_auth;
// MODULO PRINCIPALE
$apertura = str_replace("<body>", "<body onload=\"document.getElementById('nick').focus();\">", openLayout1(_NOME_PROJ));
echo $apertura;
if (isset($_GET['nolog'])) {
echo "<div id=\"nologin\"><p>" . _('Error in username or password, please verify') . "</p></div>\n";
}
if (isset($_SESSION['VF_VARS']['recupero_password']) && $_SESSION['VF_VARS']['recupero_password'] == 1) {
if ($conf_auth['tipo_external_auth'] == null) {
$PASSW_RECOVER = "<p><a href=\"password_recover.php\">" . _('I\'ve forgotten my password') . "</a></p>";
} else if (isset($_SESSION['VF_VARS']['recupero_password_url']) && $_SESSION['VF_VARS']['recupero_password_url'] != '') {
$PASSW_RECOVER = "<p><a href=\"{$_SESSION['VF_VARS']['recupero_password_url']}\">" . _('I\'ve forgotten my password') . "</a></p>";
} else {
$PASSW_RECOVER = '';
}
} else {
$PASSW_RECOVER = '';
}
$access_label = ($conf_auth['tipo_external_auth'] == '' || ($conf_auth['campo_nick'] == $conf_auth['campo_mail'])) ? _('E-mail') : _('Username');
echo "
<div id=\"login\" align=\"center\">
<form method=\"post\" action=\"" . Common::phpself() . "?login\" >
<fieldset>
<legend>" . _('System access') . "</legend>
<p>
<label for=\"nick\">" . $access_label . "</label><br />
<input type=\"text\" name=\"nick\" size=\"30\" maxlength=\"200\" id=\"nick\" /><br />
</p>
<p>
<label for=\"passw\">" . _('Password') . "</label><br />
<input type=\"password\" name=\"passw\" size=\"30\" maxlength=\"100\" id=\"passw\" /><br />
</p>
<p><input type=\"submit\" name=\"accedi\" value=\" " . _('Access') . " \" id=\"accedi\" /></p>
$PASSW_RECOVER
</fieldset>
</form>
</div>
";
echo closeLayout1();
exit;
}
/**
* Funzione che genera il codice per produrre la home page.
* Qualora non ci fosse una sessione valida viene invece creata la pagina di login,
* mediante la funzione mostra_login()
* @see function mostra_login
*
*/
function mostra_loggato() {
global $vmreg, $db1;
proteggi(1);
$files = array("js/scriptaculous/lib/prototype.js",
"js/scriptaculous/src/scriptaculous.js",
"js/home.js");
echo openLayout1(_NOME_PROJ, $files);
echo "<h1 style=\"padding-left:4px;\">" . _('Main menu') . "</h1>\n";
if (User_Session::gid() == 0 && (isset($_SESSION['VF_VARS']['alert_login_default']) && $_SESSION['VF_VARS']['alert_login_default'] == 1)) {
echo "<div class=\"info\"><strong>" . _('Warning!') . "</strong><br />
" . _('You\'re attempting to login via the <strong>default group') . "</strong>.
" . _("If you login for the first time, this is correct; contact your system administrator to set the privileges correctly") . "</div>\n";
}
// TEst configurazione
if (User_Session::level() >= 2) {
// prendi il test
$testvfront = @join('', @file('./conf/.testvfront'));
if ($testvfront == '1' && $_SESSION['VF_VARS']['alert_config'] == 1) {
echo "<div class=\"alertbox\" id=\"alert_config\"><strong>" . _('Warning!') . "</strong><br />\n";
echo sprintf(_('There are some problems in configuring VFront which may affect the full functioning of the application. See %s'), '<a href="admin/vfront.info.php">' . _('diagnostic page') . '</a>');
echo " - \n";
echo "<span id=\"hide_alert_config\" class=\"fakelink\" onclick=\"$('alert_config').fade();\">" . _('Do not show this message again') . "</span> " .
"(" . sprintf(_('you can always restore from page %s'), "<a href=\"admin/variabili.php\">" . _('variables') . "</a>") . ")";
echo "</div>\n";
}
}
//
// RECUPERO LE TABELLE
$matrice_tab = RegTools::prendi_tabelle(User_Session::gid(), true, true, true);
// RECUPERO LE VISTE
$matrice_view = RegTools::prendi_viste(User_Session::gid(), true, true);
// RECUPERO LE STATISTICHE
if (Common::is_admin()) {
$sql_add_stat = '';
} else {
$sql_add_stat = " AND ( (auth_stat=1) ";
$sql_add_stat .= " OR (auth_stat=2 AND u.gid=" . User_Session::gid() . " )";
$sql_add_stat .= " OR (auth_stat=3 AND autore=" . User_Session::id() . " ))";
}
$sql_stat = "SELECT id_stat, nome_stat, desc_stat, u.gid
FROM {$db1['frontend']}{$db1['sep']}stat s
INNER JOIN {$db1['frontend']}{$db1['sep']}utente u ON s.autore=u.id_utente
WHERE published=1
$sql_add_stat
ORDER BY nome_stat
";
$q_stat = $vmreg->query($sql_stat);
$matrice_stat = $vmreg->fetch_assoc_all($q_stat);
$LI1 = "";
for ($i = 0; $i < count($matrice_tab); $i++) {
$comment1 = preg_replace("/;? ?InnoDB.*|/ui", "", $matrice_tab[$i]['commento']);
$tab_name = ($matrice_tab[$i]['table_alias'] == '') ? $matrice_tab[$i]['table_name'] : $matrice_tab[$i]['table_alias'];
$default_view_hash = (isset($matrice_tab[$i]['default_view']) && $matrice_tab[$i]['default_view'] == 'table') ? '#tab' : '';
$LI1 .= "
<li>
<a href=\"scheda.php?oid=" . $matrice_tab[$i]['id_table'] . $default_view_hash . "\">" . $tab_name . "</a>
<div class=\"desc-tab\">" . htmlentities(Common::vf_utf8_decode($comment1), ENT_QUOTES, FRONT_ENCODING) . "</div>
</li>\n";
}
$LI2 = "";
for ($i = 0; $i < count($matrice_view); $i++) {
$view_name = ($matrice_view[$i]['table_alias'] == '') ? $matrice_view[$i]['table_name'] : $matrice_view[$i]['table_alias'];
$LI2 .= "
<li>
<a href=\"scheda.php?oid=" . $matrice_view[$i]['id_table'] . "\">" . $view_name . "</a>
<div class=\"desc-tab\"> </div>
</li>\n";
}
$LI3 = "";
for ($i = 0; $i < count($matrice_stat); $i++) {
$LI3 .= "
<li>
<a href=\"stats/stat.personal.php?id_s=" . $matrice_stat[$i]['id_stat'] . "&ref=home\">" . $matrice_stat[$i]['nome_stat'] . "</a>
<div class=\"desc-tab\">" . $matrice_stat[$i]['desc_stat'] . "</div>
</li>\n";
}
######################################################################################################################
if ($LI1 == '') {
if (User_Session::level() == 3) {
$tabs = RegTools::prendi_tabelle();
if (count($tabs) == 0) {
$inizializza = " <a href=\"admin/menu_registri.php?initreg\">" . _("Initialize registry") . "</a>\n";
} else
$inizializza = '';
} else {
$inizializza = '';
}
$LI1 = "<li>" . _('At the moment there are no available tables') . $inizializza . "</li>";
}
$files_add_index = glob("{./usr/add_index.php,./usr/*/add_index.php}", GLOB_BRACE);
//if(file_exists("./usr/add_index.php")){
foreach ($files_add_index as $file_add) {
include($file_add);
if (function_exists('add_index_top')) {
echo add_index_top();
}
if (preg_match("|./usr/([\w]+)/.+|", $file_add, $dirusrname)) {
$fname = $dirusrname[1] . '__add_index_top';
if (function_exists($fname)) {
echo $fname();
}
}
}
echo "
<div id=\"box-tabelle\" class=\"box-home\">
<div class=\"box-home-txt\">
<h2>" . _('Available tables') . "</h2>
<ul class=\"lista-tabelle\">
$LI1
</ul>
</div>
</div>
";
if (count($matrice_view) > 0) {
echo "
<div id=\"box-viste\" class=\"box-home\">
<div class=\"box-home-txt\">
<h2>" . _('Data views') . "</h2>
<ul class=\"lista-tabelle\">
$LI2
</ul>
</div>
</div>
";
}
if (count($matrice_stat) > 0) {
echo "
<div id=\"box-stat-home\" class=\"box-home\" style=\"clear:both;\">
<div class=\"box-home-txt\">
<h2>" . _('Database statistics') . "</h2>
<ul class=\"lista-tabelle\">
$LI3
</ul>
</div>
</div>
";
}
echo "
<div id=\"box-info\" class=\"box-home\" style=\"clear:both;\">
<div class=\"box-home-txt\">
<h2>" . _('FAQs (Frequently Asked Questions) and answers') . "</h2>
<p><a href=\"helpdocs.php\">" . _('Useful documents') . "</a></p>
<p><a href=\"credits.php\">" . _('Credits') . "</a></p>
</div>
</div>
<p style=\"clear:both;\"> </p>
";
echo closeLayout1();
}