Курсовая работа: Разработка сайта. Система поиска по сайту
}
$term_paper ['result']. ="</table>";
$term_paper ['result']. ="</td></tr><tr><tr><td bgcolor=maroon colspan=2></td></tr><tr><td colspan=2 bgcolor=#faedcf>";
if (empty ($section)) $term_paper ['result']. ="<center><br><font face=verdana size=1 color=green>Сделайте выбор</font></br><br></center>";
#elseif (! isset ($term_paper ['sections'] [ ($section-1) /2/3/4/5/6/7/8/90])) $term_paper ['result']. ="<br><center><font face=verdana size=1 color=#de0000>Выбраный Вами раздел не существует</font></cebter><br><br>";
elseif (! isset ($term_paper ['NewSections'] [ ($section-1) /2/3/4/5/6/7/8/90])) $term_paper ['result']. ="<br><center><font face=verdana size=1 color=#de0000>Выбраный Вами раздел не существует</font></cebter><br><br>";
else
{
#$term_paper ['status']. =" <font color=blue>"</font> <font color=green>". $term_paper ['section'] ['name'] =ucfirst ($term_paper ['sections'] [$case=floor ( ($section-1) /2/3/4/5/6/7/8/90)]). "</font>";
$term_paper ['status']. =" <font color=blue>"</font> <font color=green>". $term_paper ['section'] ['name'] =ucfirst ($term_paper ['NewSections'] [$case=floor ( ($section-1) /2/3/4/5/6/7/8/90)]). "</font>";
$term_paper ['result']. ="<table border=0 width=98% align=center><tr><td><font face=verdana size=1>";
switch ($case)
{
case "10":
if (! isset ($_POST ['dir']) ||! isset ($_POST ['url']))
$term_paper ['result']. =
'<script language="javascript" type="text/javascript">
<! - -
function StartSubscripting ()
{
OpenSubscriptingWindow=open ("","SubscriptingWindow","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,left=50,top=50,width=700,height=500");
OpenSubscriptingWindow. focus ();
OpenSubscriptingWindow. document. open ();
OpenSubscriptingWindow. document. write ("<html> <head> <title>Индексация. </title> <meta http-equiv=\"pragma\" content=\"no-cache\"> <meta http-equiv=\"content-type\" content=\"text/html; charset=windows-1251\"></head><body bgcolor=#ffffff> <table border=0 width=100% height=100%> <tr><td align=center><font face=verdana size=4 color=green><i>Идёт индексация сайта, пожалуйста, подождите. </td></tr> </table> </body> </html>");
OpenSubscriptingWindow. document. close ();
}
->
</script>
<table border=0 width=100%>
<form method=post onSubmit=StartSubscripting () target=SubscriptingWindow>
<tr><td height=10></td></tr>
<tr><td align=center><font face=verdana size=1 color=maroon><i>Укажите папку, в которой берёт начало Ваш сайт (без / в конце): </td></tr>
<tr><td align=center><input type=text name=dir size=52 class=name onfocus="id=className" onblur="id=\'\'"" style="font: italic; width: 346px" value="'.htmlspecialchars ( (isset ($_SERVER ['DOCUMENT_ROOT']))? $_SERVER ['DOCUMENT_ROOT']: null). '"></td></tr>
<tr><td height=10></td></tr>
<tr><td align=center><font face=verdana size=1 color=maroon><i>Укажите URL, который соответствует папке,<br>которую Вы указали (без / в конце): </td></tr>
<tr><td height=10></td></tr>
<tr><td align=center><input type=text name=url size=52 class=name onfocus="id=className" onblur="id=\'\'"" style="font: italic; width: 346px" value="http://'.htmlspecialchars ( (isset ($_SERVER ['HTTP_HOST']))? $_SERVER ['HTTP_HOST']: null). '"></td></tr>
<tr><td height=10></td></tr>
<tr><td align=center>
<table border=0 cellspacing=0 cellpadding=1 bgcolor=#000000>
<tr><td><input type=submit value="Начать индексирование" class=submit style="width: 150px"></td></tr>
</table>
</td></tr>
<tr><td height=10></td></tr>
<tr><td align=center><font face=verdana size=1 color=#de0000><i> (скорость индексации зависит от быстроты Вашего компьютера,<br>обязательно дождитесь окончания индексации) </td></tr>
</form>
</table>';
else
{
if (! is_dir ($_POST ['dir']))
$term_paper ['result']. ="<center><font face=verdana size=1 color=#de0000><b><br><br><br><br>Указанная Вами папка не существует<br><br><br><br><br></b></font></center>";
elseif (! is_readable ($_POST ['dir']))
$term_paper ['result']. ="<center><font face=verdana size=1 color=#de0000><b><br><br><br><br>Нет прав для чтения указанной Вами папки<br><br><br><br><br></b></font></center>";
else
{
$_POST ['dir'] =preg_replace ("/\\\+/",chr (47),$_POST ['dir']);
preg_match_all ("/\w+/",term_paper_stripslashes ($term_paper ['other'] ['NotAllowed']),$NotAllowedArray);
$NotAllowedTemp=array_unique ($NotAllowedArray [0]);
$NotAllowedArray [0] =null;
while (list (,$value) =each ($NotAllowedTemp))
$NotAllowedArray [0] [] =$value;
if (! $NotAllowedCount=count ($NotAllowedArray [0]))
$NotAllowed=chr (32);
else
function DirSubscripting ($dir)
{
global $term_paper,$OpenData,$NotAllowed;
if (is_readable ($dir2=$dir))
{
$OpenDir=opendir ($dir);
while ( ($file=readdir ($OpenDir))! ==false)
{
if ($file! =". "&&$file! =". "&&! preg_match ("/". $NotAllowed. "/i",$file))
{
if (is_dir ($dir. chr (47). $file))
DirSubscripting ($dir. chr (47). $file);
else
{
$OpenFile=fopen ($dir. chr (47). $file,'r');
$content=fread ($OpenFile,filesize ($dir. chr (47). $file));
preg_match ("! <title> (. *) </title>! is",$content,$title);
$content=term_paper_strip_new_line (strip_tags ($content));
$content=preg_replace ("/ +/s"," ",$content);
preg_match_all ("/\w+/i",$content,$ContentArray);
if (! empty ($title [1]))
{
$title [1] =term_paper_strip_new_line ($title [1]);
preg_match_all ("/\w+/i",$title [1],$NewTitle);
$title [1] =null;
while (list (,$string) =each ($NewTitle [0]))
$title [1]. =$string. chr (32);
}
$dir2=eregi_replace (strtolower ($_POST ['dir']),"",$dir2);
$content=null;
while (list (,$string) =each ($ContentArray [0]))
$content. =$string. chr (32);
if (! empty ($content))
fwrite ($OpenData,$_POST ['url']. $dir2. chr (47). $file. chr (32). ( (isset ($title [1]))? str_replace (" "," ­ ",$title [1]): str_replace (" "," ",$term_paper ['other'] ['untitled'])). chr (32). $content. chr (13). chr (10));
fclose ($OpenFile);
}
}
}
}
}
$OpenData=fopen ($term_paper ['file'] ['data'],'w');
DirSubscripting ($_POST ['dir']);
fclose ($OpenData);
$term_paper ['result']. ="<center><font face=verdana size=1 color=green><b><br><br><br><br>Сайт удачно проиндексирован<br><br><br><br><br></b></font></center>";
}
}
break;
case "20":
if (empty ($_POST))
$term_paper ['result']. =<<<HTML
<br><i><font face=verdana color=#de0000>Будьте внимательны! </font><br><i><ul type=square><li>После изменения пароля старый действовать больше не будет. </li><li>Для того чтобы не забыть новый пароль, запишите его где-нибудь. </li><li>В пароль могут входить: русские, латинский буквы и цифры. </li><li>Учитывается регистр. </li></ul></i>
<br>
<form method=post>
<center>Новый пароль: <input type=password name=NewPassword size=52 class=name onfocus="id=className" onblur="id=''"" style="font: italic; width: 346px"></center>
<br><br>
<center>
<table border=0 cellspacing=0 cellpadding=1 bgcolor=#000000>
<tr><td><input type=submit value=Применить class=submit style="width: 70px"></td></tr>
</table>
</center>
</form>
HTML;
else
{
if (empty ($_POST ['NewPassword'])) $term_paper ['result']. ="<br><center><font color=#de0000>Вы не ввели новый пароль. </font><br><br>. <a href='? section=148780800'>вернуться на шаг назад</a><br><br></center>";
elseif (! eregi ("^ [a-zа-яё0-9] +$",$_POST ['NewPassword'])) $term_paper ['result']. ="<br><center><font color=#de0000>Пароль должен состоять, только из русских, латинский букв и цифр. </font><br><br>. <a href='? section=148780800'>вернуться на шаг назад</a><br><br></center>";
else
{
$term_paper ['okay'] =1;
$OpenPasswordFile=fopen (". /inc/password. inc. dat","w");
flock ($OpenPasswordFile,1);
flock ($OpenPasswordFile,2);
fwrite ($OpenPasswordFile,md5 ($_POST ['NewPassword']));
fclose ($OpenPasswordFile);
setcookie ($term_paper ['script'] ['prefix']. "password",md5 ($_POST ['NewPassword']));
$term_paper ['result']. ="<br><center><font color=green>Новый пароль успешно внесён в базу. </font><br><br></center>";
}
}
break;
case "30":
$term_paper ['section'] ['name'] ="Версия PHP интерпретатора";
$term_paper ['result']. ="<br><center>Версия PHP интерпретатора - <i><font color=maroon>". phpversion (). "</font></i><br><br>". ( (php_sapi_name () =="cgi")?"<font color=green>Установлен в качестве CGI</font>": "<font color=#de0000>Установлен в качестве модуля</font>"). "</center><br>";
break;
case "40":
$term_paper ['section'] ['name'] ="Операционная система";
list ($os) =split (" ",php_uname (),2);
$term_paper ['result']. ="<br><center>Операционная система - <i><font color=maroon>". $os. "</font></i></center><br>";
break;
case "100":
echo "цикл не работает";
}
$term_paper ['result']. ="</font></td></tr></table>";
}
}
if (empty ($term_paper ['status'])) $term_paper ['status'] ="вход не выполнен";
? >
<html>
<head>
<title><? =$term_paper ['script'] ['name'],", версия: ",$term_paper ['script'] ['version']? > " Управление " <? =ereg_replace ("< [^>] +>", "",ucfirst ($term_paper ['status']))? ></title>
<meta http-equiv="content-type" content="text/html; charset=windows-1251">
<meta http-equiv="pragma" content="no-cache">
<? if (isset ($term_paper ['okay'])) echo '<meta http-equiv="refresh" content="3; url=? '. term_paper_char_generator ("qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890",32). '">';? >
<style type="text/css">
<! - -
a: link{color: #000000; text-decoration: none; }
a: active{color: #000000; text-decoration: none; }
a: visited{color: #000000; text-decoration: none; }
a: hover{color: #de0000; text-decoration: none; }
. name{border: 1px; border-style: solid; height: 16px; border-color: #000000; background-color: #ffe6b7; font-family: verdana; font-size: 10px; color: #de0000; }
#name{border: 1px; border-style: solid; height: 16px; border-color: #000000; background-color: #fef1d8; font-family: verdana; font-size: 10px; color: #de0000; }
. submit{border: 0px; height: 14px; background-color: #ffe6b7; font-family: verdana; font-size: 10px; color: #000000; }
->
</style>
</script>
</head>
<body bgcolor=#ffffff background="images/background. gif" style="cursor: default" topmargin=3>
<table border=0 align=center cellspacing=0 cellpadding=1>
<tr><td align=right><font face=verdana size=1 style="background-color: #ffffff" color=#de0000><? =$term_paper ['status']? ></font></td></tr>
<tr><td>
<table width=500 align=center cellspacing=1 cellpadding=1 bgcolor=#faad1e>
<tr align=center bgcolor=#faedca height=44><td><font face=verdana size=6 color=#FAD27D><b><? =$term_paper ['script'] ['name']? ></i></b></font></td></tr>
<tr><td align=cetner bgcolor=#faedc0>
<table border=0 align=center cellspacing=0 cellpadding=1 width=470>
<tr><td height=10></td></tr>
<tr><td bgcolor=maroon colspan=2></td></tr>
<tr><td align=center bgcolor=#faedca colspan=2><font face=verdana color=maroon size=1><? = (isset ($term_paper ['section'] ['name']))? $term_paper ['section'] ['name']: ''? ></font></td></tr>
<tr><td bgcolor=maroon colspan=2></td></tr>
<tr><td height=10></td></tr>
<tr><td bgcolor=maroon colspan=2></td></tr>
<tr><td colspan=2 bgcolor=#faedca><? = (isset ($term_paper ['result']))? $term_paper ['result']: ''? ></td></tr>
<tr><td bgcolor=maroon colspan=2></td></tr>
<tr><td height=10></td></tr>
</table>
</td></tr>
</table>
</td></tr>
<?
if (! empty ($term_paper ['access']))
{
echo "<tr><td align=right><font face=verdana size=1> (<a href='? exit'>закрыть сессию</a>) </font></td></tr>";
}
? >
</table>
<br><br><br>
<div align="center">
<table>
<tr><a href=". /down.html">На главную</a></tr>
<tr><img src=". /img/logo_pic. gif"></tr>
</table></div>
</body>
</html>
Изображения хранятся в папке "img", скрипты поиска в папке "search".