require_once $_SERVER['DOCUMENT_ROOT'].'/inc/page_common.php';
$id = $_GET['id']; // ловим от Апача или из GET
if ($id=='') { // Если Апач не отдал, но id= в GET есть
$u = explode ("/", $_SERVER['REQUEST_URI']); // print_r ($u);
parse_str (eregi_replace ('\?', '', $u [2])); // '?' убрать - а то первый парам естся
// if ($id=='') $id = $u[2]; при такой строке первая ловля $_GET['id'] в начале просто не нужна
unset ($u);
}
$id = eregi_replace ('/' , '', $id); // убираем хвостовой/
if ( isset($id) && $id !='') exit (require_once $_SERVER['DOCUMENT_ROOT'].$rootpath.'single.php');
$tpl->define(array('mainidx' => 'all_index.tpl'));
$tpl->assign ('PAGE_TITLE', 'Новости');
$tpl->assign ('KEY_WORDS', 'Новости развитие хронология обзоры');
$tpl->define_dynamic('row', 'mainidx');
$tpl->parse ('ft_head', 'head');
$tpl->FastPrint ('ft_head');
$res_razdel = mysqli_query ("SELECT value,title FROM a_news_razdel ORDER BY id"); // DISTINCT - пришлось убрать после перехода на UTF
$in_page = $cfg ['links_latest'];
while ($rr = mysqli_fetch_array ($res_razdel)) {
if ( ($rr['value']=='drafts') && empty ($_GET ['includedrafts'])) { continue;
}
$tpl->assign(
array(
"NAME_RAZDEL" => $rr['title'],
"ARCHIVE_LINK" => 'archive/' . $rr['value'] . '/'
)
);
$sql = "SELECT *,date_format(date, '%d/%m/%Y') as ddate
FROM a_news_db WHERE razdel='$rr[value]' ORDER BY id DESC
LIMIT $in_page";
$result = mysqli_query ($sql);
if (@mysqli_num_rows ($result) > 0) { while ($r = mysqli_fetch_array ($result)) {
if ($r['urgent'])
{ $dt = '' . $r['ddate'] . '';
$comment = '(важная)';
}else{
$dt = '' . $r['ddate'] . '';
$comment = '';
};
$tpl->assign(
array(
"N_INFO" => $dt,
"N_LINK" => $r ['id'] . '/',
"N_TITLE" => stripslashes ($r ['title']),
"N_COMMENT" => $comment
)
);
$tpl->parse ('ft_mainidx', '.row');
}
$tpl->parse ('ft_mainidx', 'mainidx');
$tpl->FastPrint ('ft_mainidx');
}
$tpl->clear ('ft_mainidx');
}
$tpl->parse ('ft_foot', 'foot');
$tpl->FastPrint ('ft_foot');
?>