if( is_numeric($sections[1]) and is_numeric($sections[2]) ){
$date=$sections[1].'/'.$sections[2].'/01';
$where_str="date_format(date, '%m%Y') = '".dateformat('mY',$date)."' ";
}elseif( is_numeric($sections[1]) ){
$where_str="id='".escape($sections[1])."'";
$article=true;
}elseif( $sections[1] and $sections[2] ){
$where_str="page_name='".escape($sections[2])."'";
$article=true;
}elseif( $sections[1] ){
$where_str="category='".escape($sections[1])."'";
}else{
//get most recent month
$last_entry=sql_query("SELECT * FROM news ORDER BY date DESC LIMIT 1");
$date=$last_entry[0]['date'];
$where_str="date_format(date, '%m%Y') = '".dateformat('mY',$date)."'";
}
$content=sql_query("SELECT * FROM news N
WHERE
display=1 AND
$where_str
ORDER BY date DESC
");
$news=sql_query("SELECT * FROM news WHERE
display=1
ORDER BY date DESC
");
$url='http://'.$_SERVER['HTTP_HOST'].'/'.$request;
$url.='&title='.$content[0]['headline'];
?>