* * $Id: search.php,v 1.7 2001/02/06 19:28:39 haakon Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ include "../.sipsconfig.php"; include $config["sipssys"] ."/code/search.inc.php"; printTop("search"); if ($config["enablesearch"] == 1) { ?>

Search

" .str_replace("_", " ", ucfirst($cats[$i])) .""; } else { $ca = ""; for ($a=0; $a<=$i; $a++) { $ca = $ca .$cats[$a] ."."; } $p = $p ."" .ucfirst(str_replace("_", " ", $cats[$i])) ." / "; } } print("Path: " .$p); // PRINTING ANY SUBCATEGORIES: $hascats = false; $handle=opendir($config["sipssys"] ."/sites"); while ($file = readdir($handle)) { if (($file != ".") && ($file != "..")) { if (substr($file, 0, strlen($category)) == $category) { // if this category is a subcategory of the current... $subcat = substr($file, strlen($category)+1); // extracts the remainder of the category when the current is removed if ((!strpos($subcat, ".")) && ($file != $category)) { // if this is a direct subcategory (and not the current)... $c = ucfirst(substr(strrchr($file, "."),1)); // extracts the utmost category and capitalizes it $subcats = $subcats ."" .$c ." (" .count(file($config["sipssys"] ."/sites/$file")) ."), "; $hascats = true; } } } } closedir($handle); if (strlen($subcats) > 1) { print("

" .i18n("Category hits") ."

\n
" .substr($subcats, 0, strlen($subcats)-2) ."
"); } // PRINTING LINKS IN THIS CATEGORY $links = getLinksInCategory($category); $nohits = count($links); if ($nohits>1) { print("

Site hits

"); print(""); for($i=0; $i\n"); } print("
" .$links[$i]["Title"] ."
\n" .$links[$i]["Desc"] ."
"); } else { if (!$hascats) { // we have no subcategories and no links in this category... print("

This category appears to be empty at the moment, sorry."); } } print("

" .i18n("Submit a site to this category!") ."

"); } else { print("

" .i18n("There's no such category.")); } } else if(isset($text)) { // We are searching free text! if ($text == "") { print(i18n("You left the search field empty!")); } else { $cathits = searchCategoriesFor($text); $linkhits = searchLinksFor($text); if (!$cathits) { // I found no better way at the moment.. suggestions? :) } else { print("

" .i18n("Category hits") ."

"); print(""); for($i=0; $i\n"); } print("
   " .ucfirst(str_replace("_", " ", str_replace(".", " / ", $cathits[$i]))) ."
"); } if (!$linkhits) { } else { print("

" .i18n("Site hits") ."

"); print(""); for($i=0; $i\n"); } print("
" .$linkhits[$i]["Title"] .""); $cats = explode(".", $linkhits[$i]["Cat"]); print(" (found in " .ucfirst(str_replace("_", " ", $cats[count($cats)-1])) .")"); print("
\n" .$linkhits[$i]["Desc"] ."
"); } if ((!$linkhits) && (!$cathits)) { print(i18n("I found nothing searching for #1#.", $text)); } } } ?>