@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | /* APPEND mode */ |
| 87 | 87 | |
| 88 | - $ret_saved_value = trim($current_value)."\n\n".trim($new_value); |
|
| 88 | + $ret_saved_value = trim($current_value) . "\n\n" . trim($new_value); |
|
| 89 | 89 | self::update_notes($cache_id, $request->token->user_id, $ret_saved_value); |
| 90 | 90 | } |
| 91 | 91 | |
@@ -123,11 +123,11 @@ discard block |
||
| 123 | 123 | from coordinates |
| 124 | 124 | where |
| 125 | 125 | type = 2 -- personal note |
| 126 | - and cache_id = '".Db::escape_string($cache_id)."' |
|
| 127 | - and user_id = '".Db::escape_string($user_id)."' |
|
| 126 | + and cache_id = '".Db::escape_string($cache_id) . "' |
|
| 127 | + and user_id = '".Db::escape_string($user_id) . "' |
|
| 128 | 128 | "); |
| 129 | 129 | $id = null; |
| 130 | - if($row = Db::fetch_assoc($rs)) { |
|
| 130 | + if ($row = Db::fetch_assoc($rs)) { |
|
| 131 | 131 | $id = $row['id']; |
| 132 | 132 | } |
| 133 | 133 | if ($id == null) { |
@@ -137,17 +137,17 @@ discard block |
||
| 137 | 137 | description |
| 138 | 138 | ) values ( |
| 139 | 139 | 2, 0, 0, |
| 140 | - '".Db::escape_string($cache_id)."', |
|
| 141 | - '".Db::escape_string($user_id)."', |
|
| 142 | - '".Db::escape_string($new_notes)."' |
|
| 140 | + '".Db::escape_string($cache_id) . "', |
|
| 141 | + '".Db::escape_string($user_id) . "', |
|
| 142 | + '".Db::escape_string($new_notes) . "' |
|
| 143 | 143 | ) |
| 144 | 144 | "); |
| 145 | 145 | } else { |
| 146 | 146 | Db::query(" |
| 147 | 147 | update coordinates |
| 148 | - set description = '".Db::escape_string($new_notes)."' |
|
| 148 | + set description = '".Db::escape_string($new_notes) . "' |
|
| 149 | 149 | where |
| 150 | - id = '".Db::escape_string($id)."' |
|
| 150 | + id = '".Db::escape_string($id) . "' |
|
| 151 | 151 | and type = 2 |
| 152 | 152 | "); |
| 153 | 153 | } |
@@ -158,11 +158,11 @@ discard block |
||
| 158 | 158 | select max(note_id) as id |
| 159 | 159 | from cache_notes |
| 160 | 160 | where |
| 161 | - cache_id = '".Db::escape_string($cache_id)."' |
|
| 162 | - and user_id = '".Db::escape_string($user_id)."' |
|
| 161 | + cache_id = '".Db::escape_string($cache_id) . "' |
|
| 162 | + and user_id = '".Db::escape_string($user_id) . "' |
|
| 163 | 163 | "); |
| 164 | 164 | $id = null; |
| 165 | - if($row = Db::fetch_assoc($rs)) { |
|
| 165 | + if ($row = Db::fetch_assoc($rs)) { |
|
| 166 | 166 | $id = $row['id']; |
| 167 | 167 | } |
| 168 | 168 | if ($id == null) { |
@@ -170,20 +170,20 @@ discard block |
||
| 170 | 170 | insert into cache_notes ( |
| 171 | 171 | cache_id, user_id, date, desc_html, `desc` |
| 172 | 172 | ) values ( |
| 173 | - '".Db::escape_string($cache_id)."', |
|
| 174 | - '".Db::escape_string($user_id)."', |
|
| 173 | + '".Db::escape_string($cache_id) . "', |
|
| 174 | + '".Db::escape_string($user_id) . "', |
|
| 175 | 175 | NOW(), 0, |
| 176 | - '".Db::escape_string($new_notes)."' |
|
| 176 | + '".Db::escape_string($new_notes) . "' |
|
| 177 | 177 | ) |
| 178 | 178 | "); |
| 179 | 179 | } else { |
| 180 | 180 | Db::query(" |
| 181 | 181 | update cache_notes |
| 182 | 182 | set |
| 183 | - `desc` = '".Db::escape_string($new_notes)."', |
|
| 183 | + `desc` = '".Db::escape_string($new_notes) . "', |
|
| 184 | 184 | desc_html = 0, |
| 185 | 185 | date = NOW() |
| 186 | - where note_id = '".Db::escape_string($id)."' |
|
| 186 | + where note_id = '".Db::escape_string($id) . "' |
|
| 187 | 187 | "); |
| 188 | 188 | } |
| 189 | 189 | } |
@@ -197,12 +197,12 @@ discard block |
||
| 197 | 197 | delete from coordinates |
| 198 | 198 | where |
| 199 | 199 | type = 2 -- personal note |
| 200 | - and cache_id = '".Db::escape_string($cache_id)."' |
|
| 201 | - and user_id = '".Db::escape_string($user_id)."' |
|
| 200 | + and cache_id = '".Db::escape_string($cache_id) . "' |
|
| 201 | + and user_id = '".Db::escape_string($user_id) . "' |
|
| 202 | 202 | and longitude = 0 |
| 203 | 203 | and latitude = 0 |
| 204 | 204 | "); |
| 205 | - if (Db::get_affected_row_count() <= 0){ |
|
| 205 | + if (Db::get_affected_row_count() <= 0) { |
|
| 206 | 206 | # no rows deleted - record either doesn't exist, or has coords |
| 207 | 207 | # remove only description |
| 208 | 208 | Db::execute(" |
@@ -210,16 +210,16 @@ discard block |
||
| 210 | 210 | set description = null |
| 211 | 211 | where |
| 212 | 212 | type = 2 |
| 213 | - and cache_id = '".Db::escape_string($cache_id)."' |
|
| 214 | - and user_id = '".Db::escape_string($user_id)."' |
|
| 213 | + and cache_id = '".Db::escape_string($cache_id) . "' |
|
| 214 | + and user_id = '".Db::escape_string($user_id) . "' |
|
| 215 | 215 | "); |
| 216 | 216 | } |
| 217 | 217 | } else { # oc.pl branch |
| 218 | 218 | Db::execute(" |
| 219 | 219 | delete from cache_notes |
| 220 | 220 | where |
| 221 | - cache_id = '".Db::escape_string($cache_id)."' |
|
| 222 | - and user_id = '".Db::escape_string($user_id)."' |
|
| 221 | + cache_id = '".Db::escape_string($cache_id) . "' |
|
| 222 | + and user_id = '".Db::escape_string($user_id) . "' |
|
| 223 | 223 | "); |
| 224 | 224 | } |
| 225 | 225 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | throw new ParamMissing('center'); |
| 35 | 35 | $parts = explode('|', $tmp); |
| 36 | 36 | if (count($parts) != 2) |
| 37 | - throw new InvalidParam('center', "Expecting 2 pipe-separated parts, got ".count($parts)."."); |
|
| 37 | + throw new InvalidParam('center', "Expecting 2 pipe-separated parts, got " . count($parts) . "."); |
|
| 38 | 38 | foreach ($parts as &$part_ref) |
| 39 | 39 | { |
| 40 | 40 | if (!preg_match("/^-?[0-9]+(\.?[0-9]*)$/", $part_ref)) |
@@ -70,27 +70,27 @@ discard block |
||
| 70 | 70 | { |
| 71 | 71 | if (!preg_match("/^-?[0-9]+(\.?[0-9]*)$/", $tmp)) |
| 72 | 72 | throw new InvalidParam('radius', "'$tmp' is not a valid float number."); |
| 73 | - $radius = floatval($tmp); # is given in kilometers |
|
| 73 | + $radius = floatval($tmp); # is given in kilometers |
|
| 74 | 74 | if ($radius <= 0) |
| 75 | 75 | throw new InvalidParam('radius', "Has to be a positive number."); |
| 76 | 76 | |
| 77 | 77 | # Apply a latitude-range prefilter if it looks promising. |
| 78 | 78 | # See https://github.com/opencaching/okapi/issues/363 for more info. |
| 79 | 79 | |
| 80 | - $optimization_radius = 100; # in kilometers, optimized for Opencaching.de |
|
| 80 | + $optimization_radius = 100; # in kilometers, optimized for Opencaching.de |
|
| 81 | 81 | $km2degrees_upper_estimate_factor = 0.01; |
| 82 | 82 | |
| 83 | 83 | if ($radius <= $optimization_radius) |
| 84 | 84 | { |
| 85 | 85 | $radius_degrees = $radius * $km2degrees_upper_estimate_factor; |
| 86 | 86 | $where_conds[] = " |
| 87 | - caches.latitude >= '".Db::escape_string($center_lat - $radius_degrees)."' |
|
| 88 | - and caches.latitude <= '".Db::escape_string($center_lat + $radius_degrees)."' |
|
| 87 | + caches.latitude >= '".Db::escape_string($center_lat - $radius_degrees) . "' |
|
| 88 | + and caches.latitude <= '".Db::escape_string($center_lat + $radius_degrees) . "' |
|
| 89 | 89 | "; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - $radius *= 1000; # convert from kilometers to meters |
|
| 93 | - $where_conds[] = "$distance_formula <= '".Db::escape_string($radius)."'"; |
|
| 92 | + $radius *= 1000; # convert from kilometers to meters |
|
| 93 | + $where_conds[] = "$distance_formula <= '" . Db::escape_string($radius) . "'"; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | $search_params = $search_assistant->get_search_params(); |
@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | unix_timestamp(expires) as expires |
| 35 | 35 | from okapi_search_sets |
| 36 | 36 | where |
| 37 | - params_hash = '".Db::escape_string($params_hash)."' |
|
| 38 | - and date_add(date_created, interval '".Db::escape_string($ref_max_age)."' second) > now() |
|
| 37 | + params_hash = '".Db::escape_string($params_hash) . "' |
|
| 38 | + and date_add(date_created, interval '".Db::escape_string($ref_max_age) . "' second) > now() |
|
| 39 | 39 | order by id desc |
| 40 | 40 | limit 1 |
| 41 | 41 | "); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $tmp = $request->get_parameter('min_store'); |
| 52 | 52 | if ($tmp === null) $tmp = "300"; |
| 53 | 53 | $min_store = intval($tmp); |
| 54 | - if (("$min_store" !== $tmp) ||($min_store < 0) || ($min_store > 64800)) |
|
| 54 | + if (("$min_store" !== $tmp) || ($min_store < 0) || ($min_store > 64800)) |
|
| 55 | 55 | throw new InvalidParam('min_store', "Has to be in the 0..64800 range."); |
| 56 | 56 | |
| 57 | 57 | $tmp = $request->get_parameter('ref_max_age'); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | values ( |
| 129 | 129 | 'processing in progress', |
| 130 | 130 | now(), |
| 131 | - date_add(now(), interval '".Db::escape_string($min_store + 60)."' second) |
|
| 131 | + date_add(now(), interval '".Db::escape_string($min_store + 60) . "' second) |
|
| 132 | 132 | ) |
| 133 | 133 | "); |
| 134 | 134 | $set_id = Db::last_insert_id(); |
@@ -137,12 +137,12 @@ discard block |
||
| 137 | 137 | Db::execute(" |
| 138 | 138 | insert into okapi_search_results (set_id, cache_id) |
| 139 | 139 | select distinct |
| 140 | - '".Db::escape_string($set_id)."', |
|
| 140 | + '".Db::escape_string($set_id) . "', |
|
| 141 | 141 | caches.cache_id |
| 142 | 142 | from |
| 143 | - ".implode(", ", $tables)." |
|
| 144 | - ".implode(" ", $joins)." |
|
| 145 | - where (".implode(") and (", $where_conds).") |
|
| 143 | + ".implode(", ", $tables) . " |
|
| 144 | + ".implode(" ", $joins) . " |
|
| 145 | + where (".implode(") and (", $where_conds) . ") |
|
| 146 | 146 | "); |
| 147 | 147 | |
| 148 | 148 | # Lock barrier, to make sure the data is visible by other |
@@ -153,8 +153,8 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | Db::execute(" |
| 155 | 155 | update okapi_search_sets |
| 156 | - set params_hash = '".Db::escape_string($params_hash)."' |
|
| 157 | - where id = '".Db::escape_string($set_id)."' |
|
| 156 | + set params_hash = '".Db::escape_string($params_hash) . "' |
|
| 157 | + where id = '".Db::escape_string($set_id) . "' |
|
| 158 | 158 | "); |
| 159 | 159 | } else { |
| 160 | 160 | # Some other thread acquired the lock before us and it has |
@@ -178,8 +178,8 @@ discard block |
||
| 178 | 178 | { |
| 179 | 179 | Db::execute(" |
| 180 | 180 | update okapi_search_sets |
| 181 | - set expires = date_add(now(), interval '".Db::escape_string($min_store + 60)."' second) |
|
| 182 | - where id = '".Db::escape_string($set_id)."' |
|
| 181 | + set expires = date_add(now(), interval '".Db::escape_string($min_store + 60) . "' second) |
|
| 182 | + where id = '".Db::escape_string($set_id) . "' |
|
| 183 | 183 | "); |
| 184 | 184 | } |
| 185 | 185 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | select cache_id, wp_oc |
| 122 | 122 | from caches |
| 123 | 123 | where |
| 124 | - cache_id in ('".implode("','", array_map('\okapi\Db::escape_string', $internal_ids))."') |
|
| 124 | + cache_id in ('".implode("','", array_map('\okapi\Db::escape_string', $internal_ids)) . "') |
|
| 125 | 125 | and status in (1,2,3) |
| 126 | 126 | "); |
| 127 | 127 | $dict = array(); |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | select uuid, wp_oc |
| 146 | 146 | from caches |
| 147 | 147 | where |
| 148 | - uuid in ('".implode("','", array_map('\okapi\Db::escape_string', $uuids))."') |
|
| 148 | + uuid in ('".implode("','", array_map('\okapi\Db::escape_string', $uuids)) . "') |
|
| 149 | 149 | and status in (1,2,3) |
| 150 | 150 | "); |
| 151 | 151 | $dict = array(); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | throw new ParamMissing('bbox'); |
| 35 | 35 | $parts = explode('|', $tmp); |
| 36 | 36 | if (count($parts) != 4) |
| 37 | - throw new InvalidParam('bbox', "Expecting 4 pipe-separated parts, got ".count($parts)."."); |
|
| 37 | + throw new InvalidParam('bbox', "Expecting 4 pipe-separated parts, got " . count($parts) . "."); |
|
| 38 | 38 | foreach ($parts as &$part_ref) |
| 39 | 39 | { |
| 40 | 40 | if (!preg_match("/^-?[0-9]+(\.?[0-9]*)$/", $part_ref)) |
@@ -61,15 +61,15 @@ discard block |
||
| 61 | 61 | $lat = $search_assistant->get_latitude_expr(); |
| 62 | 62 | $lon = $search_assistant->get_longitude_expr(); |
| 63 | 63 | $where_conds[] = "( |
| 64 | - $lat >= '".Db::escape_string($bbsouth)."' |
|
| 65 | - and $lat < '".Db::escape_string($bbnorth)."' |
|
| 64 | + $lat >= '" . Db::escape_string($bbsouth) . "' |
|
| 65 | + and $lat < '" . Db::escape_string($bbnorth) . "' |
|
| 66 | 66 | )"; |
| 67 | 67 | if ($bbeast > $bbwest) |
| 68 | 68 | { |
| 69 | 69 | # Easy one. |
| 70 | 70 | $where_conds[] = "( |
| 71 | - $lon >= '".Db::escape_string($bbwest)."' |
|
| 72 | - and $lon < '".Db::escape_string($bbeast)."' |
|
| 71 | + $lon >= '" . Db::escape_string($bbwest) . "' |
|
| 72 | + and $lon < '" . Db::escape_string($bbeast) . "' |
|
| 73 | 73 | )"; |
| 74 | 74 | } |
| 75 | 75 | else |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | # We'll have to assume that this bbox goes through the 180-degree meridian. |
| 78 | 78 | # For example, $bbwest = 179 and $bbeast = -179. |
| 79 | 79 | $where_conds[] = "( |
| 80 | - $lon >= '".Db::escape_string($bbwest)."' |
|
| 81 | - or $lon < '".Db::escape_string($bbeast)."' |
|
| 80 | + $lon >= '" . Db::escape_string($bbwest) . "' |
|
| 81 | + or $lon < '" . Db::escape_string($bbeast) . "' |
|
| 82 | 82 | )"; |
| 83 | 83 | } |
| 84 | 84 | |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | if (count($types) > 0) |
| 156 | - $where_conds[] = "caches.type $operator ('".implode("','", array_map('\okapi\Db::escape_string', $types))."')"; |
|
| 156 | + $where_conds[] = "caches.type $operator ('" . implode("','", array_map('\okapi\Db::escape_string', $types)) . "')"; |
|
| 157 | 157 | else if ($operator == "in") |
| 158 | 158 | $where_conds[] = "false"; |
| 159 | 159 | } |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | throw new InvalidParam('size2', "'$name' is not a valid cache size."); |
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | - $where_conds[] = "caches.size $operator ('".implode("','", array_map('\okapi\Db::escape_string', $types))."')"; |
|
| 186 | + $where_conds[] = "caches.size $operator ('" . implode("','", array_map('\okapi\Db::escape_string', $types)) . "')"; |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | # |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | throw new InvalidParam('status', "'$name' is not a valid cache status."); |
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | - $where_conds[] = "caches.status in ('".implode("','", array_map('\okapi\Db::escape_string', $codes))."')"; |
|
| 207 | + $where_conds[] = "caches.status in ('" . implode("','", array_map('\okapi\Db::escape_string', $codes)) . "')"; |
|
| 208 | 208 | |
| 209 | 209 | # |
| 210 | 210 | # owner_uuid |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | $user_ids = array(); |
| 231 | 231 | foreach ($users as $user) |
| 232 | 232 | $user_ids[] = $user['internal_id']; |
| 233 | - $where_conds[] = "caches.user_id $operator ('".implode("','", array_map('\okapi\Db::escape_string', $user_ids))."')"; |
|
| 233 | + $where_conds[] = "caches.user_id $operator ('" . implode("','", array_map('\okapi\Db::escape_string', $user_ids)) . "')"; |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | # |
@@ -282,8 +282,8 @@ discard block |
||
| 282 | 282 | # 'other' size caches will NOT be included (user must use the |
| 283 | 283 | # 'size2' parameter to search these). 'nano' caches will be |
| 284 | 284 | # included whenever 'micro' caches are included ($min=1). |
| 285 | - $where_conds[] = "(caches.size between $min+1 and $max+1)". |
|
| 286 | - ($allow_null ? " or caches.size=7" : ""). |
|
| 285 | + $where_conds[] = "(caches.size between $min+1 and $max+1)" . |
|
| 286 | + ($allow_null ? " or caches.size=7" : "") . |
|
| 287 | 287 | (($min == 1) ? " or caches.size=8" : ""); |
| 288 | 288 | } |
| 289 | 289 | break; |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | $divisors = array(-999, -1.0, 0.1, 1.4, 2.2, 999); |
| 297 | 297 | $min = $divisors[$min - 1]; |
| 298 | 298 | $max = $divisors[$max]; |
| 299 | - $where_conds[] = "($X_SCORE >= $min and $X_SCORE < $max and $X_VOTES >= 3)". |
|
| 299 | + $where_conds[] = "($X_SCORE >= $min and $X_SCORE < $max and $X_VOTES >= 3)" . |
|
| 300 | 300 | ($allow_null ? " or ($X_VOTES < 3)" : ""); |
| 301 | 301 | } |
| 302 | 302 | } |
@@ -324,12 +324,12 @@ discard block |
||
| 324 | 324 | if ($tmp > 100 || $tmp < 0) |
| 325 | 325 | throw new InvalidParam('min_rcmds', "'$tmp'"); |
| 326 | 326 | $tmp = floatval($tmp) / 100.0; |
| 327 | - $where_conds[] = "$X_TOPRATINGS >= $X_FOUNDS * '".Db::escape_string($tmp)."'"; |
|
| 327 | + $where_conds[] = "$X_TOPRATINGS >= $X_FOUNDS * '" . Db::escape_string($tmp) . "'"; |
|
| 328 | 328 | $where_conds[] = "$X_FOUNDS > 0"; |
| 329 | 329 | } |
| 330 | 330 | if (!is_numeric($tmp)) |
| 331 | 331 | throw new InvalidParam('min_rcmds', "'$tmp'"); |
| 332 | - $where_conds[] = "$X_TOPRATINGS >= '".Db::escape_string($tmp)."'"; |
|
| 332 | + $where_conds[] = "$X_TOPRATINGS >= '" . Db::escape_string($tmp) . "'"; |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | # |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | { |
| 341 | 341 | if (!is_numeric($tmp)) |
| 342 | 342 | throw new InvalidParam('min_founds', "'$tmp'"); |
| 343 | - $where_conds[] = "$X_FOUNDS >= '".Db::escape_string($tmp)."'"; |
|
| 343 | + $where_conds[] = "$X_FOUNDS >= '" . Db::escape_string($tmp) . "'"; |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | # |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | { |
| 353 | 353 | if (!is_numeric($tmp)) |
| 354 | 354 | throw new InvalidParam('max_founds', "'$tmp'"); |
| 355 | - $where_conds[] = "$X_FOUNDS <= '".Db::escape_string($tmp)."'"; |
|
| 355 | + $where_conds[] = "$X_FOUNDS <= '" . Db::escape_string($tmp) . "'"; |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | # |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | { |
| 364 | 364 | $timestamp = strtotime($tmp); |
| 365 | 365 | if ($timestamp) |
| 366 | - $where_conds[] = "unix_timestamp(caches.last_modified) > '".Db::escape_string($timestamp)."'"; |
|
| 366 | + $where_conds[] = "unix_timestamp(caches.last_modified) > '" . Db::escape_string($timestamp) . "'"; |
|
| 367 | 367 | else |
| 368 | 368 | throw new InvalidParam('modified_since', "'$tmp' is not in a valid format or is not a valid date."); |
| 369 | 369 | } |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | { |
| 383 | 383 | $found_cache_ids = self::get_found_cache_ids(array($this->request->token->user_id)); |
| 384 | 384 | $operator = ($tmp == 'found_only') ? "in" : "not in"; |
| 385 | - $where_conds[] = "caches.cache_id $operator ('".implode("','", array_map('\okapi\Db::escape_string', $found_cache_ids))."')"; |
|
| 385 | + $where_conds[] = "caches.cache_id $operator ('" . implode("','", array_map('\okapi\Db::escape_string', $found_cache_ids)) . "')"; |
|
| 386 | 386 | } |
| 387 | 387 | } |
| 388 | 388 | |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | } |
| 401 | 401 | $internal_user_ids = array_map(create_function('$user', 'return $user["internal_id"];'), $users); |
| 402 | 402 | $found_cache_ids = self::get_found_cache_ids($internal_user_ids); |
| 403 | - $where_conds[] = "caches.cache_id in ('".implode("','", array_map('\okapi\Db::escape_string', $found_cache_ids))."')"; |
|
| 403 | + $where_conds[] = "caches.cache_id in ('" . implode("','", array_map('\okapi\Db::escape_string', $found_cache_ids)) . "')"; |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | # |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | } |
| 418 | 418 | $internal_user_ids = array_map(create_function('$user', 'return $user["internal_id"];'), $users); |
| 419 | 419 | $found_cache_ids = self::get_found_cache_ids($internal_user_ids); |
| 420 | - $where_conds[] = "caches.cache_id not in ('".implode("','", array_map('\okapi\Db::escape_string', $found_cache_ids))."')"; |
|
| 420 | + $where_conds[] = "caches.cache_id not in ('" . implode("','", array_map('\okapi\Db::escape_string', $found_cache_ids)) . "')"; |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | # |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | $watched_cache_ids = Db::select_column(" |
| 436 | 436 | select cache_id |
| 437 | 437 | from cache_watches |
| 438 | - where user_id = '".Db::escape_string($this->request->token->user_id)."' |
|
| 438 | + where user_id = '".Db::escape_string($this->request->token->user_id) . "' |
|
| 439 | 439 | "); |
| 440 | 440 | if (Settings::get('OC_BRANCH') == 'oc.de') |
| 441 | 441 | { |
@@ -443,10 +443,10 @@ discard block |
||
| 443 | 443 | select cache_id |
| 444 | 444 | from cache_list_items cli, cache_list_watches clw |
| 445 | 445 | where cli.cache_list_id = clw.cache_list_id |
| 446 | - and clw.user_id = '".Db::escape_string($this->request->token->user_id)."' |
|
| 446 | + and clw.user_id = '".Db::escape_string($this->request->token->user_id) . "' |
|
| 447 | 447 | ")); |
| 448 | 448 | } |
| 449 | - $where_conds[] = "caches.cache_id in ('".implode("','", array_map('\okapi\Db::escape_string', $watched_cache_ids))."')"; |
|
| 449 | + $where_conds[] = "caches.cache_id in ('" . implode("','", array_map('\okapi\Db::escape_string', $watched_cache_ids)) . "')"; |
|
| 450 | 450 | } |
| 451 | 451 | } |
| 452 | 452 | |
@@ -485,10 +485,10 @@ discard block |
||
| 485 | 485 | $ignored_cache_ids = Db::select_column(" |
| 486 | 486 | select cache_id |
| 487 | 487 | from cache_ignore |
| 488 | - where user_id = '".Db::escape_string($this->request->token->user_id)."' |
|
| 488 | + where user_id = '".Db::escape_string($this->request->token->user_id) . "' |
|
| 489 | 489 | "); |
| 490 | 490 | $not = ($ignored_status == 'notignored_only' ? 'not' : ''); |
| 491 | - $where_conds[] = "caches.cache_id ".$not." in ('".implode("','", array_map('\okapi\Db::escape_string', $ignored_cache_ids))."')"; |
|
| 491 | + $where_conds[] = "caches.cache_id " . $not . " in ('" . implode("','", array_map('\okapi\Db::escape_string', $ignored_cache_ids)) . "')"; |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | # |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | if (!in_array($tmp, array('true', 'false'))) |
| 503 | 503 | throw new InvalidParam('exclude_my_own', "'$tmp'"); |
| 504 | 504 | if ($tmp == 'true') |
| 505 | - $where_conds[] = "caches.user_id != '".Db::escape_string($this->request->token->user_id)."'"; |
|
| 505 | + $where_conds[] = "caches.user_id != '" . Db::escape_string($this->request->token->user_id) . "'"; |
|
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | # |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | if (strlen($tmp) > 100) |
| 518 | 518 | throw new InvalidParam('name', "Maximum length of 'name' parameter is 100 characters"); |
| 519 | 519 | $tmp = str_replace("*", "%", str_replace("%", "%%", $tmp)); |
| 520 | - $where_conds[] = "caches.name LIKE '".Db::escape_string($tmp)."'"; |
|
| 520 | + $where_conds[] = "caches.name LIKE '" . Db::escape_string($tmp) . "'"; |
|
| 521 | 521 | } |
| 522 | 522 | |
| 523 | 523 | # |
@@ -580,9 +580,9 @@ discard block |
||
| 580 | 580 | $where_conds[] = "PowerTrail.id = powerTrail_caches.powerTrailId"; |
| 581 | 581 | $where_conds[] = 'PowerTrail.status = 1'; |
| 582 | 582 | if ($powertrail_ids) { |
| 583 | - $where_conds[] = "PowerTrail.id in ('".implode( |
|
| 583 | + $where_conds[] = "PowerTrail.id in ('" . implode( |
|
| 584 | 584 | "','", array_map('\okapi\Db::escape_string', explode("|", $powertrail_ids)) |
| 585 | - )."')"; |
|
| 585 | + ) . "')"; |
|
| 586 | 586 | } |
| 587 | 587 | } else { |
| 588 | 588 | $where_conds[] = "0=1"; |
@@ -601,13 +601,13 @@ discard block |
||
| 601 | 601 | $exists = Db::select_value(" |
| 602 | 602 | select 1 |
| 603 | 603 | from okapi_search_sets |
| 604 | - where id = '".Db::escape_string($tmp)."' |
|
| 604 | + where id = '".Db::escape_string($tmp) . "' |
|
| 605 | 605 | "); |
| 606 | 606 | if (!$exists) |
| 607 | 607 | throw new InvalidParam('set_and', "Couldn't find a set by given ID."); |
| 608 | 608 | $extra_tables[] = "okapi_search_results osr_and"; |
| 609 | 609 | $where_conds[] = "osr_and.cache_id = caches.cache_id"; |
| 610 | - $where_conds[] = "osr_and.set_id = '".Db::escape_string($tmp)."'"; |
|
| 610 | + $where_conds[] = "osr_and.set_id = '" . Db::escape_string($tmp) . "'"; |
|
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | # |
@@ -682,8 +682,8 @@ discard block |
||
| 682 | 682 | # To avoid join errors, put each of the $where_conds in extra paranthesis. |
| 683 | 683 | |
| 684 | 684 | $tmp = array(); |
| 685 | - foreach($where_conds as $cond) |
|
| 686 | - $tmp[] = "(".$cond.")"; |
|
| 685 | + foreach ($where_conds as $cond) |
|
| 686 | + $tmp[] = "(" . $cond . ")"; |
|
| 687 | 687 | $where_conds = $tmp; |
| 688 | 688 | unset($tmp); |
| 689 | 689 | |
@@ -718,7 +718,7 @@ discard block |
||
| 718 | 718 | public function get_common_search_result() |
| 719 | 719 | { |
| 720 | 720 | $tables = array_merge( |
| 721 | - array('caches '.$this->search_params['caches_indexhint']), |
|
| 721 | + array('caches ' . $this->search_params['caches_indexhint']), |
|
| 722 | 722 | $this->search_params['extra_tables'] |
| 723 | 723 | ); |
| 724 | 724 | $where_conds = array_merge( |
@@ -731,11 +731,11 @@ discard block |
||
| 731 | 731 | |
| 732 | 732 | $cache_codes = Db::select_column(" |
| 733 | 733 | select caches.wp_oc |
| 734 | - from ".implode(", ", $tables)." ". |
|
| 735 | - implode(" ", $this->search_params['extra_joins'])." |
|
| 736 | - where ".implode(" and ", $where_conds)." |
|
| 737 | - ".((count($this->search_params['order_by']) > 0) ? "order by ".implode(", ", $this->search_params['order_by']) : "")." |
|
| 738 | - limit ".($this->search_params['offset']).", ".($this->search_params['limit'] + 1)."; |
|
| 734 | + from ".implode(", ", $tables) . " " . |
|
| 735 | + implode(" ", $this->search_params['extra_joins']) . " |
|
| 736 | + where ".implode(" and ", $where_conds) . " |
|
| 737 | + ".((count($this->search_params['order_by']) > 0) ? "order by " . implode(", ", $this->search_params['order_by']) : "") . " |
|
| 738 | + limit ".($this->search_params['offset']) . ", " . ($this->search_params['limit'] + 1) . "; |
|
| 739 | 739 | "); |
| 740 | 740 | |
| 741 | 741 | if (count($cache_codes) > $this->search_params['limit']) |
@@ -773,7 +773,7 @@ discard block |
||
| 773 | 773 | # Make sure location_source has prefix alt_wpt: |
| 774 | 774 | if ($location_source != 'default-coords' && strncmp($location_source, 'alt_wpt:', 8) != 0) |
| 775 | 775 | { |
| 776 | - throw new InvalidParam('location_source', '\''.$location_source.'\''); |
|
| 776 | + throw new InvalidParam('location_source', '\'' . $location_source . '\''); |
|
| 777 | 777 | } |
| 778 | 778 | |
| 779 | 779 | # Make sure we have sufficient authorization |
@@ -800,7 +800,7 @@ discard block |
||
| 800 | 800 | $extra_joins = array(" |
| 801 | 801 | left join cache_mod_cords |
| 802 | 802 | on cache_mod_cords.cache_id = caches.cache_id |
| 803 | - and cache_mod_cords.user_id = '".Db::escape_string($this->request->token->user_id)."' |
|
| 803 | + and cache_mod_cords.user_id = '".Db::escape_string($this->request->token->user_id) . "' |
|
| 804 | 804 | "); |
| 805 | 805 | } else { |
| 806 | 806 | # oc.de |
@@ -809,7 +809,7 @@ discard block |
||
| 809 | 809 | $extra_joins = array(" |
| 810 | 810 | left join coordinates |
| 811 | 811 | on coordinates.cache_id = caches.cache_id |
| 812 | - and coordinates.user_id = '".Db::escape_string($this->request->token->user_id)."' |
|
| 812 | + and coordinates.user_id = '".Db::escape_string($this->request->token->user_id) . "' |
|
| 813 | 813 | and coordinates.type = 2 |
| 814 | 814 | and coordinates.longitude != 0 |
| 815 | 815 | and coordinates.latitude != 0 |
@@ -855,12 +855,12 @@ discard block |
||
| 855 | 855 | select cache_id |
| 856 | 856 | from cache_logs |
| 857 | 857 | where |
| 858 | - user_id in ('".implode("','", array_map('\okapi\Db::escape_string', $internal_user_ids))."') |
|
| 858 | + user_id in ('".implode("','", array_map('\okapi\Db::escape_string', $internal_user_ids)) . "') |
|
| 859 | 859 | and type in ( |
| 860 | - '".Db::escape_string(Okapi::logtypename2id("Found it"))."', |
|
| 861 | - '".Db::escape_string(Okapi::logtypename2id("Attended"))."' |
|
| 860 | + '".Db::escape_string(Okapi::logtypename2id("Found it")) . "', |
|
| 861 | + '".Db::escape_string(Okapi::logtypename2id("Attended")) . "' |
|
| 862 | 862 | ) |
| 863 | - and ".((Settings::get('OC_BRANCH') == 'oc.pl') ? "deleted = 0" : "true")." |
|
| 863 | + and ".((Settings::get('OC_BRANCH') == 'oc.pl') ? "deleted = 0" : "true") . " |
|
| 864 | 864 | "); |
| 865 | 865 | } |
| 866 | 866 | } |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | catch (BadRequest $e) |
| 70 | 70 | { |
| 71 | - throw new InvalidParam('search_params', "Search method responded with the ". |
|
| 72 | - "following error message: ".$e->getMessage()); |
|
| 71 | + throw new InvalidParam('search_params', "Search method responded with the " . |
|
| 72 | + "following error message: " . $e->getMessage()); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | # Run retrieval method |
@@ -81,8 +81,8 @@ discard block |
||
| 81 | 81 | } |
| 82 | 82 | catch (BadRequest $e) |
| 83 | 83 | { |
| 84 | - throw new InvalidParam('retr_params', "Retrieval method responded with the ". |
|
| 85 | - "following error message: ".$e->getMessage()); |
|
| 84 | + throw new InvalidParam('retr_params', "Retrieval method responded with the " . |
|
| 85 | + "following error message: " . $e->getMessage()); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | if ($wrap) |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | if (is_numeric($val) || is_string($val)) |
| 116 | 116 | $dict[$key] = (string)$val; |
| 117 | 117 | else |
| 118 | - throw new BadRequest("Invalid value format for key: ".$key); |
|
| 118 | + throw new BadRequest("Invalid value format for key: " . $key); |
|
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | } |
@@ -46,16 +46,16 @@ discard block |
||
| 46 | 46 | Db::execute(" |
| 47 | 47 | insert ignore into cache_watches (cache_id, user_id) |
| 48 | 48 | values ( |
| 49 | - '".Db::escape_string($geocache['internal_id'])."', |
|
| 50 | - '".Db::escape_string($request->token->user_id)."' |
|
| 49 | + '".Db::escape_string($geocache['internal_id']) . "', |
|
| 50 | + '".Db::escape_string($request->token->user_id) . "' |
|
| 51 | 51 | ); |
| 52 | 52 | "); |
| 53 | 53 | elseif ($tmp == 'false') |
| 54 | 54 | Db::execute(" |
| 55 | 55 | delete from cache_watches |
| 56 | 56 | where |
| 57 | - cache_id = '".Db::escape_string($geocache['internal_id'])."' |
|
| 58 | - and user_id = '".Db::escape_string($request->token->user_id)."'; |
|
| 57 | + cache_id = '".Db::escape_string($geocache['internal_id']) . "' |
|
| 58 | + and user_id = '".Db::escape_string($request->token->user_id) . "'; |
|
| 59 | 59 | "); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -69,16 +69,16 @@ discard block |
||
| 69 | 69 | Db::execute(" |
| 70 | 70 | insert ignore into cache_ignore (cache_id, user_id) |
| 71 | 71 | values ( |
| 72 | - '".Db::escape_string($geocache['internal_id'])."', |
|
| 73 | - '".Db::escape_string($request->token->user_id)."' |
|
| 72 | + '".Db::escape_string($geocache['internal_id']) . "', |
|
| 73 | + '".Db::escape_string($request->token->user_id) . "' |
|
| 74 | 74 | ); |
| 75 | 75 | "); |
| 76 | 76 | elseif ($tmp == 'false') |
| 77 | 77 | Db::execute(" |
| 78 | 78 | delete from cache_ignore |
| 79 | 79 | where |
| 80 | - cache_id = '".Db::escape_string($geocache['internal_id'])."' |
|
| 81 | - and user_id = '".Db::escape_string($request->token->user_id)."' |
|
| 80 | + cache_id = '".Db::escape_string($geocache['internal_id']) . "' |
|
| 81 | + and user_id = '".Db::escape_string($request->token->user_id) . "' |
|
| 82 | 82 | "); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | if ((!preg_match("/^[0-9]+$/", $issue_id)) || (strlen($issue_id) > 6)) |
| 32 | 32 | throw new InvalidParam('issue_id'); |
| 33 | 33 | |
| 34 | - $cache_key = "apiref/issue#".$issue_id; |
|
| 34 | + $cache_key = "apiref/issue#" . $issue_id; |
|
| 35 | 35 | $result = Cache::get($cache_key); |
| 36 | 36 | if ($result == null) |
| 37 | 37 | { |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $extra_headers[] = "Accept: application/vnd.github.v3.html+json"; |
| 44 | 44 | $extra_headers[] = "User-Agent: https://github.com/opencaching/okapi/"; |
| 45 | 45 | if (Settings::get('GITHUB_ACCESS_TOKEN')) { |
| 46 | - $extra_headers[] = "Authorization: token ".Settings::get('GITHUB_ACCESS_TOKEN'); |
|
| 46 | + $extra_headers[] = "Authorization: token " . Settings::get('GITHUB_ACCESS_TOKEN'); |
|
| 47 | 47 | } |
| 48 | 48 | $opts = array( |
| 49 | 49 | 'http' => array( |
@@ -58,8 +58,8 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | catch (ErrorException $e) |
| 60 | 60 | { |
| 61 | - throw new BadRequest("Sorry, we could not retrieve issue stats from the GitHub site. ". |
|
| 62 | - "This is probably due to a temporary connection problem. Try again later or contact ". |
|
| 61 | + throw new BadRequest("Sorry, we could not retrieve issue stats from the GitHub site. " . |
|
| 62 | + "This is probably due to a temporary connection problem. Try again later or contact " . |
|
| 63 | 63 | "us if this seems permanent."); |
| 64 | 64 | } |
| 65 | 65 | |