63 lines
2.0 KiB
PHP
63 lines
2.0 KiB
PHP
<?php
|
|
if(isset($_POST['admin1_save'])||isset($_POST['admin1_edit'])){
|
|
$name = htmlspecialchars(addslashes($_POST['name']));
|
|
$descr = htmlspecialchars(addslashes($_POST['descr']));
|
|
$pos = (int)htmlspecialchars(addslashes($_POST['pos']));
|
|
$status = (int)htmlspecialchars(addslashes($_POST['status']));
|
|
$dostup = (int)htmlspecialchars(addslashes($_POST['dostup']));
|
|
}
|
|
if(isset($_POST['admin1_save'])){
|
|
$sql = 'INSERT INTO `'.$TB['razdels'].'` VALUES (0,"'.$name.'","'.$descr.'",'.$pos.','.$status.','.$dostup.')';
|
|
$rez = $DB->QUR($sql);
|
|
if(!$rez['err']){
|
|
$msg['msg'][]='Запись создана!';
|
|
}else{
|
|
$msg['err'][]='Запись не создана! Ошибка БД!!!';
|
|
}
|
|
$des = 'show';
|
|
}
|
|
if(isset($_POST['admin1_edit'])){
|
|
$id = (int)$_POST['id'];
|
|
$sql = 'UPDATE `'.$TB['razdels'].'` SET name="'.$name.'",descr="'.$descr.'",pos='.$pos.',status='.$status.',dostup='.$dostup.' WHERE id='.$id.' LIMIT 1';
|
|
$rez = $DB->QUR($sql);
|
|
if(!$rez['err']){
|
|
$msg['msg'][]='Запись отредактирована!';
|
|
}else{
|
|
$msg['err'][]='Запись не отредактирована! Ошибка БД!!!';
|
|
}
|
|
$des = 'show';
|
|
}
|
|
if($des == 'dele'){
|
|
$id = (int)$_GET['id'];
|
|
$rez = $DB->QUR_SEL('DELETE FROM '.$TB['razdels'].' WHERE id='.$id.' LIMIT 1');
|
|
//echo '<pre>'.print_r($rez,1).'</pre>';exit();
|
|
$des = 'show';
|
|
}
|
|
if($des == 'add'){
|
|
|
|
}
|
|
if($des == 'edit'){
|
|
$id = (int)$_GET['id'];
|
|
$sql = 'SELECT * FROM '.$TB['razdels'].' WHERE id='.$id.'';
|
|
$rez = $DB->QUR_SEL($sql);
|
|
if($rez){
|
|
$smarty->assign('item',$rez[1]);
|
|
}else{
|
|
$des = 'show';
|
|
}
|
|
}
|
|
if($des == 'show'){
|
|
$items=array();
|
|
$sql = 'SELECT * FROM '.$TB['razdels'].' ORDER BY pos';
|
|
$rez = $DB->QUR_SEL($sql);
|
|
if($rez){
|
|
foreach($rez as $key => $val)if($key){
|
|
$items[] = $val;
|
|
}
|
|
}
|
|
$smarty->assign('items',$items);
|
|
}
|
|
|
|
$smarty->assign('page',$page);
|
|
$smarty->assign('des',$des);
|
|
$maincontent = $smarty->fetch('tpl_rejtnpr_main.html'); |