ok и un po una spataffiata cmq..
pagina index.php, dove cи l'input x la ricerca
Codice PHP:
<?
<?
############################################################################
# WFSearch Engine by jID Version 0.7 (PHP4) (03.07.2002) #
# Copyright (C) jID, 2002 #
# #
# search module :: модуль поиска #
############################################################################
require ("config.php");
# Is filename suitable?
# Имя файла входит в фильтр?
function inlist($f)
{
global $allowed_names, $disallowed_names;
$n=0;
for ($i=0; $i<count($allowed_names); $i++)
if (strpos(strtolower($f),strtolower($allowed_names[$i]))) $n++;
for ($i=0; $i<count($disallowed_names); $i++)
if (strpos(strtolower($f),strtolower($disallowed_names[$i]))) $n=0;
return $n;
}
# Searching of $texi in file
# Поиск в файле строки $text
function queryfound($name, $text, $c)
{
global $explodestring;
$n=0;
$fc=file($name);
$s=implode($fc,$explodestring);
$s=strip_tags($s);
$fc=explode($explodestring,$s);
$t=explode(" ",$text);
if ($c=="or")
{
for ($i=0; $i<count($fc); $i++)
{
for ($j=0; $j<count($t); $j++)
{
if (strpos(" ".strtolower(strip_tags($fc[$i])), strtolower($t[$j]))) $n++;
}
}
} else
{
$nn=Array();
for ($i=0; $i<count($t); $i++)
array_push($nn,0);
for ($i=0; $i<count($fc); $i++)
for ($j=0; $j<count($t); $j++)
if (strpos(" ".strtolower(strip_tags($fc[$i])), strtolower($t[$j]))) $nn[$j]++;
for ($i=0; $i<count($t); $i++)
if ($nn[$i]>0) $n+=1;
if ($n==count($t)) $n/=count($nn); else $n=0;
}
return $n;
}
# Founded file processing
# Работа с найденным файлом
function process($f, $query, $m)
{
global $desc_header, $desc_footer, $real_loc, $all, $from,
$showed, $pages, $color1, $color2, $explodestring,
$color0, $interface_all, $lang_goto;
if (inlist($f))
if (!is_dir($f))
if (queryfound($f, $query, $m))
{
$all++;
if (($all>=$from)&&($showed<$pages))
{
if ((($showed>>1)<<1)==$showed)
echo "<tr><td bgcolor=$color1>"; else
echo "<tr><td bgcolor=$color2>";
echo str_replace("%1", $all, $interface_all);
echo $desc_header;
$fc=file($f);
$s=implode($fc,$explodestring);
$s=strip_tags($s);
$fc=explode($explodestring,$s);
$q=explode(" ",$query);
for ($i=0; $i<count($fc); $i++)
{
for ($j=0; $j<count($q); $j++)
{
if (strpos(" ".strtolower(strip_tags($fc[$i])), strtolower($q[$j])))
{
$t=strip_tags($fc[$i]);
$k=1;
do
{
$t=str_replace(strtolower($q[$j]), "[b]$q[$j][/b]", strtolower($t));
$k=strpos(strtolower($t), strtolower($q[$j]), $k+7);
}
while ($k==0);
echo "...$t...";
}
}
}
$showed++;
echo "<p align=right>[url=".str_replace($real_loc, "] $lang_goto > >[/url]</p>";
echo $desc_footer;
echo "</tr></td>";
}
}
}
# Counting of suitable files
# Подсчет (только подходящие файлы)
function counting($f, $query, $m)
{
global $all;
$n=0;
if (inlist($f))
if (!is_dir($f))
if (queryfound($f, $query, $m))
$n++;
$all+=$n;
}
# Counting
# Подсчет
function countdirs($q, $c)
{
$f="not empty value";
$dir=opendir(".");
$f=readdir($dir);
while ($f!="")
{
if (is_dir($f))
{
if (($f!=".") && ($f!=".."))
{
chdir($f);
countdirs($q, $c);
chdir("..");
}
}
$f=readdir($dir);
counting($f, $q, $c);
}
closedir($dir);
}
# Main search function
# Главная функция поиска
function alldirs($q, $c)
{
$f="not empty value";
$dir=opendir(".");
$f=readdir($dir);
while ($f!="")
{
if (is_dir($f))
{
if (($f!=".") && ($f!=".."))
{
chdir($f);
alldirs($q, $c);
chdir("..");
}
}
$f=readdir($dir);
process($f, $q, $c);
}
closedir($dir);
}
# ****************************> MAIN CODE <*********************************
$all=0;
$showed=0;
if (!isset($from)) $from=1;
if (!isset($query)) $query="";
$query=trim($query);
$query=strip_tags($query);
# Place Header
place_header();
if ((isset($query))&&($query!=""))
{
chdir($start_search);
countdirs($query, $m);
if ($all>0)
{
echo "<table width=96% align=center cellpadding=0 cellspacing=0><tr><td>
<center>".str_replace("%1", $all, $lang_wasfound)."
<table width=100% cellpadding=0 cellspacing=0><tr bgcolor=$color0><td align=center width=20%>";
for ($k=1; $k<=$all; $k+=$pages)
{
echo "<a href=$PHP_SELF?query=".urlencode($query)."&m=$m&from=$k>$k-";
if (($k+$pages)>$all) echo "$all </a>"; else echo ($k-1+$pages)." </a>";
if (!(($k+$pages)>$all)) echo $search_separator;
}
$all=0;
echo "</td></tr>";
alldirs($query, $m);
echo "<tr bgcolor=$color0><td align=center width=100%>";
for ($k=1; $k<=$all; $k+=$pages)
{
echo "<a href=$PHP_SELF?query=".urlencode($query)."&m=$m&from=$k>$k-";
if (($k+$pages)>$all) echo "$all </a>"; else echo ($k-1+$pages)." </a>";
if (!(($k+$pages)>$all)) echo $search_separator;
}
echo "
</center></table>";
} else echo "<center>$lang_nofiles</center><hr>";
} else
{
echo "<center>$lang_noquery</center><hr>";
}
# Place Footer
place_footer();
?>
pagina di config.php
Codice PHP:
<?
############################################################################
# WFSearch Engine by jID Version 0.7 (PHP4) (03.07.2002) #
# Copyright (C) jID, 2002 #
# #
# configuration file :: Файл конфигурации #
############################################################################
# Allowed files (if thoose strings are founded then allowed to search)
# Разрешенные файлы (если такая строка есть, то разрешено)
$allowed_names=Array(".html",".php",".pdf",".htm","portfolio");
# Disallowed files (if thoose strings are founded then disallowed to search)
# Запрещенные файлы (если такая строка есть, то запрещено)
$disallowed_names=Array("index.php","config.php","../.htaccess","../cgi-bin/formmail.pl","../cgi-bin/formmail.html","../error/.htaccess","../test");
# Selection of result description
# Выделение краткого описания
$desc_header="<font size=-1>";
$desc_footer="</font>";
# Page separator
# Разделитель страниц
$search_separator=" :: ";
# Style of numbers. This is "1)" style.
# Стиль чисел. Этот, например - "1)".
$interface_all="[b]<font color=black>%1)[/b]</font> ";
# Real location, for example: "www/sources.fatal.ru/html/" at UNIX,
# and "C:\\jid\\mysite" at Windows. Case sensitive!
# Реальное расположение (чтобы удалить эту строку), например:
# "www/sources.fatal.ru/html/" в среде UNIX, и "C:\\jid\\mysite"
# в среде Windows. Чувствительно к регистру!
$real_loc="http://wwww.pyrolog.ch/";
# Table colors
# Цвета вывода разноцветной таблички
$color0="#E4EBEF";
$color1="#F0F0F0";
$color2="#D0D0D0";
# This is unique string. Whis string needs to some tags clearing...
# С помощью этой строки производится некоторая очистка от тэгов...
# так что, если в ваших файлах может иметься такая строчка, то лучше
# замените здесь значение переменной на что-нибудб другое (уникальное)
$explodestring="**^!separate!^**";
# Location of start directory "." - current
# Расположение каталога начала поиска "." - текущий
$start_search="..";
# Results per page
# Кол-во результатов на страницу
$pages=5;
# Inderface language file (\language\ directory)
# Языковой файл интерфейса (каталог \language\)
$lang_pagetitle = "Search results for \"%1\"";
$lang_noquery = "Query string is not specifed.";
$lang_usingand = "Unsing \"and\"";
$lang_usingor = "Unsing \"or\"";
$lang_search = "Search";
$lang_goto = "GoTo";
$lang_wasfound = "There was found [b]%1[/b] file(s).";
$lang_nofiles = "There are no files found. Try another query string.";
# ****************************> HEADER <*********************************
function place_header()
{
global $query,
$lang_search,
$lang_pagetitle,
$lang_noquery,
$lang_usingand,
$lang_usingor;
?>
<html>
<title><?if (isset($query)) echo str_replace("%1", $query, $lang_pagetitle);else echo $lang_noquery;?></title>
<body bgcolor=#C0DED>
<form name=search method=get action=<?echo @$PHP_SELF;?>>
<input name=query length=40<?if (isset($query)) echo(" value=\"".$query."\"");?>><input type=submit value='<?echo $lang_search;?>'>
<input type=radio checked=true name=m value=and><?echo $lang_usingand;?>
<input type=radio name=m value=or><?echo $lang_usingor;?>
</input>
</form>
<hr>
<?
}
# ****************************> FOOTER <*********************************
function place_footer()
{
?>
<p align=right>[size="1"]Copyright (C) jID, 2002[/size]</p>
</body>
</html>
<?
}
?>
gli errori me li da alla riga 131 e 155 del file index.php (il primo postato) le quali righe dicono
135. chdir($f);
155. if (is_dir($f))
grazie mille, sarа tosta mi sa..