Re work search.shtml and update CSS.

This commit is contained in:
Darren 'Tadgy' Austin 2024-09-04 20:02:35 +01:00
commit 51bad6e7e6
4 changed files with 32 additions and 23 deletions

View file

@ -121,6 +121,10 @@ td {
border: 1px; border: 1px;
border-color: #555555; border-color: #555555;
border-style: solid; border-style: solid;
margin-left: 5px;
padding-left: 5px;
padding-right: 5px;
vertical-align: middle;
width: 500px; width: 500px;
} }

View file

@ -121,6 +121,10 @@ td {
border: 1px; border: 1px;
border-color: #000000; border-color: #000000;
border-style: solid; border-style: solid;
margin-left: 5px;
padding-left: 5px;
padding-right: 5px;
vertical-align: middle;
width: 500px; width: 500px;
} }

View file

@ -3,21 +3,15 @@
/* Output an error box */ /* Output an error box */
function writeerror (string $message, bool $link) { function writeerror (string $message, bool $link) {
?> print ('<div class="box boxmargins" id="headingbox">');
<div class="box boxmargins" id="headingbox"> print (' <div id="headingtext">');
<div id="headingtext"> print (' <span class="heading bold">Search Error</span><br><br>');
<span class="heading bold">Search Error</span><br><br> print (' <span class="subheading">' . $message . '</span>');
<span class="subheading"><?php print ($message); ?></span>
<?php
if ($link == true) { if ($link == true) {
?> print (' <br><br>Click <a href="//' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . '" title="Retry search">here</a> to retry your search.');
<br><br>Click <a href="//<?php print ("$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"); ?>" title="Retry search">here</a> to retry your search.
<?php
} }
?> print (' </div>');
</div> print ('</div>');
</div>
<?php
} }
/* Construct the url */ /* Construct the url */
@ -27,15 +21,15 @@
$url = "http://"; $url = "http://";
} }
$url .= $_SERVER["HTTP_HOST"] . "/cgi-bin/searchapi.cgi?"; $url .= $_SERVER["HTTP_HOST"] . "/cgi-bin/searchapi.cgi?";
if (isset ($_GET[l])) { if (isset ($_GET["l"])) {
$url .= "l=" . urlencode ($_GET["l"]) . "&"; $url .= "l=" . urlencode ($_GET["l"]) . "&";
} }
if (isset ($_GET[p])) { if (isset ($_GET["p"])) {
$url .= "p=" . urlencode ($_GET["p"]) . "&"; $url .= "p=" . urlencode ($_GET["p"]) . "&";
} else { } else {
$url .= "p=%2F&"; $url .= "p=%2F&";
} }
if (isset ($_GET[q])) { if (isset ($_GET["q"])) {
$url .= "q=" . urlencode ($_GET["q"]); $url .= "q=" . urlencode ($_GET["q"]);
} else { } else {
$url .= "q="; $url .= "q=";
@ -57,10 +51,17 @@
Searches may contain multiple terms, include globs (<code>man 7 <a href="https://man7.org/linux/man-pages/man7/glob.7.html" title="glob man pageg">glob</a></code>)<br> Searches may contain multiple terms, include globs (<code>man 7 <a href="https://man7.org/linux/man-pages/man7/glob.7.html" title="glob man pageg">glob</a></code>)<br>
and descend down from the current directory.<br><br> and descend down from the current directory.<br><br>
<span class="bold">Adjust search:</span> <span class="bold">Adjust search:</span>
<div style="display: flex; justify-content: center;"> <!-- <div style="Xdisplay: flex; Xjustify-content: center;"> -->
<div>
<!-- <div style="text-align: right; justify-content: center;"> -->
<div style="text-align: right;"> <div style="text-align: right;">
<form action="/search"> <form action="/search">
<span class="bold">Search path:</span> <!-- <span class="bold" style="text-align: right; justify-content: center;">Search path:</span>
<input class="searchinput searchresultsinput" title="Search Path" type="text" name="p" value="<?php print ($_GET["p"]); ?>" autocomplete="on" required><br>
<span class="bold">Search query:</span>
<input class="searchinput searchresultsinput" title="Search Query" type="text" name="q" value="<?php print ($_GET["q"]); ?>" autocomplete="on" required>
<input type="submit" hidden> -->
<span class="bold" style="text-align: right;">Search path:</span>
<input class="searchinput searchresultsinput" title="Search Path" type="text" name="p" value="<?php print ($_GET["p"]); ?>" autocomplete="on" required><br> <input class="searchinput searchresultsinput" title="Search Path" type="text" name="p" value="<?php print ($_GET["p"]); ?>" autocomplete="on" required><br>
<span class="bold">Search query:</span> <span class="bold">Search query:</span>
<input class="searchinput searchresultsinput" title="Search Query" type="text" name="q" value="<?php print ($_GET["q"]); ?>" autocomplete="on" required> <input class="searchinput searchresultsinput" title="Search Query" type="text" name="q" value="<?php print ($_GET["q"]); ?>" autocomplete="on" required>
@ -83,10 +84,10 @@
$type = strtok ($result_line, " "); $type = strtok ($result_line, " ");
$entry = strtok ("\0"); $entry = strtok ("\0");
if ($type == "f" || $type == "l" || $type == "o") { if ($type == "f" || $type == "l" || $type == "o") {
print ("&bull; <a href=\"$entry\" title=\"View $entry\">$entry</a><br>"); print ('&bull; <a href="' . $entry . '" title="View $entry">' . $entry . '</a><br>');
$count++; $count++;
} elseif ($type == "d") { } elseif ($type == "d") {
print ("&bull; <a href=\"$entry\" title=\"Directory $entry\">$entry</a>&nbsp;(<a href=\"/search?l=$_GET[l]&p=$entry&q=" . urlencode ($_GET[q]) . "\" title=\"Repeat search in this directory\">Repeat search in this directory</a>)<br>"); print ('&bull; <a href="' . $entry . '" title="Directory ' . $entry . '">' . $entry . '</a>&nbsp;(<a href="/search?l=' . $_GET["l"] . '&p=' . urlencode ($entry) . '&q=' . urlencode ($_GET["q"]) . '" title="Repeat search in this directory">Repeat search in this directory</a>)<br>');
$count++; $count++;
} }
} }
@ -95,9 +96,9 @@
if ($count == 0) { if ($count == 0) {
print ("No results - try to widen your search."); print ("No results - try to widen your search.");
} elseif ($count == 1) { } elseif ($count == 1) {
print ("1 result found."); print ("1 result shown.");
} else { } else {
print ($count . " results found."); print ($count . " results shown.");
} }
?> ?>
</code> </code>