This blob has been accessed 377 times via Git panel.
- <?php
- require("core.php");
- ?>
- <title>Dig!</title>
- <style>
- body {
- color: #666666;
- margin: 10px;
- padding: 0px;
- text-align: left;
- font-family: <?php
- if (file_exists("$maj_data_directory/fonts/body.txt")) {
- $font_body = file_get_contents("$maj_data_directory/fonts/body.txt");
- echo "{$font_body},";
- }
- ?> arial, helvetica, sans-serif;
- background-color: #FFFFFF;
- }
- p, td {
- 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
- if (!isset($_POST['search'])) {
- }
- if (empty($_POST['search'])) {
- echo "<p>Search string required. Click <a href=\"index.php\">here</a> to go to the index page.</p>";
- }
- $search = trim(strip_tags(mb_strtolower($_POST['search'])));
- $google = str_replace(" ", "+", $search);
- if (mb_strlen($search) < 3) {
- 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>";
- }
- if (file_exists("$maj_data_directory/bb.txt") and file_exists("$maj_data_directory/members/active") and ($dh_search_members = opendir("$maj_data_directory/members/active"))) {
- $start_time_member = round(microtime(), 3);
- while (($entry_search_members = readdir($dh_search_members)) !== false) {
- if ($entry_search_members != "." && $entry_search_members != "..") {
- $total_members[] = $entry_search_members;
- }
- if ($entry_search_members != "." && $entry_search_members != ".." && (preg_match("/\b$search\b/i", file_get_contents("$maj_data_directory/members/active/$entry_search_members/firstname.txt")) or preg_match("/\b$search\b/i", file_get_contents("$maj_data_directory/members/active/$entry_search_members/lastname.txt")) or preg_match("/\b$search\b/i", file_get_contents("$maj_data_directory/members/active/$entry_search_members/rank.txt")) or ($search == $entry_search_members))) {
- $show_search_members[] = $entry_search_members;
- }
- }
- $stop_time_member = round(microtime(), 3);
- $generation_time_member = $stop_time_member - $start_time_member;
- $generation_time_member = str_replace("-","",$generation_time_member);
- $show_search_members = array_unique($show_search_members);
- $show_search_members = array_values($show_search_members);
- sort($show_search_members);
- $count_search_members = count($show_search_members);
- $count_total_members = count($total_members);
- if ($count_search_members > 0) {
- echo "<p>Found <b>$search</b> in $count_search_members out of $count_total_members ";
- if ($count_total_members == 1) {
- echo "member";
- }
- if ($count_total_members > 1) {
- echo "members";
- }
- echo " ($generation_time_member seconds).</p>";
- $search_ucfirst = ucfirst($search);
- $search_ucwords = ucwords($search);
- $search_strtoupper = mb_strtoupper($search);
- foreach ($show_search_members as $match_member) {
- $match_member_firstname = file_get_contents("$maj_data_directory/members/active/$match_member/firstname.txt");
- $match_member_firstname = str_replace($search, "<span style=\"background-color: #ffff00;\">$search</span>", $match_member_firstname);
- $match_member_firstname = str_replace($search_ucfirst, "<span style=\"background-color: #ffff00;\">$search_ucfirst</span>", $match_member_firstname);
- $match_member_firstname = str_replace($search_ucwords, "<span style=\"background-color: #ffff00;\">$search_ucwords</span>", $match_member_firstname);
- $match_member_firstname = str_replace($search_strtoupper, "<span style=\"background-color: #ffff00;\">$search_strtoupper</span>", $match_member_firstname);
- $match_member_lastname = file_get_contents("$maj_data_directory/members/active/$match_member/lastname.txt");
- $match_member_lastname = str_replace($search, "<span style=\"background-color: #ffff00;\">$search</span>", $match_member_lastname);
- $match_member_lastname = str_replace($search_ucfirst, "<span style=\"background-color: #ffff00;\">$search_ucfirst</span>", $match_member_lastname);
- $match_member_lastname = str_replace($search_ucwords, "<span style=\"background-color: #ffff00;\">$search_ucwords</span>", $match_member_lastname);
- $match_member_lastname = str_replace($search_strtoupper, "<span style=\"background-color: #ffff00;\">$search_strtoupper</span>", $match_member_lastname);
- $match_member_link = "http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/member.php?id={$match_member}";
- $match_member_link_fix = array('//member.php', '///member.php');
- $match_member_link = str_replace($match_member_link_fix, '/member.php', $match_member_link);
- $match_member_link = trim($match_member_link);
- echo "<p><a href=member.php?id={$match_member}>$match_member</a><br>{$match_member_firstname} {$match_member_lastname}<br>$match_member_link</p>";
- }
- }
- }
- if ($dh_search_items = opendir("$maj_data_directory/items")) {
- $start_time_item = round(microtime(), 3);
- while (($entry_search_items = readdir($dh_search_items)) !== false) {
- if (($entry_search_items > $today) and (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $maj_admin_username))) {
- continue;
- }
- $private = "0";
- if (file_exists("$maj_data_directory/items/$entry_search_items/categories")) {
- if ($dh_cat_dig = opendir("$maj_data_directory/items/$entry_search_items/categories")) {
- while (($entry_cat_dig = readdir($dh_cat_dig)) !== false) {
- if ($entry_cat_dig != "." && $entry_cat_dig != "..") {
- if (file_exists("$maj_data_directory/categories/$entry_cat_dig/private.txt") and (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $maj_admin_username))) {
- $private = $private + 1;
- }
- }
- }
- closedir($dh_cat_dig);
- }
- }
- if (($private > 0) and !file_exists("$maj_data_directory/items/$entry_search_items/cat.txt")) {
- continue;
- }
- if (file_exists("$maj_data_directory/items/$entry_search_items/private.txt") and (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $maj_admin_username))) {
- continue;
- }
- if (file_exists("$maj_data_directory/items/$entry_search_items/passwd.txt") and (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $maj_admin_username))) {
- continue;
- }
- if (file_exists("$maj_data_directory/items/$entry_search_items/member.txt") and !isset($_SESSION['logged_in'])) {
- continue;
- }
- if ($entry_search_items != "." && $entry_search_items != "..") {
- $total_entries[] = $entry_search_items;
- }
- if ($entry_search_items != "." && $entry_search_items != ".." && (preg_match("/\b$search\b/i", file_get_contents("$maj_data_directory/items/$entry_search_items/title.txt")) or preg_match("/\b$search\b/i", file_get_contents("$maj_data_directory/items/$entry_search_items/body.txt")))) {
- $show_search_items[] = $entry_search_items;
- }
- if ($entry_search_items != "." && $entry_search_items != ".." && file_exists("$maj_data_directory/items/$entry_search_items/comments/live")) {
- if ($dh_comment_items = opendir("$maj_data_directory/items/$entry_search_items/comments/live")) {
- while (($entry_comment_items = readdir($dh_comment_items)) !== false) {
- if ($entry_comment_items != "." && $entry_comment_items != "..") {
- $total_comments[] = $entry_comment_items;
- }
- if ($entry_comment_items != "." && $entry_comment_items != ".." && preg_match("/\b$search\b/i", file_get_contents("$maj_data_directory/items/$entry_search_items/comments/live/$entry_comment_items/comment.txt"))) {
- $show_search_items[] = $entry_search_items;
- }
- }
- }
- }
- }
- closedir($dh_search_items);
- }
- $stop_time_item = round(microtime(), 3);
- $generation_time_item = $stop_time_item - $start_time_item;
- $generation_time_item = str_replace("-","",$generation_time_item);
- $show_search_items = array_unique($show_search_items);
- $show_search_items = array_values($show_search_items);
- rsort($show_search_items);
- $count_search_items = count($show_search_items);
- $count_total_comments = count($total_comments);
- $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";
- }
- if ($count_total_comments > 0) {
- echo " and $count_total_comments ";
- if ($count_total_comments == 1) {
- echo "comment";
- }
- if ($count_total_comments > 1) {
- echo "comments";
- }
- }
- echo " ($generation_time_item seconds).</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";
- if (file_exists("$maj_data_directory/items/$show_search_items[$increment_search_entries]/comments/live") and !preg_match("/\b$search\b/i",file_get_contents("$maj_data_directory/items/$show_search_items[$increment_search_entries]/title.txt")) and !preg_match("/\b$search\b/i",file_get_contents("$maj_data_directory/items/$show_search_items[$increment_search_entries]/body.txt"))) {
- echo "&show=comments";
- }
- echo ">";
- readfile("$maj_data_directory/items/$show_search_items[$increment_search_entries]/title.txt");
- echo "</a><br>";
- entry2date($show_search_items[$increment_search_entries]);
- echo "<br>";
- $body = file_get_contents("$maj_data_directory/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);
- if (file_exists("$maj_data_directory/pf.txt") and file_exists("$maj_data_directory/pf-badwords.txt")) {
- $badwords = file_get_contents("$maj_data_directory/pf-badwords.txt");
- if (file_exists("$maj_data_directory/pf-censor.txt")) {
- $censor = file_get_contents("$maj_data_directory/pf-censor.txt");
- }
- else {
- $censor = "[expletive]";
- }
- $body = preg_replace("/\b($badwords)\b/i",$censor,$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 = mb_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("$maj_data_directory/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 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";
- }
- if ($count_total_comments > 0) {
- echo " and $count_total_comments ";
- if ($count_total_comments == 1) {
- echo "comment";
- }
- if ($count_total_comments > 1) {
- echo "comments";
- }
- }
- echo " ($generation_time_item seconds).<br><br>Click <a href=http://google.com/search?q=$google 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>";
- }
- ?>