File size: 3.58Kb
<?php
define('_IN_JOHNCMS', 1);
$headmod = 'board';
$textl = 'Доска объявлений';
require_once '../incfiles/core.php';
require_once '../incfiles/head.php';
$req = mysql_query("SELECT * FROM `board_settings`");
while ($res = mysql_fetch_row($req)) $set_board[$res[0]] = $res[1];
$array = array(
'add_ad',
'edit_ad',
'del_ad',
'list',
'view',
'my',
'archive'
);
if (in_array($act, $array))
{
require_once 'includes/' . $act . '.php';
}
else
{
if ($id)
$category = mysql_fetch_assoc(mysql_query("SELECT `name` FROM `board_categories` WHERE `id` = $id"));
echo (!$id) ? '<div class="phdr">Доска объявлений</div>' : '<div class="phdr"><a href="index.php">Доска объявлений</a> | ' . $category['name'] . '</div>';
$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `board_categories` WHERE `cat_id` = " . ($id ? $id : 0) . ""), 0);
if ($total)
{
$req = mysql_query("SELECT * FROM `board_categories` WHERE `cat_id` = " . ($id ? $id : 0) . " ORDER BY `id` ASC LIMIT $start, $kmess");
$i = 0 ;
while ($res = mysql_fetch_assoc($req))
{
echo $i % 2 ? '<div class="list1"><img src="' . $home . '/images/board1.gif" alt="img">' : '<div class="list2"><img src="' . $home . '/images/board2.gif" alt="img">';
if ($res['cat_id'] == 0)
$total_cat = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `board_categories` WHERE `cat_id` = " . $res['id'] . ""), 0);
else
$total_ads = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `board_ads` WHERE `cat_id` = " . $res['id'] . " AND `status` = 1"), 0);
echo ' <a href="' . ($res['cat_id'] == 0 ? './?id=' . $res['id']: './?act=list&id=' . $res['id']) . '">' . functions::checkout($res['name'], 0, 0) . '</a> [' . ($res['cat_id'] == 0 ? $total_cat : $total_ads) . ']';
echo ($rights >= 7) ? '<div class="sub"><a href="admin.php?act=edit_cat&id=' . $res['id'] . '">Редактировать</a> | <a href="admin.php?act=del_cat&id=' . $res['id'] . '">Удалить</a></div>' : null;
echo '</div>';
$i++;
}
}
else
{
echo '<div class="menu">Категории еще не созданы</div>';
}
echo '<div class="phdr">Всего: ' . $total . '</div>';
if ($total > $kmess)
echo '<div class="topmenu">' . functions::display_pagination(($id ? './?id=' . $id . '&' : '?'), $start, $total, $kmess) . '</div>';
$archive = mysql_result(mysql_query("SELECT COUNT(*) FROM `board_ads` WHERE `status` = 2"), 0);
echo ($archive) ? '<div class="rmenu"><img src="../images/del.png" width="12" height="12" alt="archive"> <a href="./?act=archive">Архив</a> [' . $archive . ']</div>' : null;
}
echo ($id) ? '<div class="menu"><a href="./">К доске</a></div>' : null;
if ($rights >= 7)
{
$total_mod = mysql_result(mysql_query("SELECT COUNT(*) FROM `board_ads` WHERE `status` = 0"), 0);
echo '<div class="gmenu">';
echo (!$id) ? '<a href="admin.php?act=new_cat">Создать категорию</a>' : '<a href="admin.php?act=new_cat&id=' . $id . '">Создать подкатегорию</a>';
echo ($total_mod) ? '<br><a href="admin.php?act=mod">На модерации</a> (<span class="red">' . $total_mod . '</span>)' : null;
echo '<br><a href="admin.php?act=settings">Настройки</a>'
. '</div>';
}
require_once '../incfiles/end.php';