index.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. <?php
  2. ini_set("display_errors", "On");
  3. error_reporting(E_ALL | E_STRICT);
  4. set_time_limit(0);
  5. /* vim: set expandtab sw=4 ts=4 sts=4: */
  6. /**
  7. *
  8. * @package PhpMyAdmin
  9. */
  10. /**
  11. * Gets some core libraries and displays a top message if required
  12. */
  13. require_once 'libraries/common.inc.php';
  14. /**
  15. * display Git revision if requested
  16. */
  17. require_once 'libraries/display_git_revision.lib.php';
  18. /**
  19. * pass variables to child pages
  20. */
  21. $drops = array(
  22. 'lang',
  23. 'server',
  24. 'collation_connection',
  25. 'db',
  26. 'table'
  27. );
  28. foreach ($drops as $each_drop) {
  29. if (array_key_exists($each_drop, $_GET)) {
  30. unset($_GET[$each_drop]);
  31. }
  32. }
  33. unset($drops, $each_drop);
  34. // If we have a valid target, let's load that script instead
  35. if (! empty($_REQUEST['target'])
  36. && is_string($_REQUEST['target'])
  37. && ! preg_match('/^index/', $_REQUEST['target'])
  38. && in_array($_REQUEST['target'], $goto_whitelist)
  39. ) {
  40. include $_REQUEST['target'];
  41. exit;
  42. }
  43. /**
  44. * Check if it is an ajax request to reload the recent tables list.
  45. */
  46. require_once 'libraries/RecentTable.class.php';
  47. if ($GLOBALS['is_ajax_request'] && ! empty($_REQUEST['recent_table'])) {
  48. $response = PMA_Response::getInstance();
  49. $response->addJSON(
  50. 'options',
  51. PMA_RecentTable::getInstance()->getHtmlSelectOption()
  52. );
  53. exit;
  54. }
  55. if ($GLOBALS['PMA_Config']->isGitRevision()) {
  56. if (isset($_REQUEST['git_revision']) && $GLOBALS['is_ajax_request'] == true) {
  57. PMA_printGitRevision();
  58. exit;
  59. }
  60. echo '<div id="is_git_revision"></div>';
  61. }
  62. // Handles some variables that may have been sent by the calling script
  63. $GLOBALS['db'] = '';
  64. $GLOBALS['table'] = '';
  65. $show_query = '1';
  66. // Any message to display?
  67. if (! empty($message)) {
  68. echo PMA_Util::getMessage($message);
  69. unset($message);
  70. }
  71. $common_url_query = PMA_generate_common_url('', '');
  72. // when $server > 0, a server has been chosen so we can display
  73. // all MySQL-related information
  74. if ($server > 0) {
  75. include 'libraries/server_common.inc.php';
  76. include 'libraries/StorageEngine.class.php';
  77. // Use the verbose name of the server instead of the hostname
  78. // if a value is set
  79. $server_info = '';
  80. if (! empty($cfg['Server']['verbose'])) {
  81. $server_info .= htmlspecialchars($cfg['Server']['verbose']);
  82. if ($GLOBALS['cfg']['ShowServerInfo']) {
  83. $server_info .= ' (';
  84. }
  85. }
  86. if ($GLOBALS['cfg']['ShowServerInfo'] || empty($cfg['Server']['verbose'])) {
  87. $server_info .= PMA_DBI_get_host_info();
  88. }
  89. if (! empty($cfg['Server']['verbose']) && $GLOBALS['cfg']['ShowServerInfo']) {
  90. $server_info .= ')';
  91. }
  92. $mysql_cur_user_and_host = PMA_DBI_fetch_value('SELECT USER();');
  93. // should we add the port info here?
  94. $short_server_info = (!empty($GLOBALS['cfg']['Server']['verbose'])
  95. ? $GLOBALS['cfg']['Server']['verbose']
  96. : $GLOBALS['cfg']['Server']['host']);
  97. }
  98. echo '<div id="maincontainer">' . "\n";
  99. echo '<div id="main_pane_left">';
  100. if ($server > 0 || count($cfg['Servers']) > 1
  101. ) {
  102. echo '<div class="group">';
  103. echo '<h2>' . __('General Settings') . '</h2>';
  104. echo '<ul>';
  105. /**
  106. * Displays the MySQL servers choice form
  107. */
  108. if ($cfg['ServerDefault'] == 0
  109. || (! $cfg['NavigationDisplayServers']
  110. && (count($cfg['Servers']) > 1
  111. || ($server == 0 && count($cfg['Servers']) == 1)
  112. )
  113. )
  114. ) {
  115. echo '<li id="li_select_server" class="no_bullets" >';
  116. include_once 'libraries/select_server.lib.php';
  117. echo PMA_Util::getImage('s_host.png') . " " . PMA_selectServer(true, true);
  118. echo '</li>';
  119. }
  120. /**
  121. * Displays the mysql server related links
  122. */
  123. if ($server > 0 && ! PMA_DRIZZLE) {
  124. include_once 'libraries/check_user_privileges.lib.php';
  125. // Logout for advanced authentication
  126. if ($cfg['Server']['auth_type'] != 'config') {
  127. if ($cfg['ShowChgPassword']) {
  128. $conditional_class = 'ajax';
  129. PMA_printListItem(
  130. PMA_Util::getImage('s_passwd.png') . " " . __('Change password'),
  131. 'li_change_password',
  132. 'user_password.php?' . $common_url_query,
  133. null,
  134. null,
  135. 'change_password_anchor',
  136. "no_bullets",
  137. $conditional_class
  138. );
  139. }
  140. } // end if
  141. echo ' <li id="li_select_mysql_collation" class="no_bullets" >';
  142. echo ' <form method="post" action="index.php">' . "\n"
  143. . PMA_generate_common_hidden_inputs(null, null, 4, 'collation_connection')
  144. . ' <label for="select_collation_connection">' . "\n"
  145. . ' '. PMA_Util::getImage('s_asci.png') . " "
  146. . __('Server connection collation') . "\n"
  147. // put the doc link in the form so that it appears on the same line
  148. . PMA_Util::showMySQLDocu(
  149. 'MySQL_Database_Administration',
  150. 'Charset-connection'
  151. )
  152. . ': ' . "\n"
  153. . ' </label>' . "\n"
  154. . PMA_generateCharsetDropdownBox(
  155. PMA_CSDROPDOWN_COLLATION,
  156. 'collation_connection',
  157. 'select_collation_connection',
  158. $collation_connection,
  159. true,
  160. 4,
  161. true
  162. )
  163. . ' </form>' . "\n"
  164. . ' </li>' . "\n";
  165. } // end of if ($server > 0 && !PMA_DRIZZLE)
  166. echo '</ul>';
  167. echo '</div>';
  168. }
  169. echo '<div class="group">';
  170. echo '<h2>' . __('Appearance Settings') . '</h2>';
  171. echo ' <ul>';
  172. // Displays language selection combo
  173. if (empty($cfg['Lang']) && count($GLOBALS['available_languages']) > 1) {
  174. echo '<li id="li_select_lang" class="no_bullets">';
  175. include_once 'libraries/display_select_lang.lib.php';
  176. echo PMA_Util::getImage('s_lang.png') . " " . PMA_getLanguageSelectorHtml();
  177. echo '</li>';
  178. }
  179. // ThemeManager if available
  180. if ($GLOBALS['cfg']['ThemeManager']) {
  181. echo '<li id="li_select_theme" class="no_bullets">';
  182. echo PMA_Util::getImage('s_theme.png') . " "
  183. . $_SESSION['PMA_Theme_Manager']->getHtmlSelectBox();
  184. echo '</li>';
  185. }
  186. echo '<li id="li_select_fontsize">';
  187. echo PMA_Config::getFontsizeForm();
  188. echo '</li>';
  189. echo '</ul>';
  190. // User preferences
  191. if ($server > 0) {
  192. echo '<ul>';
  193. PMA_printListItem(
  194. PMA_Util::getImage('b_tblops.png')." " .__('More settings'),
  195. 'li_user_preferences',
  196. 'prefs_manage.php?' . $common_url_query,
  197. null,
  198. null,
  199. null,
  200. "no_bullets"
  201. );
  202. echo '</ul>';
  203. }
  204. echo '</div>';
  205. echo '</div>';
  206. echo '<div id="main_pane_right">';
  207. if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) {
  208. echo '<div class="group">';
  209. echo '<h2>' . __('Database server') . '</h2>';
  210. echo '<ul>' . "\n";
  211. PMA_printListItem(
  212. __('Server') . ': ' . $server_info,
  213. 'li_server_info'
  214. );
  215. PMA_printListItem(
  216. __('Server type') . ': ' . PMA_Util::getServerType(),
  217. 'li_server_type'
  218. );
  219. PMA_printListItem(
  220. __('Server version') . ': ' . PMA_MYSQL_STR_VERSION . ' - ' . PMA_MYSQL_VERSION_COMMENT,
  221. 'li_server_version'
  222. );
  223. PMA_printListItem(
  224. __('Protocol version') . ': ' . PMA_DBI_get_proto_info(),
  225. 'li_mysql_proto'
  226. );
  227. PMA_printListItem(
  228. __('User') . ': ' . htmlspecialchars($mysql_cur_user_and_host),
  229. 'li_user_info'
  230. );
  231. echo ' <li id="li_select_mysql_charset">';
  232. echo ' ' . __('Server charset') . ': '
  233. . ' <span lang="en" dir="ltr">';
  234. if (! PMA_DRIZZLE) {
  235. echo ' ' . $mysql_charsets_descriptions[$mysql_charset_map['utf-8']] . "\n";
  236. }
  237. echo ' (' . $mysql_charset_map['utf-8'] . ')' . "\n"
  238. . ' </span>' . "\n"
  239. . ' </li>' . "\n";
  240. echo ' </ul>';
  241. echo ' </div>';
  242. }
  243. if ($GLOBALS['cfg']['ShowServerInfo']) {
  244. echo '<div class="group">';
  245. echo '<h2>' . __('Web server') . '</h2>';
  246. echo '<ul>';
  247. if ($GLOBALS['cfg']['ShowServerInfo']) {
  248. PMA_printListItem($_SERVER['SERVER_SOFTWARE'], 'li_web_server_software');
  249. if ($server > 0) {
  250. $client_version_str = PMA_DBI_get_client_info();
  251. if (preg_match('#\d+\.\d+\.\d+#', $client_version_str)
  252. && in_array($GLOBALS['cfg']['Server']['extension'], array('mysql', 'mysqli'))
  253. ) {
  254. $client_version_str = 'libmysql - ' . $client_version_str;
  255. }
  256. PMA_printListItem(
  257. __('Database client version') . ': ' . $client_version_str,
  258. 'li_mysql_client_version'
  259. );
  260. $php_ext_string = __('PHP extension') . ': '
  261. . $GLOBALS['cfg']['Server']['extension'] . ' '
  262. . PMA_Util::showPHPDocu(
  263. 'book.' . $GLOBALS['cfg']['Server']['extension'] . '.php'
  264. );
  265. PMA_printListItem(
  266. $php_ext_string,
  267. 'li_used_php_extension'
  268. );
  269. }
  270. }
  271. echo ' </ul>';
  272. echo ' </div>';
  273. }
  274. echo '<div class="group pmagroup">';
  275. echo '<h2>phpMyAdmin</h2>';
  276. echo '<ul>';
  277. $class = null;
  278. // We rely on CSP to allow access to https://www.phpmyadmin.net, but IE lacks
  279. // support here and does not allow request to http once using https.
  280. if ($GLOBALS['cfg']['VersionCheck']
  281. && (! $GLOBALS['PMA_Config']->get('is_https') || PMA_USR_BROWSER_AGENT != 'IE')
  282. ) {
  283. $class = 'jsversioncheck';
  284. }
  285. PMA_printListItem(
  286. __('Version information') . ': ' . PMA_VERSION,
  287. 'li_pma_version',
  288. null,
  289. null,
  290. null,
  291. null,
  292. $class
  293. );
  294. PMA_printListItem(
  295. __('Documentation'),
  296. 'li_pma_docs',
  297. PMA_Util::getDocuLink('index'),
  298. null,
  299. '_blank'
  300. );
  301. PMA_printListItem(
  302. __('Wiki'),
  303. 'li_pma_wiki',
  304. PMA_linkURL('https://wiki.phpmyadmin.net/'),
  305. null,
  306. '_blank'
  307. );
  308. // does not work if no target specified, don't know why
  309. PMA_printListItem(
  310. __('Official Homepage'),
  311. 'li_pma_homepage',
  312. PMA_linkURL('http://www.phpmyadmin.net/'),
  313. null,
  314. '_blank'
  315. );
  316. PMA_printListItem(
  317. __('Contribute'),
  318. 'li_pma_contribute',
  319. PMA_linkURL('https://www.phpmyadmin.net/home_page/improve.php'),
  320. null,
  321. '_blank'
  322. );
  323. PMA_printListItem(
  324. __('Get support'),
  325. 'li_pma_support',
  326. PMA_linkURL('https://www.phpmyadmin.net/home_page/support.php'),
  327. null,
  328. '_blank'
  329. );
  330. PMA_printListItem(
  331. __('List of changes'),
  332. 'li_pma_changes',
  333. PMA_linkURL('changelog.php'),
  334. null,
  335. '_blank'
  336. );
  337. ?>
  338. </ul>
  339. </div>
  340. </div>
  341. </div>
  342. <?php
  343. /**
  344. * Warning if using the default MySQL privileged account
  345. */
  346. if ($server != 0
  347. && $cfg['Server']['user'] == 'root'
  348. && $cfg['Server']['password'] == ''
  349. ) {
  350. trigger_error(
  351. __('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\'.'),
  352. E_USER_WARNING
  353. );
  354. }
  355. /**
  356. * Nijel: As we try to handle charsets by ourself, mbstring overloads just
  357. * break it, see bug 1063821.
  358. */
  359. if (@extension_loaded('mbstring') && @ini_get('mbstring.func_overload') > 1) {
  360. trigger_error(
  361. __('You have enabled mbstring.func_overload in your PHP configuration. This option is incompatible with phpMyAdmin and might cause some data to be corrupted!'),
  362. E_USER_WARNING
  363. );
  364. }
  365. /**
  366. * Nijel: mbstring is used for handling multibyte inside parser, so it is good
  367. * to tell user something might be broken without it, see bug #1063149.
  368. */
  369. if (! @extension_loaded('mbstring')) {
  370. trigger_error(
  371. __('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.'),
  372. E_USER_WARNING
  373. );
  374. }
  375. /**
  376. * Check whether session.gc_maxlifetime limits session validity.
  377. */
  378. $gc_time = (int)@ini_get('session.gc_maxlifetime');
  379. if ($gc_time < $GLOBALS['cfg']['LoginCookieValidity'] ) {
  380. trigger_error(
  381. __('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.'),
  382. E_USER_WARNING
  383. );
  384. }
  385. /**
  386. * Check whether LoginCookieValidity is limited by LoginCookieStore.
  387. */
  388. if ($GLOBALS['cfg']['LoginCookieStore'] != 0
  389. && $GLOBALS['cfg']['LoginCookieStore'] < $GLOBALS['cfg']['LoginCookieValidity']
  390. ) {
  391. trigger_error(
  392. __('Login cookie store is lower than cookie validity configured in phpMyAdmin, because of this, your login will expire sooner than configured in phpMyAdmin.'),
  393. E_USER_WARNING
  394. );
  395. }
  396. /**
  397. * Check if user does not have defined blowfish secret and it is being used.
  398. */
  399. if (! empty($_SESSION['encryption_key'])) {
  400. if (empty($GLOBALS['cfg']['blowfish_secret'])) {
  401. trigger_error(
  402. __(
  403. 'The configuration file now needs a secret passphrase (blowfish_secret).'
  404. ),
  405. E_USER_WARNING
  406. );
  407. } elseif (strlen($GLOBALS['cfg']['blowfish_secret']) < 32) {
  408. trigger_error(
  409. __(
  410. 'The secret passphrase in configuration (blowfish_secret) is too short.'
  411. ),
  412. E_USER_WARNING
  413. );
  414. }
  415. }
  416. /**
  417. * Check for existence of config directory which should not exist in
  418. * production environment.
  419. */
  420. if (file_exists('config')) {
  421. trigger_error(
  422. __('Directory [code]config[/code], which is used by the setup script, still exists in your phpMyAdmin directory. You should remove it once phpMyAdmin has been configured.'),
  423. E_USER_WARNING
  424. );
  425. }
  426. if ($server > 0) {
  427. $cfgRelation = PMA_getRelationsParam();
  428. if (! $cfgRelation['allworks']
  429. && $cfg['PmaNoRelation_DisableWarning'] == false
  430. ) {
  431. $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.'));
  432. $msg->addParam(
  433. '<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php?' . $common_url_query . '">',
  434. false
  435. );
  436. $msg->addParam('</a>', false);
  437. /* Show error if user has configured something, notice elsewhere */
  438. if (!empty($cfg['Servers'][$server]['pmadb'])) {
  439. $msg->isError(true);
  440. }
  441. $msg->display();
  442. } // end if
  443. }
  444. /**
  445. * Warning about different MySQL library and server version
  446. * (a difference on the third digit does not count).
  447. * If someday there is a constant that we can check about mysqlnd,
  448. * we can use it instead of strpos().
  449. * If no default server is set, PMA_DBI_get_client_info() is not defined yet.
  450. * Drizzle can speak MySQL protocol, so don't warn about version mismatch for
  451. * Drizzle servers.
  452. */
  453. if (function_exists('PMA_DBI_get_client_info')
  454. && !PMA_DRIZZLE
  455. && $cfg['ServerLibraryDifference_DisableWarning'] == false
  456. ) {
  457. $_client_info = PMA_DBI_get_client_info();
  458. if ($server > 0
  459. && strpos($_client_info, 'mysqlnd') === false
  460. && substr(PMA_MYSQL_CLIENT_API, 0, 3) != substr(PMA_MYSQL_INT_VERSION, 0, 3)
  461. ) {
  462. trigger_error(
  463. PMA_sanitize(
  464. sprintf(
  465. __('Your PHP MySQL library version %s differs from your MySQL server version %s. This may cause unpredictable behavior.'),
  466. $_client_info,
  467. substr(
  468. PMA_MYSQL_STR_VERSION,
  469. 0,
  470. strpos(PMA_MYSQL_STR_VERSION . '-', '-')
  471. )
  472. )
  473. ),
  474. E_USER_NOTICE
  475. );
  476. }
  477. unset($_client_info);
  478. }
  479. /**
  480. * Warning about Suhosin
  481. */
  482. if ($cfg['SuhosinDisableWarning'] == false
  483. && @ini_get('suhosin.request.max_value_length')
  484. // warn about Suhosin only if its simulation mode is not enabled
  485. && @ini_get('suhosin.simulation') == '0'
  486. ) {
  487. trigger_error(
  488. sprintf(
  489. __('Server running with Suhosin. Please refer to %sdocumentation%s for possible issues.'),
  490. '[doc@faq1-38]',
  491. '[/doc]'
  492. ),
  493. E_USER_WARNING
  494. );
  495. }
  496. /**
  497. * Warning about mcrypt.
  498. */
  499. if (! function_exists('mcrypt_encrypt')
  500. && ! $GLOBALS['cfg']['McryptDisableWarning']
  501. ) {
  502. PMA_warnMissingExtension('mcrypt');
  503. }
  504. /**
  505. * Warning about incomplete translations.
  506. *
  507. * The data file is created while creating release by ./scripts/remove-incomplete-mo
  508. */
  509. if (file_exists('libraries/language_stats.inc.php')) {
  510. include 'libraries/language_stats.inc.php';
  511. /*
  512. * This message is intentionally not translated, because we're
  513. * handling incomplete translations here and focus on english
  514. * speaking users.
  515. */
  516. if (isset($GLOBALS['language_stats'][$lang])
  517. && $GLOBALS['language_stats'][$lang] < $cfg['TranslationWarningThreshold']
  518. ) {
  519. trigger_error(
  520. 'You are using an incomplete translation, please help to make it better by [a@https://www.phpmyadmin.net/home_page/improve.php#translate@_blank]contributing[/a].',
  521. E_USER_NOTICE
  522. );
  523. }
  524. }
  525. /**
  526. * prints list item for main page
  527. *
  528. * @param string $name displayed text
  529. * @param string $id id, used for css styles
  530. * @param string $url make item as link with $url as target
  531. * @param string $mysql_help_page display a link to MySQL's manual
  532. * @param string $target special target for $url
  533. * @param string $a_id id for the anchor,
  534. * used for jQuery to hook in functions
  535. * @param string $class class for the li element
  536. * @param string $a_class class for the anchor element
  537. *
  538. * @return void
  539. */
  540. function PMA_printListItem($name, $id = null, $url = null, $mysql_help_page = null,
  541. $target = null, $a_id = null, $class = null, $a_class = null
  542. ) {
  543. echo '<li id="' . $id . '"';
  544. if (null !== $class) {
  545. echo ' class="' . $class . '"';
  546. }
  547. echo '>';
  548. if (null !== $url) {
  549. echo '<a href="' . $url . '"';
  550. if (null !== $target) {
  551. echo ' target="' . $target . '"';
  552. if ($target == '_blank') {
  553. echo ' rel="noopener noreferrer"';
  554. }
  555. }
  556. if (null != $a_id) {
  557. echo ' id="' . $a_id .'"';
  558. }
  559. if (null != $a_class) {
  560. echo ' class="' . $a_class .'"';
  561. }
  562. echo '>';
  563. }
  564. echo $name;
  565. if (null !== $url) {
  566. echo '</a>' . "\n";
  567. }
  568. if (null !== $mysql_help_page) {
  569. echo PMA_Util::showMySQLDocu('', $mysql_help_page);
  570. }
  571. echo '</li>';
  572. }
  573. ?>