header("HTTP/1.0 200 OK");
session_start();
include("path.php");
$path_relativ="../";
include($path."data/amaconfigz.php");
include($path."data/functions_ama.php");
include($path."data/functions.php");
include($path."admin/data/configz.php");
include($path."data/ama_texts.php");
$base_href = $user_base_href;
$pagename = html_entity_decode($mainheadline , ENT_QUOTES);
$_SESSION["session_curentpage"] = "http://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
$base_href1 = str_replace("index.html",'',"http://".$_SERVER["SERVER_NAME"].$_SERVER['PHP_SELF']);
$comaa = str_replace($base_href1,'',"http://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);
$com2 = explode("?",$comaa);
if(preg_match("/\?x=[^&]+/",$comaa,$match)){$_GET["x"]=str_replace("?x=",'',$match[0]);}else {$_GET["x"]='';}
list($comaa,)=explode("?",$comaa);
if(!empty($comaa) && $comaa!='index.html') {
$cale = explode('/',str_replace("_"," ",trim($comaa,'/')));
$exista = preg_match("/^(page [0-9]+.html)$/i",end($cale),$matches);
$exista_article = preg_match("/^(article [0-9]+.html)$/i",end($cale),$matches);
if((end($cale) == '') || $exista || $exista_article || (end($cale) == 'index.html')){
$article = 0;
$curentpage = 0;
if($exista) { $curentpage = intval(str_replace(array("page ",".html") , "" , end($cale))); }
if($exista_article) { $article = intval(str_replace(array("article ",".html"),"",end($cale))); }
$cale = array_slice($cale , 0 , count($cale) - 1);
if(!is_int($curentpage) && !is_int($article)){
header("Location: ".$base_href1.generate_cale_dir($cale)."index.html");
}
}
$calea_buna = test_good_path($cale);
if(is_array($calea_buna)){
$category_name = end($calea_buna);
$cale_link = generate_cale_dir($calea_buna);
}
} else {
$category_name = "New Parenting Articles";
$cale_link = '';
$id_cat = 1;
}
$subcategories = get_subcategory($id_cat);
if(is_array($subcategories)) {
asort($subcategories);
$subcategories_shw .= '
|
'.(($id_cat == 1) ? 'Categories' : 'Subcategories').'
|
';
$x_cat = ceil(count($subcategories)/2);
$i = 0;
foreach($subcategories as $k=>$v) {
if($i%$x_cat==0 && $i!=0) { $subcategories_shw .= ' | '; }
$i++;
if(strlen(trim($v))>0){ $subcategories_shw .= "- ".ucfirst($v)."
"; }
}
$subcategories_shw .= ' |
';
}
if ($subcategories_shw) { $subcategories_show = $subcategories_shw; }
$rowsperpage = $lperpage;
$screen = $curentpage;
$start = $screen*$rowsperpage;
$sql_order = $lorder == 2 ? " ORDER BY `title` " : " ORDER BY `date` DESC";
if (!empty($_GET["x"])) { $sql_search = " AND (`title` LIKE '%".$_GET['x']."%' OR `main_body` LIKE '%".$_GET['x']."%') "; }
if ($adminapproval == 'yes') { $sql_admin = " AND `admin_confirm` = 'a' "; }
if ($id_cat <> 1) {
$sql_cat = " AND `id_parent` = ".$id_cat." ";
$sql_order .= " LIMIT ".$start.",".$rowsperpage;
} else {
$sql_order = " ORDER BY `id` DESC LIMIT 3";
}
$sql = "SELECT SQL_CALC_FOUND_ROWS * FROM ".$mysql_prefix."articles where status='v' ".$sql_cat.$sql_admin.$sql_search.$sql_order;
$result = query($sql);
list($totalrecords) = mysql_fetch_array(query("SELECT FOUND_ROWS()"));
$pages = ceil($totalrecords/$rowsperpage);
if($totalrecords > 0) {
$cale_link_home = $cale_link;
while($row = mysql_fetch_array($result))
{
if ($id_cat == 1) { $cale_link_home = returncale($row["id_parent"]); }
$rows.= ''.
''.$row["title"].'
'.
''.nl2br($row["summary"]).'';
$rows .= "
";
}
}
else
{
if($_GET["x"]) {
$rows="
No articles have been found in this category matching your search";
} else {
$rows="
No articles have been found in this category";
}
}
$_SESSION["id_cat"] = $id_cat;
$add_url = "";
if (empty($_GET["x"])||($_GET["x"]=='')) {
$pager="page_";
$qs='';
} else {
$pager="page_";
$qs="?x=".$_GET["x"];
}
if ($id_cat <> 1) {
$navigator = "
| ";
if($screen>0) {
$navigator.="".$pageprev." ";
}
$navigator .= " | ";
$begin = 0;
$end = $pages;
if($curentpage > 5 && $pages > 10) $begin = $curentpage-5;
if($curentpage<$pages-5 && $pages>10) $end=$curentpage+5;
for($page=$begin;$page<$end;$page++) {
if($page!=$curentpage) {
$navigator.="".($page+1)." | ";
} else {
$navigator.="".($page+1)." | ";
}
}
$navigator = trim($navigator,' | ');
$navigator .= " | ";
if($screen<$pages-1 && $totalrecords>0) {
$navigator.="".$pagenext."";
}
$navigator.=" |
";
}
//generare caregorii principale + nr de link-uri
$query = query("SELECT id,name FROM ".$mysql_prefix."categories where id_parent=1 and status='v' order by name");
$main_categories = "More Directory Categories:
";
$contor = 0;
while ($r_tops = mysql_fetch_array($query)) {
$x_num_list = 0;
$contor++;
if ($contor%2 != 0) { $main_categories.="";$pus=1; }
$main_categories .= "| ".$r_tops["name"]." | ";
if ($contor%2) { $main_categories.=" |
"; $pus=0;}
}
if($pus) { $main_categories.=""; }
$main_categories .= "
";
$title_add = strtoupper($category_name);
if($_GET["x"]) { $title_add = $id_cat <> 1 ? "Search Results in category ".strtoupper($category_name) : "Search Results"; }
if($article == 0) {
print_header($pagename);
$tpl->assign("faction",$base_href1.$cale_link);
$tpl->assign("category_name",$title_add);
$tpl->assign("home_root",return_cale_afisare($calea_buna));
$tpl->assign("subcategories", ($subcategories_show <> '') ? '
'.$subcategories_show : '' );
$tpl->assign("rows",$rows);
$tpl->assign("xvalue",$_GET["x"]);
if(get_cat_status($id_cat)=='h'){$add_url='';}
$tpl->assign("add_url",$add_url);
if($pages>1){$nav=$navigator;}
else{$nav='';}
$tpl->assign("navigator",$nav);
if($id_cat==1){ $main_categories=''; }
$tpl->assign("main_categories",$main_categories);
$tpl->assign("mainpage", html_entity_decode($mainpage , ENT_QUOTES));
$tpl->parse("main.ama");
print_footer();
}
else
{
print_header($pagename);
$sql=query("SELECT * FROM ".$mysql_prefix."articles where id='".$article."'") ;
if(mysql_num_rows($sql)){
$row=mysql_fetch_array($sql);
}
$tpl->assign("faction",$base_href1.$cale_link);
$tpl->assign("title",ucfirst($row["title"]));
$tpl->assign("home_root",return_cale_afisare1($calea_buna));
$tpl->assign("author",$row["author"]);
$date=strtotime($row["updated"]);
$tpl->assign("updated",date("M, d Y H:i:s",$date));
$date=strtotime($row["date"]);
$tpl->assign("created",date("M, d Y H:i:s",$date));
// transform all new lines into
$article_body = ''.nl2br($row["main_body"]).'
';
// add resurce box
$article_body .= '
';
$article_body .= $row["resourcebox"] <> '' ? 'About the Author:
'.transform_url($row["resourcebox"]).'
' : '';
$article_body .= $row["url"] <> '' ? 'Author\'s site: '.$row["url"].'' : '';
$tpl->assign("article" , $article_body);
$tpl->parse("main.amaarticle");
print_footer();
}
?>