include "../rcontrol/config.php";
include "../rcommon/database.php";
$remove = array("\x92", "\x96","\x97","&");
$query="SELECT * FROM ynfx_mis_istats WHERE visibility = '1' AND status ='a' AND company !='1' order by id desc limit 50";
$result=mysql_db_query($DATABASE,$query);
$num = mysql_num_rows($result);
if ($num != 0)
{
$file= fopen("statistics.xml", "wb");
$_xml .="\r\n";
$_xml .="\r\n";
$_xml .="\r\n";
$_xml .="YarnsandFibers Textile Statistics\r\n";
$_xml .="http://www.yarnsandfibers.com\r\n";
$_xml .="YarnsandFibers Textile Statistics\r\n";
$_xml .="en\r\n";
$_xml .="[email protected]\r\n";
$_xml .="YarnsandFibers\r\n";
$_xml .="".date("r")."\r\n";
$_xml .="".date("r")."\r\n";
$_xml .="\r\n";
$_xml .="YarnsandFibers Textile Statistics\r\n";
$_xml .="http://www.yarnsandfibers.com/preferredsupplier/images/nhp/ynfx_logo.png\r\n";
$_xml .="http://www.yarnsandfibers.com/mis/\r\n";
$_xml .="\r\n";
for($i=0; $i<$num; $i++)
{
$id = mysql_result($result,$i,"id");
$title = mysql_result($result,$i,"header");
$body = substr(mysql_result($result,$i,"body"),0,300);
str_replace($remove,"",$body);
$date_ir = mysql_result($result,$i,"date");
$country = mysql_result($result,$i,"country");
$COUNTRY_news = unserialize($country);
$sql="select name from ynfx_mis_country where id = '$COUNTRY_news[0]' and enable='1'";
$result1=mysql_db_query($DATABASE,$sql);
if(mysql_error()) error("Unexpected ERROR");
$country = mysql_result($result1,0,"name");
$product = mysql_result($result,$i,"product");
$PROD_news = unserialize($product);
$sql="select name from ynfx_mis_product where id = '$PROD_news[0]' and enable='1'";
$result3=mysql_db_query($DATABASE,$sql);
if(mysql_error()) error("Unexpected ERROR");
$product = mysql_result($result3,0,"name");
$_xml .="- \r\n";
$_xml .="".str_replace($remove,"",$title)."\r\n";
$_xml .="http://www.yarnsandfibers.com/mis/indexis.php\r\n";
$_xml .="".$product."\r\n";
$_xml .="".date("r",$date_ir)."\r\n";
$_xml .="".str_replace($remove,"",$body)."\r\n";
$_xml .="
\r\n";
}
$_xml .="\r\n";
$_xml .="\r\n";
fwrite($file, $_xml);
fclose($file);
}
header("location:statistics.xml");
echo "XML has been written. View the XML.";
?>