@@ -16,9 +16,9 @@ discard block |
||
16 | 16 | |
17 | 17 | public function cUrlMulti(array $url) |
18 | 18 | { |
19 | - $chandle= []; |
|
19 | + $chandle = []; |
|
20 | 20 | $mhandle = curl_multi_init(); |
21 | - for ($i=0; $i < count($url); $i++) { |
|
21 | + for ($i = 0; $i < count($url); $i++) { |
|
22 | 22 | array_push($chandle, curl_init($url[$i])); |
23 | 23 | curl_setopt($chandle[$i], CURLOPT_RETURNTRANSFER, true); |
24 | 24 | curl_multi_add_handle($mhandle, $chandle[$i]); |
@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | } while ($running); |
31 | 31 | |
32 | 32 | //close the handles |
33 | - for ($i=0; $i < count($chandle); $i++) { |
|
33 | + for ($i = 0; $i < count($chandle); $i++) { |
|
34 | 34 | curl_multi_remove_handle($mhandle, $chandle[$i]); |
35 | 35 | } |
36 | 36 | |
37 | 37 | curl_multi_close($mhandle); |
38 | 38 | |
39 | 39 | $json = []; |
40 | - for ($i=0; $i < count($chandle); $i++) { |
|
40 | + for ($i = 0; $i < count($chandle); $i++) { |
|
41 | 41 | array_push($json, curl_multi_getcontent($chandle[$i])); |
42 | 42 | } |
43 | 43 | return $json; |
@@ -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"]); |
@@ -52,16 +52,16 @@ discard block |
||
52 | 52 | $ipNumber = $request->getGet("ip"); |
53 | 53 | $test = $validateIP->validate($ipNumber); |
54 | 54 | if ($test[0]) { |
55 | - $location = $getJson->cUrl($ipstack["url"]. $ipNumber. '?access_key='. $ipstack["key"]); |
|
55 | + $location = $getJson->cUrl($ipstack["url"].$ipNumber.'?access_key='.$ipstack["key"]); |
|
56 | 56 | $location = json_decode($location, true); |
57 | 57 | $latitude = $location["latitude"]; |
58 | 58 | $longitude = $location["longitude"]; |
59 | 59 | $location = [$location["city"], $latitude, $longitude]; |
60 | 60 | } else { |
61 | - $search = array('å','ä','ö'); |
|
62 | - $replace = array('a','a','o'); |
|
61 | + $search = array('å', 'ä', 'ö'); |
|
62 | + $replace = array('a', 'a', 'o'); |
|
63 | 63 | $ipNumber = str_replace($search, $replace, $ipNumber); |
64 | - $location = $getJson->cUrl($mapquest["url"]. $mapquest["key"]. $mapquest["extra"]. $ipNumber); |
|
64 | + $location = $getJson->cUrl($mapquest["url"].$mapquest["key"].$mapquest["extra"].$ipNumber); |
|
65 | 65 | $location = json_decode($location, true); |
66 | 66 | $latitude = $location["results"][0]["locations"][0]["latLng"]["lat"]; |
67 | 67 | $longitude = $location["results"][0]["locations"][0]["latLng"]["lng"]; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | $extra = "?lang=sv&units=auto"; |
73 | 73 | $mapDiv = $map->getMap($latitude, $longitude); |
74 | - $weatherJson = $getJson->cUrl($darksky["url"]. $darksky["key"]. "/". $latitude. ",". $longitude. $extra); |
|
74 | + $weatherJson = $getJson->cUrl($darksky["url"].$darksky["key"]."/".$latitude.",".$longitude.$extra); |
|
75 | 75 | |
76 | 76 | $weather = json_decode($weatherJson, true); |
77 | 77 | $page->add("weather/weather", [ |
@@ -103,21 +103,21 @@ discard block |
||
103 | 103 | $ipNumber = $request->getGet("ip"); |
104 | 104 | $test = $validateIP->validate($ipNumber); |
105 | 105 | if ($test[0]) { |
106 | - $location = $getJson->cUrl($ipstack["url"]. $ipNumber. '?access_key='. $ipstack["key"]); |
|
106 | + $location = $getJson->cUrl($ipstack["url"].$ipNumber.'?access_key='.$ipstack["key"]); |
|
107 | 107 | $location = json_decode($location, true); |
108 | 108 | $latitude = $location["latitude"]; |
109 | 109 | $longitude = $location["longitude"]; |
110 | 110 | $location = [$location["city"], $latitude, $longitude]; |
111 | 111 | } else { |
112 | - $search = array('å','ä','ö'); |
|
113 | - $replace = array('a','a','o'); |
|
112 | + $search = array('å', 'ä', 'ö'); |
|
113 | + $replace = array('a', 'a', 'o'); |
|
114 | 114 | $ipNumber = str_replace($search, $replace, $ipNumber); |
115 | 115 | $location = $getJson->cUrl("http://www.mapquestapi.com/geocoding/v1/address?key=HVd7TbTeHvGGiGF14rSntAMMq3VDSAtT&location=".$ipNumber); |
116 | 116 | $location = json_decode($location, true); |
117 | 117 | |
118 | 118 | $latitude = $location["results"][0]["locations"][0]["latLng"]["lat"]; |
119 | 119 | $longitude = $location["results"][0]["locations"][0]["latLng"]["lng"]; |
120 | - $location = $getJson->cUrl("http://www.mapquestapi.com/geocoding/v1/reverse?key=HVd7TbTeHvGGiGF14rSntAMMq3VDSAtT&location=".$latitude. ",". $longitude); |
|
120 | + $location = $getJson->cUrl("http://www.mapquestapi.com/geocoding/v1/reverse?key=HVd7TbTeHvGGiGF14rSntAMMq3VDSAtT&location=".$latitude.",".$longitude); |
|
121 | 121 | $location = json_decode($location, true); |
122 | 122 | $city = $location["results"][0]["locations"][0]["adminArea5"] ?? "Ingen ort"; |
123 | 123 | $location = [$city, $latitude, $longitude]; |
@@ -125,16 +125,16 @@ discard block |
||
125 | 125 | $url = []; |
126 | 126 | $extra = "?lang=sv&units=auto"; |
127 | 127 | $time = time() - (30 * 24 * 60 * 60); |
128 | - for ($i=0; $i < 31; $i++) { |
|
129 | - $time = time() - ($i * 24 * 60 * 60); |
|
130 | - array_push($url, $darksky["url"]. $darksky["key"]. "/". $latitude. ",". $longitude. ",". $time. $extra); |
|
128 | + for ($i = 0; $i < 31; $i++) { |
|
129 | + $time = time() - ($i * 24 * 60 * 60); |
|
130 | + array_push($url, $darksky["url"].$darksky["key"]."/".$latitude.",".$longitude.",".$time.$extra); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
134 | 134 | $mapDiv = $map->getMap($latitude, $longitude); |
135 | 135 | $weatherJson = $getJson->cUrlMulti($url); |
136 | 136 | $weather = []; |
137 | - for ($i=0; $i < count($weatherJson); $i++) { |
|
137 | + for ($i = 0; $i < count($weatherJson); $i++) { |
|
138 | 138 | array_push($weather, json_decode($weatherJson[$i], true)); |
139 | 139 | } |
140 | 140 |
@@ -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="<?=$weather[$i]["daily"]["data"][0]["icon"]?>"></i> |
@@ -6,7 +6,7 @@ |
||
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"); |
@@ -6,7 +6,7 @@ |
||
6 | 6 | "services" => [ |
7 | 7 | "ipstack" => [ |
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("ipstack.php"); |
@@ -6,7 +6,7 @@ |
||
6 | 6 | "services" => [ |
7 | 7 | "mapquest" => [ |
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("mapquest.php"); |