//session_start();
include 'config.php';
include 'database.php';
include 'functions.php';
//$The_Cat_ID = intval($_GET['catid']);
$Cat_Style_ID = 1; //intval($_GET['styleid']);
$current_art_start = intval($_GET['art_start']);
$current_art_end = intval($_GET['art_end']);
$show_list_art = intval($_GET['art_list']);
$show_list_cat = intval($_GET['cat_list']);
$result_per_page = 20;
$result_for_first_page = 6;
$search_in = array(0,2,5,6,7,10,11,13,14);
$search_in = "('" . implode("','",$search_in) . "')";
if($current_art_end==0 AND $current_art_start==0)$current_art_end=6;
if(!$Cat_Style_ID OR $Cat_Style_ID<=0 OR $Cat_Style_ID==0)
{
if($The_Cat_ID==0)
{
$Cat_Style_ID=1;
}else if(!$The_Cat_ID)
{
$Cat_Style_ID=1;
}
else if($The_Cat_ID >0)
{
$sql ="SELECT `Cat_Style_ID` , `Cat_Name` FROM `categories` WHERE `Cat_ID` = $The_Cat_ID LIMIT 0 , 1 ";
$result =mysql_query($sql);
$rows =mysql_fetch_array($result);
//$number_of_rows =mysql_num_rows($result);
//if($number_of_rows ==0 ) $Cat_Style_ID=1;
//echo $number_of_rows;
$Cat_Style_ID =$rows['Cat_Style_ID'];
$page_title =$rows['Cat_Name'];
$Current_Cat_Name =$rows['Cat_Name'];
if(!$Cat_Style_ID or $Cat_Style_ID=="" or $Cat_Style_ID<=0)$Cat_Style_ID =1;
}else
{
$Cat_Style_ID=1;
}
//echo "
sid1=".$Cat_Style_ID;
}
if($The_Cat_ID<=0) $link_cat="" ; else $link_cat ="&catid=$The_Cat_ID";
if($Cat_Style_ID<=1) $link_style="" ; else $link_cat ="&styleid=$Cat_Style_ID";
if($show_list_cat !=1) $link_list_cat="" ; else $link_list_cat ="&cat_list=$show_list_cat";
if($show_list_art !=1) $link_list_art="" ; else $link_list_art ="&art_list=$show_list_art";
$next_art_start = $current_art_end+1;
$next_art_end = $current_art_end+$result_per_page;
$link_next_page = "index.php?art_start=".$next_art_start."&art_end=".$next_art_end.$link_cat.$link_style.$link_list_cat.$link_list_art;
$prev_art_start = $current_art_start-$result_per_page;
$prev_art_end = $current_art_end-$result_per_page;
if($prev_art_start<0 OR $prev_art_end<=0)
{
$prev_art_start = 0;
$prev_art_end = $result_for_first_page;
}
$link_prev_page = "index.php?art_start=".$prev_art_start."&art_end=".$prev_art_end.$link_cat.$link_style.$link_list_cat.$link_list_art;
/*
else
{
$Cat_Style_ID=1;
}
*/
//echo "
sid2=".$Cat_Style_ID;
if($show_list_art !=1)
{
$sql="
SELECT `Art_ID` , `Art_Name` , `Art_Shot` , `Art_Pic` , `Art_Show` , `Art_Writer` , `Art_Date` , Art_ID + Art_Show AS priority
FROM `articles`
WHERE `Art_Cat_ID` IN $search_in
ORDER BY priority DESC
LIMIT $current_art_start , $current_art_end ";
//echo $sql;
$result=mysql_query($sql);
$number_of_rows =mysql_num_rows($result);
$count=0;
$List_ID=0;
while ($rows = mysql_fetch_array($result))
{
/*
$Art_ID[$List_ID] =$rows['Art_ID'];
//echo $Cat_Parent_ID[$List_ID];
$Art_Cat_ID[$List_ID] =$rows['Art_Cat_ID'];
//echo $Cat_Parent_ID[$List_ID];
$Art_Style_ID[$List_ID] =$rows['Art_Style_ID'];
$Art_Name[$List_ID] =$rows['Art_Name'];
$Art_Shot[$List_ID] =$rows['Art_Shot'];
$Art_Long[$List_ID] =$rows['Art_Long'];
$Art_Writer[$List_ID] =$rows['Art_Writer'];
$Art_Pic[$List_ID] =$rows['Art_Pic'];
$Art_File[$List_ID] =$rows['Art_File'];
$Art_Date[$List_ID] =$rows['Art_Date'];
$Art_Show[$List_ID] =$rows['Art_Show'];
*/
$all_rows[$count] =$List_ID;
$count++;
$all_rows[$count] =$rows['Art_ID'];
$count++;
$all_rows[$count] =$rows['Art_Name'];
$count++;
$all_rows[$count] =$rows['Art_Pic'];
if($rows['Art_Pic']=="")$all_rows[$count] ="default.jpg";
$count++;
$all_rows[$count] =$rows['Art_Shot'];
$count++;
$all_rows[$count] =$rows['Art_Date'];
$count++;
$all_rows[$count] =$rows['Art_Writer'];
$count++;
$List_ID=$List_ID+1;
}
$file_name = "templates/main/$Cat_Style_ID/show_cat_art_rows.html";
$search_text = array('{List_ID}','{Art_ID}','{Art_Name}','{Art_Pic}','{Art_Shot}','{Art_Date}','{Art_Writer}');
$replace_with = $all_rows;
$all_art_rows_html = make_template_rows($file_name,$search_text,$replace_with,$number_of_rows);
$file_name = "templates/main/$Cat_Style_ID/show_cat_art.html";
$search_text = array('{rows}','{art_start}','{art_end}','{link_next_page}','{link_prev_page}');
$replace_with = array($all_art_rows_html,$current_art_start,$current_art_end,$link_next_page,$link_prev_page);
$all_art_rows_html = make_template_rows($file_name,$search_text,$replace_with,$number_of_rows);
//echo sizeof($all_rows);
}else
{
$all_art_rows_html = "";
}
$file_name ="templates/main/$Cat_Style_ID/show_cat.html";
$search_text =array('{art_rows}','{cat_rows}','{current_cat_name}');
$replace_with =array($all_art_rows_html,$all_cat_rows_html,$Current_Cat_Name);
$page_content =make_template($file_name,$search_text,$replace_with);
$counter=thecounter();
$file_name ="templates/main/$Cat_Style_ID/pages.html";
$search_text =array('{page_content}','{page_title}','{page_description}','{total_visits}');
$replace_with =array($page_content,"",strip_tags($Art_Shot),$counter['visits']);
echo make_template($file_name,$search_text,$replace_with);
?>