1 | <?php |
||
20 | class PageController extends Controller { |
||
21 | |||
22 | private $userId; |
||
23 | private $cacheManager; |
||
24 | private $deviceMapper; |
||
25 | public function __construct($appName, IRequest $request, $userId, |
||
26 | CacheManager $cacheManager, |
||
27 | DeviceMapper $deviceMapper) { |
||
28 | parent::__construct($appName, $request); |
||
29 | $this -> userId = $userId; |
||
30 | $this -> cacheManager = $cacheManager; |
||
31 | $this -> deviceMapper = $deviceMapper; |
||
32 | } |
||
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 | public function index() { |
||
45 | |||
46 | $params = array('user' => $this -> userId,'devices'=>$this->deviceMapper->findAll($this->userId)); |
||
47 | $response = new TemplateResponse('maps', 'main', $params); |
||
48 | if (class_exists('OCP\AppFramework\Http\ContentSecurityPolicy')) { |
||
49 | $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy(); |
||
50 | // map tiles |
||
51 | $csp->addAllowedImageDomain('http://*.mqcdn.com'); |
||
52 | // marker icons |
||
53 | $csp->addAllowedImageDomain('https://api.tiles.mapbox.com'); |
||
54 | // inline images |
||
55 | $csp->addAllowedScriptDomain('data:'); |
||
56 | $response->setContentSecurityPolicy($csp); |
||
57 | } |
||
58 | return $response; |
||
59 | // templates/main.php |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * Get an layer |
||
64 | * @NoAdminRequired |
||
65 | * @NoCSRFRequired |
||
66 | */ |
||
67 | public function getlayer() { |
||
68 | $layer = ($this -> params('layer')) ? $this -> params('layer') : null; |
||
69 | if ($layer === "contacts") { |
||
70 | if (\OCP\App::isEnabled('contacts')) { |
||
71 | |||
72 | } else { |
||
73 | OCP\Util::writeLog('maps', "App contacts missing for Maps", \OCP\Util::WARN); |
||
74 | } |
||
75 | } |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * Simply method that posts back the payload of the request |
||
80 | * @NoAdminRequired |
||
81 | * @NoCSRFRequired |
||
82 | */ |
||
83 | public function doProxy($echo) { |
||
84 | $url = ($this -> params('url')) ? $this -> params('url') : ''; |
||
85 | $allowedHosts = array('overpass.osm.rambler.ru', 'overpass-api.de', 'dev.virtualearth.net', 'router.project-osrm.org', 'nominatim.openstreetmap.org', 'maps.googleapis.com'); |
||
86 | $parseUrl = parse_url($url); |
||
87 | |||
88 | if (in_array($parseUrl['host'], $allowedHosts)) { |
||
89 | header('Content-Type: application/javascript'); |
||
90 | $split = explode('url=', $_SERVER['REQUEST_URI']); |
||
91 | echo $this -> getURL($split[1]); |
||
92 | } |
||
93 | die(); |
||
94 | } |
||
95 | |||
96 | /** |
||
97 | * Simply method that posts back the payload of the request |
||
98 | * @NoAdminRequired |
||
99 | * @NoCSRFRequired |
||
100 | */ |
||
101 | public function search() { |
||
102 | $cm = \OC::$server -> getContactsManager(); |
||
103 | $kw = $this -> params('search'); |
||
104 | $bbox = $this -> params('bbox'); |
||
105 | $response = array('contacts'=>array(),'nodes'=>array(),'addresses'=>array()); |
||
106 | |||
107 | $contacts = $cm -> search($kw, array('FN', 'ADR')); |
||
108 | foreach ($contacts as $r) { |
||
109 | $data = array(); |
||
|
|||
110 | $contact = $r; |
||
111 | for($i=0; $i<count($r['ADR']); $i++){ |
||
112 | $lookupAdr = implode(',', array_filter($r['ADR'][$i])); |
||
113 | $lookup = $this -> doAdresslookup($lookupAdr); |
||
114 | $contact ['location'][] = $lookup[0]; |
||
115 | } |
||
116 | array_push($response['contacts'],$contact); |
||
117 | } |
||
118 | $response['nodes'] = $this->bboxSearch($kw, $bbox); |
||
119 | $addresses = $this->doAdresslookup(urlencode($kw)); |
||
120 | foreach($addresses as $address){ |
||
121 | array_push($response['addresses'],$address); |
||
122 | if($address->osm_type === "node"){ |
||
123 | } |
||
124 | } |
||
125 | //$response['addresses'] = (array)($this->doAdresslookup($kw)); |
||
126 | |||
127 | return $response; |
||
128 | } |
||
129 | |||
130 | /** |
||
131 | * Simply method that posts back the payload of the request |
||
132 | * @NoAdminRequired |
||
133 | * @NoCSRFRequired |
||
134 | */ |
||
135 | public function geodecode(){ |
||
155 | /** |
||
156 | * Simply method that posts back the payload of the request |
||
157 | * @NoAdminRequired |
||
158 | * @NoCSRFRequired |
||
159 | */ |
||
160 | public function adresslookup() { |
||
171 | |||
172 | private function bboxSearch($q,$bbox){ |
||
179 | |||
180 | /** |
||
181 | * @param string $q |
||
182 | */ |
||
183 | private function doAdresslookup($q) { |
||
205 | |||
206 | /** |
||
207 | * @param string $hash |
||
208 | */ |
||
209 | private function checkGeoCache($hash) { |
||
212 | |||
213 | private function getURL($url, $userAgent = true) { |
||
235 | |||
236 | } |
||
237 |
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.