Пример #1
0
$l_stations = array();
function getStations()
{
    global $l_stations;
    $station = "";
    $lines = file("project/stations_uk.txt");
    for ($i = 0; $i < count($lines); $i++) {
        if (trim($lines[$i]) != "") {
            $lines[$i] = trim(str_replace("\n", "", $lines[$i]));
            array_push($l_stations, $lines[$i]);
        }
    }
}
function getStation($data)
{
    $station = "";
    $station = search($data, "<title>", "</title>");
    $station = $station . "<";
    $station = search($station, "from ", "<");
    return $station;
}
function search($str, $word1, $word2)
{
    preg_match('~' . preg_quote($word1) . '(.*?)' . preg_quote($word2) . '~is', $str, $match);
    $res = isset($match[1]) ? $match[1] : "";
    return $res;
}
getStations();
getData($l_stations);
//http://www.realtimetrains.co.uk/search/advanced/ABW/2015/06/18/1200
//$data =  openUrl("ABW","2015/06/18","1100");
Пример #2
0
function main()
{
    switch ($_GET["get"]) {
        case "stations":
            connectDB();
            echo json_encode(getStations($_GET["lat"], $_GET["lng"], $_GET["radius"]));
            break;
        case "station":
            connectDB();
            echo json_encode(getStation($_GET["id"]));
            break;
        case "cron":
            global $cronjob_key;
            if ($_GET["key"] == $cronjob_key) {
                cron();
            }
            break;
        case "info":
            connectDB();
            getInfo(true);
            break;
        default:
            header("Location: https://github.com/xXSparkeyy/harbour-spritradar");
    }
}