Translated using Weblate (Turkish)
[phpmyadmin.git] / index.php
blob3d236fd0252f83b24ce799adba970d1fb2002517
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Main loader script
6 * @package PhpMyAdmin
7 */
9 use PhpMyAdmin\Charsets;
10 use PhpMyAdmin\Core;
11 use PhpMyAdmin\LanguageManager;
12 use PhpMyAdmin\Message;
13 use PhpMyAdmin\RecentFavoriteTable;
14 use PhpMyAdmin\Response;
15 use PhpMyAdmin\Sanitize;
16 use PhpMyAdmin\ThemeManager;
17 use PhpMyAdmin\Url;
19 /**
20 * Gets some core libraries and displays a top message if required
22 require_once 'libraries/common.inc.php';
24 /**
25 * display Git revision if requested
27 require_once 'libraries/display_git_revision.lib.php';
29 /**
30 * pass variables to child pages
32 $drops = array(
33 'lang',
34 'server',
35 'collation_connection',
36 'db',
37 'table'
39 foreach ($drops as $each_drop) {
40 if (array_key_exists($each_drop, $_GET)) {
41 unset($_GET[$each_drop]);
44 unset($drops, $each_drop);
47 * Black list of all scripts to which front-end must submit data.
48 * Such scripts must not be loaded on home page.
51 $target_blacklist = array (
52 'import.php', 'export.php'
55 // If we have a valid target, let's load that script instead
56 if (! empty($_REQUEST['target'])
57 && is_string($_REQUEST['target'])
58 && ! preg_match('/^index/', $_REQUEST['target'])
59 && ! in_array($_REQUEST['target'], $target_blacklist)
60 && in_array($_REQUEST['target'], $goto_whitelist)
61 ) {
62 include $_REQUEST['target'];
63 exit;
66 if (isset($_REQUEST['ajax_request']) && ! empty($_REQUEST['access_time'])) {
67 exit;
70 // See FAQ 1.34
71 if (! empty($_REQUEST['db'])) {
72 $page = null;
73 if (! empty($_REQUEST['table'])) {
74 $page = PhpMyAdmin\Util::getScriptNameForOption(
75 $GLOBALS['cfg']['DefaultTabTable'], 'table'
77 } else {
78 $page = PhpMyAdmin\Util::getScriptNameForOption(
79 $GLOBALS['cfg']['DefaultTabDatabase'], 'database'
82 include $page;
83 exit;
86 $response = Response::getInstance();
87 /**
88 * Check if it is an ajax request to reload the recent tables list.
90 if ($response->isAjax() && ! empty($_REQUEST['recent_table'])) {
91 $response->addJSON(
92 'list',
93 RecentFavoriteTable::getInstance('recent')->getHtmlList()
95 exit;
98 if ($GLOBALS['PMA_Config']->isGitRevision()) {
99 if (isset($_REQUEST['git_revision']) && $response->isAjax()) {
100 PMA_printGitRevision();
101 exit;
103 echo '<div id="is_git_revision"></div>';
106 // Handles some variables that may have been sent by the calling script
107 $GLOBALS['db'] = '';
108 $GLOBALS['table'] = '';
109 $show_query = '1';
111 // Any message to display?
112 if (! empty($message)) {
113 echo PhpMyAdmin\Util::getMessage($message);
114 unset($message);
116 if (isset($_SESSION['partial_logout'])) {
117 Message::success(
118 __('You were logged out from one server, to logout completely from phpMyAdmin, you need to logout from all servers.')
119 )->display();
120 unset($_SESSION['partial_logout']);
123 $common_url_query = Url::getCommon();
124 $mysql_cur_user_and_host = '';
126 // when $server > 0, a server has been chosen so we can display
127 // all MySQL-related information
128 if ($server > 0) {
129 include 'libraries/server_common.inc.php';
131 // Use the verbose name of the server instead of the hostname
132 // if a value is set
133 $server_info = '';
134 if (! empty($cfg['Server']['verbose'])) {
135 $server_info .= htmlspecialchars($cfg['Server']['verbose']);
136 if ($GLOBALS['cfg']['ShowServerInfo']) {
137 $server_info .= ' (';
140 if ($GLOBALS['cfg']['ShowServerInfo'] || empty($cfg['Server']['verbose'])) {
141 $server_info .= $GLOBALS['dbi']->getHostInfo();
143 if (! empty($cfg['Server']['verbose']) && $GLOBALS['cfg']['ShowServerInfo']) {
144 $server_info .= ')';
146 $mysql_cur_user_and_host = $GLOBALS['dbi']->fetchValue('SELECT USER();');
148 // should we add the port info here?
149 $short_server_info = (!empty($GLOBALS['cfg']['Server']['verbose'])
150 ? $GLOBALS['cfg']['Server']['verbose']
151 : $GLOBALS['cfg']['Server']['host']);
154 echo '<div id="maincontainer">' , "\n";
155 // Anchor for favorite tables synchronization.
156 echo RecentFavoriteTable::getInstance('favorite')->getHtmlSyncFavoriteTables();
157 echo '<div id="main_pane_left">';
158 if ($server > 0 || count($cfg['Servers']) > 1
160 if ($cfg['DBG']['demo']) {
161 echo '<div class="group">';
162 echo '<h2>' , __('phpMyAdmin Demo Server') , '</h2>';
163 echo '<p style="margin: 0.5em 1em 0.5em 1em">';
164 printf(
166 'You are using the demo server. You can do anything here, but '
167 . 'please do not change root, debian-sys-maint and pma users. '
168 . 'More information is available at %s.'
170 '<a href="url.php?url=https://demo.phpmyadmin.net/" target="_blank" rel="noopener noreferrer">demo.phpmyadmin.net</a>'
172 echo '</p>';
173 echo '</div>';
175 echo '<div class="group">';
176 echo '<h2>' , __('General settings') , '</h2>';
177 echo '<ul>';
180 * Displays the MySQL servers choice form
182 if ($cfg['ServerDefault'] == 0
183 || (! $cfg['NavigationDisplayServers']
184 && (count($cfg['Servers']) > 1
185 || ($server == 0 && count($cfg['Servers']) == 1)))
187 echo '<li id="li_select_server" class="no_bullets" >';
188 include_once 'libraries/select_server.lib.php';
189 echo PhpMyAdmin\Util::getImage('s_host.png') , " "
190 , PMA_selectServer(true, true);
191 echo '</li>';
195 * Displays the mysql server related links
197 if ($server > 0) {
198 include_once 'libraries/check_user_privileges.lib.php';
200 // Logout for advanced authentication
201 if ($cfg['Server']['auth_type'] != 'config') {
202 if ($cfg['ShowChgPassword']) {
203 $conditional_class = 'ajax';
204 PMA_printListItem(
205 PhpMyAdmin\Util::getImage('s_passwd.png') . "&nbsp;" . __(
206 'Change password'
208 'li_change_password',
209 'user_password.php' . $common_url_query,
210 null,
211 null,
212 'change_password_anchor',
213 "no_bullets",
214 $conditional_class
217 } // end if
218 echo ' <li id="li_select_mysql_collation" class="no_bullets" >';
219 echo ' <form method="post" action="index.php">' , "\n"
220 . Url::getHiddenInputs(null, null, 4, 'collation_connection')
221 . ' <label for="select_collation_connection">' . "\n"
222 . ' ' . PhpMyAdmin\Util::getImage('s_asci.png')
223 . "&nbsp;" . __('Server connection collation') . "\n"
224 // put the doc link in the form so that it appears on the same line
225 . PhpMyAdmin\Util::showMySQLDocu('Charset-connection')
226 . ': ' . "\n"
227 . ' </label>' . "\n"
229 . Charsets::getCollationDropdownBox(
230 'collation_connection',
231 'select_collation_connection',
232 $collation_connection,
233 true,
234 true
236 . ' </form>' . "\n"
237 . ' </li>' . "\n";
238 } // end of if ($server > 0)
239 echo '</ul>';
240 echo '</div>';
243 echo '<div class="group">';
244 echo '<h2>' , __('Appearance settings') , '</h2>';
245 echo ' <ul>';
247 // Displays language selection combo
248 $language_manager = LanguageManager::getInstance();
249 if (empty($cfg['Lang']) && $language_manager->hasChoice()) {
250 echo '<li id="li_select_lang" class="no_bullets">';
252 echo PhpMyAdmin\Util::getImage('s_lang.png') , " "
253 , $language_manager->getSelectorDisplay();
254 echo '</li>';
257 // ThemeManager if available
259 if ($GLOBALS['cfg']['ThemeManager']) {
260 echo '<li id="li_select_theme" class="no_bullets">';
261 echo PhpMyAdmin\Util::getImage('s_theme.png') , " "
262 , ThemeManager::getInstance()->getHtmlSelectBox();
263 echo '</li>';
265 echo '<li id="li_select_fontsize">';
266 echo PhpMyAdmin\Config::getFontsizeForm();
267 echo '</li>';
269 echo '</ul>';
271 // User preferences
273 if ($server > 0) {
274 echo '<ul>';
275 PMA_printListItem(
276 PhpMyAdmin\Util::getImage('b_tblops.png') . "&nbsp;" . __(
277 'More settings'
279 'li_user_preferences',
280 'prefs_manage.php' . $common_url_query,
281 null,
282 null,
283 null,
284 "no_bullets"
286 echo '</ul>';
289 echo '</div>';
292 echo '</div>';
293 echo '<div id="main_pane_right">';
296 if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) {
298 echo '<div class="group">';
299 echo '<h2>' , __('Database server') , '</h2>';
300 echo '<ul>' , "\n";
301 PMA_printListItem(
302 __('Server:') . ' ' . $server_info,
303 'li_server_info'
305 PMA_printListItem(
306 __('Server type:') . ' ' . PhpMyAdmin\Util::getServerType(),
307 'li_server_type'
309 PMA_printListItem(
310 __('Server connection:') . ' ' . PhpMyAdmin\Util::getServerSSL(),
311 'li_server_type'
313 PMA_printListItem(
314 __('Server version:')
315 . ' '
316 . $GLOBALS['dbi']->getVersionString() . ' - ' . $GLOBALS['dbi']->getVersionComment(),
317 'li_server_version'
319 PMA_printListItem(
320 __('Protocol version:') . ' ' . $GLOBALS['dbi']->getProtoInfo(),
321 'li_mysql_proto'
323 PMA_printListItem(
324 __('User:') . ' ' . htmlspecialchars($mysql_cur_user_and_host),
325 'li_user_info'
328 echo ' <li id="li_select_mysql_charset">';
329 echo ' ' , __('Server charset:') , ' '
330 . ' <span lang="en" dir="ltr">';
331 $unicode = Charsets::$mysql_charset_map['utf-8'];
332 $charsets = Charsets::getMySQLCharsetsDescriptions();
333 echo ' ' , $charsets[$unicode], ' (' . $unicode, ')';
334 echo ' </span>'
335 . ' </li>'
336 . ' </ul>'
337 . ' </div>';
340 if ($GLOBALS['cfg']['ShowServerInfo'] || $GLOBALS['cfg']['ShowPhpInfo']) {
341 echo '<div class="group">';
342 echo '<h2>' , __('Web server') , '</h2>';
343 echo '<ul>';
344 if ($GLOBALS['cfg']['ShowServerInfo']) {
345 PMA_printListItem($_SERVER['SERVER_SOFTWARE'], 'li_web_server_software');
347 if ($server > 0) {
348 $client_version_str = $GLOBALS['dbi']->getClientInfo();
349 if (preg_match('#\d+\.\d+\.\d+#', $client_version_str)) {
350 $client_version_str = 'libmysql - ' . $client_version_str;
352 PMA_printListItem(
353 __('Database client version:') . ' ' . $client_version_str,
354 'li_mysql_client_version'
357 $php_ext_string = __('PHP extension:') . ' ';
359 $extensions = PhpMyAdmin\Util::listPHPExtensions();
361 foreach ($extensions as $extension) {
362 $php_ext_string .= ' ' . $extension
363 . PhpMyAdmin\Util::showPHPDocu('book.' . $extension . '.php');
366 PMA_printListItem(
367 $php_ext_string,
368 'li_used_php_extension'
371 $php_version_string = __('PHP version:') . ' ' . phpversion();
373 PMA_printListItem(
374 $php_version_string,
375 'li_used_php_version'
380 if ($cfg['ShowPhpInfo']) {
381 PMA_printListItem(
382 __('Show PHP information'),
383 'li_phpinfo',
384 'phpinfo.php' . $common_url_query,
385 null,
386 '_blank'
389 echo ' </ul>';
390 echo ' </div>';
393 echo '<div class="group pmagroup">';
394 echo '<h2>phpMyAdmin</h2>';
395 echo '<ul>';
396 $class = null;
397 if ($GLOBALS['cfg']['VersionCheck']) {
398 $class = 'jsversioncheck';
400 PMA_printListItem(
401 __('Version information:') . ' <span class="version">' . PMA_VERSION . '</span>',
402 'li_pma_version',
403 null,
404 null,
405 null,
406 null,
407 $class
409 PMA_printListItem(
410 __('Documentation'),
411 'li_pma_docs',
412 PhpMyAdmin\Util::getDocuLink('index'),
413 null,
414 '_blank'
417 // does not work if no target specified, don't know why
418 PMA_printListItem(
419 __('Official Homepage'),
420 'li_pma_homepage',
421 Core::linkURL('https://www.phpmyadmin.net/'),
422 null,
423 '_blank'
425 PMA_printListItem(
426 __('Contribute'),
427 'li_pma_contribute',
428 Core::linkURL('https://www.phpmyadmin.net/contribute/'),
429 null,
430 '_blank'
432 PMA_printListItem(
433 __('Get support'),
434 'li_pma_support',
435 Core::linkURL('https://www.phpmyadmin.net/support/'),
436 null,
437 '_blank'
439 PMA_printListItem(
440 __('List of changes'),
441 'li_pma_changes',
442 'changelog.php' . Url::getCommon(),
443 null,
444 '_blank'
446 PMA_printListItem(
447 __('License'),
448 'li_pma_license',
449 'license.php' . Url::getCommon(),
450 null,
451 '_blank'
453 echo ' </ul>';
454 echo ' </div>';
456 echo '</div>';
458 echo '</div>';
461 * mbstring is used for handling multibytes inside parser, so it is good
462 * to tell user something might be broken without it, see bug #1063149.
464 if (! @extension_loaded('mbstring')) {
465 trigger_error(
467 'The mbstring PHP extension was not found and you seem to be using'
468 . ' a multibyte charset. Without the mbstring extension phpMyAdmin'
469 . ' is unable to split strings correctly and it may result in'
470 . ' unexpected results.'
472 E_USER_WARNING
477 * Missing functionality
479 if (! extension_loaded('curl') && ! ini_get('allow_url_fopen')) {
480 trigger_error(
482 'The curl extension was not found and allow_url_fopen is '
483 . 'disabled. Due to this some features such as error reporting '
484 . 'or version check are disabled.'
489 if ($cfg['LoginCookieValidityDisableWarning'] == false) {
491 * Check whether session.gc_maxlifetime limits session validity.
493 $gc_time = (int)@ini_get('session.gc_maxlifetime');
494 if ($gc_time < $GLOBALS['cfg']['LoginCookieValidity'] ) {
495 trigger_error(
497 'Your PHP parameter [a@https://secure.php.net/manual/en/session.' .
498 'configuration.php#ini.session.gc-maxlifetime@_blank]session.' .
499 'gc_maxlifetime[/a] is lower than cookie validity configured ' .
500 'in phpMyAdmin, because of this, your login might expire sooner ' .
501 'than configured in phpMyAdmin.'
503 E_USER_WARNING
509 * Check whether LoginCookieValidity is limited by LoginCookieStore.
511 if ($GLOBALS['cfg']['LoginCookieStore'] != 0
512 && $GLOBALS['cfg']['LoginCookieStore'] < $GLOBALS['cfg']['LoginCookieValidity']
514 trigger_error(
516 'Login cookie store is lower than cookie validity configured in ' .
517 'phpMyAdmin, because of this, your login will expire sooner than ' .
518 'configured in phpMyAdmin.'
520 E_USER_WARNING
525 * Check if user does not have defined blowfish secret and it is being used.
527 if (! empty($_SESSION['encryption_key'])) {
528 if (empty($GLOBALS['cfg']['blowfish_secret'])) {
529 trigger_error(
531 'The configuration file now needs a secret passphrase (blowfish_secret).'
533 E_USER_WARNING
535 } elseif (strlen($GLOBALS['cfg']['blowfish_secret']) < 32) {
536 trigger_error(
538 'The secret passphrase in configuration (blowfish_secret) is too short.'
540 E_USER_WARNING
546 * Check for existence of config directory which should not exist in
547 * production environment.
549 if (@file_exists('config')) {
550 trigger_error(
552 'Directory [code]config[/code], which is used by the setup script, ' .
553 'still exists in your phpMyAdmin directory. It is strongly ' .
554 'recommended to remove it once phpMyAdmin has been configured. ' .
555 'Otherwise the security of your server may be compromised by ' .
556 'unauthorized people downloading your configuration.'
558 E_USER_WARNING
562 if ($server > 0) {
563 $cfgRelation = PMA_getRelationsParam();
564 if (! $cfgRelation['allworks']
565 && $cfg['PmaNoRelation_DisableWarning'] == false
567 $msg_text = __(
568 'The phpMyAdmin configuration storage is not completely '
569 . 'configured, some extended features have been deactivated. '
570 . '%sFind out why%s. '
572 if ($cfg['ZeroConf'] == true) {
573 $msg_text .= '<br>' .
575 'Or alternately go to \'Operations\' tab of any database '
576 . 'to set it up there.'
579 $msg = PhpMyAdmin\Message::notice($msg_text);
580 $msg->addParamHtml('<a href="./chk_rel.php' . $common_url_query . '">');
581 $msg->addParamHtml('</a>');
582 /* Show error if user has configured something, notice elsewhere */
583 if (!empty($cfg['Servers'][$server]['pmadb'])) {
584 $msg->isError(true);
586 $msg->display();
587 } // end if
591 * Warning about Suhosin only if its simulation mode is not enabled
593 if ($cfg['SuhosinDisableWarning'] == false
594 && @ini_get('suhosin.request.max_value_length')
595 && @ini_get('suhosin.simulation') == '0'
597 trigger_error(
598 sprintf(
600 'Server running with Suhosin. Please refer to %sdocumentation%s ' .
601 'for possible issues.'
603 '[doc@faq1-38]',
604 '[/doc]'
606 E_USER_WARNING
610 /* Missing template cache */
611 if (is_null($GLOBALS['PMA_Config']->getTempDir('twig'))) {
612 trigger_error(
613 sprintf(
614 __('The $cfg[\'TempDir\'] (%s) is not accessible. phpMyAdmin is not able to cache templates and will be slow because of this.'),
615 $GLOBALS['PMA_Config']->get('TempDir')
617 E_USER_WARNING
622 * Warning about incomplete translations.
624 * The data file is created while creating release by ./scripts/remove-incomplete-mo
626 if (@file_exists('libraries/language_stats.inc.php')) {
627 include 'libraries/language_stats.inc.php';
629 * This message is intentionally not translated, because we're
630 * handling incomplete translations here and focus on english
631 * speaking users.
633 if (isset($GLOBALS['language_stats'][$lang])
634 && $GLOBALS['language_stats'][$lang] < $cfg['TranslationWarningThreshold']
636 trigger_error(
637 'You are using an incomplete translation, please help to make it '
638 . 'better by [a@https://www.phpmyadmin.net/translate/'
639 . '@_blank]contributing[/a].',
640 E_USER_NOTICE
646 * prints list item for main page
648 * @param string $name displayed text
649 * @param string $listId id, used for css styles
650 * @param string $url make item as link with $url as target
651 * @param string $mysql_help_page display a link to MySQL's manual
652 * @param string $target special target for $url
653 * @param string $a_id id for the anchor,
654 * used for jQuery to hook in functions
655 * @param string $class class for the li element
656 * @param string $a_class class for the anchor element
658 * @return void
660 function PMA_printListItem($name, $listId = null, $url = null,
661 $mysql_help_page = null, $target = null, $a_id = null, $class = null,
662 $a_class = null
664 echo PhpMyAdmin\Template::get('list/item')
665 ->render(
666 array(
667 'content' => $name,
668 'id' => $listId,
669 'class' => $class,
670 'url' => array(
671 'href' => $url,
672 'target' => $target,
673 'id' => $a_id,
674 'class' => $a_class,
676 'mysql_help_page' => $mysql_help_page,