db = $db; $mod -> install(); if ( ID ){ unset( $a ); $a['id'] = ID; $page_cat = $db -> get_massiv( 'pages', $a, '', 1 ); $smarty->assign( 'pages_cat', $page_cat ); if ( @$_POST['title'] ){ unset( $_POST['ok'] ); unset( $a ); if ( $_POST['public'] == 'on' ) $_POST['public'] = 1; else $_POST['public'] = 0; $a['title'] = $_POST['txt']; $id = $db -> get_val( 'pages', $a, 'id' ); if( @$_FILES['img']['tmp_name'] ){ $_POST['img'] = $mod -> upload( $_FILES ); unlink( MYDIR . '/img/pages_cat/' . $page_cat[0]['img'] . '.jpg' ); } if ( !$id ) $db -> update( 'pages', ID, $_POST ); header( 'Location: /page_cat/' . ID ); } }else{ if ( @$_POST['title'] ){ unset( $_POST['ok'] ); //Узнаем, есть ли категория unset( $a ); if ( $_POST['public'] == 'on' ) $_POST['public'] = 1; else $_POST['public'] = 0; // $a['json'] = $_POST['txt']; // $id = $db -> get_val( 'pages_cat', $a, 'id' ); if( @$_FILES['img']['tmp_name'] ) $_POST['img'] = $mod -> upload( $_FILES ); unset($json); $json['json']=serialize($_POST); $json['user_id']=$_SESSION['user_id']; $json['parent']=0; $json['public']=$_POST['public']; $db -> add( 'pages', $json ); //header( 'Location: /page_cat/' ); } } $db -> get_massiv ( 'pages', '', 'json' ); $smarty -> assign( 'list', $db -> result ); ?>