Passed
Branch development (e0e718)
by Nils
04:45
created

admin.php (2 issues)

1
<?php
2
/**
3
 * @file          admin.php
4
 * @author        Nils Laumaillé
5
 * @version       2.1.27
6
 * @copyright     (c) 2009-2017 Nils Laumaillé
7
 * @licensing     GNU GPL-3.0
8
 * @link          http://www.teampass.net
9
 *
10
 * This library is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 */
14
15
if (!isset($_SESSION['CPM']) || $_SESSION['CPM'] != 1 ||
16
    !isset($_SESSION['user_id']) || empty($_SESSION['user_id']) ||
17
    !isset($_SESSION['key']) || empty($_SESSION['key'])
18
) {
19
    die('Hacking attempt...');
20
}
21
22
// Load config
23
if (file_exists('../includes/config/tp.config.php')) {
24
    require_once '../includes/config/tp.config.php';
25
} elseif (file_exists('./includes/config/tp.config.php')) {
26
    require_once './includes/config/tp.config.php';
27
} else {
28
    throw new Exception("Error file '/includes/config/tp.config.php' not exists", 1);
29
}
30
31
/* do checks */
32
require_once $SETTINGS['cpassman_dir'].'/sources/checks.php';
33
if (!checkUser($_SESSION['user_id'], $_SESSION['key'], "manage_main")) {
34
    $_SESSION['error']['code'] = ERR_NOT_ALLOWED; //not allowed page
35
    include $SETTINGS['cpassman_dir'].'/error.php';
36
    exit();
37
}
38
39
// get current statistics items
40
$statistics_items = array();
41
if (isset($SETTINGS['send_statistics_items'])) {
42
    $statistics_items = array_filter(explode(";", $SETTINGS['send_statistics_items']));
43
}
44
45
echo '
46
<input type="hidden" id="setting_send_stats" value="', isset($SETTINGS['send_stats']) ? $SETTINGS['send_stats'] : '0', '" />
47
<div class="title ui-widget-content ui-corner-all">'.$LANG['thku'].' <span style="float:right;">', isset($SETTINGS_EXT['version_full']) ? '<span class="fa fa-plug"></span>&nbsp;'.$SETTINGS_EXT['version_full'] : '', '</span></div>
48
49
<div style="margin:auto; line-height:20px; padding:10px;" id="tabs">
50
    <ul>
51
        <li><a href="#tabs-2">'.$LANG['communication_means'].'</a></li>
52
        <li><a href="#tabs-1">'.$LANG['sending_anonymous_statistics'].'</a></li>
53
        <li><a href="#tabs-3">'.$LANG['changelog'].'</a></li>
54
        <li><a href="#tabs-4">'.$LANG['admin_info'].'</a></li>
55
    </ul>
56
57
58
    <div id="tabs-1">
59
        <div>
60
            <span class="fa fa-area-chart fa-2x"></span>&nbsp;<label style="font-size:16px;">'.$LANG['considering_sending_anonymous_statistics'].'</label>
61
        </div>
62
        <div class="ui-state-default ui-corner-all" style="padding:5px; margin:15px 0 10px 0;"><span class="fa fa-info-circle fa-lg"></span>&nbsp;'.$LANG['sending_anonymous_statistics_details'].'</div>
63
        <div style="margin:5px 0 5px 0;">'.$LANG['anonymous_statistics_definition'].':</div>
64
        <div style="margin-left:10px; width:100%;">
65
            <table border="0" style="width:100%;">
66
                <thead>
67
                    <tr>
68
                    <th style="width:25%;" colspan="2">'.$LANG['characteristic'].'</th>
69
                    <th style="width:20%;">'.$LANG['usage_example'].'</th>
70
                    <th style="width:55%;">'.$LANG['current_value'].'</th>
71
                    </tr>
72
                </thead>
73
                <tbody>
74
                <tr style="border-bottom:1px;">
75
                    <td>
76
                    <input type="checkbox" id="stat_country" style="margin-right:15px;" ',in_array("stat_country", $statistics_items) || count($statistics_items) === 0 ? "checked" : "", ' class="stat_option"></td><td><label for="stat_country"><b>'.$LANG['country'].'</b></label>
77
                    </td>
78
                    <td>
79
                    <i>'.$LANG['country_statistics'].'</i>
80
                    </td>
81
                    <td>
82
                        <div class="spin_wait" id="value_country" style="text-align:center;"><span class="fa fa-cog fa-spin "></span></div>
83
                    </td>
84
                </tr>
85
                <tr>
86
                    <td>
87
                    <input type="checkbox" id="stat_users" style="margin-right:15px;" ',in_array("stat_users", $statistics_items) || count($statistics_items) === 0 ? "checked" : "", '  class="stat_option" class="stat_option"></td><td><label for="stat_users"><b>'.$LANG['users'].'</b></label>
88
                    </td>
89
                    <td>
90
                    <i>'.$LANG['users_statistics'].'</i>
91
                    </td>
92
                    <td>
93
                        <div class="spin_wait" id="value_users" style="text-align:center;"><span class="fa fa-cog fa-spin "></span></div>
94
                    </td>
95
                </tr>
96
                <tr>
97
                    <td>
98
                    <input type="checkbox" id="stat_items" style="margin-right:15px;" ',in_array("stat_items", $statistics_items) || count($statistics_items) === 0 ? "checked" : "", '  class="stat_option"></td><td><label for="stat_items"><b>'.$LANG['items_all'].'</b></label>
99
                    </td>
100
                    <td>
101
                    <i>'.$LANG['items_statistics'].'</i>
102
                    </td>
103
                    <td>
104
                        <div class="spin_wait" id="value_items" style="text-align:center;"><span class="fa fa-cog fa-spin "></span></div>
105
                    </td>
106
                </tr>
107
                <tr>
108
                    <td>
109
                    <input type="checkbox" id="stat_items_shared" style="margin-right:15px;" ',in_array("stat_items_shared", $statistics_items) || count($statistics_items) === 0 ? "checked" : "", '  class="stat_option"></td><td><label for="stat_items_shared"><b>'.$LANG['items_shared'].'</b></label>
110
                    </td>
111
                    <td>
112
                    </td>
113
                    <td>
114
                        <div class="spin_wait" id="value_items_shared" style="text-align:center;"><span class="fa fa-cog fa-spin "></span></div>
115
                    </td>
116
                </tr>
117
                <tr>
118
                    <td>
119
                    <input type="checkbox" id="stat_folders" style="margin-right:15px;" ',in_array("stat_folders", $statistics_items) || count($statistics_items) === 0 ? "checked" : "", '  class="stat_option"></td><td><label for="stat_folders"><b>'.$LANG['folders_all'].'</b></label>
120
                    </td>
121
                    <td>
122
                    <i>'.$LANG['folders_statistics'].'</i>
123
                    </td>
124
                    <td>
125
                        <div class="spin_wait" id="value_folders" style="text-align:center;"><span class="fa fa-cog fa-spin "></span></div>
126
                    </td>
127
                </tr>
128
                <tr>
129
                    <td>
130
                    <input type="checkbox" id="stat_folders_shared" style="margin-right:15px;" ',in_array("stat_folders_shared", $statistics_items) || count($statistics_items) === 0 ? "checked" : "", '  class="stat_option"></td><td><label for="stat_folders_shared"><b>'.$LANG['folders_shared'].'</b></label>
131
                    </td>
132
                    <td>
133
                    </td>
134
                    <td>
135
                        <div class="spin_wait" id="value_folders_shared" style="text-align:center;"><span class="fa fa-cog fa-spin "></span></div>
136
                    </td>
137
                </tr>
138
                <tr>
139
                    <td>
140
                    <input type="checkbox" id="stat_admins" style="margin-right:15px;" ',in_array("stat_admins", $statistics_items) || count($statistics_items) === 0 ? "checked" : "", '  class="stat_option"></td><td><label for="stat_admins"><b>'.$LANG['administrators_number'].'</b></label>
141
                    </td>
142
                    <td>
143
                    <i>'.$LANG['administrators_number_statistics'].'</i>
144
                    </td>
145
                    <td>
146
                        <div class="spin_wait" id="value_admin" style="text-align:center;"><span class="fa fa-cog fa-spin "></span></div>
147
                    </td>
148
                </tr>
149
                <tr>
150
                    <td>
151
                    <input type="checkbox" id="stat_managers" style="margin-right:15px;" ',in_array("stat_managers", $statistics_items) || count($statistics_items) === 0 ? "checked" : "", '  class="stat_option"></td><td><label for="stat_managers"><b>'.$LANG['managers_number'].'</b></label>
152
                    </td>
153
                    <td>
154
                    <i>'.$LANG['managers_number_statistics'].'</i>
155
                    </td>
156
                    <td>
157
                        <div class="spin_wait" id="value_manager" style="text-align:center;"><span class="fa fa-cog fa-spin "></span></div>
158
                    </td>
159
                </tr>
160
                <tr>
161
                    <td>
162
                    <input type="checkbox" id="stat_ro" style="margin-right:15px;" ',in_array("stat_ro", $statistics_items) || count($statistics_items) === 0 ? "checked" : "", '  class="stat_option"></td><td><label for="stat_ro"><b>'.$LANG['readonly_number'].'</b></label>
163
                    </td>
164
                    <td>
165
                    <i>'.$LANG['readonly_number_statistics'].'</i>
166
                    </td>
167
                    <td>
168
                        <div class="spin_wait" id="value_ro" style="text-align:center;"><span class="fa fa-cog fa-spin "></span></div>
169
                    </td>
170
                </tr>
171
                <tr>
172
                    <td>
173
                    <input type="checkbox" id="stat_mysqlversion" style="margin-right:15px;" ',in_array("stat_mysqlversion", $statistics_items) || count($statistics_items) === 0 ? "checked" : "", '  class="stat_option"></td><td><label for="stat_mysqlversion"><b>'.$LANG['mysql_version'].'</b></label>
174
                    </td>
175
                    <td>
176
                    </td>
177
                    <td>
178
                        <div class="spin_wait" id="value_mysql" style="text-align:center;"><span class="fa fa-cog fa-spin "></span></div>
179
                    </td>
180
                </tr>
181
                <tr>
182
                    <td>
183
                    <input type="checkbox" id="stat_phpversion" style="margin-right:15px;" ',in_array("stat_phpversion", $statistics_items) || count($statistics_items) === 0 ? "checked" : "", '  class="stat_option"></td><td><label for="stat_phpversion"><b>'.$LANG['php_version'].'</b></label>
184
                    </td>
185
                    <td>
186
                    </td>
187
                    <td>
188
                        <div class="spin_wait" id="value_php" style="text-align:center;"><span class="fa fa-cog fa-spin "></span></div>
189
                    </td>
190
                </tr>
191
                <tr>
192
                    <td>
193
                    <input type="checkbox" id="stat_teampassversion" style="margin-right:15px;" ',in_array("stat_teampassversion", $statistics_items) || count($statistics_items) === 0 ? "checked" : "", '  class="stat_option"></td><td><label for="stat_teampassversion"><b>'.$LANG['teampass_version'].'</b></label>
194
                    </td>
195
                    <td>
196
                    </td>
197
                    <td>
198
                        <div class="spin_wait" id="value_teampassv" style="text-align:center;"><span class="fa fa-cog fa-spin "></span></div>
199
                    </td>
200
                </tr>
201
                <tr>
202
                    <td>
203
                    <input type="checkbox" id="stat_languages" style="margin-right:15px;" ',in_array("stat_languages", $statistics_items) || count($statistics_items) === 0 ? "checked" : "", '  class="stat_option"></td><td><label for="stat_languages"><b>'.$LANG['languages_used'].'</b></label>
204
                    </td>
205
                    <td>
206
                    <i>'.$LANG['languages_statistics'].'</i>
207
                    </td>
208
                    <td>
209
                        <div class="spin_wait" id="value_languages" style="text-align:center;"><span class="fa fa-cog fa-spin "></span></div>
210
                    </td>
211
                </tr>
212
                <tr>
213
                    <td>
214
                    <input type="checkbox" id="stat_kb" style="margin-right:15px;" ',in_array("stat_kb", $statistics_items) || count($statistics_items) === 0 ? "checked" : "", '  class="stat_option"></td><td><label for="stat_kb"><b>'.$LANG['kb_option_enabled'].'</b></label>
215
                    </td>
216
                    <td>
217
                    </td>
218
                    <td>
219
                        <div class="spin_wait" id="value_kb" style="text-align:center;"><span class="fa fa-cog fa-spin "></span></div>
220
                    </td>
221
                </tr>
222
                <tr>
223
                    <td>
224
                    <input type="checkbox" id="stat_suggestion" style="margin-right:15px;" ',in_array("stat_suggestion", $statistics_items) || count($statistics_items) === 0 ? "checked" : "", '  class="stat_option"></td><td><label for="stat_suggestion"><b>'.$LANG['suggestion_option_enabled'].'</b></label>
225
                    </td>
226
                    <td>
227
                    </td>
228
                    <td>
229
                        <div class="spin_wait" id="value_suggestion" style="text-align:center;"><span class="fa fa-cog fa-spin "></span></div>
230
                    </td>
231
                </tr>
232
                <tr>
233
                    <td>
234
                    <input type="checkbox" id="stat_customfields" style="margin-right:15px;" ',in_array("stat_customfields", $statistics_items) || count($statistics_items) === 0 ? "checked" : "", '  class="stat_option"></td><td><label for="stat_customfields"><b>'.$LANG['customfields_option_enabled'].'</b></label>
235
                    </td>
236
                    <td>
237
                    </td>
238
                    <td>
239
                        <div class="spin_wait" id="value_customfields" style="text-align:center;"><span class="fa fa-cog fa-spin "></span></div>
240
                    </td>
241
                </tr>
242
                <tr>
243
                    <td>
244
                    <input type="checkbox" id="stat_api" style="margin-right:15px;" ',in_array("stat_api", $statistics_items) || count($statistics_items) === 0 ? "checked" : "", '  class="stat_option"></td><td><label for="stat_api"><b>'.$LANG['api_option_enabled'].'</b></label>
245
                    </td>
246
                    <td>
247
                    </td>
248
                    <td>
249
                        <div class="spin_wait" id="value_api" style="text-align:center;"><span class="fa fa-cog fa-spin "></span></div>
250
                    </td>
251
                </tr>
252
                <tr>
253
                    <td>
254
                    <input type="checkbox" id="stat_2fa" style="margin-right:15px;" ',in_array("stat_2fa", $statistics_items) || count($statistics_items) === 0 ? "checked" : "", '  class="stat_option"></td><td><label for="stat_2fa"><b>'.$LANG['2fa_option_enabled'].'</b></label>
255
                    </td>
256
                    <td>
257
                    </td>
258
                    <td>
259
                        <div class="spin_wait" id="value_2fa" style="text-align:center;"><span class="fa fa-cog fa-spin "></span></div>
260
                    </td>
261
                </tr>
262
                <tr>
263
                    <td>
264
                    <input type="checkbox" id="stat_agses" style="margin-right:15px;" ',in_array("stat_agses", $statistics_items) || count($statistics_items) === 0 ? "checked" : "", '  class="stat_option"></td><td><label for="stat_agses"><b>'.$LANG['agses_option_enabled'].'</b></label>
265
                    </td>
266
                    <td>
267
                    </td>
268
                    <td>
269
                        <div class="spin_wait" id="value_agses" style="text-align:center;"><span class="fa fa-cog fa-spin "></span></div>
270
                    </td>
271
                </tr>
272
                <tr>
273
                    <td>
274
                    <input type="checkbox" id="stat_duo" style="margin-right:15px;" ',in_array("stat_duo", $statistics_items) || count($statistics_items) === 0 ? "checked" : "", '  class="stat_option"></td><td><label for="stat_duo"><b>'.$LANG['duo_option_enabled'].'</b></label>
275
                    </td>
276
                    <td>
277
                    </td>
278
                    <td>
279
                        <div class="spin_wait" id="value_duo" style="text-align:center;"><span class="fa fa-cog fa-spin "></span></div>
280
                    </td>
281
                </tr>
282
                <tr>
283
                    <td>
284
                    <input type="checkbox" id="stat_ldap" style="margin-right:15px;" ',in_array("stat_ldap", $statistics_items) || count($statistics_items) === 0 ? "checked" : "", '  class="stat_option"></td><td><label for="stat_ldap"><b>'.$LANG['ldap_option_enabled'].'</b></label>
285
                    </td>
286
                    <td>
287
                    </td>
288
                    <td>
289
                        <div class="spin_wait" id="value_ldap" style="text-align:center;"><span class="fa fa-cog fa-spin "></span></div>
290
                    </td>
291
                </tr>
292
                <tr>
293
                    <td>
294
                    <input type="checkbox" id="stat_syslog" style="margin-right:15px;" ',in_array("stat_syslog", $statistics_items) || count($statistics_items) === 0 ? "checked" : "", '  class="stat_option"></td><td><label for="stat_syslog"><b>'.$LANG['syslog_option_enabled'].'</b></label>
295
                    </td>
296
                    <td>
297
                    </td>
298
                    <td>
299
                        <div class="spin_wait" id="value_syslog" style="text-align:center;"><span class="fa fa-cog fa-spin "></span></div>
300
                    </td>
301
                </tr>
302
                <tr>
303
                    <td>
304
                    <input type="checkbox" id="stat_stricthttps" style="margin-right:15px;" ',in_array("stat_stricthttps", $statistics_items) || count($statistics_items) === 0 ? "checked" : "", '  class="stat_option"></td><td><label for="stat_stricthttps"><b>'.$LANG['stricthttps_option_enabled'].'</b></label>
305
                    </td>
306
                    <td>
307
                    </td>
308
                    <td>
309
                        <div class="spin_wait" id="value_https" style="text-align:center;"><span class="fa fa-cog fa-spin "></span></div>
310
                    </td>
311
                </tr>
312
                <tr>
313
                    <td>
314
                    <input type="checkbox" id="stat_fav" style="margin-right:15px;" ',in_array("stat_fav", $statistics_items) || count($statistics_items) === 0 ? "checked" : "", '  class="stat_option"></td><td><label for="stat_fav"><b>'.$LANG['favourites_option_enabled'].'</b></label>
315
                    </td>
316
                    <td>
317
                    </td>
318
                    <td>
319
                        <div class="spin_wait" id="value_fav" style="text-align:center;"><span class="fa fa-cog fa-spin "></span></div>
320
                    </td>
321
                </tr>
322
                <tr>
323
                    <td>
324
                    <input type="checkbox" id="stat_pf" style="margin-right:15px;" ',in_array("stat_pf", $statistics_items) || count($statistics_items) === 0 ? "checked" : "", '  class="stat_option"></td><td><label for="stat_pf"><b>'.$LANG['personalfolders_option_enabled'].'</b></label>
325
                    </td>
326
                    <td>
327
                    </td>
328
                    <td>
329
                        <div class="spin_wait" id="value_pf" style="text-align:center;"><span class="fa fa-cog fa-spin "></span></div>
330
                    </td>
331
                </tr>
332
                <tr>
333
                    <td colspan="3">
334
                    <input type="checkbox" id="cb_select_all" style="margin:10px 15px 0 4px;"><label for="cb_select_all"><b>'.$LANG['select_all'].'</b></label>
335
                    </td>
336
                </tr>
337
                </tbody>
338
            </table>
339
        </div>
340
341
        <div style="text-align:center; margin-top:20px;">
342
            <table border="0">
343
                <tr>
344
                <td>'.$LANG['settings_send_stats'].'&nbsp;</td>
345
                <td width="200px"><div class="toggle toggle-modern" id="send_stats" data-toggle-on="', isset($SETTINGS['send_stats']) && $SETTINGS['send_stats'] === "1" ? 'true' : 'false', '"></div><input type="hidden" id="send_stats_input" name="send_stats_input" value="', isset($SETTINGS['send_stats']) && $SETTINGS['send_stats'] === "1" ? '1' : '0', '" /></td>
346
                </tr>
347
            </table>
348
        </div>
349
350
        <div style="text-align:center; margin-top:20px; font-size:16px;">
351
        <input type="button" id="but_save_send_stat" style="width:300px;" value="'.addslashes($LANG['save_statistics_choice']).'" />
352
        </div>
353
    </div>
354
355
356
    <div id="tabs-2" style="font-size:15px;">
357
358
        <div>
359
            <span class="fa fa-globe fa-lg"></span>&nbsp;&nbsp;<a target="_blank" href="http://www.teampass.net">'.addslashes($LANG['website_canal']).'</a>
360
        </div>
361
        <div style="margin-top:30px;">
362
            <span class="fa fa-book fa-lg"></span>&nbsp;&nbsp;'.addslashes($LANG['documentation_canal']).'&nbsp;<a target="_blank" href="https://teampass.readthedocs.org" style="font-weight:bold;font-style:italic;">ReadTheDoc</a>
363
        </div>
364
        <div style="margin-top:13px;">
365
            <span class="fa fa-github fa-lg"></span>&nbsp;&nbsp;'.addslashes($LANG['bug_canal']).'&nbsp;<a target="_blank" href="https://github.com/nilsteampassnet/TeamPass/issues" style="font-weight:bold;font-style:italic;">Github</a>
366
        </div>
367
        <div style="margin-top:13px;">
368
        <span class="fa fa-lightbulb-o fa-lg"></span>&nbsp;&nbsp;'.addslashes($LANG['feature_request_canal']).'&nbsp;<a target="_blank" href="https://teampass.userecho.com/" style="font-weight:bold;font-style:italic;">UserEcho</a>
369
        </div>
370
        <div style="margin-top:13px;">
371
        <span class="fa fa-reddit-alien fa-lg"></span>&nbsp;&nbsp;'.addslashes($LANG['feature_support_canal']).'&nbsp;<a target="_blank" href="https://www.reddit.com/r/TeamPass/" style="font-weight:bold;font-style:italic;">Reddit</a>
372
        </div>
373
374
375
        <div style="margin-top:30px;">
376
        <span class="fa fa-beer fa-lg"></span>&nbsp;&nbsp;'.addslashes($LANG['consider_a_donation']).'&nbsp;<span class="fa fa-smile-o"></span>&nbsp;<a target="_blank" href="https://teampass.net/donation" style="font-weight:bold;font-style:italic;">'.addslashes($LANG['more_information']).'</a>
377
        </div>
378
    </div>
379
    <div id="tabs-3">';
380
// Display the readme file
381
$Fnm = "changelog.md";
382
if (file_exists($Fnm)) {
383
    $tab = file($Fnm);
384
    echo '
385
        <h3>'.$LANG['changelog'].'</h3>';
386
    $show = false;
387
    $cnt = 0;
388
    while (list($cle, $val) = each($tab)) {
0 ignored issues
show
Deprecated Code introduced by
The function each() has been deprecated: 7.2 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

388
    while (list($cle, $val) = /** @scrutinizer ignore-deprecated */ each($tab)) {

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
It seems like $tab can also be of type false; however, parameter $array of each() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

388
    while (list($cle, $val) = each(/** @scrutinizer ignore-type */ $tab)) {
Loading history...
389
        if ($cnt < 30) {
390
            echo $val."<br />";
391
            $cnt++;
392
        } elseif ($cnt == 30) {
393
            echo '...<br /><br /><b><a href="changelog.md" target="_blank"><span class="fa fa-book"></span>&nbsp;'.$LANG['readme_open'].'</a></b>';
394
            break;
395
        }
396
    }
397
}
398
echo '
399
    </div>
400
    <div id="tabs-4">
401
    <div id="CPM_infos" style="">'.$LANG['admin_info_loading'].'&nbsp;<span class="fa fa-cog fa-spin"></span></div>
402
    </div>
403
</div>';
404
405
// javascript
406
echo '
407
<script type="text/javascript">
408
//<![CDATA[
409
$(function() {
410
    $("#tabs").tabs();
411
});
412
//]]>
413
</script>';
414