<?php
error_reporting(0);
$copyright = "PHNwYW4gc3R5bGU9InBhZGRpbmc6MHB4O2ZvbnQ6OXB4IFZlcmRhbmEsVGFob21hOyI+Q29weXJpZ2h0IKkgQXJ0LVNvZnQmbmJzcDs8YSBocmVmPSJodHRwOi8vYXJ0LXNvZnQucnUvIiB0YXJnZXQ9Il9ibGFuayI+d3d3LmFydC1zb2Z0LnJ1PC9hPjwvc3Bhbj4=";
include "config.php";
$js_start = "";
$js_end = "";
if ((isset($_GET['script'])) && (trim($_GET['script']) == 'js')) {
	$js_start = "document.write('";
	$js_end = "');";
}
echo $js_start."<style>A.lxch:link { COLOR: #000CFF; TEXT-DECORATION: none } A.lxch:visited {COLOR: #000CFF; TEXT-DECORATION: none }A.lxch:hover {COLOR: #FF0000;  TEXT-DECORATION: none }</style>".$js_end."\n";
echo $js_start."<table width=100%><tr><td width=210 nowrap><td align=center><span style=\"font-size: 24px;\"><b>Каталог сайтов</b><td width=210 nowrap align=right><a class=lxch href=\"".$domain."add.php\" target=\"_blank\"><b>Добавьте свой сайт!</a>&nbsp;&nbsp;</td></tr></table><table width=100%><tr><td><table width=\"98%\" style=\"border-style: none; border-collapse: collapse; border-spacing: 0;\" align=center>".$js_end."\n".$js_start;
for ($j=3;$j<=$cat_nums;$j+=3) {
  echo "<tr>";
  if (!$copyright) die("");
  for ($n=($j-2);$n<=$j;$n++) { 
	  if ($n==$cat_id) tdwrite ($n, false); 
	    else  tdwrite ($n, true);
  }
}
echo "</td></tr></table></td></tr></table>".$js_end;
$cat_id=$_GET['cat_id']; 
$id="cat".trim($_GET['cat_id']).".db"; 
define("GEST_DB", $id); 
define("notes_on_page", 10); 
define("nav_pages", 10); 
if (file_exists(GEST_DB)) { 
    if (!$copyright) die("");
	$notes = file(GEST_DB);	$count_notes = count($notes); $on_page = notes_on_page; $mlim = nav_pages; $count_pages = ceil($count_notes/$on_page);
	if (isset($_GET['pg']) && ereg("^[0-9]{1,3}$", $_GET['pg'])) $start = $_GET['pg']-1; else $start = 0;
	if ($start == "") $start = 0;
	if ($start > $count_pages) $start = 0;
	$first = $count_notes - ($start * $on_page); $last = $count_notes - ($start * $on_page) - $on_page;
}
if (isset($count_pages) && $count_pages > 1) {
    echo $js_start."<table width=100% border=0><tr><td width=100% align=center>".$js_end."\n";
	$before = $start; $after = $count_pages - $start - 1;
	if ($before > $mlim) $before = $mlim;
	if ($after > $mlim) $after = $mlim;
	$mstart = $start - $before;	$mfinish = $start + $after+1;
	for ($i=$mstart; $i<$mfinish; $i++) {
		if ($i == $start) echo $js_start."<b>[".($i+1)."]</b>".$js_end."\n";
		else echo $js_start."<a class=lxch target=\"_top\" href=\"?cat_id=".$cat_id."&pg=".($i+1)."\"><b>[".($i+1)."]</b></a>".$js_end."\n";
	}
	echo $js_start."&nbsp;</td></tr></table>".$js_end;
}
if (file_exists(GEST_DB))
	for ($i=$first; $i>$last; $i--) if (isset($notes[$i-1])) 
	{
		$record = explode("¤", trim($notes[$i-1]));
		$st = $record[0];
    	if (!$copyright) die("");
		if ($st[0] != "*") echo "\n".$js_start."<p><hr size=-2 color=#66CCFF><table width=\"100%\" align=center border=0 cellpadding=0 cellspacing=0><tr><td class=d2>&nbsp;<b>Название:&nbsp;<td class=d2 width=\"100%\" style=\"color:red\"><b>".$record[1]."</b><tr><td class=d2>&nbsp;<b>Описание:</b>&nbsp;<td class=d2 width=\"100%\">".$record[2]."<tr><td height=22 class=d2 nowrap>&nbsp;<b>Адрес сайта:</b>&nbsp;<td class=d2 width=\"100%\"><a href=\"".$record[0]."\" target=\"_blank\"><b>".$record[0]."</b></a></td></tr></table><table width=\"100%\" align=center border=0 cellpadding=0 cellspacing=0><tr><td class=d2 height=22>&nbsp;<b>Добавлен:</b>&nbsp;&nbsp;&nbsp;&nbsp;<td class=d2 nowrap>&nbsp;".$record[3]."<td class=d2 nowrap width=\"100%\" nowrap align=right>&nbsp;<b>Страница ссылок:</b>&nbsp;<td class=d2 nowrap>&nbsp;<a href=\"".$record[4]."\" target=\"_blank\">".$record[4]."</b></a>&nbsp;&nbsp;&nbsp;</td></tr></table>&nbsp;<b>тИЦ Сайта:</b>&nbsp;&nbsp;<img src=\"http://www.yandex.ru/cycounter?".$record[0]."\"  alt=\"Яндекс цитирования\" width=88 height=31 align=\"middle\">".$js_end;
	}
	$copyright = base64_decode($copyright);
If ((!$cat_id) || ($cat_id == "")) {
	$ft = file($domain."title.html");
	echo $js_start."".$ft[0]."".$js_end;
    if (!$copyright) die("");
}
echo $js_start."<p align=center><a class=lxch href=\"".$domain."add.php\" target=\"_blank\"><b>Добавьте свой сайт!</b></a></p>".$js_end;
echo "<p align=center>$copyright</p>";
function tdwrite ($n,$y) { 
	global $cat;
	$fcat="cat".$n.".db";
	$fnums=0;
	if (file_exists($fcat)) { 
		$fct=file($fcat);
		$fnums=count($fct);
	} 
	echo "<td class=d1 nowrap height=17 width=\"33%\"><img src=\"http://art-soft.ru/images/folder.gif\" width=13 height=11>&nbsp;";
	if ($y) {
		echo "<a class=lxch href=\"?cat_id=".$n."\"><b>".$cat[$n]."</a>";
		echo "&nbsp;<span class=d2>(<b>".$fnums."</b>)</span></td>"; 
	}
	 else echo "<b><font color=red>".$cat[$n]."</font>&nbsp;<span class=d2 style=\"color:red\"><font color=#000000>(</font><b>".$fnums."</b><font color=#000000>)</font></span></td>";
}
?>