forked from phpmyadmin/phpmyadmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
644 lines (590 loc) · 19.2 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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Main loader script
*
* @package PhpMyAdmin
*/
/**
* Gets some core libraries and displays a top message if required
*/
require_once 'libraries/common.inc.php';
/**
* display Git revision if requested
*/
require_once 'libraries/display_git_revision.lib.php';
/**
* pass variables to child pages
*/
$drops = array(
'lang',
'server',
'collation_connection',
'db',
'table'
);
foreach ($drops as $each_drop) {
if (array_key_exists($each_drop, $_GET)) {
unset($_GET[$each_drop]);
}
}
unset($drops, $each_drop);
// If we have a valid target, let's load that script instead
if (! empty($_REQUEST['target'])
&& is_string($_REQUEST['target'])
&& ! preg_match('/^index/', $_REQUEST['target'])
&& in_array($_REQUEST['target'], $goto_whitelist)
) {
include $_REQUEST['target'];
exit;
}
/**
* Check if it is an ajax request to reload the recent tables list.
*/
require_once 'libraries/RecentTable.class.php';
if ($GLOBALS['is_ajax_request'] && ! empty($_REQUEST['recent_table'])) {
$response = PMA_Response::getInstance();
$response->addJSON(
'options',
PMA_RecentTable::getInstance()->getHtmlSelectOption()
);
exit;
}
if ($GLOBALS['PMA_Config']->isGitRevision()) {
if (isset($_REQUEST['git_revision']) && $GLOBALS['is_ajax_request'] == true) {
PMA_printGitRevision();
exit;
}
echo '<div id="is_git_revision"></div>';
}
// Handles some variables that may have been sent by the calling script
$GLOBALS['db'] = '';
$GLOBALS['table'] = '';
$show_query = '1';
// Any message to display?
if (! empty($message)) {
echo PMA_Util::getMessage($message);
unset($message);
}
$common_url_query = PMA_URL_getCommon('', '');
// when $server > 0, a server has been chosen so we can display
// all MySQL-related information
if ($server > 0) {
include 'libraries/server_common.inc.php';
include 'libraries/StorageEngine.class.php';
// Use the verbose name of the server instead of the hostname
// if a value is set
$server_info = '';
if (! empty($cfg['Server']['verbose'])) {
$server_info .= htmlspecialchars($cfg['Server']['verbose']);
if ($GLOBALS['cfg']['ShowServerInfo']) {
$server_info .= ' (';
}
}
if ($GLOBALS['cfg']['ShowServerInfo'] || empty($cfg['Server']['verbose'])) {
$server_info .= $GLOBALS['dbi']->getHostInfo();
}
if (! empty($cfg['Server']['verbose']) && $GLOBALS['cfg']['ShowServerInfo']) {
$server_info .= ')';
}
$mysql_cur_user_and_host = $GLOBALS['dbi']->fetchValue('SELECT USER();');
// should we add the port info here?
$short_server_info = (!empty($GLOBALS['cfg']['Server']['verbose'])
? $GLOBALS['cfg']['Server']['verbose']
: $GLOBALS['cfg']['Server']['host']);
}
echo '<div id="maincontainer">' . "\n";
echo '<div id="main_pane_left">';
if ($server > 0 || count($cfg['Servers']) > 1
) {
if ($cfg['DBG']['demo']) {
echo '<div class="group">';
echo '<h2>' . __('phpMyAdmin Demo Server') . '</h2>';
echo '<p style="margin: 0.5em 1em 0.5em 1em">';
printf(
__(
'You are using the demo server. You can do anything here, but '
. 'please do not change root, debian-sys-maint and pma users. '
. 'More information is available at %s.'
),
'<a href="http://demo.phpmyadmin.net/">demo.phpmyadmin.net</a>'
);
echo '</p>';
echo '</div>';
}
echo '<div class="group">';
echo '<h2>' . __('General Settings') . '</h2>';
echo '<ul>';
/**
* Displays the MySQL servers choice form
*/
if ($cfg['ServerDefault'] == 0
|| (! $cfg['NavigationDisplayServers']
&& (count($cfg['Servers']) > 1
|| ($server == 0 && count($cfg['Servers']) == 1)
)
)
) {
echo '<li id="li_select_server" class="no_bullets" >';
include_once 'libraries/select_server.lib.php';
echo PMA_Util::getImage('s_host.png') . " " . PMA_selectServer(true, true);
echo '</li>';
}
/**
* Displays the mysql server related links
*/
if ($server > 0 && ! PMA_DRIZZLE) {
include_once 'libraries/check_user_privileges.lib.php';
// Logout for advanced authentication
if ($cfg['Server']['auth_type'] != 'config') {
if ($cfg['ShowChgPassword']) {
$conditional_class = 'ajax';
PMA_printListItem(
PMA_Util::getImage('s_passwd.png') . " " . __('Change password'),
'li_change_password',
'user_password.php?' . $common_url_query,
null,
null,
'change_password_anchor',
"no_bullets",
$conditional_class
);
}
} // end if
echo ' <li id="li_select_mysql_collation" class="no_bullets" >';
echo ' <form method="post" action="index.php">' . "\n"
. PMA_URL_getHiddenInputs(null, null, 4, 'collation_connection')
. ' <label for="select_collation_connection">' . "\n"
. ' '. PMA_Util::getImage('s_asci.png') . " "
. __('Server connection collation') . "\n"
// put the doc link in the form so that it appears on the same line
. PMA_Util::showMySQLDocu('Charset-connection')
. ': ' . "\n"
. ' </label>' . "\n"
. PMA_generateCharsetDropdownBox(
PMA_CSDROPDOWN_COLLATION,
'collation_connection',
'select_collation_connection',
$collation_connection,
true,
4,
true
)
. ' </form>' . "\n"
. ' </li>' . "\n";
} // end of if ($server > 0 && !PMA_DRIZZLE)
echo '</ul>';
echo '</div>';
}
echo '<div class="group">';
echo '<h2>' . __('Appearance Settings') . '</h2>';
echo ' <ul>';
// Displays language selection combo
if (empty($cfg['Lang']) && count($GLOBALS['available_languages']) > 1) {
echo '<li id="li_select_lang" class="no_bullets">';
include_once 'libraries/display_select_lang.lib.php';
echo PMA_Util::getImage('s_lang.png') . " " . PMA_getLanguageSelectorHtml();
echo '</li>';
}
// ThemeManager if available
if ($GLOBALS['cfg']['ThemeManager']) {
echo '<li id="li_select_theme" class="no_bullets">';
echo PMA_Util::getImage('s_theme.png') . " "
. $_SESSION['PMA_Theme_Manager']->getHtmlSelectBox();
echo '</li>';
}
echo '<li id="li_select_fontsize">';
echo PMA_Config::getFontsizeForm();
echo '</li>';
echo '</ul>';
// User preferences
if ($server > 0) {
echo '<ul>';
PMA_printListItem(
PMA_Util::getImage('b_tblops.png')." " .__('More settings'),
'li_user_preferences',
'prefs_manage.php?' . $common_url_query,
null,
null,
null,
"no_bullets"
);
echo '</ul>';
}
echo '</div>';
echo '</div>';
echo '<div id="main_pane_right">';
if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) {
echo '<div class="group">';
echo '<h2>' . __('Database server') . '</h2>';
echo '<ul>' . "\n";
PMA_printListItem(
__('Server:') . ' ' . $server_info,
'li_server_info'
);
PMA_printListItem(
__('Server type:') . ' ' . PMA_Util::getServerType(),
'li_server_type'
);
PMA_printListItem(
__('Server version:') . ' ' . PMA_MYSQL_STR_VERSION . ' - ' . PMA_MYSQL_VERSION_COMMENT,
'li_server_version'
);
PMA_printListItem(
__('Protocol version:') . ' ' . $GLOBALS['dbi']->getProtoInfo(),
'li_mysql_proto'
);
PMA_printListItem(
__('User:') . ' ' . htmlspecialchars($mysql_cur_user_and_host),
'li_user_info'
);
echo ' <li id="li_select_mysql_charset">';
echo ' ' . __('Server charset:') . ' '
. ' <span lang="en" dir="ltr">'
. ' ' . $mysql_charsets_descriptions[$mysql_charset_map['utf-8']] . "\n"
. ' (' . $mysql_charset_map['utf-8'] . ')' . "\n"
. ' </span>' . "\n"
. ' </li>' . "\n";
echo ' </ul>';
echo ' </div>';
}
if ($GLOBALS['cfg']['ShowServerInfo'] || $GLOBALS['cfg']['ShowPhpInfo']) {
echo '<div class="group">';
echo '<h2>' . __('Web server') . '</h2>';
echo '<ul>';
if ($GLOBALS['cfg']['ShowServerInfo']) {
PMA_printListItem($_SERVER['SERVER_SOFTWARE'], 'li_web_server_software');
if ($server > 0) {
$client_version_str = $GLOBALS['dbi']->getClientInfo();
if (preg_match('#\d+\.\d+\.\d+#', $client_version_str)
&& in_array($GLOBALS['cfg']['Server']['extension'], array('mysql', 'mysqli'))
) {
$client_version_str = 'libmysql - ' . $client_version_str;
}
PMA_printListItem(
__('Database client version:') . ' ' . $client_version_str,
'li_mysql_client_version'
);
$php_ext_string = __('PHP extension:') . ' '
. $GLOBALS['cfg']['Server']['extension'] . ' '
. PMA_Util::showPHPDocu(
'book.' . $GLOBALS['cfg']['Server']['extension'] . '.php'
);
PMA_printListItem(
$php_ext_string,
'li_used_php_extension'
);
}
}
if ($cfg['ShowPhpInfo']) {
PMA_printListItem(
__('Show PHP information'),
'li_phpinfo',
'phpinfo.php?' . $common_url_query,
null,
'_blank'
);
}
echo ' </ul>';
echo ' </div>';
}
echo '<div class="group pmagroup">';
echo '<h2>phpMyAdmin</h2>';
echo '<ul>';
$class = null;
// We rely on CSP to allow access to http://www.phpmyadmin.net, but IE lacks
// support here and does not allow request to http once using https.
if ($GLOBALS['cfg']['VersionCheck']
&& (! $GLOBALS['PMA_Config']->get('is_https') || PMA_USR_BROWSER_AGENT != 'IE')
) {
$class = 'jsversioncheck';
}
PMA_printListItem(
__('Version information:') . ' ' . PMA_VERSION,
'li_pma_version',
null,
null,
null,
null,
$class
);
PMA_printListItem(
__('Documentation'),
'li_pma_docs',
PMA_Util::getDocuLink('index'),
null,
'_blank'
);
PMA_printListItem(
__('Wiki'),
'li_pma_wiki',
PMA_linkURL('http://wiki.phpmyadmin.net/'),
null,
'_blank'
);
// does not work if no target specified, don't know why
PMA_printListItem(
__('Official Homepage'),
'li_pma_homepage',
PMA_linkURL('http://www.phpMyAdmin.net/'),
null,
'_blank'
);
PMA_printListItem(
__('Contribute'),
'li_pma_contribute',
PMA_linkURL('http://www.phpmyadmin.net/home_page/improve.php'),
null,
'_blank'
);
PMA_printListItem(
__('Get support'),
'li_pma_support',
PMA_linkURL('http://www.phpmyadmin.net/home_page/support.php'),
null,
'_blank'
);
PMA_printListItem(
__('List of changes'),
'li_pma_changes',
PMA_linkURL('changelog.php'),
null,
'_blank'
);
?>
</ul>
</div>
</div>
</div>
<?php
/**
* Warning if using the default MySQL privileged account
*/
if ($server != 0
&& $cfg['Server']['user'] == 'root'
&& $cfg['Server']['password'] == ''
) {
trigger_error(
__(
'Your configuration file contains settings (root with no password)'
. ' that correspond to the default MySQL privileged account.'
. ' Your MySQL server is running with this default, is open to'
. ' intrusion, and you really should fix this security hole by'
. ' setting a password for user \'root\'.'
),
E_USER_WARNING
);
}
/**
* As we try to handle charsets by ourself, mbstring overloads just
* break it, see bug 1063821.
*/
if (@extension_loaded('mbstring') && @ini_get('mbstring.func_overload') > 1) {
trigger_error(
__(
'You have enabled mbstring.func_overload in your PHP '
. 'configuration. This option is incompatible with phpMyAdmin '
. 'and might cause some data to be corrupted!'
),
E_USER_WARNING
);
}
/**
* mbstring is used for handling multibyte inside parser, so it is good
* to tell user something might be broken without it, see bug #1063149.
*/
if (! @extension_loaded('mbstring')) {
trigger_error(
__(
'The mbstring PHP extension was not found and you seem to be using'
. ' a multibyte charset. Without the mbstring extension phpMyAdmin'
. ' is unable to split strings correctly and it may result in'
. ' unexpected results.'
),
E_USER_WARNING
);
}
/**
* Check whether session.gc_maxlifetime limits session validity.
*/
$gc_time = (int)@ini_get('session.gc_maxlifetime');
if ($gc_time < $GLOBALS['cfg']['LoginCookieValidity'] ) {
trigger_error(
__('Your PHP parameter [a@http://php.net/manual/en/session.configuration.php#ini.session.gc-maxlifetime@_blank]session.gc_maxlifetime[/a] is lower than cookie validity configured in phpMyAdmin, because of this, your login will expire sooner than configured in phpMyAdmin.'),
E_USER_WARNING
);
}
/**
* Check whether LoginCookieValidity is limited by LoginCookieStore.
*/
if ($GLOBALS['cfg']['LoginCookieStore'] != 0
&& $GLOBALS['cfg']['LoginCookieStore'] < $GLOBALS['cfg']['LoginCookieValidity']
) {
trigger_error(
__('Login cookie store is lower than cookie validity configured in phpMyAdmin, because of this, your login will expire sooner than configured in phpMyAdmin.'),
E_USER_WARNING
);
}
/**
* Check if user does not have defined blowfish secret and it is being used.
*/
if (! empty($_SESSION['auto_blowfish_secret'])
&& empty($GLOBALS['cfg']['blowfish_secret'])
) {
trigger_error(
__('The configuration file now needs a secret passphrase (blowfish_secret).'),
E_USER_WARNING
);
}
/**
* Check for existence of config directory which should not exist in
* production environment.
*/
if (file_exists('config')) {
trigger_error(
__('Directory [code]config[/code], which is used by the setup script, still exists in your phpMyAdmin directory. It is strongly recommended to remove it once phpMyAdmin has been configured. Otherwise the security of your server may be compromised by unauthorized people downloading your configuration.'),
E_USER_WARNING
);
}
if ($server > 0) {
$cfgRelation = PMA_getRelationsParam();
if (! $cfgRelation['allworks']
&& $cfg['PmaNoRelation_DisableWarning'] == false
) {
$msg = PMA_Message::notice(__('The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated. To find out why click %shere%s.'));
$msg->addParam(
'<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php?' . $common_url_query . '">',
false
);
$msg->addParam('</a>', false);
/* Show error if user has configured something, notice elsewhere */
if (!empty($cfg['Servers'][$server]['pmadb'])) {
$msg->isError(true);
}
$msg->display();
} // end if
}
/**
* Warning about different MySQL library and server version
* (a difference on the third digit does not count).
* If someday there is a constant that we can check about mysqlnd,
* we can use it instead of strpos().
* If no default server is set, $GLOBALS['dbi'] is not defined yet.
* Drizzle can speak MySQL protocol, so don't warn about version mismatch for
* Drizzle servers.
*/
if (isset($GLOBALS['dbi']) && !PMA_DRIZZLE) {
$_client_info = $GLOBALS['dbi']->getClientInfo();
if ($server > 0
&& strpos($_client_info, 'mysqlnd') === false
&& substr(PMA_MYSQL_CLIENT_API, 0, 3) != substr(PMA_MYSQL_INT_VERSION, 0, 3)
) {
trigger_error(
PMA_sanitize(
sprintf(
__('Your PHP MySQL library version %s differs from your MySQL server version %s. This may cause unpredictable behavior.'),
$_client_info,
substr(
PMA_MYSQL_STR_VERSION,
0,
strpos(PMA_MYSQL_STR_VERSION . '-', '-')
)
)
),
E_USER_NOTICE
);
}
unset($_client_info);
}
/**
* Warning about Suhosin only if its simulation mode is not enabled
*/
if ($cfg['SuhosinDisableWarning'] == false
&& @ini_get('suhosin.request.max_value_length')
&& @ini_get('suhosin.simulation') == '0'
) {
trigger_error(
sprintf(
__('Server running with Suhosin. Please refer to %sdocumentation%s for possible issues.'),
'[doc@faq1-38]',
'[/doc]'
),
E_USER_WARNING
);
}
/**
* Warning about mcrypt.
*/
if (! function_exists('mcrypt_encrypt')
&& ! $GLOBALS['cfg']['McryptDisableWarning']
) {
PMA_warnMissingExtension('mcrypt');
}
/**
* Warning about incomplete translations.
*
* The data file is created while creating release by ./scripts/remove-incomplete-mo
*/
if (file_exists('libraries/language_stats.inc.php')) {
include 'libraries/language_stats.inc.php';
/*
* This message is intentionally not translated, because we're
* handling incomplete translations here and focus on english
* speaking users.
*/
if (isset($GLOBALS['language_stats'][$lang])
&& $GLOBALS['language_stats'][$lang] < $cfg['TranslationWarningThreshold']
) {
trigger_error(
'You are using an incomplete translation, please help to make it better by [a@http://www.phpmyadmin.net/home_page/improve.php#translate@_blank]contributing[/a].',
E_USER_NOTICE
);
}
}
/**
* prints list item for main page
*
* @param string $name displayed text
* @param string $id id, used for css styles
* @param string $url make item as link with $url as target
* @param string $mysql_help_page display a link to MySQL's manual
* @param string $target special target for $url
* @param string $a_id id for the anchor,
* used for jQuery to hook in functions
* @param string $class class for the li element
* @param string $a_class class for the anchor element
*
* @return void
*/
function PMA_printListItem($name, $id = null, $url = null,
$mysql_help_page = null, $target = null, $a_id = null, $class = null,
$a_class = null
) {
echo '<li id="' . $id . '"';
if (null !== $class) {
echo ' class="' . $class . '"';
}
echo '>';
if (null !== $url) {
echo '<a href="' . $url . '"';
if (null !== $target) {
echo ' target="' . $target . '"';
}
if (null != $a_id) {
echo ' id="' . $a_id .'"';
}
if (null != $a_class) {
echo ' class="' . $a_class .'"';
}
echo '>';
}
echo $name;
if (null !== $url) {
echo '</a>' . "\n";
}
if (null !== $mysql_help_page) {
echo PMA_Util::showMySQLDocu($mysql_help_page);
}
echo '</li>';
}
?>