"); $sverige = stripos($buffer, "Sverige"); $s_tog = stripos($buffer, "S-tog"); while (1) { $pos = stripos($buffer, "W=", $pos); if ($pos == FALSE) break; if ($pos >= $sverige && $pos<$s_tog) { $pos = $s_tog; continue; } $stationEnd = stripos($buffer, "'>", $pos); $statStr = substr($buffer,$pos, $stationEnd-$pos); $pos++; $pairs = split("&", $statStr); $entry = array(); foreach ($pairs as $pair) { $tmppair = split("=", $pair); $key = strtolower($tmppair[0]); if ($key == "artikelid") continue; $entry[ $key ] = $tmppair[1]; } $stations[] = $entry; } return $stations; } function lastUpdateString( $updateCode ) { switch( $updateCode ) { case '1': $result = "< 3 min"; break; case '2': $result = "3 - 10 min"; break; case '3': $result = ">10 min"; break; case '4': $result = "No info"; break; default: $result = "Unknown:" . $buffer[$pos]; } return $result; } function tog3($search) { $result = array(); $current = tog("FJRN", $search, ""); $result2 = array_merge($result,$current); $result = $result2; $current = tog("S2", $search, ""); $result2 = array_merge($result,$current); $result = $result; return $result; } function tog2($search) { // echo "\n"; $result = array(); $search = strtolower($search); $stations = stationList(); for ($i=0; $i\n"; $lcstation = strtolower($stationname); if ($search == $lcstation || strpos($search, $lcstation) != FALSE || strpos($lcstation,$search) != FALSE) { $current = tog($type,$stationcode,$stationname); $result2 = array_merge($result,$current); $result = $result2; } } return $result; } function tog($type, $stationcode, $stationname) { $result = array(); $url = "http://www.bane.dk/visStation.asp?W=$type&S=$stationcode&artikelId=4275&statnavn=$stationname"; $buffer = download($url); $pos=0; $ankomstpos = stripos($buffer, "id='ankomsttabel'"); $count = 0; while(1) { // start med tid $pos = stripos($buffer, "", $pos); if ($pos == FALSE) break; if ($pos > $ankomstpos) break; $pos = stripos($buffer, "", $pos); $time = substr($buffer,$start, $stop-$start); $time = strip_tags($time); $result[$count][0] = trim($time); //Opdaterings-info $pos = stripos($buffer, "", $pos); $pos = stripos($buffer, "src='",$pos); $pos = stripos($buffer, "opdater",$pos); $pos += 7; $result[$count][1] = $buffer[$pos]; // Type $pos = stripos($buffer, "", $pos); $start = $pos + 20; $stop = stripos($buffer, "", $pos); $type = substr($buffer, $start, $stop-$start); $type = strip_tags($type); $type = str_replace(" ", " ", $type); $result[$count][2] = $type; // Destination $pos = stripos($buffer, "", $pos); $start = $pos + 16; $stop = stripos($buffer,"", $pos); $destination = substr($buffer, $start, $stop-$start); $destination = strip_tags($destination); $destination = str_replace(" ", " ", $destination); $result[$count][3] = $destination; //origin $pos = stripos($buffer, "", $pos); $start = $pos + 20; $stop = stripos($buffer,"", $pos); $origin = substr($buffer, $start, $stop-$start); $origin = strip_tags($origin); $origin = str_replace(" ", " ", $origin); $result[$count][4] = $origin; //current location $pos++; //since origin and current use the same search pattern, we must increase the position //so we don't get origin twice. $pos = stripos($buffer, "", $pos); $start = $pos + 20; $stop = stripos($buffer,"", $pos); $current = substr($buffer, $start, $stop-$start); $current = strip_tags($current); $current = str_replace(" ", " ", $current); $result[$count][5] = $current; //Status $pos = stripos($buffer, "", $pos); $start = $pos + 19; $stop = stripos($buffer,"", $pos); $status = substr($buffer, $start, $stop-$start); $status = str_replace(" ", " ", $status); $status = strip_tags($status); $result[$count][6] = $status; //note $pos = stripos($buffer, "", $pos); $start = $pos + 16; $stop = stripos($buffer,"", $pos); $note = substr($buffer, $start, $stop-$start); $note = str_replace(" ", " ", $note); $hasExtraI = stripos($note, ">i<") != FALSE; $note = strip_tags($note); if ($hasExtraI) $note = substr($note,0, strlen($note)-2); $result[$count][7] = $note; $count++; } return $result; } ?>