import von xml daten mit hilfe von fsockopen implementiert

git-svn-id: svn://svn.cccv.de/engel-system@161 29ba0400-6e00-0410-a75a-ca02368028f8
This commit is contained in:
cookie 2006-11-13 23:40:06 +00:00
parent c8713d0218
commit ffa84f39e7
3 changed files with 51 additions and 20 deletions

5
README
View File

@ -14,3 +14,8 @@ Systemconfig:
./www-ssl/inc/db.php
einstellungen der DB
Achtung: DB user braucht folgende Rechte: SELECT, CREATE, INSERT, ALTER, UPDATE, INDEX, DELETE, DROP
php.ini:
--------
add:
allow_url_fopen = On

View File

@ -38,6 +38,8 @@ $ModemEnable = false;
$Tempdir="/tmp";
//Pentabarf ConferenzDI für UpdateDB
$PentabarXCALurl="https://pentabarf.cccv.de/xcal/conference/<ConfereneceID>";
$PentabarfXMLhost = "pentabarf.cccv.de";
$PentabarfXMLpath = "Xcal/conference/";
$PentabarfXMLEventID = "31";
?>

View File

@ -47,35 +47,59 @@ if( isset($_POST["PentabarfUser"]) && isset($_POST["password"]) && isset($_POST[
{
echo "Update XCAL-File from Pentabarf..";
//user uns password in url einbauen
$FileNameIn = "pentabarf.cccv.de";/*.
$_POST["PentabarfUser"]. ":".
$_POST["password"]. "@".
$_POST["PentabarfURL"];*/
//backup error messeges and delate
$Backuperror_messages = $error_messages;
$fp = fsockopen( $FileNameIn, 443, $errno, $errstr, 30);
$fp = fsockopen( "ssl://$PentabarfXMLhost", 443, $errno, $errstr, 30);
$error_messages = $Backuperror_messages;
if( !$fp)
{
echo "<h2>fail: File 'ssl://". $_POST["PentabarfURL"]. "' not readable!</h2>".
"[$errstr ($errno)]<br>\n";
echo "<h2>fail: File 'https://$PentabarfXMLhost/$PentabarfXMLpath$PentabarfXMLEventID' not readable!".
"[$errstr ($errno)]</h2>";
}
else
{
// if( ($fileOut = fopen( "$Tempdir/engelXML", "w")) != FALSE)
if( 1)
if( ($fileOut = fopen( "$Tempdir/engelXML", "w")) != FALSE)
{
fputs( $fp, "GET / HTTP/1.0\r\n\r\n");
$Zeilen = 0;
$head = 'GET /'. $PentabarfXMLpath. $PentabarfXMLEventID. ' HTTP/1.1'."\r\n".
'Host: '. $PentabarfXMLhost. "\r\n".
'User-Agent: Engelsystem'. "\r\n".
'Authorization: Basic '.
base64_encode($_POST["PentabarfUser"]. ':'. $_POST["password"])."\r\n".
"\r\n";
fputs( $fp, $head);
$Zeilen = -1;
while (!feof($fp))
{
$Zeilen++;
// fputs( $fileOut, fgets($fp,128));
echo fgets($fp,128);
$Temp= fgets($fp,1024);
// ende des headers
if( $Temp== "f20\r\n" )
{
$Zeilen = 0;
$Temp="";
}
// fclose( $fileOut);
//file ende?
if( $Temp=="0\r\n")
break;
if( ($Zeilen>-1) && ($Temp!="ffb\r\n") )
{
//steuerzeichen ausfiltern
if( strpos( "#$Temp", "\r\n") > 0)
$Temp = substr($Temp, 0, strlen($Temp)-2);
if( strpos( "#$Temp", "1005") > 0)
$Temp = "";
if( strpos( "#$Temp", "783") > 0)
$Temp = "";
//schreiben in file
fputs( $fileOut, $Temp);
$Zeilen++;
}
}
fclose( $fileOut);
echo "<br>Es wurden $Zeilen Zeilen eingelesen<br>";
}
else
@ -87,9 +111,9 @@ else
{
echo "<form action=\"dbUpdateFromXLS.php\" method=\"post\">\n";
echo "<table border=\"0\">\n";
echo "\t<tr><td>XCAL-File: https://</td>".
"<td><input name=\"PentabarfURL\" type=\"text\" size=\"100\" maxlength=\"1000\" ".
"value=\"$PentabarXCALurl\"></td></tr>\n";
echo "\t<tr><td>XCAL-File: https://$PentabarfXMLhost/$PentabarfXMLpath</td>".
"<td><input name=\"PentabarfURL\" type=\"text\" size=\"4\" maxlength=\"5\" ".
"value=\"$PentabarfXMLEventID\"></td></tr>\n";
echo "\t<tr><td>Username:</td>".
"<td><input name=\"PentabarfUser\" type=\"text\" size=\"30\" maxlength=\"30\"></td></tr>\n";
echo "\t<tr><td>Password:</td>".