

/* Servers configuration */
$i = 0;

/* Server localhost (config:root) [1] */
$i++;
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '/var/lib/mysql/mysql.sock';
$cfg['Servers'][$i]['connect_type'] = 'socket';
$cfg['Servers'][$i]['compress'] = false;

# standalone or login mode
$scriptname=end(explode('/',$_SERVER['PHP_SELF']));
$scriptpath=str_replace($scriptname,'',$_SERVER['PHP_SELF']);


# standalone login part
{
my $adminaccess = ($phpmyadmin{'adminaccess'} || 'enabled');
my $multiaccess = ($phpmyadmin{'multiaccess'} || 'disabled');

# this one could be tricky, with fpm we need to translate the auth from httpd 
# we need to have this in httpd.conf in the directory of phpmyadmin : 
# SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=\$1
# also need in the fpm pool this (and the file in the open base dir )
# php_admin_value[auto_prepend_file] = /usr/share/php/auth_translation.php
# the line here could help debug :
# error_log("current user: REDIRECT". $_SERVER['REDIRECT_REMOTE_USER'] ."REMOTE". $_SERVER['REMOTE_USER'] . " PHP_AUTH_USER". $_SERVER['PHP_AUTH_USER'] ); 
if (("$adminaccess" eq "enabled"))
  {
  $OUT .="if (\$scriptpath==\"/phpmyadmin/\" && \$_SERVER['PHP_AUTH_USER']=='admin')\n";
  $OUT .="{\n";
  $OUT .="\$cfg['Servers'][\$i]['auth_type'] = 'config';\n";
  $OUT .="\$cfg['Servers'][\$i]['user'] = 'root';\n";
  open (PW, "/etc/openldap/ldap.pw")
        || die "Could not read LDAP password.\n";
  my $pw = <PW>;
  chomp ($pw);
  close PW;
  $OUT .="\$cfg['Servers'][\$i]['password']  = '$pw';\n";
  $OUT .="}";
  }
else
  {
  $OUT .="# standalone admin configuration disabled";
  }
}
# end of  standalone login part


# multiuser login part
{
my $adminaccess = ($phpmyadmin{'adminaccess'} || 'enabled');
my $multiaccess = ($phpmyadmin{'multiaccess'} || 'disabled');

  $OUT .="\n";
if (("$multiaccess" eq "enabled") && ("$adminaccess" eq "enabled"))
  {
  $OUT .="if (\$scriptpath==\"/phpmyadmin-multi/\")\n";
  $OUT .="{\n";
  }
if (("$multiaccess" eq "enabled"))
  {
  $OUT .="\$cfg['Servers'][\$i]['auth_type'] = 'cookie';\n";
  my $secret = ${'httpd-admin'}{TKTAuthSecret} || "34322500-7330-4400-423A-3A00434F5245";
  $OUT .="\$cfg['blowfish_secret'] = '$secret';\n";
  }
else
  {
   $OUT .="# multiuser disabled\n";
  }
if (("$multiaccess" eq "enabled") && ("$adminaccess" eq "enabled"))
  {
  $OUT .="}\n";
  }

}
# end of multiuser login part


{
use esmith::util;
#we retrieve values for settings options below
our $dbname = $phpmyadmin{'DbName'} || 'phpmyadmin';
our $dbuser = $phpmyadmin{'DbUser'} || 'phpmyadmin';
our $dbpass = $phpmyadmin{'DbPassword'} || 'phpmyadmin';

$OUT .= '';

}


/* enhanced servers configuration */

$cfg['Servers'][$i]['pmadb'] = '{$dbname}';
$cfg['Servers'][$i]['controluser'] = '{$dbuser}';
$cfg['Servers'][$i]['controlpass'] = '{$dbpass}';
$cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
$cfg['Servers'][$i]['relation'] = 'pma_relation';
$cfg['Servers'][$i]['userconfig'] = 'pma_userconfig';
$cfg['Servers'][$i]['table_info'] = 'pma_table_info';
$cfg['Servers'][$i]['column_info'] = 'pma_column_info';
$cfg['Servers'][$i]['history'] = 'pma_history';
$cfg['Servers'][$i]['recent'] = 'pma_recent';
$cfg['Servers'][$i]['table_uiprefs'] = 'pma_table_uiprefs';
$cfg['Servers'][$i]['tracking'] = 'pma_tracking';
$cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
$cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';
$cfg['Servers'][$i]['AllowRoot']               = TRUE;
$cfg['Servers'][$i]['AllowDeny']['rules']      = array();
$cfg['Servers'][$i]['AllowNoPassword']         = FALSE;
$cfg['Servers'][$i]['bs_garbage_threshold']    = 50;
$cfg['Servers'][$i]['bs_repository_threshold'] = '32M';
$cfg['Servers'][$i]['bs_temp_blob_timeout']    = 600; 
$cfg['Servers'][$i]['bs_temp_log_threshold']   = '32M';

/* End of servers configuration */

