1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-16 19:44:00 +02:00

Add helper for <input type=hidden name=token>

This commit is contained in:
Jakub Vrana
2025-03-17 18:45:08 +01:00
parent 91f9980267
commit e1f0fded69
23 changed files with 35 additions and 26 deletions

View File

@@ -84,7 +84,7 @@ if (
. "</div></div>\n"
: ""
);
echo "<input type='hidden' name='token' value='$token'>\n";
echo input_token();
echo "</form>\n";
echo script("tableCheck();");
}

View File

@@ -182,7 +182,7 @@ function page_messages($error) {
* @return null
*/
function page_footer($missing = "") {
global $adminer, $token;
global $adminer;
?>
</div>
@@ -195,7 +195,7 @@ function page_footer($missing = "") {
<p class="logout">
<span><?php echo h($_GET["username"]) . "\n"; ?></span>
<input type="submit" name="logout" value="<?php echo lang('Logout'); ?>" id="logout">
<input type="hidden" name="token" value="<?php echo $token; ?>">
<?php echo input_token(); ?>
</p>
</form>
<?php } ?>

View File

@@ -25,6 +25,15 @@ function nonce() {
return ' nonce="' . get_nonce() . '"';
}
/** Get <input type="hidden" name="token">
* @param string token to use instead of global $token
* @return string HTML
*/
function input_token($special = "") {
global $token;
return "<input type='hidden' name='token' value='" . ($special ?: $token) . "'>\n";
}
/** Get a target="_blank" attribute
* @return string
*/
@@ -414,7 +423,7 @@ function on_help($command, $side = 0) {
* @return null
*/
function edit_form($table, $fields, $row, $update) {
global $adminer, $token, $error;
global $adminer, $error;
$table_name = $adminer->tableName(table_status1($table, true));
page_header(
($update ? lang('Edit') : lang('Insert')),
@@ -514,7 +523,7 @@ function edit_form($table, $fields, $row, $update) {
?>
<input type="hidden" name="referer" value="<?php echo h(isset($_POST["referer"]) ? $_POST["referer"] : $_SERVER["HTTP_REFERER"]); ?>">
<input type="hidden" name="save" value="1">
<input type="hidden" name="token" value="<?php echo $token; ?>">
<?php echo input_token(); ?>
</form>
<?php
}

View File

@@ -95,7 +95,7 @@ function switch_lang() {
echo "<form action='' method='post'>\n<div id='lang'>";
echo lang('Language') . ": " . html_select("lang", $langs, $LANG, "this.form.submit();");
echo " <input type='submit' value='" . lang('Use') . "' class='hidden'>\n";
echo "<input type='hidden' name='token' value='" . get_token() . "'>\n"; // $token may be empty in auth.inc.php
echo input_token(get_token()); // $token may be empty in auth.inc.php
echo "</div>\n</form>\n";
}