133 lines
3.9 KiB
PHP
133 lines
3.9 KiB
PHP
<?php
|
|
session_start();
|
|
$maincontent = '';
|
|
$smarty->assign('razdel','rejtdek');
|
|
if(isset($_GET['page'])){ $page=$_GET['page']; }else{ $page='main'; }
|
|
if(isset($_GET['des'])){ $des=$_GET['des']; }else{ $des='show';}
|
|
|
|
$TB['razdels'] = $ST['dbpf'].'_rejtdek_razdels';
|
|
$TB['items'] = $ST['dbpf'].'_rejtdek_items';
|
|
$TB['polyas'] = $ST['dbpf'].'_rejtdek_polyas';
|
|
$TB['itemspolyas'] = $ST['dbpf'].'_rejtdek_itemspolyas';
|
|
$TB['saves'] = $ST['dbpf'].'_rejtdek_saves';
|
|
$TB['otchgods'] = $ST['dbpf'].'_rejt_otchgods';
|
|
|
|
{$sql = 'CREATE TABLE IF NOT EXISTS `'.$TB['razdels'].'` (
|
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
`name` varchar(255) NOT NULL,
|
|
`descr` varchar(255) NOT NULL,
|
|
`pos` tinyint(4) NOT NULL,
|
|
`status` tinyint(4) NOT NULL,
|
|
`dostup` tinyint(4) NOT NULL,
|
|
PRIMARY KEY (`id`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;';
|
|
$rez = $DB->QUR($sql);}
|
|
{$sql = 'CREATE TABLE IF NOT EXISTS `'.$TB['items'].'` (
|
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
`id_razdel` int(11) NOT NULL,
|
|
`name` text NOT NULL,
|
|
`tip` tinyint(4) NOT NULL,
|
|
`pos` tinyint(4) NOT NULL,
|
|
`formuls` varchar(255) NOT NULL,
|
|
`descr` text NOT NULL,
|
|
PRIMARY KEY (`id`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;';
|
|
$rez = $DB->QUR($sql);}
|
|
{$sql = 'CREATE TABLE IF NOT EXISTS `'.$TB['polyas'].'` (
|
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
`id_item` int(11) NOT NULL,
|
|
`name` text NOT NULL,
|
|
`pos` tinyint(4) NOT NULL,
|
|
`value` DOUBLE NOT NULL,
|
|
PRIMARY KEY (`id`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;';
|
|
$rez = $DB->QUR($sql);}
|
|
{$sql = 'CREATE TABLE IF NOT EXISTS `'.$TB['itemspolyas'].'` (
|
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
`id_item` int(11) NOT NULL,
|
|
`name` varchar(255) NOT NULL,
|
|
`pos` tinyint(4) NOT NULL,
|
|
`value` varchar(255) NOT NULL,
|
|
PRIMARY KEY (`id`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;';
|
|
$rez = $DB->QUR($sql);}
|
|
{$sql = 'CREATE TABLE IF NOT EXISTS `'.$TB['saves'].'` (
|
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
`data_c` int(11) NOT NULL,
|
|
`id_user` int(11) NOT NULL,
|
|
`id_razdel` int(11) NOT NULL,
|
|
`id_items` int(11) NOT NULL,
|
|
`id_itemspolyas` int(11) NOT NULL,
|
|
`id_polyas` int(11) NOT NULL,
|
|
`value` text NOT NULL,
|
|
`pos` tinyint(4) NOT NULL,
|
|
PRIMARY KEY (`id`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;';
|
|
$rez = $DB->QUR($sql);}
|
|
|
|
function rejt_get_razdels($id=0){
|
|
GLOBAL $TB,$DB; $out=array();
|
|
if($id){
|
|
$sql = 'SELECT * FROM '.$TB['razdels'].' WHERE id='.$id.' LIMIT 1';
|
|
}else{
|
|
$sql = 'SELECT * FROM '.$TB['razdels'].' ORDER BY pos';
|
|
}
|
|
$rez = $DB->QUR_SEL($sql);
|
|
if($rez){
|
|
foreach($rez as $key => $val)if($key){
|
|
$out[]=$val;
|
|
}
|
|
}
|
|
return $out;
|
|
}
|
|
function rejt_get_items($id=0){
|
|
GLOBAL $TB,$DB; $out=array();
|
|
if($id){
|
|
$sql = 'SELECT * FROM '.$TB['itemspolyas'].' WHERE id='.$id.' LIMIT 1';
|
|
}else{
|
|
$sql = 'SELECT * FROM '.$TB['itemspolyas'].' ORDER BY id_item,pos';
|
|
}
|
|
$rez = $DB->QUR_SEL($sql);
|
|
if($rez){
|
|
foreach($rez as $key => $val)if($key){
|
|
$sql1 = 'SELECT * FROM '.$TB['items'].' WHERE id='.$val['id_item'].'';
|
|
$rez1 = $DB->QUR_SEL($sql1);
|
|
if($rez1){
|
|
$sql2 = 'SELECT * FROM '.$TB['razdels'].' WHERE id='.$rez1[1]['id_razdel'].'';
|
|
$rez2 = $DB->QUR_SEL($sql2);
|
|
if($rez2){
|
|
$rez1[1]['razdel'] = $rez2[1];
|
|
}
|
|
$val['item'] = $rez1[1];
|
|
}
|
|
$out[]=$val;
|
|
}
|
|
}
|
|
return $out;
|
|
}
|
|
|
|
|
|
|
|
//if($_SESSION['user']['status']==99){
|
|
|
|
if($page=='admin'){
|
|
$smarty->assign('page',$page);
|
|
$smarty->assign('des',$des);
|
|
$maincontent = $smarty->fetch('tpl_rejtdek_main.html');
|
|
}
|
|
if($page=='admin1'){//УПРАВЛЕНИЕ ОСНОВНЫМИ РАЗДЕЛАМИ
|
|
include 'rejtdek_admin1.php';
|
|
}
|
|
if($page=='admin2'){//УПРАВЛЕНИЕ ПОДРАЗДЕЛАМИ
|
|
include 'rejtdek_admin2.php';
|
|
}
|
|
if($page=='admin3'){//УПРАВЛЕНИЕ полями в ПОДРАЗДЕЛАХ
|
|
include 'rejtdek_admin3.php';
|
|
}
|
|
if($page=='admin4'){//УПРАВЛЕНИЕ значениями в полях
|
|
include 'rejtdek_admin4.php';
|
|
}
|
|
if($page=='main'){
|
|
include 'rejtdek_anketa.php';
|
|
}
|
|
//}else{$maincontent = 'в разработке';}
|