diff options
author | cookie <cookie@29ba0400-6e00-0410-a75a-ca02368028f8> | 2006-11-13 23:40:06 +0000 |
---|---|---|
committer | cookie <cookie@29ba0400-6e00-0410-a75a-ca02368028f8> | 2006-11-13 23:40:06 +0000 |
commit | ffa84f39e7105cf64b5af13c7bc0a293b500a680 (patch) | |
tree | 246bde5ed7d15f0e0dfed561e963f6ba44e03e20 | |
parent | c8713d0218c4b1b49e20f5c1ad815dc2cc9e61ba (diff) |
import von xml daten mit hilfe von fsockopen implementiert
git-svn-id: svn://svn.cccv.de/engel-system@161 29ba0400-6e00-0410-a75a-ca02368028f8
-rw-r--r-- | README | 5 | ||||
-rwxr-xr-x | default-conf/www-ssl/inc/config.php | 4 | ||||
-rwxr-xr-x | www-ssl/admin/dbUpdateFromXLS.php | 62 |
3 files changed, 51 insertions, 20 deletions
@@ -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 diff --git a/default-conf/www-ssl/inc/config.php b/default-conf/www-ssl/inc/config.php index 21f9c847..ccf359c4 100755 --- a/default-conf/www-ssl/inc/config.php +++ b/default-conf/www-ssl/inc/config.php @@ -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"; ?> diff --git a/www-ssl/admin/dbUpdateFromXLS.php b/www-ssl/admin/dbUpdateFromXLS.php index ab2794b6..e4ec65eb 100755 --- a/www-ssl/admin/dbUpdateFromXLS.php +++ b/www-ssl/admin/dbUpdateFromXLS.php @@ -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=""; + } + + //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); + 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>". |