2025-03-16 18:31:38 +01:00
< ? php
namespace Adminer ;
2025-03-28 09:13:36 +01:00
/** Return <script> element */
2025-03-28 09:03:09 +01:00
function script ( string $source , string $trailing = " \n " ) : string {
2025-03-16 18:31:38 +01:00
return " <script " . nonce () . " > $source </script> $trailing " ;
}
2025-03-28 09:13:36 +01:00
/** Return <script src> element */
2025-03-28 09:03:09 +01:00
function script_src ( string $url ) : string {
2025-03-16 18:31:38 +01:00
return " <script src=' " . h ( $url ) . " ' " . nonce () . " ></script> \n " ;
}
2025-03-28 09:13:36 +01:00
/** Get a nonce="" attribute with CSP nonce */
2025-03-28 09:03:09 +01:00
function nonce () : string {
2025-03-16 18:31:38 +01:00
return ' nonce="' . get_nonce () . '"' ;
}
2025-03-18 17:15:10 +01:00
/** Get < input type = " hidden " >
2025-03-28 07:06:34 +01:00
* @ param string | int $value
2025-03-18 17:15:10 +01:00
* @ return string HTML
*/
2025-03-28 09:03:09 +01:00
function input_hidden ( string $name , $value = " " ) : string {
2025-03-18 17:15:10 +01:00
return " <input type='hidden' name=' " . h ( $name ) . " ' value=' " . h ( $value ) . " '> \n " ;
}
2025-03-17 18:45:08 +01:00
/** Get < input type = " hidden " name = " token " >
2025-03-28 07:06:34 +01:00
* @ param string $special token to use instead of global $token
2025-03-17 18:45:08 +01:00
* @ return string HTML
*/
2025-03-28 09:03:09 +01:00
function input_token ( string $special = " " ) : string {
2025-03-17 18:45:08 +01:00
global $token ;
2025-03-18 17:15:10 +01:00
return input_hidden ( " token " , ( $special ? : $token ));
2025-03-17 18:45:08 +01:00
}
2025-03-28 09:13:36 +01:00
/** Get a target="_blank" attribute */
2025-03-28 09:03:09 +01:00
function target_blank () : string {
2025-03-16 18:31:38 +01:00
return ' target="_blank" rel="noreferrer noopener"' ;
}
2025-03-28 09:13:36 +01:00
/** Escape for HTML */
2025-03-28 09:03:09 +01:00
function h ( string $string ) : string {
2025-03-16 18:31:38 +01:00
return str_replace ( " \0 " , " � " , htmlspecialchars ( $string , ENT_QUOTES , 'utf-8' ));
}
2025-03-28 09:13:36 +01:00
/** Convert \n to <br> */
2025-03-28 09:03:09 +01:00
function nl_br ( string $string ) : string {
2025-03-16 18:31:38 +01:00
return str_replace ( " \n " , " <br> " , $string ); // nl2br() uses XHTML before PHP 5.3
}
/** Generate HTML checkbox
2025-03-28 07:06:34 +01:00
* @ param string | int $value
2025-03-16 18:31:38 +01:00
*/
2025-03-28 09:03:09 +01:00
function checkbox ( string $name , $value , bool $checked , string $label = " " , string $onclick = " " , string $class = " " , string $labelled_by = " " ) : string {
2025-03-16 18:31:38 +01:00
$return = " <input type='checkbox' name=' $name ' value=' " . h ( $value ) . " ' "
. ( $checked ? " checked " : " " )
. ( $labelled_by ? " aria-labelledby=' $labelled_by ' " : " " )
. " > "
. ( $onclick ? script ( " qsl('input').onclick = function () { $onclick }; " , " " ) : " " )
;
return ( $label != " " || $class ? " <label " . ( $class ? " class=' $class ' " : " " ) . " > $return " . h ( $label ) . " </label> " : $return );
}
/** Generate list of HTML options
2025-03-28 07:06:34 +01:00
* @ param string [] | string [][] $options array of strings or arrays ( creates optgroup )
* @ param mixed $selected
* @ param bool $use_keys always use array keys for value = " " , otherwise only string keys are used
2025-03-16 18:31:38 +01:00
*/
2025-03-28 09:03:09 +01:00
function optionlist ( $options , $selected = null , bool $use_keys = false ) : string {
2025-03-16 18:31:38 +01:00
$return = " " ;
foreach ( $options as $k => $v ) {
$opts = array ( $k => $v );
if ( is_array ( $v )) {
$return .= '<optgroup label="' . h ( $k ) . '">' ;
$opts = $v ;
}
foreach ( $opts as $key => $val ) {
$return .= '<option'
. ( $use_keys || is_string ( $key ) ? ' value="' . h ( $key ) . '"' : '' )
. ( $selected !== null && ( $use_keys || is_string ( $key ) ? ( string ) $key : $val ) === $selected ? ' selected' : '' )
. '>' . h ( $val )
;
}
if ( is_array ( $v )) {
$return .= '</optgroup>' ;
}
}
return $return ;
}
/** Generate HTML < select >
2025-03-28 07:06:34 +01:00
* @ param string [] $options
2025-03-16 18:31:38 +01:00
*/
2025-03-28 09:03:09 +01:00
function html_select ( string $name , array $options , string $value = " " , string $onchange = " " , string $labelled_by = " " ) : string {
2025-03-16 18:31:38 +01:00
return " <select name=' " . h ( $name ) . " ' "
. ( $labelled_by ? " aria-labelledby=' $labelled_by ' " : " " )
. " > " . optionlist ( $options , $value ) . " </select> "
. ( $onchange ? script ( " qsl('select').onchange = function () { $onchange }; " , " " ) : " " )
;
}
/** Generate HTML radio list
2025-03-28 07:06:34 +01:00
* @ param string [] $options
2025-03-16 18:31:38 +01:00
*/
2025-03-28 09:03:09 +01:00
function html_radios ( string $name , array $options , string $value = " " ) : string {
2025-03-16 18:31:38 +01:00
$return = " " ;
foreach ( $options as $key => $val ) {
$return .= " <label><input type='radio' name=' " . h ( $name ) . " ' value=' " . h ( $key ) . " ' " . ( $key == $value ? " checked " : " " ) . " > " . h ( $val ) . " </label> " ;
}
return $return ;
}
2025-03-28 09:13:36 +01:00
/** Get onclick confirmation */
2025-03-28 09:03:09 +01:00
function confirm ( string $message = " " , string $selector = " qsl('input') " ) : string {
2025-03-20 10:22:44 +01:00
return script ( " $selector .onclick = () => confirm(' " . ( $message ? js_escape ( $message ) : lang ( 'Are you sure?' )) . " '); " , " " );
2025-03-16 18:31:38 +01:00
}
2025-03-28 09:13:36 +01:00
/** Print header for hidden fieldset (close by </div></fieldset>) */
2025-03-28 09:03:09 +01:00
function print_fieldset ( string $id , string $legend , bool $visible = false ) : void {
2025-03-16 18:31:38 +01:00
echo " <fieldset><legend> " ;
echo " <a href='#fieldset- $id '> $legend </a> " ;
echo script ( " qsl('a').onclick = partial(toggle, 'fieldset- $id '); " , " " );
echo " </legend> " ;
echo " <div id='fieldset- $id ' " . ( $visible ? " " : " class='hidden' " ) . " > \n " ;
}
2025-03-28 09:13:36 +01:00
/** Return class='active' if $bold is true */
2025-03-28 09:03:09 +01:00
function bold ( bool $bold , string $class = " " ) : string {
2025-03-16 18:31:38 +01:00
return ( $bold ? " class='active $class ' " : ( $class ? " class=' $class ' " : " " ));
}
2025-03-28 09:13:36 +01:00
/** Escape string for JavaScript apostrophes */
2025-03-28 09:03:09 +01:00
function js_escape ( string $string ) : string {
2025-03-16 18:31:38 +01:00
return addcslashes ( $string , " \r \n ' \\ / " ); // slash for <script>
}
2025-03-28 09:13:36 +01:00
/** Generate page number for pagination */
2025-03-28 09:03:09 +01:00
function pagination ( int $page , int $current ) : string {
2025-03-16 18:31:38 +01:00
return " " . ( $page == $current
? $page + 1
: '<a href="' . h ( remove_from_uri ( " page " ) . ( $page ? " &page= $page " . ( $_GET [ " next " ] ? " &next= " . urlencode ( $_GET [ " next " ]) : " " ) : " " )) . '">' . ( $page + 1 ) . " </a> "
);
}
/** Print hidden fields
2025-03-28 07:06:34 +01:00
* @ param mixed [] $process
* @ param list < string > $ignore
2025-03-16 18:31:38 +01:00
*/
2025-03-28 09:03:09 +01:00
function hidden_fields ( array $process , array $ignore = array (), string $prefix = '' ) : bool {
2025-03-16 18:31:38 +01:00
$return = false ;
foreach ( $process as $key => $val ) {
if ( ! in_array ( $key , $ignore )) {
if ( is_array ( $val )) {
hidden_fields ( $val , array (), $key );
} else {
$return = true ;
2025-03-18 17:15:10 +01:00
echo input_hidden (( $prefix ? $prefix . " [ $key ] " : $key ), $val );
2025-03-16 18:31:38 +01:00
}
}
}
return $return ;
}
2025-03-28 09:13:36 +01:00
/** Print hidden fields for GET forms */
2025-03-28 09:03:09 +01:00
function hidden_fields_get () : void {
2025-03-18 17:15:10 +01:00
echo ( sid () ? input_hidden ( session_name (), session_id ()) : '' );
echo ( SERVER !== null ? input_hidden ( DRIVER , SERVER ) : " " );
echo input_hidden ( " username " , $_GET [ " username " ]);
2025-03-16 18:31:38 +01:00
}
2025-03-24 06:41:31 +01:00
/** Print enum or set input field
2025-03-28 07:06:34 +01:00
* @ param string $type " radio " | " checkbox "
* @ param Field $field
* @ param mixed $value string | array
2025-03-16 18:31:38 +01:00
*/
2025-03-28 09:03:09 +01:00
function enum_input ( string $type , string $attrs , array $field , $value , string $empty = null ) : string {
2025-03-16 18:31:38 +01:00
global $adminer ;
preg_match_all ( " ~'((?:[^']|'')*)'~ " , $field [ " length " ], $matches );
$return = ( $empty !== null ? " <label><input type=' $type ' $attrs value=' $empty ' " . (( is_array ( $value ) ? in_array ( $empty , $value ) : $value === $empty ) ? " checked " : " " ) . " ><i> " . lang ( 'empty' ) . " </i></label> " : " " );
foreach ( $matches [ 1 ] as $i => $val ) {
$val = stripcslashes ( str_replace ( " '' " , " ' " , $val ));
$checked = ( is_array ( $value ) ? in_array ( $val , $value ) : $value === $val );
$return .= " <label><input type=' $type ' $attrs value=' " . h ( $val ) . " ' " . ( $checked ? ' checked' : '' ) . '>' . h ( $adminer -> editVal ( $val , $field )) . '</label>' ;
}
return $return ;
}
/** Print edit input field
2025-03-28 07:06:34 +01:00
* @ param Field | RoutineField $field one field from fields ()
* @ param mixed $value
2025-03-16 18:31:38 +01:00
*/
2025-03-28 09:03:09 +01:00
function input ( array $field , $value , string $function , bool $autofocus = false ) : void {
2025-03-16 18:31:38 +01:00
global $driver , $adminer ;
$name = h ( bracket_escape ( $field [ " field " ]));
echo " <td class='function'> " ;
if ( is_array ( $value ) && ! $function ) {
2025-03-18 11:15:03 +01:00
$value = json_encode ( $value , 128 | 64 | 256 ); // 128 - JSON_PRETTY_PRINT, 64 - JSON_UNESCAPED_SLASHES, 256 - JSON_UNESCAPED_UNICODE available since PHP 5.4
2025-03-16 18:31:38 +01:00
$function = " json " ;
}
$reset = ( JUSH == " mssql " && $field [ " auto_increment " ]);
if ( $reset && ! $_POST [ " save " ]) {
$function = null ;
}
$functions = ( isset ( $_GET [ " select " ]) || $reset ? array ( " orig " => lang ( 'original' )) : array ()) + $adminer -> editFunctions ( $field );
$disabled = stripos ( $field [ " default " ], " GENERATED ALWAYS AS " ) === 0 ? " disabled='' " : " " ;
$attrs = " name='fields[ $name ]' $disabled " . ( $autofocus ? " autofocus " : " " );
$enums = $driver -> enumLength ( $field );
if ( $enums ) {
$field [ " type " ] = " enum " ;
$field [ " length " ] = $enums ;
}
echo $driver -> unconvertFunction ( $field ) . " " ;
if ( $field [ " type " ] == " enum " ) {
echo h ( $functions [ " " ]) . " <td> " . $adminer -> editInput ( $_GET [ " edit " ], $field , $attrs , $value );
} else {
$has_function = ( in_array ( $function , $functions ) || isset ( $functions [ $function ]));
echo ( count ( $functions ) > 1
? " <select name='function[ $name ]' $disabled > " . optionlist ( $functions , $function === null || $has_function ? $function : " " ) . " </select> "
2025-03-21 23:41:46 +01:00
. on_help ( " event.target.value.replace(/^SQL \$ /, '') " , 1 )
2025-03-16 18:31:38 +01:00
. script ( " qsl('select').onchange = functionChange; " , " " )
: h ( reset ( $functions ))
) . '<td>' ;
$input = $adminer -> editInput ( $_GET [ " edit " ], $field , $attrs , $value ); // usage in call is without a table
if ( $input != " " ) {
echo $input ;
} elseif ( preg_match ( '~bool~' , $field [ " type " ])) {
echo " <input type='hidden' $attrs value='0'> "
. " <input type='checkbox' " . ( preg_match ( '~^(1|t|true|y|yes|on)$~i' , $value ) ? " checked='checked' " : " " ) . " $attrs value='1'> " ;
} elseif ( $field [ " type " ] == " set " ) {
preg_match_all ( " ~'((?:[^']|'')*)'~ " , $field [ " length " ], $matches );
foreach ( $matches [ 1 ] as $i => $val ) {
$val = stripcslashes ( str_replace ( " '' " , " ' " , $val ));
$checked = in_array ( $val , explode ( " , " , $value ), true );
echo " <label><input type='checkbox' name='fields[ $name ][ $i ]' value=' " . h ( $val ) . " ' " . ( $checked ? ' checked' : '' ) . " > " . h ( $adminer -> editVal ( $val , $field )) . '</label>' ;
}
} elseif ( preg_match ( '~blob|bytea|raw|file~' , $field [ " type " ]) && ini_bool ( " file_uploads " )) {
echo " <input type='file' name='fields- $name '> " ;
2025-03-18 11:12:07 +01:00
} elseif ( $function == " json " || preg_match ( '~^jsonb?$~' , $field [ " type " ])) {
echo " <textarea $attrs cols='50' rows='12' class='jush-js'> " . h ( $value ) . '</textarea>' ;
2025-03-16 18:31:38 +01:00
} elseif (( $text = preg_match ( '~text|lob|memo~i' , $field [ " type " ])) || preg_match ( " ~ \n ~ " , $value )) {
if ( $text && JUSH != " sqlite " ) {
$attrs .= " cols='50' rows='12' " ;
} else {
$rows = min ( 12 , substr_count ( $value , " \n " ) + 1 );
2024-09-09 23:54:51 +02:00
$attrs .= " cols='30' rows=' $rows ' " ;
2025-03-16 18:31:38 +01:00
}
echo " <textarea $attrs > " . h ( $value ) . '</textarea>' ;
} else {
// int(3) is only a display hint
$types = $driver -> types ();
$maxlength = ( ! preg_match ( '~int~' , $field [ " type " ]) && preg_match ( '~^(\d+)(,(\d+))?$~' , $field [ " length " ], $match )
? (( preg_match ( " ~binary~ " , $field [ " type " ]) ? 2 : 1 ) * $match [ 1 ] + ( $match [ 3 ] ? 1 : 0 ) + ( $match [ 2 ] && ! $field [ " unsigned " ] ? 1 : 0 ))
: ( $types [ $field [ " type " ]] ? $types [ $field [ " type " ]] + ( $field [ " unsigned " ] ? 0 : 1 ) : 0 )
);
if ( JUSH == 'sql' && min_version ( 5.6 ) && preg_match ( '~time~' , $field [ " type " ])) {
$maxlength += 7 ; // microtime
}
// type='date' and type='time' display localized value which may be confusing, type='datetime' uses 'T' as date and time separator
echo " <input "
. (( ! $has_function || $function === " " ) && preg_match ( '~(?<!o)int(?!er)~' , $field [ " type " ]) && ! preg_match ( '~\[\]~' , $field [ " full_type " ]) ? " type='number' " : " " )
. " value=' " . h ( $value ) . " ' " . ( $maxlength ? " data-maxlength=' $maxlength ' " : " " )
2025-03-20 15:39:55 +01:00
. ( preg_match ( '~char|binary~' , $field [ " type " ]) && $maxlength > 20 ? " size=' " . ( $maxlength > 99 ? 60 : 40 ) . " ' " : " " )
2025-03-16 18:31:38 +01:00
. " $attrs > "
;
}
echo $adminer -> editHint ( $_GET [ " edit " ], $field , $value );
// skip 'original'
$first = 0 ;
foreach ( $functions as $key => $val ) {
if ( $key === " " || ! $val ) {
break ;
}
$first ++ ;
}
2025-03-24 08:39:04 +01:00
if ( $first && count ( $functions ) > 1 ) {
echo script ( " qsl('td').oninput = partial(skipOriginal, $first ); " );
2025-03-16 18:31:38 +01:00
}
}
}
/** Process edit input field
2025-03-28 07:06:34 +01:00
* @ param Field | RoutineField $field one field from fields ()
2025-03-26 16:57:58 +01:00
* @ return mixed false to leave the original value
2025-03-16 18:31:38 +01:00
*/
2025-03-28 08:23:20 +01:00
function process_input ( array $field ) {
2025-03-16 18:31:38 +01:00
global $adminer , $driver ;
if ( stripos ( $field [ " default " ], " GENERATED ALWAYS AS " ) === 0 ) {
2025-03-26 16:57:58 +01:00
return ;
2025-03-16 18:31:38 +01:00
}
$idf = bracket_escape ( $field [ " field " ]);
2025-03-26 04:16:17 +01:00
$function = idx ( $_POST [ " function " ], $idf );
2025-03-16 18:31:38 +01:00
$value = $_POST [ " fields " ][ $idf ];
if ( $field [ " type " ] == " enum " || $driver -> enumLength ( $field )) {
if ( $value == - 1 ) {
return false ;
}
if ( $value == " " ) {
return " NULL " ;
}
}
if ( $field [ " auto_increment " ] && $value == " " ) {
return null ;
}
if ( $function == " orig " ) {
return ( preg_match ( '~^CURRENT_TIMESTAMP~i' , $field [ " on_update " ]) ? idf_escape ( $field [ " field " ]) : false );
}
if ( $function == " NULL " ) {
return " NULL " ;
}
if ( $field [ " type " ] == " set " ) {
$value = implode ( " , " , ( array ) $value );
}
if ( $function == " json " ) {
$function = " " ;
$value = json_decode ( $value , true );
if ( ! is_array ( $value )) {
return false ; //! report errors
}
return $value ;
}
if ( preg_match ( '~blob|bytea|raw|file~' , $field [ " type " ]) && ini_bool ( " file_uploads " )) {
$file = get_file ( " fields- $idf " );
if ( ! is_string ( $file )) {
return false ; //! report errors
}
return $driver -> quoteBinary ( $file );
}
return $adminer -> processInput ( $field , $value , $function );
}
/** Print results of search in all tables
* @ uses $_GET [ " where " ][ 0 ]
* @ uses $_POST [ " tables " ]
*/
2025-03-28 09:03:09 +01:00
function search_tables () : void {
2025-03-16 18:31:38 +01:00
global $adminer , $connection ;
$_GET [ " where " ][ 0 ][ " val " ] = $_POST [ " query " ];
$sep = " <ul> \n " ;
foreach ( table_status ( '' , true ) as $table => $table_status ) {
$name = $adminer -> tableName ( $table_status );
if ( isset ( $table_status [ " Engine " ]) && $name != " " && ( ! $_POST [ " tables " ] || in_array ( $table , $_POST [ " tables " ]))) {
$result = $connection -> query ( " SELECT " . limit ( " 1 FROM " . table ( $table ), " WHERE " . implode ( " AND " , $adminer -> selectSearchProcess ( fields ( $table ), array ())), 1 ));
if ( ! $result || $result -> fetch_row ()) {
$print = " <a href=' " . h ( ME . " select= " . urlencode ( $table ) . " &where[0][op]= " . urlencode ( $_GET [ " where " ][ 0 ][ " op " ]) . " &where[0][val]= " . urlencode ( $_GET [ " where " ][ 0 ][ " val " ])) . " '> $name </a> " ;
echo " $sep <li> " . ( $result ? $print : " <p class='error'> $print : " . error ()) . " \n " ;
$sep = " " ;
}
}
}
echo ( $sep ? " <p class='message'> " . lang ( 'No tables.' ) : " </ul> " ) . " \n " ;
}
/** Return events to display help on mouse over
2025-03-28 07:06:34 +01:00
* @ param string $command JS expression
* @ param int $side JS expression
2025-03-16 18:31:38 +01:00
*/
2025-03-28 09:03:09 +01:00
function on_help ( string $command , int $side = 0 ) : string {
2025-03-16 18:31:38 +01:00
return script ( " mixin(qsl('select, input'), { onmouseover: function (event) { helpMouseover.call(this, event, $command , $side ) }, onmouseout: helpMouseout}); " , " " );
}
/** Print edit data form
2025-03-28 07:06:34 +01:00
* @ param Field [] $fields
* @ param mixed $row
2025-03-16 18:31:38 +01:00
*/
2025-03-28 09:03:09 +01:00
function edit_form ( string $table , array $fields , $row , bool $update ) : void {
2025-03-17 18:45:08 +01:00
global $adminer , $error ;
2025-03-16 18:31:38 +01:00
$table_name = $adminer -> tableName ( table_status1 ( $table , true ));
page_header (
( $update ? lang ( 'Edit' ) : lang ( 'Insert' )),
$error ,
array ( " select " => array ( $table , $table_name )),
$table_name
);
$adminer -> editRowPrint ( $table , $fields , $row , $update );
if ( $row === false ) {
echo " <p class='error'> " . lang ( 'No rows.' ) . " \n " ;
return ;
}
2025-03-16 23:54:25 +01:00
echo " <form action='' method='post' enctype='multipart/form-data' id='form'> \n " ;
2025-03-16 18:31:38 +01:00
if ( ! $fields ) {
echo " <p class='error'> " . lang ( 'You have no privileges to update this table.' ) . " \n " ;
} else {
echo " <table class='layout'> " . script ( " qsl('table').onkeydown = editingKeydown; " );
$autofocus = ! $_POST ;
foreach ( $fields as $name => $field ) {
echo " <tr><th> " . $adminer -> fieldName ( $field );
2025-03-26 04:16:17 +01:00
$default = idx ( $_GET [ " set " ], bracket_escape ( $name ));
2025-03-16 18:31:38 +01:00
if ( $default === null ) {
$default = $field [ " default " ];
if ( $field [ " type " ] == " bit " && preg_match ( " ~^b'([01]*)' \$ ~ " , $default , $regs )) {
$default = $regs [ 1 ];
}
if ( JUSH == " sql " && preg_match ( '~binary~' , $field [ " type " ])) {
$default = bin2hex ( $default ); // same as UNHEX
}
}
$value = ( $row !== null
? ( $row [ $name ] != " " && JUSH == " sql " && preg_match ( " ~enum|set~ " , $field [ " type " ]) && is_array ( $row [ $name ])
? implode ( " , " , $row [ $name ])
: ( is_bool ( $row [ $name ]) ? + $row [ $name ] : $row [ $name ])
)
: ( ! $update && $field [ " auto_increment " ]
? " "
: ( isset ( $_GET [ " select " ]) ? false : $default )
)
);
if ( ! $_POST [ " save " ] && is_string ( $value )) {
$value = $adminer -> editVal ( $value , $field );
}
$function = ( $_POST [ " save " ]
2025-03-26 04:16:17 +01:00
? idx ( $_POST [ " function " ], $name , " " )
2025-03-16 18:31:38 +01:00
: ( $update && preg_match ( '~^CURRENT_TIMESTAMP~i' , $field [ " on_update " ])
? " now "
: ( $value === false ? null : ( $value !== null ? '' : 'NULL' ))
)
);
if ( ! $_POST && ! $update && $value == $field [ " default " ] && preg_match ( '~^[\w.]+\(~' , $value )) {
$function = " SQL " ;
}
if ( preg_match ( " ~time~ " , $field [ " type " ]) && preg_match ( '~^CURRENT_TIMESTAMP~i' , $value )) {
$value = " " ;
$function = " now " ;
}
if ( $field [ " type " ] == " uuid " && $value == " uuid() " ) {
$value = " " ;
$function = " uuid " ;
}
if ( $autofocus !== false ) {
$autofocus = ( $field [ " auto_increment " ] || $function == " now " || $function == " uuid " ? null : true ); // null - don't autofocus this input but check the next one
}
input ( $field , $value , $function , $autofocus );
if ( $autofocus ) {
$autofocus = false ;
}
echo " \n " ;
}
2025-03-18 11:00:57 +01:00
if ( ! support ( " table " ) && ! fields ( $table )) {
2025-03-16 18:31:38 +01:00
echo " <tr> "
. " <th><input name='field_keys[]'> "
. script ( " qsl('input').oninput = fieldChange; " )
. " <td class='function'> " . html_select ( " field_funs[] " , $adminer -> editFunctions ( array ( " null " => isset ( $_GET [ " select " ]))))
. " <td><input name='field_vals[]'> "
. " \n "
;
}
echo " </table> \n " ;
}
echo " <p> \n " ;
if ( $fields ) {
echo " <input type='submit' value=' " . lang ( 'Save' ) . " '> \n " ;
if ( ! isset ( $_GET [ " select " ])) {
echo " <input type='submit' name='insert' value=' " . ( $update
? lang ( 'Save and continue edit' )
: lang ( 'Save and insert next' )
) . " ' title='Ctrl+Shift+Enter'> \n " ;
echo ( $update ? script ( " qsl('input').onclick = function () { return !ajaxForm(this.form, ' " . lang ( 'Saving' ) . " …', this); }; " ) : " " );
}
}
echo ( $update ? " <input type='submit' name='delete' value=' " . lang ( 'Delete' ) . " '> " . confirm () . " \n " : " " );
if ( isset ( $_GET [ " select " ])) {
hidden_fields ( array ( " check " => ( array ) $_POST [ " check " ], " clone " => $_POST [ " clone " ], " all " => $_POST [ " all " ]));
}
2025-03-18 17:15:10 +01:00
echo input_hidden ( " referer " , ( isset ( $_POST [ " referer " ]) ? $_POST [ " referer " ] : $_SERVER [ " HTTP_REFERER " ]));
echo input_hidden ( " save " , 1 );
2025-03-18 16:45:15 +01:00
echo input_token ();
echo " </form> \n " ;
2025-03-16 18:31:38 +01:00
}
2025-03-26 00:08:16 +01:00
2025-03-28 09:13:36 +01:00
/** Get button with icon */
2025-03-28 09:03:09 +01:00
function icon ( string $icon , string $name , string $html , string $title ) : string {
2025-03-26 00:08:16 +01:00
return " <button type='submit' name=' $name ' title=' " . h ( $title ) . " ' class='icon icon- $icon '><span> $html </span></button> " ;
}