no way to compare when less than two revisions
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen gezeigt.
— | stephan:public:rrw-script [201710301018] (aktuell) – angelegt stephan | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
+ | < | ||
+ | <?php | ||
+ | /* ----------------------------------------------------------------- */ | ||
+ | /* */ | ||
+ | /* v1.0 5.1.2017 | ||
+ | /* kml_gpx(kml, | ||
+ | /* | ||
+ | /* | ||
+ | /* auch alle <wpt> ins gpx tun */ | ||
+ | /* wie kann man daraus eine mediawiki extension machen? | ||
+ | /* http:// | ||
+ | /* */ | ||
+ | /* v1.1 3.5.2017 reine server-version | ||
+ | /* */ | ||
+ | /* aufruf | ||
+ | | ||
+ | */ | ||
+ | /* */ | ||
+ | /* v1.2 8.5.2017 lösung: s.u. curl */ | ||
+ | /* */ | ||
+ | /* v1.3 10.5.2017 kommentare bereinigt | ||
+ | /* | ||
+ | /* */ | ||
+ | /* v1.4 11.5.2017 liste der downloads führen | ||
+ | /* */ | ||
+ | /* v1.5 12.5.2017 track name gefunden; sack und asche! | ||
+ | /* */ | ||
+ | /* v1.6 13.5.2017 rechenzeit ins log schreiben | ||
+ | /* | ||
+ | /* */ | ||
+ | /* v1.7 15.5.2017 regex mit utf-8 chars */ | ||
+ | /* sein gelassen, macht nicht viel sinn */ | ||
+ | /* */ | ||
+ | /* v1.8 19.5.2017 tempfilename unabhängig vom echten namen wählen */ | ||
+ | /* | ||
+ | /* */ | ||
+ | /* v1.9 20.5.2017 auf temp files ganz verzichten? | ||
+ | /* | ||
+ | /* | ||
+ | /* */ | ||
+ | /* v2.0 9.6.2017 function hitliste() | ||
+ | /* | ||
+ | /* */ | ||
+ | /* ----------------------------------------------------------------- */ | ||
+ | /* ----------------------------------------------------------------- */ | ||
+ | /* | ||
+ | kml to gpx converter, von hier, via stackoverflow: | ||
+ | http:// | ||
+ | code-entwurf s. erste version dieses teils. | ||
+ | */ | ||
+ | /* ----------------------------------------------------------------- */ | ||
+ | |||
+ | /* ----------------------------------------------------------------- */ | ||
+ | /* ----- functions ----- */ | ||
+ | /* ----------------------------------------------------------------- */ | ||
+ | |||
+ | /* ----------------------------------------------------------------- */ | ||
+ | /* helpers | ||
+ | /* ----------------------------------------------------------------- */ | ||
+ | function traceprint($tracebool, | ||
+ | { | ||
+ | if ($tracebool) echo $printstring; | ||
+ | } // traceprint() | ||
+ | |||
+ | /* ----------------------------------------------------------------- */ | ||
+ | function traceprintr($tracebool, | ||
+ | { | ||
+ | if ($tracebool) | ||
+ | { | ||
+ | echo " | ||
+ | | ||
+ | } | ||
+ | } // traceprintr() | ||
+ | |||
+ | /* ----------------------------------------------------------------- */ | ||
+ | function microtime_float() | ||
+ | { | ||
+ | list($usec, $sec) = explode(" | ||
+ | return ((float)$usec + (float)$sec); | ||
+ | } | ||
+ | |||
+ | /* ----------------------------------------------------------------- */ | ||
+ | function utcdate() | ||
+ | { | ||
+ | | ||
+ | } | ||
+ | |||
+ | |||
+ | /* ----------------------------------------------------------------- */ | ||
+ | /* kml to gpx converter, von hier, via stackoverflow | ||
+ | /* http:// | ||
+ | /* ----------------------------------------------------------------- */ | ||
+ | function kml_gpx($kmldoc, | ||
+ | { | ||
+ | if (null !== $kmldoc) | ||
+ | { | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | |||
+ | // | ||
+ | $gpx = $dom_gpx-> | ||
+ | $gpx = $dom_gpx-> | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | |||
+ | // placemarks | ||
+ | | ||
+ | | ||
+ | { | ||
+ | //name | ||
+ | foreach ($placemark-> | ||
+ | { | ||
+ | | ||
+ | // | ||
+ | if (array_key_exists($name, | ||
+ | { | ||
+ | //increment the value | ||
+ | ++$names[$name]; | ||
+ | $name = $name." | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | $names[$name] = 0; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | // | ||
+ | $trkdesc = ''; | ||
+ | foreach ($placemark-> | ||
+ | { | ||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | // 12.5.2017 der track name steht in < | ||
+ | $trkname = ''; | ||
+ | foreach ($placemark-> | ||
+ | { | ||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | if ($arOpts[' | ||
+ | { | ||
+ | | ||
+ | { | ||
+ | foreach ($point-> | ||
+ | { | ||
+ | //add the marker | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | if (($lat = $latlng[1]) && ($lng = $latlng[0])) | ||
+ | { | ||
+ | $gpx_wpt = $dom_gpx-> | ||
+ | $gpx_wpt = $gpx-> | ||
+ | |||
+ | $gpx_wpt_lat = $dom_gpx-> | ||
+ | $gpx_wpt-> | ||
+ | $gpx_wpt_lat_text = $dom_gpx-> | ||
+ | $gpx_wpt_lat-> | ||
+ | |||
+ | $gpx_wpt_lon = $dom_gpx-> | ||
+ | $gpx_wpt-> | ||
+ | $gpx_wpt_lon_text = $dom_gpx-> | ||
+ | $gpx_wpt_lon-> | ||
+ | |||
+ | // und wo bleibt die < | ||
+ | if ($ele = $latlng[2]) | ||
+ | { | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | $gpx_name = $dom_gpx-> | ||
+ | $gpx_name = $gpx_wpt-> | ||
+ | $gpx_name_text = $dom_gpx-> | ||
+ | $gpx_name-> | ||
+ | |||
+ | $gpx_desc = $dom_gpx-> | ||
+ | $gpx_desc = $gpx_wpt-> | ||
+ | $gpx_desc_text = $dom_gpx-> | ||
+ | $gpx_desc-> | ||
+ | |||
+ | $gpx_sym = $dom_gpx-> | ||
+ | $gpx_sym = $gpx_wpt-> | ||
+ | $gpx_sym_text = $dom_gpx-> | ||
+ | $gpx_sym-> | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | } | ||
+ | |||
+ | foreach ($placemark-> | ||
+ | { | ||
+ | | ||
+ | { | ||
+ | //add the new track | ||
+ | $gpx_trk = $dom_gpx-> | ||
+ | $gpx_trk = $gpx-> | ||
+ | |||
+ | $gpx_name = $dom_gpx-> | ||
+ | $gpx_name = $gpx_trk-> | ||
+ | $gpx_name_text = $dom_gpx-> | ||
+ | // $gpx_name_text = $dom_gpx-> | ||
+ | $gpx_name-> | ||
+ | |||
+ | // description aus der placemark description | ||
+ | $gpx_desc = $dom_gpx-> | ||
+ | $gpx_desc = $gpx_trk-> | ||
+ | $gpx_desc_text = $dom_gpx-> | ||
+ | $gpx_desc-> | ||
+ | |||
+ | $gpx_trkseg = $dom_gpx-> | ||
+ | $gpx_trkseg = $gpx_trk-> | ||
+ | |||
+ | $coordinates = $coordinates-> | ||
+ | //split the coords by new line | ||
+ | $coordinates = preg_split("/ | ||
+ | |||
+ | foreach ($coordinates as $coordinate) | ||
+ | { | ||
+ | if ('' | ||
+ | $latlng = explode(",", | ||
+ | else { | ||
+ | continue; | ||
+ | } | ||
+ | |||
+ | if (($lat = $latlng[1]) && ($lng = $latlng[0])) | ||
+ | { | ||
+ | $gpx_trkpt = $dom_gpx-> | ||
+ | $gpx_trkpt = $gpx_trkseg-> | ||
+ | |||
+ | $gpx_trkpt_lat = $dom_gpx-> | ||
+ | $gpx_trkpt-> | ||
+ | $gpx_trkpt_lat_text = $dom_gpx-> | ||
+ | $gpx_trkpt_lat-> | ||
+ | |||
+ | $gpx_trkpt_lon = $dom_gpx-> | ||
+ | $gpx_trkpt-> | ||
+ | $gpx_trkpt_lon_text = $dom_gpx-> | ||
+ | $gpx_trkpt_lon-> | ||
+ | |||
+ | /* makes absolutely no sense to write the same time for all trkpt | ||
+ | $gpx_time = $dom_gpx-> | ||
+ | $gpx_time = $gpx_trkpt-> | ||
+ | $gpx_time_text = $dom_gpx-> | ||
+ | $gpx_time-> | ||
+ | */ | ||
+ | |||
+ | // und wo bleibt die < | ||
+ | if ($ele = $latlng[2]) | ||
+ | { | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | } | ||
+ | |||
+ | } // kml_gpx() | ||
+ | |||
+ | |||
+ | /* ----------------------------------------------------------------- */ | ||
+ | /* | ||
+ | timestamp; | ||
+ | 20170608230743; | ||
+ | */ | ||
+ | /* ----------------------------------------------------------------- */ | ||
+ | function hitliste($logfn, | ||
+ | { | ||
+ | if ((null !== $logfn) && ('' | ||
+ | | ||
+ | else die(" | ||
+ | |||
+ | $total = count($arlog); | ||
+ | |||
+ | // überschrift | ||
+ | $arlogline = explode(';', | ||
+ | $datum = $arlogline[0]; | ||
+ | $adatum = substr($datum, | ||
+ | |||
+ | $arlogline = explode(';', | ||
+ | $datum = $arlogline[0]; | ||
+ | $edatum = substr($datum, | ||
+ | |||
+ | $arlogtracks = array(); | ||
+ | |||
+ | foreach ($arlog as $logline) | ||
+ | { | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | unset($arlog); | ||
+ | |||
+ | sort($arlogtracks, | ||
+ | |||
+ | $artrackcount = array(); | ||
+ | $trkn = $arlogtracks[0]; | ||
+ | $trkcnt = 0; | ||
+ | foreach ($arlogtracks as $trackname) | ||
+ | { | ||
+ | if (0 == strcmp($trkn, | ||
+ | $trkcnt++; | ||
+ | else | ||
+ | { | ||
+ | // anzahl + trackname in array schreiben | ||
+ | $artrackcount[] = $trkcnt.';' | ||
+ | $trkcnt = 1; | ||
+ | } | ||
+ | $trkn = $trackname; | ||
+ | | ||
+ | |||
+ | unset($arlogtracks); | ||
+ | |||
+ | rsort($artrackcount, | ||
+ | |||
+ | $htmltitle = ' | ||
+ | $headline = ' | ||
+ | |||
+ | // das folgende irgendwohin als template legen !!! | ||
+ | $htmlhead = '< | ||
+ | < | ||
+ | |||
+ | $htmlbody = '< | ||
+ | $htmltable = '< | ||
+ | foreach ($artrackcount as $hitline) | ||
+ | { | ||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | $htmlbody .= $htmltable.'</ | ||
+ | |||
+ | print($htmlhead.$htmlbody); | ||
+ | |||
+ | } // hitliste | ||
+ | |||
+ | |||
+ | /* ----------------------------------------------------------------- */ | ||
+ | /* ----------------------------------------------------------------- */ | ||
+ | /* --- main --- */ | ||
+ | /* ----------------------------------------------------------------- */ | ||
+ | /* ----------------------------------------------------------------- */ | ||
+ | date_default_timezone_set(' | ||
+ | |||
+ | $trace = 0; // wenn der höchste verwendete tracelevel 8 ist, dann | ||
+ | // werden mit trace = 15 alle tracelevels angezeigt | ||
+ | // 2: simple trace; 4: echo xml; 8: mysql; 128: input | ||
+ | |||
+ | $azeit = microtime_float(); | ||
+ | |||
+ | if ($trace & 128) | ||
+ | { | ||
+ | echo "< | ||
+ | | ||
+ | echo "< | ||
+ | echo $_SERVER[' | ||
+ | echo "< | ||
+ | echo $_SERVER[' | ||
+ | | ||
+ | } | ||
+ | |||
+ | $arOpts = array(); | ||
+ | $arOpts[' | ||
+ | $hitliste = false; | ||
+ | |||
+ | $kmzurl = ''; | ||
+ | |||
+ | if ($_SERVER[' | ||
+ | { | ||
+ | | ||
+ | |||
+ | if ("" | ||
+ | { | ||
+ | /* check for ?parms */ | ||
+ | parse_str($querystr); | ||
+ | |||
+ | if ($url) $kmzurl = $url; | ||
+ | |||
+ | if ($wpt) $arOpts[' | ||
+ | |||
+ | if ($hits) $hitliste = true; | ||
+ | |||
+ | } /* args present */ | ||
+ | | ||
+ | else | ||
+ | | ||
+ | |||
+ | |||
+ | /* ----------------------------------------------------------------- */ | ||
+ | $workdir = ' | ||
+ | $logfn = $workdir.' | ||
+ | |||
+ | if ($hitliste) | ||
+ | { | ||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | $urlparts = pathinfo($kmzurl); | ||
+ | $filename = $urlparts[' | ||
+ | $kmztmpfn = $workdir.$azeit.' | ||
+ | |||
+ | // create a new cURL resource | ||
+ | $ch = curl_init(); | ||
+ | |||
+ | // set URL and other appropriate options | ||
+ | curl_setopt($ch, | ||
+ | //return the transfer as a string | ||
+ | curl_setopt($ch, | ||
+ | curl_setopt($ch, | ||
+ | |||
+ | // grab URL and pass it to $kmzcontents | ||
+ | $kmzcontents = curl_exec($ch); | ||
+ | $curlinfo = curl_getinfo($ch, | ||
+ | // close cURL resource, and free up system resources | ||
+ | curl_close($ch); | ||
+ | |||
+ | // zeit für den curl-aufruf loggen | ||
+ | $fcurlzeit = microtime_float() - $azeit; | ||
+ | $scurlzeit = sprintf(" | ||
+ | |||
+ | if (0 != strcmp (' | ||
+ | | ||
+ | |||
+ | // write stuff to local temp file | ||
+ | if (false === file_put_contents($kmztmpfn, | ||
+ | | ||
+ | |||
+ | unset($kmzcontents); | ||
+ | |||
+ | $kmldoc = ''; | ||
+ | $zip = new ZipArchive; | ||
+ | if (true === $zip-> | ||
+ | { | ||
+ | // $zip-> | ||
+ | $fp = $zip-> | ||
+ | if (!$fp) | ||
+ | { | ||
+ | unlink($kmztmpfn); | ||
+ | die(" | ||
+ | } | ||
+ | |||
+ | while (!feof($fp)) | ||
+ | $kmldoc .= fread($fp, 2); | ||
+ | |||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | unlink($kmztmpfn); | ||
+ | |||
+ | $gpxdoc =''; | ||
+ | kml_gpx($kmldoc, | ||
+ | |||
+ | header(' | ||
+ | header(' | ||
+ | |||
+ | print($gpxdoc); | ||
+ | |||
+ | |||
+ | $ezeit = microtime_float(); | ||
+ | $rechenzeit = sprintf(" | ||
+ | if (1.0 < $fcurlzeit) $rechenzeit = $rechenzeit." | ||
+ | |||
+ | // log | ||
+ | $logbuf = date(" | ||
+ | $logbuf = file_put_contents($logfn, | ||
+ | unset($logbuf); | ||
+ | |||
+ | /* ----------------------------------------------------------------- */ | ||
+ | ?> | ||
+ | </ |