hello,
I must receive an xml file with http_post.
my pb is that the xml file can contains some line than :
<line1>L'ASSURANCE N'EST PAS COMPRISE</line1>
instead of
<line1>L'ASSURANCE N'EST PAS COMPRISE</line1>
and i don't know how to solve my pb !
I try to use :
while(list($indice,$valeur) = each($HTTP_POST_VARS))
but i never see my complete file !
the complete post is :
"AUTH_USER=username&AUTH_PASS=password&AUTH_XML=".$data
All is ok for AUTH_USER, AUTH_PASS, but wrong for AUTH_XML
Thanks for your help
Bernard
http_post ... receive
Moderator: General Moderators
http_post
I have always the probleme :
My input data is :
<?xml version="1.0"?>
<Line1>L'ASSURANCE DE TRANSPORT N'EST PAS A COUVRIR </Line1>
while(list($indice,$valeur) = each($_POST))
{
$valeur=html_entity_decode ($valeur,ENT_NOQUOTES, "ISO-8859-15");
print "VALEUR=".$valeur."\n";
}
The resultat is :
VALEUR=<?xml version=\"1.0\"?>
<Line1>L
My input data is :
<?xml version="1.0"?>
<Line1>L'ASSURANCE DE TRANSPORT N'EST PAS A COUVRIR </Line1>
while(list($indice,$valeur) = each($_POST))
{
$valeur=html_entity_decode ($valeur,ENT_NOQUOTES, "ISO-8859-15");
print "VALEUR=".$valeur."\n";
}
The resultat is :
VALEUR=<?xml version=\"1.0\"?>
<Line1>L
You need to parse the XML file first (use XPath or XLST) - have a look at these threads:
viewtopic.php?t=20644
viewtopic.php?t=19668
Some tutorials on XML and PHP are here.
Once you've extracted the values from the XML-file, you can use html_entity_decode on them.
viewtopic.php?t=20644
viewtopic.php?t=19668
Some tutorials on XML and PHP are here.
Once you've extracted the values from the XML-file, you can use html_entity_decode on them.
receive
Hi,
I give you my complete code, before calling the parser.
I don't understand what is wrong !
Thanks for your kindness and your help
.. and excuse me for my vey bad English .....
Bernard
I give you my complete code, before calling the parser.
I don't understand what is wrong !
Thanks for your kindness and your help
.. and excuse me for my vey bad English .....
Bernard
Code: Select all
<?php
// sender.php
//1) PROGRAM USE TO SEND DATA TO THE SERVER (CLIENT)
$fic=$argv[1];
$fp = fopen($fic,"r");
$data="";
$data=fread($fp,filesize($fic));
fclose($fp);
$postvars="AUTH_USER=username&AUTH_PASS=password&AUTH_XML=".$data;
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, "http://bpinf.dyndns.org/receive");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
?>
2) THE DATA (passed as argv[1] to sender.php)
<?xml version="1.0"?>
<ImportantRemarks>
<Line1>L'ASSURANCE DE TRANSPORT N'EST PAS A COUVRIR </Line1>
</ImportantRemarks>
1) PROGRAM USE TO RECEIVE DATA
<?php
// index.php
// is username ok ?
if (!isset($HTTP_POST_VARS['AUTH_USER']))
{
$buffaux="*NOK* USER ABSENT <br>\n";
print $buffaux;
exit(1);
}
else
{
$zuser = $HTTP_POST_VARS['AUTH_USER'];
if ($zuser <> "userrname")
{
$buffaux="*NOK* USER INVALIDE ".$zuser."<br>\n";
print $buffaux;
exit(1);
}
}
// is password ok ?
if (!isset($HTTP_POST_VARS['AUTH_PASS']))
{
$buffaux="*NOK* PASSWORD ABSENT <br>\n";
print $buffaux;
exit(1);
}
else
{
$zpass = $HTTP_POST_VARS['AUTH_PASS'];
if ($zpass <> "password")
{
$buffaux="*NOK* PASSWORD INVALIDE ".$zpass."<br>\n";
print $buffaux;
exit(1);
}
}
// Controle si presence du fichier xml
if (!isset($HTTP_POST_VARS['AUTH_XML']))
{
$buffaux="*NOK* FICHIER ABSENT <br>\n";
print $buffaux;
exit(1);
}
else
{
$zfic = $HTTP_POST_VARS['AUTH_XML'];
$zfic = str_replace('"', '"', $zfic);
}
$today=date("YmdHis");
$file = "xml.".$today.".tmp";
// All is ok, now we can parse the file
$fp = fopen($file, "w");
fputs($fp, $zfic);
fclose($fp);
// call the parser (when the data is received, the parser work fine)
// but if the data contain characters like ', the data is not received correctly
print "*OK* <br>\n";
exit(0);
?>