'.print_r($_SESSION['niceditor'],1).''; if (!file_exists($_SESSION['niceditor']['path1'])){ //echo '1'; mkdir($_SESSION['niceditor']['path1'], 0766); } if (!file_exists('./upload/blog/'.$_SESSION['user']['id'].'')){ //echo '2'; mkdir('./upload/blog/'.$_SESSION['user']['id'], 0766); } if (isset($_POST['blog_add'])){//СОХРАНЕНИЕ ЗАПИСИ $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['comment'])) $comment=1; else $comment=0; if (isset($_POST['zakrep'])) $zakrep=1; else $zakrep=0; $sql = 'INSERT INTO '.$ST['dbpf'].'_blogs VALUES (0,'.mktime().','.mktime().','.$id_category.','.$id_user.',"'.$title.'","'.$text_f.'",1,0,'.$comment.','.$zakrep.')'; $rez=$DB->QUR_SEL($sql); if(!$rez['err']){ $form['msg']='Запись добавлена'; unset($_GET['des']); }else{ $form['err'][]='Ошибка добавления данных!'; } } if (isset($_POST['blog_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['comment'])) $comment=1; else $comment=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'].''; $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']='blog_add'; $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; } } } } if ($_GET['des']=='edit'){//ФОРМА РЕДАТКИРОВАНИЯ $regim='aded'; $blogs=array();// $form=array(); $form['ftitle']=$ST['page']['name'] = 'Редактирование записи'; $form['btn_url']='blog_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'].''; $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; } } } } } }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); $sql1='SELECT * FROM '.$ST['dbpf'].'_blogs WHERE id_user='.$id_user.$wh.' 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_blog_write.html'); } } else{//ПРОСМОТР БЛОГА $blog=array(); $ST['page']['name'] = 'Блоги'; $blog['breadcrumb']=array();//навигационная лента $blog['breadcrumb'][0]['url']='/'; $blog['breadcrumb'][0]['name']='Главная'; $blog['breadcrumb'][1]['url']='/blog/'; $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++; } } } {//ТЭГИ $blog['tags']=array(); $blog['tags'][0]['name']='образование'; $blog['tags'][0]['url']='образование'; $blog['tags'][1]['name']='обучение'; $blog['tags'][1]['url']='обучение'; $blog['tags'][2]['name']='тестирование';$blog['tags'][2]['url']='тестирование'; $blog['tags'][3]['name']='студенты'; $blog['tags'][3]['url']='студенты'; $blog['tags'][4]['name']='заочники'; $blog['tags'][4]['url']='заочники'; $blog['tags'][5]['name']='очное'; $blog['tags'][5]['url']='очное'; } {//АРХИВЫ $blog['arch']=array(); $blog['arch'][0]['url']='/arch/9-2013/'; $blog['arch'][0]['month']='сент'; $blog['arch'][0]['year']='2013'; $blog['arch'][1]['url']='/arch/10-2013/'; $blog['arch'][1]['month']='окт'; $blog['arch'][1]['year']='2013'; $blog['arch'][2]['url']='/arch/11-2013/'; $blog['arch'][2]['month']='ноя'; $blog['arch'][2]['year']='2013'; } $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']='/blog/'; $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('