<?php
if(!file_exists($catalog."/css.php"))exit("Не надо этот файл открывать!");
$conf=file($catalog."/admin/conf/sett.txt");
for($n=0;$n<count($conf);$n++)$conf[$n]=trim($conf[$n]);
$size_img_cat=$conf[31];
include_once($catalog."/admin/db/zagl");include_once($catalog."/dict.php"); 
if (strpos($zagl,'новости')===false && strpos($zagl,'НОВОСТИ')===false && strpos($zagl,'Новости')===false) { 
if (strpos($zagl,'статьи')!==false || strpos($zagl,'СТАТЬИ')!==false || strpos($zagl,'Статьи')!==false) include_once($catalog."/dict1.php"); 
elseif (strpos($zagl,'Публикации')!==false || strpos($zagl,'ПУБЛИКАЦИИ')!==false || strpos($zagl,'публикации')!==false) include_once($catalog."/dict2.php"); 
elseif (!is_file($catalog."/user_dict.php")) { if (copy($catalog."/dict2.php", $catalog."/user_dict.php")) include_once($catalog."/user_dict.php"); }
else include_once($catalog."/user_dict.php");
}
//include_once("$catalog/css.php"); //убрано для переноса стиля в head материнской страницы
$news1=array();
$news=array();
$d=opendir($catalog."/admin/db/news");
while(($e=readdir($d))!=false)
   {
     if($e =="." || $e ==".." || $e==".htaccess") continue;
     $news1[]=$e;
   }
closedir($d);
 foreach($news1 as $line)
 {
   $text=file("$catalog/admin/db/news/$line");
   $text[0]=trim($text[0]);
   $news[$text[0]]=$line;
 }
krsort($news,SORT_NUMERIC);
$cat=array();
$id_cat=array();
$cat=file("$catalog/admin/db/cat.txt");

foreach($cat as $line)
 {
   $line=trim($line);
   $expl=explode("*",$line);
   $id_cat[$expl[0]]=$expl[1];
 }
 echo" <div id=sgNewsMn ><ul id=sg_menuNews class=sg_menu> ";
$i=0;
foreach($news as $line)
 {
   if($i==$conf[33])break;
   $text=file("$catalog/admin/db/news/$line");
   $foto=array();
   $foto=file("$catalog/admin/db/id_foto/$line");
   for($n=0;$n<count($text);$n++)$text[$n]=trim($text[$n]);
   $get_date=getdate($text[0]);

if (mb_strlen($text[2])>30) $text[2]=mb_substr($text[2],0,mb_strripos(mb_substr($text[2],0,30,"UTF-8"),' ',0,"UTF-8"),"UTF-8").'...'; 
   if($conf[34]!="" && isset($text[4]))
     {
 //      $links1="<a href='$conf[34]$line.html'>$text[2]</a>";
 //      $links2=	"<a href='$conf[34]?id=$line'>$text[3]</a>";
  $conf34 = str_ireplace(".html", "/", $conf[34]);
  $conf34 = str_ireplace(".php", "/", $conf34);

	   $links1="<a href='$conf34".$line.".html'>$text[2]</a>";
     }
   else
    {
      $links1=$text[2];
    }
	if(isset($_GET['id']) && $_GET['id']==$line) $classCur="class=sg_menuCurrent";
	else  $classCur="";
	$links1=trim($links1);

 if($text[2]!="") echo "<li $classCur>$links1</li>";
   $i++;
 }
 
/* if($conf[24]==1 && $conf[34]!="")
 {
	 if(count($news)) {
	 if(!isset($_GET['id'])) $classCur="class=sg_menuCurrent";
	 else  $classCur="";
	 echo "<li $classCur >
	 <a href=".$_SERVER[PHP_SELF].">".$dict['Все новости']."</a></li>";
	}
 } */
echo"</ul></div>";

echo"<br /><br />";
 echo" <div id=sgCatMn ><ul id=sg_menuCat class=sg_menu> ";

if($conf[24]==1 && $conf[34]!="")
 {
  foreach($id_cat as $k=>$v)
  {
	if(isset($_GET['c']) && $_GET['c']==$k)  {$classCur="class=sg_menuCurrent";}
	else  $classCur="";
  echo"<li $classCur><a href='$conf[34]?c=$k'>$v</a></li>";
  }
if(count($news)) {
	 if(!isset($_GET['id']) && !isset($_GET['c'])) $classCur="class=sg_menuCurrent";
	 else  $classCur="";
	 echo "<li $classCur >
	 <a href=".$_SERVER['PHP_SELF'].">".$dict['Все новости']."</a></li>";
	}
  
echo"</ul></div>";
 }


?>
