This blob has been accessed 318 times via Git panel.
- <?php
- session_start();
- header("Cache-control: private");
- ?>
- <title>Dig!</title>
- <style>
- body
- {
- color: #666666;
- margin: 10px;
- padding: 0px;
- text-align: left;
- font-family: verdana, helvetica, sans-serif;
- background-color: #FFFFFF;
- }
- p
- {
- font-size: 11px;
- }
- a
- {
- font-weight: bold;
- text-decoration: none;
- }
- a:link, a:visited
- {
- color: #666666;
- }
- a:hover
- {
- color: #336699;
- }
- a:active {
- color: #336699;
- }
- </style>
- <?php
- $username_file = 'data/username.txt';
- if (!isset($_REQUEST['search'])) {
- }
- if (empty($_REQUEST['search'])) {
- echo "<p>Search string required. Click <a href=index.php>here</a> to go to the index page.</p>";
- }
- $search = trim(strip_tags(strtolower($_REQUEST['search'])));
- $google = str_replace(" ", "+", $search);
- echo "<p>Search string must be composed of 3 or more characters. Click <a href=index.php>here</a> to go to the index page.</p>";
- }
- $dir = "data/items";
- if ($dh_search_items = opendir($dir)) {
- while (($entry_search_items = readdir($dh_search_items)) !== false) {
- $cat_dir = file_get_contents("data/items/$entry_search_items/category.txt");
- if (file_exists("data/categories/$cat_dir/private.txt") and !file_exists("data/items/$entry_search_items/cat.txt") and (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $login_username))) {
- continue;
- }
- if (file_exists("data/items/$entry_search_items/private.txt") and (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $login_username))) {
- continue;
- }
- if ($entry_search_items != "." && $entry_search_items != "..") {
- $total_entries[] = $entry_search_items;
- }
- if ($entry_search_items != "." && $entry_search_items != ".." && fnmatch("*", $entry_search_items) && (preg_match("/\b$search\b/i", file_get_contents("data/items/$entry_search_items/title.txt")) or preg_match("/\b$search\b/i", file_get_contents("data/items/$entry_search_items/body.txt")))) {
- $show_search_items[] = $entry_search_items;
- }
- }
- closedir($dh_search_items);
- }
- rsort($show_search_items);
- reset($show_search_items);
- $count_search_items = count($show_search_items);
- reset($total_entries);
- $count_total_items = count($total_entries);
- if (($count_search_items > 0) and ($count_total_items > 0)) {
- echo "<p>Found <b>$search</b> in $count_search_items out of $count_total_items ";
- if ($count_total_items == 1) {
- echo "entry";
- }
- if ($count_total_items > 1) {
- echo "entries";
- }
- echo ".</p>";
- $increment_search_entries = 0;
- while ($increment_search_entries <= ($count_search_items - 1)) {
- $link = "http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/index.php?entry=$show_search_items[$increment_search_entries]";
- $fix_link = array('//index.php', '///index.php');
- $link = str_replace($fix_link, '/index.php', $link);
- $link = trim($link);
- echo "<p><a href=$link>";
- readfile("data/items/$show_search_items[$increment_search_entries]/title.txt");
- echo "</a><br>";
- readfile("data/items/$show_search_items[$increment_search_entries]/date.txt");
- echo "<br>";
- $body = file_get_contents("data/items/$show_search_items[$increment_search_entries]/body.txt");
- $body = strip_tags($body);
- $body = trim($body);
- // comment out next line for _long_ quote
- $body = str_replace(".","<br />", $body);
- $body = nl2br($body);
- $body = explode("<br />", $body);
- foreach ($body as $line) {
- if (preg_match("/\b$search\b/i", $line)) {
- $line = str_replace($search, "<span style=\"background-color: #ffff00;\">$search</span>", $line);
- $ucfirst_line = ucfirst($search);
- $line = str_replace($ucfirst_line, "<span style=\"background-color: #ffff00;\">$ucfirst_line</span>", $line);
- $strtoupper_line = strtoupper($search);
- $line = str_replace($strtoupper_line, "<span style=\"background-color: #ffff00;\">$strtoupper_line</span>", $line);
- $ucwords_line = ucwords($search);
- $line = str_replace($ucwords_line, "<span style=\"background-color: #ffff00;\">$ucwords_line</span>", $line);
- echo "$line ...<br>";
- }
- }
- echo str_replace("http://","",$link);
- $size = filesize("data/items/$show_search_items[$increment_search_entries]/body.txt");
- echo " - $size_string";
- echo "</p>";
- $increment_search_entries = $increment_search_entries + 1;
- }
- echo "<p>Click <a href=http://google.com/search?q=$google rel=nofollow target=_maj>here</a> to search for <b>$search</b> with Google.<br>Click <a href=index.php>here</a> to go to the index page.</p>";
- }
- else {
- echo "<p>Search string not found in $count_total_items ";
- if ($count_total_items == 1) {
- echo "entry";
- }
- if ($count_total_items > 1) {
- echo "entries";
- }
- echo ".<br>Click <a href=http://google.com/search?q=$google rel=nofollow target=_maj>here</a> to search for <b>$search</b> with Google.<br>Click <a href=index.php>here</a> to go to the index page.</p>";
- }
- ?>