Search For:

Back to the Blog

This search looks only in the entries of the Nothing Happens At Ten Blog. If you want to search the internet, you should use Google or Bing or Yahoo! or whatever search engine you like.

Enter a search string and click on the button. The search is not case sensitive.

Results of your search.

* - * . entries.php */ // Get the string to search for from the form that posted this file $searchString = $_POST['pattern']; // Set the name of the archive directory $archiveDirName = 'archives'; // The path to the year directory $pathToYearDir; // The path to the month directory $pathToMonthDir; // The array of root names to archived blogs // Each time a new yearly blog is archived, add the name // of the year folder to this array to include it in the search // e.g. array("./", "./arch2009/"); $rootDirs = array("./", "./arch2009/"); // Qualified archive dir $archiveDirLooper; // Loop through all the root folders in the array foreach ($rootDirs as $rootDir) { $archiveDirLooper = $rootDir . $archiveDirName; // echo "

archiveDirLooper = " . $archiveDirLooper . "

"; // open the archive directory if ($archiveDirHandle = opendir($archiveDirLooper)) { // Loop through all of the files in the archive directory while (false !== ($yearDirName = readdir($archiveDirHandle))) { // The files in the archives directory // should be year directories, but check. // Skip over the parent directories // echo "

yearDirName = " . $yearDirName . "

"; if($yearDirName == ".") continue; if($yearDirName == "..") continue; $pathToYearDir = $archiveDirLooper . "/" . $yearDirName; // echo "

pathToYearDir = " . $pathToYearDir . "

"; // Check to see if this is a directory. if(is_dir($pathToYearDir)) { // We have a directory which is not a parent directory. // Assume it is a year directory. // Open the year directory $yearDirNameHandle = opendir($pathToYearDir); // All of the files in the year directory // should be month directories, but check while(false !== ($monthDirName = readdir($yearDirNameHandle))) { // echo "

monthDirName = " . $monthDirName . "

"; // Skip over the parent directories if($monthDirName == ".") continue; if($monthDirName == "..") continue; // Check to see if this is a directory. $pathToMonthDir = $archiveDirLooper . "/" . $yearDirName . "/" . $monthDirName; // echo "

pathToMonthDir = " . $pathToMonthDir . "

"; if(is_dir($pathToMonthDir)) { // The files in the month directory that we are interested in // are all .php files since those are the // entries in the blog $monthDirNameHandle = opendir($pathToMonthDir); while(false !== ($entry = readdir($monthDirNameHandle))) { // Skip over the parent directories if($entry == ".") continue; if($entry == "..") continue; // Look only for the proper file types $suffix = substr($entry, -4); if(($suffix == '.php') || ($suffix == 'html')) { // Read in the file into one string $entryString = file_get_contents($pathToMonthDir . "/" . $entry); // Remove the tags. We aren't interested in searching tags $tagFreeEntryText = strip_tags($entryString); /* $tagPattern = '/<.*>/'; $replaceString = ' '; $tagFreeEntryText = preg_replace($tagPattern, $replaceString, $entryString); */ // Look for the pattern, case insensitive in the tag free string $found = stripos($tagFreeEntryText, $searchString); // If the pattern is found, print out a link to the page. if($found != false) { $startPoint = $found - 100; if($startPoint < 0) { $startPoint = 0; } $endPoint = $found + 100; if($endPoint >= strlen($tagFreeEntryText)) { $endPoint = strlen($tagFreeEntryText) - 1; } $contextString = substr($tagFreeEntryText, $startPoint, $endPoint - $startPoint); echo "

\n"; echo $contextString . "
\n"; // Print a link to the path so that the web page // will have a fully qualified URL to the selected // pages. $urlToEntry = $pathToMonthDir . "/" . $entry; echo "\n"; echo $urlToEntry; echo "\n"; echo "

\n"; } } } closedir($monthDirNameHandle); } } closedir($yearDirNameHandle); } } } closedir($archiveDirHandle); } // end of loop over root folders unset($rootDir); ?>