<?php header('Content-Type: text/html; charset=windows-1251'); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<META http-equiv=Content-Type content="text/html; charset=windows-1251">
<title>Search form</title>
<script type="text/javascript">
devdate=new Date();
var y="";
// 
y=devdate.getFullYear()
var m="";
//
m=devdate.getMonth()+1
var c="";
//
c=devdate.getDate();
var d="";
//
d=devdate.getDay();
var dp=""
dp=y+"-"+m+"-"+c+"-"+d
dp1=c+"."+m+"."+y
</script>
<?php
function pe($f,$ech,$ech1,$poisk,$poisk1,$poisk2,$kkk)
{
$d=100;  // 
$d1=50;  // 
$sps1 = file($f);                  //
//echo $f."<br>"; 


foreach ($sps1 as $li1 => $lin1)   //
{
//echo $li1."<br>";
 if  (strstr($lin1,"<TABLE") or strstr($lin1,"<table")  )        //
 {
 $tst=str_replace("</TD>",'.</TD>',$lin1);
 $tst=str_replace("</td>",'.</td>',$tst);
 $tst=str_replace("</TH>",'.</TH>',$tst);
 $tst=str_replace("</th>",'.</th>',$tst);
 $tst=str_replace("</CAPTION>",'.</CAPTION>',$tst);
 $tst=str_replace("</caption>",'.</caption>',$tst);
 } 
 else
 {
$tst=$lin1;
 }
 $tst=strip_tags($tst);          // 
 $tst=str_replace("&#160;",'',$tst);
 $tst=str_replace("?",'?.',$tst);
 $tst=str_replace("!",'!.',$tst);
 $mp= explode(".",$tst);          // 
 $vix=false;
 foreach ($mp as $k => $z)          // 
 {$poz=strpos(" ".$z,$poisk);
  $poz1=0;
  $poz2=0;
  if ($poz>0)
  {if (strlen($z)>$d)    //
  {if ($poz<$d1) 
  {$zp=substr($z,0,$d);}
  else 
  {$zp=substr($z,$poz-$d1,$d);
  }}
  else   // 
  {
  $zp=$z;
  }
  $zp=str_replace($poisk,"<b style='background:yellow'>".$poisk."</b>",$zp);  //
  echo "<tr><td>".$kkk."</td><td>".$ech1.$ech.$zp."</td></tr>";$vix=true; break;}
  ///
  if ($poz==0)   // 
 {$poz1=strpos(" ".$z,$poisk1);
  if ($poz1>0)
  {if (strlen($zp)>$d) 
  {if ($poz1<$d1) 
  {$zp=substr($zp,0,$d1);}
  else 
  {$zp=substr($zp,$poz1-$d1,$d);}}
  $zp=str_replace($poisk1,"<b style='background:yellow'>".$poisk1."</b>",$z);
  //echo $f.$poisk."/1".$poisk1."/1".$poisk2."<br>";  
  echo "<tr><td>".$kkk."</td><td>".$ech1.$ech.$zp."</td></tr>";$vix=true; break;}
 }
 if ($poz==0 and $poz1==0)   // 
 {$poz2=strpos(" ".$z,$poisk2);
  if ($poz2>0)
  {if (strlen($zp)>$d) 
  {if ($poz2<$d1) 
  {$zp=substr($zp,0,$d1);}
  else 
  {$zp=substr($zp,$poz2-$d1,$d);}}
  $zp=str_replace($poisk2,"<b style='background:yellow'>".$poisk2."</b>",$z);
  //echo $f.$poisk."/2".$poisk1."/2".$poisk2."<br>";  
  echo "<tr><td>".$kkk."</td><td>".$ech1.$ech.$zp."</td></tr>";$vix=true; break;}
 }
 }  // 
 if ($vix) {return true;}
 }   //
if (!$vix) {return false;} 
}    //
?>
<HTML>
<?php
$kkk=1;
if (isset($_REQUEST['pois']))   // 
{$poisk=$_REQUEST['pois'];}
else
{$poisk="";}
if (isset($_REQUEST['pois1']))   //
{$poisk1=$_REQUEST['pois1'];}
else
{$poisk1="";}
if (isset($_REQUEST['pois2']))   //
{$poisk2=$_REQUEST['pois2'];}
else
{$poisk2="";}
if ($poisk1=="" or $poisk2=="" ) {$poisk="";}
?>




<body  leftMargin=0   topMargin=0  style="">
<div id=h style="z-index:2;opacity:0.3;visibility:hidden;height:100%;width:100%;position:absolute;top:0;left:0;background:black;filter:alpha(opacity=30)">&nbsp;&nbsp;&nbsp;</div> 
<table id=tab border=0 width=100% height=100%  ><tbody>
<tr>
<td id=zagg  height=20 style="background:#316290;color:white" >
<table  height=100% border=0 width=100%><tbody>
<tr>
<td align=center colspan=2 style="FONT-SIZE: large;color:white;width:100%;FONT-WEIGHT: bolder;">
SITE SEARCH
</td>
</tr>
<tr><td  style="FONT-SIZE: large;color:white;width:200" valign=top>
<nobr>searching results</nobr>
</td>
<td align=center width=100%>
<nobr><form id=poi  method="POST" enctype="multipart/form-data" action="poisk.php" style="color:white">
Enter search text&nbsp;&nbsp;&nbsp;
<input type=text name=pois    value="<?php  echo $poisk;?>">


<input onclick="sub1(2)"    type="submit" value="to find" name="eg_sub" style="width:50px;background:#316290;color:white">
<input type=hidden name=pois1 value="">
<input type=hidden name=pois2 value="">

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<IMG name=1  border=0 src="d~e~f/arrow-up.gif">
<a href=# class=menu style="width:70px;color:white" onclick="top1()">
<b style="">To begin</b></a></form></nobr>
</td>
</tr>
</tbody></table>
</td></tr>
<tr><td>
<DIV id=ta style="OVERFLOW:auto;height:100%" >
<?php
$da=false;      //
if ($poisk=="")
{
echo "<ol><b>Search is performed </b> <li> in all internal pages, <li> in all external pages and their txt documents, <li> in the main database table, <li> in the uotside folder in the files: htm, html, txt, <li> in all diaries and notebooks that are not filled in for reading. </ol> ";
echo "<br> Enter in the white field the text by which the pages containing this text will be found and click the find button!";
echo "<br> <br> <b> Search results are shown as a sentence in which the search text was found! </b>";
echo "<br> <br> <b> The search in the file stops after the first found sentence. To search for all matches, click the found link and search using the standard browser tools by pressing Ctrl + f. </b>";
echo "<br> <br> <b> Search WILL BE PERFORMED in comments, guestbooks, questions, diaries, notebooks regardless of their publication on the page! </b>";
echo "<br> <br> <b> Search WILL NOT BE PERFORMED in readable objects, in data from modules, in voting forms! </b>";
}
else
{
//echo $poisk1."=".$poisk2."<hr>";
?>
<table border=1  cellspacing="1" cellpadding="6" width=100% >
<tr style="background:silver">
<td>N</td>
<td align=center>Found on page</td>
<td align=center>The first sentence in which the text is found.</td>
</tr>

<?php

//$poisk=
include "f.php";   //
//
$sps = file(getcwd ( )."/otd/page.txt");  

foreach ($sps as $li => $lin)         //
{if ($li>0)
{

list($s1, $s2) = explode("/",$lin); 
list($s21, $s22) = explode(".",$s2);

$dir=getcwd ( )."/pages/".$s21."/contents/";

//
$f=getcwd ( )."/pages/".$s21."/".$s21.".php";  //
$ech11="<a onclick=q1(this) target=_blank href=pages/".$s21.".php >".$s1."</a>";
$ech1="";
$ech="<a onclick=q1(this) target=_blank href='pages/".$s21.".php' >".$s1."</a></td><td>";
//echo $poisk."/".$poisk1."/".$poisk2."<hr>";
$net=pe($f,$ech,$ech1,$poisk,$poisk1,$poisk2,$kkk);
if ($net) {$da=true;$kkk++;}


 // 
$kuda=getcwd ( )."/pages/".$s21."/tc/tc.htm";
if (file_exists($kuda))  
{
$f=$kuda;  //
$ech1=""; //<a onclick=q1(this) target=_blank href=pages/".$s21.".php >".$s1."</a>";
$ech="<a onclick=q1(this) target=_blank href='pages/".$s21.".php' >".$s1."</a></td><td><b style='color:blue'>Comments:&nbsp;&nbsp;&nbsp;</b>"; 
$net=pe($f,$ech,$ech1,$poisk,$poisk1,$poisk2,$kkk);
if ($net) {$da=true;$kkk++;}
}
$kuda=getcwd ( )."/pages/".$s21."/tg/tg.htm";
if (file_exists($kuda))  
{
$f=$kuda;  //
$ech1=""; //<a onclick=q1(this) target=_blank href=pages/".$s21.".php >".$s1."</a>";
$ech="<a onclick=q1(this) target=_blank href='pages/".$s21.".php' >".$s1."</a></td><td><b style='color:blue'>Guest book:&nbsp;&nbsp;&nbsp;</b>"; 
$net=pe($f,$ech,$ech1,$poisk,$poisk1,$poisk2,$kkk);
if ($net) {$da=true;$kkk++;}
}

$kuda=getcwd ( )."/pages/".$s21."/tq/tq.htm";
if (file_exists($kuda))  
{
$f=$kuda;  //
$ech1=""; //<a onclick=q1(this) target=_blank href=pages/".$s21.".php >".$s1."</a>";
$ech="<a onclick=q1(this) target=_blank href='pages/".$s21.".php' >".$s1."</a></td><td><b style='color:blue'>Questions:&nbsp;&nbsp;&nbsp;</b>"; 
$net=pe($f,$ech,$ech1,$poisk,$poisk1,$poisk2,$kkk);
if ($net) {$da=true;$kkk++;}
}


// 
$kuda=getcwd ( )."/pages/".$s21."/y/p.html";   // 
if (file_exists($kuda))  
{
$l = file($kuda);                   //
foreach ($l as $li => $lin)         // 
{if ($li==0)                        // 
{$pass=$lin;break;}}
if ($pass==md5("1",false) or strlen($pass)==29)  // 
{
$scf="1.html,2.html,3.html,4.html,5.html,6.html,7.html,8.html,9.html,10.html,11.html,12.html";
$tag1=explode(',',$scf);        // 
foreach ($tag1 as $k => $zz)    // 
{
$f = getcwd ( )."/pages/".$s21."/y/".$zz;            //
if (file_exists($kuda))  
{
$f=getcwd ( )."/pages/".$s21."/y/".$zz;  //
$ech1=""; //<a onclick=q1(this) target=_blank href=pages/".$s21.".php >".$s1."</a>";
$ech="<a onclick=q1(this) target=_blank href='pages/".$s21.".php' >".$s1."</a></td><td><b style='color:blue'>Diary:&nbsp;&nbsp;&nbsp;</b>"; 
$net=pe($f,$ech,$ech1,$poisk,$poisk1,$poisk2,$kkk);
if ($net) {$da=true;$kkk++;}
}
if ($net) {break;} 
}
}
}


//  
$kuda=getcwd ( )."/pages/".$s21."/n/p.html";   // 
if (file_exists($kuda))  
{
$l = file($kuda);                   // 
foreach ($l as $li => $lin)         // 
{if ($li==0)                        // 
{$pass=$lin;break;}}
if ($pass==md5("1",false) or strlen($pass)==29)  // 
{
$scf="1.html,2.html,3.html,4.html,5.html,6.html,7.html,8.html,9.html,10.html,11.html,12.html,13.html,14.html,15.html,16.html,17.html,18.html,19.html,20.html,21.html,22.html,23.html,24.html,25.html,26.html,27.html,28.html,29.html,30.html,31.html,32.html,33.html,34.html,35.html,36.html,37.html,38.html,39.html,40.html,41.html,42.html";     // 
$tag1=explode(',',$scf);        //
foreach ($tag1 as $k => $zz)    //
{
$f = getcwd ( )."/pages/".$s21."/n/".$zz;            //
if (file_exists($kuda))  
{
$f=getcwd ( )."/pages/".$s21."/n/".$zz;  // 
$ech1="";  //<a onclick=q1(this) target=_blank href=pages/".$s21.".php >".$s1."</a>";
$ech="<a onclick=q1(this) target=_blank href='pages/".$s21.".php' >".$s1."</a></td><td><b style='color:blue'>Notebook:&nbsp;&nbsp;&nbsp;</b>"; 
$net=pe($f,$ech,$ech1,$poisk,$poisk1,$poisk2,$kkk);
if ($net) {$da=true;$kkk++;}
}
if ($net) {break;} 
}
}
}
///////////////////////////////
if (file_exists($dir))
{
$cont =scandir(getcwd ( )."/pages/".$s21."/contents/");
// 
foreach ($cont as $lii => $linn)    //
{
if  (strstr($linn, '.php'))           // 
{}
else                                 // 
{
if (strpos(" ".$linn,'.')==0)
{
$contt =scandir(getcwd ( )."/pages/".$s21."/contents/".$linn."/");
$php="";
foreach ($contt as $liii => $linnn)    //
{if  (strstr($linnn, '.php') and  !strstr($linnn, '#'))
{$php=$linnn;
break;
}
}
foreach ($contt as $liii => $linnn)    // 
{
if  (strstr($linnn, '.htm')  or strstr($linnn, '.html') or  strstr($linnn, '.txt'))           //
{
$s1=rtr(str_replace(".htm","",$linnn));
if  (strstr($linn, '_0') and strstr($linnn, '.txt') )   // 
{
$ech=" - <a  target=_blank href='pages/".$s21."/contents/".$linn."/".$php. "' style='color:blue'>".rtr(str_replace(".php",'',$php) )."</a></td><td>";
}
else
{
$ech=" - <a onclick=q1(this) target=_blank href='pages/".$s21."/contents/".$linn."/".str_replace(".htm",'.php',$linnn). "' style='color:blue'>".rtr(str_replace(".htm",'',$linnn) )."</a></td><td>";
}
$ech1=$ech11;
$f=getcwd ( )."/pages/".$s21."/contents/".$linn."/".$linnn;  //
//echo $f."<br>";
$net=pe($f,$ech,$ech1,$poisk,$poisk1,$poisk2,$kkk);
if ($net) {$da=true;$kkk++;}
}}
}}}}
}}

// 
$contt =scandir(getcwd ( )."/outside/");
foreach ($contt as $liii => $linnn)    // 
{
if  (strstr($linnn, '.htm') or strstr($linnn, '.html') or  strstr($linnn, '.txt') )           //
{
$ech=" - <a onclick=q1(this) target=_blank href='outside/".$linnn."' style='color:blue'>".$linnn."</a></td><td>";
$ech1="outside";
$f=getcwd ( )."/outside/".$linnn;  // 
$net=pe($f,$ech,$ech1,$poisk,$poisk1,$poisk2,$kkk);
if ($net) {$da=true;$kkk++;}
}}
?>
</table>
<?php
if (!$da)
{echo "<center style='FONT-SIZE: large'>The entered text was not found! Try to change the text and search again. </center>";
}}
?>
</div>
</td></tr>
</tbody></table>
</body>
<script type="text/javascript">




function sub1(p)
{
document.all["ta"].innerHTML="<h3>&nbsp;&nbsp;&nbsp;Wait, there is a search...</h3>";
pt=poi.elements["pois"].value
poi.elements["pois1"].value=pt.toUpperCase()
poi.elements["pois2"].value=pt.substr(0,1).toUpperCase()+pt.substr(1)
}

function top1(j)
{obj=document.all["ta"];
obj.scrollTop=0;
}

window.onload=function ()
{document.all["ta"].style.height=document.all["h"].offsetHeight-100;}

function q1(p)
{
p.href=p.href+"?td="+dp
//p.click()
}



</script>



</html>