@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | "services" => [ |
7 | 7 | "darksky" => [ |
8 | 8 | "shared" => true, |
9 | - "callback" => function () { |
|
9 | + "callback" => function() { |
|
10 | 10 | // Load the configuration files |
11 | 11 | $cfg = $this->get("configuration"); |
12 | 12 | $config = $cfg->load("darksky.php"); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | ], |
17 | 17 | "mapquest" => [ |
18 | 18 | "shared" => true, |
19 | - "callback" => function () { |
|
19 | + "callback" => function() { |
|
20 | 20 | // Load the configuration files |
21 | 21 | $cfg = $this->get("configuration"); |
22 | 22 | $config = $cfg->load("mapquest.php"); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | ], |
27 | 27 | "ipstack" => [ |
28 | 28 | "shared" => true, |
29 | - "callback" => function () { |
|
29 | + "callback" => function() { |
|
30 | 30 | // Load the configuration files |
31 | 31 | $cfg = $this->get("configuration"); |
32 | 32 | $config = $cfg->load("ipstack.php"); |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | $api = $this->di->get("ipstack"); |
19 | 19 | $ipstack = $api["config"]; |
20 | 20 | $getipInfo = new Models\Curl; |
21 | - $extra = "&fields=ip"; |
|
22 | - $userIp = $getipInfo->cUrl($ipstack["url"]. "check". '?access_key='. $ipstack["key"]. $extra); |
|
21 | + $extra = "&fields=ip"; |
|
22 | + $userIp = $getipInfo->cUrl($ipstack["url"]."check".'?access_key='.$ipstack["key"].$extra); |
|
23 | 23 | $apiResult = json_decode($userIp, true); |
24 | 24 | |
25 | 25 | $session->set("userIp", $apiResult["ip"]); |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | $location = $locationHandler->getLocation($ipNumber, $ipstack["config"], $mapquest["config"]); |
51 | 51 | |
52 | 52 | $mapDiv = $map->getMap($location["latitude"], $location["longitude"]); |
53 | - $weatherJson = $getJson->cUrl($darksky["config"]["url"]. $darksky["config"]["key"]. "/". $location["latitude"]. ",". $location["longitude"]. "?lang=sv&units=auto"); |
|
53 | + $weatherJson = $getJson->cUrl($darksky["config"]["url"].$darksky["config"]["key"]."/".$location["latitude"].",".$location["longitude"]."?lang=sv&units=auto"); |
|
54 | 54 | |
55 | 55 | $weather = json_decode($weatherJson, true); |
56 | 56 | $page->add("weather/weather", ["location" => $location, "mapDiv" => $mapDiv, "weather" => $weather]); |
57 | 57 | |
58 | - return $page->render(["title" => $title,]); |
|
58 | + return $page->render(["title" => $title, ]); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | public function weatherOldActionGet() |
@@ -75,21 +75,21 @@ discard block |
||
75 | 75 | $location = $locationHandler->getLocation($ipNumber, $ipstack["config"], $mapquest["config"]); |
76 | 76 | |
77 | 77 | $url = []; |
78 | - for ($i=0; $i < 31; $i++) { |
|
79 | - $time = time() - ($i * 24 * 60 * 60); |
|
80 | - array_push($url, $darksky["config"]["url"]. $darksky["config"]["key"]. "/". $location["latitude"]. ",". $location["longitude"]. ",". $time. "?lang=sv&units=auto"); |
|
78 | + for ($i = 0; $i < 31; $i++) { |
|
79 | + $time = time() - ($i * 24 * 60 * 60); |
|
80 | + array_push($url, $darksky["config"]["url"].$darksky["config"]["key"]."/".$location["latitude"].",".$location["longitude"].",".$time."?lang=sv&units=auto"); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | $mapDiv = $map->getMap($location["latitude"], $location["longitude"]); |
84 | 84 | $weatherJson = $getJson->cUrlMulti($url); |
85 | 85 | $weather = []; |
86 | 86 | $count = count($weatherJson); |
87 | - for ($i=0; $i < $count; $i++) { |
|
87 | + for ($i = 0; $i < $count; $i++) { |
|
88 | 88 | array_push($weather, json_decode($weatherJson[$i], true)); |
89 | 89 | } |
90 | 90 | |
91 | 91 | $page->add("weather/weatherOld", ["location" => $location, "mapDiv" => $mapDiv, "weather" => $weather]); |
92 | 92 | |
93 | - return $page->render(["title" => $title,]); |
|
93 | + return $page->render(["title" => $title, ]); |
|
94 | 94 | } |
95 | 95 | } |
@@ -16,10 +16,10 @@ discard block |
||
16 | 16 | |
17 | 17 | public function cUrlMulti(array $url) |
18 | 18 | { |
19 | - $chandle= []; |
|
19 | + $chandle = []; |
|
20 | 20 | $mhandle = curl_multi_init(); |
21 | 21 | $count = count($url); |
22 | - for ($i=0; $i < $count; $i++) { |
|
22 | + for ($i = 0; $i < $count; $i++) { |
|
23 | 23 | array_push($chandle, curl_init($url[$i])); |
24 | 24 | curl_setopt($chandle[$i], CURLOPT_RETURNTRANSFER, true); |
25 | 25 | curl_multi_add_handle($mhandle, $chandle[$i]); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | //close the handles |
34 | 34 | $count = count($chandle); |
35 | - for ($i=0; $i < $count; $i++) { |
|
35 | + for ($i = 0; $i < $count; $i++) { |
|
36 | 36 | curl_multi_remove_handle($mhandle, $chandle[$i]); |
37 | 37 | } |
38 | 38 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | $json = []; |
42 | 42 | $count = count($chandle); |
43 | - for ($i=0; $i < $count; $i++) { |
|
43 | + for ($i = 0; $i < $count; $i++) { |
|
44 | 44 | array_push($json, curl_multi_getcontent($chandle[$i])); |
45 | 45 | } |
46 | 46 | return $json; |
@@ -13,7 +13,7 @@ |
||
13 | 13 | ?> |
14 | 14 | <div class="container days"> |
15 | 15 | <?php |
16 | - for ($i=0; $i < count($weather); $i++) { |
|
16 | + for ($i = 0; $i < count($weather); $i++) { |
|
17 | 17 | ?> |
18 | 18 | <div class="container card day"> |
19 | 19 | <i class="<?=htmlentities($weather[$i]["daily"]["data"][0]["icon"])?>"></i> |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | $test = $validateIP->validate($ipNumber); |
13 | 13 | |
14 | 14 | if ($test[0]) { |
15 | - $location = $getJson->cUrl($ipstack["url"]. $ipNumber. '?access_key='. $ipstack["key"]); |
|
15 | + $location = $getJson->cUrl($ipstack["url"].$ipNumber.'?access_key='.$ipstack["key"]); |
|
16 | 16 | $location = json_decode($location, true); |
17 | 17 | $latitude = $location["latitude"]; |
18 | 18 | $longitude = $location["longitude"]; |
@@ -20,10 +20,10 @@ discard block |
||
20 | 20 | return $location; |
21 | 21 | } |
22 | 22 | |
23 | - $search = array('å','ä','ö'); |
|
24 | - $replace = array('a','a','o'); |
|
23 | + $search = array('å', 'ä', 'ö'); |
|
24 | + $replace = array('a', 'a', 'o'); |
|
25 | 25 | $ipNumber = str_replace($search, $replace, $ipNumber); |
26 | - $location = $getJson->cUrl($mapquest["url"]. $mapquest["key"]. $mapquest["extra"]. $ipNumber); |
|
26 | + $location = $getJson->cUrl($mapquest["url"].$mapquest["key"].$mapquest["extra"].$ipNumber); |
|
27 | 27 | $location = json_decode($location, true); |
28 | 28 | $latitude = $location["results"][0]["locations"][0]["latLng"]["lat"]; |
29 | 29 | $longitude = $location["results"][0]["locations"][0]["latLng"]["lng"]; |