Back out "use POST when building search results, see #1026"

Original commit changeset: c44822ec47
This commit is contained in:
Shish 2024-02-09 14:41:23 +00:00
parent 43e8ff3e3e
commit 062b6d3f4a
17 changed files with 32 additions and 22 deletions

View File

@ -741,7 +741,9 @@ function make_form(string $target, string $method = "POST", bool $multipart = fa
{
global $user;
if ($method == "GET") {
die("make_form: GET method is not supported");
$link = html_escape($target);
$target = make_link($target);
$extra_inputs = "<input type='hidden' name='q' value='$link'>";
} else {
$extra_inputs = $user->get_auth_html();
}

View File

@ -25,7 +25,7 @@ class AutoTaggerTheme extends Themelet
";
$bulk_html = "
".make_form(make_link("auto_tag/import"), 'POST', true)."
".make_form(make_link("auto_tag/import"), 'post', true)."
<input type='file' name='auto_tag_file'>
<input type='submit' value='Upload List'>
</form>

View File

@ -101,7 +101,7 @@ class CommentListTheme extends Themelet
$html = '
Delete comments by IP.
<br><br>'.make_form(make_link("comment/bulk_delete"))."
<br><br>'.make_form(make_link("comment/bulk_delete"), 'POST')."
<table class='form'>
<tr><th>IP&nbsp;Address</th> <td><input type='text' name='ip' size='15'></td></tr>
<tr><td colspan='2'><input type='submit' value='Delete'></td></tr>

View File

@ -37,8 +37,9 @@ EOD
$contact_link = empty($contact_link) ? "" : "<br><a href='$contact_link'>Contact</a> &ndash;";
$search_html = "
<div class='space' id='search'>
<form action='".search_link()."' method='POST'>
<form action='".search_link()."' method='GET'>
<input name='search' size='30' type='search' value='' class='autocomplete_tags' autofocus='autofocus' />
<input type='hidden' name='q' value='/post/list'>
<input type='submit' value='Search'/>
</form>
</div>

View File

@ -28,9 +28,9 @@ class Index extends Extension
{
global $cache, $config, $page, $user;
if ($event->page_matches("post/list")) {
if (isset($_POST['search'])) {
if (isset($_GET['search'])) {
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(search_link(Tag::explode($_POST['search'], false)));
$page->set_redirect(search_link(Tag::explode($_GET['search'], false)));
return;
}

View File

@ -89,8 +89,9 @@ and of course start organising your images :-)
$h_search_string = html_escape(Tag::implode($search_terms));
$h_search_link = search_link();
$h_search = "
<p><form action='$h_search_link' method='POST'>
<p><form action='$h_search_link' method='GET'>
<input type='search' name='search' value='$h_search_string' placeholder='Search' class='autocomplete_tags' />
<input type='hidden' name='q' value='/post/list'>
<input type='submit' value='Find' style='display: none;' />
</form>
";

View File

@ -236,9 +236,9 @@ class Pools extends Extension
{
global $config, $database, $page, $user;
if ($event->page_matches("pool/list")) { //index
if (isset($_POST['search']) and $_POST['search'] != null) {
if (isset($_GET['search']) and $_GET['search'] != null) {
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link('pool/list').'/'.url_escape($_POST['search']).'/'.strval($event->try_page_num(1)));
$page->set_redirect(make_link('pool/list').'/'.$_GET['search'].'/'.strval($event->try_page_num(1)));
return;
}
if (count($event->args) >= 4) { // Assume first 2 args are search and page num

View File

@ -133,9 +133,10 @@ class PoolsTheme extends Themelet
SHM_A("pool/updated", "Pool Changes")
);
$search = "<form action='".make_link('pool/list')."' method='POST'>
$search = "<form action='".make_link('pool/list')."' method='GET'>
<input name='search' type='text' style='width:75%'>
<input type='submit' value='Go' style='width:20%'>
<input type='hidden' name='q' value='pool/list'>
</form>";
$page->add_block(new NavBlock());

View File

@ -14,15 +14,15 @@ class RandomList extends Extension
global $config, $page;
if ($event->page_matches("random")) {
if (isset($_POST['search'])) {
if (isset($_GET['search'])) {
// implode(explode()) to resolve aliases and sanitise
$search = url_escape(Tag::implode(Tag::explode($_POST['search'], false)));
$search = url_escape(Tag::implode(Tag::explode($_GET['search'], false)));
if (empty($search)) {
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("random"));
} else {
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link('random/'.url_escape($search)));
$page->set_redirect(make_link('random/'.$search));
}
return;
}

View File

@ -53,6 +53,7 @@ class RandomListTheme extends Themelet
$h_search = "
<p><form action='$h_search_link' method='GET'>
<input type='search' name='search' value='$h_search_string' placeholder='Search random list' class='autocomplete_tags' />
<input type='hidden' name='q' value='/random'>
<input type='submit' value='Find' style='display: none;' />
</form>
";

View File

@ -26,7 +26,7 @@ class ResizeImageTheme extends Themelet
}
$html = rawHTML("
".make_form(make_link("resize/{$image->id}"))."
".make_form(make_link("resize/{$image->id}"), 'POST')."
<input type='hidden' name='image_id' value='{$image->id}'>
<input id='original_width' name='original_width' type='hidden' value='{$image->width}'>
<input id='original_height' name='original_height' type='hidden' value='{$image->height}'>

View File

@ -66,7 +66,7 @@ class SourceHistoryTheme extends Themelet
Revert source changes by a specific IP address or username, optionally limited to recent changes.
'.$validation_msg.'
<br><br>'.make_form(make_link("source_history/bulk_revert"))."
<br><br>'.make_form(make_link("source_history/bulk_revert"), 'POST')."
<table class='form'>
<tr><th>Username</th> <td><input type='text' name='revert_name' size='15'></td></tr>
<tr><th>IP&nbsp;Address</th> <td><input type='text' name='revert_ip' size='15'></td></tr>

View File

@ -32,7 +32,7 @@ class TagEditTheme extends Themelet
public function mss_html(string $terms): string
{
$h_terms = html_escape($terms);
$html = make_form(make_link("tag_edit/mass_source_set")) . "
$html = make_form(make_link("tag_edit/mass_source_set"), "POST") . "
<input type='hidden' name='tags' value='$h_terms'>
<input type='text' name='source' value=''>
<input type='submit' value='Set Source For All' onclick='return confirm(\"This will mass-edit all sources on the page.\\nAre you sure you want to do this?\")'>

View File

@ -98,7 +98,8 @@ class ViewPostTheme extends Themelet
{
$h_pin = $this->build_pin($image);
$h_search = "
<p><form action='".search_link()."' method='POST'>
<p><form action='".make_link()."' method='GET'>
<input type='hidden' name='q' value='/post/list'>
<input type='search' name='search' placeholder='Search' class='autocomplete_tags'>
<input type='submit' value='Find' style='display: none;'>
</form>

View File

@ -47,10 +47,11 @@ class CustomIndexTheme extends IndexTheme
protected function build_navigation(int $page_number, int $total_pages, array $search_terms): string
{
$h_search_string = count($search_terms) == 0 ? "" : html_escape(implode(" ", $search_terms));
$h_search_link = search_link();
$h_search_link = make_link();
return "
<p><form action='$h_search_link' method='POST'>
<p><form action='$h_search_link' method='GET'>
<input name='search' type='text' value='$h_search_string' class='autocomplete_tags' placeholder='Search' />
<input type='hidden' name='q' value='/post/list'>
<input type='submit' value='Find' style='display: none;' />
</form>
<div id='search_completions'></div>";

View File

@ -31,11 +31,12 @@ class CustomIndexTheme extends IndexTheme
protected function build_navigation(int $page_number, int $total_pages, array $search_terms): string
{
$h_search_string = count($search_terms) == 0 ? "" : html_escape(implode(" ", $search_terms));
$h_search_link = search_link();
$h_search_link = make_link();
return "
<p><form action='$h_search_link' method='POST'>
<p><form action='$h_search_link' method='GET'>
<input name='search' type='text' value='$h_search_string' class='autocomplete_tags' placeholder='' style='width:75%'/>
<input type='submit' value='Go' style='width:20%'>
<input type='hidden' name='q' value='/post/list'>
</form>
<div id='search_completions'></div>";
}

View File

@ -71,9 +71,10 @@ class CustomViewPostTheme extends ViewPostTheme
{
//$h_pin = $this->build_pin($image);
$h_search = "
<form action='".search_link()."' method='POST'>
<form action='".make_link()."' method='GET'>
<input name='search' type='text' style='width:75%'>
<input type='submit' value='Go' style='width:20%'>
<input type='hidden' name='q' value='/post/list'>
</form>
";