<?php
error_reporting(0);
include_once("modules/EcmProductB2Bs/xml_template.php");
$xml=xml($_REQUEST['record']);
$file="cache/upload/product_xml_".str_replace(" ","_",str_replace(".","_",microtime())).".xml";
fopen($file);
file_put_contents($file,$xml);
chmod($file,0777);

$remote_file="/xml_products/".$r['code']."_".date("YmdHis").".xml";
$conn_id = ftp_connect("www.leobite.com");
$login_result = ftp_login($conn_id, "ftpleobite.leobite.com", "wrT%I9g");

if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
 //echo "successfully uploaded $file\n";
} else {
 //echo "There was a problem while uploading $file\n";
}

ftp_chmod($conn_id, 0755, $remote_file);
$GLOBALS['db']->query("update ecmproducts_log set sent='1' where date_entered<='".date("Y-m-d H:i:s")."' and ecmproduct_id='".$_REQUEST['record']."'");
//header("Location: ".$file);
header("Location: index.php?module=EcmProductB2Bs&action=DetailView&record=".$_REQUEST['record']);
?>