1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-05 06:07:57 +02:00

Avoid excessive PHP and HTML mixing

This commit is contained in:
Jakub Vrana
2025-03-18 16:45:15 +01:00
parent eeb78d7e48
commit 9cfea02e19
5 changed files with 25 additions and 45 deletions

View File

@@ -986,15 +986,10 @@ class Adminer {
*/
function navigation($missing) {
global $VERSION, $drivers, $connection;
?>
<h1>
<?php echo $this->name(); ?>
<span class="version">
<?php echo $VERSION; ?>
<a href="https://www.adminer.org/#download"<?php echo target_blank(); ?> id="version"><?php echo (version_compare($VERSION, $_COOKIE["adminer_version"]) < 0 ? h($_COOKIE["adminer_version"]) : ""); ?></a>
</span>
</h1>
<?php
echo "<h1>" . $this->name() . "<span class='version'>$VERSION";
$new_version = $_COOKIE["adminer_version"];
echo " <a href='https://www.adminer.org/#download'" . target_blank() . " id='version'>" . (version_compare($VERSION, $new_version) < 0 ? h($new_version) : "") . "</a>";
echo "</span></h1>\n";
// this is matched by compile.php
switch_lang();
if ($missing == "auth") {
@@ -1084,10 +1079,7 @@ class Adminer {
if (DB && $databases && !in_array(DB, $databases)) {
array_unshift($databases, DB);
}
?>
<form action="">
<p id="dbs">
<?php
echo "<form action=''>\n<p id='dbs'>\n";
hidden_fields_get();
$db_events = script("mixin(qsl('select'), {onmousedown: dbMouseDown, onchange: dbChange});");
echo "<span title='" . lang('Database') . "'>" . lang('DB') . ":</span> " . ($databases

View File

@@ -183,14 +183,11 @@ function page_messages($error) {
*/
function page_footer($missing = "") {
global $adminer;
?>
</div>
<div id="menu">
<?php $adminer->navigation($missing); ?>
</div>
<?php if ($missing != "auth") { ?>
echo "</div>\n\n<div id='menu'>\n";
$adminer->navigation($missing);
echo "</div>\n\n";
if ($missing != "auth") {
?>
<form action="" method="post">
<p class="logout">
<span><?php echo h($_GET["username"]) . "\n"; ?></span>
@@ -198,7 +195,7 @@ function page_footer($missing = "") {
<?php echo input_token(); ?>
</p>
</form>
<?php } ?>
<?php
}
echo script("setupSubmitHighlight(document);");
}

View File

@@ -326,14 +326,12 @@ function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = arra
$fields = array_values($fields);
$default_class = (($_POST ? $_POST["defaults"] : get_setting("defaults")) ? "" : " class='hidden'");
$comment_class = (($_POST ? $_POST["comments"] : get_setting("comments")) ? "" : " class='hidden'");
?>
<thead><tr>
<?php echo ($type == "PROCEDURE" ? "<td>" : ""); ?>
<th id="label-name"><?php echo ($type == "TABLE" ? lang('Column name') : lang('Parameter name')); ?>
<td id="label-type"><?php echo lang('Type'); ?><textarea id="enum-edit" rows="4" cols="12" wrap="off" style="display: none;"></textarea><?php echo script("qs('#enum-edit').onblur = editingLengthBlur;"); ?>
<td id="label-length"><?php echo lang('Length'); ?>
<td><?php
echo lang('Options'); // no label required, options have their own label
echo "<thead><tr>\n";
echo ($type == "PROCEDURE" ? "<td>" : "");
echo "<th id='label-name'>" . ($type == "TABLE" ? lang('Column name') : lang('Parameter name'));
echo "<td id='label-type'>" . lang('Type') . "<textarea id='enum-edit' rows='4' cols='12' wrap='off' style='display: none;'></textarea>" . script("qs('#enum-edit').onblur = editingLengthBlur;");
echo "<td id='label-length'>" . lang('Length');
echo "<td>" . lang('Options'); // no label required, options have their own label
if ($type == "TABLE") {
echo "<td id='label-null'>NULL\n";
echo "<td><input type='radio' name='auto_increment_col' value=''><abbr id='label-ai' title='" . lang('Auto Increment') . "'>AI</abbr>";

View File

@@ -520,10 +520,8 @@ function edit_form($table, $fields, $row, $update) {
if (isset($_GET["select"])) {
hidden_fields(array("check" => (array) $_POST["check"], "clone" => $_POST["clone"], "all" => $_POST["all"]));
}
?>
<input type="hidden" name="referer" value="<?php echo h(isset($_POST["referer"]) ? $_POST["referer"] : $_SERVER["HTTP_REFERER"]); ?>">
<input type="hidden" name="save" value="1">
<?php echo input_token(); ?>
</form>
<?php
echo "<input type='hidden' name='referer' value='" . h(isset($_POST["referer"]) ? $_POST["referer"] : $_SERVER["HTTP_REFERER"]) . "'>\n";
echo "<input type='hidden' name='save' value='1'>\n";
echo input_token();
echo "</form>\n";
}

View File

@@ -590,15 +590,10 @@ qsl('div').onclick = whisperClick;", "")
function navigation($missing) {
global $VERSION;
?>
<h1>
<?php echo $this->name(); ?>
<span class="version">
<?php echo $VERSION; ?>
<a href="https://www.adminer.org/editor/#download"<?php echo target_blank(); ?> id="version"><?php echo (version_compare($VERSION, $_COOKIE["adminer_version"]) < 0 ? h($_COOKIE["adminer_version"]) : ""); ?></a>
</span>
</h1>
<?php
echo "<h1>" . $this->name() . "<span class='version'>$VERSION";
$new_version = $_COOKIE["adminer_version"];
echo " <a href='https://www.adminer.org/editor/#download'" . target_blank() . " id='version'>" . (version_compare($VERSION, $new_version) < 0 ? h($new_version) : "") . "</a>";
echo "</span></h1>\n";
switch_lang();
if ($missing == "auth") {
$first = true;