Location: PHPKode > projects > News Manager - RSS aggregator > newsmanager/xml_all.php
<?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('dbconnect.php');

$lang=$_REQUEST['lang'];
$id__=$_REQUEST['id'];

//$xml_qry="select * from rssurl_newsitem where language='$lang' order by url_newsitem_id desc";
$xml_qry="select * from rssurl_newsitem where rss_channel_id=$id__ order by url_newsitem_id desc";
$xml_res=$pg_sql->query_pass($xml_qry,"4");

 header("Content-type: text/xml");

	 $xmlString='<?xml version="1.0" encoding="utf-8"?>';
	 $xmlString .='<rss version="2.0">';
     $xmlString .="<channel>";
     $xmlString .="<title>news.belgium.be</title>";
     $xmlString .="<link>http://newsmanager.avalonnet.com</link>";
     $xmlString .="<description>news.belgium.be</description>";
     $xmlString .="<language>".$xml_res[0]['language']."</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]);
     $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);

	 $desc=str_replace("‘","‘",$desc);
	 $desc=str_replace("’","’",$desc);
	 $desc=eregi_replace("é","é",$desc);
     $desc=eregi_replace("É","é",$desc);



          $arr1 = array("&Atilde;","&pound;","&Acirc;","&micro;","¼","&middot;","&acute;","&sup3;","&brvbar;","&para;","&reg;","&macr;","&yen;","&uml;","&deg;","&iquest;","&Auml;","&iexcl;","&cent;",
		         "&curren;","&copy;","&sect;","&ordf;","&laquo;","&not;","&plusmn;","&sup2;","&sup1;","&cedil;",
                 "&ordm;","&raquo;","½","¾","&Agrave;","&Aacute;","&Aring;","&AElig;","&Ccedil;",
                 "&Egrave;","&Eacute;","&Ecirc;","&Euml;","&Igrave;","&Iacute;","&Icirc;","&Iuml;","&ETH;","&Ntilde;",
                 "&Ograve;","&Oacute;","&Ocirc;","&Otilde;","&Ouml;","&times;","&Oslash;","&Ugrave;","&Uacute;","&Ucirc;",
                 "&Uuml;","&Yacute;","&THORN;","ß","à","á","&atilde;","&auml;","&aring;","&aelig;",
                 "ç","è","&eacute;","&ecirc;","&igrave;","&iacute;","&icirc;","&iuml;","&eth;","&ntilde;","&ograve;",
                 "&oacute;","ô","&otilde;","&ouml;","&divide;","&oslash;","&ugrave;","&uacute;","&ucirc;","&yacute;","&thorn;","&yuml;","£","&shy;","&nbsp;","ü","‘","’","â");

		   $arr2 = array("&#195;","&#163;","&#194;","&#181;","&#188;","&#183;","&#180;","&#179;","&#166;","&#182;","&#174;","&#175;","&#165;","&#168;","&#160;","&#191;","&#196;","&#161;","&#162;","&#164;",
	             "&#169;","&#167;","&#170;","&#171;","&#172;","&#177;","&#178;","&#185;","&#184;","&#186;","&#187;","&#189;",
                 "&#190;","&#192;","&#193;","&#194;","&#197;","&#198;","&#199;","&#200;","&#201;","&#202;","&#203;","&#204;",
                 "&#205;","&#206;","&#207;","&#208;","&#209;","&#210;","&#211;","&#212;","&#213;","&#214;","&#215;","&#216;",
                 "&#217;","&#218;","&#219;","&#220;","&#221;","&#222;","&#223;","&#224;","&#225;","&#227;","&#228;","&#229;",
                 "&#230;","&#231;","&#232;","&#233;","&#234;","&#235;","&#236;","&#237;","&#238;","&#239;","&#240;","&#241;","&#242;",
                 "&#243;","&#244;","&#245;","&#246;","&#247;","&#248;","&#249;","&#250;","&#251;","&#253;","&#254;","&#255;","&#8364;","&#173;","&#176;","&#252;","&#8216;","&#8217;","&#226;");


                   $j=0;
					foreach ($arr1 as $element)
					{
						$title = eregi_replace($element,$arr2[$j],$title);
						$desc = eregi_replace($element,$arr2[$j],$desc);
						$j = $j + 1;

					}
/*
echo $title."<br>";
echo $desc."<br>";
echo "<hr>";
*/

	if($desc!="" && $title!="")
	{
	     $xmlString .="<item>";
		 $xmlString .="<title>".$title."</title>";
		 $xmlString .="<description>".$desc."</description>";
		 if($url!="")
		   $xmlString .="<link>".$url."</link>";
		 if($image!="")
			$xmlString .="<image>".$image."</image>";
		 if($author!="")
			$xmlString .="<author>".$author."</author>";
		 if($pubdate!="")
			$xmlString .="<pubdate>".$pubdate."</pubdate>";
		 if($pubdate!="")
			$xmlString .="<lastbuilddate>".$lastdate."</lastbuilddate>";
		 if($hour!="")
			$xmlString .="<hour>".$hour."</hour>";
		 if($copy!="")
			$xmlString .="<copyright>".$copy."</copyright>";
		 if($webmaster!="")
		   $xmlString .="<webmaster>".$webmaster."</webmaster>";

           $xmlString .="</item>";
      }

   }


     $xmlString .="</channel>";
     $xmlString .="</rss>";

	 echo $xmlString ;


?>
Return current item: News Manager - RSS aggregator