123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- $string = "";
- if (isset($_POST["s"])) {
- $string = $_POST["s"];
- }
- ?>
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1" />
- <link rel="stylesheet" href="/style.css" />
- <title>Bloggings</title>
- </head>
- <body>
- <header>
- <h1>Bloggings</h1>
- <p>
- <a href="index.html">Home</a> | <a href="https://searx.wittamore.com" target="_blank">SearxNG</a>
- </p>
- <hr />
- </header>
- <h2>Search</h2>
- <form action="search.php" method="post">
- <input name="s" type="text">
- <input type="submit">
- </form>
- <!-- list start -->
- <?php if (!empty($string)) {
- echo "<h2>Results</h2>";
- echo 'Search terms: <b>"' . $string . '"</b>';
- echo "<h3>Static Pages</h3>";
- $dir = new RecursiveDirectoryIterator("./static");
- echo "<ul>";
- $i=0;
- foreach (new RecursiveIteratorIterator($dir) as $filename => $file) {
- if ($file != "." && $file != "..") {
- if (!is_dir($file)) {
- $content = file_get_contents($file->getPathname());
- if (strpos($content, $string) !== false) {
- $i++;
- preg_match("/<h2>(.*?)<\/h2>/s", $content, $titre);
- $title = "?";
- if (isset($titre[1])) {
- $title = $titre[1];
- }
- echo '<li><a href="' . $file . '">' . $title . "</a></li>";
- }
- }
- }
- }
- if ($i == 0) echo "<i>No match</i>";
- echo "</ul>";
- echo "<h3>Articles</h3>";
- $dir = new RecursiveDirectoryIterator("./articles");
- echo "<ul>";
- $i=0;
- foreach (new RecursiveIteratorIterator($dir) as $filename => $file) {
- if ($file != "." && $file != "..") {
- if (!is_dir($file)) {
- $content = file_get_contents($file->getPathname());
- if (strpos($content, $string) !== false) {
- $i++;
- preg_match("/<h2>(.*?)<\/h2>/s", $content, $titre);
- $title = "?";
- if (isset($titre[1])) {
- $title = $titre[1];
- }
- echo '<li><a href="' . $file . '">' . $title . "</a></li>";
- }
- }
- }
- }
- if ($i == 0) echo "<i>No match</i>";
- echo "</ul>";
- } ?>
- <!-- list end -->
- <p> </p>
- <hr />
- <center>
- <h5>A minimalist blog by <a href="mailto:%70%68%69%6C%69%70%40%77%69%74%74%61%6D%6F%72%65%2E%63%6F%6D">Philip Wittamore</a></h5>
- </center>
- </body>
- </html>
|