index.inc.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Overview (main page)
  5. *
  6. * @package PhpMyAdmin-Setup
  7. */
  8. if (!defined('PHPMYADMIN')) {
  9. exit;
  10. }
  11. /**
  12. * Core libraries.
  13. */
  14. require_once './libraries/display_select_lang.lib.php';
  15. require_once './libraries/config/FormDisplay.class.php';
  16. require_once './libraries/config/ServerConfigChecks.class.php';
  17. require_once './setup/lib/index.lib.php';
  18. // prepare unfiltered language list
  19. $all_languages = PMA_langList();
  20. uasort($all_languages, 'PMA_languageCmp');
  21. $cf = $GLOBALS['ConfigFile'];
  22. $separator = PMA_URL_getArgSeparator('html');
  23. // message handling
  24. PMA_messagesBegin();
  25. //
  26. // Check phpMyAdmin version
  27. //
  28. if (isset($_GET['version_check'])) {
  29. PMA_versionCheck();
  30. }
  31. //
  32. // Perform various security, compatibility and consistency checks
  33. //
  34. $configChecker = new ServerConfigChecks($GLOBALS['ConfigFile']);
  35. $configChecker->performConfigChecks();
  36. //
  37. // Check whether we can read/write configuration
  38. //
  39. $config_readable = false;
  40. $config_writable = false;
  41. $config_exists = false;
  42. PMA_checkConfigRw($config_readable, $config_writable, $config_exists);
  43. if (!$config_writable || !$config_readable) {
  44. PMA_messagesSet(
  45. 'error', 'config_rw', __('Cannot load or save configuration'),
  46. PMA_sanitize(
  47. __(
  48. 'Please create web server writable folder [em]config[/em] in '
  49. . 'phpMyAdmin top level directory as described in '
  50. . '[doc@setup_script]documentation[/doc]. Otherwise you will be '
  51. . 'only able to download or display it.'
  52. )
  53. )
  54. );
  55. }
  56. //
  57. // Check https connection
  58. //
  59. $is_https = !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on';
  60. if (!$is_https) {
  61. $text = __(
  62. 'You are not using a secure connection; all data (including potentially '
  63. . 'sensitive information, like passwords) is transferred unencrypted!'
  64. );
  65. if (!empty($_SERVER['REQUEST_URI']) && !empty($_SERVER['HTTP_HOST'])) {
  66. $link = htmlspecialchars(
  67. 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']
  68. );
  69. $text .= ' ';
  70. $text .= PMA_sanitize(
  71. sprintf(
  72. __(
  73. 'If your server is also configured to accept HTTPS requests '
  74. . 'follow [a@%s]this link[/a] to use a secure connection.'
  75. ),
  76. $link
  77. )
  78. );
  79. }
  80. PMA_messagesSet('notice', 'no_https', __('Insecure connection'), $text);
  81. }
  82. echo '<form id="select_lang" method="post" action="'
  83. . htmlspecialchars($_SERVER['REQUEST_URI']) . '">';
  84. echo PMA_URL_getHiddenInputs();
  85. echo '<bdo lang="en" dir="ltr"><label for="lang">';
  86. echo __('Language') . (__('Language') != 'Language' ? ' - Language' : '');
  87. echo '</label></bdo><br />';
  88. echo '<select id="lang" name="lang" class="autosubmit" lang="en" dir="ltr">';
  89. // create language list
  90. $lang_list = array();
  91. foreach ($all_languages as $each_lang_key => $each_lang) {
  92. $lang_name = PMA_languageName($each_lang);
  93. //Is current one active?
  94. $selected = ($GLOBALS['lang'] == $each_lang_key) ? ' selected="selected"' : '';
  95. echo '<option value="' . $each_lang_key . '"' . $selected . '>' . $lang_name
  96. . '</option>' . "\n";
  97. }
  98. echo '</select>';
  99. echo '</form>';
  100. // Check for done action info and set notice message if present
  101. switch ($action_done) {
  102. case 'config_saved':
  103. /* Use uniqid to display this message every time configuration is saved */
  104. PMA_messagesSet(
  105. 'notice', uniqid('config_saved'), __('Configuration saved.'),
  106. PMA_sanitize(
  107. __(
  108. 'Configuration saved to file config/config.inc.php in phpMyAdmin '
  109. . 'top level directory, copy it to top level one and delete '
  110. . 'directory config to use it.'
  111. )
  112. )
  113. );
  114. break;
  115. default:
  116. break;
  117. }
  118. echo '<h2>' . __('Overview') . '</h2>';
  119. // message handling
  120. PMA_messagesEnd();
  121. PMA_messagesShowHtml();
  122. echo '<a href="#" id="show_hidden_messages" style="display:none">';
  123. echo __('Show hidden messages (#MSG_COUNT)');
  124. echo '</a>';
  125. echo '<fieldset class="simple"><legend>';
  126. echo __('Servers');
  127. echo '</legend>';
  128. //
  129. // Display server list
  130. //
  131. PMA_displayFormTop(
  132. 'index.php', 'get',
  133. array(
  134. 'page' => 'servers',
  135. 'mode' => 'add'
  136. )
  137. );
  138. echo '<div class="form">';
  139. if ($cf->getServerCount() > 0) {
  140. echo '<table cellspacing="0" class="datatable" style="table-layout: fixed">';
  141. echo '<tr>';
  142. echo '<th>#</th>';
  143. echo '<th>' . __('Name') . '</th>';
  144. echo '<th>' . __('Authentication type') . '</th>';
  145. echo '<th colspan="2">DSN</th>';
  146. echo '</tr>';
  147. foreach ($cf->getServers() as $id => $server) {
  148. echo '<tr>';
  149. echo '<td>' . $id . '</td>';
  150. echo '<td>' . htmlspecialchars($cf->getServerName($id)) . '</td>';
  151. echo '<td>'
  152. . htmlspecialchars($cf->getValue("Servers/$id/auth_type"))
  153. . '</td>';
  154. echo '<td>' . htmlspecialchars($cf->getServerDSN($id)) . '</td>';
  155. echo '<td style="white-space: nowrap">';
  156. echo '<small>';
  157. echo '<a href="?page=servers' . $separator
  158. . 'mode=edit' . $separator . 'id=' . $id . '">'
  159. . __('Edit') . '</a>';
  160. echo ' | ';
  161. echo '<a href="?page=servers' . $separator
  162. . 'mode=remove' . $separator . 'id=' . $id . '">'
  163. . __('Delete') . '</a>';
  164. echo '</small>';
  165. echo '</td>';
  166. echo '</tr>';
  167. }
  168. echo '</table>';
  169. } else {
  170. echo '<table width="100%">';
  171. echo '<tr>';
  172. echo '<td>';
  173. echo '<i>' . __('There are no configured servers') . '</i>';
  174. echo '</td>';
  175. echo '</tr>';
  176. echo '</table>';
  177. }
  178. echo '<table width="100%">';
  179. echo '<tr>';
  180. echo '<td class="lastrow" style="text-align: left">';
  181. echo '<input type="submit" name="submit" value="' . __('New server') . '" />';
  182. echo '</td>';
  183. echo '</tr>';
  184. echo '</table>';
  185. echo '</div>';
  186. PMA_displayFormBottom();
  187. echo '</fieldset>';
  188. echo '<fieldset class="simple"><legend>' . __('Configuration file') . '</legend>';
  189. //
  190. // Display config file settings and load/save form
  191. //
  192. $form_display = new FormDisplay($cf);
  193. PMA_displayFormTop('config.php');
  194. echo '<table width="100%" cellspacing="0">';
  195. // Display language list
  196. $opts = array(
  197. 'doc' => $form_display->getDocLink('DefaultLang'),
  198. 'values' => array(),
  199. 'values_escaped' => true);
  200. foreach ($all_languages as $each_lang_key => $each_lang) {
  201. $lang_name = PMA_languageName($each_lang);
  202. $opts['values'][$each_lang_key] = $lang_name;
  203. }
  204. PMA_displayInput(
  205. 'DefaultLang', __('Default language'), 'select',
  206. $cf->getValue('DefaultLang'), '', true, $opts
  207. );
  208. // Display server list
  209. $opts = array(
  210. 'doc' => $form_display->getDocLink('ServerDefault'),
  211. 'values' => array(),
  212. 'values_disabled' => array());
  213. if ($cf->getServerCount() > 0) {
  214. $opts['values']['0'] = __('let the user choose');
  215. $opts['values']['-'] = '------------------------------';
  216. if ($cf->getServerCount() == 1) {
  217. $opts['values_disabled'][] = '0';
  218. }
  219. $opts['values_disabled'][] = '-';
  220. foreach ($cf->getServers() as $id => $server) {
  221. $opts['values'][(string)$id] = $cf->getServerName($id) . " [$id]";
  222. }
  223. } else {
  224. $opts['values']['1'] = __('- none -');
  225. $opts['values_escaped'] = true;
  226. }
  227. PMA_displayInput(
  228. 'ServerDefault', __('Default server'), 'select',
  229. $cf->getValue('ServerDefault'), '', true, $opts
  230. );
  231. // Display EOL list
  232. $opts = array(
  233. 'values' => array(
  234. 'unix' => 'UNIX / Linux (\n)',
  235. 'win' => 'Windows (\r\n)'),
  236. 'values_escaped' => true);
  237. $eol = PMA_ifSetOr($_SESSION['eol'], (PMA_IS_WINDOWS ? 'win' : 'unix'));
  238. PMA_displayInput(
  239. 'eol', __('End of line'), 'select',
  240. $eol, '', true, $opts
  241. );
  242. echo '<tr>';
  243. echo '<td colspan="2" class="lastrow" style="text-align: left">';
  244. echo '<input type="submit" name="submit_display" value="' . __('Display') . '" />';
  245. echo '<input type="submit" name="submit_download" value="' . __('Download') . '" />';
  246. echo '&nbsp; &nbsp;';
  247. echo '<input type="submit" name="submit_save" value="' . __('Save') . '"';
  248. if (!$config_writable) {
  249. echo ' disabled="disabled"';
  250. }
  251. echo '/>';
  252. echo '<input type="submit" name="submit_load" value="' . __('Load') . '"';
  253. if (!$config_exists) {
  254. echo ' disabled="disabled"';
  255. }
  256. echo '/>';
  257. echo '<input type="submit" name="submit_delete" value="' . __('Delete') . '"';
  258. if (!$config_exists || !$config_writable) {
  259. echo ' disabled="disabled"';
  260. }
  261. echo '/>';
  262. echo '&nbsp; &nbsp;';
  263. echo '<input type="submit" name="submit_clear" value="' . __('Clear')
  264. . '" class="red" />';
  265. echo '</td>';
  266. echo '</tr>';
  267. echo '</table>';
  268. PMA_displayFormBottom();
  269. echo '</fieldset>';
  270. echo '<div id="footer">';
  271. echo '<a href="http://www.phpmyadmin.net/">' . __('phpMyAdmin homepage') . '</a>';
  272. echo '<a href="http://sourceforge.net/donate/index.php?group_id=23067">'
  273. . __('Donate') . '</a>';
  274. echo '<a href="?version_check=1' . $separator
  275. . 'token=' . $_SESSION[' PMA_token '] . '">'
  276. . __('Check for latest version') . '</a>';
  277. echo '</div>';