@@ -4,27 +4,27 @@ |
||
4 | 4 | |
5 | 5 | ?> |
6 | 6 | <h1> Weather data based on IP-address</h1> |
7 | -<?php if ($resTwo["type"] == null) : ?> |
|
7 | +<?php if ($resTwo[ "type" ] == null) : ?> |
|
8 | 8 | <p>This isn't a valid IP-address</p> |
9 | 9 | <?php else : ?> |
10 | - <p>IP-address: <?= $resTwo["ip"] ?></p> |
|
11 | - <p>Continent: <?= $resTwo["continent_name"] ?></p> |
|
12 | - <p>Country: <?= $resTwo["country_name"] ?></p> |
|
13 | - <p>Region: <?= $resTwo["region_name"] ?></p> |
|
14 | - <p>City: <?= $resTwo["city"] ?></p> |
|
15 | - <p>Latitude: <?= $resTwo["latitude"] ?></p> |
|
16 | - <p>Longitude: <?= $resTwo["longitude"] ?></p> |
|
10 | + <p>IP-address: <?= $resTwo[ "ip" ] ?></p> |
|
11 | + <p>Continent: <?= $resTwo[ "continent_name" ] ?></p> |
|
12 | + <p>Country: <?= $resTwo[ "country_name" ] ?></p> |
|
13 | + <p>Region: <?= $resTwo[ "region_name" ] ?></p> |
|
14 | + <p>City: <?= $resTwo[ "city" ] ?></p> |
|
15 | + <p>Latitude: <?= $resTwo[ "latitude" ] ?></p> |
|
16 | + <p>Longitude: <?= $resTwo[ "longitude" ] ?></p> |
|
17 | 17 | <?php endif; ?> |
18 | 18 | <?php if (sizeOf($resOne) == 2) : ?> |
19 | - <p><?= $resOne["error"] ?></p> |
|
19 | + <p><?= $resOne[ "error" ] ?></p> |
|
20 | 20 | <?php else : ?> |
21 | 21 | <h2>Weather for day/time</h2> |
22 | - <?php foreach ($resOne["daily"]["data"] as $value) : ?> |
|
23 | - <h3><?= gmdate("Y-m-d/H:i:s", $value["time"]) ?></h3> |
|
24 | - <p>Weather: <?= $value["summary"] ?></p> |
|
22 | + <?php foreach ($resOne[ "daily" ][ "data" ] as $value) : ?> |
|
23 | + <h3><?= gmdate("Y-m-d/H:i:s", $value[ "time" ]) ?></h3> |
|
24 | + <p>Weather: <?= $value[ "summary" ] ?></p> |
|
25 | 25 | <?php endforeach ?> |
26 | 26 | <?php endif ?> |
27 | -<?php if (!$resTwo["type"] == null) : ?> |
|
27 | +<?php if (!$resTwo[ "type" ] == null) : ?> |
|
28 | 28 | <h2>Karta över platsen</h2> |
29 | - <iframe width="75%" height="550" src="http://www.openstreetmap.org/export/embed.html?bbox=<?= $resTwo["longitude"] ?>%2C<?= $resTwo["latitude"] ?>%2C<?= $resTwo["longitude"] ?>%2C<?= $resTwo["latitude"] ?>&marker=<?= $resTwo["latitude"] ?>%2C<?= $resTwo["longitude"] ?>&layers=ND"></iframe> |
|
29 | + <iframe width="75%" height="550" src="http://www.openstreetmap.org/export/embed.html?bbox=<?= $resTwo[ "longitude" ] ?>%2C<?= $resTwo[ "latitude" ] ?>%2C<?= $resTwo[ "longitude" ] ?>%2C<?= $resTwo[ "latitude" ] ?>&marker=<?= $resTwo[ "latitude" ] ?>%2C<?= $resTwo[ "longitude" ] ?>&layers=ND"></iframe> |
|
30 | 30 | <?php endif; ?> |
@@ -6,7 +6,8 @@ discard block |
||
6 | 6 | <h1> Weather data based on IP-address</h1> |
7 | 7 | <?php if ($resTwo["type"] == null) : ?> |
8 | 8 | <p>This isn't a valid IP-address</p> |
9 | -<?php else : ?> |
|
9 | +<?php else { |
|
10 | + : ?> |
|
10 | 11 | <p>IP-address: <?= $resTwo["ip"] ?></p> |
11 | 12 | <p>Continent: <?= $resTwo["continent_name"] ?></p> |
12 | 13 | <p>Country: <?= $resTwo["country_name"] ?></p> |
@@ -14,10 +15,13 @@ discard block |
||
14 | 15 | <p>City: <?= $resTwo["city"] ?></p> |
15 | 16 | <p>Latitude: <?= $resTwo["latitude"] ?></p> |
16 | 17 | <p>Longitude: <?= $resTwo["longitude"] ?></p> |
17 | -<?php endif; ?> |
|
18 | +<?php endif; |
|
19 | +} |
|
20 | +?> |
|
18 | 21 | <?php if (sizeOf($resOne) == 2) : ?> |
19 | 22 | <p><?= $resOne["error"] ?></p> |
20 | -<?php else : ?> |
|
23 | +<?php else { |
|
24 | + : ?> |
|
21 | 25 | <h2>Weather for day/time</h2> |
22 | 26 | <?php foreach ($resOne["daily"]["data"] as $value) : ?> |
23 | 27 | <h3><?= gmdate("Y-m-d/H:i:s", $value["time"]) ?></h3> |
@@ -27,4 +31,6 @@ discard block |
||
27 | 31 | <?php if (!$resTwo["type"] == null) : ?> |
28 | 32 | <h2>Karta över platsen</h2> |
29 | 33 | <iframe width="75%" height="550" src="http://www.openstreetmap.org/export/embed.html?bbox=<?= $resTwo["longitude"] ?>%2C<?= $resTwo["latitude"] ?>%2C<?= $resTwo["longitude"] ?>%2C<?= $resTwo["latitude"] ?>&marker=<?= $resTwo["latitude"] ?>%2C<?= $resTwo["longitude"] ?>&layers=ND"></iframe> |
30 | -<?php endif; ?> |
|
34 | +<?php endif; |
|
35 | +} |
|
36 | +?> |
@@ -30,8 +30,8 @@ |
||
30 | 30 | $page = $this->di->get("page"); |
31 | 31 | $curl = $this->di->get("curl"); |
32 | 32 | |
33 | - $curl->getIpData($this->address, $this->api["ip_key"]); |
|
34 | - $curl->getWeatherData($this->api["weather_key"]); |
|
33 | + $curl->getIpData($this->address, $this->api[ "ip_key" ]); |
|
34 | + $curl->getWeatherData($this->api[ "weather_key" ]); |
|
35 | 35 | |
36 | 36 | $resOne = $curl->weatherData; |
37 | 37 | $resTwo = $curl->ipData; |
@@ -14,24 +14,24 @@ |
||
14 | 14 | $this->api = require ANAX_INSTALL_PATH . "/config/keys.php"; |
15 | 15 | $address = $this->di->get("request")->getGet("address"); |
16 | 16 | $curl = $this->di->get("curl"); |
17 | - $curl->getIpData($address, $this->api["ip_key"]); |
|
18 | - $curl->getWeatherData($this->api["weather_key"]); |
|
17 | + $curl->getIpData($address, $this->api[ "ip_key" ]); |
|
18 | + $curl->getWeatherData($this->api[ "weather_key" ]); |
|
19 | 19 | $resOne = $curl->weatherData; |
20 | 20 | $resTwo = $curl->ipData; |
21 | 21 | |
22 | 22 | if (sizeOf($resOne) == 2) { |
23 | 23 | $json = [ |
24 | - "error" => $resOne["error"], |
|
24 | + "error" => $resOne[ "error" ], |
|
25 | 25 | ]; |
26 | 26 | |
27 | - return [$json]; |
|
27 | + return [ $json ]; |
|
28 | 28 | } else { |
29 | 29 | $json = [ |
30 | 30 | "ip_data" => $resTwo, |
31 | - "daily_weather" => $resOne["daily"]["data"], |
|
31 | + "daily_weather" => $resOne[ "daily" ][ "data" ], |
|
32 | 32 | ]; |
33 | 33 | |
34 | - return [$json]; |
|
34 | + return [ $json ]; |
|
35 | 35 | } |
36 | 36 | } |
37 | 37 | } |
@@ -8,9 +8,9 @@ discard block |
||
8 | 8 | class CurlWrapModel implements ContainerInjectableInterface |
9 | 9 | { |
10 | 10 | use ContainerInjectableTrait; |
11 | - public $ipData = []; |
|
12 | - public $weatherData = []; |
|
13 | - public $map = []; |
|
11 | + public $ipData = [ ]; |
|
12 | + public $weatherData = [ ]; |
|
13 | + public $map = [ ]; |
|
14 | 14 | |
15 | 15 | public function getIpData($address, $key) |
16 | 16 | { |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | public function getWeatherData($weatherKey) |
31 | 31 | { |
32 | - $curl = curl_init('https://api.darksky.net/forecast/' . $weatherKey . '/' . $this->ipData["latitude"] . "," . $this->ipData["longitude"]); |
|
32 | + $curl = curl_init('https://api.darksky.net/forecast/' . $weatherKey . '/' . $this->ipData[ "latitude" ] . "," . $this->ipData[ "longitude" ]); |
|
33 | 33 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
34 | 34 | |
35 | 35 | // Store the data: |
@@ -14,7 +14,7 @@ |
||
14 | 14 | * "dsn" => "sqlite:memory::", |
15 | 15 | * |
16 | 16 | */ |
17 | -if ($_SERVER["SERVER_NAME"] === "www.student.bth.se") { |
|
17 | +if ($_SERVER[ "SERVER_NAME" ] === "www.student.bth.se") { |
|
18 | 18 | return [ |
19 | 19 | "dsn" => "mysql:host=blu-ray.student.bth.se;dbname=mos;", |
20 | 20 | "username" => "mos", |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | error_reporting(-1); // Report all type of errors |
25 | 25 | //error_reporting(E_ALL ^ E_DEPRECATED); // Report no deprecated errors |
26 | 26 | if (constant("ANAX_DEVELOPMENT")) { |
27 | - ini_set("display_errors", 1); // Display all errors |
|
27 | + ini_set("display_errors", 1); // Display all errors |
|
28 | 28 | } elseif (constant("ANAX_PRODUCTION")) { |
29 | - ini_set("display_errors", 0); // Display no errors |
|
30 | - ini_set("log_errors", 1); // Log errors to file error_log |
|
29 | + ini_set("display_errors", 0); // Display no errors |
|
30 | + ini_set("log_errors", 1); // Log errors to file error_log |
|
31 | 31 | ini_set("error_log", ANAX_INSTALL_PATH . "/log/error_log"); |
32 | 32 | } |
33 | 33 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | /** |
37 | 37 | * Default exception handler. |
38 | 38 | */ |
39 | -set_exception_handler(function ($e) { |
|
39 | +set_exception_handler(function($e) { |
|
40 | 40 | echo "<p>Anax: Uncaught exception:</p><p>Line " |
41 | 41 | . $e->getLine() |
42 | 42 | . " in file " |
@@ -6,7 +6,7 @@ |
||
6 | 6 | "services" => [ |
7 | 7 | "textfilter" => [ |
8 | 8 | "shared" => true, |
9 | - "callback" => function () { |
|
9 | + "callback" => function() { |
|
10 | 10 | $filter = new \Anax\TextFilter\TextFilter(); |
11 | 11 | if (is_dir(ANAX_INSTALL_PATH . "/content")) { |
12 | 12 | $filter->setFilterConfig("frontmatter", [ |
@@ -8,7 +8,7 @@ |
||
8 | 8 | "services" => [ |
9 | 9 | "configuration" => [ |
10 | 10 | "shared" => true, |
11 | - "callback" => function () { |
|
11 | + "callback" => function() { |
|
12 | 12 | $config = new \Anax\Configure\Configuration(); |
13 | 13 | $dirs = require ANAX_INSTALL_PATH . "/config/configuration.php"; |
14 | 14 | $config->setBaseDirectories($dirs); |
@@ -4,7 +4,7 @@ |
||
4 | 4 | "services" => [ |
5 | 5 | "curl" => [ |
6 | 6 | "shared" => true, |
7 | - "callback" => function () { |
|
7 | + "callback" => function() { |
|
8 | 8 | $curlWrap = new \Anax\Models\CurlWrapModel(); |
9 | 9 | return $curlWrap; |
10 | 10 | } |