示例#1
0
 function listChannels()
 {
     $response = openUrl($this->listurl);
     $result = '';
     if (!preg_match_all('|<a href="/program-tv/stacje/(.*?)">(.*?)</a>|', $response, $matches)) {
         echo '[TELEMAN] Unable to find channels list!' . "\n";
         return $result;
     }
     foreach ($matches[2] as $number => $value) {
         $result .= $value . ' => ' . $this->listurl . $matches[1][$number] . "\n";
     }
     return $result;
 }
示例#2
0
 function listChannels()
 {
     $response = openUrl($this->listurl);
     $result = '';
     if (!preg_match_all('|<div class="channel_wrapper">(.*?)<a href="(.*?)">|sm', $response, $matches)) {
         echo '[IPLA] Unable to find channels list!' . "\n";
         return $result;
     }
     foreach ($matches[2] as $number => $value) {
         $url = substr($matches[2][$number], strrpos($matches[2][$number], '/') + 1);
         $name = ucwords(str_replace('-', ' ', $url));
         $result .= $name . ' => ' . $this->listurl . $url . "\n";
     }
     return $result;
 }
示例#3
0
 function listChannels()
 {
     $result = '';
     foreach (array('0,9', 'a,c', 'd,f', 'g,i', 'j,l', 'm,p', 'r,t', 'u,z') as $part) {
         $response = openUrl($this->listurl . ',' . $part . '.html');
         if (!preg_match_all('|<div class="wrapper-table"><a href="(.*?)" class="channel">.*?<span class="channel-name">(.*?)</span></a></div>|sm', $response, $matches)) {
             echo '[ONET] Unable to find channels list!' . "\n";
             return $result;
         }
         foreach ($matches[2] as $number => $value) {
             $result .= $value . ' => ' . $this->baseurl . $matches[1][$number] . "\n";
         }
     }
     return $result;
 }
示例#4
0
function getData($l_stations)
{
    //structure
    $l_data = array(array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array());
    $nb_res = 0;
    $nb_commit = 0;
    $td = array();
    //prepare time for url call -2H actual time
    $localtime = date('H');
    $stime = $localtime - 2;
    if ($stime == -1) {
        $stime = 23;
    }
    if ($stime == -2) {
        $stime = 22;
    }
    if ($stime < 10) {
        $stime = "0" . $stime . "10";
    } else {
        $stime = $stime . "10";
    }
    //prepare date for url call
    $sdate = date("Y/m/d");
    if ($localtime == "00") {
        $parti = explode("/", $sdate);
        $sdate = giorno_prima($parti[2], $parti[1], $parti[0]);
    }
    $dbdate = date('Y-m-d');
    //make the url call for datas
    for ($i = 0; $i < count($l_stations); $i++) {
        //set_time_limit (5);
        echo "{$i}/" . count($l_stations) . " - ";
        $data = openUrl($l_stations[$i], $sdate, $stime);
        //echo "getstazione:$stazione<br><br>";
        if (strlen($data) > 100) {
            $data2 = search($data, "/thead", "<footer");
            //isolate the block of info
            $stazione = getStation($data);
            //echo $data2;
            $data2 = str_replace('<tr class="wtt call_public">', "", $data2);
            $data2 = str_replace('<tr class="wtt nonpassenger pass">', "", $data2);
            //RINFORZARE IL PARSING QUALCHE NUOVA CLASS METTE IN CRISI
            $data2 = str_replace('<span>', "", $data2);
            $data2 = str_replace('</span>', "", $data2);
            $tr = explode("</tr>", $data2);
            $nb_res = count($tr) - 1;
            $nb_commit = $nb_commit + $nb_res;
            //count the sum of lines for all calls
            echo "NUMERO RIGHE =" . $nb_commit . "<br>";
            for ($k = 0; $k < count($tr); $k++) {
                $td[$k] = explode("</td>", $tr[$k]);
            }
            for ($j = 0; $j < count($tr) - 1; $j++) {
                //array_pop($td[$j]);
                //for ($k = 0; $k < count($td[$j]); $k++) //produce rubbish at end
                for ($k = 1; $k < 10; $k++) {
                    $val = strip_tags($td[$j][$k]);
                    array_push($l_data[$k], $val);
                    //echo $val."|";
                }
                //echo "<br>";
                array_push($l_data[10], $stazione);
                array_push($l_data[0], $dbdate);
            }
            echo "<br>";
        }
    }
    no_none($l_data, $nb_commit);
    pdidb($l_data, $nb_commit, $stime);
}
示例#5
0
function getData($l_stations)
{
    $l_data = array(array(), array(), array(), array());
    $nb = 0;
    $localtime = date('H');
    $stime = $localtime - 1;
    if ($stime == -1) {
        $stime = 23;
    }
    echo "stime = {$stime}<br>";
    $stime = $stime . "00";
    if (strlen($stime) == 3) {
        $stime = "0" . $stime;
    }
    $dbtime = $localtime . ":00";
    $sdate1 = date("Y/m/d");
    global $day;
    $day = date("w");
    if ($localtime == "00") {
        $parti = explode("/", $sdate1);
        $sdate = giorno_prima($parti[2], $parti[1], $parti[0]);
        if ($day != 0) {
            $day--;
        } else {
            $day = 6;
        }
    } else {
        $sdate = date('mdy');
    }
    for ($i = 0; $i < count($l_stations); $i++) {
        $data = openUrl($l_stations[$i], $sdate, $stime);
        $xml = simplexml_load_string($data);
        foreach ($xml->arrivals->arrival as $dep) {
            $dbdate = date("Y-m-d H:i:s", (int) $dep->time);
            $delay = $dep['delay'];
            $vehicle = str_replace("BE.NMBS.", "", $dep->vehicle);
            //if ((substr($dbdate,-8,2))== substr($stime,0,2)) $con =1; else $con =0;
            //echo substr($dbdate,-8,2)." - ".substr($stime,0,2)." $con <br>";
            if (substr($dbdate, -8, 2) == substr($stime, 0, 2)) {
                $nb++;
                echo substr($dbdate, -8, 2) . "==" . substr($stime, 0, 2);
                array_push($l_data[0], $dbdate);
                array_push($l_data[1], $l_stations[$i]);
                array_push($l_data[2], $delay);
                array_push($l_data[3], $vehicle);
                echo "{$nb}-ARRIVAL" . $dbdate;
                echo " ";
                echo $l_stations[$i];
                echo " ";
                echo $delay;
                echo " ";
                echo $vehicle;
                echo "<br>";
            }
        }
        foreach ($xml->departures->departure as $dep) {
            $dbdate = date("Y-m-d H:i:s", (int) $dep->time);
            $delay = $dep['delay'];
            $vehicle = str_replace("BE.NMBS.", "", $dep->vehicle);
            if (substr($dbdate, -8, 2) == substr($stime, 0, 2)) {
                echo substr($dbdate, -8, 2) . "==" . substr($stime, 0, 2);
                $nb++;
                array_push($l_data[0], $dbdate);
                array_push($l_data[1], $l_stations[$i]);
                array_push($l_data[2], $delay);
                array_push($l_data[3], $vehicle);
                echo "{$nb}-DEPARTURE" . $dbdate;
                echo " ";
                echo $l_stations[$i];
                echo " ";
                echo $delay;
                echo " ";
                echo $vehicle;
                echo "<br>";
            }
        }
    }
    pdidb($l_data, $nb);
}
示例#6
0
    $count = 0;
    $listOfFolders = scandir(".");
    foreach ($listOfFolders as $entry) {
        if ($entry != "." && $entry != "..") {
            if (is_dir($entry) && $entry != "php" && $entry != "css" && $entry != "js") {
                if ($countMin <= $count && $count < $countMax) {
                    echo "----- Update #" . $count . " de " . $entry . " -----\n";
                    echo "Copie de php/functions.php  ->  " . $entry . "/php/functions.php\n";
                    copy("php/functions.php", $entry . "/php/functions.php");
                    echo "Copie de php/project.php  ->  " . $entry . "/php/project.php\n";
                    copy("php/project.php", $entry . "/php/project.php");
                    echo "Copie de create.zip  ->  " . $entry . "/php/create.zip\n";
                    copy("create.zip", $entry . "/php/create.zip");
                    $url = "http://project.memorekall.fr/" . $entry . "/php/project.php?update=now";
                    echo "Update de " . $url . "\n";
                    openUrl($url);
                    echo "\n\n";
                    exit(0);
                }
                $count++;
            }
        }
    }
    exit;
}
//Download un fichier
function openUrl($url)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
示例#7
0
function getData($l_stations)
{
    $nb_t = 0;
    global $train_id;
    $nb_res = 0;
    $ts = 0;
    $l_data = array(array(), array(), array(), array(), array(), array());
    for ($i = 0; $i < count($l_stations); $i++) {
        echo "{$i} ";
        $data = openUrl($l_stations[$i]);
        $obj = json_decode($data, true);
        $nb_res = count($obj);
        if ($nb_res != 0) {
            if ($obj[$nb_res - 1]["fermata"]["programmata"] !== null) {
                if (verifTimeStamp($obj[$nb_res - 1]["fermata"]["programmata"]) == 1) {
                    for ($j = 0; $j < $nb_res; $j++) {
                        if ($obj[$j]["fermata"]["programmata"] !== null and $obj[$j]["fermata"]["effettiva"] !== null) {
                            $ts = $obj[$j]["fermata"]["effettiva"];
                            $ts_pro = $obj[$j]["fermata"]["programmata"];
                            $nb_t++;
                            array_push($l_data[0], $obj[0]["stazione"]);
                            array_push($l_data[1], $obj[$j]["stazione"]);
                            array_push($l_data[2], timeStampToDate($ts_pro));
                            array_push($l_data[3], timeStampToDelay($ts_pro, $ts));
                            array_push($l_data[4], $train_id[$i]);
                            array_push($l_data[5], $obj[count($obj) - 1]["stazione"]);
                            $x = count($l_data[0]) - 1;
                            echo "<span style='color:{$colore};font-family:arial'>";
                            echo "{$nb_t} - ";
                            echo $l_data[0][$x];
                            echo " ";
                            echo $l_data[1][$x];
                            echo " ";
                            echo $l_data[2][$x];
                            echo " ";
                            echo $l_data[3][$x];
                            echo " ";
                            echo $l_data[4][$x];
                            echo " ";
                            echo $l_data[5][$x];
                            echo "<br>";
                            echo "</span>";
                        }
                    }
                }
            }
        }
        echo "<br><br>";
    }
    pdidb($l_data, $nb_t);
}