This commit has been accessed 574 times via Git panel.
commit 83c0857532f73c40f29e16781fc663890cbfe8f3
tree 083625f0c6b117bd9d65267c764d4d4c1bdc314d
parent 33174264c2c425a1d4d7beda3210a15ca3002c71
author Engels Antonio <engels@majcms.org> 1277314191 +0800
committer Engels Antonio <engels@majcms.org> 1277314191 +0800
maj-0.14-20071115-bb.zip
diff --git a/dig.php b/dig.php
index e6693c0..3bd5f44 100644
--- a/dig.php
+++ b/dig.php
@@ -89,6 +89,8 @@ if (strlen($search) < 3) {
$dir = "data/items";
+$start_time = round(microtime(), 3);
+
if ($dh_search_items = opendir($dir)) {
while (($entry_search_items = readdir($dh_search_items)) !== false) {
@@ -114,13 +116,18 @@ if ($dh_search_items = opendir($dir)) {
$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")))) {
+ if ($entry_search_items != "." && $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;
}
- if ($entry_search_items != "." && $entry_search_items != ".." && fnmatch("*", $entry_search_items) && file_exists("data/items/$entry_search_items/comments/live")) {
+ if ($entry_search_items != "." && $entry_search_items != ".." && file_exists("data/items/$entry_search_items/comments/live")) {
if ($dh_comment_items = opendir("data/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("data/items/$entry_search_items/comments/live/$entry_comment_items/comment.txt"))) {
$show_search_items[] = $entry_search_items;
}
@@ -132,23 +139,47 @@ if ($dh_search_items = opendir($dir)) {
}
$show_search_items = array_unique($show_search_items);
+$show_search_items = array_values($show_search_items);
rsort($show_search_items);
+
reset($show_search_items);
$count_search_items = count($show_search_items);
+reset($count_total_comments);
+$count_total_comments = count($total_comments);
+
reset($total_entries);
$count_total_items = count($total_entries);
+$stop_time = round(microtime(), 3);
+
if (($count_search_items > 0) and ($count_total_items > 0)) {
+$generation_time = $stop_time - $start_time;
+
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>";
+
+ 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 seconds).</p>";
$increment_search_entries = 0;
@@ -157,7 +188,14 @@ if (($count_search_items > 0) and ($count_total_items > 0)) {
$fix_link = array('//index.php', '///index.php');
$link = str_replace($fix_link, '/index.php', $link);
$link = trim($link);
- echo "<p><a href=$link>";
+
+ echo "<p><a href=$link";
+
+ if (file_exists("data/items/$show_search_items[$increment_search_entries]/comments/live") and !preg_match("/\b$search\b/i",file_get_contents("data/items/$show_search_items[$increment_search_entries]/title.txt")) and !preg_match("/\b$search\b/i",file_get_contents("data/items/$show_search_items[$increment_search_entries]/body.txt"))) {
+ echo "&show=comments";
+ }
+
+ echo ">";
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");
tree 083625f0c6b117bd9d65267c764d4d4c1bdc314d
parent 33174264c2c425a1d4d7beda3210a15ca3002c71
author Engels Antonio <engels@majcms.org> 1277314191 +0800
committer Engels Antonio <engels@majcms.org> 1277314191 +0800
maj-0.14-20071115-bb.zip
diff --git a/dig.php b/dig.php
index e6693c0..3bd5f44 100644
--- a/dig.php
+++ b/dig.php
@@ -89,6 +89,8 @@ if (strlen($search) < 3) {
$dir = "data/items";
+$start_time = round(microtime(), 3);
+
if ($dh_search_items = opendir($dir)) {
while (($entry_search_items = readdir($dh_search_items)) !== false) {
@@ -114,13 +116,18 @@ if ($dh_search_items = opendir($dir)) {
$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")))) {
+ if ($entry_search_items != "." && $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;
}
- if ($entry_search_items != "." && $entry_search_items != ".." && fnmatch("*", $entry_search_items) && file_exists("data/items/$entry_search_items/comments/live")) {
+ if ($entry_search_items != "." && $entry_search_items != ".." && file_exists("data/items/$entry_search_items/comments/live")) {
if ($dh_comment_items = opendir("data/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("data/items/$entry_search_items/comments/live/$entry_comment_items/comment.txt"))) {
$show_search_items[] = $entry_search_items;
}
@@ -132,23 +139,47 @@ if ($dh_search_items = opendir($dir)) {
}
$show_search_items = array_unique($show_search_items);
+$show_search_items = array_values($show_search_items);
rsort($show_search_items);
+
reset($show_search_items);
$count_search_items = count($show_search_items);
+reset($count_total_comments);
+$count_total_comments = count($total_comments);
+
reset($total_entries);
$count_total_items = count($total_entries);
+$stop_time = round(microtime(), 3);
+
if (($count_search_items > 0) and ($count_total_items > 0)) {
+$generation_time = $stop_time - $start_time;
+
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>";
+
+ 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 seconds).</p>";
$increment_search_entries = 0;
@@ -157,7 +188,14 @@ if (($count_search_items > 0) and ($count_total_items > 0)) {
$fix_link = array('//index.php', '///index.php');
$link = str_replace($fix_link, '/index.php', $link);
$link = trim($link);
- echo "<p><a href=$link>";
+
+ echo "<p><a href=$link";
+
+ if (file_exists("data/items/$show_search_items[$increment_search_entries]/comments/live") and !preg_match("/\b$search\b/i",file_get_contents("data/items/$show_search_items[$increment_search_entries]/title.txt")) and !preg_match("/\b$search\b/i",file_get_contents("data/items/$show_search_items[$increment_search_entries]/body.txt"))) {
+ echo "&show=comments";
+ }
+
+ echo ">";
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");