\n"; // sostituisce anche caratteri speciali che htmlentities() non conosce: function trasformainhtml($s) { $from_strings = array("\r","\n","•","•"," "); // ist ein Newline $to_strings = array(" ","
","•","•","
"); $s0 = htmlentities($s,ENT_QUOTES,"UTF-8"); $s3 = str_replace($from_strings, $to_strings, $s0); return($s3); } global $ModName; // solo settato, se ci troviamo in PostNuke/Gnred if( !empty($ModName) ) { if($DEBUG) echo "inside GNred
\n"; // considera eventuali parametri passato nell'URL: $frominput_eventfrom = pnVarCleanFromInput('eventfrom'); $frominput_eventtill = pnVarCleanFromInput('eventtill'); $frominput_eventcity = pnVarCleanFromInput('eventcity'); $frominput_eventranc = pnVarCleanFromInput('eventranc'); $frominput_eventlimit = pnVarCleanFromInput('eventlimit'); $frominput_eventid = pnVarCleanFromInput('eventid'); if(!empty($frominput_eventfrom)) $eventfrom = $frominput_eventfrom; if(!empty($frominput_eventtill)) $eventtill = $frominput_eventtill; if(!empty($frominput_eventcity)) $eventcity = $frominput_eventcity; if(!empty($frominput_eventranc)) $eventranc = $frominput_eventranc; if(!empty($frominput_eventlimit)) $eventlimit = $frominput_eventlimit; if(!empty($frominput_eventid)) $eventid = $frominput_eventid; } else { if($DEBUG) echo "outside GNred
\n"; // variabili se chiamato all'esterno di GNred $default_language = "it"; } $today = date("Y-m-d"); $nextyear = date("Y")+1; if( empty($la) ) $la = $default_language; // specificato in default.conf if( strtolower($la)=="nl" ) $la = "en"; // invece di olandese presentiamo gli events in inglese if( empty($eventfrom) || ($eventfrom<$today) ) $eventfrom = $today; // default: la data di oggi if( empty($eventtill) ) $eventtill = $nextyear."-12-31"; // praticamente tutti if( empty($eventcity) ) $eventcity = "0"; // basta specificare parte del nome (tedesco), es "Wolken", "stina" if( empty($eventranc) ) $eventranc = "5"; // TopEvents hanno ranc=1 if( empty($eventlimit) ) $eventlimit = 100000; // praticamente tutti if($DEBUG) echo "Parameters: la:$la, eventfrom:$eventfrom, eventtill:$eventtill, eventcity:$eventcity, eventranc:$eventranc, eventlimit:$eventlimit
\n"; /********** Funktionen zum parsen der XML-Datei eines einzelnen Events ********/ function xml_get_children($vals, &$i) { $children = array(); if (isset($vals[$i]['value'])) $children[] = $vals[$i]['value']; while (++$i < count($vals)) { switch ($vals[$i]['type']) { case 'cdata': $children[] = $vals[$i]['value']; break; case 'complete': $children[] = array( 'tag' => $vals[$i]['tag'], 'attributes' => isset($vals[$i]['attributes'])? $vals[$i]['attributes'] : null, 'value' => $vals[$i]['value'] ); break; case 'open': $children[] = array( 'tag' => $vals[$i]['tag'], 'attributes' => isset($vals[$i]['attributes'])? $vals[$i]['attributes'] : null, 'children' => xml_get_children($vals, $i) ); break; case 'close': return $children; } } } // am 4.4.2011 gab es vom Server die Antwort: // Warning: file(...): failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error function xml_get_tree($file) { $response = @file($file); // keine Fehlermeldungen anzeigen if( is_array($response) ) $data = join('', $response); else return array(); // leeres Array statt Fehler zurueckgeben $parser = xml_parser_create(); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parse_into_struct($parser, $data, $vals, $index); xml_parser_free($parser); return array( 'tag' => $vals[0]['tag'], 'attributes' => isset($vals[0]['attributes'])? $vals[0]['attributes'] : null, 'children' => xml_get_children($vals, $i = 0) ); } /********** Anzeigen eines Events *********************************************/ if( !empty($eventid) ) { // mostrare un evento specifico if($DEBUG) echo "EVENT-Details für eventid: $eventid
\n"; // $XMLSERVER = "http://data.tourist.info"; $XMLSERVER = "http://tourist.bz.it"; $URLXDATEN = $XMLSERVER."/data/CDBData.asmx/SendDataXmlOut?sInput="; $URLXTICKET = $XMLSERVER."/data/CDBData.asmx/GetTicket?sInput="; // zuert die SessionID ermitteln: $XMLSTRING = "%3CSendData%20Function='GetTicket'%20User='info@valgardena.it'%20Pwd='AB54DD9B9E'%20Version='1.0'%20PrefUserID='64E09593F49E486DA8339D4B34BE7461'%20/%3E"; $FILEURL = "$URLXTICKET$XMLSTRING"; $xmlticket = file_get_contents($FILEURL); $xmlpart = strtok($xmlticket, " \n\t"); while ($xmlpart !== false) { $sess = strstr( $xmlpart, "SessionID=" ); // ritorna la parte dopo sessionid= if( $sess ) $sessionid = str_replace("'","",strstr($sess, "'")); $xmlpart = strtok(" \n\t"); } if( empty($sessionid) ) { echo "no Session available - GetTicket failed - please try again later"; return; } // $FILEURL = $URLXDATEN."%3CSendData%20UserID='64E09593F49E486DA8339D4B34BE7461'%20SessionID='".$sessionid."'%20Function='GetEventData'%20Version='1.0'%20EvRID='".$eventid."'%20/%3E"; $FILEURL = $URLXDATEN."%3CSendData%20UserID='64E09593F49E486DA8339D4B34BE7461'%20SessionID='".$sessionid."'%20Function='GetEveVData'%20Version='1.0'%20EvRID='".$eventid."'%20LngID='".$la."'%20WithOrganizer='1'%20/%3E"; // PublRID=’…’ /> // echo "\n"; $tree = xml_get_tree($FILEURL); $ticks = $tree["attributes"]["Ticks"]; // wozu brauchen wir das?!? $subtree = $tree["children"][0]; $eventdates = array(); // echo "\n"; if(!empty($subtree["children"])) { foreach($subtree["children"] as $stc) { $tag = $stc["tag"]; switch( $tag ) { case "EventDefinition": // old $zip = $stc["attributes"]["Zip"]; foreach($stc["children"] as $sstc) { if( strcasecmp($sstc["attributes"]["LngID"],$la)==0 ) { $eventtitle = trasformainhtml($sstc["attributes"]["Title"]); $eventlocation = trasformainhtml($sstc["attributes"]["Location"]); $eventcity = trasformainhtml($sstc["attributes"]["City"]); } } break; case "Definition": $eventzip = $stc["attributes"]["Zip"]; $eventtel = $stc["attributes"]["Phone"]; foreach($stc["children"] as $sstc) { if( strcasecmp($sstc["attributes"]["LngID"],$la)==0 ) { $eventtitle = trasformainhtml($sstc["attributes"]["Title"]); $eventlocation = trasformainhtml($sstc["attributes"]["Location"]); $eventcity = trasformainhtml($sstc["attributes"]["City"]); } } break; case "EventDate": // old $zip = $stc["attributes"]["Zip"]; if( count($stc["children"]) > 0 ) foreach($stc["children"] as $sstc) { $eventdates[] = substr($sstc["attributes"]["Date"],0,10); } break; case "Day": $eventdates[] = $stc["attributes"]["Date"]; $eventtime = $stc["attributes"]["Begin"]; $eventtimeend = $stc["attributes"]["End"]; break; case "EventPublicity": // old if( strcasecmp($stc["attributes"]["LngID"],$la)==0 ) { $eventdesc = trasformainhtml($stc["attributes"]["Desc"]); // OK // $eventdesc = htmlentities(html_entity_decode($stc["attributes"]["Desc"],ENT_COMPAT,"iso-8859-15"),ENT_COMPAT,"utf-8"); // OK } break; case "Description": if( strcasecmp($stc["attributes"]["LngID"],$la)==0 ) { echo "\n\n"; $eventdescription = trasformainhtml($stc["attributes"]["Text"]); } break; case "EventTime": $eventtime = substr($stc["attributes"]["Start"],0,5); // old $eventtimeend = substr($stc["attributes"]["End"],0,5); break; case "EventFoto": $eventpicture = $stc["attributes"]["Picture"]; break; // old case "Foto": $eventpicture = $stc["attributes"]["FPath"]; break; case "EventOrganizerData": // old $eventorganizertel = $stc["attributes"]["Phone"]; $eventorganizerfax = $stc["attributes"]["Fax"]; $eventorganizerweb = $stc["attributes"]["Web"]; $eventorganizeremail = $stc["attributes"]["EMail"]; foreach($stc["children"] as $sstc) { if( strcasecmp($sstc["attributes"]["LngID"],$la)==0 ) { $eventorganizerstreet = trasformainhtml($sstc["attributes"]["Street"]); $eventorganizername = trasformainhtml($sstc["attributes"]["Orgname"]); $eventorganizercity = trasformainhtml($sstc["attributes"]["City"]); } } break; case "Organizer": foreach($stc["children"] as $sstc) { foreach($sstc["children"] as $sscc) { // echo "\n"; $eventorganizertel = $sscc["attributes"]["Phone"]; $eventorganizerfax = $sscc["attributes"]["Fax"]; $eventorganizerweb = $sscc["attributes"]["Web"]; $eventorganizeremail = $sscc["attributes"]["EMail"]; foreach($sscc["children"] as $ssccc) { $eventorganizerstreet = trasformainhtml($ssccc["attributes"]["Street"]); $eventorganizername = trasformainhtml($ssccc["attributes"]["OName"]); $eventorganizercity = trasformainhtml($ssccc["attributes"]["City"]); } } } break; } } } if( count($eventdates)>0 ) { $estart = min($eventdates); $eend = max($eventdates); } else $estart = $eend = ""; $eventstart = substr($estart,8,2).".".substr($estart,5,2).".".substr($estart,2,2); $eventend = substr($eend,8,2).".".substr($eend,5,2).".".substr($eend,2,2); $eventdate = ($eventstart != $eventend) ? "$eventstart - $eventend" : "$eventstart"; $etimeend = ($eventtimeend != "00:00") ? " - ".$eventtimeend : ""; $etime = ($eventtime != "00:00") ? ", ".$eventtime.$etimeend : ""; if( strlen($eventorganizerweb)>3 ) { $eow_url = $eventorganizerweb; $x_ms = ""; if( substr($eow_url,0,4) == "www." ) $eow_url = "http://".$eow_url; if( strpos($eow_url,"http://www.valgardena.it") === 0 ) $eow_url = str_replace("http://www.valgardena.it","/",$eow_url); $eventorganizerweb = "$eventorganizerweb"; } echo "
\n"; echo "
$eventtitle
\n"; if( !empty($eventpicture) && strlen($eventpicture)>3 ) echo "\n"; echo "
$eventdate$etime
\n"; echo "
$ecityname
\n"; echo "
$eventzip $eventcity
$eventlocation
\n"; // echo "
$eventdesc
\n"; echo "
$eventdescription
\n"; echo "
\n"; echo "
\n"; echo "
$eventorganizername
\n"; echo "
$eventorganizerstreet
\n"; echo "
$eventorganizercity
\n"; echo "
Tel: $eventorganizertel
\n"; echo "
Fax: $eventorganizerfax
\n"; echo "
$eventorganizerweb
\n"; echo "
$eventorganizeremail
\n"; echo "
\n"; echo "".$str_allevents[$lang]."\n"; } else { /********** Anzeigen einer Liste von Events ***********************************/ if($DEBUG) echo "showing EVENT-List...
\n"; // Sprachabhaengig: $filename = str_replace("XX",strtolower($la),$event_filename); // neue Events-API verwendet it,de,... statt IT,DE,... if($DEBUG) echo "including file:$filename
\n"; include $filename; if($DEBUG) echo "la:$la, eventfrom:$eventfrom, eventtill:$eventtill eventlimit:$eventlimit\n"; echo "\n"; echo "".$str_allevents[$lang]."\n"; } ?>