Guest User

Untitled

a guest
May 21st, 2020
727
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. <?php
  2.  
  3. require('/etc/phpmyadmin/config.secret.inc.php');
  4.  
  5. /* Ensure we got the environment */
  6. $vars = array(
  7. 'PMA_ARBITRARY',
  8. 'PMA_HOST',
  9. 'PMA_HOSTS',
  10. 'PMA_VERBOSE',
  11. 'PMA_VERBOSES',
  12. 'PMA_PORT',
  13. 'PMA_PORTS',
  14. 'PMA_USER',
  15. 'PMA_PASSWORD',
  16. 'PMA_ABSOLUTE_URI'
  17. );
  18. foreach ($vars as $var) {
  19. $env = getenv($var);
  20. if (!isset($_ENV[$var]) && $env !== false) {
  21. $_ENV[$var] = $env;
  22. }
  23. }
  24.  
  25. /* Arbitrary server connection */
  26. if (isset($_ENV['PMA_ARBITRARY']) && $_ENV['PMA_ARBITRARY'] === '1') {
  27. $cfg['AllowArbitraryServer'] = true;
  28. }
  29.  
  30. /* Play nice behind reverse proxys */
  31. if (isset($_ENV['PMA_ABSOLUTE_URI'])) {
  32. $cfg['PmaAbsoluteUri'] = trim($_ENV['PMA_ABSOLUTE_URI']);
  33. }
  34.  
  35. /* Figure out hosts */
  36.  
  37. /* Fallback to default linked */
  38. $hosts = array('db');
  39.  
  40. /* Set by environment */
  41. if (!empty($_ENV['PMA_HOST'])) {
  42. $hosts = array($_ENV['PMA_HOST']);
  43. $verbose = array($_ENV['PMA_VERBOSE']);
  44. $ports = array($_ENV['PMA_PORT']);
  45. } elseif (!empty($_ENV['PMA_HOSTS'])) {
  46. $hosts = explode(',', $_ENV['PMA_HOSTS']);
  47. $verbose = explode(',', $_ENV['PMA_VERBOSES']);
  48. $ports = explode(',', $_ENV['PMA_PORTS']);
  49. }
  50.  
  51. /* Server settings */
  52. for ($i = 1; isset($hosts[$i - 1]); $i++) {
  53. $cfg['Servers'][$i]['host'] = $hosts[$i - 1];
  54. if (isset($verbose[$i - 1])) {
  55. $cfg['Servers'][$i]['verbose'] = $verbose[$i - 1];
  56. }
  57. if (isset($ports[$i - 1])) {
  58. $cfg['Servers'][$i]['port'] = $ports[$i - 1];
  59. }
  60. if (isset($_ENV['PMA_USER'])) {
  61. $cfg['Servers'][$i]['auth_type'] = 'config';
  62. $cfg['Servers'][$i]['user'] = $_ENV['PMA_USER'];
  63. $cfg['Servers'][$i]['password'] = isset($_ENV['PMA_PASSWORD']) ? $_ENV['PMA_PASSWORD'] : '';
  64. } else {
  65. $cfg['Servers'][$i]['auth_type'] = 'cookie';
  66. }
  67. $cfg['Servers'][$i]['compress'] = false;
  68. $cfg['Servers'][$i]['AllowNoPassword'] = true;
  69. }
  70. /*
  71. * Revert back to last configured server to make
  72. * it easier in config.user.inc.php
  73. */
  74. $i--;
  75.  
  76. /* Uploads setup */
  77. $cfg['UploadDir'] = '';
  78. $cfg['SaveDir'] = '';
  79.  
  80. /* Include User Defined Settings Hook */
  81. if (file_exists('/etc/phpmyadmin/config.user.inc.php')) {
  82. include('/etc/phpmyadmin/config.user.inc.php');
  83. }
Add Comment
Please, Sign In to add comment