Файл: wapxl.ru/categorii.php
Строк: 94
<?php
require 'shaxty.php';
$align = 'left';
$title = 'Катагории сайтов каталога';
include_once ('shaxty/head.php');
echo '<div class="col-md-8 col-sm-12 col-xs-12"><div class="panel panel-default">';
echo '<div class="panel-heading"> <b>Управление инфой</b></div>
<div class="panel-body">';
switch($mod){
default:
$count_sites = core:: $db -> querySingle("SELECT count(*) FROM `categorii`;");
$k_page=func::k_page($count_sites,$max);
$page=func::page($k_page);
$start=$max*$page-$max;
$r = core:: $db -> query("SELECT * FROM `categorii` ORDER BY id DESC;");
while ($row= $r -> fetch()) {
$count_sites = core:: $db -> querySingle("SELECT count(*) FROM `sites` WHERE `cat` LIKE '%|".$row['id']."|%';");
echo '
<div class="xl"><table style = "width: 100%;"><tr><td style = "width: 90%;"> <a href="/'.$row['name_lat'].'"><b>'.$row['name'].'</b></a> <a href="?mod=edit&id='.$row[id].'" class="href">[Изм]</a> <br/> '.$row['abaut'].'<br/> <u>'.$row['key'].'</u></td><td style = "width: 10px; text-align: center;"><span class="pr">('.$count_sites.')</span></td></tr></table></div>
';
}
if(core::$user['level']>=9){
echo '<div class="content">';
echo '<dl></dl><a href="?mod=addcat" class="link"> Добавить Категорию</a>';
echo '</div>';
}
break;
case 'addcat':
echo '<div class="content">';
if(core::$user['level']<9)func::errors('<b>Доступ закрыт</b>');
if(!isset($_POST['submit'])){
echo '<form method="post" action="?mod='.$mod.'&'.SID.'" name="auth">';
echo '<b>Категория:</b><br/>
<input type="text" name="cat" title="cat" value="" <br/>';
echo '<br /><b>Описание:</b>
<br /><textarea cols="50" rows="3" name="abaut"></textarea><br/>';
echo '<br /><b>Ключи:</b>
<br /><textarea cols="50" rows="3" name="key"></textarea><br/>';
echo '<br /><input type="submit" class="ibutton" value="Добавить" name="submit"/></form><br /><br />';
}else{
$cat = isset($_POST['cat']) ? func::checkin($_POST['cat']) : '';
$abaut = isset($_POST['abaut']) ? func::checkin($_POST['abaut']) : '';
$key = isset($_POST['key']) ? func::checkin($_POST['key']) : '';
function delcat($text = NULL)
{
$text=str_replace('&','', $text);
$text=str_replace('ndash;','', $text);
$text=str_replace(' ','-', $text);
$text=str_replace('"','', $text);
$text=str_replace("'",'', $text);
$text=str_replace('&','', $text);
$text=str_replace('$','', $text);
$text=str_replace('>','', $text);
$text=str_replace('<','', $text);
$text=str_replace('~','', $text);
$text=str_replace('`','', $text);
$text=str_replace('#','', $text);
$text=str_replace('*','', $text);
$text=str_replace(''','', $text);
$text=str_replace('/','_', $text);
$text=str_replace('—','-', $text);
return $text;
}
$name_lat=func::rus_utf_tolower(func::retranslit(delcat($cat))); //name_lat
$dbi = core::$db -> prepare("INSERT INTO `categorii` SET `name`=?,`name_lat`=?,`abaut`=?,`key`=?");
$dbi -> execute($cat,$name_lat,$abaut,$key);
header('Location: ?');
}
echo '</div>';
break;
case 'edit':
echo '<div class="content">';
$a = core:: $db -> queryFetch("SELECT * FROM `categorii` WHERE `id`=? LIMIT 1;", array($id));
if (!isset($a['id']))func::errors('<b>Такой категории не существует</b>');
if(core::$user['level']<9)func::errors('<b>Доступ закрыт</b>');
if(!isset($_POST['submit'])){
echo '<form method="post" action="?mod='.$mod.'&id='.$id.'&'.SID.'" name="auth">';
echo '<b>Категория:</b><br/>
<input type="text" name="cat" title="cat" value="'.$a['name'].'" <br/>';
echo '<br /><b>Описание:</b>
<br /><textarea cols="50" rows="3" name="abaut">'.$a['abaut'].'</textarea><br/>';
echo '<br /><b>Ключи:</b>
<br /><textarea cols="50" rows="3" name="key">'.$a['key'].'</textarea><br/>';
echo '<br /><input type="submit" class="ibutton" value="Добавить" name="submit"/></form><br /><br />';
}else{
$cat = isset($_POST['cat']) ? func::checkin($_POST['cat']) : '';
$abaut = isset($_POST['abaut']) ? func::checkin($_POST['abaut']) : '';
$key = isset($_POST['key']) ? func::checkin($_POST['key']) : '';
function delcat($text = NULL)
{
$text=str_replace('&','', $text);
$text=str_replace('ndash;','', $text);
$text=str_replace(' ','-', $text);
$text=str_replace('"','', $text);
$text=str_replace("'",'', $text);
$text=str_replace('&','', $text);
$text=str_replace('$','', $text);
$text=str_replace('>','', $text);
$text=str_replace('<','', $text);
$text=str_replace('~','', $text);
$text=str_replace('`','', $text);
$text=str_replace('#','', $text);
$text=str_replace('*','', $text);
$text=str_replace(''','', $text);
$text=str_replace('/','_', $text);
$text=str_replace('—','-', $text);
return $text;
}
$name_lat=func::rus_utf_tolower(func::retranslit(delcat($cat))); //name_lat
$dbi = core::$db -> prepare("UPDATE `categorii` SET `name`=?,`name_lat`=?,`abaut`=?,`key`=? WHERE `id`=?");
$dbi -> execute($cat,$name_lat,$abaut,$key,$id);
header('Location: ?');
}
echo '</div>';
break;
}
echo '<br /></div></div>';
include_once ('shaxty/foot.php');
?>