@@ -12,7 +12,6 @@ |
||
| 12 | 12 | use ArrayObject; |
| 13 | 13 | use okapi\oauth\OAuthServerException; |
| 14 | 14 | use okapi\oauth\OAuthServer400Exception; |
| 15 | -use okapi\oauth\OAuthServer401Exception; |
|
| 16 | 15 | use okapi\oauth\OAuthMissingParameterException; |
| 17 | 16 | use okapi\oauth\OAuthConsumer; |
| 18 | 17 | use okapi\oauth\OAuthToken; |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | 'reason_stack' => array(), |
| 57 | 57 | ); |
| 58 | 58 | $this->provideExtras($extras); |
| 59 | - $extras['more_info'] = Settings::get('SITE_URL')."okapi/introduction.html#errors"; |
|
| 59 | + $extras['more_info'] = Settings::get('SITE_URL') . "okapi/introduction.html#errors"; |
|
| 60 | 60 | return json_encode(array("error" => $extras)); |
| 61 | 61 | } |
| 62 | 62 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | { |
| 132 | 132 | print "\n\nBUT! Since the DEBUG flag is on, then you probably ARE a developer yourself.\n"; |
| 133 | 133 | print "Let's cut to the chase then:"; |
| 134 | - print "\n\n".$exception_info; |
|
| 134 | + print "\n\n" . $exception_info; |
|
| 135 | 135 | } |
| 136 | 136 | if (class_exists("okapi\\Settings") && (Settings::get('DEBUG_PREVENT_EMAILS'))) |
| 137 | 137 | { |
@@ -140,14 +140,14 @@ discard block |
||
| 140 | 140 | } |
| 141 | 141 | else |
| 142 | 142 | { |
| 143 | - $subject = "OKAPI Method Error - ".substr( |
|
| 143 | + $subject = "OKAPI Method Error - " . substr( |
|
| 144 | 144 | $_SERVER['REQUEST_URI'], 0, strpos( |
| 145 | - $_SERVER['REQUEST_URI'].'?', '?')); |
|
| 145 | + $_SERVER['REQUEST_URI'] . '?', '?')); |
|
| 146 | 146 | |
| 147 | 147 | $message = ( |
| 148 | - "OKAPI caught the following exception while executing API method request.\n". |
|
| 149 | - "This is an error in OUR code and should be fixed. Please contact the\n". |
|
| 150 | - "developer of the module that threw this error. Thanks!\n\n". |
|
| 148 | + "OKAPI caught the following exception while executing API method request.\n" . |
|
| 149 | + "This is an error in OUR code and should be fixed. Please contact the\n" . |
|
| 150 | + "developer of the module that threw this error. Thanks!\n\n" . |
|
| 151 | 151 | $exception_info |
| 152 | 152 | ); |
| 153 | 153 | try |
@@ -175,11 +175,11 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | $admin_email = implode(", ", get_admin_emails()); |
| 177 | 177 | $sender_email = class_exists("okapi\\Settings") ? Settings::get('FROM_FIELD') : 'root@localhost'; |
| 178 | - $subject = "Fatal error mode: ".$subject; |
|
| 179 | - $message = "Fatal error mode: OKAPI will send at most ONE message per minute.\n\n".$message; |
|
| 178 | + $subject = "Fatal error mode: " . $subject; |
|
| 179 | + $message = "Fatal error mode: OKAPI will send at most ONE message per minute.\n\n" . $message; |
|
| 180 | 180 | $headers = ( |
| 181 | - "Content-Type: text/plain; charset=utf-8\n". |
|
| 182 | - "From: OKAPI <$sender_email>\n". |
|
| 181 | + "Content-Type: text/plain; charset=utf-8\n" . |
|
| 182 | + "From: OKAPI <$sender_email>\n" . |
|
| 183 | 183 | "Reply-To: $sender_email\n" |
| 184 | 184 | ); |
| 185 | 185 | mail($admin_email, $subject, $message, $headers); |
@@ -193,9 +193,9 @@ discard block |
||
| 193 | 193 | return str_replace( |
| 194 | 194 | array( |
| 195 | 195 | Settings::get('DB_PASSWORD'), |
| 196 | - "'".Settings::get('DB_USERNAME')."'", |
|
| 196 | + "'" . Settings::get('DB_USERNAME') . "'", |
|
| 197 | 197 | Settings::get('DB_SERVER'), |
| 198 | - "'".Settings::get('DB_NAME')."'" |
|
| 198 | + "'" . Settings::get('DB_NAME') . "'" |
|
| 199 | 199 | ), |
| 200 | 200 | array( |
| 201 | 201 | "******", |
@@ -218,25 +218,25 @@ discard block |
||
| 218 | 218 | # by OkapiErrorHandler::handle_shutdown. Instead of printing trace, we will just print |
| 219 | 219 | # the file and line. |
| 220 | 220 | |
| 221 | - $exception_info .= "File: ".$e->getFile()."\nLine: ".$e->getLine()."\n\n"; |
|
| 221 | + $exception_info .= "File: " . $e->getFile() . "\nLine: " . $e->getLine() . "\n\n"; |
|
| 222 | 222 | } |
| 223 | 223 | else |
| 224 | 224 | { |
| 225 | - $exception_info .= "--- Stack trace ---\n". |
|
| 226 | - self::removeSensitiveData($e->getTraceAsString())."\n\n"; |
|
| 225 | + $exception_info .= "--- Stack trace ---\n" . |
|
| 226 | + self::removeSensitiveData($e->getTraceAsString()) . "\n\n"; |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - $exception_info .= (isset($_SERVER['REQUEST_URI']) ? "--- OKAPI method called ---\n". |
|
| 230 | - preg_replace("/([?&])/", "\n$1", $_SERVER['REQUEST_URI'])."\n\n" : ""); |
|
| 231 | - $exception_info .= "--- OKAPI version ---\n".Okapi::$version_number. |
|
| 232 | - " (".Okapi::$git_revision.")\n\n"; |
|
| 229 | + $exception_info .= (isset($_SERVER['REQUEST_URI']) ? "--- OKAPI method called ---\n" . |
|
| 230 | + preg_replace("/([?&])/", "\n$1", $_SERVER['REQUEST_URI']) . "\n\n" : ""); |
|
| 231 | + $exception_info .= "--- OKAPI version ---\n" . Okapi::$version_number . |
|
| 232 | + " (" . Okapi::$git_revision . ")\n\n"; |
|
| 233 | 233 | |
| 234 | 234 | # This if-condition will solve some (but not all) problems when trying to execute |
| 235 | 235 | # OKAPI code from command line; |
| 236 | 236 | # see https://github.com/opencaching/okapi/issues/243. |
| 237 | 237 | if (function_exists('getallheaders')) |
| 238 | 238 | { |
| 239 | - $exception_info .= "--- Request headers ---\n".implode("\n", array_map( |
|
| 239 | + $exception_info .= "--- Request headers ---\n" . implode("\n", array_map( |
|
| 240 | 240 | function($k, $v) { return "$k: $v"; }, |
| 241 | 241 | array_keys(getallheaders()), array_values(getallheaders()) |
| 242 | 242 | )); |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | $this->paramName = $paramName; |
| 342 | 342 | $this->whats_wrong_about_it = $whats_wrong_about_it; |
| 343 | 343 | if ($whats_wrong_about_it) |
| 344 | - parent::__construct("Parameter '$paramName' has invalid value: ".$whats_wrong_about_it, $code); |
|
| 344 | + parent::__construct("Parameter '$paramName' has invalid value: " . $whats_wrong_about_it, $code); |
|
| 345 | 345 | else |
| 346 | 346 | parent::__construct("Parameter '$paramName' has invalid value.", $code); |
| 347 | 347 | } |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | self::$connected = true; |
| 372 | 372 | } |
| 373 | 373 | else |
| 374 | - throw new Exception("Could not connect to MySQL: ".mysql_error()); |
|
| 374 | + throw new Exception("Could not connect to MySQL: " . mysql_error()); |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | /** Fetch [{row}], return {row}. */ |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | case 0: return null; |
| 384 | 384 | case 1: return $rows[0]; |
| 385 | 385 | default: |
| 386 | - throw new DbException("Invalid query. Db::select_row returned more than one row for:\n\n".$query."\n"); |
|
| 386 | + throw new DbException("Invalid query. Db::select_row returned more than one row for:\n\n" . $query . "\n"); |
|
| 387 | 387 | } |
| 388 | 388 | } |
| 389 | 389 | |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | return null; |
| 437 | 437 | if (count($column) == 1) |
| 438 | 438 | return $column[0]; |
| 439 | - throw new DbException("Invalid query. Db::select_value returned more than one row for:\n\n".$query."\n"); |
|
| 439 | + throw new DbException("Invalid query. Db::select_value returned more than one row for:\n\n" . $query . "\n"); |
|
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | /** Fetch all [(A), (B), (C)], return [A, B, C]. */ |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | { |
| 490 | 490 | $rs = self::query($query); |
| 491 | 491 | if ($rs !== true) |
| 492 | - throw new DbException("Db::execute returned a result set for your query. ". |
|
| 492 | + throw new DbException("Db::execute returned a result set for your query. " . |
|
| 493 | 493 | "You should use Db::select_* or Db::query for SELECT queries!"); |
| 494 | 494 | } |
| 495 | 495 | |
@@ -514,8 +514,8 @@ discard block |
||
| 514 | 514 | self::execute("repair table okapi_cache"); |
| 515 | 515 | Okapi::mail_admins( |
| 516 | 516 | "okapi_cache - Automatic repair", |
| 517 | - "Hi.\n\nOKAPI detected that okapi_cache table needed ". |
|
| 518 | - "repairs and it has performed such\nrepairs automatically. ". |
|
| 517 | + "Hi.\n\nOKAPI detected that okapi_cache table needed " . |
|
| 518 | + "repairs and it has performed such\nrepairs automatically. " . |
|
| 519 | 519 | "However, this should not happen regularly!" |
| 520 | 520 | ); |
| 521 | 521 | } catch (Exception $e) { |
@@ -526,10 +526,10 @@ discard block |
||
| 526 | 526 | self::execute("truncate okapi_cache"); |
| 527 | 527 | Okapi::mail_admins( |
| 528 | 528 | "okapi_cache was truncated", |
| 529 | - "Hi.\n\nOKAPI detected that okapi_cache table needed ". |
|
| 530 | - "repairs, but it failed to repair\nthe table automatically. ". |
|
| 531 | - "In order to counteract more severe errors, \nwe have ". |
|
| 532 | - "truncated the okapi_cache table to make it alive.\n". |
|
| 529 | + "Hi.\n\nOKAPI detected that okapi_cache table needed " . |
|
| 530 | + "repairs, but it failed to repair\nthe table automatically. " . |
|
| 531 | + "In order to counteract more severe errors, \nwe have " . |
|
| 532 | + "truncated the okapi_cache table to make it alive.\n" . |
|
| 533 | 533 | "However, this should not happen regularly!" |
| 534 | 534 | ); |
| 535 | 535 | } catch (Exception $e) { |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | } |
| 539 | 539 | } |
| 540 | 540 | |
| 541 | - throw new DbException("SQL Error $errno: $msg\n\nThe query was:\n".$query."\n"); |
|
| 541 | + throw new DbException("SQL Error $errno: $msg\n\nThe query was:\n" . $query . "\n"); |
|
| 542 | 542 | } |
| 543 | 543 | return $rs; |
| 544 | 544 | } |
@@ -555,10 +555,10 @@ discard block |
||
| 555 | 555 | |
| 556 | 556 | public static function field_exists($table, $field) |
| 557 | 557 | { |
| 558 | - if (!preg_match("/[a-z0-9_]+/", $table.$field)) |
|
| 558 | + if (!preg_match("/[a-z0-9_]+/", $table . $field)) |
|
| 559 | 559 | return false; |
| 560 | 560 | try { |
| 561 | - $spec = self::select_all("desc ".$table.";"); |
|
| 561 | + $spec = self::select_all("desc " . $table . ";"); |
|
| 562 | 562 | } catch (Exception $e) { |
| 563 | 563 | /* Table doesn't exist, probably. */ |
| 564 | 564 | return false; |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | # Including OAuth internals. Preparing OKAPI Consumer and Token classes. |
| 576 | 576 | # |
| 577 | 577 | |
| 578 | -require_once($GLOBALS['rootpath']."okapi/oauth.php"); |
|
| 578 | +require_once($GLOBALS['rootpath'] . "okapi/oauth.php"); |
|
| 579 | 579 | |
| 580 | 580 | class OkapiConsumer extends OAuthConsumer |
| 581 | 581 | { |
@@ -611,7 +611,7 @@ discard block |
||
| 611 | 611 | */ |
| 612 | 612 | const FLAG_KEY_REVOKED = 4; |
| 613 | 613 | |
| 614 | - public function __construct($key, $secret, $name, $url, $email, $bflags=0) |
|
| 614 | + public function __construct($key, $secret, $name, $url, $email, $bflags = 0) |
|
| 615 | 615 | { |
| 616 | 616 | $this->key = $key; |
| 617 | 617 | $this->secret = $secret; |
@@ -718,7 +718,7 @@ discard block |
||
| 718 | 718 | { |
| 719 | 719 | public function __construct($user_id) |
| 720 | 720 | { |
| 721 | - parent::__construct('internal-'.$user_id, null, 'internal', $user_id); |
|
| 721 | + parent::__construct('internal-' . $user_id, null, 'internal', $user_id); |
|
| 722 | 722 | } |
| 723 | 723 | } |
| 724 | 724 | |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | { |
| 728 | 728 | public function __construct($user_id) |
| 729 | 729 | { |
| 730 | - parent::__construct('facade-'.$user_id, null, 'facade', $user_id); |
|
| 730 | + parent::__construct('facade-' . $user_id, null, 'facade', $user_id); |
|
| 731 | 731 | } |
| 732 | 732 | } |
| 733 | 733 | |
@@ -736,7 +736,7 @@ discard block |
||
| 736 | 736 | { |
| 737 | 737 | public function __construct($user_id) |
| 738 | 738 | { |
| 739 | - parent::__construct('debug-'.$user_id, null, 'debug', $user_id); |
|
| 739 | + parent::__construct('debug-' . $user_id, null, 'debug', $user_id); |
|
| 740 | 740 | } |
| 741 | 741 | } |
| 742 | 742 | |
@@ -777,8 +777,8 @@ discard block |
||
| 777 | 777 | |
| 778 | 778 | # Including local datastore and settings (connecting SQL database etc.). |
| 779 | 779 | |
| 780 | -require_once($GLOBALS['rootpath']."okapi/settings.php"); |
|
| 781 | -require_once($GLOBALS['rootpath']."okapi/datastore.php"); |
|
| 780 | +require_once($GLOBALS['rootpath'] . "okapi/settings.php"); |
|
| 781 | +require_once($GLOBALS['rootpath'] . "okapi/datastore.php"); |
|
| 782 | 782 | |
| 783 | 783 | class OkapiHttpResponse |
| 784 | 784 | { |
@@ -809,7 +809,7 @@ discard block |
||
| 809 | 809 | if (is_resource($this->body)) |
| 810 | 810 | { |
| 811 | 811 | while (!feof($this->body)) |
| 812 | - print fread($this->body, 1024*1024); |
|
| 812 | + print fread($this->body, 1024 * 1024); |
|
| 813 | 813 | } |
| 814 | 814 | else |
| 815 | 815 | print $this->body; |
@@ -836,14 +836,14 @@ discard block |
||
| 836 | 836 | */ |
| 837 | 837 | public function display() |
| 838 | 838 | { |
| 839 | - header("HTTP/1.1 ".$this->status); |
|
| 839 | + header("HTTP/1.1 " . $this->status); |
|
| 840 | 840 | header("Access-Control-Allow-Origin: *"); |
| 841 | - header("Content-Type: ".$this->content_type); |
|
| 842 | - header("Cache-Control: ".$this->cache_control); |
|
| 841 | + header("Content-Type: " . $this->content_type); |
|
| 842 | + header("Cache-Control: " . $this->cache_control); |
|
| 843 | 843 | if ($this->connection_close) |
| 844 | 844 | header("Connection: close"); |
| 845 | 845 | if ($this->content_disposition) |
| 846 | - header("Content-Disposition: ".$this->content_disposition); |
|
| 846 | + header("Content-Disposition: " . $this->content_disposition); |
|
| 847 | 847 | if ($this->etag) |
| 848 | 848 | header("ETag: $this->etag"); |
| 849 | 849 | |
@@ -861,7 +861,7 @@ discard block |
||
| 861 | 861 | |
| 862 | 862 | header("Content-Encoding: gzip"); |
| 863 | 863 | $gzipped = gzencode($this->body, 5); |
| 864 | - header("Content-Length: ".strlen($gzipped)); |
|
| 864 | + header("Content-Length: " . strlen($gzipped)); |
|
| 865 | 865 | print $gzipped; |
| 866 | 866 | } |
| 867 | 867 | else |
@@ -874,7 +874,7 @@ discard block |
||
| 874 | 874 | |
| 875 | 875 | $length = $this->get_length(); |
| 876 | 876 | if ($length) |
| 877 | - header("Content-Length: ".$length); |
|
| 877 | + header("Content-Length: " . $length); |
|
| 878 | 878 | $this->print_body(); |
| 879 | 879 | } |
| 880 | 880 | } |
@@ -887,11 +887,11 @@ discard block |
||
| 887 | 887 | public function display() |
| 888 | 888 | { |
| 889 | 889 | header("HTTP/1.1 303 See Other"); |
| 890 | - header("Location: ".$this->url); |
|
| 890 | + header("Location: " . $this->url); |
|
| 891 | 891 | } |
| 892 | 892 | } |
| 893 | 893 | |
| 894 | -require_once ($GLOBALS['rootpath'].'okapi/lib/tbszip.php'); |
|
| 894 | +require_once ($GLOBALS['rootpath'] . 'okapi/lib/tbszip.php'); |
|
| 895 | 895 | use \clsTbsZip; |
| 896 | 896 | |
| 897 | 897 | class OkapiZIPHttpResponse extends OkapiHttpResponse |
@@ -906,7 +906,7 @@ discard block |
||
| 906 | 906 | |
| 907 | 907 | public function print_body() |
| 908 | 908 | { |
| 909 | - $this->zip->Flush(clsTbsZip::TBSZIP_DOWNLOAD|clsTbsZip::TBSZIP_NOHEADER); |
|
| 909 | + $this->zip->Flush(clsTbsZip::TBSZIP_DOWNLOAD | clsTbsZip::TBSZIP_NOHEADER); |
|
| 910 | 910 | } |
| 911 | 911 | |
| 912 | 912 | public function get_body() |
@@ -938,7 +938,7 @@ discard block |
||
| 938 | 938 | /** Note: This does NOT tell you if someone currently locked it! */ |
| 939 | 939 | public static function exists($name) |
| 940 | 940 | { |
| 941 | - $lockfile = Okapi::get_var_dir()."/okapi-lock-".$name; |
|
| 941 | + $lockfile = Okapi::get_var_dir() . "/okapi-lock-" . $name; |
|
| 942 | 942 | return file_exists($lockfile); |
| 943 | 943 | } |
| 944 | 944 | |
@@ -957,7 +957,7 @@ discard block |
||
| 957 | 957 | } |
| 958 | 958 | else |
| 959 | 959 | { |
| 960 | - $this->lockfile = Okapi::get_var_dir()."/okapi-lock-".$name; |
|
| 960 | + $this->lockfile = Okapi::get_var_dir() . "/okapi-lock-" . $name; |
|
| 961 | 961 | $this->lock = fopen($this->lockfile, "wb"); |
| 962 | 962 | } |
| 963 | 963 | } |
@@ -973,7 +973,7 @@ discard block |
||
| 973 | 973 | if ($this->lock !== null) |
| 974 | 974 | return flock($this->lock, LOCK_EX | LOCK_NB); |
| 975 | 975 | else |
| 976 | - return true; # $lock can be null only when debugging |
|
| 976 | + return true; # $lock can be null only when debugging |
|
| 977 | 977 | } |
| 978 | 978 | |
| 979 | 979 | public function release() |
@@ -1059,8 +1059,8 @@ discard block |
||
| 1059 | 1059 | Db::execute(" |
| 1060 | 1060 | replace into okapi_vars (var, value) |
| 1061 | 1061 | values ( |
| 1062 | - '".Db::escape_string($varname)."', |
|
| 1063 | - '".Db::escape_string($value)."'); |
|
| 1062 | + '".Db::escape_string($varname) . "', |
|
| 1063 | + '".Db::escape_string($value) . "'); |
|
| 1064 | 1064 | "); |
| 1065 | 1065 | self::$okapi_vars[$varname] = $value; |
| 1066 | 1066 | } |
@@ -1083,12 +1083,12 @@ discard block |
||
| 1083 | 1083 | # Make sure we're not sending HUGE emails. |
| 1084 | 1084 | |
| 1085 | 1085 | if (strlen($message) > 10000) { |
| 1086 | - $message = substr($message, 0, 10000)."\n\n...(message clipped at 10k chars)\n"; |
|
| 1086 | + $message = substr($message, 0, 10000) . "\n\n...(message clipped at 10k chars)\n"; |
|
| 1087 | 1087 | } |
| 1088 | 1088 | |
| 1089 | 1089 | # Make sure we're not spamming. |
| 1090 | 1090 | |
| 1091 | - $cache_key = 'mail_admins_counter/'.(floor(time() / 3600) * 3600).'/'.md5($subject); |
|
| 1091 | + $cache_key = 'mail_admins_counter/' . (floor(time() / 3600) * 3600) . '/' . md5($subject); |
|
| 1092 | 1092 | try { |
| 1093 | 1093 | $counter = Cache::get($cache_key); |
| 1094 | 1094 | } catch (DbException $e) { |
@@ -1119,22 +1119,22 @@ discard block |
||
| 1119 | 1119 | { |
| 1120 | 1120 | # We are spamming. Prevent sending more emails. |
| 1121 | 1121 | |
| 1122 | - $content_cache_key_prefix = 'mail_admins_spam/'.(floor(time() / 3600) * 3600).'/'; |
|
| 1122 | + $content_cache_key_prefix = 'mail_admins_spam/' . (floor(time() / 3600) * 3600) . '/'; |
|
| 1123 | 1123 | $timeout = 86400; |
| 1124 | 1124 | if ($counter == 6) |
| 1125 | 1125 | { |
| 1126 | 1126 | self::mail_from_okapi(get_admin_emails(), "Anti-spam mode activated for '$subject'", |
| 1127 | - "OKAPI has activated an \"anti-spam\" mode for the following subject:\n\n". |
|
| 1128 | - "\"$subject\"\n\n". |
|
| 1129 | - "Anti-spam mode is activiated when more than 5 messages with\n". |
|
| 1130 | - "the same subject are sent within one hour.\n\n". |
|
| 1131 | - "Additional debug information:\n". |
|
| 1132 | - "- counter cache key: $cache_key\n". |
|
| 1133 | - "- content prefix: $content_cache_key_prefix<n>\n". |
|
| 1127 | + "OKAPI has activated an \"anti-spam\" mode for the following subject:\n\n" . |
|
| 1128 | + "\"$subject\"\n\n" . |
|
| 1129 | + "Anti-spam mode is activiated when more than 5 messages with\n" . |
|
| 1130 | + "the same subject are sent within one hour.\n\n" . |
|
| 1131 | + "Additional debug information:\n" . |
|
| 1132 | + "- counter cache key: $cache_key\n" . |
|
| 1133 | + "- content prefix: $content_cache_key_prefix<n>\n" . |
|
| 1134 | 1134 | "- content timeout: $timeout\n" |
| 1135 | 1135 | ); |
| 1136 | 1136 | } |
| 1137 | - $content_cache_key = $content_cache_key_prefix.$counter; |
|
| 1137 | + $content_cache_key = $content_cache_key_prefix . $counter; |
|
| 1138 | 1138 | Cache::set($content_cache_key, $message, $timeout); |
| 1139 | 1139 | } |
| 1140 | 1140 | } |
@@ -1152,8 +1152,8 @@ discard block |
||
| 1152 | 1152 | $email_addresses = array($email_addresses); |
| 1153 | 1153 | $sender_email = class_exists("okapi\\Settings") ? Settings::get('FROM_FIELD') : 'root@localhost'; |
| 1154 | 1154 | mail(implode(", ", $email_addresses), $subject, $message, |
| 1155 | - "Content-Type: text/plain; charset=utf-8\n". |
|
| 1156 | - "From: OKAPI <$sender_email>\n". |
|
| 1155 | + "Content-Type: text/plain; charset=utf-8\n" . |
|
| 1156 | + "From: OKAPI <$sender_email>\n" . |
|
| 1157 | 1157 | "Reply-To: $sender_email\n" |
| 1158 | 1158 | ); |
| 1159 | 1159 | } |
@@ -1174,7 +1174,7 @@ discard block |
||
| 1174 | 1174 | $site_url = Settings::get('SITE_URL'); |
| 1175 | 1175 | $matches = null; |
| 1176 | 1176 | if (preg_match("#^https?://(www.)?opencaching.([a-z.]+)/$#", $site_url, $matches)) { |
| 1177 | - return "Opencaching.".strtoupper($matches[2]); |
|
| 1177 | + return "Opencaching." . strtoupper($matches[2]); |
|
| 1178 | 1178 | } else { |
| 1179 | 1179 | return "DEVELSITE"; |
| 1180 | 1180 | } |
@@ -1198,18 +1198,18 @@ discard block |
||
| 1198 | 1198 | /* All OCDE-based sites use exactly the same schema. */ |
| 1199 | 1199 | |
| 1200 | 1200 | if (Settings::get('OC_BRANCH') == 'oc.de') { |
| 1201 | - return "OCDE"; // OC |
|
| 1201 | + return "OCDE"; // OC |
|
| 1202 | 1202 | } |
| 1203 | 1203 | |
| 1204 | 1204 | /* All OCPL-based sites use separate schemas. (Hopefully, this will |
| 1205 | 1205 | * change in time.) */ |
| 1206 | 1206 | |
| 1207 | 1207 | $mapping = array( |
| 1208 | - 2 => "OCPL", // OP |
|
| 1209 | - 6 => "OCORGUK", // OK |
|
| 1210 | - 10 => "OCUS", // OU |
|
| 1211 | - 14 => "OCNL", // OB |
|
| 1212 | - 16 => "OCRO", // OR |
|
| 1208 | + 2 => "OCPL", // OP |
|
| 1209 | + 6 => "OCORGUK", // OK |
|
| 1210 | + 10 => "OCUS", // OU |
|
| 1211 | + 14 => "OCNL", // OB |
|
| 1212 | + 16 => "OCRO", // OR |
|
| 1213 | 1213 | // should be expanded when new OCPL-based sites are added |
| 1214 | 1214 | ); |
| 1215 | 1215 | $oc_node_id = Settings::get("OC_NODE_ID"); |
@@ -1231,7 +1231,7 @@ discard block |
||
| 1231 | 1231 | */ |
| 1232 | 1232 | public static function get_recommended_base_url() |
| 1233 | 1233 | { |
| 1234 | - return Settings::get('SITE_URL')."okapi/"; |
|
| 1234 | + return Settings::get('SITE_URL') . "okapi/"; |
|
| 1235 | 1235 | } |
| 1236 | 1236 | |
| 1237 | 1237 | /** |
@@ -1261,7 +1261,7 @@ discard block |
||
| 1261 | 1261 | ); |
| 1262 | 1262 | break; |
| 1263 | 1263 | case 'OCDE': |
| 1264 | - if (in_array(Settings::get('OC_NODE_ID'), array(4,5))) { |
|
| 1264 | + if (in_array(Settings::get('OC_NODE_ID'), array(4, 5))) { |
|
| 1265 | 1265 | $urls = array( |
| 1266 | 1266 | preg_replace("/^https:/", "http:", Settings::get('SITE_URL')) . 'okapi/', |
| 1267 | 1267 | preg_replace("/^http:/", "https:", Settings::get('SITE_URL')) . 'okapi/', |
@@ -1352,7 +1352,7 @@ discard block |
||
| 1352 | 1352 | $nearest_event = Okapi::get_var("cron_nearest_event"); |
| 1353 | 1353 | if ($nearest_event + 0 <= time()) |
| 1354 | 1354 | { |
| 1355 | - require_once($GLOBALS['rootpath']."okapi/cronjobs.php"); |
|
| 1355 | + require_once($GLOBALS['rootpath'] . "okapi/cronjobs.php"); |
|
| 1356 | 1356 | $nearest_event = CronJobController::run_jobs('pre-request'); |
| 1357 | 1357 | Okapi::set_var("cron_nearest_event", $nearest_event); |
| 1358 | 1358 | } |
@@ -1369,7 +1369,7 @@ discard block |
||
| 1369 | 1369 | { |
| 1370 | 1370 | set_time_limit(0); |
| 1371 | 1371 | ignore_user_abort(true); |
| 1372 | - require_once($GLOBALS['rootpath']."okapi/cronjobs.php"); |
|
| 1372 | + require_once($GLOBALS['rootpath'] . "okapi/cronjobs.php"); |
|
| 1373 | 1373 | $nearest_event = CronJobController::run_jobs('cron-5'); |
| 1374 | 1374 | Okapi::set_var("cron_nearest_event", $nearest_event); |
| 1375 | 1375 | } |
@@ -1485,9 +1485,9 @@ discard block |
||
| 1485 | 1485 | $chars = "abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
| 1486 | 1486 | $max = strlen($chars); |
| 1487 | 1487 | $key = ""; |
| 1488 | - for ($i=0; $i<$length; $i++) |
|
| 1488 | + for ($i = 0; $i < $length; $i++) |
|
| 1489 | 1489 | { |
| 1490 | - $key .= $chars[rand(0, $max-1)]; |
|
| 1490 | + $key .= $chars[rand(0, $max - 1)]; |
|
| 1491 | 1491 | } |
| 1492 | 1492 | return $key; |
| 1493 | 1493 | } |
@@ -1499,7 +1499,7 @@ discard block |
||
| 1499 | 1499 | */ |
| 1500 | 1500 | public static function register_new_consumer($appname, $appurl, $email) |
| 1501 | 1501 | { |
| 1502 | - require_once($GLOBALS['rootpath']."okapi/service_runner.php"); |
|
| 1502 | + require_once($GLOBALS['rootpath'] . "okapi/service_runner.php"); |
|
| 1503 | 1503 | $consumer = new OkapiConsumer(Okapi::generate_key(20), Okapi::generate_key(40), |
| 1504 | 1504 | $appname, $appurl, $email); |
| 1505 | 1505 | $sample_cache = OkapiServiceRunner::call("services/caches/search/all", |
@@ -1517,7 +1517,7 @@ discard block |
||
| 1517 | 1517 | print "Note: Consumer Secret is needed only when you intend to use OAuth.\n"; |
| 1518 | 1518 | print "You don't need Consumer Secret for Level 1 Authentication.\n\n"; |
| 1519 | 1519 | print "Now you can easily access Level 1 OKAPI methods. E.g.:\n"; |
| 1520 | - print Settings::get('SITE_URL')."okapi/services/caches/geocache?cache_code=$sample_cache_code&consumer_key=$consumer->key\n\n"; |
|
| 1520 | + print Settings::get('SITE_URL') . "okapi/services/caches/geocache?cache_code=$sample_cache_code&consumer_key=$consumer->key\n\n"; |
|
| 1521 | 1521 | print "If you plan on using OKAPI for a longer time, then you may want to\n"; |
| 1522 | 1522 | print "subscribe to the OKAPI News blog to stay up-to-date:\n"; |
| 1523 | 1523 | print "http://opencaching-api.blogspot.com/\n\n"; |
@@ -1538,11 +1538,11 @@ discard block |
||
| 1538 | 1538 | Db::execute(" |
| 1539 | 1539 | insert into okapi_consumers (`key`, name, secret, url, email, date_created) |
| 1540 | 1540 | values ( |
| 1541 | - '".Db::escape_string($consumer->key)."', |
|
| 1542 | - '".Db::escape_string($consumer->name)."', |
|
| 1543 | - '".Db::escape_string($consumer->secret)."', |
|
| 1544 | - '".Db::escape_string($consumer->url)."', |
|
| 1545 | - '".Db::escape_string($consumer->email)."', |
|
| 1541 | + '".Db::escape_string($consumer->key) . "', |
|
| 1542 | + '".Db::escape_string($consumer->name) . "', |
|
| 1543 | + '".Db::escape_string($consumer->secret) . "', |
|
| 1544 | + '".Db::escape_string($consumer->url) . "', |
|
| 1545 | + '".Db::escape_string($consumer->email) . "', |
|
| 1546 | 1546 | now() |
| 1547 | 1547 | ); |
| 1548 | 1548 | "); |
@@ -1551,13 +1551,13 @@ discard block |
||
| 1551 | 1551 | /** Return the distance between two geopoints, in meters. */ |
| 1552 | 1552 | public static function get_distance($lat1, $lon1, $lat2, $lon2) |
| 1553 | 1553 | { |
| 1554 | - $x1 = (90-$lat1) * 3.14159 / 180; |
|
| 1555 | - $x2 = (90-$lat2) * 3.14159 / 180; |
|
| 1554 | + $x1 = (90 - $lat1) * 3.14159 / 180; |
|
| 1555 | + $x2 = (90 - $lat2) * 3.14159 / 180; |
|
| 1556 | 1556 | # |
| 1557 | 1557 | # min(1, ...) was added below to prevent getting values greater than 1 due |
| 1558 | 1558 | # to floating point precision limits. See issue #351 for details. |
| 1559 | 1559 | # |
| 1560 | - $d = acos(min(1, cos($x1) * cos($x2) + sin($x1) * sin($x2) * cos(($lon1-$lon2) * 3.14159 / 180))) * 6371000; |
|
| 1560 | + $d = acos(min(1, cos($x1) * cos($x2) + sin($x1) * sin($x2) * cos(($lon1 - $lon2) * 3.14159 / 180))) * 6371000; |
|
| 1561 | 1561 | if ($d < 0) $d = 0; |
| 1562 | 1562 | return $d; |
| 1563 | 1563 | } |
@@ -1595,7 +1595,7 @@ discard block |
||
| 1595 | 1595 | $bearing = atan2(sin($delta_lon) * cos($rad_lat2), |
| 1596 | 1596 | cos($rad_lat1) * sin($rad_lat2) - sin($rad_lat1) * cos($rad_lat2) * cos($delta_lon)); |
| 1597 | 1597 | $bearing = 180.0 * $bearing / 3.14159; |
| 1598 | - if ( $bearing < 0.0 ) $bearing = $bearing + 360.0; |
|
| 1598 | + if ($bearing < 0.0) $bearing = $bearing + 360.0; |
|
| 1599 | 1599 | |
| 1600 | 1600 | return $bearing; |
| 1601 | 1601 | } |
@@ -1662,7 +1662,7 @@ discard block |
||
| 1662 | 1662 | throw new InvalidParam('callback', "'$callback' doesn't seem to be a valid JavaScript function name (should match /^[a-zA-Z_][a-zA-Z0-9_]*\$/)."); |
| 1663 | 1663 | $response = new OkapiHttpResponse(); |
| 1664 | 1664 | $response->content_type = "application/javascript; charset=utf-8"; |
| 1665 | - $response->body = $callback."(".json_encode($object).");"; |
|
| 1665 | + $response->body = $callback . "(" . json_encode($object) . ");"; |
|
| 1666 | 1666 | return $response; |
| 1667 | 1667 | } |
| 1668 | 1668 | elseif ($format == 'xmlmap') |
@@ -1732,7 +1732,7 @@ discard block |
||
| 1732 | 1732 | $chunks[] = "<dict>"; |
| 1733 | 1733 | foreach ($obj as $key => &$item_ref) |
| 1734 | 1734 | { |
| 1735 | - $chunks[] = "<item key=\"".self::xmlescape($key)."\">"; |
|
| 1735 | + $chunks[] = "<item key=\"" . self::xmlescape($key) . "\">"; |
|
| 1736 | 1736 | self::_xmlmap_add($chunks, $item_ref); |
| 1737 | 1737 | $chunks[] = "</item>"; |
| 1738 | 1738 | } |
@@ -1742,13 +1742,13 @@ discard block |
||
| 1742 | 1742 | else |
| 1743 | 1743 | { |
| 1744 | 1744 | # That's a bug. |
| 1745 | - throw new Exception("Cannot encode as xmlmap: " + print_r($obj, true)); |
|
| 1745 | + throw new Exception("Cannot encode as xmlmap: " +print_r($obj, true)); |
|
| 1746 | 1746 | } |
| 1747 | 1747 | } |
| 1748 | 1748 | |
| 1749 | 1749 | private static function _xmlmap2_add(&$chunks, &$obj, $key) |
| 1750 | 1750 | { |
| 1751 | - $attrs = ($key !== null) ? " key=\"".self::xmlescape($key)."\"" : ""; |
|
| 1751 | + $attrs = ($key !== null) ? " key=\"" . self::xmlescape($key) . "\"" : ""; |
|
| 1752 | 1752 | if (is_string($obj)) |
| 1753 | 1753 | { |
| 1754 | 1754 | $chunks[] = "<string$attrs>"; |
@@ -1853,8 +1853,8 @@ discard block |
||
| 1853 | 1853 | $ref = &self::$cache_types[Settings::get('OC_BRANCH')]; |
| 1854 | 1854 | if (isset($ref[$name])) |
| 1855 | 1855 | return $ref[$name]; |
| 1856 | - throw new Exception("Method cache_type_name2id called with unsupported cache ". |
|
| 1857 | - "type name '$name'. You should not allow users to submit caches ". |
|
| 1856 | + throw new Exception("Method cache_type_name2id called with unsupported cache " . |
|
| 1857 | + "type name '$name'. You should not allow users to submit caches " . |
|
| 1858 | 1858 | "of non-primary type."); |
| 1859 | 1859 | } |
| 1860 | 1860 | |
@@ -2018,7 +2018,7 @@ discard block |
||
| 2018 | 2018 | |
| 2019 | 2019 | $html = preg_replace( |
| 2020 | 2020 | "~\b(src|href)=([\"'])(?![a-z0-9_-]+:)~", |
| 2021 | - "$1=$2".Settings::get("SITE_URL"), |
|
| 2021 | + "$1=$2" . Settings::get("SITE_URL"), |
|
| 2022 | 2022 | $html |
| 2023 | 2023 | ); |
| 2024 | 2024 | |
@@ -2048,10 +2048,10 @@ discard block |
||
| 2048 | 2048 | { |
| 2049 | 2049 | $value = trim(ini_get($variable)); |
| 2050 | 2050 | if (!preg_match("/^[0-9]+[KM]?$/", $value)) |
| 2051 | - throw new Exception("Unexpected PHP setting: ".$variable. " = ".$value); |
|
| 2051 | + throw new Exception("Unexpected PHP setting: " . $variable . " = " . $value); |
|
| 2052 | 2052 | $value = str_replace('K', '*1024', $value); |
| 2053 | 2053 | $value = str_replace('M', '*1024*1024', $value); |
| 2054 | - $value = eval('return '.$value.';'); |
|
| 2054 | + $value = eval('return ' . $value . ';'); |
|
| 2055 | 2055 | return $value; |
| 2056 | 2056 | } |
| 2057 | 2057 | |
@@ -2060,8 +2060,8 @@ discard block |
||
| 2060 | 2060 | const OBJECT_TYPE_CACHE_DESCRIPTION = 2; |
| 2061 | 2061 | const OBJECT_TYPE_CACHE_IMAGE = 3; |
| 2062 | 2062 | const OBJECT_TYPE_CACHE_MP3 = 4; |
| 2063 | - const OBJECT_TYPE_CACHE_LOG = 5; # implemented |
|
| 2064 | - const OBJECT_TYPE_CACHE_LOG_IMAGE = 6; # implemented |
|
| 2063 | + const OBJECT_TYPE_CACHE_LOG = 5; # implemented |
|
| 2064 | + const OBJECT_TYPE_CACHE_LOG_IMAGE = 6; # implemented |
|
| 2065 | 2065 | const OBJECT_TYPE_CACHELIST = 7; |
| 2066 | 2066 | const OBJECT_TYPE_EMAIL = 8; |
| 2067 | 2067 | const OBJECT_TYPE_CACHE_REPORT = 9; |
@@ -2084,14 +2084,14 @@ discard block |
||
| 2084 | 2084 | { |
| 2085 | 2085 | # The current cache implementation is ALWAYS persistent, so we will |
| 2086 | 2086 | # just replace it with a big value. |
| 2087 | - $timeout = 100*365*86400; |
|
| 2087 | + $timeout = 100 * 365 * 86400; |
|
| 2088 | 2088 | } |
| 2089 | 2089 | Db::execute(" |
| 2090 | 2090 | replace into okapi_cache (`key`, value, expires) |
| 2091 | 2091 | values ( |
| 2092 | - '".Db::escape_string($key)."', |
|
| 2093 | - '".Db::escape_string(gzdeflate(serialize($value)))."', |
|
| 2094 | - date_add(now(), interval '".Db::escape_string($timeout)."' second) |
|
| 2092 | + '".Db::escape_string($key) . "', |
|
| 2093 | + '".Db::escape_string(gzdeflate(serialize($value))) . "', |
|
| 2094 | + date_add(now(), interval '".Db::escape_string($timeout) . "' second) |
|
| 2095 | 2095 | ); |
| 2096 | 2096 | "); |
| 2097 | 2097 | } |
@@ -2105,8 +2105,8 @@ discard block |
||
| 2105 | 2105 | Db::execute(" |
| 2106 | 2106 | replace into okapi_cache (`key`, value, expires, score) |
| 2107 | 2107 | values ( |
| 2108 | - '".Db::escape_string($key)."', |
|
| 2109 | - '".Db::escape_string(gzdeflate(serialize($value)))."', |
|
| 2108 | + '".Db::escape_string($key) . "', |
|
| 2109 | + '".Db::escape_string(gzdeflate(serialize($value))) . "', |
|
| 2110 | 2110 | date_add(now(), interval 120 day), |
| 2111 | 2111 | 1.0 |
| 2112 | 2112 | ); |
@@ -2122,20 +2122,20 @@ discard block |
||
| 2122 | 2122 | { |
| 2123 | 2123 | # The current cache implementation is ALWAYS persistent, so we will |
| 2124 | 2124 | # just replace it with a big value. |
| 2125 | - $timeout = 100*365*86400; |
|
| 2125 | + $timeout = 100 * 365 * 86400; |
|
| 2126 | 2126 | } |
| 2127 | 2127 | $entries_escaped = array(); |
| 2128 | 2128 | foreach ($dict as $key => $value) |
| 2129 | 2129 | { |
| 2130 | 2130 | $entries_escaped[] = "( |
| 2131 | - '".Db::escape_string($key)."', |
|
| 2132 | - '".Db::escape_string(gzdeflate(serialize($value)))."', |
|
| 2133 | - date_add(now(), interval '".Db::escape_string($timeout)."' second) |
|
| 2131 | + '".Db::escape_string($key) . "', |
|
| 2132 | + '".Db::escape_string(gzdeflate(serialize($value))) . "', |
|
| 2133 | + date_add(now(), interval '".Db::escape_string($timeout) . "' second) |
|
| 2134 | 2134 | )"; |
| 2135 | 2135 | } |
| 2136 | 2136 | Db::execute(" |
| 2137 | 2137 | replace into okapi_cache (`key`, value, expires) |
| 2138 | - values ".implode(", ", $entries_escaped)." |
|
| 2138 | + values ".implode(", ", $entries_escaped) . " |
|
| 2139 | 2139 | "); |
| 2140 | 2140 | } |
| 2141 | 2141 | |
@@ -2149,7 +2149,7 @@ discard block |
||
| 2149 | 2149 | select value, score |
| 2150 | 2150 | from okapi_cache |
| 2151 | 2151 | where |
| 2152 | - `key` = '".Db::escape_string($key)."' |
|
| 2152 | + `key` = '".Db::escape_string($key) . "' |
|
| 2153 | 2153 | and expires > now() |
| 2154 | 2154 | "); |
| 2155 | 2155 | list($blob, $score) = Db::fetch_row($rs); |
@@ -2159,7 +2159,7 @@ discard block |
||
| 2159 | 2159 | { |
| 2160 | 2160 | Db::execute(" |
| 2161 | 2161 | insert into okapi_cache_reads (`cache_key`) |
| 2162 | - values ('".Db::escape_string($key)."') |
|
| 2162 | + values ('".Db::escape_string($key) . "') |
|
| 2163 | 2163 | "); |
| 2164 | 2164 | } |
| 2165 | 2165 | return unserialize(gzinflate($blob)); |
@@ -2173,7 +2173,7 @@ discard block |
||
| 2173 | 2173 | select `key`, value |
| 2174 | 2174 | from okapi_cache |
| 2175 | 2175 | where |
| 2176 | - `key` in ('".implode("','", array_map('\okapi\Db::escape_string', $keys))."') |
|
| 2176 | + `key` in ('".implode("','", array_map('\okapi\Db::escape_string', $keys)) . "') |
|
| 2177 | 2177 | and expires > now() |
| 2178 | 2178 | "); |
| 2179 | 2179 | while ($row = Db::fetch_assoc($rs)) |
@@ -2186,10 +2186,10 @@ discard block |
||
| 2186 | 2186 | { |
| 2187 | 2187 | unset($dict[$row['key']]); |
| 2188 | 2188 | Okapi::mail_admins("Debug: Unserialize error", |
| 2189 | - "Could not unserialize key '".$row['key']."' from Cache.\n". |
|
| 2190 | - "Probably something REALLY big was put there and data has been truncated.\n". |
|
| 2191 | - "Consider upgrading cache table to LONGBLOB.\n\n". |
|
| 2192 | - "Length of data, compressed: ".strlen($row['value'])); |
|
| 2189 | + "Could not unserialize key '" . $row['key'] . "' from Cache.\n" . |
|
| 2190 | + "Probably something REALLY big was put there and data has been truncated.\n" . |
|
| 2191 | + "Consider upgrading cache table to LONGBLOB.\n\n" . |
|
| 2192 | + "Length of data, compressed: " . strlen($row['value'])); |
|
| 2193 | 2193 | } |
| 2194 | 2194 | } |
| 2195 | 2195 | if (count($dict) < count($keys)) |
@@ -2214,7 +2214,7 @@ discard block |
||
| 2214 | 2214 | return; |
| 2215 | 2215 | Db::execute(" |
| 2216 | 2216 | delete from okapi_cache |
| 2217 | - where `key` in ('".implode("','", array_map('\okapi\Db::escape_string', $keys))."') |
|
| 2217 | + where `key` in ('".implode("','", array_map('\okapi\Db::escape_string', $keys)) . "') |
|
| 2218 | 2218 | "); |
| 2219 | 2219 | } |
| 2220 | 2220 | } |
@@ -2228,7 +2228,7 @@ discard block |
||
| 2228 | 2228 | { |
| 2229 | 2229 | public static function get_file_path($key) |
| 2230 | 2230 | { |
| 2231 | - $filename = Okapi::get_var_dir()."/okapi_filecache_".md5($key); |
|
| 2231 | + $filename = Okapi::get_var_dir() . "/okapi_filecache_" . md5($key); |
|
| 2232 | 2232 | if (!file_exists($filename)) |
| 2233 | 2233 | return null; |
| 2234 | 2234 | return $filename; |
@@ -2241,7 +2241,7 @@ discard block |
||
| 2241 | 2241 | */ |
| 2242 | 2242 | public static function set($key, $value) |
| 2243 | 2243 | { |
| 2244 | - $filename = Okapi::get_var_dir()."/okapi_filecache_".md5($key); |
|
| 2244 | + $filename = Okapi::get_var_dir() . "/okapi_filecache_" . md5($key); |
|
| 2245 | 2245 | file_put_contents($filename, $value); |
| 2246 | 2246 | return $filename; |
| 2247 | 2247 | } |
@@ -2262,7 +2262,7 @@ discard block |
||
| 2262 | 2262 | { |
| 2263 | 2263 | public $consumer; |
| 2264 | 2264 | public $token; |
| 2265 | - public $etag; # see: http://en.wikipedia.org/wiki/HTTP_ETag |
|
| 2265 | + public $etag; # see: http://en.wikipedia.org/wiki/HTTP_ETag |
|
| 2266 | 2266 | |
| 2267 | 2267 | /** |
| 2268 | 2268 | * Set this to true, for some method to allow you to set higher "limit" |
@@ -2386,7 +2386,7 @@ discard block |
||
| 2386 | 2386 | |
| 2387 | 2387 | if (!Settings::get('DEBUG')) |
| 2388 | 2388 | { |
| 2389 | - throw new Exception("Attempted to use DEBUG_AS_USERNAME in ". |
|
| 2389 | + throw new Exception("Attempted to use DEBUG_AS_USERNAME in " . |
|
| 2390 | 2390 | "non-debug environment. Accidental commit?"); |
| 2391 | 2391 | } |
| 2392 | 2392 | |
@@ -2417,12 +2417,12 @@ discard block |
||
| 2417 | 2417 | list($this->consumer, $this->token) = Okapi::$server-> |
| 2418 | 2418 | verify_request2($this->request, $this->opt_token_type, $this->opt_min_auth_level == 3); |
| 2419 | 2419 | if ($this->get_parameter('consumer_key') && $this->get_parameter('consumer_key') != $this->get_parameter('oauth_consumer_key')) |
| 2420 | - throw new BadRequest("Inproper mixing of authentication types. You used both 'consumer_key' ". |
|
| 2421 | - "and 'oauth_consumer_key' parameters (Level 1 and Level 2), but they do not match with ". |
|
| 2420 | + throw new BadRequest("Inproper mixing of authentication types. You used both 'consumer_key' " . |
|
| 2421 | + "and 'oauth_consumer_key' parameters (Level 1 and Level 2), but they do not match with " . |
|
| 2422 | 2422 | "each other. Were you trying to hack me? ;)"); |
| 2423 | 2423 | if ($this->opt_min_auth_level == 3 && !$this->token) |
| 2424 | 2424 | { |
| 2425 | - throw new BadRequest("This method requires a valid Token to be included (Level 3 ". |
|
| 2425 | + throw new BadRequest("This method requires a valid Token to be included (Level 3 " . |
|
| 2426 | 2426 | "Authentication). You didn't provide one."); |
| 2427 | 2427 | } |
| 2428 | 2428 | } |
@@ -2430,8 +2430,8 @@ discard block |
||
| 2430 | 2430 | { |
| 2431 | 2431 | if ($this->opt_min_auth_level >= 2) |
| 2432 | 2432 | { |
| 2433 | - throw new BadRequest("This method requires OAuth signature (Level ". |
|
| 2434 | - $this->opt_min_auth_level." Authentication). You didn't sign your request."); |
|
| 2433 | + throw new BadRequest("This method requires OAuth signature (Level " . |
|
| 2434 | + $this->opt_min_auth_level . " Authentication). You didn't sign your request."); |
|
| 2435 | 2435 | } |
| 2436 | 2436 | else |
| 2437 | 2437 | { |
@@ -2444,7 +2444,7 @@ discard block |
||
| 2444 | 2444 | } |
| 2445 | 2445 | } |
| 2446 | 2446 | if (($this->opt_min_auth_level == 1) && (!$this->consumer)) |
| 2447 | - throw new BadRequest("This method requires the 'consumer_key' argument (Level 1 ". |
|
| 2447 | + throw new BadRequest("This method requires the 'consumer_key' argument (Level 1 " . |
|
| 2448 | 2448 | "Authentication). You didn't provide one."); |
| 2449 | 2449 | } |
| 2450 | 2450 | } |
@@ -2477,10 +2477,10 @@ discard block |
||
| 2477 | 2477 | # Note, that this will override any other valid authentication the |
| 2478 | 2478 | # developer might have issued. |
| 2479 | 2479 | |
| 2480 | - $debug_user_id = Db::select_value("select user_id from user where username='". |
|
| 2481 | - Db::escape_string($options['DEBUG_AS_USERNAME'])."'"); |
|
| 2480 | + $debug_user_id = Db::select_value("select user_id from user where username='" . |
|
| 2481 | + Db::escape_string($options['DEBUG_AS_USERNAME']) . "'"); |
|
| 2482 | 2482 | if ($debug_user_id == null) |
| 2483 | - throw new Exception("Invalid user name in DEBUG_AS_USERNAME: '".$options['DEBUG_AS_USERNAME']."'"); |
|
| 2483 | + throw new Exception("Invalid user name in DEBUG_AS_USERNAME: '" . $options['DEBUG_AS_USERNAME'] . "'"); |
|
| 2484 | 2484 | $this->consumer = new OkapiDebugConsumer(); |
| 2485 | 2485 | $this->token = new OkapiDebugAccessToken($debug_user_id); |
| 2486 | 2486 | } |
@@ -2516,9 +2516,9 @@ discard block |
||
| 2516 | 2516 | } |
| 2517 | 2517 | if (!$allowed) { |
| 2518 | 2518 | throw new BadRequest( |
| 2519 | - "Unrecognized base URL prefix! See `okapi_base_urls` field ". |
|
| 2520 | - "in the `services/apisrv/installation` method. (Recommended ". |
|
| 2521 | - "base URL to use is '".Okapi::get_recommended_base_url()."'.)" |
|
| 2519 | + "Unrecognized base URL prefix! See `okapi_base_urls` field " . |
|
| 2520 | + "in the `services/apisrv/installation` method. (Recommended " . |
|
| 2521 | + "base URL to use is '" . Okapi::get_recommended_base_url() . "'.)" |
|
| 2522 | 2522 | ); |
| 2523 | 2523 | } |
| 2524 | 2524 | } |
@@ -3,19 +3,14 @@ |
||
| 3 | 3 | namespace okapi\services\caches\formatters\garmin; |
| 4 | 4 | |
| 5 | 5 | |
| 6 | -use okapi\Okapi; |
|
| 7 | 6 | use okapi\Cache; |
| 8 | 7 | use okapi\Settings; |
| 9 | 8 | use okapi\OkapiRequest; |
| 10 | -use okapi\OkapiHttpResponse; |
|
| 11 | 9 | use okapi\OkapiInternalRequest; |
| 12 | 10 | use okapi\OkapiServiceRunner; |
| 13 | 11 | use okapi\OkapiZIPHttpResponse; |
| 14 | -use okapi\BadRequest; |
|
| 15 | 12 | use okapi\ParamMissing; |
| 16 | 13 | use okapi\InvalidParam; |
| 17 | -use okapi\OkapiAccessToken; |
|
| 18 | -use okapi\services\caches\search\SearchAssistant; |
|
| 19 | 14 | |
| 20 | 15 | use \Exception; |
| 21 | 16 | use \clsTbsZip; |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | $langpref = $request->get_parameter('langpref'); |
| 41 | 41 | if (!$langpref) $langpref = "en"; |
| 42 | - $langpref .= "|".Settings::get('SITELANG'); |
|
| 42 | + $langpref .= "|" . Settings::get('SITELANG'); |
|
| 43 | 43 | $images = $request->get_parameter('images'); |
| 44 | 44 | if (!$images) $images = "all"; |
| 45 | 45 | if (!in_array($images, array("none", "all", "spoilers", "nonspoilers"))) |
@@ -60,14 +60,14 @@ discard block |
||
| 60 | 60 | # also include image references (actual images will be added as separate files later) |
| 61 | 61 | # and personal data (if the method was invoked using Level 3 Authentication). |
| 62 | 62 | |
| 63 | - switch($format) { |
|
| 63 | + switch ($format) { |
|
| 64 | 64 | case 'gpx' : |
| 65 | - $data_filename = "Garmin/GPX/opencaching".time().rand(100000,999999).".gpx"; |
|
| 65 | + $data_filename = "Garmin/GPX/opencaching" . time() . rand(100000, 999999) . ".gpx"; |
|
| 66 | 66 | $data_method = 'services/caches/formatters/gpx'; |
| 67 | 67 | $data_use_compression = true; |
| 68 | 68 | break; |
| 69 | 69 | case 'ggz' : |
| 70 | - $data_filename = "Garmin/GGZ/opencaching".time().rand(100000,999999).".ggz"; |
|
| 70 | + $data_filename = "Garmin/GGZ/opencaching" . time() . rand(100000, 999999) . ".ggz"; |
|
| 71 | 71 | $data_method = 'services/caches/formatters/ggz'; |
| 72 | 72 | $data_use_compression = false; |
| 73 | 73 | break; |
@@ -107,9 +107,9 @@ discard block |
||
| 107 | 107 | $imgs = $dict['images']; |
| 108 | 108 | if (count($imgs) == 0) |
| 109 | 109 | continue; |
| 110 | - $dir = "Garmin/GeocachePhotos/".$cache_code[strlen($cache_code) - 1]; |
|
| 111 | - $dir .= "/".$cache_code[strlen($cache_code) - 2]; |
|
| 112 | - $dir .= "/".$cache_code; |
|
| 110 | + $dir = "Garmin/GeocachePhotos/" . $cache_code[strlen($cache_code) - 1]; |
|
| 111 | + $dir .= "/" . $cache_code[strlen($cache_code) - 2]; |
|
| 112 | + $dir .= "/" . $cache_code; |
|
| 113 | 113 | foreach ($imgs as $no => $img) |
| 114 | 114 | { |
| 115 | 115 | if ($images == 'spoilers' && (!$img['is_spoiler'])) |
@@ -119,19 +119,19 @@ discard block |
||
| 119 | 119 | $tmp = false; |
| 120 | 120 | foreach ($supported_extensions as $ext) |
| 121 | 121 | { |
| 122 | - if (strtolower(substr($img['url'], strlen($img['url']) - strlen($ext) - 1)) != ".".$ext) |
|
| 122 | + if (strtolower(substr($img['url'], strlen($img['url']) - strlen($ext) - 1)) != "." . $ext) |
|
| 123 | 123 | { |
| 124 | 124 | $tmp = true; |
| 125 | 125 | continue; |
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | 128 | if (!$tmp) |
| 129 | - continue; # unsupported file extension |
|
| 129 | + continue; # unsupported file extension |
|
| 130 | 130 | |
| 131 | 131 | if ($img['is_spoiler']) { |
| 132 | - $zippath = $dir."/Spoilers/".$img['unique_caption'].".jpg"; |
|
| 132 | + $zippath = $dir . "/Spoilers/" . $img['unique_caption'] . ".jpg"; |
|
| 133 | 133 | } else { |
| 134 | - $zippath = $dir."/".$img['unique_caption'].".jpg"; |
|
| 134 | + $zippath = $dir . "/" . $img['unique_caption'] . ".jpg"; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | # The safest way would be to use the URL, but that would be painfully slow! |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | # Note: Oliver Dietz (oc.de) replied that images with 'local' set to 0 could not |
| 142 | 142 | # be accessed locally. But all the files have 'local' set to 1 anyway. |
| 143 | 143 | |
| 144 | - $syspath = Settings::get('IMAGES_DIR')."/".$img['uuid'].".jpg"; |
|
| 144 | + $syspath = Settings::get('IMAGES_DIR') . "/" . $img['uuid'] . ".jpg"; |
|
| 145 | 145 | if (file_exists($syspath)) |
| 146 | 146 | { |
| 147 | 147 | $response->zip->FileAdd($zippath, $syspath, clsTbsZip::TBSZIP_FILE, false); |
@@ -151,13 +151,13 @@ discard block |
||
| 151 | 151 | # If file exists, but does not end with ".jpg", we will create |
| 152 | 152 | # JPEG version of it and store it in the cache. |
| 153 | 153 | |
| 154 | - $cache_key = "jpg#".$img['uuid']; |
|
| 154 | + $cache_key = "jpg#" . $img['uuid']; |
|
| 155 | 155 | $jpeg_contents = Cache::get($cache_key); |
| 156 | 156 | if ($jpeg_contents === null) |
| 157 | 157 | { |
| 158 | 158 | foreach ($supported_extensions as $ext) |
| 159 | 159 | { |
| 160 | - $syspath_other = Settings::get('IMAGES_DIR')."/".$img['uuid'].".".$ext; |
|
| 160 | + $syspath_other = Settings::get('IMAGES_DIR') . "/" . $img['uuid'] . "." . $ext; |
|
| 161 | 161 | if (file_exists($syspath_other)) |
| 162 | 162 | { |
| 163 | 163 | try |
@@ -13,8 +13,6 @@ |
||
| 13 | 13 | use okapi\BadRequest; |
| 14 | 14 | use okapi\OkapiInternalRequest; |
| 15 | 15 | use okapi\OkapiServiceRunner; |
| 16 | -use okapi\OkapiAccessToken; |
|
| 17 | -use okapi\services\caches\search\SearchAssistant; |
|
| 18 | 16 | use okapi\services\attrs\AttrHelper; |
| 19 | 17 | |
| 20 | 18 | class WebService |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | 'my_notes', 'trackables_count', 'trackables', 'alt_wpts', 'last_found', |
| 35 | 35 | 'last_modified', 'date_created', 'date_hidden', 'internal_id', 'is_watched', |
| 36 | 36 | 'is_ignored', 'willattends', 'country', 'state', 'preview_image', |
| 37 | - 'trip_time', 'trip_distance', 'attribution_note','gc_code', 'hint2', 'hints2', |
|
| 37 | + 'trip_time', 'trip_distance', 'attribution_note', 'gc_code', 'hint2', 'hints2', |
|
| 38 | 38 | 'protection_areas', 'short_description', 'short_descriptions', 'needs_maintenance'); |
| 39 | 39 | |
| 40 | 40 | public static function call(OkapiRequest $request) |
@@ -51,14 +51,14 @@ discard block |
||
| 51 | 51 | $cache_codes = explode("|", $cache_codes); |
| 52 | 52 | |
| 53 | 53 | if ((count($cache_codes) > 500) && (!$request->skip_limits)) |
| 54 | - throw new InvalidParam('cache_codes', "Maximum allowed number of referenced ". |
|
| 55 | - "caches is 500. You provided ".count($cache_codes)." cache codes."); |
|
| 54 | + throw new InvalidParam('cache_codes', "Maximum allowed number of referenced " . |
|
| 55 | + "caches is 500. You provided " . count($cache_codes) . " cache codes."); |
|
| 56 | 56 | if (count($cache_codes) != count(array_unique($cache_codes))) |
| 57 | 57 | throw new InvalidParam('cache_codes', "Duplicate codes detected (make sure each cache is referenced only once)."); |
| 58 | 58 | |
| 59 | 59 | $langpref = $request->get_parameter('langpref'); |
| 60 | 60 | if (!$langpref) $langpref = "en"; |
| 61 | - $langpref .= "|".Settings::get('SITELANG'); |
|
| 61 | + $langpref .= "|" . Settings::get('SITELANG'); |
|
| 62 | 62 | $langpref = explode("|", $langpref); |
| 63 | 63 | |
| 64 | 64 | $fields = $request->get_parameter('fields'); |
@@ -99,12 +99,12 @@ discard block |
||
| 99 | 99 | throw new InvalidParam('attribution_append'); |
| 100 | 100 | |
| 101 | 101 | $log_fields = $request->get_parameter('log_fields'); |
| 102 | - if (!$log_fields) $log_fields = "uuid|date|user|type|comment"; // validation is done on call |
|
| 102 | + if (!$log_fields) $log_fields = "uuid|date|user|type|comment"; // validation is done on call |
|
| 103 | 103 | |
| 104 | 104 | $user_uuid = $request->get_parameter('user_uuid'); |
| 105 | 105 | if ($user_uuid != null) |
| 106 | 106 | { |
| 107 | - $user_id = Db::select_value("select user_id from user where uuid='".Db::escape_string($user_uuid)."'"); |
|
| 107 | + $user_id = Db::select_value("select user_id from user where uuid='" . Db::escape_string($user_uuid) . "'"); |
|
| 108 | 108 | if ($user_id == null) |
| 109 | 109 | throw new InvalidParam('user_uuid', "User not found."); |
| 110 | 110 | if (($request->token != null) && ($request->token->user_id != $user_id)) |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | throw new BadRequest("When using 'distance' or 'bearing' fields, you have to supply 'my_location' parameter."); |
| 137 | 137 | $parts = explode('|', $tmp); |
| 138 | 138 | if (count($parts) != 2) |
| 139 | - throw new InvalidParam('my_location', "Expecting 2 pipe-separated parts, got ".count($parts)."."); |
|
| 139 | + throw new InvalidParam('my_location', "Expecting 2 pipe-separated parts, got " . count($parts) . "."); |
|
| 140 | 140 | foreach ($parts as &$part_ref) |
| 141 | 141 | { |
| 142 | 142 | if (!preg_match("/^-?[0-9]+(\.?[0-9]*)$/", $part_ref)) |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | caches c |
| 179 | 179 | left join stat_caches as sc on c.cache_id = sc.cache_id |
| 180 | 180 | where |
| 181 | - wp_oc in ('".implode("','", array_map('\okapi\Db::escape_string', $cache_codes))."') |
|
| 181 | + wp_oc in ('".implode("','", array_map('\okapi\Db::escape_string', $cache_codes)) . "') |
|
| 182 | 182 | and status in (1,2,3) |
| 183 | 183 | "); |
| 184 | 184 | } |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | from |
| 210 | 210 | caches c |
| 211 | 211 | where |
| 212 | - wp_oc in ('".implode("','", array_map('\okapi\Db::escape_string', $cache_codes))."') |
|
| 212 | + wp_oc in ('".implode("','", array_map('\okapi\Db::escape_string', $cache_codes)) . "') |
|
| 213 | 213 | and c.status in (1,2,3) |
| 214 | 214 | "); |
| 215 | 215 | } |
@@ -239,11 +239,11 @@ discard block |
||
| 239 | 239 | break; |
| 240 | 240 | case 'name': $entry['name'] = $row['name']; break; |
| 241 | 241 | case 'names': $entry['names'] = array(Settings::get('SITELANG') => $row['name']); break; // for the future |
| 242 | - case 'location': $entry['location'] = round($row['latitude'], 6)."|".round($row['longitude'], 6); break; |
|
| 242 | + case 'location': $entry['location'] = round($row['latitude'], 6) . "|" . round($row['longitude'], 6); break; |
|
| 243 | 243 | case 'type': $entry['type'] = Okapi::cache_type_id2name($row['type']); break; |
| 244 | 244 | case 'status': $entry['status'] = Okapi::cache_status_id2name($row['status']); break; |
| 245 | 245 | case 'needs_maintenance': $entry['needs_maintenance'] = $row['needs_maintenance'] > 0; break; |
| 246 | - case 'url': $entry['url'] = Settings::get('SITE_URL')."viewcache.php?wp=".$row['wp_oc']; break; |
|
| 246 | + case 'url': $entry['url'] = Settings::get('SITE_URL') . "viewcache.php?wp=" . $row['wp_oc']; break; |
|
| 247 | 247 | case 'owner': |
| 248 | 248 | $owner_ids[$row['wp_oc']] = $row['user_id']; |
| 249 | 249 | /* continued later */ |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | break; |
| 254 | 254 | case 'bearing': |
| 255 | 255 | $tmp = Okapi::get_bearing($center_lat, $center_lon, $row['latitude'], $row['longitude']); |
| 256 | - $entry['bearing'] = ($tmp !== null) ? ((int)(10*$tmp)) / 10.0 : null; |
|
| 256 | + $entry['bearing'] = ($tmp !== null) ? ((int)(10 * $tmp)) / 10.0 : null; |
|
| 257 | 257 | break; |
| 258 | 258 | case 'bearing2': |
| 259 | 259 | $tmp = Okapi::get_bearing($center_lat, $center_lon, $row['latitude'], $row['longitude']); |
@@ -287,13 +287,13 @@ discard block |
||
| 287 | 287 | switch (Okapi::cache_sizeid_to_size2($row['size'])) |
| 288 | 288 | { |
| 289 | 289 | case 'none': $entry['size'] = null; break; |
| 290 | - case 'nano': $entry['size'] = 1.0; break; # same as micro |
|
| 290 | + case 'nano': $entry['size'] = 1.0; break; # same as micro |
|
| 291 | 291 | case 'micro': $entry['size'] = 1.0; break; |
| 292 | 292 | case 'small': $entry['size'] = 2.0; break; |
| 293 | 293 | case 'regular': $entry['size'] = 3.0; break; |
| 294 | 294 | case 'large': $entry['size'] = 4.0; break; |
| 295 | 295 | case 'xlarge': $entry['size'] = 5.0; break; |
| 296 | - case 'other': $entry['size'] = null; break; # same as none |
|
| 296 | + case 'other': $entry['size'] = null; break; # same as none |
|
| 297 | 297 | default: throw new Exception(); |
| 298 | 298 | } |
| 299 | 299 | break; |
@@ -304,12 +304,12 @@ discard block |
||
| 304 | 304 | case 'trip_time': |
| 305 | 305 | # search time is entered in hours:minutes and converted to decimal hours, |
| 306 | 306 | # which can produce lots of unneeded decimal places; 2 of them are sufficient here |
| 307 | - $entry['trip_time'] = $row['trip_time'] === null ? null : round($row['trip_time'],2); break; |
|
| 307 | + $entry['trip_time'] = $row['trip_time'] === null ? null : round($row['trip_time'], 2); break; |
|
| 308 | 308 | break; |
| 309 | 309 | case 'trip_distance': |
| 310 | 310 | # way length is entered in km as decimal fraction, but number conversions can |
| 311 | 311 | # create fake digits which should be stripped; meter precision is sufficient here |
| 312 | - $entry['trip_distance'] = $row['trip_distance'] === null ? null : round($row['trip_distance'],3); break; |
|
| 312 | + $entry['trip_distance'] = $row['trip_distance'] === null ? null : round($row['trip_distance'], 3); break; |
|
| 313 | 313 | break; |
| 314 | 314 | case 'rating': |
| 315 | 315 | if ($row['votes'] < 3) $entry['rating'] = null; |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | case 'internal_id': $entry['internal_id'] = $row['cache_id']; break; |
| 349 | 349 | case 'attribution_note': /* handled separately */ break; |
| 350 | 350 | case 'protection_areas': /* handled separately */ break; |
| 351 | - default: throw new Exception("Missing field case: ".$field); |
|
| 351 | + default: throw new Exception("Missing field case: " . $field); |
|
| 352 | 352 | } |
| 353 | 353 | } |
| 354 | 354 | $results[$row['wp_oc']] = $entry; |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | $rs = Db::query(" |
| 365 | 365 | select user_id, uuid, username |
| 366 | 366 | from user |
| 367 | - where user_id in ('".implode("','", array_map('\okapi\Db::escape_string', array_values($owner_ids)))."') |
|
| 367 | + where user_id in ('".implode("','", array_map('\okapi\Db::escape_string', array_values($owner_ids))) . "') |
|
| 368 | 368 | "); |
| 369 | 369 | $tmp = array(); |
| 370 | 370 | while ($row = Db::fetch_assoc($rs)) |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | $result_ref['owner'] = array( |
| 376 | 376 | 'uuid' => $row['uuid'], |
| 377 | 377 | 'username' => $row['username'], |
| 378 | - 'profile_url' => Settings::get('SITE_URL')."viewprofile.php?userid=".$row['user_id'] |
|
| 378 | + 'profile_url' => Settings::get('SITE_URL') . "viewprofile.php?userid=" . $row['user_id'] |
|
| 379 | 379 | ); |
| 380 | 380 | } |
| 381 | 381 | } |
@@ -394,11 +394,11 @@ discard block |
||
| 394 | 394 | where |
| 395 | 395 | c.cache_id = cl.cache_id |
| 396 | 396 | and cl.type in ( |
| 397 | - '".Db::escape_string(Okapi::logtypename2id("Found it"))."', |
|
| 398 | - '".Db::escape_string(Okapi::logtypename2id("Attended"))."' |
|
| 397 | + '".Db::escape_string(Okapi::logtypename2id("Found it")) . "', |
|
| 398 | + '".Db::escape_string(Okapi::logtypename2id("Attended")) . "' |
|
| 399 | 399 | ) |
| 400 | - and cl.user_id = '".Db::escape_string($user_id)."' |
|
| 401 | - ".((Settings::get('OC_BRANCH') == 'oc.pl') ? "and cl.deleted = 0" : "")." |
|
| 400 | + and cl.user_id = '".Db::escape_string($user_id) . "' |
|
| 401 | + ".((Settings::get('OC_BRANCH') == 'oc.pl') ? "and cl.deleted = 0" : "") . " |
|
| 402 | 402 | "); |
| 403 | 403 | $tmp2 = array(); |
| 404 | 404 | foreach ($tmp as $cache_code) |
@@ -420,9 +420,9 @@ discard block |
||
| 420 | 420 | cache_logs cl |
| 421 | 421 | where |
| 422 | 422 | c.cache_id = cl.cache_id |
| 423 | - and cl.type = '".Db::escape_string(Okapi::logtypename2id("Didn't find it"))."' |
|
| 424 | - and cl.user_id = '".Db::escape_string($user_id)."' |
|
| 425 | - ".((Settings::get('OC_BRANCH') == 'oc.pl') ? "and cl.deleted = 0" : "")." |
|
| 423 | + and cl.type = '".Db::escape_string(Okapi::logtypename2id("Didn't find it")) . "' |
|
| 424 | + and cl.user_id = '".Db::escape_string($user_id) . "' |
|
| 425 | + ".((Settings::get('OC_BRANCH') == 'oc.pl') ? "and cl.deleted = 0" : "") . " |
|
| 426 | 426 | "); |
| 427 | 427 | $tmp2 = array(); |
| 428 | 428 | foreach ($tmp as $cache_code) |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | cache_watches cw |
| 445 | 445 | where |
| 446 | 446 | c.cache_id = cw.cache_id |
| 447 | - and cw.user_id = '".Db::escape_string($request->token->user_id)."' |
|
| 447 | + and cw.user_id = '".Db::escape_string($request->token->user_id) . "' |
|
| 448 | 448 | "); |
| 449 | 449 | $tmp2 = array(); |
| 450 | 450 | foreach ($tmp as $cache_code) |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | where |
| 463 | 463 | cli.cache_id = c.cache_id |
| 464 | 464 | and clw.cache_list_id = cli.cache_list_id |
| 465 | - and clw.user_id = '".Db::escape_string($request->token->user_id)."' |
|
| 465 | + and clw.user_id = '".Db::escape_string($request->token->user_id) . "' |
|
| 466 | 466 | "); |
| 467 | 467 | foreach ($tmp as $cache_code) |
| 468 | 468 | $tmp2[$cache_code] = true; |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | cache_ignore ci |
| 486 | 486 | where |
| 487 | 487 | c.cache_id = ci.cache_id |
| 488 | - and ci.user_id = '".Db::escape_string($request->token->user_id)."' |
|
| 488 | + and ci.user_id = '".Db::escape_string($request->token->user_id) . "' |
|
| 489 | 489 | "); |
| 490 | 490 | $tmp2 = array(); |
| 491 | 491 | foreach ($tmp as $cache_code) |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | $rs = Db::query(" |
| 518 | 518 | select cache_id, language, `desc`, short_desc, hint |
| 519 | 519 | from cache_desc |
| 520 | - where cache_id in ('".implode("','", array_map('\okapi\Db::escape_string', array_keys($cacheid2wptcode)))."') |
|
| 520 | + where cache_id in ('".implode("','", array_map('\okapi\Db::escape_string', array_keys($cacheid2wptcode))) . "') |
|
| 521 | 521 | "); |
| 522 | 522 | while ($row = Db::fetch_assoc($rs)) |
| 523 | 523 | { |
@@ -534,11 +534,11 @@ discard block |
||
| 534 | 534 | { |
| 535 | 535 | Okapi::gettext_domain_init(array_merge(array($row['language']), $langpref)); |
| 536 | 536 | $tmp = ( |
| 537 | - "<p style='color:#c00000'><strong>". |
|
| 538 | - _('Parts of this geocache listing may be outdated.'). |
|
| 539 | - "</strong> ". |
|
| 540 | - _('See the log entries for more information.'). |
|
| 541 | - "</p>\n". |
|
| 537 | + "<p style='color:#c00000'><strong>" . |
|
| 538 | + _('Parts of this geocache listing may be outdated.') . |
|
| 539 | + "</strong> " . |
|
| 540 | + _('See the log entries for more information.') . |
|
| 541 | + "</p>\n" . |
|
| 542 | 542 | $tmp |
| 543 | 543 | ); |
| 544 | 544 | Okapi::gettext_domain_restore(); |
@@ -546,11 +546,11 @@ discard block |
||
| 546 | 546 | |
| 547 | 547 | if ($attribution_append != 'none') |
| 548 | 548 | { |
| 549 | - $tmp .= "\n<p><em>". |
|
| 549 | + $tmp .= "\n<p><em>" . |
|
| 550 | 550 | self::get_cache_attribution_note( |
| 551 | 551 | $row['cache_id'], strtolower($row['language']), $langpref, |
| 552 | 552 | $results[$cache_code]['owner'], $attribution_append |
| 553 | - ). |
|
| 553 | + ) . |
|
| 554 | 554 | "</em></p>"; |
| 555 | 555 | } |
| 556 | 556 | $results[$cache_code]['descriptions'][strtolower($row['language'])] = $tmp; |
@@ -563,7 +563,7 @@ discard block |
||
| 563 | 563 | { |
| 564 | 564 | $results[$cache_code]['hints'][strtolower($row['language'])] = $row['hint']; |
| 565 | 565 | $results[$cache_code]['hints2'][strtolower($row['language'])] |
| 566 | - = htmlspecialchars_decode(mb_ereg_replace("<br />", "" , $row['hint']), ENT_COMPAT); |
|
| 566 | + = htmlspecialchars_decode(mb_ereg_replace("<br />", "", $row['hint']), ENT_COMPAT); |
|
| 567 | 567 | } |
| 568 | 568 | } |
| 569 | 569 | foreach ($results as &$result_ref) |
@@ -601,10 +601,10 @@ discard block |
||
| 601 | 601 | else |
| 602 | 602 | $preview_field = "0"; |
| 603 | 603 | $rs = Db::query(" |
| 604 | - select object_id, uuid, url, title, spoiler, ".$preview_field." as preview |
|
| 604 | + select object_id, uuid, url, title, spoiler, ".$preview_field . " as preview |
|
| 605 | 605 | from pictures |
| 606 | 606 | where |
| 607 | - object_id in ('".implode("','", array_map('\okapi\Db::escape_string', array_keys($cacheid2wptcode)))."') |
|
| 607 | + object_id in ('".implode("','", array_map('\okapi\Db::escape_string', array_keys($cacheid2wptcode))) . "') |
|
| 608 | 608 | and display = 1 |
| 609 | 609 | and object_type = 2 |
| 610 | 610 | and unknown_format = 0 |
@@ -630,7 +630,7 @@ discard block |
||
| 630 | 630 | $image = array( |
| 631 | 631 | 'uuid' => $row['uuid'], |
| 632 | 632 | 'url' => $row['url'], |
| 633 | - 'thumb_url' => Settings::get('SITE_URL') . 'thumbs.php?'.$object_type_param.'uuid=' . $row['uuid'], |
|
| 633 | + 'thumb_url' => Settings::get('SITE_URL') . 'thumbs.php?' . $object_type_param . 'uuid=' . $row['uuid'], |
|
| 634 | 634 | 'caption' => $row['title'], |
| 635 | 635 | 'unique_caption' => self::get_unique_caption($row['title']), |
| 636 | 636 | 'is_spoiler' => ($row['spoiler'] ? true : false), |
@@ -658,13 +658,13 @@ discard block |
||
| 658 | 658 | |
| 659 | 659 | # Load internal_attr_id => acode mapping. |
| 660 | 660 | |
| 661 | - require_once($GLOBALS['rootpath'].'okapi/services/attrs/attr_helper.inc.php'); |
|
| 661 | + require_once($GLOBALS['rootpath'] . 'okapi/services/attrs/attr_helper.inc.php'); |
|
| 662 | 662 | $internal2acode = AttrHelper::get_internal_id_to_acode_mapping(); |
| 663 | 663 | |
| 664 | 664 | $rs = Db::query(" |
| 665 | 665 | select cache_id, attrib_id |
| 666 | 666 | from caches_attributes |
| 667 | - where cache_id in ('".implode("','", array_map('\okapi\Db::escape_string', array_keys($cacheid2wptcode)))."') |
|
| 667 | + where cache_id in ('".implode("','", array_map('\okapi\Db::escape_string', array_keys($cacheid2wptcode))) . "') |
|
| 668 | 668 | "); |
| 669 | 669 | while ($row = Db::fetch_assoc($rs)) |
| 670 | 670 | { |
@@ -721,9 +721,9 @@ discard block |
||
| 721 | 721 | select cache_id, uuid |
| 722 | 722 | from cache_logs |
| 723 | 723 | where |
| 724 | - cache_id in ('".implode("','", array_map('\okapi\Db::escape_string', array_keys($cacheid2wptcode)))."') |
|
| 725 | - and ".((Settings::get('OC_BRANCH') == 'oc.pl') ? "deleted = 0" : "true")." |
|
| 726 | - order by cache_id, ".$logs_order_field_SQL." desc, date_created desc, id desc |
|
| 724 | + cache_id in ('".implode("','", array_map('\okapi\Db::escape_string', array_keys($cacheid2wptcode))) . "') |
|
| 725 | + and ".((Settings::get('OC_BRANCH') == 'oc.pl') ? "deleted = 0" : "true") . " |
|
| 726 | + order by cache_id, ".$logs_order_field_SQL . " desc, date_created desc, id desc |
|
| 727 | 727 | "); |
| 728 | 728 | |
| 729 | 729 | $loguuids = array(); |
@@ -808,8 +808,8 @@ discard block |
||
| 808 | 808 | select cache_id, max(date) as date, group_concat(`desc`) as `desc` |
| 809 | 809 | from cache_notes |
| 810 | 810 | where |
| 811 | - cache_id in ('".implode("','", array_map('\okapi\Db::escape_string', array_keys($cacheid2wptcode)))."') |
|
| 812 | - and user_id = '".Db::escape_string($request->token->user_id)."' |
|
| 811 | + cache_id in ('".implode("','", array_map('\okapi\Db::escape_string', array_keys($cacheid2wptcode))) . "') |
|
| 812 | + and user_id = '".Db::escape_string($request->token->user_id) . "' |
|
| 813 | 813 | group by cache_id |
| 814 | 814 | "); |
| 815 | 815 | } |
@@ -822,8 +822,8 @@ discard block |
||
| 822 | 822 | from coordinates |
| 823 | 823 | where |
| 824 | 824 | type = 2 -- personal note |
| 825 | - and cache_id in ('".implode("','", array_map('\okapi\Db::escape_string', array_keys($cacheid2wptcode)))."') |
|
| 826 | - and user_id = '".Db::escape_string($request->token->user_id)."' |
|
| 825 | + and cache_id in ('".implode("','", array_map('\okapi\Db::escape_string', array_keys($cacheid2wptcode))) . "') |
|
| 826 | + and user_id = '".Db::escape_string($request->token->user_id) . "' |
|
| 827 | 827 | group by cache_id |
| 828 | 828 | "); |
| 829 | 829 | } |
@@ -849,7 +849,7 @@ discard block |
||
| 849 | 849 | gk_item gki |
| 850 | 850 | where |
| 851 | 851 | gkiw.id = gki.id |
| 852 | - and gkiw.wp in ('".implode("','", array_map('\okapi\Db::escape_string', $cache_codes))."') |
|
| 852 | + and gkiw.wp in ('".implode("','", array_map('\okapi\Db::escape_string', $cache_codes)) . "') |
|
| 853 | 853 | "); |
| 854 | 854 | $trs = array(); |
| 855 | 855 | while ($row = Db::fetch_assoc($rs)) |
@@ -862,9 +862,9 @@ discard block |
||
| 862 | 862 | foreach ($trs[$cache_code] as $t) |
| 863 | 863 | { |
| 864 | 864 | $result_ref['trackables'][] = array( |
| 865 | - 'code' => 'GK'.str_pad(strtoupper(dechex($t['gk_id'])), 4, "0", STR_PAD_LEFT), |
|
| 865 | + 'code' => 'GK' . str_pad(strtoupper(dechex($t['gk_id'])), 4, "0", STR_PAD_LEFT), |
|
| 866 | 866 | 'name' => $t['name'], |
| 867 | - 'url' => 'http://geokrety.org/konkret.php?id='.$t['gk_id'] |
|
| 867 | + 'url' => 'http://geokrety.org/konkret.php?id=' . $t['gk_id'] |
|
| 868 | 868 | ); |
| 869 | 869 | } |
| 870 | 870 | } |
@@ -883,7 +883,7 @@ discard block |
||
| 883 | 883 | $rs = Db::query(" |
| 884 | 884 | select wp as cache_code, count(*) as count |
| 885 | 885 | from gk_item_waypoint |
| 886 | - where wp in ('".implode("','", array_map('\okapi\Db::escape_string', $cache_codes))."') |
|
| 886 | + where wp in ('".implode("','", array_map('\okapi\Db::escape_string', $cache_codes)) . "') |
|
| 887 | 887 | group by wp |
| 888 | 888 | "); |
| 889 | 889 | $tr_counts = new ArrayObject(); |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | |
| 937 | 937 | foreach ($results as &$result_ref) |
| 938 | 938 | $result_ref['alt_wpts'] = array(); |
| 939 | - $cache_codes_escaped_and_imploded = "'".implode("','", array_map('\okapi\Db::escape_string', array_keys($cacheid2wptcode)))."'"; |
|
| 939 | + $cache_codes_escaped_and_imploded = "'" . implode("','", array_map('\okapi\Db::escape_string', array_keys($cacheid2wptcode))) . "'"; |
|
| 940 | 940 | |
| 941 | 941 | if (Settings::get('OC_BRANCH') == 'oc.pl') |
| 942 | 942 | { |
@@ -966,7 +966,7 @@ discard block |
||
| 966 | 966 | end as okapi_type |
| 967 | 967 | from waypoints |
| 968 | 968 | where |
| 969 | - cache_id in (".$cache_codes_escaped_and_imploded.") |
|
| 969 | + cache_id in (".$cache_codes_escaped_and_imploded . ") |
|
| 970 | 970 | and status = 1 |
| 971 | 971 | order by cache_id, stage, `desc` |
| 972 | 972 | "); |
@@ -1002,7 +1002,7 @@ discard block |
||
| 1002 | 1002 | from coordinates |
| 1003 | 1003 | where |
| 1004 | 1004 | type = 1 |
| 1005 | - and cache_id in (".$cache_codes_escaped_and_imploded.") |
|
| 1005 | + and cache_id in (".$cache_codes_escaped_and_imploded . ") |
|
| 1006 | 1006 | order by cache_id, id |
| 1007 | 1007 | "); |
| 1008 | 1008 | } |
@@ -1010,7 +1010,7 @@ discard block |
||
| 1010 | 1010 | foreach ($cacheid2waypoints as $cache_id => $waypoints) |
| 1011 | 1011 | { |
| 1012 | 1012 | $cache_code = $cacheid2wptcode[$cache_id]; |
| 1013 | - $wpt_format = $cache_code."-%0".strlen(count($waypoints))."d"; |
|
| 1013 | + $wpt_format = $cache_code . "-%0" . strlen(count($waypoints)) . "d"; |
|
| 1014 | 1014 | $index = 0; |
| 1015 | 1015 | foreach ($waypoints as $row) |
| 1016 | 1016 | { |
@@ -1023,11 +1023,11 @@ discard block |
||
| 1023 | 1023 | $index++; |
| 1024 | 1024 | $results[$cache_code]['alt_wpts'][] = array( |
| 1025 | 1025 | 'name' => sprintf($wpt_format, $index), |
| 1026 | - 'location' => round($row['latitude'], 6)."|".round($row['longitude'], 6), |
|
| 1026 | + 'location' => round($row['latitude'], 6) . "|" . round($row['longitude'], 6), |
|
| 1027 | 1027 | 'type' => $row['okapi_type'], |
| 1028 | 1028 | 'type_name' => Okapi::pick_best_language($internal_wpt_type_id2names[$row['internal_type_id']], $langpref), |
| 1029 | 1029 | 'sym' => $row['sym'], |
| 1030 | - 'description' => ($row['stage'] ? _("Stage")." ".$row['stage'].": " : "").$row['desc'], |
|
| 1030 | + 'description' => ($row['stage'] ? _("Stage") . " " . $row['stage'] . ": " : "") . $row['desc'], |
|
| 1031 | 1031 | ); |
| 1032 | 1032 | } |
| 1033 | 1033 | } |
@@ -1045,7 +1045,7 @@ discard block |
||
| 1045 | 1045 | from cache_mod_cords |
| 1046 | 1046 | where |
| 1047 | 1047 | cache_id in ($cache_codes_escaped_and_imploded) |
| 1048 | - and user_id = '".Db::escape_string($request->token->user_id)."' |
|
| 1048 | + and user_id = '" . Db::escape_string($request->token->user_id) . "' |
|
| 1049 | 1049 | "); |
| 1050 | 1050 | } else { |
| 1051 | 1051 | # oc.de |
@@ -1055,7 +1055,7 @@ discard block |
||
| 1055 | 1055 | from coordinates |
| 1056 | 1056 | where |
| 1057 | 1057 | cache_id in ($cache_codes_escaped_and_imploded) |
| 1058 | - and user_id = '".Db::escape_string($request->token->user_id)."' |
|
| 1058 | + and user_id = '" . Db::escape_string($request->token->user_id) . "' |
|
| 1059 | 1059 | and type = 2 |
| 1060 | 1060 | and longitude != 0 |
| 1061 | 1061 | and latitude != 0 |
@@ -1068,8 +1068,8 @@ discard block |
||
| 1068 | 1068 | { |
| 1069 | 1069 | # there should be only one user waypoint per cache... |
| 1070 | 1070 | $results[$cache_code]['alt_wpts'][] = array( |
| 1071 | - 'name' => $cache_code.'-USER-COORDS', |
|
| 1072 | - 'location' => round($row['latitude'], 6)."|".round($row['longitude'], 6), |
|
| 1071 | + 'name' => $cache_code . '-USER-COORDS', |
|
| 1072 | + 'location' => round($row['latitude'], 6) . "|" . round($row['longitude'], 6), |
|
| 1073 | 1073 | 'type' => 'user-coords', |
| 1074 | 1074 | 'type_name' => _("User location"), |
| 1075 | 1075 | 'sym' => 'Block, Green', |
@@ -1114,7 +1114,7 @@ discard block |
||
| 1114 | 1114 | inner join countries on countries.short=c.country |
| 1115 | 1115 | inner join sys_trans_text stt on stt.trans_id = countries.trans_id |
| 1116 | 1116 | where |
| 1117 | - c.wp_oc in ('".implode("','", array_map('\okapi\Db::escape_string', $cache_codes))."') |
|
| 1117 | + c.wp_oc in ('".implode("','", array_map('\okapi\Db::escape_string', $cache_codes)) . "') |
|
| 1118 | 1118 | "); |
| 1119 | 1119 | $country_codes2names = array(); |
| 1120 | 1120 | while ($row = Db::fetch_assoc($rs)) |
@@ -1131,7 +1131,7 @@ discard block |
||
| 1131 | 1131 | caches c |
| 1132 | 1132 | left join cache_location cl on c.cache_id = cl.cache_id |
| 1133 | 1133 | where |
| 1134 | - c.wp_oc in ('".implode("','", array_map('\okapi\Db::escape_string', $cache_codes))."') |
|
| 1134 | + c.wp_oc in ('".implode("','", array_map('\okapi\Db::escape_string', $cache_codes)) . "') |
|
| 1135 | 1135 | "); |
| 1136 | 1136 | while ($row = Db::fetch_assoc($rs)) |
| 1137 | 1137 | { |
@@ -1159,7 +1159,7 @@ discard block |
||
| 1159 | 1159 | caches c, |
| 1160 | 1160 | cache_location cl |
| 1161 | 1161 | where |
| 1162 | - c.wp_oc in ('".implode("','", array_map('\okapi\Db::escape_string', $cache_codes))."') |
|
| 1162 | + c.wp_oc in ('".implode("','", array_map('\okapi\Db::escape_string', $cache_codes)) . "') |
|
| 1163 | 1163 | and c.cache_id = cl.cache_id |
| 1164 | 1164 | "); |
| 1165 | 1165 | while ($row = Db::fetch_assoc($rs)) |
@@ -1203,7 +1203,7 @@ discard block |
||
| 1203 | 1203 | |
| 1204 | 1204 | if (in_array('protection_areas', $fields)) |
| 1205 | 1205 | { |
| 1206 | - $cache_ids_escaped_and_imploded = "'".implode("','", array_map('\okapi\Db::escape_string', array_keys($cacheid2wptcode)))."'"; |
|
| 1206 | + $cache_ids_escaped_and_imploded = "'" . implode("','", array_map('\okapi\Db::escape_string', array_keys($cacheid2wptcode))) . "'"; |
|
| 1207 | 1207 | |
| 1208 | 1208 | if (Settings::get('OC_BRANCH') == 'oc.de') |
| 1209 | 1209 | { |
@@ -1218,7 +1218,7 @@ discard block |
||
| 1218 | 1218 | inner join npa_areas on cache_npa_areas.npa_id = npa_areas.id |
| 1219 | 1219 | inner join npa_types on npa_areas.type_id = npa_types.id |
| 1220 | 1220 | where |
| 1221 | - c.cache_id in (".$cache_ids_escaped_and_imploded.") |
|
| 1221 | + c.cache_id in (".$cache_ids_escaped_and_imploded . ") |
|
| 1222 | 1222 | group by npa_areas.type_id, npa_areas.name |
| 1223 | 1223 | order by npa_types.ordinal |
| 1224 | 1224 | "); |
@@ -1233,14 +1233,14 @@ discard block |
||
| 1233 | 1233 | $rs = Db::query(" |
| 1234 | 1234 | select |
| 1235 | 1235 | c.wp_oc as cache_code, |
| 1236 | - '"._('National Park / Landscape')."' as type, |
|
| 1236 | + '"._('National Park / Landscape') . "' as type, |
|
| 1237 | 1237 | CONVERT(parkipl.name USING utf8) as name |
| 1238 | 1238 | from |
| 1239 | 1239 | caches c |
| 1240 | 1240 | inner join cache_npa_areas on cache_npa_areas.cache_id=c.cache_id |
| 1241 | 1241 | inner join parkipl on cache_npa_areas.parki_id=parkipl.id |
| 1242 | 1242 | where |
| 1243 | - c.cache_id in (".$cache_ids_escaped_and_imploded.") |
|
| 1243 | + c.cache_id in (".$cache_ids_escaped_and_imploded . ") |
|
| 1244 | 1244 | and cache_npa_areas.parki_id != 0 |
| 1245 | 1245 | union |
| 1246 | 1246 | select |
@@ -1252,7 +1252,7 @@ discard block |
||
| 1252 | 1252 | inner join cache_npa_areas on cache_npa_areas.cache_id=c.cache_id |
| 1253 | 1253 | inner join npa_areas on cache_npa_areas.npa_id=npa_areas.id |
| 1254 | 1254 | where |
| 1255 | - c.cache_id in (".$cache_ids_escaped_and_imploded.") |
|
| 1255 | + c.cache_id in (".$cache_ids_escaped_and_imploded . ") |
|
| 1256 | 1256 | and cache_npa_areas.npa_id != 0 |
| 1257 | 1257 | "); |
| 1258 | 1258 | } |
@@ -1321,7 +1321,7 @@ discard block |
||
| 1321 | 1321 | 'description', 'descriptions' |
| 1322 | 1322 | ), $fields)) > 0) |
| 1323 | 1323 | ) { |
| 1324 | - require_once($GLOBALS['rootpath'].'okapi/lib/ocpl_access_logs.php'); |
|
| 1324 | + require_once($GLOBALS['rootpath'] . 'okapi/lib/ocpl_access_logs.php'); |
|
| 1325 | 1325 | \okapi\OCPLAccessLogs::log_geocache_access($request, $cache_ids); |
| 1326 | 1326 | } |
| 1327 | 1327 | } |
@@ -1340,7 +1340,7 @@ discard block |
||
| 1340 | 1340 | # Garmin and cannot determine WHY. That's why we won't use captions until we |
| 1341 | 1341 | # know more. |
| 1342 | 1342 | |
| 1343 | - $caption = self::$caption_no.""; |
|
| 1343 | + $caption = self::$caption_no . ""; |
|
| 1344 | 1344 | self::$caption_no++; |
| 1345 | 1345 | return $caption; |
| 1346 | 1346 | |
@@ -1404,7 +1404,7 @@ discard block |
||
| 1404 | 1404 | # which replicates geocaches! |
| 1405 | 1405 | |
| 1406 | 1406 | $site_name = Okapi::get_normalized_site_name(); |
| 1407 | - $cache_url = $site_url."viewcache.php?cacheid=$cache_id"; |
|
| 1407 | + $cache_url = $site_url . "viewcache.php?cacheid=$cache_id"; |
|
| 1408 | 1408 | |
| 1409 | 1409 | Okapi::gettext_domain_init(array_merge(array($lang), $langpref)); |
| 1410 | 1410 | if (Settings::get('OC_BRANCH') == 'oc.pl') |
@@ -1424,8 +1424,8 @@ discard block |
||
| 1424 | 1424 | { |
| 1425 | 1425 | $note = sprintf( |
| 1426 | 1426 | _( |
| 1427 | - "© <a href='%s'>%s</a>, <a href='%s'>%s</a>, ". |
|
| 1428 | - "<a href='http://creativecommons.org/licenses/by-nc-nd/3.0/de/deed.en'>CC-BY-NC-ND</a>, ". |
|
| 1427 | + "© <a href='%s'>%s</a>, <a href='%s'>%s</a>, " . |
|
| 1428 | + "<a href='http://creativecommons.org/licenses/by-nc-nd/3.0/de/deed.en'>CC-BY-NC-ND</a>, " . |
|
| 1429 | 1429 | "as of %s; all log entries © their authors" |
| 1430 | 1430 | ), |
| 1431 | 1431 | $owner['profile_url'], $owner['username'], $cache_url, $site_name, strftime('%x') |
@@ -1435,8 +1435,8 @@ discard block |
||
| 1435 | 1435 | { |
| 1436 | 1436 | $note = sprintf( |
| 1437 | 1437 | _( |
| 1438 | - "© <a href='%s'>%s</a>, <a href='%s'>%s</a>, ". |
|
| 1439 | - "<a href='http://creativecommons.org/licenses/by-nc-nd/3.0/de/deed.en'>CC-BY-NC-ND</a>; ". |
|
| 1438 | + "© <a href='%s'>%s</a>, <a href='%s'>%s</a>, " . |
|
| 1439 | + "<a href='http://creativecommons.org/licenses/by-nc-nd/3.0/de/deed.en'>CC-BY-NC-ND</a>; " . |
|
| 1440 | 1440 | "all log entries © their authors" |
| 1441 | 1441 | ), |
| 1442 | 1442 | $owner['profile_url'], $owner['username'], $cache_url, $site_name |
@@ -2,21 +2,11 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace okapi\services\caches\map; |
| 4 | 4 | |
| 5 | -use Exception; |
|
| 6 | -use okapi\Okapi; |
|
| 7 | -use okapi\Settings; |
|
| 8 | -use okapi\Cache; |
|
| 9 | 5 | use okapi\Db; |
| 10 | -use okapi\OkapiRequest; |
|
| 11 | -use okapi\OkapiHttpResponse; |
|
| 12 | -use okapi\ParamMissing; |
|
| 13 | 6 | use okapi\InvalidParam; |
| 14 | -use okapi\BadRequest; |
|
| 15 | -use okapi\DoesNotExist; |
|
| 16 | 7 | use okapi\OkapiInternalRequest; |
| 17 | 8 | use okapi\OkapiInternalConsumer; |
| 18 | 9 | use okapi\OkapiServiceRunner; |
| 19 | - |
|
| 20 | 10 | use okapi\services\caches\map\TileTree; |
| 21 | 11 | |
| 22 | 12 | require_once 'tiletree.inc.php'; |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | from okapi_tile_caches |
| 74 | 74 | where |
| 75 | 75 | z=0 |
| 76 | - and cache_id = '".Db::escape_string($cache['internal_id'])."' |
|
| 76 | + and cache_id = '".Db::escape_string($cache['internal_id']) . "' |
|
| 77 | 77 | ")); |
| 78 | 78 | |
| 79 | 79 | # Caches near the poles caused our computations to break here. We will |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | Db::execute(" |
| 124 | 124 | delete from okapi_tile_caches |
| 125 | - where cache_id = '".Db::escape_string($cache_id)."' |
|
| 125 | + where cache_id = '".Db::escape_string($cache_id) . "' |
|
| 126 | 126 | "); |
| 127 | 127 | |
| 128 | 128 | # Note, that after this operation, okapi_tile_status may be out-of-date. |
@@ -145,8 +145,8 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | $z21x = $row[1]; |
| 147 | 147 | $z21y = $row[2]; |
| 148 | - $ex = $z21x >> 8; # initially, z21x / <tile width> |
|
| 149 | - $ey = $z21y >> 8; # initially, z21y / <tile height> |
|
| 148 | + $ex = $z21x >> 8; # initially, z21x / <tile width> |
|
| 149 | + $ey = $z21y >> 8; # initially, z21y / <tile height> |
|
| 150 | 150 | for ($zoom = 21; $zoom >= 0; $zoom--, $ex >>= 1, $ey >>= 1) |
| 151 | 151 | { |
| 152 | 152 | # ($ex, $ey) points to the "exact match" tile. We need to determine |
@@ -154,9 +154,9 @@ discard block |
||
| 154 | 154 | # go with the simple approach and check all 1+8 bordering tiles. |
| 155 | 155 | |
| 156 | 156 | $tiles_in_this_region = array(); |
| 157 | - for ($x=$ex-1; $x<=$ex+1; $x++) |
|
| 158 | - for ($y=$ey-1; $y<=$ey+1; $y++) |
|
| 159 | - if (($x >= 0) && ($x < 1<<$zoom) && ($y >= 0) && ($y < 1<<$zoom)) |
|
| 157 | + for ($x = $ex - 1; $x <= $ex + 1; $x++) |
|
| 158 | + for ($y = $ey - 1; $y <= $ey + 1; $y++) |
|
| 159 | + if (($x >= 0) && ($x < 1 << $zoom) && ($y >= 0) && ($y < 1 << $zoom)) |
|
| 160 | 160 | $tiles_in_this_region[] = array($x, $y); |
| 161 | 161 | |
| 162 | 162 | foreach ($tiles_in_this_region as $coords) |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | list($x, $y) = $coords; |
| 165 | 165 | |
| 166 | 166 | $scale = 8 + 21 - $zoom; |
| 167 | - $margin = 1 << ($scale - 3); # 32px of current $zoom level, measured in z21 pixels. |
|
| 167 | + $margin = 1 << ($scale - 3); # 32px of current $zoom level, measured in z21 pixels. |
|
| 168 | 168 | |
| 169 | 169 | $left_z21x = ($x << $scale) - $margin; |
| 170 | 170 | $right_z21x = (($x + 1) << $scale) + $margin; |
@@ -195,9 +195,9 @@ discard block |
||
| 195 | 195 | { |
| 196 | 196 | list($z, $x, $y) = $coords; |
| 197 | 197 | $alternatives_escaped[] = "( |
| 198 | - z = '".Db::escape_string($z)."' |
|
| 199 | - and x = '".Db::escape_string($x)."' |
|
| 200 | - and y = '".Db::escape_string($y)."' |
|
| 198 | + z = '".Db::escape_string($z) . "' |
|
| 199 | + and x = '".Db::escape_string($x) . "' |
|
| 200 | + and y = '".Db::escape_string($y) . "' |
|
| 201 | 201 | )"; |
| 202 | 202 | } |
| 203 | 203 | if (count($alternatives_escaped) > 0) |
@@ -208,17 +208,17 @@ discard block |
||
| 208 | 208 | ) |
| 209 | 209 | select |
| 210 | 210 | z, x, y, |
| 211 | - '".Db::escape_string($row[0])."', |
|
| 212 | - '".Db::escape_string($row[1])."', |
|
| 213 | - '".Db::escape_string($row[2])."', |
|
| 214 | - '".Db::escape_string($row[3])."', |
|
| 215 | - '".Db::escape_string($row[4])."', |
|
| 216 | - ".(($row[5] === null) ? "null" : "'".Db::escape_string($row[5])."'").", |
|
| 217 | - '".Db::escape_string($row[6])."', |
|
| 218 | - '".Db::escape_string($row[7])."' |
|
| 211 | + '".Db::escape_string($row[0]) . "', |
|
| 212 | + '".Db::escape_string($row[1]) . "', |
|
| 213 | + '".Db::escape_string($row[2]) . "', |
|
| 214 | + '".Db::escape_string($row[3]) . "', |
|
| 215 | + '".Db::escape_string($row[4]) . "', |
|
| 216 | + ".(($row[5] === null) ? "null" : "'" . Db::escape_string($row[5]) . "'") . ", |
|
| 217 | + '".Db::escape_string($row[6]) . "', |
|
| 218 | + '".Db::escape_string($row[7]) . "' |
|
| 219 | 219 | from okapi_tile_status |
| 220 | 220 | where |
| 221 | - (".implode(" or ", $alternatives_escaped).") |
|
| 221 | + (".implode(" or ", $alternatives_escaped) . ") |
|
| 222 | 222 | and status in (1,2) |
| 223 | 223 | "); |
| 224 | 224 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | update okapi_tile_status |
| 230 | 230 | set status=2 |
| 231 | 231 | where |
| 232 | - (".implode(" or ", $alternatives_escaped).") |
|
| 232 | + (".implode(" or ", $alternatives_escaped) . ") |
|
| 233 | 233 | and status=1 |
| 234 | 234 | "); |
| 235 | 235 | } |
@@ -246,13 +246,13 @@ discard block |
||
| 246 | 246 | Db::execute(" |
| 247 | 247 | update okapi_tile_caches |
| 248 | 248 | set |
| 249 | - status = '".Db::escape_string($row[3])."', |
|
| 250 | - type = '".Db::escape_string($row[4])."', |
|
| 251 | - rating = ".(($row[5] === null) ? "null" : "'".Db::escape_string($row[5])."'").", |
|
| 252 | - flags = '".Db::escape_string($row[6])."', |
|
| 253 | - name_crc = '".Db::escape_string($row[7])."' |
|
| 249 | + status = '".Db::escape_string($row[3]) . "', |
|
| 250 | + type = '".Db::escape_string($row[4]) . "', |
|
| 251 | + rating = ".(($row[5] === null) ? "null" : "'" . Db::escape_string($row[5]) . "'") . ", |
|
| 252 | + flags = '".Db::escape_string($row[6]) . "', |
|
| 253 | + name_crc = '".Db::escape_string($row[7]) . "' |
|
| 254 | 254 | where |
| 255 | - cache_id = '".Db::escape_string($row[0])."' |
|
| 255 | + cache_id = '".Db::escape_string($row[0]) . "' |
|
| 256 | 256 | "); |
| 257 | 257 | } |
| 258 | 258 | |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | $cache_id = Db::select_value(" |
| 264 | 264 | select cache_id |
| 265 | 265 | from caches |
| 266 | - where wp_oc='".Db::escape_string($c['object_key']['code'])."' |
|
| 266 | + where wp_oc='".Db::escape_string($c['object_key']['code']) . "' |
|
| 267 | 267 | "); |
| 268 | 268 | self::remove_geocache_from_cached_tiles($cache_id); |
| 269 | 269 | } |
@@ -2,26 +2,18 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace okapi\services\caches\map\tile; |
| 4 | 4 | |
| 5 | -use Exception; |
|
| 6 | -use okapi\Okapi; |
|
| 7 | 5 | use okapi\Settings; |
| 8 | 6 | use okapi\Cache; |
| 9 | -use okapi\FileCache; |
|
| 10 | 7 | use okapi\Db; |
| 11 | 8 | use okapi\OkapiRequest; |
| 12 | 9 | use okapi\OkapiHttpResponse; |
| 13 | 10 | use okapi\ParamMissing; |
| 14 | 11 | use okapi\InvalidParam; |
| 15 | 12 | use okapi\BadRequest; |
| 16 | -use okapi\DoesNotExist; |
|
| 17 | 13 | use okapi\OkapiInternalRequest; |
| 18 | -use okapi\OkapiInternalConsumer; |
|
| 19 | 14 | use okapi\OkapiServiceRunner; |
| 20 | -use okapi\OkapiLock; |
|
| 21 | - |
|
| 22 | 15 | use okapi\services\caches\map\TileTree; |
| 23 | 16 | use okapi\services\caches\map\TileRenderer; |
| 24 | -use okapi\services\caches\search\SearchAssistant; |
|
| 25 | 17 | use okapi\OkapiConsumer; |
| 26 | 18 | |
| 27 | 19 | require_once('tiletree.inc.php'); |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | require_once('tiletree.inc.php'); |
| 28 | 28 | require_once('tilerenderer.inc.php'); |
| 29 | -require_once($GLOBALS['rootpath']."okapi/services/caches/search/searching.inc.php"); |
|
| 29 | +require_once($GLOBALS['rootpath'] . "okapi/services/caches/search/searching.inc.php"); |
|
| 30 | 30 | |
| 31 | 31 | class WebService |
| 32 | 32 | { |
@@ -88,10 +88,10 @@ discard block |
||
| 88 | 88 | throw new InvalidParam('z', "Maximum value for this parameter is 21."); |
| 89 | 89 | $x = self::require_uint($request, 'x'); |
| 90 | 90 | $y = self::require_uint($request, 'y'); |
| 91 | - if ($x >= 1<<$zoom) |
|
| 92 | - throw new InvalidParam('x', "Should be in 0..".((1<<$zoom) - 1)."."); |
|
| 93 | - if ($y >= 1<<$zoom) |
|
| 94 | - throw new InvalidParam('y', "Should be in 0..".((1<<$zoom) - 1)."."); |
|
| 91 | + if ($x >= 1 << $zoom) |
|
| 92 | + throw new InvalidParam('x', "Should be in 0.." . ((1 << $zoom) - 1) . "."); |
|
| 93 | + if ($y >= 1 << $zoom) |
|
| 94 | + throw new InvalidParam('y', "Should be in 0.." . ((1 << $zoom) - 1) . "."); |
|
| 95 | 95 | |
| 96 | 96 | # Now, we will create a search set (or use one previously created). |
| 97 | 97 | # Instead of creating a new OkapiInternalRequest object, we will pass |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | { |
| 129 | 129 | # Load user-related cache ids. |
| 130 | 130 | |
| 131 | - $cache_key = "tileuser/".$request->token->user_id; |
|
| 131 | + $cache_key = "tileuser/" . $request->token->user_id; |
|
| 132 | 132 | $user = self::$USE_OTHER_CACHE ? Cache::get($cache_key) : null; |
| 133 | 133 | if ($user === null) |
| 134 | 134 | { |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | $rs = Db::query(" |
| 140 | 140 | select cache_id |
| 141 | 141 | from cache_ignore |
| 142 | - where user_id = '".Db::escape_string($request->token->user_id)."' |
|
| 142 | + where user_id = '".Db::escape_string($request->token->user_id) . "' |
|
| 143 | 143 | "); |
| 144 | 144 | $user['ignored'] = array(); |
| 145 | 145 | while (list($cache_id) = Db::fetch_row($rs)) |
@@ -151,9 +151,9 @@ discard block |
||
| 151 | 151 | select distinct cache_id |
| 152 | 152 | from cache_logs |
| 153 | 153 | where |
| 154 | - user_id = '".Db::escape_string($request->token->user_id)."' |
|
| 154 | + user_id = '".Db::escape_string($request->token->user_id) . "' |
|
| 155 | 155 | and type = 1 |
| 156 | - and ".((Settings::get('OC_BRANCH') == 'oc.pl') ? "deleted = 0" : "true")." |
|
| 156 | + and ".((Settings::get('OC_BRANCH') == 'oc.pl') ? "deleted = 0" : "true") . " |
|
| 157 | 157 | "); |
| 158 | 158 | $user['found'] = array(); |
| 159 | 159 | while (list($cache_id) = Db::fetch_row($rs)) |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | $rs = Db::query(" |
| 165 | 165 | select distinct cache_id |
| 166 | 166 | from caches |
| 167 | - where user_id = '".Db::escape_string($request->token->user_id)."' |
|
| 167 | + where user_id = '".Db::escape_string($request->token->user_id) . "' |
|
| 168 | 168 | "); |
| 169 | 169 | $user['own'] = array(); |
| 170 | 170 | while (list($cache_id) = Db::fetch_row($rs)) |
@@ -182,9 +182,9 @@ discard block |
||
| 182 | 182 | # the current user is the owner). |
| 183 | 183 | |
| 184 | 184 | if (isset($user['found'][$row_ref[0]])) |
| 185 | - $row_ref[6] |= TileTree::$FLAG_FOUND; # $row[6] is "flags" |
|
| 185 | + $row_ref[6] |= TileTree::$FLAG_FOUND; # $row[6] is "flags" |
|
| 186 | 186 | if (isset($user['own'][$row_ref[0]])) |
| 187 | - $row_ref[6] |= TileTree::$FLAG_OWN; # $row[6] is "flags" |
|
| 187 | + $row_ref[6] |= TileTree::$FLAG_OWN; # $row[6] is "flags" |
|
| 188 | 188 | } |
| 189 | 189 | } |
| 190 | 190 | |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | $response = new OkapiHttpResponse(); |
| 200 | 200 | $response->content_type = $tile->get_content_type(); |
| 201 | 201 | $response->cache_control = "Cache-Control: private, max-age=600"; |
| 202 | - $response->etag = 'W/"'.$image_fingerprint.'"'; |
|
| 202 | + $response->etag = 'W/"' . $image_fingerprint . '"'; |
|
| 203 | 203 | $response->allow_gzip = false; // images are usually compressed, prevent compression at Apache level |
| 204 | 204 | |
| 205 | 205 | # Check if the request didn't include the same ETag. |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | |
| 219 | 219 | # Check if the image was recently rendered and is kept in image cache. |
| 220 | 220 | |
| 221 | - $cache_key = "tile/".$image_fingerprint; |
|
| 221 | + $cache_key = "tile/" . $image_fingerprint; |
|
| 222 | 222 | $response->body = self::$USE_IMAGE_CACHE ? Cache::get($cache_key) : null; |
| 223 | 223 | OkapiServiceRunner::save_stats_extra("caches/map/tile/checkpointC", null, |
| 224 | 224 | microtime(true) - $checkpointC_started); |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Exception; |
| 6 | 6 | use okapi\Okapi; |
| 7 | -use okapi\Settings; |
|
| 8 | 7 | use okapi\Cache; |
| 9 | 8 | use okapi\Db; |
| 10 | 9 | use okapi\FileCache; // WRTODO |
@@ -101,8 +101,8 @@ discard block |
||
| 101 | 101 | return ob_get_clean(); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - private static function get_image($name, $opacity=1, $brightness=0, |
|
| 105 | - $contrast=0, $r=0, $g=0, $b=0) |
|
| 104 | + private static function get_image($name, $opacity = 1, $brightness = 0, |
|
| 105 | + $contrast = 0, $r = 0, $g = 0, $b = 0) |
|
| 106 | 106 | { |
| 107 | 107 | static $locmem_cache = array(); |
| 108 | 108 | |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | try |
| 117 | 117 | { |
| 118 | - $cache_key = "tilesrc/".Okapi::$git_revision."/".self::$VERSION."/".$key; |
|
| 118 | + $cache_key = "tilesrc/" . Okapi::$git_revision . "/" . self::$VERSION . "/" . $key; |
|
| 119 | 119 | $gd2_path = self::$USE_STATIC_IMAGE_CACHE |
| 120 | 120 | ? FileCache::get_file_path($cache_key) : null; |
| 121 | 121 | if ($gd2_path === null) |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | { |
| 129 | 129 | # Miss again (or error decoding). Read the image from PNG. |
| 130 | 130 | |
| 131 | - $locmem_cache[$key] = imagecreatefrompng($GLOBALS['rootpath']."okapi/static/tilemap/$name.png"); |
|
| 131 | + $locmem_cache[$key] = imagecreatefrompng($GLOBALS['rootpath'] . "okapi/static/tilemap/$name.png"); |
|
| 132 | 132 | |
| 133 | 133 | # Apply all wanted effects. |
| 134 | 134 | |
@@ -165,9 +165,9 @@ discard block |
||
| 165 | 165 | $w = imagesx($im); |
| 166 | 166 | $h = imagesy($im); |
| 167 | 167 | |
| 168 | - for($x = 0; $x < $w; $x++) |
|
| 168 | + for ($x = 0; $x < $w; $x++) |
|
| 169 | 169 | { |
| 170 | - for($y = 0; $y < $h; $y++) |
|
| 170 | + for ($y = 0; $y < $h; $y++) |
|
| 171 | 171 | { |
| 172 | 172 | $color = imagecolorat($im, $x, $y); |
| 173 | 173 | $new_color = ((max(0, floor(127 - ((127 - (($color >> 24) & 0x7f)) * $ratio))) & 0x7f) << 24) | ($color & 0x80ffffff); |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | |
| 248 | 248 | # Put the inner marker (indicates the type). |
| 249 | 249 | |
| 250 | - $inner_marker = self::get_image("large_inner_".self::get_type_suffix( |
|
| 250 | + $inner_marker = self::get_image("large_inner_" . self::get_type_suffix( |
|
| 251 | 251 | $type, true), $a, $br, $c, $r, $g, $b); |
| 252 | 252 | imagecopy($this->im, $inner_marker, $px - 7, $py - 22, 0, 0, 16, 16); |
| 253 | 253 | |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | |
| 288 | 288 | if ($found) |
| 289 | 289 | { |
| 290 | - $icon = self::get_image("found", 0.7*$a, $br, $c, $r, $g, $b); |
|
| 290 | + $icon = self::get_image("found", 0.7 * $a, $br, $c, $r, $g, $b); |
|
| 291 | 291 | imagecopy($this->im, $icon, $px - 2, $py - $center_y - 3, 0, 0, 16, 16); |
| 292 | 292 | } |
| 293 | 293 | |
@@ -302,16 +302,16 @@ discard block |
||
| 302 | 302 | $lines = array(); |
| 303 | 303 | $line = ""; |
| 304 | 304 | $nextBonus = ""; |
| 305 | - for ($i=0; ($i<count($words)) || (mb_strlen($nextBonus)>0); $i++) { |
|
| 306 | - $word = isset($words[$i])?$words[$i]:""; |
|
| 305 | + for ($i = 0; ($i < count($words)) || (mb_strlen($nextBonus) > 0); $i++) { |
|
| 306 | + $word = isset($words[$i]) ? $words[$i] : ""; |
|
| 307 | 307 | if (mb_strlen($nextBonus) > 0) |
| 308 | - $word = $nextBonus." ".$word; |
|
| 308 | + $word = $nextBonus . " " . $word; |
|
| 309 | 309 | $nextBonus = ""; |
| 310 | 310 | while (true) { |
| 311 | - $bbox = imagettfbbox($size, 0, $font, $line.$word); |
|
| 312 | - $width = $bbox[2]-$bbox[0]; |
|
| 311 | + $bbox = imagettfbbox($size, 0, $font, $line . $word); |
|
| 312 | + $width = $bbox[2] - $bbox[0]; |
|
| 313 | 313 | if ($width <= $maxWidth) { |
| 314 | - $line .= $word." "; |
|
| 314 | + $line .= $word . " "; |
|
| 315 | 315 | continue 2; |
| 316 | 316 | } |
| 317 | 317 | if (mb_strlen($line) > 0) { |
@@ -319,8 +319,8 @@ discard block |
||
| 319 | 319 | $line = ""; |
| 320 | 320 | continue; |
| 321 | 321 | } |
| 322 | - $nextBonus = $word[mb_strlen($word)-1].$nextBonus; |
|
| 323 | - $word = mb_substr($word, 0, mb_strlen($word)-1); |
|
| 322 | + $nextBonus = $word[mb_strlen($word) - 1] . $nextBonus; |
|
| 323 | + $word = mb_substr($word, 0, mb_strlen($word) - 1); |
|
| 324 | 324 | continue; |
| 325 | 325 | } |
| 326 | 326 | } |
@@ -336,16 +336,16 @@ discard block |
||
| 336 | 336 | { |
| 337 | 337 | # Check cache. |
| 338 | 338 | |
| 339 | - $cache_key = "tilecaption/".self::$VERSION."/".$cache_id."/".$name_crc; |
|
| 339 | + $cache_key = "tilecaption/" . self::$VERSION . "/" . $cache_id . "/" . $name_crc; |
|
| 340 | 340 | $gd2 = self::$USE_CAPTIONS_CACHE ? Cache::get($cache_key) : null; |
| 341 | 341 | if ($gd2 === null) |
| 342 | 342 | { |
| 343 | 343 | # We'll work with 16x bigger image to get smoother interpolation. |
| 344 | 344 | |
| 345 | - $im = imagecreatetruecolor(64*4, 26*4); |
|
| 345 | + $im = imagecreatetruecolor(64 * 4, 26 * 4); |
|
| 346 | 346 | imagealphablending($im, false); |
| 347 | 347 | $transparent = imagecolorallocatealpha($im, 255, 255, 255, 127); |
| 348 | - imagefilledrectangle($im, 0, 0, 64*4, 26*4, $transparent); |
|
| 348 | + imagefilledrectangle($im, 0, 0, 64 * 4, 26 * 4, $transparent); |
|
| 349 | 349 | imagealphablending($im, true); |
| 350 | 350 | |
| 351 | 351 | # Get the name of the cache. |
@@ -353,15 +353,15 @@ discard block |
||
| 353 | 353 | $name = Db::select_value(" |
| 354 | 354 | select name |
| 355 | 355 | from caches |
| 356 | - where cache_id = '".Db::escape_string($cache_id)."' |
|
| 356 | + where cache_id = '".Db::escape_string($cache_id) . "' |
|
| 357 | 357 | "); |
| 358 | 358 | |
| 359 | 359 | # Split the name into a couple of lines. |
| 360 | 360 | |
| 361 | 361 | //$font = $GLOBALS['rootpath'].'util.sec/bt.ttf'; |
| 362 | - $font = $GLOBALS['rootpath'].'okapi/static/tilemap/tahoma.ttf'; |
|
| 362 | + $font = $GLOBALS['rootpath'] . 'okapi/static/tilemap/tahoma.ttf'; |
|
| 363 | 363 | $size = 25; |
| 364 | - $lines = explode("\n", self::wordwrap($font, $size, 64*4 - 6*2, $name)); |
|
| 364 | + $lines = explode("\n", self::wordwrap($font, $size, 64 * 4 - 6 * 2, $name)); |
|
| 365 | 365 | |
| 366 | 366 | # For each line, compute its (x, y) so that the text is centered. |
| 367 | 367 | |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | foreach ($lines as $line) |
| 371 | 371 | { |
| 372 | 372 | $bbox = imagettfbbox($size, 0, $font, $line); |
| 373 | - $width = $bbox[2]-$bbox[0]; |
|
| 373 | + $width = $bbox[2] - $bbox[0]; |
|
| 374 | 374 | $x = 128 - ($width >> 1); |
| 375 | 375 | $positions[] = array($x, $y); |
| 376 | 376 | $y += 36; |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | $drawer = function($x, $y, $color) use (&$lines, &$positions, &$im, &$size, &$font) |
| 379 | 379 | { |
| 380 | 380 | $len = count($lines); |
| 381 | - for ($i=0; $i<$len; $i++) |
|
| 381 | + for ($i = 0; $i < $len; $i++) |
|
| 382 | 382 | { |
| 383 | 383 | $line = $lines[$i]; |
| 384 | 384 | list($offset_x, $offset_y) = $positions[$i]; |
@@ -389,8 +389,8 @@ discard block |
||
| 389 | 389 | # Draw an outline. |
| 390 | 390 | |
| 391 | 391 | $outline_color = imagecolorallocatealpha($im, 255, 255, 255, 80); |
| 392 | - for ($x=0; $x<=12; $x+=3) |
|
| 393 | - for ($y=$size-3; $y<=$size+9; $y+=3) |
|
| 392 | + for ($x = 0; $x <= 12; $x += 3) |
|
| 393 | + for ($y = $size - 3; $y <= $size + 9; $y += 3) |
|
| 394 | 394 | $drawer($x, $y, $outline_color); |
| 395 | 395 | |
| 396 | 396 | # Add a slight shadow effect (on top of the outline). |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | imagealphablending($im, false); |
| 407 | 407 | $small = imagecreatetruecolor(64, 26); |
| 408 | 408 | imagealphablending($small, false); |
| 409 | - imagecopyresampled($small, $im, 0, 0, 0, 0, 64, 26, 64*4, 26*4); |
|
| 409 | + imagecopyresampled($small, $im, 0, 0, 0, 0, 64, 26, 64 * 4, 26 * 4); |
|
| 410 | 410 | |
| 411 | 411 | # Cache it! |
| 412 | 412 | |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | |
| 434 | 434 | # Put the marker (indicates the type). |
| 435 | 435 | |
| 436 | - $marker = self::get_image("medium_".self::get_type_suffix($type, false), $a); |
|
| 436 | + $marker = self::get_image("medium_" . self::get_type_suffix($type, false), $a); |
|
| 437 | 437 | $width = 14; |
| 438 | 438 | $height = 14; |
| 439 | 439 | $center_x = 7; |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | { |
| 491 | 491 | # Mark found caches with V. |
| 492 | 492 | |
| 493 | - $icon = self::get_image("found", 0.7*$a); |
|
| 493 | + $icon = self::get_image("found", 0.7 * $a); |
|
| 494 | 494 | imagecopy($this->im, $icon, $px - ($center_x - $markercenter_x) - 7, |
| 495 | 495 | $py - ($center_y - $markercenter_y) - 9, 0, 0, 16, 16); |
| 496 | 496 | } |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | $own = $flags & TileTree::$FLAG_OWN; |
| 533 | 533 | $new = $flags & TileTree::$FLAG_NEW; |
| 534 | 534 | |
| 535 | - $marker = self::get_image("tiny_".self::get_type_suffix($type, false)); |
|
| 535 | + $marker = self::get_image("tiny_" . self::get_type_suffix($type, false)); |
|
| 536 | 536 | $width = 10; |
| 537 | 537 | $height = 10; |
| 538 | 538 | $center_x = 5; |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | # This is efficient and yields acceptable results. |
| 578 | 578 | |
| 579 | 579 | $matrix = array(); |
| 580 | - for ($i=0; $i<12; $i++) |
|
| 580 | + for ($i = 0; $i < 12; $i++) |
|
| 581 | 581 | $matrix[] = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); |
| 582 | 582 | |
| 583 | 583 | foreach ($this->rows_ref as &$row_ref) |
@@ -586,27 +586,27 @@ discard block |
||
| 586 | 586 | $my = ($row_ref[2] + 64) >> 5; |
| 587 | 587 | if (($mx >= 12) || ($my >= 12)) continue; |
| 588 | 588 | if (($matrix[$mx][$my] === 0) && ($row_ref[8] == 1)) # 8 is count |
| 589 | - $matrix[$mx][$my] = $row_ref[0]; # 0 is cache_id |
|
| 589 | + $matrix[$mx][$my] = $row_ref[0]; # 0 is cache_id |
|
| 590 | 590 | else |
| 591 | 591 | $matrix[$mx][$my] = -1; |
| 592 | 592 | } |
| 593 | 593 | $selected_cache_ids = array(); |
| 594 | - for ($mx=1; $mx<11; $mx++) |
|
| 594 | + for ($mx = 1; $mx < 11; $mx++) |
|
| 595 | 595 | { |
| 596 | - for ($my=1; $my<11; $my++) |
|
| 596 | + for ($my = 1; $my < 11; $my++) |
|
| 597 | 597 | { |
| 598 | 598 | if ($matrix[$mx][$my] > 0) # cache_id |
| 599 | 599 | { |
| 600 | 600 | # Check all adjacent squares. |
| 601 | 601 | |
| 602 | - if ( ($matrix[$mx-1][$my-1] === 0) |
|
| 603 | - && ($matrix[$mx-1][$my ] === 0) |
|
| 604 | - && ($matrix[$mx-1][$my+1] === 0) |
|
| 605 | - && ($matrix[$mx ][$my-1] === 0) |
|
| 606 | - && ($matrix[$mx ][$my+1] === 0) |
|
| 607 | - && ($matrix[$mx+1][$my-1] === 0) |
|
| 608 | - && ($matrix[$mx+1][$my ] === 0) |
|
| 609 | - && ($matrix[$mx+1][$my+1] === 0) |
|
| 602 | + if (($matrix[$mx - 1][$my - 1] === 0) |
|
| 603 | + && ($matrix[$mx - 1][$my] === 0) |
|
| 604 | + && ($matrix[$mx - 1][$my + 1] === 0) |
|
| 605 | + && ($matrix[$mx][$my - 1] === 0) |
|
| 606 | + && ($matrix[$mx][$my + 1] === 0) |
|
| 607 | + && ($matrix[$mx + 1][$my - 1] === 0) |
|
| 608 | + && ($matrix[$mx + 1][$my] === 0) |
|
| 609 | + && ($matrix[$mx + 1][$my + 1] === 0) |
|
| 610 | 610 | ) |
| 611 | 611 | $selected_cache_ids[] = $matrix[$mx][$my]; |
| 612 | 612 | } |
@@ -4,19 +4,11 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Exception; |
| 6 | 6 | use okapi\Okapi; |
| 7 | -use okapi\Settings; |
|
| 8 | 7 | use okapi\Cache; |
| 9 | 8 | use okapi\Db; |
| 10 | -use okapi\OkapiRequest; |
|
| 11 | -use okapi\OkapiHttpResponse; |
|
| 12 | -use okapi\ParamMissing; |
|
| 13 | -use okapi\InvalidParam; |
|
| 14 | -use okapi\BadRequest; |
|
| 15 | -use okapi\DoesNotExist; |
|
| 16 | 9 | use okapi\OkapiInternalRequest; |
| 17 | 10 | use okapi\OkapiInternalConsumer; |
| 18 | 11 | use okapi\OkapiServiceRunner; |
| 19 | -use okapi\OkapiLock; |
|
| 20 | 12 | |
| 21 | 13 | |
| 22 | 14 | class TileTree |
@@ -41,9 +41,9 @@ discard block |
||
| 41 | 41 | select status |
| 42 | 42 | from okapi_tile_status |
| 43 | 43 | where |
| 44 | - z = '".Db::escape_string($zoom)."' |
|
| 45 | - and x = '".Db::escape_string($x)."' |
|
| 46 | - and y = '".Db::escape_string($y)."' |
|
| 44 | + z = '".Db::escape_string($zoom) . "' |
|
| 45 | + and x = '".Db::escape_string($x) . "' |
|
| 46 | + and y = '".Db::escape_string($y) . "' |
|
| 47 | 47 | "); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -83,9 +83,9 @@ discard block |
||
| 83 | 83 | $tile_upper_x = $x << 8; |
| 84 | 84 | $tile_leftmost_y = $y << 8; |
| 85 | 85 | |
| 86 | - $zoom_escaped = "'".Db::escape_string($zoom)."'"; |
|
| 87 | - $tile_upper_x_escaped = "'".Db::escape_string($tile_upper_x)."'"; |
|
| 88 | - $tile_leftmost_y_escaped = "'".Db::escape_string($tile_leftmost_y)."'"; |
|
| 86 | + $zoom_escaped = "'" . Db::escape_string($zoom) . "'"; |
|
| 87 | + $tile_upper_x_escaped = "'" . Db::escape_string($tile_upper_x) . "'"; |
|
| 88 | + $tile_leftmost_y_escaped = "'" . Db::escape_string($tile_leftmost_y) . "'"; |
|
| 89 | 89 | return Db::query(" |
| 90 | 90 | select |
| 91 | 91 | otc.cache_id, |
@@ -97,10 +97,10 @@ discard block |
||
| 97 | 97 | okapi_search_results osr |
| 98 | 98 | where |
| 99 | 99 | z = $zoom_escaped |
| 100 | - and x = '".Db::escape_string($x)."' |
|
| 101 | - and y = '".Db::escape_string($y)."' |
|
| 100 | + and x = '" . Db::escape_string($x) . "' |
|
| 101 | + and y = '".Db::escape_string($y) . "' |
|
| 102 | 102 | and otc.cache_id = osr.cache_id |
| 103 | - and osr.set_id = '".Db::escape_string($set_id)."' |
|
| 103 | + and osr.set_id = '".Db::escape_string($set_id) . "' |
|
| 104 | 104 | group by |
| 105 | 105 | z21x >> (3 + (21 - $zoom_escaped)), |
| 106 | 106 | z21y >> (3 + (21 - $zoom_escaped)) |
@@ -135,8 +135,8 @@ discard block |
||
| 135 | 135 | # but there is *no need* to - this query is run seldom and is cached. |
| 136 | 136 | |
| 137 | 137 | $params = array(); |
| 138 | - $params['status'] = "Available|Temporarily unavailable|Archived"; # we want them all |
|
| 139 | - $params['limit'] = "10000000"; # no limit |
|
| 138 | + $params['status'] = "Available|Temporarily unavailable|Archived"; # we want them all |
|
| 139 | + $params['limit'] = "10000000"; # no limit |
|
| 140 | 140 | |
| 141 | 141 | $internal_request = new OkapiInternalRequest(new OkapiInternalConsumer(), null, $params); |
| 142 | 142 | $internal_request->skip_limits = true; |
@@ -162,14 +162,14 @@ discard block |
||
| 162 | 162 | z, x, y, cache_id, z21x, z21y, status, type, rating, flags, name_crc |
| 163 | 163 | ) values ( |
| 164 | 164 | 0, 0, 0, |
| 165 | - '".Db::escape_string($row[0])."', |
|
| 166 | - '".Db::escape_string($row[1])."', |
|
| 167 | - '".Db::escape_string($row[2])."', |
|
| 168 | - '".Db::escape_string($row[3])."', |
|
| 169 | - '".Db::escape_string($row[4])."', |
|
| 170 | - ".(($row[5] === null) ? "null" : "'".Db::escape_string($row[5])."'").", |
|
| 171 | - '".Db::escape_string($row[6])."', |
|
| 172 | - '".Db::escape_string($row[7])."' |
|
| 165 | + '".Db::escape_string($row[0]) . "', |
|
| 166 | + '".Db::escape_string($row[1]) . "', |
|
| 167 | + '".Db::escape_string($row[2]) . "', |
|
| 168 | + '".Db::escape_string($row[3]) . "', |
|
| 169 | + '".Db::escape_string($row[4]) . "', |
|
| 170 | + ".(($row[5] === null) ? "null" : "'" . Db::escape_string($row[5]) . "'") . ", |
|
| 171 | + '".Db::escape_string($row[6]) . "', |
|
| 172 | + '".Db::escape_string($row[7]) . "' |
|
| 173 | 173 | ); |
| 174 | 174 | "); |
| 175 | 175 | } |
@@ -229,31 +229,31 @@ discard block |
||
| 229 | 229 | flags, name_crc |
| 230 | 230 | ) |
| 231 | 231 | select |
| 232 | - '".Db::escape_string($zoom)."', |
|
| 233 | - '".Db::escape_string($x)."', |
|
| 234 | - '".Db::escape_string($y)."', |
|
| 232 | + '".Db::escape_string($zoom) . "', |
|
| 233 | + '".Db::escape_string($x) . "', |
|
| 234 | + '".Db::escape_string($y) . "', |
|
| 235 | 235 | cache_id, z21x, z21y, status, type, rating, |
| 236 | 236 | flags, name_crc |
| 237 | 237 | from okapi_tile_caches tc2 |
| 238 | 238 | where |
| 239 | - z = '".Db::escape_string($parent_zoom)."' |
|
| 240 | - and x = '".Db::escape_string($parent_x)."' |
|
| 241 | - and y = '".Db::escape_string($parent_y)."' |
|
| 239 | + z = '".Db::escape_string($parent_zoom) . "' |
|
| 240 | + and x = '".Db::escape_string($parent_x) . "' |
|
| 241 | + and y = '".Db::escape_string($parent_y) . "' |
|
| 242 | 242 | and z21x between $left_z21x and $right_z21x |
| 243 | 243 | and z21y between $top_z21y and $bottom_z21y |
| 244 | 244 | "); |
| 245 | 245 | Db::execute("unlock tables;"); |
| 246 | 246 | } catch (Exception $e) { |
| 247 | - Db::execute("unlock tables"); // No "finally" in PHP 5.3 |
|
| 247 | + Db::execute("unlock tables"); // No "finally" in PHP 5.3 |
|
| 248 | 248 | throw $e; |
| 249 | 249 | } |
| 250 | 250 | $test = Db::select_value(" |
| 251 | 251 | select 1 |
| 252 | 252 | from okapi_tile_caches |
| 253 | 253 | where |
| 254 | - z = '".Db::escape_string($zoom)."' |
|
| 255 | - and x = '".Db::escape_string($x)."' |
|
| 256 | - and y = '".Db::escape_string($y)."' |
|
| 254 | + z = '".Db::escape_string($zoom) . "' |
|
| 255 | + and x = '".Db::escape_string($x) . "' |
|
| 256 | + and y = '".Db::escape_string($y) . "' |
|
| 257 | 257 | limit 1; |
| 258 | 258 | "); |
| 259 | 259 | if ($test) |
@@ -268,10 +268,10 @@ discard block |
||
| 268 | 268 | Db::execute(" |
| 269 | 269 | replace into okapi_tile_status (z, x, y, status) |
| 270 | 270 | values ( |
| 271 | - '".Db::escape_string($zoom)."', |
|
| 272 | - '".Db::escape_string($x)."', |
|
| 273 | - '".Db::escape_string($y)."', |
|
| 274 | - '".Db::escape_string($status)."' |
|
| 271 | + '".Db::escape_string($zoom) . "', |
|
| 272 | + '".Db::escape_string($x) . "', |
|
| 273 | + '".Db::escape_string($y) . "', |
|
| 274 | + '".Db::escape_string($status) . "' |
|
| 275 | 275 | ); |
| 276 | 276 | "); |
| 277 | 277 | |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | { |
| 320 | 320 | $offset = 128 << 21; |
| 321 | 321 | $x = round($offset + ($offset * $lon / 180)); |
| 322 | - $y = round($offset - $offset/pi() * log((1 + sin($lat * pi() / 180)) / (1 - sin($lat * pi() / 180))) / 2); |
|
| 322 | + $y = round($offset - $offset / pi() * log((1 + sin($lat * pi() / 180)) / (1 - sin($lat * pi() / 180))) / 2); |
|
| 323 | 323 | return array($x, $y); |
| 324 | 324 | } |
| 325 | 325 | } |
| 326 | 326 | \ No newline at end of file |
@@ -2,16 +2,12 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace okapi\services\caches\save_personal_notes; |
| 4 | 4 | |
| 5 | -use Exception; |
|
| 6 | 5 | use okapi\Okapi; |
| 7 | 6 | use okapi\Db; |
| 8 | 7 | use okapi\OkapiRequest; |
| 9 | 8 | use okapi\ParamMissing; |
| 10 | -use okapi\InvalidParam; |
|
| 11 | -use okapi\BadRequest; |
|
| 12 | 9 | use okapi\OkapiInternalRequest; |
| 13 | 10 | use okapi\OkapiServiceRunner; |
| 14 | -use okapi\OkapiAccessToken; |
|
| 15 | 11 | use okapi\Settings; |
| 16 | 12 | |
| 17 | 13 | |
@@ -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 | } |
@@ -6,7 +6,6 @@ |
||
| 6 | 6 | |
| 7 | 7 | use okapi\Okapi; |
| 8 | 8 | use okapi\OkapiRequest; |
| 9 | -use okapi\ParamMissing; |
|
| 10 | 9 | use okapi\InvalidParam; |
| 11 | 10 | use okapi\Db; |
| 12 | 11 | use okapi\OkapiLock; |
@@ -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 | |