]> _ Git - tortuga-home.git/commitdiff
.
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 10 Jul 2023 18:00:09 +0000 (20:00 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 10 Jul 2023 18:00:09 +0000 (20:00 +0200)
.idea/workspace.xml
scripts/cron/cron.php
scripts/cron/traffic.php [new file with mode: 0644]
scripts/lib/traffic.php
scripts/lib/velib.php

index e4085bc866dbe50c113e7df8d00016a2e2b63d23..1540e88a6fa599c4125796835cdd72b84e9a641b 100644 (file)
@@ -5,8 +5,11 @@
   </component>
   <component name="ChangeListManager">
     <list default="true" id="352ce63a-b52a-41a2-979b-becda7920939" name="Default" comment=".">
+      <change afterPath="$PROJECT_DIR$/scripts/cron/traffic.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/scripts/lib/scenes.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/scenes.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/cron/cron.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/cron/cron.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/traffic.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/traffic.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/velib.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/velib.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
       <workItem from="1688750143650" duration="1624000" />
       <workItem from="1688808953960" duration="594000" />
       <workItem from="1688849303515" duration="1558000" />
-      <workItem from="1688897001591" duration="21616000" />
+      <workItem from="1688897001591" duration="22890000" />
+      <workItem from="1689010387612" duration="1396000" />
     </task>
     <task id="LOCAL-00502" summary=".">
       <created>1641726946298</created>
       <option name="project" value="LOCAL" />
       <updated>1687259667913</updated>
     </task>
-    <option name="localTasksCounter" value="568" />
+    <option name="localTasksCounter" value="569" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
index 13b9103e6228d4e8a192354870d73d6faa5678b5..7e547138a3ad41338db0b7e5cb86839588d84247 100644 (file)
@@ -219,7 +219,13 @@ function cronTraffic($cronmin, $force = false) {
                $limit = 60;
        }
        if ($force || !file_exists($cache) || filemtime($cache) < time() - $limit) {
-               $traffic = array('time' => date('H:i', time() + ($departure_in * 60)), 'jams' => trafficJams(), 'car' => itineraryIssy('driving'), 'subway' => itineraryIssy('transit'), 'bike' => itineraryIssy('bicycling'));
+               $traffic = [
+                       'time' => date('H:i', time() + ($departure_in * 60)),
+                       'jams' => trafficJams(),
+                       'car' => itineraryIssy(),
+                       'subway' => itineraryIssy('transit'),
+                       'bike' => itineraryIssy('bicycling')
+               ];
                $json = json_encode($traffic);
                file_put_contents($cache, $json);
                if (isset($_GET['force'])) {
diff --git a/scripts/cron/traffic.php b/scripts/cron/traffic.php
new file mode 100644 (file)
index 0000000..f050663
--- /dev/null
@@ -0,0 +1,3 @@
+<?php
+require_once 'cron.php';
+cronTraffic(1, true);
\ No newline at end of file
index cef50a8bcda4cab8315f69c2a13567fdeae7b788..a706902c07e85b13cea26aee2d47e4cc4ac87548 100644 (file)
@@ -1,33 +1,36 @@
 <?php
-function trafficJams()
-{
-    $dom = new DOMDocument();
-    @$dom->loadHTMLFile('http://www.sytadin.fr/');
-    $e = $dom->getElementById('cumul_bouchon');
-    if (null === $e) {
-        return '??';
-    }
-    $i = $e->getElementsByTagName('img')->item(0);
-    return intval((string)$i->getAttribute('alt'));
+function trafficJams() {
+       $dom = new DOMDocument();
+       @$dom->loadHTMLFile('http://www.sytadin.fr/');
+       $e = $dom->getElementById('cumul_bouchon');
+       if (null === $e) {
+               return '??';
+       }
+       $i = $e->getElementsByTagName('img')->item(0);
+       return intval((string)$i->getAttribute('alt'));
 }
 
-function itineraryIssy($mode = 'driving')
-{
-    global $departure_in;
-    $key = 'AIzaSyCmBfccaAxrhp5CH27sydD2n0jE-xFp9A8';
-    //$origin = '5 rue de Rochechouart, Paris';
-    $origin = 'place_id:ChIJISH0cEBu5kcRtWqJGS8R9vc';
-    // $destination = '11 rue René Jacques, Issy-les-moulineaux';
-    $destination = 'place_id:ChIJ_zVpOo965kcRLVwpXuatEOo';
-    $departure = time() + ($departure_in * 60);
-    $transit_mode = '';
-    if ($mode == 'transit') {
-        $transit_mode = '&transit_mode=rail';
-    }
-    $res = json_decode(file_get_contents('https://maps.googleapis.com/maps/api/directions/json?mode=' . $mode . $transit_mode . '&languages=fr&departure_time=' . $departure . '&origin=' . urlencode($origin) . '&destination=' . urlencode($destination) . '&key=' . $key), true);
-    if ($mode == 'driving') {
-        return round($res['routes'][0]['legs'][0]['duration_in_traffic']['value'] / 60);
-    } else {
-        return round($res['routes'][0]['legs'][0]['duration']['value'] / 60);
-    }
+function itineraryIssy($mode = 'driving') {
+       global $departure_in;
+       $key = 'AIzaSyCmBfccaAxrhp5CH27sydD2n0jE-xFp9A8';
+       //$origin = '5 rue de Rochechouart, Paris';
+       //$origin = 'place_id:ChIJISH0cEBu5kcRtWqJGS8R9vc';
+       if ($mode === 'driving') {
+               $origin = 'place_id:ChIJ28lUzD5u5kcRQo1KXiy9xys';
+       } else {
+               $origin = 'place_id:ChIJfdFmjj9u5kcRUyCLnw-tkIU';
+       }
+       // $destination = '11 rue René Jacques, Issy-les-moulineaux';
+       $destination = 'place_id:ChIJ_zVpOo965kcRLVwpXuatEOo';
+       $departure = time() + ($departure_in * 60);
+       $transit_mode = '';
+       if ($mode == 'transit') {
+               $transit_mode = '&transit_mode=rail';
+       }
+       $res = json_decode(file_get_contents('https://maps.googleapis.com/maps/api/directions/json?mode=' . $mode . $transit_mode . '&languages=fr&departure_time=' . $departure . '&origin=' . urlencode($origin) . '&destination=' . urlencode($destination) . '&key=' . $key), true);
+       if ($mode == 'driving') {
+               return round($res['routes'][0]['legs'][0]['duration_in_traffic']['value'] / 60) + 10;
+       } else {
+               return round($res['routes'][0]['legs'][0]['duration']['value'] / 60);
+       }
 }
\ No newline at end of file
index 2ccd0d55eb4da21bbfb86138ac2581e5a1ee381e..7e17f188a6232e9f376971d5b3856a723a120b53 100644 (file)
@@ -11,12 +11,12 @@ function velibStations($force = false)
         $limit = 60;
     }
 
-    if ($force || !file_exists($cache) || filemtime($cache) < time() - $limit) {
+    if ($force || !file_exists($cache) || filemtime($cache) < (time() - $limit)) {
         $allcache = __DIR__ . '/../../cache/velib.all.json';
-        $ffversion = rand('96', '105');
+        $ffversion = rand('105', '116');
         $thversion = rand('1', '100');
 
-        `curl 'https://velib-metropole-opendata.smoove.pro/opendata/Velib_Metropole/station_status.json' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv$ffversion.0) Gecko/20100101 Firefox/$ffversion.0 TortugaHome/$thversion.0' --output $cache`;
+        `curl 'https://velib-metropole-opendata.smoove.pro/opendata/Velib_Metropole/station_status.json' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv$ffversion.0) Gecko/20100101 Firefox/$ffversion.0 TortugaHome/$thversion.0' --output $allcache`;
         $alldata = json_decode(file_get_contents($allcache), true);
 
         $stations = ['Cadet' => '9101', 'Bleue' => '9113', 'Folies bergères' => '9011', 'Square Montholon' => '9009', 'Le Pelletier' => '9014'];