Start using the new HTML5/CSS code.

This commit is contained in:
Darren 'Tadgy' Austin 2024-08-10 23:10:01 +01:00
commit c23c0987af
30 changed files with 1023 additions and 1637 deletions

View file

@ -3,114 +3,117 @@
/* Output an error box */
function writeerror (string $message, bool $link) {
print ("<center>");
print (" <table class=\"header\" align=\"center\">");
print (" <tr>");
print (" <td align=\"center\">");
print (" <b class=\"subheading\">$message</b>");
?>
<div class="box boxmargins" id="headingbox">
<div id="headingtext">
<span class="heading bold">Search Error</span><br><br>
<span class="subheading"><?php print ($message); ?></span>
<?php
if ($link == true) {
printf (" <br>Click <a href=\"https://$_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 (" </td>");
print (" </tr>");
print (" </table>");
print ("</center>");
print ("<br>");
?>
</div>
</div>
<?php
}
/* Construct the url */
$url = "https://slackware.uk/cgi-bin/searchapi.cgi?";
if (isset ($_SERVER["HTTPS"])) {
$url = "https://";
} else {
$url = "http://";
}
$url .= $_SERVER["HTTP_HOST"] . "/cgi-bin/searchapi.cgi?";
if (isset ($_GET[l])) {
$url = $url . "l=$_GET[l]&";
$url .= "l=" . urlencode ($_GET["l"]) . "&";
}
if (isset ($_GET[p])) {
$url = $url . "p=$_GET[p]&";
$url .= "p=" . urlencode ($_GET["p"]) . "&";
} else {
$url = $url . "p=/&";
$url .= "p=%2F&";
}
if (isset ($_GET[q])) {
$url = $url . "q=" . str_replace (" ", "+", $_GET[q]);
$url .= "q=" . urlencode ($_GET["q"]);
} else {
$url = $url . "q=";
$url .= "q=";
}
/* Query the search API */
if ($fh = fopen ($url, "r")) {
/* Read and extract the status number */
$status_line = stream_get_line ($fh, 0, "\n");
$status_line = stream_get_line ($fh, 0, "\0");
$status = explode (":", $status_line);
/* Process the status code and output content */
if ($status[1] == "0") {
?>
<center>
<table class="header" align="center">
<tr>
<td align="center">
<b class="heading">Search Results</b><br><br>
<b class="subheading">Search query: <?php print ($_GET["q"]) ?></b><br>
Searches may contain multiple terms, include (basic) globs,<br>
and descend down from the current directory.
</td>
</tr>
</table>
</center>
<table width="90%" align="center" cellspacing="15">
<tr>
<td class="search" align="right" valign="center">
<div class="box boxmargins" id="headingbox">
<div id="headingtext">
<span class="heading bold">Search Results</span><br>
<div class="subheading">
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>
<span class="bold">Adjust search:</span>
<div style="display: flex; justify-content: center;">
<div style="text-align: right;">
<form action="/search">
<input type="hidden" name="p" value="<?php print ($_GET["p"]) ?>">
<input class="searchinput" title="Search" alt="Search Box" type="text" name="q" value="<?php print ($_GET["q"]) ?>" autocomplete="on" required>
<span class="bold">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>
</form>
</td>
<td width="100%">
<!-- This cell is intentionally empty -->
</td>
<td class="search" align="left" valign="center">
<a href="/html/toggletheme.php" title="Toggle Theme" alt="Toggle Theme"><img src="/html/toggletheme.png" title="Toggle Theme" alt="Toggle Theme"></a>
</td>
</tr>
<tr>
<td class="searchresults" colspan="3">
<hr>
<code>
</div>
</div>
</div>
</div>
</div>
<br>
<div class="box boxmargins boxpadding" id="searchresultsbox">
<hr>
<code>
<?php
/* Read the results and turn into urls */
$count = 0;
while ($result_line = stream_get_line ($fh, 0, "\n")) {
/* Read the results and turn them into urls */
while ($result_line = stream_get_line ($fh, 0, "\0")) {
$type = strtok ($result_line, " ");
$entry = strtok ("\n");
$entry = strtok ("\0");
if ($type == "f" || $type == "l" || $type == "o") {
print ("&bull; <a href=\"$entry\" title=\"View $entry\">$entry</a><br>");
$count++;
} elseif ($type == "d") {
print ("&bull; <a href=\"$entry\" title=\"Directory $entry\">$entry</a>&nbsp;(<a href=\"/search?l=$_GET[l]&p=$entry&q=" . str_replace (" ", "+", $_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=$entry&q=" . urlencode ($_GET[q]) . "\" title=\"Repeat search in this directory\">Repeat search in this directory</a>)<br>");
$count++;
}
}
/* Output a total */
if ($count == 0) {
print (" No results - try to widen your search.");
print ("No results - try to widen your search.");
} elseif ($count == 1) {
print (" " . $count . " result found.");
print ("1 result found.");
} else {
print (" " . $count . " results found.");
print ($count . " results found.");
}
?>
</code>
<hr>
</td>
</tr>
</table>
</code>
<hr>
</div>
<?php
} else {
/* The status line indicates an error */
$error_line = stream_get_line ($fh, 0, "\n");
$error_line = stream_get_line ($fh, 0, "\0");
$error = explode (":", $error_line);
if ($status[1] == 1) {
writeerror ($error[1], true);
} elseif ($status[1] == 2) {
writeerror ($error[1], false);
} else {
writeerror ("An unexpected error occured", false);
writeerror ("An unexpected error occured!", false);
}
}
} else {