First functions
This commit is contained in:
parent
c89f3a4171
commit
33d32256a3
7 changed files with 127 additions and 1 deletions
36
suggest.php
Normal file
36
suggest.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
if(!empty($_GET['name']) && strlen($_GET['name'])>2) {
|
||||
$type = $_GET['type'];
|
||||
//http://fahrplan.oebb.at/bin/ajax-getstop.exe/dn?REQ0JourneyStopsS0A=1&REQ0JourneyStopsB=12&S=""&js=true
|
||||
$name = urldecode($_GET['name']);
|
||||
$ch = curl_init();
|
||||
$buffer = "";
|
||||
curl_setopt($ch, CURLOPT_URL, 'https://fahrplan.oebb.at/bin/ajax-getstop.exe/dn?REQ0JourneyStopsS0A=1&REQ0JourneyStopsB=12&S='.$name.'&js=true');
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
$fh=curl_exec($ch);
|
||||
//var_dump(curl_getinfo($ch));
|
||||
// schließe den cURL-Handle und gebe die Systemresourcen frei
|
||||
curl_close($ch);
|
||||
if ($fh) {
|
||||
$buffer = trim($fh);
|
||||
}
|
||||
$data = json_decode(mb_convert_encoding(str_replace("SLs.sls={\"suggestions\":","",str_replace("};SLs.showSuggestion();","",$buffer)),'UTF-8','ISO-8859-1'));
|
||||
if($type=="station") {
|
||||
$output = '<datalist id="listit">';
|
||||
foreach ($data as $value) {
|
||||
$output .= '<option value="' . $value->{"extId"} . '">' . $value->{"value"} . '</option>';
|
||||
}
|
||||
$output .= '</datalist>';
|
||||
echo $output;
|
||||
}else{
|
||||
$output = '<datalist id="liststations">';
|
||||
foreach ($data as $value) {
|
||||
$output .= '<option>' . $value->{"value"} . '</option>';
|
||||
}
|
||||
$output .= '</datalist>';
|
||||
echo $output;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue