1 | <?php |
||
20 | class PageController extends Controller { |
||
21 | |||
22 | private $userId; |
||
23 | private $cacheManager; |
||
24 | private $deviceMapper; |
||
25 | 1 | public function __construct($appName, IRequest $request, $userId, |
|
26 | CacheManager $cacheManager, |
||
27 | DeviceMapper $deviceMapper) { |
||
28 | 1 | parent::__construct($appName, $request); |
|
29 | 1 | $this -> userId = $userId; |
|
30 | 1 | $this -> cacheManager = $cacheManager; |
|
31 | 1 | $this -> deviceMapper = $deviceMapper; |
|
32 | 1 | } |
|
33 | |||
34 | /** |
||
35 | * CAUTION: the @Stuff turn off security checks, for this page no admin is |
||
36 | * required and no CSRF check. If you don't know what CSRF is, read |
||
37 | * it up in the docs or you might create a security hole. This is |
||
38 | * basically the only required method to add this exemption, don't |
||
39 | * add it to any other method if you don't exactly know what it does |
||
40 | * |
||
41 | * @NoAdminRequired |
||
42 | * @NoCSRFRequired |
||
43 | */ |
||
44 | 1 | public function index() { |
|
45 | |||
46 | 1 | $params = array('user' => $this -> userId,'devices'=>$this->deviceMapper->findAll($this->userId)); |
|
47 | 1 | $response = new TemplateResponse('maps', 'main', $params); |
|
48 | 1 | if (class_exists('OCP\AppFramework\Http\ContentSecurityPolicy')) { |
|
49 | 1 | $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy(); |
|
50 | // map tiles |
||
51 | 1 | $csp->addAllowedImageDomain('http://*.mqcdn.com'); |
|
52 | // marker icons |
||
53 | 1 | $csp->addAllowedImageDomain('https://api.tiles.mapbox.com'); |
|
54 | // inline images |
||
55 | 1 | $csp->addAllowedScriptDomain('data:'); |
|
56 | // nominatim geocoder |
||
57 | 1 | $csp->addAllowedScriptDomain('http://nominatim.openstreetmap.org/search?q=*'); |
|
58 | 1 | $csp->addAllowedScriptDomain('http://nominatim.openstreetmap.org/reverse'); |
|
59 | 1 | $csp->addAllowedConnectDomain('http://router.project-osrm.org'); |
|
60 | // mapzen geocoder |
||
61 | 1 | $csp->addAllowedConnectDomain('http://search.mapzen.com/v1/search?'); |
|
62 | 1 | $csp->addAllowedConnectDomain('http://search.mapzen.com/v1/reverse?'); |
|
63 | 1 | $response->setContentSecurityPolicy($csp); |
|
64 | 1 | } |
|
65 | 1 | return $response; |
|
66 | // templates/main.php |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * Get an layer |
||
71 | * @NoAdminRequired |
||
72 | * @NoCSRFRequired |
||
73 | */ |
||
74 | public function getlayer() { |
||
84 | |||
85 | /** |
||
86 | * Simply method that posts back the payload of the request |
||
87 | * @NoAdminRequired |
||
88 | * @NoCSRFRequired |
||
89 | */ |
||
90 | public function doProxy($echo) { |
||
102 | |||
103 | /** |
||
104 | * Simply method that posts back the payload of the request |
||
105 | * @NoAdminRequired |
||
106 | * @NoCSRFRequired |
||
107 | */ |
||
108 | public function search() { |
||
136 | |||
137 | /** |
||
138 | * Simply method that posts back the payload of the request |
||
139 | * @NoAdminRequired |
||
140 | * @NoCSRFRequired |
||
141 | */ |
||
142 | public function geodecode(){ |
||
162 | /** |
||
163 | * Simply method that posts back the payload of the request |
||
164 | * @NoAdminRequired |
||
165 | * @NoCSRFRequired |
||
166 | */ |
||
167 | public function adresslookup() { |
||
178 | |||
179 | private function bboxSearch($q,$bbox){ |
||
186 | |||
187 | /** |
||
188 | * @param string $q |
||
189 | */ |
||
190 | private function doAdresslookup($q) { |
||
212 | |||
213 | /** |
||
214 | * @param string $hash |
||
215 | */ |
||
216 | private function checkGeoCache($hash) { |
||
219 | |||
220 | private function getURL($url, $userAgent = true) { |
||
242 | |||
243 | } |
||
244 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.