'.print_r($_SESSION['niceditor'],1).''; if (!file_exists($_SESSION['niceditor']['path1'])){ //echo '1'; mkdir($_SESSION['niceditor']['path1'], 0766); } if (!file_exists('./upload/instruction/'.$_SESSION['user']['id'].'')){ //echo '2'; mkdir('./upload/instruction/'.$_SESSION['user']['id'], 0766); } if (isset($_POST['save_help'])){//СОХРАНЕНИЕ ЗАПИСИ $id = (int)$_POST['id']; $id_category = (int)$_POST['id_category']; $title = get_data_fu($_POST['title']); $text_f = addslashes($_POST['text_f']); //$id_user = $_SESSION['user']['id']; if (isset($_POST['status'])) $status=1; else $status=0; $sql = 'INSERT INTO '.$ST['dbpf'].'_help VALUES (0,'.mktime().','.mktime().','.$id_category.',"'.$title.'","'.$text_f.'",'.$status.', 0)'; /*echo $sql; exit;*/ $rez=$DB->QUR_SEL($sql); if(!$rez['err']){ $form['msg']='Запись добавлена'; unset($_GET['des']); }else{ $form['err'][]='Ошибка добавления данных!'; } } if (isset($_POST['help_edit'])){//РЕДАКТИРОВАНИЕ ЗАПИСИ $id = (int)$_POST['id']; $id_category = (int)$_POST['id_category']; $title = get_data_fu($_POST['title']); $text_f = addslashes($_POST['text_f']); $id_user = $_SESSION['user']['id']; if (isset($_POST['status'])) $status=1; else $status=0; if (isset($_POST['zakrep'])) $zakrep=1; else $zakrep=0; //$sql = 'UPDATE '.$ST['dbpf'].'_blogs SET data_u='.mktime().',id_category='.$id_category.',id_user='.$id_user.',title="'.$title.'",text_f="'.$text_f.'",comment='.$comment.', zakrep='.$zakrep.' WHERE id='.$id.' AND id_user='.$_SESSION['user']['id'].''; $sql = 'UPDATE '.$ST['dbpf'].'_help SET data_u='.mktime().',id_category='.$id_category.',title="'.$title.'",text_f="'.$text_f.'",status="'.$status.'" WHERE id='.$id.''; //echo $sql; $rez=$DB->QUR_SEL($sql); if(!$rez['err']){ $form['msg']='Запись изменена'; unset($_GET['des']); }else{ $form['err'][]='Ошибка изменения данных!'; } } if (isset($_GET['des'])){//ОБРАБОТКА ДЕЙСТВИЙ не требующих ответа от пользователя if($_GET['des']=='del'){//Удаление блога $form['id']=(int)$_GET['id']; $sql='SELECT * FROM '.$ST['dbpf'].'_blogs WHERE id='.$form['id'].''; $rez=$DB->QUR_SEL($sql); if($rez){ if ($rez[1]['id_user']==$_SESSION['user']['id']){//Хозяин записи if($rez[1]['status']==1) $DB->QUR('UPDATE '.$ST['dbpf'].'_blogs SET status=0 WHERE id='.$form['id'].' LIMIT 1'); if($rez[1]['status']==0) $DB->QUR('DELETE FROM '.$ST['dbpf'].'_blogs WHERE id='.$form['id'].' LIMIT 1'); }else{ $DB->QUR('UPDATE '.$ST['dbpf'].'_blogs SET status=0 WHERE id='.$form['id'].' LIMIT 1'); } } unset($_GET['des']); } if($_GET['des']=='aprove'){//Активация блога $form['id']=(int)$_GET['id']; $DB->QUR('UPDATE '.$ST['dbpf'].'_blogs SET status=1 WHERE id='.$form['id'].' LIMIT 1'); unset($_GET['des']); } } if (isset($_GET['des'])){//ОБРАБОТКА ДЕЙСТВИЙ if ($_GET['des']=='add'){//ФОРМА ДОБАВЛЕНИЯ $regim='aded'; $blogs=array();// $form=array(); $form['ftitle']=$ST['page']['name'] = 'Добавление записи'; $form['btn_url']='save_help'; $form['btn_name']='Добавить запись'; $form['id']=0; /*$sql1='SELECT * FROM '.$ST['dbpf'].'_blogs_category ORDER BY pos'; $rez1=$DB->QUR_SEL($sql1); if($rez1){ foreach($rez1 as $key1 => $val1)if($key1){ if (in_array($val1['id'],$_SESSION['user']['blog']['id_blog_category'])){ $form['categorys'][]=$val1; } } }*/ $sql1='SELECT * FROM '.$ST['dbpf'].'_help_category '; $rez1=$DB->QUR_SEL($sql1); if($rez1){ foreach($rez1 as $key1 => $val1)if($key1){ //if (in_array($val1['id'],$_SESSION['user']['blog']['id_blog_category'])){ $form['categorys'][]=$val1; //} } } } if ($_GET['des']=='edit'){//ФОРМА РЕДАТКИРОВАНИЯ $regim='aded'; $blogs=array();// $form=array(); $form['ftitle']=$ST['page']['name'] = 'Редактирование записи'; $form['btn_url']='help_edit'; $form['btn_name']='Редактировать запись'; $form['id']=(int)$_GET['id']; //$sql='SELECT * FROM '.$ST['dbpf'].'_blogs WHERE id='.$form['id'].' AND id_user='.$_SESSION['user']['id'].''; $sql='SELECT * FROM '.$ST['dbpf'].'_help WHERE id='.$form['id'].''; $rez=$DB->QUR_SEL($sql); if($rez){ $form['title']=out_data_fu($rez[1]['title']); $form['text_f']=out_data_fu($rez[1]['text_f']); $form['comment']=(int)$rez[1]['comment']; $form['zakrep']=(int)$rez[1]['zakrep']; //**************старое $sql1='SELECT * FROM '.$ST['dbpf'].'_blogs_category ORDER BY pos'; $rez1=$DB->QUR_SEL($sql1); if($rez1){ foreach($rez1 as $key1 => $val1)if($key1){ if (in_array($val1['id'],$_SESSION['user']['blog']['id_blog_category'])){ if($val1['id']==$rez[1]['id_category']) $val1['sel']=1; $form['categorys'][]=$val1; } } } //новое $sql1='SELECT * FROM '.$ST['dbpf'].'_help_category '; $rez1=$DB->QUR_SEL($sql1); if($rez1){ foreach($rez1 as $key1 => $val1)if($key1){ //if (in_array($val1['id'],$_SESSION['user']['blog']['id_blog_category'])){ $form['categorys'][]=$val1; //} } } } } }else{ $regim='show'; $form=array(); $blogs=array(); //надо определить записи которые необходимо отобразить пользователю!!! $id_user = $_SESSION['user']['id']; $id_cat = $_SESSION['user']['blog']['id_blog_category']; $id_cats=array(); foreach($id_cat as $key => $val) $id_cats[]=$val; if (count($id_cats)) $wh = ' OR (id_category='.implode(' OR id_category=',$id_cats).')'; else $wh=''; //$pagi=pagination_blog('SELECT * FROM '.$ST['dbpf'].'_blogs WHERE id_user='.$id_user.$wh.'',10); $pagi=pagination_blog('SELECT * FROM '.$ST['dbpf'].'_help ',10); $sql1='SELECT * FROM '.$ST['dbpf'].'_help ORDER BY data_c DESC '.$pagi['limit']; $rez1=$DB->QUR_SEL($sql1); //echo $sql1; if($rez1){ foreach($rez1 as $key1 => $val1)if($key1){ $val1['data_c']=date('H:i:s d.m.Y',$val1['data_c']); $val1['data_u']=date('H:i:s d.m.Y',$val1['data_u']); $val1['title']=out_data_fu($val1['title']); $rez=$DB->QUR_SEL('SELECT * FROM '.$ST['dbpf'].'_blogs_category WHERE id='.$val1['id_category'].' LIMIT 1'); if($rez){ $val1['category'] = $rez[1]['name']; } else $val1['category']='не определили'; $blogs[] = $val1; } } $ST['page']['name'] = 'Просмотр блогов'; } $smarty->assign('form',$form); $smarty->assign('regim',$regim); $smarty->assign('pagination',$pagi); $smarty->assign('blogs',$blogs);//список записей в блоге $maincontent = $smarty->fetch('tpl_instruction_write.html'); } elseif($_GET['page']=='razdel'){ //ИНСТРУКЦИИ РАЗДЕЛЫ $msg = 0; //нет сообщений //добавление нового раздела if (isset($_POST['add_category'])){ $name = addslashes($_POST['name']); $id_main = addslashes($_POST['id_main']); $sql = 'INSERT INTO '.$ST['dbpf'].'_help_category VALUES (0,"'.$name.'",'.$id_main.', 0)'; $rez=$DB->QUR_SEL($sql); $msg = 1; } //все категории $categoryAll = array(); $sql = 'SELECT * FROM '.$ST['dbpf'].'_help_category '; $rez = $DB->QUR_SEL($sql); if($rez){ foreach ($rez as $key => $val) if($key){ $sql_razdel = 'SELECT * FROM '.$ST['dbpf'].'_help_category WHERE id = "'.$val['id_main'].'" '; $rez_razdel = $DB->QUR_SEL($sql_razdel); $val['razdel'] = $rez_razdel[1]['name']; $categoryAll[] = $val; } } /*****/ $smarty->assign('categoryAll',$categoryAll); $smarty->assign('msg',$msg); $maincontent = $smarty->fetch('tpl_instruction_razdel.html'); } } else{//ПРОСМОТР БЛОГА $blog=array(); $ST['page']['name'] = 'Инструкции'; $blog['breadcrumb']=array();//навигационная лента $blog['breadcrumb'][0]['url']='/'; $blog['breadcrumb'][0]['name']='Главная'; $blog['breadcrumb'][1]['url']='/help/'; $blog['breadcrumb'][1]['name']='Инструкции'; $blog['breadcrumb'][1]['active']=1; {//КАТЕГОРИЯ $icons=array(0=>'icon-trophy','icon-plane','icon-pushpin','icon-beaker','icon-bullhorn','icon-trophy','icon-umbrella'); $blog['category']=array(); $sql = 'SELECT * FROM '.$ST['dbpf'].'_blogs_category ORDER BY pos LIMIT 6'; $rez=$DB->QUR_SEL($sql); if($rez){ $i=0; foreach($rez as $key => $val)if($key){ $blog['category'][$i]['url']='/blog/'.$val['alt_name'].'/'; $blog['category'][$i]['name']=''.out_data_fu($val['name']).''; $blog['category'][$i]['icon']=$icons[$i]; $i++; } } } {//ПОСЛЕДНИЕ СООБЩЕНИЯ $blog['latest']=array(); $sql = 'SELECT * FROM '.$ST['dbpf'].'_blogs ORDER BY zakrep, data_c DESC LIMIT 5'; $rez=$DB->QUR_SEL($sql); if($rez){ $i=0; foreach($rez as $key => $val)if($key){ $blog['latest'][$i]['date']=date('H:i:s d.m.Y',$val['data_u']); $blog['latest'][$i]['url']='/blog/'.$val['id'].'/'; $t=img_get_all(out_data_fu($val['text_f'])); $blog['latest'][$i]['img']=$t[0]; $blog['latest'][$i]['text_s']=strip_tags(out_data_fu($val['text_f'])); $i++; } } } $mes=array('01'=>'Январь','02'=>'Февраль','03'=>'Март','04'=>'Апрель','05'=>'Май','06'=>'Июнь','07'=>'Июль','08'=>'Август','09'=>'Сентябрь','10'=>'Октябрь','11'=>'Ноябрь','12'=>'Декабрь'); $day=array('0'=>'Воскресенье','1'=>'Понедельник','2'=>'Вторник','3'=>'Среда','4'=>'Четверг','5'=>'Пятница','6'=>'Суббота'); $color=array(0=>'orange',1=>'green',2=>'red',3=>'yellow',4=>'blue'); if(!isset($_GET['id'])&&!isset($_GET['page'])){//Просмотр всех записей $blog['name']='Инструкции ЭИОС'; $w['id_category']=''; if (isset($_GET['cat'])) { $sql = 'SELECT * FROM '.$ST['dbpf'].'_blogs_category WHERE alt_name="'.get_data_fu($_GET['cat']).'"'; $rez=$DB->QUR_SEL($sql);//echo $sql.mysql_error(); if($rez) { $blog['name']=out_data_fu($rez[1]['name']); $w['id_category']=$rez[1]['id']; } } $blog['breadcrumb']=array();//навигационная лента $blog['breadcrumb'][0]['url']='/'; $blog['breadcrumb'][0]['name']='Инструкции'; $blog['breadcrumb'][1]['url']='/help/'; $blog['breadcrumb'][1]['name']='Инструкции ЭИОС'; $blog['breadcrumb'][1]['active']=1; $WH=''; if($w['id_category']!=''){ if($WH=='') $WH=' AND '; $WH .= 'id_category='.$w['id_category']; } $pagi=pagination_blog('SELECT * FROM '.$ST['dbpf'].'_blogs WHERE status=1'.$WH.'',5); $sql = 'SELECT * FROM '.$ST['dbpf'].'_blogs WHERE status=1'.$WH.' ORDER BY zakrep DESC, data_c DESC '.$pagi['limit']; $rez=$DB->QUR_SEL($sql); //print_r($_GET); echo $sql; if($rez){ $i=0; foreach($rez as $key => $val)if($key){ $blog['posts'][$i]['d_d']=date('d',$val['data_c']); $blog['posts'][$i]['d_m']=$mes[date('m',$val['data_c'])]; $blog['posts'][$i]['d_day']=$day[date('w',$val['data_c'])]; $blog['posts'][$i]['time']=date('H:i',$val['data_c']); $blog['posts'][$i]['view']=$val['views']; if($val['comment']==1) $blog['posts'][$i]['com_kol']=get_comment_kol('blog',$val['id']); else $blog['posts'][$i]['com_kol']=''; $blog['posts'][$i]['url']=$val['id']; $blog['posts'][$i]['name']=out_data_fu($val['title']); $t=get_user($val['id_user']); $blog['posts'][$i]['author']=out_data_fu($t['fio']); $blog['posts'][$i]['img']=''; $blog['posts'][$i]['color']=$color[$i]; $val['text_f'] = str_replace('