From a49eb0bdaa624ca89bde36a776f3a1dfe6906c6a Mon Sep 17 00:00:00 2001 From: cookie Date: Tue, 15 Nov 2005 16:22:35 +0000 Subject: umgestellt auf xcal git-svn-id: svn://svn.cccv.de/engel-system@51 29ba0400-6e00-0410-a75a-ca02368028f8 --- www-ssl/admin/dbUpdateFromXLS.php | 415 +++++--------------------------------- 1 file changed, 55 insertions(+), 360 deletions(-) (limited to 'www-ssl/admin') diff --git a/www-ssl/admin/dbUpdateFromXLS.php b/www-ssl/admin/dbUpdateFromXLS.php index eb3b5ac3..1549a32a 100755 --- a/www-ssl/admin/dbUpdateFromXLS.php +++ b/www-ssl/admin/dbUpdateFromXLS.php @@ -8,14 +8,33 @@ include ("./inc/funktion_xml.php"); /////////// // DEBUG // /////////// -$EnableRooms = true; -$EnableRoomsDB = true; -$EnableSchudle = true; -$EnableSchudleDB = true; -//$EnableRooms = false; -//$EnableRoomsDB = false; -//$EnableSchudle = false; -//$EnableSchudleDB = false; +$ShowDataStrukture = 0; +$EnableRoomFunctions = 0; +$EnableRooms = 0; +$EnableRoomsDB = 0; +$EnableSchudleFunctions = 1; +$EnableSchudle = 1; +$EnableSchudleDB = 0; + + +/*############################################################################################## + erstellt Arrays der Reume + ##############################################################################################*/ +$sql = "SELECT `RID`, `Name` FROM `Room` ". + "WHERE `Show`='Y'". + "ORDER BY `Number`, `Name`;"; +$Erg = mysql_query($sql, $con); +$rowcount = mysql_num_rows($Erg); + +for ($i=0; $i<$rowcount; $i++) +{ + $Room[$i]["RID"] = mysql_result($Erg, $i, "RID"); + $Room[$i]["Name"] = mysql_result($Erg, $i, "Name"); + $RoomID[ mysql_result($Erg, $i, "RID") ] = mysql_result($Erg, $i, "Name"); + $RoomName[ mysql_result($Erg, $i, "Name") ] = mysql_result($Erg, $i, "RID"); +} + + /*############################################################################################## F I L E @@ -24,12 +43,13 @@ echo "\n\n
\n

XML File:

\n"; if( isset($_POST["PentabarfUser"]) && isset($_POST["PentabarfPasswd"]) && isset($_POST["PentabarfURL"])) { echo "Update XML-File from Pentabarf.."; -/* $Command = "wget --http-user=". $_POST["PentabarfUser"]. " --http-passwd=".$_POST["PentabarfPasswd"]. " ". + $Command = "wget --http-user=". $_POST["PentabarfUser"]. " --http-passwd=".$_POST["PentabarfPasswd"]. " ". $_POST["PentabarfURL"]. - " --output-file=/tmp/engelXMLwgetLog --output-document=/tmp/engelXML"; -*/ - $Command = "lynx -auth=". $_POST["PentabarfUser"]. ":".$_POST["PentabarfPasswd"]. " -dump ". - $_POST["PentabarfURL"]. " > /tmp/engelXML"; + " --output-file=/tmp/engelXMLwgetLog --output-document=/tmp/engelXML". + " --no-check-certificate"; + +// $Command = "lynx -auth=". $_POST["PentabarfUser"]. ":".$_POST["PentabarfPasswd"]. " -dump ". +// $_POST["PentabarfURL"]. " > /tmp/engelXML"; echo system( $Command, $Status); if( $Status==0) @@ -43,7 +63,7 @@ else echo "\n"; echo "\t". "\n"; + "value=\"https://pentabarf.cccv.de/~sven/xcal/conference/7\">\n"; echo "\t". "\n"; echo "\t". @@ -58,13 +78,19 @@ else //readXMLfile("xml.php.xml"); if( readXMLfile("/tmp/engelXML") == 0) { -/* -echo "

"; -echo $XMLmain->name; -echo "
"; -//print_r(array_values ($XMLmain->sub)); +$XMLmain = getXMLsubPease( $XMLmain, "VCALENDAR"); +if( $ShowDataStrukture) +{ + echo "

"; + echo $XMLmain->name; + echo "
"; + print_r(array_values ($XMLmain->sub)); + echo "
"; +} + +/* echo "
"; $Feld=7; echo "$Feld#". $XMLmain->sub[$Feld]->name. "
"; @@ -72,362 +98,31 @@ echo "$Feld#". $XMLmain->sub[$Feld]->sub; //print_r(array_values ($XMLmain->sub[$Feld]->sub)); while(list($key, $value) = each($XMLmain->sub[$Feld]->sub)) echo "?ID".$value->sub[1]->data. "=". $value->sub[2]->data. "\n"; - echo "
"; */ + /*############################################################################################## V e r s i o n ##############################################################################################*/ + echo "
\n"; -$XMLrelease = getXMLsubPease( $XMLmain, "RELEASE"); +$XMLrelease = getXMLsubPease( $XMLmain, "X-WR-CALDESC"); echo "release: ". $XMLrelease->data. "
\n"; -$XMLreleaseDate = getXMLsubPease( $XMLmain, "RELEASE-DATE"); -echo "release date: ". $XMLreleaseDate->data. "
\n"; +//$XMLreleaseDate = getXMLsubPease( $XMLmain, "RELEASE-DATE"); +//echo "release date: ". $XMLreleaseDate->data. "
\n"; echo "
\n"; /*############################################################################################## - R o o m - ##############################################################################################*/ -echo "\n\n
\n

Rooms:

\n"; - -function saveRoomData() -{ - include ("./inc/db.php"); - if( isset($_GET["RID"]) && isset($_GET["NumberXML"]) && isset($_GET["NameXML"])) - { - $SQL1 = "SELECT `RID` FROM `Room` ". - "WHERE `RID` = '". $_GET["RID"]. "';"; - $Erg1 = mysql_query($SQL1, $con); - - if( mysql_num_rows($Erg1)==1 ) - $SQL= "UPDATE `Room` SET `Name` = '". mysql_escape_string($_GET["NameXML"]). - "', `FromPentabarf`='Y', `Number`='". $_GET["NumberXML"]. "' ". - "WHERE `RID` = '". $_GET["RID"]. "' LIMIT 1;"; - else - $SQL= "INSERT INTO `Room` ( `RID` , `Name`, `FromPentabarf`, `Number` ) ". - "VALUES ('". $_GET["RID"]. "', '". mysql_escape_string($_GET["NameXML"]). - "', 'Y', ". $_GET["NumberXML"]. ");"; - $Erg = mysql_query($SQL, $con); - if( $Erg ) - echo "Aenderung, an Raum ". $_GET["NameXML"]. ", war erfogreich
"; - else - echo "Aenderung, an Raum ". $_GET["NameXML"]. ", war nicht erfogreich.(". - mysql_error($con). ")
[$SQL]
"; - } - else - echo "Fehler in den Parametern!
"; -} /*function saveRoomData*/ - -function getDBRoomName( $RID) -{ - include ("./inc/db.php"); - $SQL = "SELECT Name FROM `Room` WHERE RID=$RID"; - $Erg = mysql_query($SQL, $con); - if(mysql_num_rows($Erg)>0) - return mysql_result($Erg, 0, 0); - else - return ""; -} /*function getDBRoomName*/ - -function getDBRoomNumber( $RID) -{ - include ("./inc/db.php"); - $SQL = "SELECT Number FROM `Room` WHERE RID=$RID"; - $Erg = mysql_query($SQL, $con); - if(mysql_num_rows($Erg)>0) - return mysql_result($Erg, 0, 0); - else - return ""; -} /*function getDBRoomNumber*/ - - - -if( isset($_GET["RoomUpdate"])) - saveRoomData(); - -//INIT Status counter -$DS_OK = 0; -$DS_KO = 0; -$Where = ""; - -//Ausgabe -echo "
XML-File:
Username:
Password:
\n"; -echo "\n"; -$XMLroom = getXMLsubPease( $XMLmain, "ROOMS"); -while( (list($key, $value) = each($XMLroom->sub)) && $EnableRooms) -{ - $XMLRID = getXMLsubPease( $value, "ID"); - $RID = $XMLRID->data; - $XMLNumber = getXMLsubPease( $value, "NUMBER"); - $NumberXML = trim($XMLNumber->data); - $XMLName = getXMLsubPease( $value, "NAME"); - $NameXML = trim($XMLName->data); - - if( isset($_GET["UpdateALL"])) - { - $_GET["NameXML"] = $NameXML; - $_GET["NumberXML"] = $NumberXML; - $_GET["RID"] = $RID; - saveRoomData(); - } - - $NameDB = convertValues(getDBRoomName($RID)); - $NumberDB = convertValues(getDBRoomNumber($RID)); - - echo "\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - if( !( $NameXML==$NameDB && $NumberXML==$NumberDB) ) - { - echo "\t\n"; - $DS_KO++; - } - else - { - echo "\t\n"; - $DS_OK++; - } - echo "\t\n"; - echo "\n"; - $Where.= " OR RID=$RID"; -} -echo "\n"; - -//Anzeige von nicht im XML File vorkommende entraege -$SQL2 = "SELECT * FROM `Room` WHERE NOT (".substr( $Where, 4). ") AND FromPentabarf = 'Y';"; -$Erg2 = mysql_query($SQL2, $con); -if( mysql_num_rows($Erg2)>0 && $EnableRoomsDB ) - for( $i=0; $i\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - } - -echo "
RIDNumberXMLNumberDBNameXMLNameDBstate
OK
status: $DS_KO/$DS_OK nicht Aktuel.
edit
\n"; - - - - -/*############################################################################################## - S c h e d u l e + V e r s i o n ##############################################################################################*/ -echo "\n\n

Schudle:

\n"; - -// erstellt ein Array der Reume - $sql = "SELECT * FROM `Room` ". - "ORDER BY `Number`, `Name`;"; - $Erg = mysql_query($sql, $con); - for( $i=0; $i=24 ) - { - $TimeH -= 24; - $DateEnd = substr($_GET["DateXML"], 0, 8). - (substr($_GET["DateXML"], 8, 2)+1). " "; - } - else - $DateEnd = substr($_GET["DateXML"], 0, 11); - $DateEnd .= "$TimeH:$TimeM:00"; - - //Update OR insert ? - $SQL1 = "Select `SID` FROM `Shifts` WHERE `SID`='". $_GET["SIDXML"]. "';"; - $Erg1 = mysql_query($SQL1, $con); - - if( mysql_num_rows($Erg1)==0) - $SQL= "INSERT INTO `Shifts` (`SID`, `DateS`, `DateE`, `Len`, `RID`, `Man`, `FromPentabarf`) ". - "VALUES ('". $_GET["SIDXML"]. "', '". $_GET["DateXML"]. "', '". - $DateEnd. "', '". $_GET["LenXML"]. "', '". - $_GET["RIDXML"]. "', '". mysql_escape_string($_GET["ManXML"]). "', 'Y');"; - else - $SQL= "UPDATE `Shifts` SET ". - "`DateS` = '". $_GET["DateXML"]. "', ". - "`DateE` = '". $DateEnd. "', ". - "`Len` = '". $_GET["LenXML"]. "', ". - "`RID` = '". $_GET["RIDXML"]. "', ". - "`Man` = '". mysql_escape_string($_GET["ManXML"]). "', ". - "`FromPentabarf`= 'Y' ". - "WHERE `SID` = '". $_GET["SIDXML"]. "' LIMIT 1;"; - $Erg = mysql_query($SQL, $con); - if( $Erg ) - { - echo "Aenderung, am Schedule '". $_GET["SIDXML"]. "', war erfogreich
\n"; - if( mysql_num_rows($Erg1)==0) - { - echo "-->Create Shifts:
\n"; - foreach ($RoomID[ $_GET["RIDXML"]] as $Key => $Value) - if( substr( $Key, 0, 12)=="DEFAULT_EID_" && $Value > 0 ) - { - echo "---->Create engeltype: ". substr( $Key, 12). " ". $Value. "x
\n"; - $i=0; - while( $i++ < $Value ) - { - $SQL3 = "INSERT INTO `ShiftEntry` (`SID`, `TID`) VALUES (". - "'". $_GET["SIDXML"]. "', '". substr( $Key, 12). "');"; - - $Erg = mysql_query($SQL3, $con); - - if ($Erg == 1) - echo "------>pass
\n"; - else - echo "------>fail ". mysql_error($con). - "($SQL3)
\n"; - } - - } - echo "
\n"; - } - } - else - echo "Aenderung, am Schedule '". $_GET["SIDXML"]. "', war nicht erfogreich.(". - mysql_error($con). ")
[$SQL]
\n"; - } - else - echo "Fehler in den Parametern!
"; -} /*SaveSchedule*/ - -if( isset($_GET["ScheduleUpdate"])) - SaveSchedule(); - -//INIT Status counter -$DS_OK = 0; -$DS_KO = 0; -$Where = ""; - -//ausgabe -echo "\n"; -echo "". - "\n"; -echo "". - "\n"; -$XMLevents = getXMLsubPease( $XMLmain, "EVENTS"); -while( (list($EventKey, $Event) = each($XMLevents->sub)) && $EnableSchudle) -{ - echo "\n"; - echo "\t\n"; - - $DateXML = substr($Event->attributes["START"], 0, 10). " ". - substr($Event->attributes["START"], 11). ":00"; - $LenXML = $Event->attributes["DURATION"]; - $LenXML = substr( $LenXML, 0, 2) + (substr($LenXML, 3, 2)/60); - $XMLeventID = getXMLsubPease( $Event, "ID"); - $SIDXML = $XMLeventID->data; - $RIDXML = $Event->attributes["ROOM-ID"]; - $XMLTitle = getXMLsubPease( $Event, "TITLE"); - $ManXML = $XMLTitle->data; - - if( isset($_GET["UpdateALL"])) - { - $_GET["SIDXML"] = $SIDXML; - $_GET["DateXML"] = "$DateXML $TimeXML"; - $_GET["LenXML"] = $LenXML; - $_GET["RIDXML"] = $RIDXML; - $_GET["ManXML"] = $ManXML; - SaveSchedule(); - } - - $SQL = "SELECT * FROM `Shifts` WHERE SID=$SIDXML"; - $Erg = mysql_query($SQL, $con); - if(mysql_num_rows($Erg)>0) - { - $SIDDB = mysql_result($Erg, 0, "SID"); - $TimeDB = mysql_result($Erg, 0, "DateS"); - $LenDB = mysql_result($Erg, 0, "Len"); - $RIDDB = mysql_result($Erg, 0, "RID"); - $ManDB = mysql_result($Erg, 0, "Man"); - } - else - $SIDDB = $TimeDB = $LenDB = $RIDDB = $ManDB= ""; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - if( !( $SIDXML==$SIDDB && - $DateXML==$TimeDB && - $RIDXML==$RIDDB && - $LenXML==$LenDB && - $ManXML==$ManDB) ) - { - echo "\t\n"; - $DS_KO++; - } - else - { - echo "\t\n"; - $DS_OK++; - } - echo "\t\n"; - echo "\n"; - $Where.= " OR SID=$SIDXML"; -} -echo "\n"; - -//Anzeige von nicht im XML File vorkommende entraege -$SQL2 = "SELECT * FROM `Shifts` WHERE NOT (".substr( $Where, 4). ") AND FromPentabarf = 'Y';"; -$Erg2 = mysql_query($SQL2, $con); -if(mysql_num_rows($Erg2)>0 && $EnableSchudleDB ) - for( $i=0; $i\n"; - $SID = mysql_result($Erg2, $i, "SID"); - $Time = mysql_result($Erg2, $i, "DateS"); - $Len = mysql_result($Erg2, $i, "Len"); - $RID = mysql_result($Erg2, $i, "RID"); - $Man = mysql_result($Erg2, $i, "Man"); - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - } -echo "
SIDDateRoomLenNamestate
XML - DBXML - DBXML - DBXML - DBXML - DB
\n\t\t". - "\n\t\t". - "\n\t\t". - "\n\t\t". - "OK
status: $DS_KO/$DS_OK nicht Aktuel.
\n\t\t". - "\n\t\t". - "\n\t\t". - "\n\t\t". - "edit
"; +if( $EnableRoomFunctions) + include("./inc/funktion_xml_room.php"); +if( $EnableSchudleFunctions) + include("./inc/funktion_xml_schudle.php"); /*############################################################################################## -- cgit v1.2.3-70-g09d2