include "../rcontrol/config.php";
include "../rcommon/database.php";
$remove = array("&","\x92", "\x96","\x97","\x80","\x9c","\x80,","\x99","�");
//fakhruddin: for adding paid news to all xml file
$status_ = "status ='a' or status='r'"; // r for paid news a for free
//end
$query="Select * from ynfx_mis_ir WHERE visibility='1' AND ($status_) order by id desc limit 15";
$result=mysql_db_query($DATABASE,$query);
$num = mysql_num_rows($result);
//echo $num;
if ($num != 0)
{
$file= fopen("reports.xml", "wb");
$_xml .="\r\n";
$_xml .="\r\n";
$_xml .="\r\n";
$_xml .="YarnsandFibers Textile Reports\r\n";
$_xml .="http://www.yarnsandfibers.com\r\n";
$_xml .="YarnsandFibers Textile Reports\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 Reports\r\n";
$_xml .="http://www.yarnsandfibers.com/preferredsupplier/images/nhp/ynfx_logo.png\r\n";
$_xml .="http://www.yarnsandfibers.com/revamp_ir/index.php\r\n";
$_xml .="\r\n";
for($i=0; $i<$num; $i++)
{
$id = mysql_result($result,$i,"id");
$title = mysql_result($result,$i,"header");
$description =mysql_result($result,$i,"small_desc");
$date_ir = mysql_result($result,$i,"date_ir");
$country = mysql_result($result,$i,"country");
$source = mysql_result($result,$i,"source");
$SOURCE_reports = unserialize($source);
$COUNTRY_reports = unserialize($country);
$sql="select name from ynfx_mis_country where id = '$COUNTRY_reports[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_reports = unserialize($product);
$subproduct = mysql_result($result,$i,"subproduct");
$SUBPRODUCT_reports = unserialize($subproduct);
foreach($PROD_reports as $p_id)
{
$sql_n="SELECT name,id FROM `ynfx_mis_product` WHERE `id` ='$p_id' and enable='1'";
$result_n=mysql_db_query($DATABASE,$sql_n);
if(mysql_error()) error("Unexpected ERROR");
$field = mysql_fetch_array($result_n);
$p_type = $field['name'];
$source_id = $field['id'];
}
if(eregi('N',$product))
{
foreach($SUBPRODUCT_reports as $p_id)
{
$sql_n="SELECT name,id FROM `ynfx_mis_subproducts` WHERE `id` ='$s_id' and enable='1'";
$result_n=mysql_db_query($DATABASE,$sql_n);
if(mysql_error()) error("Unexpected ERROR");
$field = mysql_fetch_array($result_n);
$p_type = $field['name'];
$source_id = $field['id'];
}
}
foreach($SOURCE_reports as $s_id)
{
$sql_n="SELECT name,id FROM `ynfx_mis_ir_source` WHERE `id` ='$s_id' and enable='1'";
$result_n=mysql_db_query($DATABASE,$sql_n);
if(mysql_error()) error("Unexpected ERROR");
$field = mysql_fetch_array($result_n);
$type = $field['name'];
$source_id = $field['id'];
$id.$cid .= $id.$type;
}
$f_type=$id.$cid;
if(eregi('Textiles Intelligence',$f_type)){$st1=1;}
if(eregi('YarnsandFibers Free',$f_type)){$st1=2;}
if(eregi('YarnsandFibers Paid',$f_type)){$st1=3;}
if(eregi('Google',$f_type)){$st1=4;}
if(eregi('Special Reports',$f_type)){$st1=5;}
if($st1==1){
$value="Textiles Intelligence";
$source="Textiles Intelligence";
}
if($st1==2){$value="FREE MEMBERS";
$source="YarnsandFibers Free";
}
if($st1==3){
$value="PAID MEMBERS";
$source="YarnsandFibers Paid";
}
if($st1==4){
$value="FREE REPORTS";
$source="Google";
}
if($st1==5){
$value="Specials Reports";
$source="Special Reports";
}
$_xml .="- \r\n";
$_xml .="".str_replace($remove,"",$title)."\r\n";
$_xml .="http://www.yarnsandfibers.com/revamp_ir/report_fullstory.php?id=$id";
$_xml .="\r\n";
$_xml .="".$p_type."\r\n";
$_xml .="".date("r",$date_ir)."\r\n";
$remove = array("\x92", "\x96","\x97","&");
$_xml .="".str_replace($remove," ",$description)."...\r\n";
$_xml .="
\r\n";
}
$_xml .="\r\n";
$_xml .="\r\n";
fwrite($file, $_xml);
fclose($file);
}
//header("location:reports.xml");
?>