0) { $tmp = $q; $where = array(); while($v = array_shift($tmp)) { $where[] = '(path='.$db->SetString($cpath).' AND filename='.$db->SetString($v).')'; $cpath .= $v.'/'; } $dirs = $db->select('news_folders', 'fid,path,filename,title', implode(' OR ', $where), 'fid', 'path'); foreach($dirs as $k=>$v) { $app['bcrumb'][] = array(bbcode($v['title']), $url.'news'.$v['path'].$v['filename'].'/'); $apath = $v['path'].$v['filename'].'/'; $citem = $k; } } if($apath!==$cpath) { $item = substr($cpath, strlen($apath), -1); if(!$is_item=$db->fetchrec('news_items', 'fid='.$citem.' AND filename='.$db->SetString(substr($cpath, strlen($apath), -1)))) goto404(); } else if(!empty($_GET['q']) && substr($_GET['q'], -1)!='/') redirect($url.'news/'.$_GET['q'].'/'); // render body if($is_item) { $app['bcrumb'][] = array(bbcode($is_item['title']), $url.'news'.$cpath.$is_item['filename']); $d = array(); $d['title'] = bbcode($is_item['title']); $d['date'] = create_date($is_item['date']); $d['content'] = $is_item['content']; $d['attach'] = ''; if(!empty($is_item['attach']) && is_file('./files/'.$is_item['attach'])) { $d['attach'] = $tpl->parse_var('news-file.html', array('filename'=>$is_item['attach'], 'filesize'=>create_size(filesize('./files/'.$is_item['attach'])), 'fileurl'=>$url.'news/files/'.$is_item['attach'])); } $app['content'] = $tpl->parse_var('news-view.html', $d); } else { $dirs = $db->select('news_folders', '*', 'path='.$db->SetString($cpath), 'fid', 'title'); $tmp = ''; foreach($dirs as $k=>$v) { $d = array(); $d['url'] = $url.'news'.$cpath.$v['filename'].'/'; $d['title'] = bbcode($v['title']); $tmp .= $tpl->parse_var('dirs-item.html',$d); } $app['content'] .= empty($tmp) ? '' : $tpl->parse_var('dirs-list.html',array('dirs'=>$tmp)); $news = $db->select('news_items', '*', 'fid='.$citem, 'nid', 'title'); $tmp = ''; foreach($news as $k=>$v) { $d = array(); $d['url'] = $url.'news'.$cpath.$v['filename']; $d['title'] = bbcode($v['title']); $tmp .= $tpl->parse_var('news-item.html',$d); } $app['content'] .= empty($tmp) ? '' : $tpl->parse_var('news-list.html',array('news'=>$tmp)); $app['content'] = empty($app['content']) ? $tpl->parse('news-empty.html') : $app['content']; } require_once('../adm/core.public-stop.php'); die();