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, |
|
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() { |
|
64 | |||
65 | /** |
||
66 | * Get an layer |
||
67 | * @NoAdminRequired |
||
68 | * @NoCSRFRequired |
||
69 | */ |
||
70 | public function getlayer() { |
||
80 | |||
81 | /** |
||
82 | * Simply method that posts back the payload of the request |
||
83 | * @NoAdminRequired |
||
84 | * @NoCSRFRequired |
||
85 | */ |
||
86 | public function doProxy($echo) { |
||
98 | |||
99 | /** |
||
100 | * Simply method that posts back the payload of the request |
||
101 | * @NoAdminRequired |
||
102 | * @NoCSRFRequired |
||
103 | */ |
||
104 | public function search() { |
||
105 | $cm = \OC::$server -> getContactsManager(); |
||
106 | $kw = $this -> params('search'); |
||
107 | $bbox = $this -> params('bbox'); |
||
108 | $response = array('contacts'=>array(),'nodes'=>array(),'addresses'=>array()); |
||
109 | |||
110 | $contacts = $cm -> search($kw, array('FN', 'ADR')); |
||
111 | foreach ($contacts as $r) { |
||
112 | $data = array(); |
||
|
|||
113 | $contact = $r; |
||
114 | for($i=0; $i<count($r['ADR']); $i++){ |
||
115 | $lookupAdr = implode(',', array_filter($r['ADR'][$i])); |
||
116 | $lookup = $this -> doAdresslookup($lookupAdr); |
||
117 | $contact ['location'][] = $lookup[0]; |
||
118 | } |
||
119 | array_push($response['contacts'],$contact); |
||
120 | } |
||
121 | $response['nodes'] = $this->bboxSearch($kw, $bbox); |
||
122 | $addresses = $this->doAdresslookup(urlencode($kw)); |
||
123 | foreach($addresses as $address){ |
||
124 | array_push($response['addresses'],$address); |
||
125 | if($address->osm_type === "node"){ |
||
126 | } |
||
127 | } |
||
128 | //$response['addresses'] = (array)($this->doAdresslookup($kw)); |
||
129 | |||
130 | return $response; |
||
131 | } |
||
132 | |||
133 | /** |
||
134 | * Simply method that posts back the payload of the request |
||
135 | * @NoAdminRequired |
||
136 | * @NoCSRFRequired |
||
137 | */ |
||
138 | public function geodecode(){ |
||
139 | $lat = $this->params('lat'); |
||
140 | $lng = $this->params('lng'); |
||
141 | $zoom = $this->params('zoom'); |
||
142 | |||
143 | $hash = md5($lat.','.$lng.'@'.$zoom); |
||
144 | |||
145 | $checkCache = $this -> checkGeoCache($hash); |
||
146 | if(!$checkCache){ |
||
147 | $url = 'http://nominatim.openstreetmap.org/reverse/?format=json&[email protected]&lat='.$lat.'&lng='. $lng.'&zoom=67108864'; |
||
148 | $response = $this->getURL($url,false); |
||
149 | if($response){ |
||
150 | $this -> cacheManager -> insert($hash, $response); |
||
151 | } |
||
152 | } else { |
||
153 | $response = $checkCache; |
||
154 | } |
||
155 | echo $response; |
||
156 | die(); |
||
157 | } |
||
158 | /** |
||
159 | * Simply method that posts back the payload of the request |
||
160 | * @NoAdminRequired |
||
161 | * @NoCSRFRequired |
||
162 | */ |
||
163 | public function adresslookup() { |
||
174 | |||
175 | private function bboxSearch($q,$bbox){ |
||
182 | |||
183 | /** |
||
184 | * @param string $q |
||
185 | */ |
||
186 | private function doAdresslookup($q) { |
||
208 | |||
209 | /** |
||
210 | * @param string $hash |
||
211 | */ |
||
212 | private function checkGeoCache($hash) { |
||
215 | |||
216 | private function getURL($url, $userAgent = true) { |
||
217 | $ch = curl_init(); |
||
238 | |||
239 | } |
||
240 |
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.