<?
# .................................................................................
#
# Скрипт: Manlix Search, версия: 1.3
# Автор: Manlix (http://manlix.ru)
# .................................................................................
if(phpversion()<4.1) exit("<font face='verdana' size='1' color='#de0000'><b>Версия PHP интерпретатора должна быть 4.1.0 или выше, но никак не ниже (ваша версия интерпретатора: ".phpversion().")</b></font>");
function error($error,$file){exit('<font face="verdana" size="1" color="#de0000"><b>'.$error.'<br>['.htmlspecialchars($file).']</b></font>');}
@set_time_limit(0);
@SetLocale(LC_ALL,"ru_RU.CP1251");
if(isset($_GET))
while(list($key,$value)=each($_GET))
$$key=$value;
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
function read_dir($dir)
{
if($OpenDir=opendir($dir))
{
while(($file=readdir($OpenDir))!==false)
{
if($file!="."&&$file!="..")
{
if(is_dir($dir.chr(47).$file))
{
if(!is_readable($dir.chr(47).$file))
error("нет прав для чтения текущий папки",$dir.chr(47).$file);
elseif(!is_writeable($dir.chr(47).$file))
error("нет прав для записи в текущую папку",$dir.chr(47).$file);
else
read_dir($dir.chr(47).$file);
}
else
{
if(!is_readable($dir.chr(47).$file))
error("нет прав для чтения файла",$dir.chr(47).$file);
elseif(!is_writeable($dir.chr(47).$file))
error("нет прав для записи в файл",$dir.chr(47).$file);
}
}
}
}
else error("нет прав",$dir);
}
function CheckConf($conf)
{
while(list($section,$array)=each($conf))
while(list($key,$value)=each($array))
if(!strlen($value))
error("В файле параметров скрипта, а именно в секции <font color=green>".$section."</font>, пуст ключ <font color=green>".$key."</font>",$conf['dir']['path']."/".$conf['dir']['inc']."/config.inc.dat");
}
if(!is_readable("./inc")) error("нет прав для чтения текущий папки","./inc");
elseif(!is_writeable("./inc")) error("нет прав для записи в текущую папку","./inc");
else read_dir("./inc");
$manlix=parse_ini_file("./inc/config.inc.dat",1);
CheckConf($manlix);
include("./inc/functions.inc.php");
if(isset($_SERVER['QUERY_STRING'])&&$_SERVER['QUERY_STRING']=="exit")
{
$_COOKIE=null;
setcookie($manlix['script']['prefix']."password",null);
}
#$manlix['sections']=array(
# 10 => "Создание базы (индексация сайта)",
# 20 => "Смена пароля",
# 30 => "Просмотр параметров скрипта",
# 40 => "Изменение параметров скрипта",
# 50 => "Информация о скрипте"
# );
$manlix['sections']=array(
'Основное меню' => array(
'10' => 'создание базы (индексация сайта)'
),
'Параметры скрипта'=> array(
'30' => 'просмотр',
'40' => 'изменение',
'20' => 'смена пароля'
),
'Шаблоны' => array(
'80' => 'выбор используемого шаблона',
'90' => 'создание шаблона',
'100' => 'редактирование шаблона'
),
'Информация' => array(
'50' => 'о скрипте',
'60' => 'версия PHP интерпретатора',
'70' => 'операционная система'
)
);
function CheckPostRequest()
{
global $manlix;
if(!count($_POST)) return 0;
elseif(!isset($_POST['password'])) return 0;
elseif(strlen($_POST['password'])==32) return 0;
else
{
setcookie($manlix['script']['prefix']."password",md5($_POST['password']));
$_COOKIE[$manlix['script']['prefix']."password"]=md5($_POST['password']);
return 1;
}
}
function CheckAdminPassword($password)
{
global $manlix;
$PasswordFile=manlix_read_file("./inc/password.inc.dat");
if(!isset($password)) return 0;
elseif(!isset($PasswordFile[0])) return 0;
elseif(strlen($password)==32&&isset($_COOKIE[$manlix['script']['prefix']."password"])&&$_COOKIE[$manlix['script']['prefix']."password"]==$PasswordFile[0]) return 1;
elseif($password==$PasswordFile[0]) return 1;
else return 0;
}
if(CheckPostRequest()) $manlix['access']=CheckAdminPassword($_COOKIE[$manlix['script']['prefix']."password"]);
else $manlix['access']=CheckAdminPassword((!isset($_COOKIE[$manlix['script']['prefix']."password"]))?null:$_COOKIE[$manlix['script']['prefix']."password"]);
if(empty($manlix['access']))
{
if(isset($_POST['password'])) $manlix['status']="пароль не опознан, повторите ввод";
$manlix['section']['name']="Вход в управление скриптом";
$manlix['result']='<br><table border="0" align="center" cellspacing="0" cellpadding="1">
<form method="post">
<tr><td align="right"><font face="verdana" size="1" color="maroon">Пароль:</td> <td><input type="password" name="password" size="30" class="name" onfocus="id=className" onblur="id=\'\'"" style="font: italic; width: 165px" value=""></td></tr>
<tr><td height="10"></td></tr>
<tr><td align="right" colspan="2">
<table border="0" cellspacing="0" cellpadding="1" bgcolor="#000000">
<tr><td><input type="submit" value="Выполнить вход" class="submit" style="width: 163px"></td></tr>
</table>
</td></tr>
<tr><td height="20"></td></tr>
</form>
</table>';
}
else
{
$manlix['status']="<a href='?".manlix_char_generator("qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890",32)."'><font color=#de0000>Главное меню</font></a>";
$manlix['result']=(!isset($manlix['result']))?null:$manlix['result'];
$manlix['section']['name']="Выберите нужное Вам действие";
$manlix['result'].="<table border=0 width=80% align=center>";
$manlix['NewSections']=array();
# while(list($a,$b)=each($manlix['sections']))
# $manlix['result'].="<tr><td><a href='?section=".(($a+1)*2*3*4*5*6*7*8*90)."'><font face=verdana size=1>".$void++.chr(46).chr(32).ucfirst($b)."</a></td></tr>";
while(list($a,$b)=each($manlix['sections']))
{
$manlix['result'].="<tr><td><font face=verdana size=1><b><font color=maroon>".$a."</font></b><ul type=square>";
while(list($key,$value)=each($b))
{
$manlix['result'].="<li><a href='?section=".(($key+1)*2*3*4*5*6*7*8*90)."'><font face=verdana size=1><i>".ucfirst($value)."</i></a></li>";
$manlix['NewSections'][$key]=$value;
}
$manlix['result'].="</ul></td></tr>";
}
$manlix['result'].="</table>";
$manlix['result'].="</td></tr><tr><tr><td bgcolor=maroon colspan=2></td></tr><tr><td colspan=2 bgcolor=#faedcf>";
if(empty($section)) $manlix['result'].="<center><br><font face=verdana size=1 color=green>Сделайте выбор</font></br><br></center>";
# elseif(!isset($manlix['sections'][($section-1)/2/3/4/5/6/7/8/90])) $manlix['result'].="<br><center><font face=verdana size=1 color=#de0000>Выбраный Вами раздел не существует</font></cebter><br><br>";
elseif(!isset($manlix['NewSections'][($section-1)/2/3/4/5/6/7/8/90])) $manlix['result'].="<br><center><font face=verdana size=1 color=#de0000>Выбраный Вами раздел не существует</font></cebter><br><br>";
else
{
# $manlix['status'].=" <font color=blue>»</font> <font color=green>".$manlix['section']['name']=ucfirst($manlix['sections'][$case=floor(($section-1)/2/3/4/5/6/7/8/90)])."</font>";
$manlix['status'].=" <font color=blue>»</font> <font color=green>".$manlix['section']['name']=ucfirst($manlix['NewSections'][$case=floor(($section-1)/2/3/4/5/6/7/8/90)])."</font>";
$manlix['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']))
$manlix['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']))
$manlix['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']))
$manlix['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+/",manlix_stripslashes($manlix['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
{
$NotAllowed="(";
for($i=0;$i<$NotAllowedCount;$i++)
if($i!=($NotAllowedCount-1))
$NotAllowed.=$NotAllowedArray[0][$i]."|";
else
$NotAllowed.=$NotAllowedArray[0][$i];
$NotAllowed.=")";
}
function DirSubscripting($dir)
{
global $manlix,$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=manlix_strip_new_line(strip_tags($content));
$content=preg_replace("/ +/s"," ",$content);
preg_match_all("/\w+/i",$content,$ContentArray);
if(!empty($title[1]))
{
$title[1]=manlix_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(" "," ",$manlix['other']['untitled'])).chr(32).$content.chr(13).chr(10));
fclose($OpenFile);
}
}
}
}
}
$OpenData=fopen($manlix['file']['data'],'w');
DirSubscripting($_POST['dir']);
fclose($OpenData);
$manlix['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))
$manlix['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'])) $manlix['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'])) $manlix['result'].="<br><center><font color=#de0000>Пароль должен состоять, только из русских, латинский букв и цифр.</font><br><br>...<a href='?section=148780800'>вернуться на шаг назад</a><br><br></center>";
else
{
$manlix['okay']=1;
$OpenPasswordFile=fopen("./inc/password.inc.dat","w");
flock($OpenPasswordFile,1);
flock($OpenPasswordFile,2);
fwrite($OpenPasswordFile,md5($_POST['NewPassword']));
fclose($OpenPasswordFile);
setcookie($manlix['script']['prefix']."password",md5($_POST['NewPassword']));
$manlix['result'].="<br><center><font color=green>Новый пароль успешно внесён в базу.</font><br><br></center>";
}
}
break;
case "30":
$manlix['section']['name']="Просмотр параметров скрипта";
$conf=parse_ini_file("./inc/config.inc.dat",1);
$void=0;
$manlix['result'].="<table border=0 width=440 align=center><tr><td>";
while(list($section,$array)=each($conf))
{
$manlix['result'].="<table border=0 width=100% align=center cellspacing=0 cellpadding=1><tr><td colspan=2 bgcolor=#7e5757></td></tr><tr><td colspan=2 bgcolor=#f7f1e1 align=center><font face=verdana size=1><b>".((description($section,0))?description($section,0):$section)."</td></tr><tr><td colspan=2 bgcolor=#7e5757></td></tr>";
while(list($key,$value)=each($array))
{
$bgcolor=(manlix_even($void))?"#f6f4dd":"#f6f4cd";
$manlix['result'].="<tr bgcolor=".$bgcolor." valign=top><td width=200><font face=verdana size=1 color=maroon> <i>".($void+1)."</i> <b>·</b> ".((description($section,$key))?description($section,$key):$key)." </td><td><font face=verdana size=1>".((!empty($value))?($value!=" ")?htmlspecialchars($value):"<b>пробел</b>":0)."</td></tr>";
$void++;
}
$manlix['result'].= "<tr><td colspan=2 bgcolor=#7e5757></td></tr>".
"</table>".
"<table border=0 height=10><tr><td></td></tr></table>";
}
$manlix['result'].="</td></tr></table>";
break;
case "40":
$manlix['section']['name']="Изменение параметров скрипта";
if(!count($_POST))
{
$conf=parse_ini_file("./inc/config.inc.dat",1);
$void=0;
$manlix['result'].="<table border=0 width=440 align=center><form method=post><input type=hidden name=dir__inc value='".$conf['dir']['inc']."'><tr><td>";
while(list($section,$array)=each($conf))
{
$manlix['result'].="<table border=0 width=100% align=center cellspacing=0 cellpadding=1><tr><td colspan=2 bgcolor=#7e5757></td></tr><tr><td colspan=2 bgcolor=#f7f1e1 align=center><font face=verdana size=1><b>".((description($section,0))?description($section,0):$section)."</td></tr><tr><td colspan=2 bgcolor=#7e5757></td></tr>";
while(list($key,$value)=each($array))
{
$bgcolor=(manlix_even($void))?"#f6f4dd":"#f6f4cd";
$manlix['result'].="<tr bgcolor=".$bgcolor." valign=top><td width=200><font face=verdana size=1 color=maroon> <i>".($void+1)."</i> <b>·</b> ".((description($section,$key))?description($section,$key):$key)." </td><td><input type=text name=".$section."__".$key." size=42 class=name onfocus=\"id=className\" style=\"font: italic; width: 228px\" onblur=\"id=''\"\" value=\"".((!empty($value))?htmlspecialchars($value):0)."\" ".(($section=="dir"&&$key=="inc")?" disabled":null)."></td></tr>";
$void++;
}
$manlix['result'].= "<tr><td colspan=2 bgcolor=#7e5757></td></tr>".
"</table>".
"<table border=0 height=10><tr><td></td></tr></table>";
}
$manlix['result'].= "</td></tr></table>".
"<table border=0 cellspacing=0 cellpadding=1 bgcolor=#000000 align=center>
<tr><td><input type=submit value=Применить class=submit style='width: 100px'></td></tr>
</table></form>";
}
else
{
$OpenConfigFile=fopen($manlix['dir']['path']."/".$manlix['dir']['inc']."/config.inc.dat","w");
flock($OpenConfigFile,1);
flock($OpenConfigFile,2);
while(list($key,$value)=each($_POST))
{
list($a,$b)=explode("__",$key);
if(!isset($manlix['temp'][$a]))
{
$manlix['temp'][$a]=1;
fwrite($OpenConfigFile,"[".$a."]".chr(13).chr(10));
}
fwrite($OpenConfigFile,$b."=\"".stripslashes(stripslashes(addslashes(str_replace('"','\'',$value))))."\";".chr(13).chr(10));
}
fclose($OpenConfigFile);
$manlix['okay']=1;
$manlix['result'].=<<<HTML
<center><br><br><font face=verdana size=1 color=maroon>Параметры скрипта успешно изменены</font><br><br><br></center>
HTML;
}
break;
case "50":
$manlix['section']['name']="Информация о скрипте";
$manlix['script']['info']=(!empty($manlix['script']['info']))?$manlix['script']['info']:"нет информации";
$manlix['result'].= "<table border=0 width=400 align=center>".
"<tr><td width=80><font face=verdana size=1>Имя скрипта:</td><td><font face=verdana size=1 color=maroon>".$manlix['script']['name']."</td></tr>".
"<tr><td><font face=verdana size=1>По-русски:</td><td><font face=verdana size=1 color=maroon>".$manlix['script']['russian']."</td></tr>".
"<tr><td><font face=verdana size=1>Версия:</td><td><font face=verdana size=1 color=#de0000>".$manlix['script']['version']."</td></tr>".
"<tr><td colspan=2><font face=verdana size=1>Дополнительно:</td></tr>".
"<tr><td colspan=2><font face=verdana size=1><i>".$manlix['script']['info']."</td></tr>".
"</table>";
break;
case "60":
$manlix['section']['name']="Версия PHP интерпретатора";
$manlix['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 "70":
$manlix['section']['name']="Операционная система";
list($os)=split(" ",php_uname(),2);
$manlix['result'].="<br><center>Операционная система - <i><font color=maroon>".$os."</font></i></center><br>";
break;
case "80":
if(empty($_POST['SelectedTemplate']))
{
$manlix['section']['name']="Выберите шаблон, который будет использваться";
$manlix['result'].="<center><form method=post><br><select name=SelectedTemplate class=name onfocus='id=className' onblur='id=\"\"' style='font: italic'>";
$manlix['result'].="<option value=''>сделайте выбор...</option>";
$OpenTemplatesDir=opendir($manlix['dir']['templates']);
while(($template=readdir($OpenTemplatesDir))!==false)
{
if($template!="."&&$template!="..")
{
if($manlix['template']['parse']==$template)
$manlix['result'].="<option value='".$template."' style='color: green'>".$template."</option>";
else
$manlix['result'].="<option value='".$template."'>".$template."</option>";
}
}
$manlix['result'].="</select></center>";
$manlix['result'].='<br><table border=0 cellspacing=0 cellpadding=1 bgcolor=#000000 align=center>
<tr><td><input type=submit value=Применить class=submit style="width: 100px"></td></tr>
</table>
</form>';
}
elseif($_POST['SelectedTemplate']==$manlix['template']['parse'])
{
$manlix['section']['name']="Шаблон";
$manlix['result'].=<<<HTML
<center><br><font face=verdana size=1 color=maroon>Выбранный Вами шаблон уже используется<br><br>(<a href='?section=330220800'>вернуться на шаг назад</a> | <a href='?'>вернуться в главное меню</a>)</font><br><br></center>
HTML;
}
elseif(!is_dir($manlix['dir']['templates']."/".$_POST['SelectedTemplate']))
{
$manlix['section']['name']="Шаблон";
$manlix['result'].=<<<HTML
<center><br><font face=verdana size=1 color=maroon>Выбарнный Вами шаблон не существует<br><br>(<a href='?section=330220800'>вернуться на шаг назад</a> | <a href='?'>вернуться в главное меню</a>)</font><br><br></center>
HTML;
}
else
{
$manlix['section']['name']="Шаблон применён";
$conf=parse_ini_file("./inc/config.inc.dat",1);
$OpenConfigFile=fopen("./inc/config.inc.dat","w");
while(list($IniKey,$array)=each($conf))
{
fwrite($OpenConfigFile,"[".$IniKey."]".chr(13).chr(10));
if($IniKey!="template")
while(list($key,$value)=each($array))
fwrite($OpenConfigFile,$key."=\"".$value."\";".chr(13).chr(10));
else
fwrite($OpenConfigFile,"parse=\"".$_POST['SelectedTemplate']."\";".chr(13).chr(10));
}
fclose($OpenConfigFile);
$manlix['okay']=1;
$manlix['result'].=<<<HTML
<center><br><font face=verdana size=1 color=maroon>Операция прошла успешно.<br><br>(<a href='?section=330220800'>вернуться на шаг назад</a> | <a href='?'>вернуться в главное меню</a>)</font><br><br></center>
HTML;
}
break;
case "90":
if(!eregi("^[a-z0-9_-]+$",(!empty($_POST['TemplateName']))?$_POST['TemplateName']:null))
{
$manlix['section']['name']="Задайте имя для нового шаблона";
$manlix['result'].='
<center><br>
<form method=post>
<font face=verdana size=1>Используйте, только: русские,<br>латинские буквы, цифры, знак подчёркивания и чёрточку (минус).</font>
<br><br>
<input type=text name=TemplateName size=30 class=name onfocus="id=className" onblur="id=\'\'"" style="font: italic; width: 165px" value="'.htmlspecialchars((!empty($_POST['TemplateName']))?$_POST['TemplateName']:null).'"><br><br>
<table border=0 cellspacing=0 cellpadding=1 bgcolor=#000000 align=center>
<tr><td><input type=submit value=Дальше... class=submit style="width: 100px"></td></tr>
</table>
</form>
</center>';
}
elseif(count($_POST)<2)
{
$manlix['section']['name']="Заполните формы";
$manlix['result'].= "<table border=0 align=center>".
"<form method=post>".
"<input type=hidden name=TemplateName value='".$_POST['TemplateName']."'>".
"<tr><td><div align=right><font face=verdana size=2 color=green><br><b><i>ШАБЛОНЫ<br>(информацию по константам смотрите в файле <a href='info.html'>info.html</a>)</i></b></font></div></td></tr>";
while(list($key,$FileName)=each($manlix['templates']))
{
switch($key)
{
case "top": $TemplateName="Верхушка";
break;
case "form": $TemplateName="Форма для начала поиска";
break;
case "result": $TemplateName="Результат";
break;
case "error": $TemplateName="Ошибка";
break;
case "loading": $TemplateName="Ожидание результатов";
break;
case "stat": $TemplateName="Информации по поиску (статистика)";
break;
case "navigation": $TemplateName="Навигация по страницам результата поиска";
break;
case "bottom": $TemplateName="Низ";
break;
case "okay": $TemplateName="Сообщение добавлено";
break;
default: $TemplateName=$key;
}
$manlix['result'].= "<tr><td><font face=verdana size=1><b><i>· <font color=maroon>".$TemplateName."</font></i></b></font></td></tr>".
"<tr><td><textarea wrap=off rows=10 cols=56 name=templates__".$key." class=name onfocus=\"id=className\" onblur=\"id=''\"\" style=\"width: 450px; height: 150px\"></textarea></td></tr>";
}
$manlix['result'].=<<<HTML
<tr><td> <table border=0 cellspacing=0 cellpadding=1 bgcolor=#000000 align=center>
<tr><td><input type=submit value=Создать class=submit style="width: 100px"></td></tr>
</table>
</td></tr>
</form>
</table>
HTML;
}
else
{
mkdir($manlix['dir']['templates']."/".$_POST['TemplateName'],"0770");
while(list($key,$value)=each($_POST))
{
if(strstr($key,"templates__"))
{
list($a,$b)=explode("__",$key);
if(isset($manlix[$a][$b]))
{
$OpenTemplateFile=fopen($manlix['dir']['templates']."/".$_POST['TemplateName']."/".$manlix['templates'][$b],"w");
flock($OpenTemplateFile,1);
flock($OpenTemplateFile,2);
fwrite($OpenTemplateFile,manlix_stripslashes($value));
fclose($OpenTemplateFile);
}
}
}
$manlix['okay']=1;
$manlix['section']['name']="Операция прошла успешно";
$manlix['result'].=<<<HTML
<center><font face=verdana size=1 color=maroon><br>Шаблон успешно создан<br><br>(<a href='?section=330220800'>создать ещё шаблон</a> | <a href='?'>вернуться в главное меню</a>)<br><br></font></center>
HTML;
}
break;
case "100":
if(empty($_POST['SelectedTemplate']))
{
$manlix['section']['name']="Выберите шаблон, который нужно отредактировать";
$manlix['result'].="<center><form method=post><br><select name=SelectedTemplate class=name onfocus='id=className' onblur='id=\"\"' style='font: italic'>";
$manlix['result'].="<option value=''>сделайте выбор...</option>";
$OpenTemplatesDir=opendir($manlix['dir']['templates']);
while(($template=readdir($OpenTemplatesDir))!==false)
{
if($template!="."&&$template!="..")
{
if($manlix['template']['parse']==$template)
$manlix['result'].="<option value='".$template."' style='color: green'>".$template."</option>";
else
$manlix['result'].="<option value='".$template."'>".$template."</option>";
}
}
$manlix['result'].="</select></center>";
$manlix['result'].='<br><table border=0 cellspacing=0 cellpadding=1 bgcolor=#000000 align=center>
<tr><td><input type=submit value=Выбрать... class=submit style="width: 100px"></td></tr>
</table>
</form>';
}
elseif(!is_dir($manlix['dir']['templates']."/".$_POST['SelectedTemplate']))
{
$manlix['section']['name']="Шаблон";
$manlix['result'].=<<<HTML
<center><br><font face=verdana size=1 color=maroon>Выбарнный Вами шаблон не существует<br><br>(<a href='?section=366508800'>вернуться на шаг назад</a> | <a href='?'>вернуться в главное меню</a>)</font><br><br></center>
HTML;
}
elseif(count($_POST)<2)
{
$manlix['section']['name']="Заполните формы для шаблона";
$manlix['result'].= "<table border=0 align=center>".
"<form method=post>".
"<input type=hidden name=SelectedTemplate value='".$_POST['SelectedTemplate']."'>".
"<tr><td><div align=right><font face=verdana size=2 color=green><br><b><i>ШАБЛОНЫ<br>(информацию по константам смотрите в файле <a href='info.html'>info.html</a>)</i></b></font></div></td></tr>";
while(list($key,$FileName)=each($manlix['templates']))
{
switch($key)
{
case "top": $TemplateName="Верхушка";
break;
case "form": $TemplateName="Форма для начала поиска";
break;
case "result": $TemplateName="Результат";
break;
case "error": $TemplateName="Ошибка";
break;
case "loading": $TemplateName="Ожидание результатов";
break;
case "stat": $TemplateName="Информации по поиску (статистика)";
break;
case "navigation": $TemplateName="Навигация по страницам результата поиска";
break;
case "bottom": $TemplateName="Низ";
break;
case "okay": $TemplateName="Сообщение добавлено";
break;
default: $TemplateName=$key;
}
$manlix['result'].= "<tr><td><font face=verdana size=1><b><i>· <font color=maroon>".$TemplateName."</font></i></b></font></td></tr>".
"<tr><td><textarea wrap=off rows=10 cols=56 name=templates__".$key." class=name onfocus=\"id=className\" onblur=\"id=''\"\" style=\"width: 450px; height: 150px\">".ReadTemplate($_POST['SelectedTemplate'],$FileName)."</textarea></td></tr>";
}
$manlix['result'].=<<<HTML
<tr><td><br>
<table border=0 cellspacing=0 cellpadding=1 bgcolor=#000000 align=center>
<tr><td><input type=submit value=Применить class=submit style="width: 100px"></td></tr>
</table>
<br>
</td></tr>
</form>
</table>
HTML;
}
else
{
while(list($key,$value)=each($_POST))
{
if(strstr($key,"templates__"))
{
list($a,$b)=explode("__",$key);
if(isset($manlix[$a][$b]))
{
$OpenTemplateFile=fopen($manlix['dir']['templates']."/".$_POST['SelectedTemplate']."/".$manlix['templates'][$b],"w");
flock($OpenTemplateFile,1);
flock($OpenTemplateFile,2);
fwrite($OpenTemplateFile,manlix_stripslashes($value));
fclose($OpenTemplateFile);
}
}
}
$manlix['okay']=1;
$manlix['section']['name']="Операция прошла успешно";
$manlix['result'].=<<<HTML
<center><font face=verdana size=1 color=maroon><br>Шаблон успешно отредактирован<br><br>(<a href='?section=3665088001'>выбрать другой шаблон для изменения</a> | <a href='?'>вернуться в главное меню</a>)<br><br></font></center>
HTML;
}
}
$manlix['result'].="</font></td></tr></table>";
}
}
if(empty($manlix['status'])) $manlix['status']="вход не выполнен";
?>
<html>
<head>
<title><?=$manlix['script']['name'],", версия: ",$manlix['script']['version']?> » Управление » <?=ereg_replace("<[^>]+>", "",ucfirst($manlix['status']))?></title>
<meta http-equiv="content-type" content="text/html; charset=windows-1251">
<meta http-equiv="pragma" content="no-cache">
<? if(isset($manlix['okay'])) echo '<meta http-equiv="refresh" content="3; url=?'.manlix_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><?=$manlix['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><?=$manlix['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($manlix['section']['name']))?$manlix['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($manlix['result']))?$manlix['result']:''?></td></tr>
<tr><td bgcolor=maroon colspan=2></td></tr>
<tr><td height=10></td></tr>
</table>
</td></tr>
<tr align=center bgcolor=#faedca><td align=center><font face=verdana size=1><a href="http://manlix.ru" target="_blank">Разработка скрипта: Manlix</a></font></td></tr>
</table>
</td></tr>
<?
if(!empty($manlix['access']))
{
echo "<tr><td align=right><font face=verdana size=1>(<a href='?exit'>закрыть сессию</a>)</font></td></tr>";
}
?>
</table>
</body>
</html>