2025-04-06 06:24:55 +02:00
< ? php
/** Configure options by end - users and store them to a cookie
* @ link https :// www . adminer . org / plugins / #use
* @ author Jakub Vrana , https :// www . vrana . cz /
* @ license https :// www . apache . org / licenses / LICENSE - 2.0 Apache License , Version 2.0
* @ license https :// www . gnu . org / licenses / gpl - 2.0 . html GNU General Public License , version 2 ( one or other )
*/
2025-04-06 06:43:26 +02:00
class AdminerConfig extends Adminer\Plugin {
2025-04-06 06:24:55 +02:00
function headers () {
static $called ; // this function is called from page_header() and it also calls page_header()
if ( isset ( $_GET [ " config " ]) && ! $called && Adminer\connection ()) {
$called = true ;
2025-04-06 16:41:25 +02:00
if ( $_GET [ " config " ]) { // using $_GET allows sharing links between devices but doesn't protect against same-site RF; CSRF is protected by SameSite cookies
2025-04-06 08:08:57 +02:00
Adminer\save_settings ( $_GET [ " config " ], " adminer_config " );
Adminer\redirect ( null , $this -> lang ( 'Configuration saved.' ));
2025-04-06 06:24:55 +02:00
}
Adminer\page_header ( $this -> lang ( 'Configuration' ));
$config = Adminer\adminer () -> config ();
if ( ! $config ) {
2025-04-06 07:28:54 +02:00
// this plugin itself defines config() so this branch is not currently used
2025-04-06 06:24:55 +02:00
echo " <p> " . $this -> lang ( 'Only some plugins support configuration, e.g. %s.' , '<a href="https://github.com/vrana/adminer/blob/master/plugins/menu-links.php"' . Adminer\target_blank () . '>menu-links</a>' ) . " \n " ;
} else {
2025-04-06 08:08:57 +02:00
echo " <form action=''> \n " ;
Adminer\hidden_fields_get ();
2025-04-06 06:24:55 +02:00
echo " <table> \n " ;
2025-04-06 07:28:54 +02:00
foreach ( array_reverse ( $config ) as $title => $html ) { // Plugins::$append actually prepends
2025-04-06 06:24:55 +02:00
echo " <tr><th> $title <td> $html\n " ;
}
echo " </table> \n " ;
echo " <p><input type='submit' value=' " . Adminer\lang ( 'Save' ) . " '> \n " ;
echo " </form> \n " ;
}
Adminer\page_footer ( 'db' );
exit ;
}
}
2025-04-06 07:28:54 +02:00
function config () {
$options = array (
'' => $this -> lang ( 'Use %s if exists' , " adminer.css " ),
'builtin' => $this -> lang ( 'Use builtin design' ),
);
2025-04-06 08:08:57 +02:00
return array ( $this -> lang ( 'Design' ) => Adminer\html_radios ( 'config[design]' , $options , Adminer\get_setting ( " design " , " adminer_config " ), " <br> " ));
2025-04-06 07:28:54 +02:00
}
function css () {
if ( Adminer\get_setting ( " design " , " adminer_config " ) == " builtin " ) {
return array ();
}
}
2025-04-06 06:24:55 +02:00
function navigation () {
2025-04-06 07:28:54 +02:00
if ( Adminer\connection ()) { // don't display on login page
2025-04-06 06:24:55 +02:00
$link = substr ( preg_replace ( '~\b(db|ns)=[^&]*&~' , '' , Adminer\ME ), 0 , - 1 );
?>
< style >
#configlink { position: absolute; top: -2.6em; left: 17.8em; }
#configlink a { font-size: 150%; }
@ media all and ( max - width : 800 px ) {
#configlink { top: 5em; left: auto; right: 20px; }
}
</ style >
< ? php
echo " <div id='configlink'><a href=' " . Adminer\h ( $link ) . " &config=' title=' " . $this -> lang ( 'Configuration' ) . " '>⚙</a></div> \n " ;
}
}
protected static $translations = array (
'cs' => array (
'Configuration' => 'Konfigurace' ,
'Configuration saved.' => 'Konfigurace uložena.' ,
'Only some plugins support configuration, e.g. %s.' => 'Konfiguraci podporují jen některé pluginy, např. %s.' ,
2025-04-06 07:28:54 +02:00
'Design' => 'Vzhled' ,
'Use %s if exists' => 'Použít %s, pokud existuje' ,
'Use builtin design' => 'Použít vestavěný vzhled' ,
2025-04-06 06:24:55 +02:00
),
2025-04-06 15:40:41 +02:00
'pl' => array (
'Configuration' => 'Konfiguracja' ,
'Configuration saved.' => 'Konfiguracja zapisana.' ,
'Only some plugins support configuration, e.g. %s.' => 'Tylko niektóre wtyczki obsługują konfigurację, np. %s.' ,
'Design' => 'Wygląd' ,
'Use %s if exists' => 'Użyj %s, jeśli istnieje' ,
'Use builtin design' => 'Użyj wbudowanego wyglądu' ,
),
2025-04-06 06:24:55 +02:00
);
}