</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">
$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'])) {
--- /dev/null
+<?php
+require_once 'cron.php';
+cronTraffic(1, true);
\ No newline at end of file
<?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
$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'];