Файл: blogs/cat.php
Строк: 79
<?php
require_once ('../shaxty.php');
check_login();
$title = 'Блоги';
$align = 'left';
unset($_SESSION['msg']);
unset($_SESSION['s']);
include_once (H.'shaxty/head.php');
if(isset($id)){
$id2= rus_lat(rus_utf_tolower(del($id)));
if (ctype_digit($id)) $sql = "and `id` = '$id'";
else if (!ctype_digit($id)) $sql = "and `name_lat` = '$id2'";
}
$cat=mysql_fetch_array(mysql_query("select * from blogs where tip = 'cat' $sql;"));
if($level>=5){
if(isset($_GET['delblog'])) {
mysql_query("DELETE FROM `blogs` WHERE tip = 'msg' and id = '".check(intval($_GET['delblog']))."'");
mysql_query("DELETE FROM `blog_komm` where blog = '".check(intval($_GET['delblog']))."'");
header ('Location: ?');
}
}
// Выводим папки :)
if (strpos ($cat['refer'],"|") !== false){
$record=split("|", $cat['refer']);
$num=count($record)-1;
for ($i=1;$i<$num;$i++){
if($i>=$num)break;
$adr=$record[$i];
$cat0=mysql_fetch_array(mysql_query("select * from blogs where tip = 'cat' and `name_lat` = '$adr';"));
$put .= '»<a href="cat.php?id='.$cat0['id'].'">'.$cat0['name'].'</a>';
}
if($cat['name'])$catn = '»'.$cat['name'];
echo $div4.'<a href="cat">Категории</a>'.$put.$catn.''.$div9;
} else {
echo $div4.'Категории'.$div9;
}
///////////////////////////////////////////////////
echo '<dl></dl>';
if($cat['adds']==1){
if(empty($_GET['order']))$order = 'time';
else $order = check($_GET['order']);
echo 'Сортировать по: '; // ,'rur-Деньги'
$arr = array('time-Время','name-Имя','yes-Рейтинг','chit-Просмотры');
foreach($arr as $v){
list ($o,$n) = explode('-',$v);
if($order!=$o)echo '<a href="?order='.$o.'">'.$n.'</a>|';
else echo ''.$n.'|';
}
if($order == 'time') $order1 = '`time` DESC';
elseif($order == 'name') $order1 = '`name` DESC';
elseif($order == 'chit') $order1 = '`chit` DESC';
elseif($order == 'yes') $order1 = '`yes` DESC ,`no` ASC';
echo '<br /><br />';
}else{
$order1 = '`pos` ASC';
}
$q = mysql_query("select * from blogs where refid = '".$cat['id']."' and html = 0 order by ".$order1.";");
if (mysql_affected_rows() == 0) {
echo "Блогов пока нет<br/>";
} else {
$max = 10;
$k_post=mysql_result(mysql_query("select COUNT(*) from blogs WHERE refid = '".$cat['id']." and html = 0';"),0);
$k_page=k_page($k_post,$max);
$page=page($k_page);
$start=$max*$page-$max;
$q2 = mysql_query("select * from `blogs` WHERE refid = '".$cat['id']."' and html = 0 order by ".$order1." limit $start, $max;");
$d==1;
while($a = mysql_fetch_array($q2)){
$d++;
if(is_integer($d / 2)) echo '<div class="second_name">'; else echo $div2;
if($a['tip']=='msg'){
$cat=mysql_fetch_array(mysql_query("select * from blogs where `id` = '".$a['refid']."';"));
if($level>=5)$moders = "<a href="/blogs/edit.php?blog=".$a['id']."">[Ред.]</a>|<a href="?delblog=".$a['id']."">[Удал.]</a>";
echo "<img src="img/blog2.png" alt=""/> <b><a href="/blogs/".$a['id']."">".$a['name']."</a></b> (".times($a['time']).") $moders $div9".$a['about']."<br/><img src="img/next.gif" alt=""/> <a href="/blogs/".$a['id']."">Читать полностью</a><dt></dt>
<img src="img/comments.gif" alt=""/> <a href="".$a['id']."?komm">Комментарии</a>(".mysql_result(mysql_query("select count(*) as num from blog_komm where `blog` = '".$a['id']."'"),0).")
<br />
<img src="img/ico_inte.png" alt=""/> Автор: ".nik($a['user_id'])."<br />";
if ($a['klych'] != ''){
echo '<img src="img/tag.gif" alt=""/> ';
$record=split(",", $a['klych']);
$num=count($record);
if(!isset($s))$s=1;
$max=round(($num/10)+0.45);
$p==1;
for ($i=0;$i<$num;$i++){
$p++;
$adr=$record[$i];
if($p>2) $zp = ', '; else $zp = '';
echo '<a href="/blogs/search.php?s=key&msg='.$adr.'">'.$adr.'</a>'.$zp;
}
}
echo '<dl></dl>';
}elseif($a['tip']=='cat'){
/*$g = mysql_fetch_array(mysql_query ("select count(id) as num from blogs where refid='$a[id]';"));
$numg = $g["num"];
if($a['adds']!=1) $numg = $numg.' разд.';
else if($a['adds']==1) $numg = $numg.' блогов';*/
$name_lat = rus_lat(rus_utf_tolower(del($a['name'])));
$catyy = mysql_fetch_array(mysql_query('SELECT count(*) FROM `blogs` WHERE `refer` LIKE "%'.$a['name_lat'].'%" and `tip` = "cat";')); //".$catyy[0]."/
$msg = mysql_fetch_array(mysql_query('SELECT count(*) FROM `blogs` WHERE `refer` LIKE "%'.$a['name_lat'].'%" and `tip` = "msg" and html = 0;'));
if($level>=7)echo "<a href="/blogs/admin.php?mod=editr&id=".$a['id'].""><img src="img/folder_table.png" alt=""/> </a>";
else echo "<img src="img/folder_table.png" alt=""/> ";
echo "<a href="cat.php?id=".$a['id'].""><b>".$a['name']."</b></a> (".$msg[0].")<br /><small>".$a['about']."</small>$div9";
}
}
if ($k_page>1){
echo '<br /><dl><dt></dt></dl>';
str("?order=$order&",$k_page,$page); // Вывод страниц
echo '<br /><dl><dt></dt></dl>';
}
}
if($level>=7){
echo '<br /><br />*<a href="/blogs/admin.php?mod=addr&id='.$cat['id'].'">Добавить категорию</a><br />';
}
echo '<br />';
echo $div1.'<a href="index.php">Блоги</a>'.$div9;
include_once (H.'shaxty/foot.php');
?>