index.inc.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Overview (main page)
  5. *
  6. * @package PhpMyAdmin-Setup
  7. */
  8. use PhpMyAdmin\Config\ConfigFile;
  9. use PhpMyAdmin\Config\FormDisplay;
  10. use PhpMyAdmin\Config\FormDisplayTemplate;
  11. use PhpMyAdmin\Config\ServerConfigChecks;
  12. use PhpMyAdmin\Core;
  13. use PhpMyAdmin\LanguageManager;
  14. use PhpMyAdmin\Sanitize;
  15. use PhpMyAdmin\Setup\Index as SetupIndex;
  16. use PhpMyAdmin\Url;
  17. if (!defined('PHPMYADMIN')) {
  18. exit;
  19. }
  20. // prepare unfiltered language list
  21. $all_languages = LanguageManager::getInstance()->sortedLanguages();
  22. /** @var ConfigFile $cf */
  23. $cf = $GLOBALS['ConfigFile'];
  24. // message handling
  25. SetupIndex::messagesBegin();
  26. //
  27. // Check phpMyAdmin version
  28. //
  29. if (isset($_GET['version_check'])) {
  30. SetupIndex::versionCheck();
  31. }
  32. //
  33. // Perform various security, compatibility and consistency checks
  34. //
  35. $configChecker = new ServerConfigChecks($GLOBALS['ConfigFile']);
  36. $configChecker->performConfigChecks();
  37. //
  38. // Https connection warning (check done on the client side)
  39. //
  40. $text = __(
  41. 'You are not using a secure connection; all data (including potentially '
  42. . 'sensitive information, like passwords) is transferred unencrypted!'
  43. );
  44. $text .= ' <a href="#">';
  45. $text .= __(
  46. 'If your server is also configured to accept HTTPS requests '
  47. . 'follow this link to use a secure connection.'
  48. );
  49. $text .= '</a>';
  50. SetupIndex::messagesSet('notice', 'no_https', __('Insecure connection'), $text);
  51. echo '<form id="select_lang" method="post">';
  52. echo Url::getHiddenInputs();
  53. echo '<bdo lang="en" dir="ltr"><label for="lang">';
  54. echo __('Language') , (__('Language') != 'Language' ? ' - Language' : '');
  55. echo '</label></bdo><br />';
  56. echo '<select id="lang" name="lang" class="autosubmit" lang="en" dir="ltr">';
  57. // create language list
  58. $lang_list = array();
  59. foreach ($all_languages as $each_lang) {
  60. //Is current one active?
  61. $selected = $each_lang->isActive() ? ' selected="selected"' : '';
  62. echo '<option value="' , $each_lang->getCode() , '"' , $selected , '>' , $each_lang->getName()
  63. , '</option>' , "\n";
  64. }
  65. echo '</select>';
  66. echo '</form>';
  67. // Check for done action info and set notice message if present
  68. switch ($action_done) {
  69. case 'config_saved':
  70. /* Use uniqid to display this message every time configuration is saved */
  71. SetupIndex::messagesSet(
  72. 'notice', uniqid('config_saved'), __('Configuration saved.'),
  73. Sanitize::sanitize(
  74. __(
  75. 'Configuration saved to file config/config.inc.php in phpMyAdmin '
  76. . 'top level directory, copy it to top level one and delete '
  77. . 'directory config to use it.'
  78. )
  79. )
  80. );
  81. break;
  82. case 'config_not_saved':
  83. /* Use uniqid to display this message every time configuration is saved */
  84. SetupIndex::messagesSet(
  85. 'notice', uniqid('config_not_saved'), __('Configuration not saved!'),
  86. Sanitize::sanitize(
  87. __(
  88. 'Please create web server writable folder [em]config[/em] in '
  89. . 'phpMyAdmin top level directory as described in '
  90. . '[doc@setup_script]documentation[/doc]. Otherwise you will be '
  91. . 'only able to download or display it.'
  92. )
  93. )
  94. );
  95. break;
  96. default:
  97. break;
  98. }
  99. echo '<h2>' , __('Overview') , '</h2>';
  100. // message handling
  101. SetupIndex::messagesEnd();
  102. SetupIndex::messagesShowHtml();
  103. echo '<a href="#" id="show_hidden_messages" class="hide">';
  104. echo __('Show hidden messages (#MSG_COUNT)');
  105. echo '</a>';
  106. echo '<fieldset class="simple"><legend>';
  107. echo __('Servers');
  108. echo '</legend>';
  109. //
  110. // Display server list
  111. //
  112. echo FormDisplayTemplate::displayFormTop(
  113. 'index.php', 'get',
  114. array(
  115. 'page' => 'servers',
  116. 'mode' => 'add'
  117. )
  118. );
  119. echo '<div class="form">';
  120. if ($cf->getServerCount() > 0) {
  121. echo '<table cellspacing="0" class="datatable">';
  122. echo '<tr>';
  123. echo '<th>#</th>';
  124. echo '<th>' , __('Name') , '</th>';
  125. echo '<th>' , __('Authentication type') , '</th>';
  126. echo '<th colspan="2">DSN</th>';
  127. echo '</tr>';
  128. foreach ($cf->getServers() as $id => $server) {
  129. echo '<tr>';
  130. echo '<td>' , $id , '</td>';
  131. echo '<td>' , htmlspecialchars($cf->getServerName($id)) , '</td>';
  132. echo '<td>'
  133. , htmlspecialchars($cf->getValue("Servers/$id/auth_type"))
  134. , '</td>';
  135. echo '<td>' , htmlspecialchars($cf->getServerDSN($id)) , '</td>';
  136. echo '<td class="nowrap">';
  137. echo '<small>';
  138. echo '<a href="' , Url::getCommon(array('page' => 'servers', 'mode' => 'edit', 'id' => $id)), '">'
  139. , __('Edit') , '</a>';
  140. echo ' | ';
  141. echo '<a class="delete-server" href="' . Url::getCommon(array('page' => 'servers', 'mode' => 'remove', 'id' => $id));
  142. echo '" data-post="' . Url::getCommon(array('token' => $_SESSION[' PMA_token ']), '', false) . '">';
  143. echo __('Delete') . '</a>';
  144. echo '</small>';
  145. echo '</td>';
  146. echo '</tr>';
  147. }
  148. echo '</table>';
  149. } else {
  150. echo '<table width="100%">';
  151. echo '<tr>';
  152. echo '<td>';
  153. echo '<i>' , __('There are no configured servers') , '</i>';
  154. echo '</td>';
  155. echo '</tr>';
  156. echo '</table>';
  157. }
  158. echo '<table width="100%">';
  159. echo '<tr>';
  160. echo '<td class="lastrow left">';
  161. echo '<input type="submit" name="submit" value="' , __('New server') , '" />';
  162. echo '</td>';
  163. echo '</tr>';
  164. echo '</table>';
  165. echo '</div>';
  166. echo FormDisplayTemplate::displayFormBottom();
  167. echo '</fieldset>';
  168. echo '<fieldset class="simple"><legend>' , __('Configuration file') , '</legend>';
  169. //
  170. // Display config file settings and load/save form
  171. //
  172. $form_display = new FormDisplay($cf);
  173. echo FormDisplayTemplate::displayFormTop('config.php');
  174. echo '<table width="100%" cellspacing="0">';
  175. // Display language list
  176. $opts = array(
  177. 'doc' => $form_display->getDocLink('DefaultLang'),
  178. 'values' => array(),
  179. 'values_escaped' => true);
  180. foreach ($all_languages as $each_lang) {
  181. $opts['values'][$each_lang->getCode()] = $each_lang->getName();
  182. }
  183. echo FormDisplayTemplate::displayInput(
  184. 'DefaultLang', __('Default language'), 'select',
  185. $cf->getValue('DefaultLang'), '', true, $opts
  186. );
  187. // Display server list
  188. $opts = array(
  189. 'doc' => $form_display->getDocLink('ServerDefault'),
  190. 'values' => array(),
  191. 'values_disabled' => array());
  192. if ($cf->getServerCount() > 0) {
  193. $opts['values']['0'] = __('let the user choose');
  194. $opts['values']['-'] = '------------------------------';
  195. if ($cf->getServerCount() == 1) {
  196. $opts['values_disabled'][] = '0';
  197. }
  198. $opts['values_disabled'][] = '-';
  199. foreach ($cf->getServers() as $id => $server) {
  200. $opts['values'][(string)$id] = $cf->getServerName($id) . " [$id]";
  201. }
  202. } else {
  203. $opts['values']['1'] = __('- none -');
  204. $opts['values_escaped'] = true;
  205. }
  206. echo FormDisplayTemplate::displayInput(
  207. 'ServerDefault', __('Default server'), 'select',
  208. $cf->getValue('ServerDefault'), '', true, $opts
  209. );
  210. // Display EOL list
  211. $opts = array(
  212. 'values' => array(
  213. 'unix' => 'UNIX / Linux (\n)',
  214. 'win' => 'Windows (\r\n)'),
  215. 'values_escaped' => true);
  216. $eol = Core::ifSetOr($_SESSION['eol'], (PMA_IS_WINDOWS ? 'win' : 'unix'));
  217. echo FormDisplayTemplate::displayInput(
  218. 'eol', __('End of line'), 'select',
  219. $eol, '', true, $opts
  220. );
  221. echo '<tr>';
  222. echo '<td colspan="2" class="lastrow left">';
  223. echo '<input type="submit" name="submit_display" value="' , __('Display') , '" />';
  224. echo '<input type="submit" name="submit_download" value="' , __('Download') , '" />';
  225. echo '&nbsp; &nbsp;';
  226. echo '<input type="submit" name="submit_clear" value="' , __('Clear')
  227. , '" class="red" />';
  228. echo '</td>';
  229. echo '</tr>';
  230. echo '</table>';
  231. echo FormDisplayTemplate::displayFormBottom();
  232. echo '</fieldset>';
  233. echo '<div id="footer">';
  234. echo '<a href="../url.php?url=https://www.phpmyadmin.net/">' , __('phpMyAdmin homepage') , '</a>';
  235. echo '<a href="../url.php?url=https://www.phpmyadmin.net/donate/">'
  236. , __('Donate') , '</a>';
  237. echo '<a href="' , Url::getCommon(array('version_check' => '1')), '">'
  238. , __('Check for latest version') , '</a>';
  239. echo '</div>';