<?php
/*******************************************************************************
** File : xml_view.php **
** Author : G.Ramkumar **
** Description : Xml view **
** Date : 14/07/2005 **
** Last Modified : 02/08/2005 **
** PHP Version : 5.0.3 **
** **
*******************************************************************************/
include('db/dbconnect.php');
include('translate.php');
$lang=$_REQUEST['lang'];
$id=$_REQUEST['cat_id'];
$comdate=date("Y-m-d")." ".date("H:i:s");
include("spotnews_qry.php");
$comp_id=$xml_id_new_S.$xml_id_S;
include("readalso_qry.php");
$comp_id_r=$xml_id_new_r.$xml_id_r;
include("allnews_qry.php");
$newid_X=trim($tot_all_news__,",");
$id_X=trim($tot_all_news__,",");
if($id_X!="")
{
$xml_qry="select * from rssurl_newsitem where url_newsitem_id in ($id_X) order by pubtime desc";
$xml_res=$pg_sql->query_pass($xml_qry,"4");
}
if($newid_X!="")
{
$xml_qry_new="select * from new_newsitem where newsitem_id in ($newid_X) order by pubdate,hour desc";
$xml_res_new=$pg_sql->query_pass($xml_qry_new,"4");
}
if($id!=""){
$rss_cat_name="select * from category where category_id='$id'";
$rss_cat_name_res=$pg_sql->query_pass($rss_cat_name,"4");
$rss_catname=$rss_cat_name_res[0]['category_name'];
}
if($rss_catname!="")
{
$theme=eregi_replace("é","é",$rss_catname);
$titarr = array("Ã","£","Â","µ","¼","·","´","³","¦","¶","®","¯","¥","¨","°","¿","Ä","¡","¢",
"¤","©","§","ª","«","¬","±","²","¹","¸",
"º","»","½","¾","À","Á","Å","Æ","Ç",
"È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ",
"Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û",
"Ü","Ý","Þ","ß","à","á","ã","ä","å","æ",
"ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò",
"ó","ô","õ","ö","÷","ø","ù","ú","û","ý","þ","ÿ","&#euro;","­"," ","ü","","","â","",
"","","","","","","","","","");
$titarr_ = array("Ã","£","Â","µ","¼","·","´","³","¦","¶","®","¯","¥","¨","°","¿","Ä","¡","¢","¤",
"©","§","ª","«","¬","±","²","¹","¸","º","»","½",
"¾","À","Á","Â","Å","Æ","Ç","È","É","Ê","Ë","Ì",
"Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø",
"Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","ã","ä","å",
"æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò",
"ó","ô","õ","ö","÷","ø","ù","ú","û","ý","þ","ÿ","€","­"," ","ü","‘","’","â","-",
"Œ","œ","Š","š","Ÿ","ƒ","—","–");
$t=0;
foreach ($titarr as $element)
{
$theme = eregi_replace($element,$titarr_[$t],$theme);
$t = $t + 1;
}
if(!is_dir($lang))
mkdir($lang,0777);
$filename=$lang."/".strtolower($rss_catname).".xml";
$theme_name="/".strtolower($theme);
}else{
$filename=$lang.".xml";
}
header("Content-type: text/xml");
$xmlString='<?xml version="1.0" encoding="utf-8"?>';
$xmlString .='<rss version="2.0">';
$xmlString .="<channel>";
$xmlString .="<title>http://news.belgium.be".$theme_name."</title>";
$xmlString .="<link>http://news.belgium.be</link>";
$xmlString .="<image><title>News.Belgium.be</title><url>http://newsmanager.avalonnet.com/images/logo_final_en.jpg</url>";
$xmlString .="<link>http://news.belgium.be</link>";
$xmlString .="</image>";
$xmlString .="<description>news.belgium.be</description>";
$xmlString .="<language>".$lang."</language>";
for($i=0;$i<count($xml_res);$i++)
{
$title=str_replace("||","'",$xml_res[$i][news_title]);
$image=trim($xml_res[$i][image]);
$desc=str_replace("||","'",$xml_res[$i][description]);
$url=trim($xml_res[$i][url]);
$author=trim($xml_res[$i][author]);
//$pubdate=trim($xml_res[$i][pubdate]);
$pubdate=trim($xml_res[$i][pubtime]);
$timestamp = $pubdate;
$formatted = date('r', strtotime($timestamp));
$lastdate=trim($xml_res[$i][last_builddate]);
$hour=trim($xml_res[$i][hour]);
$copy=trim($xml_res[$i][copyright]);
$webmaster=trim($xml_res[$i][webmaster]);
$title=eregi_replace("é","é",$title);
$title=eregi_replace("É","é",$title);
$title=str_replace("â","",$title);
$title=str_replace("â","",$title);
$title=str_replace("â¦","...",$title);
$title=str_replace("â","",$title);
$title=str_replace("â","",$title);
$desc=str_replace("â","",$desc);
$desc=str_replace("â","",$desc);
$desc=eregi_replace("é","é",$desc);
$desc=eregi_replace("É","é",$desc);
$desc=eregi_replace("&#xEB;","ë",$desc);
$arr1 = array("Ã","£","Â","µ","¼","·","´","³","¦","¶","®","¯","¥","¨","°","¿","Ä","¡","¢",
"¤","©","§","ª","«","¬","±","²","¹","¸",
"º","»","½","¾","À","Á","Å","Æ","Ç",
"È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ",
"Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û",
"Ü","Ý","Þ","ß","à","á","ã","ä","å","æ",
"ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò",
"ó","ô","õ","ö","÷","ø","ù","ú","û","ý","þ","ÿ","&#euro;","­"," ","ü","","","â","",
"","","","","","","","");
$arr2 = array("Ã","£","Â","µ","¼","·","´","³","¦","¶","®","¯","¥","¨","°","¿","Ä","¡","¢","¤",
"©","§","ª","«","¬","±","²","¹","¸","º","»","½",
"¾","À","Á","Â","Å","Æ","Ç","È","É","Ê","Ë","Ì",
"Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø",
"Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","ã","ä","å",
"æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò",
"ó","ô","õ","ö","÷","ø","ù","ú","û","ý","þ","ÿ","€","­"," ","ü","‘","’","â","-",
"Œ","œ","Š","š","Ÿ","ƒ","—","–");
$j=0;
foreach ($arr1 as $element)
{
$title = eregi_replace($element,$arr2[$j],$title);
$desc = eregi_replace($element,$arr2[$j],$desc);
$j = $j + 1;
}
if($title!="")
{
$xmlString .="<item>";
$xmlString .="<title>".$title."</title>";
if($desc!="")
$xmlString .="<description>".$desc."</description>";
if($url!=""){
if(strstr($url,"http://"))
$url=$url;
else
$url="http://".$url;
$xmlString .="<link>".$url."</link>";
}
if($pubdate!="")
$xmlString .="<pubDate>".$formatted."</pubDate>";
$xmlString .="</item>";
}
}
for($j=0;$j<count($xml_res_new);$j++)
{
$title_=trim($xml_res_new[$j]['title']);
$intro_=trim(strip_tags($xml_res_new[$j]['introtext']));
$desc_=trim($xml_res_new[$j]['body']);
$new_desc=strip_tags($intro_)."<br>".strip_tags($desc_);
$pubdate_=trim($xml_res_new[$j]['pubdate']);
$hour_=trim($xml_res_new[$j]['hour']);
if($hour_!="")
$hour_=$hour_.":00";
$pubtime_=$pubdate_." ".$hour_;
$timestamp_=date("r",strtotime($pubtime_));
$url_=trim($xml_res_new[$j]['url_external']);
$new_desc=str_replace(" "," ",$new_desc);
$title_=eregi_replace("é","é",$title_);
$title_=eregi_replace("É","é",$title_);
$title_=str_replace("â","",$title_);
$title_=str_replace("â","",$title_);
$title_=str_replace("â¦","...",$title_);
$title_=str_replace("â","",$title_);
$title_=str_replace("â","",$title_);
$new_desc=str_replace("â","",$new_desc);
$new_desc=str_replace("â","",$new_desc);
$new_desc=eregi_replace("é","é",$new_desc);
$new_desc=eregi_replace("É","é",$new_desc);
$new_desc=eregi_replace("&#xEB;","ë",$new_desc);
$arr1_ = array("Ã","£","Â","µ","¼","·","´","³","¦","¶","®","¯","¥","¨","°","¿","Ä","¡","¢",
"¤","©","§","ª","«","¬","±","²","¹","¸",
"º","»","½","¾","À","Á","Å","Æ","Ç",
"È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ",
"Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û",
"Ü","Ý","Þ","ß","à","á","ã","ä","å","æ",
"ç","è","é","ê","ì","í","î","ï","ð","ñ","ò",
"ó","ô","õ","ö","÷","ø","ù","ú","û","ý","þ","ÿ","&#euro;","­"," ","ü","","","â","",
"","","","","");
$arr2_ = array("Ã","£","Â","µ","¼","·","´","³","¦","¶","®","¯","¥","¨","°","¿","Ä","¡","¢","¤",
"©","§","ª","«","¬","±","²","¹","¸","º","»","½",
"¾","À","Á","Â","Å","Æ","Ç","È","É","Ê","Ë","Ì",
"Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø",
"Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","ã","ä","å",
"æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò",
"ó","ô","õ","ö","÷","ø","ù","ú","û","ý","þ","ÿ","€","­"," ","ü","‘","’","â","-",
"Œ","œ","Š","š","Ÿ","ƒ","—");
$k=0;
foreach ($arr1_ as $element_)
{
$title_ = eregi_replace($element_,$arr2_[$k],$title_);
$new_desc = eregi_replace($element_,$arr2_[$k],$new_desc);
$k = $k + 1;
}
$xmlString .="<item>";
$xmlString .="<title>".$title_."</title>";
$xmlString .="<description>".$new_desc."</description>";
if($url_!=""){
if(strstr($url_,"http://"))
$url_=$url_;
else
$url_="http://".$url_;
$xmlString .="<link>".$url_."</link>";
}
if($pubdate_!="")
$xmlString .="<pubDate>".$timestamp_."</pubDate>";
$xmlString .="</item>";
}
$xmlString .="</channel>";
$xmlString .="</rss>";
$filePtr=fopen($filename,"wb");
if(is_writeable($filename))
{
fwrite($filePtr,$xmlString);
fclose($filePtr);
}
header("Location: ".$filename);
exit;
?>