@@ -195,12 +195,12 @@ discard block |
||
| 195 | 195 | /** |
| 196 | 196 | * Maximum size of uploaded images in bytes |
| 197 | 197 | */ |
| 198 | - 'IMAGE_MAX_UPLOAD_SIZE' => 4194304, # 4 MB |
|
| 198 | + 'IMAGE_MAX_UPLOAD_SIZE' => 4194304, # 4 MB |
|
| 199 | 199 | |
| 200 | 200 | /** |
| 201 | 201 | * Maximum 'resolution' of saved images in pixels |
| 202 | 202 | */ |
| 203 | - 'IMAGE_MAX_PIXEL_COUNT' => 524288, # 0.5 MP |
|
| 203 | + 'IMAGE_MAX_PIXEL_COUNT' => 524288, # 0.5 MP |
|
| 204 | 204 | |
| 205 | 205 | /** |
| 206 | 206 | * Quality of saved JPEG images on a scale from 50 to 100. The higher the |
@@ -229,12 +229,12 @@ discard block |
||
| 229 | 229 | # We have to temporarilly disable our default error handler. |
| 230 | 230 | |
| 231 | 231 | OkapiErrorHandler::disable(); |
| 232 | - require_once($GLOBALS['rootpath']."okapi_settings.php"); |
|
| 232 | + require_once($GLOBALS['rootpath'] . "okapi_settings.php"); |
|
| 233 | 233 | $ref = get_okapi_settings(); |
| 234 | 234 | OkapiErrorHandler::reenable(); |
| 235 | 235 | |
| 236 | 236 | } catch (Exception $e) { |
| 237 | - throw new Exception("Could not import <rootpath>/okapi_settings.php:\n".$e->getMessage()); |
|
| 237 | + throw new Exception("Could not import <rootpath>/okapi_settings.php:\n" . $e->getMessage()); |
|
| 238 | 238 | } |
| 239 | 239 | self::$SETTINGS = self::$DEFAULT_SETTINGS; |
| 240 | 240 | foreach (self::$SETTINGS as $key => $_) |
@@ -318,12 +318,12 @@ discard block |
||
| 318 | 318 | */ |
| 319 | 319 | public static function default_gettext_init($langprefs) |
| 320 | 320 | { |
| 321 | - require_once($GLOBALS['rootpath']."okapi/locale/locales.php"); |
|
| 321 | + require_once($GLOBALS['rootpath'] . "okapi/locale/locales.php"); |
|
| 322 | 322 | $locale = Locales::get_best_locale($langprefs); |
| 323 | 323 | putenv("LC_ALL=$locale"); |
| 324 | 324 | setlocale(LC_ALL, $locale); |
| 325 | 325 | setlocale(LC_NUMERIC, "POSIX"); # We don't want *this one* to get out of control. |
| 326 | - bindtextdomain("okapi_messages", $GLOBALS['rootpath'].'okapi/locale'); |
|
| 326 | + bindtextdomain("okapi_messages", $GLOBALS['rootpath'] . 'okapi/locale'); |
|
| 327 | 327 | return $locale; |
| 328 | 328 | } |
| 329 | 329 | |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | public $key; |
| 173 | 173 | public $secret; |
| 174 | 174 | |
| 175 | - function __construct($key, $secret, $callback_url=NULL) { |
|
| 175 | + function __construct($key, $secret, $callback_url = NULL) { |
|
| 176 | 176 | $this->key = $key; |
| 177 | 177 | $this->secret = $secret; |
| 178 | 178 | $this->callback_url = $callback_url; |
@@ -403,9 +403,9 @@ discard block |
||
| 403 | 403 | public static $version = '1.0'; |
| 404 | 404 | public static $POST_INPUT = 'php://input'; |
| 405 | 405 | |
| 406 | - function __construct($http_method, $http_url, $parameters=NULL) { |
|
| 406 | + function __construct($http_method, $http_url, $parameters = NULL) { |
|
| 407 | 407 | $parameters = ($parameters) ? $parameters : array(); |
| 408 | - $parameters = array_merge( OAuthUtil::parse_parameters(parse_url($http_url, PHP_URL_QUERY)), $parameters); |
|
| 408 | + $parameters = array_merge(OAuthUtil::parse_parameters(parse_url($http_url, PHP_URL_QUERY)), $parameters); |
|
| 409 | 409 | $this->parameters = $parameters; |
| 410 | 410 | $this->http_method = $http_method; |
| 411 | 411 | $this->http_url = $http_url; |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | /** |
| 416 | 416 | * attempt to build up a request from what was passed to the server |
| 417 | 417 | */ |
| 418 | - public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) { |
|
| 418 | + public static function from_request($http_method = NULL, $http_url = NULL, $parameters = NULL) { |
|
| 419 | 419 | $scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on") |
| 420 | 420 | ? 'http' |
| 421 | 421 | : 'https'; |
@@ -467,8 +467,8 @@ discard block |
||
| 467 | 467 | /** |
| 468 | 468 | * pretty much a helper function to set up the request |
| 469 | 469 | */ |
| 470 | - public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=NULL) { |
|
| 471 | - $parameters = ($parameters) ? $parameters : array(); |
|
| 470 | + public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters = NULL) { |
|
| 471 | + $parameters = ($parameters) ? $parameters : array(); |
|
| 472 | 472 | $defaults = array("oauth_version" => OAuthRequest::$version, |
| 473 | 473 | "oauth_nonce" => OAuthRequest::generate_nonce(), |
| 474 | 474 | "oauth_timestamp" => OAuthRequest::generate_timestamp(), |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | $post_data = $this->to_postdata(); |
| 578 | 578 | $out = $this->get_normalized_http_url(); |
| 579 | 579 | if ($post_data) { |
| 580 | - $out .= '?'.$post_data; |
|
| 580 | + $out .= '?' . $post_data; |
|
| 581 | 581 | } |
| 582 | 582 | return $out; |
| 583 | 583 | } |
@@ -592,9 +592,9 @@ discard block |
||
| 592 | 592 | /** |
| 593 | 593 | * builds the Authorization: header |
| 594 | 594 | */ |
| 595 | - public function to_header($realm=null) { |
|
| 595 | + public function to_header($realm = null) { |
|
| 596 | 596 | $first = true; |
| 597 | - if($realm) { |
|
| 597 | + if ($realm) { |
|
| 598 | 598 | $out = 'Authorization: OAuth realm="' . OAuthUtil::urlencode_rfc3986($realm) . '"'; |
| 599 | 599 | $first = false; |
| 600 | 600 | } else |
@@ -656,7 +656,7 @@ discard block |
||
| 656 | 656 | |
| 657 | 657 | class OAuthServer { |
| 658 | 658 | protected $timestamp_threshold = 300; // in seconds, five minutes |
| 659 | - protected $version = '1.0'; // hi blaine |
|
| 659 | + protected $version = '1.0'; // hi blaine |
|
| 660 | 660 | protected $signature_methods = array(); |
| 661 | 661 | |
| 662 | 662 | protected $data_store; |
@@ -790,7 +790,7 @@ discard block |
||
| 790 | 790 | /** |
| 791 | 791 | * try to find the token for the provided request's token key |
| 792 | 792 | */ |
| 793 | - protected function get_token($request, $consumer, $token_type="access") { |
|
| 793 | + protected function get_token($request, $consumer, $token_type = "access") { |
|
| 794 | 794 | $token_field = $request instanceof OAuthRequest |
| 795 | 795 | ? $request->get_parameter('oauth_token') |
| 796 | 796 | : NULL; |
@@ -841,7 +841,7 @@ discard block |
||
| 841 | 841 | * check that the timestamp is new enough |
| 842 | 842 | */ |
| 843 | 843 | private function check_timestamp($timestamp) { |
| 844 | - if( ! $timestamp ) |
|
| 844 | + if (!$timestamp) |
|
| 845 | 845 | throw new OAuthMissingParameterException('oauth_timestamp'); |
| 846 | 846 | |
| 847 | 847 | // Cast to integer. See issue #314. |
@@ -859,7 +859,7 @@ discard block |
||
| 859 | 859 | * check that the nonce is not repeated |
| 860 | 860 | */ |
| 861 | 861 | private function check_nonce($consumer, $token, $nonce, $timestamp) { |
| 862 | - if( ! $nonce ) |
|
| 862 | + if (!$nonce) |
|
| 863 | 863 | throw new OAuthMissingParameterException('oauth_nonce'); |
| 864 | 864 | |
| 865 | 865 | // verify that the nonce is uniqueish |
@@ -932,7 +932,7 @@ discard block |
||
| 932 | 932 | // see http://code.google.com/p/oauth/issues/detail?id=163 |
| 933 | 933 | public static function split_header($header, $only_allow_oauth_parameters = true) { |
| 934 | 934 | $params = array(); |
| 935 | - if (preg_match_all('/('.($only_allow_oauth_parameters ? 'oauth_' : '').'[a-z_-]*)=(:?"([^"]*)"|([^,]*))/', $header, $matches)) { |
|
| 935 | + if (preg_match_all('/(' . ($only_allow_oauth_parameters ? 'oauth_' : '') . '[a-z_-]*)=(:?"([^"]*)"|([^,]*))/', $header, $matches)) { |
|
| 936 | 936 | foreach ($matches[1] as $i => $h) { |
| 937 | 937 | $params[$h] = OAuthUtil::urldecode_rfc3986(empty($matches[3][$i]) ? $matches[4][$i] : $matches[3][$i]); |
| 938 | 938 | } |
@@ -967,9 +967,9 @@ discard block |
||
| 967 | 967 | // otherwise we don't have apache and are just going to have to hope |
| 968 | 968 | // that $_SERVER actually contains what we need |
| 969 | 969 | $out = array(); |
| 970 | - if( isset($_SERVER['CONTENT_TYPE']) ) |
|
| 970 | + if (isset($_SERVER['CONTENT_TYPE'])) |
|
| 971 | 971 | $out['Content-Type'] = $_SERVER['CONTENT_TYPE']; |
| 972 | - if( isset($_ENV['CONTENT_TYPE']) ) |
|
| 972 | + if (isset($_ENV['CONTENT_TYPE'])) |
|
| 973 | 973 | $out['Content-Type'] = $_ENV['CONTENT_TYPE']; |
| 974 | 974 | |
| 975 | 975 | foreach ($_SERVER as $key => $value) { |
@@ -992,7 +992,7 @@ discard block |
||
| 992 | 992 | // This function takes a input like a=b&a=c&d=e and returns the parsed |
| 993 | 993 | // parameters like this |
| 994 | 994 | // array('a' => array('b','c'), 'd' => 'e') |
| 995 | - public static function parse_parameters( $input ) { |
|
| 995 | + public static function parse_parameters($input) { |
|
| 996 | 996 | if (!isset($input) || !$input) return array(); |
| 997 | 997 | |
| 998 | 998 | $pairs = explode('&', $input); |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | $row = Db::select_row(" |
| 12 | 12 | select `key`, secret, name, url, email, bflags |
| 13 | 13 | from okapi_consumers |
| 14 | - where `key` = '".Db::escape_string($consumer_key)."' |
|
| 14 | + where `key` = '".Db::escape_string($consumer_key) . "' |
|
| 15 | 15 | "); |
| 16 | 16 | if (!$row) |
| 17 | 17 | return null; |
@@ -25,9 +25,9 @@ discard block |
||
| 25 | 25 | select `key`, consumer_key, secret, token_type, user_id, verifier, callback |
| 26 | 26 | from okapi_tokens |
| 27 | 27 | where |
| 28 | - consumer_key = '".Db::escape_string($consumer->key)."' |
|
| 29 | - and token_type = '".Db::escape_string($token_type)."' |
|
| 30 | - and `key` = '".Db::escape_string($token)."' |
|
| 28 | + consumer_key = '".Db::escape_string($consumer->key) . "' |
|
| 29 | + and token_type = '".Db::escape_string($token_type) . "' |
|
| 30 | + and `key` = '".Db::escape_string($token) . "' |
|
| 31 | 31 | "); |
| 32 | 32 | if (!$row) |
| 33 | 33 | return null; |
@@ -65,9 +65,9 @@ discard block |
||
| 65 | 65 | Db::execute(" |
| 66 | 66 | insert into okapi_nonces (consumer_key, nonce_hash, timestamp) |
| 67 | 67 | values ( |
| 68 | - '".Db::escape_string($consumer->key)."', |
|
| 69 | - '".Db::escape_string($nonce_hash)."', |
|
| 70 | - '".Db::escape_string($timestamp)."' |
|
| 68 | + '".Db::escape_string($consumer->key) . "', |
|
| 69 | + '".Db::escape_string($nonce_hash) . "', |
|
| 70 | + '".Db::escape_string($timestamp) . "' |
|
| 71 | 71 | ); |
| 72 | 72 | "); |
| 73 | 73 | return null; |
@@ -93,17 +93,17 @@ discard block |
||
| 93 | 93 | (`key`, secret, token_type, timestamp, |
| 94 | 94 | user_id, consumer_key, verifier, callback) |
| 95 | 95 | values ( |
| 96 | - '".Db::escape_string($token->key)."', |
|
| 97 | - '".Db::escape_string($token->secret)."', |
|
| 96 | + '".Db::escape_string($token->key) . "', |
|
| 97 | + '".Db::escape_string($token->secret) . "', |
|
| 98 | 98 | 'request', |
| 99 | 99 | unix_timestamp(), |
| 100 | 100 | null, |
| 101 | - '".Db::escape_string($consumer->key)."', |
|
| 102 | - '".Db::escape_string($token->verifier)."', |
|
| 101 | + '".Db::escape_string($consumer->key) . "', |
|
| 102 | + '".Db::escape_string($token->verifier) . "', |
|
| 103 | 103 | ".(($token->callback_url == 'oob') |
| 104 | 104 | ? "null" |
| 105 | - : "'".Db::escape_string($token->callback_url)."'" |
|
| 106 | - )." |
|
| 105 | + : "'" . Db::escape_string($token->callback_url) . "'" |
|
| 106 | + ) . " |
|
| 107 | 107 | ); |
| 108 | 108 | "); |
| 109 | 109 | return $token; |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | Db::execute(" |
| 124 | 124 | delete from okapi_tokens |
| 125 | - where `key` = '".Db::escape_string($token->key)."' |
|
| 125 | + where `key` = '".Db::escape_string($token->key) . "' |
|
| 126 | 126 | "); |
| 127 | 127 | |
| 128 | 128 | # In OKAPI, all Access Tokens are long lived. Therefore, we don't want |
@@ -135,8 +135,8 @@ discard block |
||
| 135 | 135 | from okapi_tokens |
| 136 | 136 | where |
| 137 | 137 | token_type = 'access' |
| 138 | - and user_id = '".Db::escape_string($token->authorized_by_user_id)."' |
|
| 139 | - and consumer_key = '".Db::escape_string($consumer->key)."' |
|
| 138 | + and user_id = '".Db::escape_string($token->authorized_by_user_id) . "' |
|
| 139 | + and consumer_key = '".Db::escape_string($consumer->key) . "' |
|
| 140 | 140 | "); |
| 141 | 141 | if ($row) |
| 142 | 142 | { |
@@ -155,12 +155,12 @@ discard block |
||
| 155 | 155 | insert into okapi_tokens |
| 156 | 156 | (`key`, secret, token_type, timestamp, user_id, consumer_key) |
| 157 | 157 | values ( |
| 158 | - '".Db::escape_string($access_token->key)."', |
|
| 159 | - '".Db::escape_string($access_token->secret)."', |
|
| 158 | + '".Db::escape_string($access_token->key) . "', |
|
| 159 | + '".Db::escape_string($access_token->secret) . "', |
|
| 160 | 160 | 'access', |
| 161 | 161 | unix_timestamp(), |
| 162 | - '".Db::escape_string($access_token->user_id)."', |
|
| 163 | - '".Db::escape_string($consumer->key)."' |
|
| 162 | + '".Db::escape_string($access_token->user_id) . "', |
|
| 163 | + '".Db::escape_string($consumer->key) . "' |
|
| 164 | 164 | ); |
| 165 | 165 | "); |
| 166 | 166 | } |
@@ -36,9 +36,9 @@ discard block |
||
| 36 | 36 | use okapi\OkapiFacadeAccessToken; |
| 37 | 37 | use okapi\Cache; |
| 38 | 38 | |
| 39 | -require_once($GLOBALS['rootpath']."okapi/core.php"); |
|
| 39 | +require_once($GLOBALS['rootpath'] . "okapi/core.php"); |
|
| 40 | 40 | OkapiErrorHandler::$treat_notices_as_errors = true; |
| 41 | -require_once($GLOBALS['rootpath']."okapi/service_runner.php"); |
|
| 41 | +require_once($GLOBALS['rootpath'] . "okapi/service_runner.php"); |
|
| 42 | 42 | Okapi::init_internals(); |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -97,10 +97,10 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public static function import_search_set($temp_table, $min_store, $max_ref_age) |
| 99 | 99 | { |
| 100 | - require_once($GLOBALS['rootpath'].'okapi/services/caches/search/save.php'); |
|
| 100 | + require_once($GLOBALS['rootpath'] . 'okapi/services/caches/search/save.php'); |
|
| 101 | 101 | $tables = array('caches', $temp_table); |
| 102 | 102 | $where_conds = array( |
| 103 | - $temp_table.".cache_id = caches.cache_id", |
|
| 103 | + $temp_table . ".cache_id = caches.cache_id", |
|
| 104 | 104 | 'caches.status in (1,2,3)', |
| 105 | 105 | ); |
| 106 | 106 | return \okapi\services\caches\search\save\WebService::get_set( |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | Db::execute(" |
| 124 | 124 | update caches |
| 125 | 125 | set okapi_syncbase = now() |
| 126 | - where wp_oc in ('".implode("','", array_map('\okapi\Db::escape_string', $cache_codes))."') |
|
| 126 | + where wp_oc in ('".implode("','", array_map('\okapi\Db::escape_string', $cache_codes)) . "') |
|
| 127 | 127 | "); |
| 128 | 128 | } |
| 129 | 129 | |
@@ -140,8 +140,8 @@ discard block |
||
| 140 | 140 | update cache_logs |
| 141 | 141 | set okapi_syncbase = now() |
| 142 | 142 | where |
| 143 | - cache_id = '".Db::escape_string($cache_id)."' |
|
| 144 | - and user_id = '".Db::escape_string($user_id)."' |
|
| 143 | + cache_id = '".Db::escape_string($cache_id) . "' |
|
| 144 | + and user_id = '".Db::escape_string($user_id) . "' |
|
| 145 | 145 | "); |
| 146 | 146 | } |
| 147 | 147 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | public static function database_update() |
| 153 | 153 | { |
| 154 | - require_once($GLOBALS['rootpath']."okapi/views/update.php"); |
|
| 154 | + require_once($GLOBALS['rootpath'] . "okapi/views/update.php"); |
|
| 155 | 155 | $update = new views\update\View; |
| 156 | 156 | $update->call(); |
| 157 | 157 | } |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | */ |
| 202 | 202 | public static function cache_set($key, $value, $timeout) |
| 203 | 203 | { |
| 204 | - Cache::set("facade#".$key, $value, $timeout); |
|
| 204 | + Cache::set("facade#" . $key, $value, $timeout); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** Same as `cache_set`, but works on many key->value pair at once. */ |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | { |
| 210 | 210 | $prefixed_dict = array(); |
| 211 | 211 | foreach ($dict as $key => &$value_ref) { |
| 212 | - $prefixed_dict["facade#".$key] = &$value_ref; |
|
| 212 | + $prefixed_dict["facade#" . $key] = &$value_ref; |
|
| 213 | 213 | } |
| 214 | 214 | Cache::set_many($prefixed_dict, $timeout); |
| 215 | 215 | } |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | */ |
| 221 | 221 | public static function cache_get($key) |
| 222 | 222 | { |
| 223 | - return Cache::get("facade#".$key); |
|
| 223 | + return Cache::get("facade#" . $key); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** Same as `cache_get`, but it works on multiple keys at once. */ |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | { |
| 229 | 229 | $prefixed_keys = array(); |
| 230 | 230 | foreach ($keys as $key) { |
| 231 | - $prefixed_keys[] = "facade#".$key; |
|
| 231 | + $prefixed_keys[] = "facade#" . $key; |
|
| 232 | 232 | } |
| 233 | 233 | $prefixed_result = Cache::get_many($prefixed_keys); |
| 234 | 234 | $result = array(); |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | */ |
| 244 | 244 | public static function cache_delete($key) |
| 245 | 245 | { |
| 246 | - Cache::delete("facade#".$key); |
|
| 246 | + Cache::delete("facade#" . $key); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** Same as `cache_delete`, but works on many keys at once. */ |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | { |
| 252 | 252 | $prefixed_keys = array(); |
| 253 | 253 | foreach ($keys as $key) { |
| 254 | - $prefixed_keys[] = "facade#".$key; |
|
| 254 | + $prefixed_keys[] = "facade#" . $key; |
|
| 255 | 255 | } |
| 256 | 256 | Cache::delete_many($prefixed_keys); |
| 257 | 257 | } |
@@ -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 | } |
@@ -25,6 +25,6 @@ |
||
| 25 | 25 | if (!$OC_sessionid) |
| 26 | 26 | return null; |
| 27 | 27 | |
| 28 | - return Db::select_value("select user_id from sys_sessions where uuid='".Db::escape_string($OC_sessionid)."'"); |
|
| 28 | + return Db::select_value("select user_id from sys_sessions where uuid='" . Db::escape_string($OC_sessionid) . "'"); |
|
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | \ No newline at end of file |
@@ -22,14 +22,14 @@ discard block |
||
| 22 | 22 | // traverse PHP call stack to find out who originally called us |
| 23 | 23 | // first, find first service_runner.php invocation |
| 24 | 24 | // then, find previous class invocation |
| 25 | - for($i = count($trace)-1; $i >= 0; $i--) |
|
| 25 | + for ($i = count($trace) - 1; $i >= 0; $i--) |
|
| 26 | 26 | { |
| 27 | 27 | $frame = $trace[$i]; |
| 28 | 28 | if ($break_next && isset($frame['class'])) |
| 29 | 29 | { |
| 30 | 30 | $class_elems = explode('\\', $frame['class']); |
| 31 | 31 | if (count($class_elems) >= 2) |
| 32 | - $org_caller = $class_elems[count($class_elems)-2]; |
|
| 32 | + $org_caller = $class_elems[count($class_elems) - 2]; |
|
| 33 | 33 | break; |
| 34 | 34 | } |
| 35 | 35 | if (isset($frame['file']) && |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | public static function log_geocache_access(OkapiRequest $request, $cache_ids) |
| 52 | 52 | { |
| 53 | 53 | if (Settings::get('OCPL_ENABLE_GEOCACHE_ACCESS_LOGS') !== true) |
| 54 | - return ; |
|
| 54 | + return; |
|
| 55 | 55 | |
| 56 | 56 | if (Settings::get('OC_BRANCH') == 'oc.pl') |
| 57 | 57 | { |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | if ($request->token != null) |
| 71 | 71 | $user_id = $request->token->user_id; |
| 72 | 72 | $user_id_escaped = $user_id === null ? "null" : "'" . Db::escape_string($user_id) . "'"; |
| 73 | - if (is_array($cache_ids)){ |
|
| 73 | + if (is_array($cache_ids)) { |
|
| 74 | 74 | if (count($cache_ids) == 1) |
| 75 | 75 | $cache_ids_where = "= '" . Db::escape_string($cache_ids[0]) . "'"; |
| 76 | 76 | else |
@@ -101,24 +101,24 @@ discard block |
||
| 101 | 101 | if (is_array($cache_ids) && count($already_logged_cache_ids) == count($cache_ids) |
| 102 | 102 | || !is_array($cache_ids) && count($already_logged_cache_ids) == 1) |
| 103 | 103 | { |
| 104 | - return ; |
|
| 104 | + return; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - if (is_array($cache_ids)){ |
|
| 107 | + if (is_array($cache_ids)) { |
|
| 108 | 108 | $tmp = array(); |
| 109 | 109 | foreach ($cache_ids as $cache_id) |
| 110 | 110 | $tmp[$cache_id] = true; |
| 111 | 111 | foreach ($already_logged_cache_ids as $cache_id) |
| 112 | 112 | unset($tmp[$cache_id]); |
| 113 | 113 | if (count($tmp) <= 0) |
| 114 | - return ; |
|
| 114 | + return; |
|
| 115 | 115 | $cache_ids_filterd = array_keys($tmp); |
| 116 | 116 | unset($tmp); |
| 117 | 117 | } else { |
| 118 | 118 | $cache_ids_filterd = $cache_ids; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - if (is_array($cache_ids_filterd)){ |
|
| 121 | + if (is_array($cache_ids_filterd)) { |
|
| 122 | 122 | if (count($cache_ids_filterd) == 1) |
| 123 | 123 | $cache_ids_where = "= '" . Db::escape_string($cache_ids_filterd[0]) . "'"; |
| 124 | 124 | else |
@@ -12,10 +12,10 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | class clsTbsZip { |
| 15 | - const TBSZIP_DOWNLOAD = 1; // download (default) |
|
| 16 | - const TBSZIP_NOHEADER = 4; // option to use with DOWNLOAD: no header is sent |
|
| 17 | - const TBSZIP_FILE = 8; // output to file , or add from file |
|
| 18 | - const TBSZIP_STRING = 32; // output to string, or add from string |
|
| 15 | + const TBSZIP_DOWNLOAD = 1; // download (default) |
|
| 16 | + const TBSZIP_NOHEADER = 4; // option to use with DOWNLOAD: no header is sent |
|
| 17 | + const TBSZIP_FILE = 8; // output to file , or add from file |
|
| 18 | + const TBSZIP_STRING = 32; // output to string, or add from string |
|
| 19 | 19 | |
| 20 | 20 | function __construct() { |
| 21 | 21 | $this->Meth8Ok = extension_loaded('zlib'); // check if Zlib extension is available. This is need for compress and uncompress with method 8. |
@@ -24,26 +24,26 @@ discard block |
||
| 24 | 24 | $this->Error = false; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - function CreateNew($ArchName='new.zip') { |
|
| 27 | + function CreateNew($ArchName = 'new.zip') { |
|
| 28 | 28 | // Create a new virtual empty archive, the name will be the default name when the archive is flushed. |
| 29 | - if (!isset($this->Meth8Ok)) $this->__construct(); // for PHP 4 compatibility |
|
| 29 | + if (!isset($this->Meth8Ok)) $this->__construct(); // for PHP 4 compatibility |
|
| 30 | 30 | $this->Close(); // note that $this->ArchHnd is set to false here |
| 31 | 31 | $this->Error = false; |
| 32 | 32 | $this->ArchFile = $ArchName; |
| 33 | 33 | $this->ArchIsNew = true; |
| 34 | - $bin = 'PK'.chr(05).chr(06).str_repeat(chr(0), 18); |
|
| 34 | + $bin = 'PK' . chr(05) . chr(06) . str_repeat(chr(0), 18); |
|
| 35 | 35 | $this->CdEndPos = strlen($bin) - 4; |
| 36 | 36 | $this->CdInfo = array('disk_num_curr'=>0, 'disk_num_cd'=>0, 'file_nbr_curr'=>0, 'file_nbr_tot'=>0, 'l_cd'=>0, 'p_cd'=>0, 'l_comm'=>0, 'v_comm'=>'', 'bin'=>$bin); |
| 37 | 37 | $this->CdPos = $this->CdInfo['p_cd']; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - function Open($ArchFile, $UseIncludePath=false) { |
|
| 40 | + function Open($ArchFile, $UseIncludePath = false) { |
|
| 41 | 41 | // Open the zip archive |
| 42 | - if (!isset($this->Meth8Ok)) $this->__construct(); // for PHP 4 compatibility |
|
| 42 | + if (!isset($this->Meth8Ok)) $this->__construct(); // for PHP 4 compatibility |
|
| 43 | 43 | $this->Close(); // close handle and init info |
| 44 | 44 | $this->Error = false; |
| 45 | 45 | $this->ArchIsNew = false; |
| 46 | - $this->ArchIsStream = (is_resource($ArchFile) && (get_resource_type($ArchFile)=='stream')); |
|
| 46 | + $this->ArchIsStream = (is_resource($ArchFile) && (get_resource_type($ArchFile) == 'stream')); |
|
| 47 | 47 | if ($this->ArchIsStream) { |
| 48 | 48 | $this->ArchFile = 'from_stream.zip'; |
| 49 | 49 | $this->ArchHnd = $ArchFile; |
@@ -52,13 +52,13 @@ discard block |
||
| 52 | 52 | $this->ArchFile = $ArchFile; |
| 53 | 53 | $this->ArchHnd = fopen($ArchFile, 'rb', $UseIncludePath); |
| 54 | 54 | } |
| 55 | - $ok = !($this->ArchHnd===false); |
|
| 55 | + $ok = !($this->ArchHnd === false); |
|
| 56 | 56 | if ($ok) $ok = $this->CentralDirRead(); |
| 57 | 57 | return $ok; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | function Close() { |
| 61 | - if (isset($this->ArchHnd) and ($this->ArchHnd!==false)) fclose($this->ArchHnd); |
|
| 61 | + if (isset($this->ArchHnd) and ($this->ArchHnd !== false)) fclose($this->ArchHnd); |
|
| 62 | 62 | $this->ArchFile = ''; |
| 63 | 63 | $this->ArchHnd = false; |
| 64 | 64 | $this->CdInfo = array(); |
@@ -71,20 +71,20 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | function ArchCancelModif() { |
| 73 | 73 | $this->LastReadComp = false; // compression of the last read file (1=compressed, 0=stored not compressed, -1= stored compressed but read uncompressed) |
| 74 | - $this->LastReadIdx = false; // index of the last file read |
|
| 74 | + $this->LastReadIdx = false; // index of the last file read |
|
| 75 | 75 | $this->ReplInfo = array(); |
| 76 | 76 | $this->ReplByPos = array(); |
| 77 | 77 | $this->AddInfo = array(); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - function FileAdd($Name, $Data, $DataType=self::TBSZIP_STRING, $Compress=true) { |
|
| 80 | + function FileAdd($Name, $Data, $DataType = self::TBSZIP_STRING, $Compress = true) { |
|
| 81 | 81 | |
| 82 | - if ($Data===false) return $this->FileCancelModif($Name, false); // Cancel a previously added file |
|
| 82 | + if ($Data === false) return $this->FileCancelModif($Name, false); // Cancel a previously added file |
|
| 83 | 83 | |
| 84 | 84 | // Save information for adding a new file into the archive |
| 85 | - $Diff = 30 + 46 + 2*strlen($Name); // size of the header + cd info |
|
| 85 | + $Diff = 30 + 46 + 2 * strlen($Name); // size of the header + cd info |
|
| 86 | 86 | $Ref = $this->_DataCreateNewRef($Data, $DataType, $Compress, $Diff, $Name); |
| 87 | - if ($Ref===false) return false; |
|
| 87 | + if ($Ref === false) return false; |
|
| 88 | 88 | $Ref['name'] = $Name; |
| 89 | 89 | $this->AddInfo[] = $Ref; |
| 90 | 90 | return $Ref['res']; |
@@ -92,20 +92,20 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | function CentralDirRead() { |
| 95 | - $cd_info = 'PK'.chr(05).chr(06); // signature of the Central Directory |
|
| 95 | + $cd_info = 'PK' . chr(05) . chr(06); // signature of the Central Directory |
|
| 96 | 96 | $cd_pos = -22; |
| 97 | 97 | $this->_MoveTo($cd_pos, SEEK_END); |
| 98 | 98 | $b = $this->_ReadData(4); |
| 99 | - if ($b===$cd_info) { |
|
| 99 | + if ($b === $cd_info) { |
|
| 100 | 100 | $this->CdEndPos = ftell($this->ArchHnd) - 4; |
| 101 | 101 | } else { |
| 102 | 102 | $p = $this->_FindCDEnd($cd_info); |
| 103 | 103 | //echo 'p='.var_export($p,true); exit; |
| 104 | - if ($p===false) { |
|
| 104 | + if ($p === false) { |
|
| 105 | 105 | return $this->RaiseError('The End of Central Directory Record is not found.'); |
| 106 | 106 | } else { |
| 107 | 107 | $this->CdEndPos = $p; |
| 108 | - $this->_MoveTo($p+4); |
|
| 108 | + $this->_MoveTo($p + 4); |
|
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | $this->CdInfo = $this->CentralDirRead_End($cd_info); |
@@ -113,13 +113,13 @@ discard block |
||
| 113 | 113 | $this->CdFileNbr = $this->CdInfo['file_nbr_curr']; |
| 114 | 114 | $this->CdPos = $this->CdInfo['p_cd']; |
| 115 | 115 | |
| 116 | - if ($this->CdFileNbr<=0) return $this->RaiseError('No header found in the Central Directory.'); |
|
| 117 | - if ($this->CdPos<=0) return $this->RaiseError('No position found for the Central Directory.'); |
|
| 116 | + if ($this->CdFileNbr <= 0) return $this->RaiseError('No header found in the Central Directory.'); |
|
| 117 | + if ($this->CdPos <= 0) return $this->RaiseError('No position found for the Central Directory.'); |
|
| 118 | 118 | |
| 119 | 119 | $this->_MoveTo($this->CdPos); |
| 120 | - for ($i=0;$i<$this->CdFileNbr;$i++) { |
|
| 120 | + for ($i = 0; $i < $this->CdFileNbr; $i++) { |
|
| 121 | 121 | $x = $this->CentralDirRead_File($i); |
| 122 | - if ($x!==false) { |
|
| 122 | + if ($x !== false) { |
|
| 123 | 123 | $this->CdFileLst[$i] = $x; |
| 124 | 124 | $this->CdFileByName[$x['v_name']] = $i; |
| 125 | 125 | } |
@@ -128,17 +128,17 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | function CentralDirRead_End($cd_info) { |
| 131 | - $b = $cd_info.$this->_ReadData(18); |
|
| 131 | + $b = $cd_info . $this->_ReadData(18); |
|
| 132 | 132 | $x = array(); |
| 133 | - $x['disk_num_curr'] = $this->_GetDec($b,4,2); // number of this disk |
|
| 134 | - $x['disk_num_cd'] = $this->_GetDec($b,6,2); // number of the disk with the start of the central directory |
|
| 135 | - $x['file_nbr_curr'] = $this->_GetDec($b,8,2); // total number of entries in the central directory on this disk |
|
| 136 | - $x['file_nbr_tot'] = $this->_GetDec($b,10,2); // total number of entries in the central directory |
|
| 137 | - $x['l_cd'] = $this->_GetDec($b,12,4); // size of the central directory |
|
| 138 | - $x['p_cd'] = $this->_GetDec($b,16,4); // position of start of central directory with respect to the starting disk number |
|
| 139 | - $x['l_comm'] = $this->_GetDec($b,20,2); // .ZIP file comment length |
|
| 133 | + $x['disk_num_curr'] = $this->_GetDec($b, 4, 2); // number of this disk |
|
| 134 | + $x['disk_num_cd'] = $this->_GetDec($b, 6, 2); // number of the disk with the start of the central directory |
|
| 135 | + $x['file_nbr_curr'] = $this->_GetDec($b, 8, 2); // total number of entries in the central directory on this disk |
|
| 136 | + $x['file_nbr_tot'] = $this->_GetDec($b, 10, 2); // total number of entries in the central directory |
|
| 137 | + $x['l_cd'] = $this->_GetDec($b, 12, 4); // size of the central directory |
|
| 138 | + $x['p_cd'] = $this->_GetDec($b, 16, 4); // position of start of central directory with respect to the starting disk number |
|
| 139 | + $x['l_comm'] = $this->_GetDec($b, 20, 2); // .ZIP file comment length |
|
| 140 | 140 | $x['v_comm'] = $this->_ReadData($x['l_comm']); // .ZIP file comment |
| 141 | - $x['bin'] = $b.$x['v_comm']; |
|
| 141 | + $x['bin'] = $b . $x['v_comm']; |
|
| 142 | 142 | return $x; |
| 143 | 143 | } |
| 144 | 144 | |
@@ -146,48 +146,48 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | $b = $this->_ReadData(46); |
| 148 | 148 | |
| 149 | - $x = $this->_GetHex($b,0,4); |
|
| 150 | - if ($x!=='h:02014b50') return $this->RaiseError("Signature of Central Directory Header #".$idx." (file information) expected but not found at position ".$this->_TxtPos(ftell($this->ArchHnd) - 46)."."); |
|
| 149 | + $x = $this->_GetHex($b, 0, 4); |
|
| 150 | + if ($x !== 'h:02014b50') return $this->RaiseError("Signature of Central Directory Header #" . $idx . " (file information) expected but not found at position " . $this->_TxtPos(ftell($this->ArchHnd) - 46) . "."); |
|
| 151 | 151 | |
| 152 | 152 | $x = array(); |
| 153 | - $x['vers_used'] = $this->_GetDec($b,4,2); |
|
| 154 | - $x['vers_necess'] = $this->_GetDec($b,6,2); |
|
| 155 | - $x['purp'] = $this->_GetBin($b,8,2); |
|
| 156 | - $x['meth'] = $this->_GetDec($b,10,2); |
|
| 157 | - $x['time'] = $this->_GetDec($b,12,2); |
|
| 158 | - $x['date'] = $this->_GetDec($b,14,2); |
|
| 159 | - $x['crc32'] = $this->_GetDec($b,16,4); |
|
| 160 | - $x['l_data_c'] = $this->_GetDec($b,20,4); |
|
| 161 | - $x['l_data_u'] = $this->_GetDec($b,24,4); |
|
| 162 | - $x['l_name'] = $this->_GetDec($b,28,2); |
|
| 163 | - $x['l_fields'] = $this->_GetDec($b,30,2); |
|
| 164 | - $x['l_comm'] = $this->_GetDec($b,32,2); |
|
| 165 | - $x['disk_num'] = $this->_GetDec($b,34,2); |
|
| 166 | - $x['int_file_att'] = $this->_GetDec($b,36,2); |
|
| 167 | - $x['ext_file_att'] = $this->_GetDec($b,38,4); |
|
| 168 | - $x['p_loc'] = $this->_GetDec($b,42,4); |
|
| 153 | + $x['vers_used'] = $this->_GetDec($b, 4, 2); |
|
| 154 | + $x['vers_necess'] = $this->_GetDec($b, 6, 2); |
|
| 155 | + $x['purp'] = $this->_GetBin($b, 8, 2); |
|
| 156 | + $x['meth'] = $this->_GetDec($b, 10, 2); |
|
| 157 | + $x['time'] = $this->_GetDec($b, 12, 2); |
|
| 158 | + $x['date'] = $this->_GetDec($b, 14, 2); |
|
| 159 | + $x['crc32'] = $this->_GetDec($b, 16, 4); |
|
| 160 | + $x['l_data_c'] = $this->_GetDec($b, 20, 4); |
|
| 161 | + $x['l_data_u'] = $this->_GetDec($b, 24, 4); |
|
| 162 | + $x['l_name'] = $this->_GetDec($b, 28, 2); |
|
| 163 | + $x['l_fields'] = $this->_GetDec($b, 30, 2); |
|
| 164 | + $x['l_comm'] = $this->_GetDec($b, 32, 2); |
|
| 165 | + $x['disk_num'] = $this->_GetDec($b, 34, 2); |
|
| 166 | + $x['int_file_att'] = $this->_GetDec($b, 36, 2); |
|
| 167 | + $x['ext_file_att'] = $this->_GetDec($b, 38, 4); |
|
| 168 | + $x['p_loc'] = $this->_GetDec($b, 42, 4); |
|
| 169 | 169 | $x['v_name'] = $this->_ReadData($x['l_name']); |
| 170 | 170 | $x['v_fields'] = $this->_ReadData($x['l_fields']); |
| 171 | 171 | $x['v_comm'] = $this->_ReadData($x['l_comm']); |
| 172 | 172 | |
| 173 | - $x['bin'] = $b.$x['v_name'].$x['v_fields'].$x['v_comm']; |
|
| 173 | + $x['bin'] = $b . $x['v_name'] . $x['v_fields'] . $x['v_comm']; |
|
| 174 | 174 | |
| 175 | 175 | return $x; |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | function RaiseError($Msg) { |
| 179 | 179 | if ($this->DisplayError) { |
| 180 | - if (PHP_SAPI==='cli') { |
|
| 181 | - echo get_class($this).' ERROR with the zip archive: '.$Msg."\r\n"; |
|
| 180 | + if (PHP_SAPI === 'cli') { |
|
| 181 | + echo get_class($this) . ' ERROR with the zip archive: ' . $Msg . "\r\n"; |
|
| 182 | 182 | } else { |
| 183 | - echo '<strong>'.get_class($this).' ERROR with the zip archive:</strong> '.$Msg.'<br>'."\r\n"; |
|
| 183 | + echo '<strong>' . get_class($this) . ' ERROR with the zip archive:</strong> ' . $Msg . '<br>' . "\r\n"; |
|
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | $this->Error = $Msg; |
| 187 | 187 | return false; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - function Debug($FileHeaders=false) { |
|
| 190 | + function Debug($FileHeaders = false) { |
|
| 191 | 191 | |
| 192 | 192 | $this->DisplayError = true; |
| 193 | 193 | |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | $pos = 0; |
| 198 | 198 | $pos_stop = $this->CdInfo['p_cd']; |
| 199 | 199 | $this->_MoveTo($pos); |
| 200 | - while ( ($pos<$pos_stop) && ($ok = $this->_ReadFile($idx,false)) ) { |
|
| 200 | + while (($pos < $pos_stop) && ($ok = $this->_ReadFile($idx, false))) { |
|
| 201 | 201 | $this->VisFileLst[$idx]['p_this_header (debug_mode only)'] = $pos; |
| 202 | 202 | $pos = ftell($this->ArchHnd); |
| 203 | 203 | $idx++; |
@@ -207,22 +207,22 @@ discard block |
||
| 207 | 207 | $nl = "\r\n"; |
| 208 | 208 | echo "<pre>"; |
| 209 | 209 | |
| 210 | - echo "-------------------------------".$nl; |
|
| 211 | - echo "End of Central Directory record".$nl; |
|
| 212 | - echo "-------------------------------".$nl; |
|
| 210 | + echo "-------------------------------" . $nl; |
|
| 211 | + echo "End of Central Directory record" . $nl; |
|
| 212 | + echo "-------------------------------" . $nl; |
|
| 213 | 213 | print_r($this->DebugArray($this->CdInfo)); |
| 214 | 214 | |
| 215 | 215 | echo $nl; |
| 216 | - echo "-------------------------".$nl; |
|
| 217 | - echo "Central Directory headers".$nl; |
|
| 218 | - echo "-------------------------".$nl; |
|
| 216 | + echo "-------------------------" . $nl; |
|
| 217 | + echo "Central Directory headers" . $nl; |
|
| 218 | + echo "-------------------------" . $nl; |
|
| 219 | 219 | print_r($this->DebugArray($this->CdFileLst)); |
| 220 | 220 | |
| 221 | 221 | if ($FileHeaders) { |
| 222 | 222 | echo $nl; |
| 223 | - echo "------------------".$nl; |
|
| 224 | - echo "Local File headers".$nl; |
|
| 225 | - echo "------------------".$nl; |
|
| 223 | + echo "------------------" . $nl; |
|
| 224 | + echo "Local File headers" . $nl; |
|
| 225 | + echo "------------------" . $nl; |
|
| 226 | 226 | print_r($this->DebugArray($this->VisFileLst)); |
| 227 | 227 | } |
| 228 | 228 | |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | foreach ($arr as $k=>$v) { |
| 235 | 235 | if (is_array($v)) { |
| 236 | 236 | $arr[$k] = $this->DebugArray($v); |
| 237 | - } elseif (substr($k,0,2)=='p_') { |
|
| 237 | + } elseif (substr($k, 0, 2) == 'p_') { |
|
| 238 | 238 | $arr[$k] = $this->_TxtPos($v); |
| 239 | 239 | } |
| 240 | 240 | } |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | function FileExists($NameOrIdx) { |
| 245 | - return ($this->FileGetIdx($NameOrIdx)!==false); |
|
| 245 | + return ($this->FileGetIdx($NameOrIdx) !== false); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | function FileGetIdx($NameOrIdx) { |
@@ -267,18 +267,18 @@ discard block |
||
| 267 | 267 | if (!is_string($Name)) return false; |
| 268 | 268 | $idx_lst = array_keys($this->AddInfo); |
| 269 | 269 | foreach ($idx_lst as $idx) { |
| 270 | - if ($this->AddInfo[$idx]['name']===$Name) return $idx; |
|
| 270 | + if ($this->AddInfo[$idx]['name'] === $Name) return $idx; |
|
| 271 | 271 | } |
| 272 | 272 | return false; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - function FileRead($NameOrIdx, $Uncompress=true) { |
|
| 275 | + function FileRead($NameOrIdx, $Uncompress = true) { |
|
| 276 | 276 | |
| 277 | 277 | $this->LastReadComp = false; // means the file is not found |
| 278 | 278 | $this->LastReadIdx = false; |
| 279 | 279 | |
| 280 | 280 | $idx = $this->FileGetIdx($NameOrIdx); |
| 281 | - if ($idx===false) return $this->RaiseError('File "'.$NameOrIdx.'" is not found in the Central Directory.'); |
|
| 281 | + if ($idx === false) return $this->RaiseError('File "' . $NameOrIdx . '" is not found in the Central Directory.'); |
|
| 282 | 282 | |
| 283 | 283 | $pos = $this->CdFileLst[$idx]['p_loc']; |
| 284 | 284 | $this->_MoveTo($pos); |
@@ -290,19 +290,19 @@ discard block |
||
| 290 | 290 | // Manage uncompression |
| 291 | 291 | $Comp = 1; // means the contents stays compressed |
| 292 | 292 | $meth = $this->CdFileLst[$idx]['meth']; |
| 293 | - if ($meth==8) { |
|
| 293 | + if ($meth == 8) { |
|
| 294 | 294 | if ($Uncompress) { |
| 295 | 295 | if ($this->Meth8Ok) { |
| 296 | 296 | $Data = gzinflate($Data); |
| 297 | 297 | $Comp = -1; // means uncompressed |
| 298 | 298 | } else { |
| 299 | - $this->RaiseError('Unable to uncompress file "'.$NameOrIdx.'" because extension Zlib is not installed.'); |
|
| 299 | + $this->RaiseError('Unable to uncompress file "' . $NameOrIdx . '" because extension Zlib is not installed.'); |
|
| 300 | 300 | } |
| 301 | 301 | } |
| 302 | - } elseif($meth==0) { |
|
| 302 | + } elseif ($meth == 0) { |
|
| 303 | 303 | $Comp = 0; // means stored without compression |
| 304 | 304 | } else { |
| 305 | - if ($Uncompress) $this->RaiseError('Unable to uncompress file "'.$NameOrIdx.'" because it is compressed with method '.$meth.'.'); |
|
| 305 | + if ($Uncompress) $this->RaiseError('Unable to uncompress file "' . $NameOrIdx . '" because it is compressed with method ' . $meth . '.'); |
|
| 306 | 306 | } |
| 307 | 307 | $this->LastReadComp = $Comp; |
| 308 | 308 | |
@@ -315,40 +315,40 @@ discard block |
||
| 315 | 315 | |
| 316 | 316 | $b = $this->_ReadData(30); |
| 317 | 317 | |
| 318 | - $x = $this->_GetHex($b,0,4); |
|
| 319 | - if ($x!=='h:04034b50') return $this->RaiseError("Signature of Local File Header #".$idx." (data section) expected but not found at position ".$this->_TxtPos(ftell($this->ArchHnd)-30)."."); |
|
| 318 | + $x = $this->_GetHex($b, 0, 4); |
|
| 319 | + if ($x !== 'h:04034b50') return $this->RaiseError("Signature of Local File Header #" . $idx . " (data section) expected but not found at position " . $this->_TxtPos(ftell($this->ArchHnd) - 30) . "."); |
|
| 320 | 320 | |
| 321 | 321 | $x = array(); |
| 322 | - $x['vers'] = $this->_GetDec($b,4,2); |
|
| 323 | - $x['purp'] = $this->_GetBin($b,6,2); |
|
| 324 | - $x['meth'] = $this->_GetDec($b,8,2); |
|
| 325 | - $x['time'] = $this->_GetDec($b,10,2); |
|
| 326 | - $x['date'] = $this->_GetDec($b,12,2); |
|
| 327 | - $x['crc32'] = $this->_GetDec($b,14,4); |
|
| 328 | - $x['l_data_c'] = $this->_GetDec($b,18,4); |
|
| 329 | - $x['l_data_u'] = $this->_GetDec($b,22,4); |
|
| 330 | - $x['l_name'] = $this->_GetDec($b,26,2); |
|
| 331 | - $x['l_fields'] = $this->_GetDec($b,28,2); |
|
| 322 | + $x['vers'] = $this->_GetDec($b, 4, 2); |
|
| 323 | + $x['purp'] = $this->_GetBin($b, 6, 2); |
|
| 324 | + $x['meth'] = $this->_GetDec($b, 8, 2); |
|
| 325 | + $x['time'] = $this->_GetDec($b, 10, 2); |
|
| 326 | + $x['date'] = $this->_GetDec($b, 12, 2); |
|
| 327 | + $x['crc32'] = $this->_GetDec($b, 14, 4); |
|
| 328 | + $x['l_data_c'] = $this->_GetDec($b, 18, 4); |
|
| 329 | + $x['l_data_u'] = $this->_GetDec($b, 22, 4); |
|
| 330 | + $x['l_name'] = $this->_GetDec($b, 26, 2); |
|
| 331 | + $x['l_fields'] = $this->_GetDec($b, 28, 2); |
|
| 332 | 332 | $x['v_name'] = $this->_ReadData($x['l_name']); |
| 333 | 333 | $x['v_fields'] = $this->_ReadData($x['l_fields']); |
| 334 | 334 | |
| 335 | - $x['bin'] = $b.$x['v_name'].$x['v_fields']; |
|
| 335 | + $x['bin'] = $b . $x['v_name'] . $x['v_fields']; |
|
| 336 | 336 | |
| 337 | 337 | // Read Data |
| 338 | 338 | if (isset($this->CdFileLst[$idx])) { |
| 339 | 339 | $len_cd = $this->CdFileLst[$idx]['l_data_c']; |
| 340 | - if ($x['l_data_c']==0) { |
|
| 340 | + if ($x['l_data_c'] == 0) { |
|
| 341 | 341 | // Sometimes, the size is not specified in the local information. |
| 342 | 342 | $len = $len_cd; |
| 343 | 343 | } else { |
| 344 | 344 | $len = $x['l_data_c']; |
| 345 | - if ($len!=$len_cd) { |
|
| 345 | + if ($len != $len_cd) { |
|
| 346 | 346 | //echo "TbsZip Warning: Local information for file #".$idx." says len=".$len.", while Central Directory says len=".$len_cd."."; |
| 347 | 347 | } |
| 348 | 348 | } |
| 349 | 349 | } else { |
| 350 | 350 | $len = $x['l_data_c']; |
| 351 | - if ($len==0) $this->RaiseError("File Data #".$idx." cannt be read because no length is specified in the Local File Header and its Central Directory information has not been found."); |
|
| 351 | + if ($len == 0) $this->RaiseError("File Data #" . $idx . " cannt be read because no length is specified in the Local File Header and its Central Directory information has not been found."); |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | if ($ReadData) { |
@@ -358,13 +358,13 @@ discard block |
||
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | // Description information |
| 361 | - $desc_ok = ($x['purp'][2+3]=='1'); |
|
| 361 | + $desc_ok = ($x['purp'][2 + 3] == '1'); |
|
| 362 | 362 | if ($desc_ok) { |
| 363 | 363 | $b = $this->_ReadData(12); |
| 364 | - $s = $this->_GetHex($b,0,4); |
|
| 364 | + $s = $this->_GetHex($b, 0, 4); |
|
| 365 | 365 | $d = 0; |
| 366 | 366 | // the specification says the signature may or may not be present |
| 367 | - if ($s=='h:08074b50') { |
|
| 367 | + if ($s == 'h:08074b50') { |
|
| 368 | 368 | $b .= $this->_ReadData(4); |
| 369 | 369 | $d = 4; |
| 370 | 370 | $x['desc_bin'] = $b; |
@@ -372,9 +372,9 @@ discard block |
||
| 372 | 372 | } else { |
| 373 | 373 | $x['desc_bin'] = $b; |
| 374 | 374 | } |
| 375 | - $x['desc_crc32'] = $this->_GetDec($b,0+$d,4); |
|
| 376 | - $x['desc_l_data_c'] = $this->_GetDec($b,4+$d,4); |
|
| 377 | - $x['desc_l_data_u'] = $this->_GetDec($b,8+$d,4); |
|
| 375 | + $x['desc_crc32'] = $this->_GetDec($b, 0 + $d, 4); |
|
| 376 | + $x['desc_l_data_c'] = $this->_GetDec($b, 4 + $d, 4); |
|
| 377 | + $x['desc_l_data_u'] = $this->_GetDec($b, 8 + $d, 4); |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | // Save file info without the data |
@@ -389,15 +389,15 @@ discard block |
||
| 389 | 389 | |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - function FileReplace($NameOrIdx, $Data, $DataType=self::TBSZIP_STRING, $Compress=true) { |
|
| 392 | + function FileReplace($NameOrIdx, $Data, $DataType = self::TBSZIP_STRING, $Compress = true) { |
|
| 393 | 393 | // Store replacement information. |
| 394 | 394 | |
| 395 | 395 | $idx = $this->FileGetIdx($NameOrIdx); |
| 396 | - if ($idx===false) return $this->RaiseError('File "'.$NameOrIdx.'" is not found in the Central Directory.'); |
|
| 396 | + if ($idx === false) return $this->RaiseError('File "' . $NameOrIdx . '" is not found in the Central Directory.'); |
|
| 397 | 397 | |
| 398 | 398 | $pos = $this->CdFileLst[$idx]['p_loc']; |
| 399 | 399 | |
| 400 | - if ($Data===false) { |
|
| 400 | + if ($Data === false) { |
|
| 401 | 401 | // file to delete |
| 402 | 402 | $this->ReplInfo[$idx] = false; |
| 403 | 403 | $Result = true; |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | // file to replace |
| 406 | 406 | $Diff = - $this->CdFileLst[$idx]['l_data_c']; |
| 407 | 407 | $Ref = $this->_DataCreateNewRef($Data, $DataType, $Compress, $Diff, $NameOrIdx); |
| 408 | - if ($Ref===false) return false; |
|
| 408 | + if ($Ref === false) return false; |
|
| 409 | 409 | $this->ReplInfo[$idx] = $Ref; |
| 410 | 410 | $Result = $Ref['res']; |
| 411 | 411 | } |
@@ -423,15 +423,15 @@ discard block |
||
| 423 | 423 | function FileGetState($NameOrIdx) { |
| 424 | 424 | |
| 425 | 425 | $idx = $this->FileGetIdx($NameOrIdx); |
| 426 | - if ($idx===false) { |
|
| 426 | + if ($idx === false) { |
|
| 427 | 427 | $idx = $this->FileGetIdxAdd($NameOrIdx); |
| 428 | - if ($idx===false) { |
|
| 428 | + if ($idx === false) { |
|
| 429 | 429 | return false; |
| 430 | 430 | } else { |
| 431 | 431 | return 'a'; |
| 432 | 432 | } |
| 433 | 433 | } elseif (isset($this->ReplInfo[$idx])) { |
| 434 | - if ($this->ReplInfo[$idx]===false) { |
|
| 434 | + if ($this->ReplInfo[$idx] === false) { |
|
| 435 | 435 | return 'd'; |
| 436 | 436 | } else { |
| 437 | 437 | return 'm'; |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - function FileCancelModif($NameOrIdx, $ReplacedAndDeleted=true) { |
|
| 445 | + function FileCancelModif($NameOrIdx, $ReplacedAndDeleted = true) { |
|
| 446 | 446 | // cancel added, modified or deleted modifications on a file in the archive |
| 447 | 447 | // return the number of cancels |
| 448 | 448 | |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | if ($ReplacedAndDeleted) { |
| 452 | 452 | // replaced or deleted files |
| 453 | 453 | $idx = $this->FileGetIdx($NameOrIdx); |
| 454 | - if ($idx!==false) { |
|
| 454 | + if ($idx !== false) { |
|
| 455 | 455 | if (isset($this->ReplInfo[$idx])) { |
| 456 | 456 | $pos = $this->CdFileLst[$idx]['p_loc']; |
| 457 | 457 | unset($this->ReplByPos[$pos]); |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | |
| 464 | 464 | // added files |
| 465 | 465 | $idx = $this->FileGetIdxAdd($NameOrIdx); |
| 466 | - if ($idx!==false) { |
|
| 466 | + if ($idx !== false) { |
|
| 467 | 467 | unset($this->AddInfo[$idx]); |
| 468 | 468 | $nbr++; |
| 469 | 469 | } |
@@ -472,10 +472,10 @@ discard block |
||
| 472 | 472 | |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | - function Flush($Render=self::TBSZIP_DOWNLOAD, $File='', $ContentType='') { |
|
| 475 | + function Flush($Render = self::TBSZIP_DOWNLOAD, $File = '', $ContentType = '') { |
|
| 476 | 476 | |
| 477 | - if ( ($File!=='') && ($this->ArchFile===$File) && ($Render==self::TBSZIP_FILE) ) { |
|
| 478 | - $this->RaiseError('Method Flush() cannot overwrite the current opened archive: \''.$File.'\''); // this makes corrupted zip archives without PHP error. |
|
| 477 | + if (($File !== '') && ($this->ArchFile === $File) && ($Render == self::TBSZIP_FILE)) { |
|
| 478 | + $this->RaiseError('Method Flush() cannot overwrite the current opened archive: \'' . $File . '\''); // this makes corrupted zip archives without PHP error. |
|
| 479 | 479 | return false; |
| 480 | 480 | } |
| 481 | 481 | |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | $this->OutputFromArch($ArchPos, $ReplPos); |
| 499 | 499 | // get current file information |
| 500 | 500 | if (!isset($this->VisFileLst[$ReplIdx])) $this->_ReadFile($ReplIdx, false); |
| 501 | - $FileInfo =& $this->VisFileLst[$ReplIdx]; |
|
| 501 | + $FileInfo = & $this->VisFileLst[$ReplIdx]; |
|
| 502 | 502 | $b1 = $FileInfo['bin']; |
| 503 | 503 | if (isset($FileInfo['desc_bin'])) { |
| 504 | 504 | $b2 = $FileInfo['desc_bin']; |
@@ -507,8 +507,8 @@ discard block |
||
| 507 | 507 | } |
| 508 | 508 | $info_old_len = strlen($b1) + $this->CdFileLst[$ReplIdx]['l_data_c'] + strlen($b2); // $FileInfo['l_data_c'] may have a 0 value in some archives |
| 509 | 509 | // get replacement information |
| 510 | - $ReplInfo =& $this->ReplInfo[$ReplIdx]; |
|
| 511 | - if ($ReplInfo===false) { |
|
| 510 | + $ReplInfo = & $this->ReplInfo[$ReplIdx]; |
|
| 511 | + if ($ReplInfo === false) { |
|
| 512 | 512 | // The file is to be deleted |
| 513 | 513 | $Delta = $Delta - $info_old_len; // headers and footers are also deleted |
| 514 | 514 | $DelLst[$ReplIdx] = true; |
@@ -520,22 +520,22 @@ discard block |
||
| 520 | 520 | $this->_PutDec($b1, $ReplInfo['crc32'], 14, 4); // crc32 |
| 521 | 521 | $this->_PutDec($b1, $ReplInfo['len_c'], 18, 4); // l_data_c |
| 522 | 522 | $this->_PutDec($b1, $ReplInfo['len_u'], 22, 4); // l_data_u |
| 523 | - if ($ReplInfo['meth']!==false) $this->_PutDec($b1, $ReplInfo['meth'], 8, 2); // meth |
|
| 523 | + if ($ReplInfo['meth'] !== false) $this->_PutDec($b1, $ReplInfo['meth'], 8, 2); // meth |
|
| 524 | 524 | // prepare the bottom description if the zipped file, if any |
| 525 | - if ($b2!=='') { |
|
| 526 | - $d = (strlen($b2)==16) ? 4 : 0; // offset because of the signature if any |
|
| 527 | - $this->_PutDec($b2, $ReplInfo['crc32'], $d+0, 4); // crc32 |
|
| 528 | - $this->_PutDec($b2, $ReplInfo['len_c'], $d+4, 4); // l_data_c |
|
| 529 | - $this->_PutDec($b2, $ReplInfo['len_u'], $d+8, 4); // l_data_u |
|
| 525 | + if ($b2 !== '') { |
|
| 526 | + $d = (strlen($b2) == 16) ? 4 : 0; // offset because of the signature if any |
|
| 527 | + $this->_PutDec($b2, $ReplInfo['crc32'], $d + 0, 4); // crc32 |
|
| 528 | + $this->_PutDec($b2, $ReplInfo['len_c'], $d + 4, 4); // l_data_c |
|
| 529 | + $this->_PutDec($b2, $ReplInfo['len_u'], $d + 8, 4); // l_data_u |
|
| 530 | 530 | } |
| 531 | 531 | // output data |
| 532 | - $this->OutputFromString($b1.$ReplInfo['data'].$b2); |
|
| 532 | + $this->OutputFromString($b1 . $ReplInfo['data'] . $b2); |
|
| 533 | 533 | unset($ReplInfo['data']); // save PHP memory |
| 534 | 534 | $Delta = $Delta + $ReplInfo['diff'] + $ReplInfo['len_c']; |
| 535 | 535 | } |
| 536 | 536 | // Update the delta of positions for zipped files which are physically after the currently replaced one |
| 537 | - for ($i=0;$i<$this->CdFileNbr;$i++) { |
|
| 538 | - if ($this->CdFileLst[$i]['p_loc']>$ReplPos) { |
|
| 537 | + for ($i = 0; $i < $this->CdFileNbr; $i++) { |
|
| 538 | + if ($this->CdFileLst[$i]['p_loc'] > $ReplPos) { |
|
| 539 | 539 | $FicNewPos[$i] = $this->CdFileLst[$i]['p_loc'] + $Delta; |
| 540 | 540 | } |
| 541 | 541 | } |
@@ -544,13 +544,13 @@ discard block |
||
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | // Ouput all the zipped files that remain before the Central Directory listing |
| 547 | - if ($this->ArchHnd!==false) $this->OutputFromArch($ArchPos, $this->CdPos); // ArchHnd is false if CreateNew() has been called |
|
| 547 | + if ($this->ArchHnd !== false) $this->OutputFromArch($ArchPos, $this->CdPos); // ArchHnd is false if CreateNew() has been called |
|
| 548 | 548 | $ArchPos = $this->CdPos; |
| 549 | 549 | |
| 550 | 550 | // Output file to add |
| 551 | 551 | $AddNbr = count($this->AddInfo); |
| 552 | 552 | $AddDataLen = 0; // total len of added data (inlcuding file headers) |
| 553 | - if ($AddNbr>0) { |
|
| 553 | + if ($AddNbr > 0) { |
|
| 554 | 554 | $AddPos = $ArchPos + $Delta; // position of the start |
| 555 | 555 | $AddLst = array_keys($this->AddInfo); |
| 556 | 556 | foreach ($AddLst as $idx) { |
@@ -563,32 +563,32 @@ discard block |
||
| 563 | 563 | // Modifiy file information in the Central Directory for replaced files |
| 564 | 564 | $b2 = ''; |
| 565 | 565 | $old_cd_len = 0; |
| 566 | - for ($i=0;$i<$this->CdFileNbr;$i++) { |
|
| 566 | + for ($i = 0; $i < $this->CdFileNbr; $i++) { |
|
| 567 | 567 | $b1 = $this->CdFileLst[$i]['bin']; |
| 568 | 568 | $old_cd_len += strlen($b1); |
| 569 | 569 | if (!isset($DelLst[$i])) { |
| 570 | - if (isset($FicNewPos[$i])) $this->_PutDec($b1, $FicNewPos[$i], 42, 4); // p_loc |
|
| 570 | + if (isset($FicNewPos[$i])) $this->_PutDec($b1, $FicNewPos[$i], 42, 4); // p_loc |
|
| 571 | 571 | if (isset($this->ReplInfo[$i])) { |
| 572 | - $ReplInfo =& $this->ReplInfo[$i]; |
|
| 572 | + $ReplInfo = & $this->ReplInfo[$i]; |
|
| 573 | 573 | $this->_PutDec($b1, $time, 12, 2); // time |
| 574 | 574 | $this->_PutDec($b1, $date, 14, 2); // date |
| 575 | 575 | $this->_PutDec($b1, $ReplInfo['crc32'], 16, 4); // crc32 |
| 576 | 576 | $this->_PutDec($b1, $ReplInfo['len_c'], 20, 4); // l_data_c |
| 577 | 577 | $this->_PutDec($b1, $ReplInfo['len_u'], 24, 4); // l_data_u |
| 578 | - if ($ReplInfo['meth']!==false) $this->_PutDec($b1, $ReplInfo['meth'], 10, 2); // meth |
|
| 578 | + if ($ReplInfo['meth'] !== false) $this->_PutDec($b1, $ReplInfo['meth'], 10, 2); // meth |
|
| 579 | 579 | } |
| 580 | 580 | $b2 .= $b1; |
| 581 | 581 | } |
| 582 | 582 | } |
| 583 | 583 | $this->OutputFromString($b2); |
| 584 | 584 | $ArchPos += $old_cd_len; |
| 585 | - $DeltaCdLen = $DeltaCdLen + strlen($b2) - $old_cd_len; |
|
| 585 | + $DeltaCdLen = $DeltaCdLen + strlen($b2) - $old_cd_len; |
|
| 586 | 586 | |
| 587 | 587 | // Output until "end of central directory record" |
| 588 | - if ($this->ArchHnd!==false) $this->OutputFromArch($ArchPos, $this->CdEndPos); // ArchHnd is false if CreateNew() has been called |
|
| 588 | + if ($this->ArchHnd !== false) $this->OutputFromArch($ArchPos, $this->CdEndPos); // ArchHnd is false if CreateNew() has been called |
|
| 589 | 589 | |
| 590 | 590 | // Output file information of the Central Directory for added files |
| 591 | - if ($AddNbr>0) { |
|
| 591 | + if ($AddNbr > 0) { |
|
| 592 | 592 | $b2 = ''; |
| 593 | 593 | foreach ($AddLst as $idx) { |
| 594 | 594 | $b2 .= $this->AddInfo[$idx]['bin']; |
@@ -600,10 +600,10 @@ discard block |
||
| 600 | 600 | // Output "end of central directory record" |
| 601 | 601 | $b2 = $this->CdInfo['bin']; |
| 602 | 602 | $DelNbr = count($DelLst); |
| 603 | - if ( ($AddNbr>0) or ($DelNbr>0) ) { |
|
| 603 | + if (($AddNbr > 0) or ($DelNbr > 0)) { |
|
| 604 | 604 | // total number of entries in the central directory on this disk |
| 605 | 605 | $n = $this->_GetDec($b2, 8, 2); |
| 606 | - $this->_PutDec($b2, $n + $AddNbr - $DelNbr, 8, 2); |
|
| 606 | + $this->_PutDec($b2, $n + $AddNbr - $DelNbr, 8, 2); |
|
| 607 | 607 | // total number of entries in the central directory |
| 608 | 608 | $n = $this->_GetDec($b2, 10, 2); |
| 609 | 609 | $this->_PutDec($b2, $n + $AddNbr - $DelNbr, 10, 2); |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | $this->_PutDec($b2, $n + $DeltaCdLen, 12, 4); |
| 613 | 613 | $Delta = $Delta + $AddDataLen; |
| 614 | 614 | } |
| 615 | - $this->_PutDec($b2, $this->CdPos+$Delta , 16, 4); // p_cd (offset of start of central directory with respect to the starting disk number) |
|
| 615 | + $this->_PutDec($b2, $this->CdPos + $Delta, 16, 4); // p_cd (offset of start of central directory with respect to the starting disk number) |
|
| 616 | 616 | $this->OutputFromString($b2); |
| 617 | 617 | |
| 618 | 618 | $this->OutputClose(); |
@@ -627,32 +627,32 @@ discard block |
||
| 627 | 627 | |
| 628 | 628 | function OutputOpen($Render, $File, $ContentType) { |
| 629 | 629 | |
| 630 | - if (($Render & self::TBSZIP_FILE)==self::TBSZIP_FILE) { |
|
| 630 | + if (($Render & self::TBSZIP_FILE) == self::TBSZIP_FILE) { |
|
| 631 | 631 | $this->OutputMode = self::TBSZIP_FILE; |
| 632 | - if (''.$File=='') $File = basename($this->ArchFile).'.zip'; |
|
| 632 | + if ('' . $File == '') $File = basename($this->ArchFile) . '.zip'; |
|
| 633 | 633 | $this->OutputHandle = @fopen($File, 'w'); |
| 634 | - if ($this->OutputHandle===false) { |
|
| 635 | - return $this->RaiseError('Method Flush() cannot overwrite the target file \''.$File.'\'. This may not be a valid file path or the file may be locked by another process or because of a denied permission.'); |
|
| 634 | + if ($this->OutputHandle === false) { |
|
| 635 | + return $this->RaiseError('Method Flush() cannot overwrite the target file \'' . $File . '\'. This may not be a valid file path or the file may be locked by another process or because of a denied permission.'); |
|
| 636 | 636 | } |
| 637 | - } elseif (($Render & self::TBSZIP_STRING)==self::TBSZIP_STRING) { |
|
| 637 | + } elseif (($Render & self::TBSZIP_STRING) == self::TBSZIP_STRING) { |
|
| 638 | 638 | $this->OutputMode = self::TBSZIP_STRING; |
| 639 | 639 | $this->OutputSrc = ''; |
| 640 | - } elseif (($Render & self::TBSZIP_DOWNLOAD)==self::TBSZIP_DOWNLOAD) { |
|
| 640 | + } elseif (($Render & self::TBSZIP_DOWNLOAD) == self::TBSZIP_DOWNLOAD) { |
|
| 641 | 641 | $this->OutputMode = self::TBSZIP_DOWNLOAD; |
| 642 | 642 | // Output the file |
| 643 | - if (''.$File=='') $File = basename($this->ArchFile); |
|
| 644 | - if (($Render & self::TBSZIP_NOHEADER)==self::TBSZIP_NOHEADER) { |
|
| 643 | + if ('' . $File == '') $File = basename($this->ArchFile); |
|
| 644 | + if (($Render & self::TBSZIP_NOHEADER) == self::TBSZIP_NOHEADER) { |
|
| 645 | 645 | } else { |
| 646 | - header ('Pragma: no-cache'); |
|
| 647 | - if ($ContentType!='') header ('Content-Type: '.$ContentType); |
|
| 648 | - header('Content-Disposition: attachment; filename="'.$File.'"'); |
|
| 646 | + header('Pragma: no-cache'); |
|
| 647 | + if ($ContentType != '') header('Content-Type: ' . $ContentType); |
|
| 648 | + header('Content-Disposition: attachment; filename="' . $File . '"'); |
|
| 649 | 649 | header('Expires: 0'); |
| 650 | 650 | header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
| 651 | 651 | header('Cache-Control: public'); |
| 652 | 652 | header('Content-Description: File Transfer'); |
| 653 | 653 | header('Content-Transfer-Encoding: binary'); |
| 654 | 654 | $Len = $this->_EstimateNewArchSize(); |
| 655 | - if ($Len!==false) header('Content-Length: '.$Len); |
|
| 655 | + if ($Len !== false) header('Content-Length: ' . $Len); |
|
| 656 | 656 | } |
| 657 | 657 | } else { |
| 658 | 658 | return $this->RaiseError('Method Flush is called with a unsupported render option.'); |
@@ -664,10 +664,10 @@ discard block |
||
| 664 | 664 | |
| 665 | 665 | function OutputFromArch($pos, $pos_stop) { |
| 666 | 666 | $len = $pos_stop - $pos; |
| 667 | - if ($len<0) return; |
|
| 667 | + if ($len < 0) return; |
|
| 668 | 668 | $this->_MoveTo($pos); |
| 669 | 669 | $block = 1024; |
| 670 | - while ($len>0) { |
|
| 670 | + while ($len > 0) { |
|
| 671 | 671 | $l = min($len, $block); |
| 672 | 672 | $x = $this->_ReadData($l); |
| 673 | 673 | $this->OutputFromString($x); |
@@ -677,9 +677,9 @@ discard block |
||
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | function OutputFromString($data) { |
| 680 | - if ($this->OutputMode===self::TBSZIP_DOWNLOAD) { |
|
| 680 | + if ($this->OutputMode === self::TBSZIP_DOWNLOAD) { |
|
| 681 | 681 | echo $data; // donwload |
| 682 | - } elseif ($this->OutputMode===self::TBSZIP_STRING) { |
|
| 682 | + } elseif ($this->OutputMode === self::TBSZIP_STRING) { |
|
| 683 | 683 | $this->OutputSrc .= $data; // to string |
| 684 | 684 | } elseif (self::TBSZIP_FILE) { |
| 685 | 685 | fwrite($this->OutputHandle, $data); // to file |
@@ -687,7 +687,7 @@ discard block |
||
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | function OutputClose() { |
| 690 | - if ( ($this->OutputMode===self::TBSZIP_FILE) && ($this->OutputHandle!==false) ) { |
|
| 690 | + if (($this->OutputMode === self::TBSZIP_FILE) && ($this->OutputHandle !== false)) { |
|
| 691 | 691 | fclose($this->OutputHandle); |
| 692 | 692 | $this->OutputHandle = false; |
| 693 | 693 | } |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | function _ReadData($len) { |
| 705 | - if ($len>0) { |
|
| 705 | + if ($len > 0) { |
|
| 706 | 706 | $x = fread($this->ArchHnd, $len); |
| 707 | 707 | return $x; |
| 708 | 708 | } else { |
@@ -717,32 +717,32 @@ discard block |
||
| 717 | 717 | function _GetDec($txt, $pos, $len) { |
| 718 | 718 | $x = substr($txt, $pos, $len); |
| 719 | 719 | $z = 0; |
| 720 | - for ($i=0;$i<$len;$i++) { |
|
| 720 | + for ($i = 0; $i < $len; $i++) { |
|
| 721 | 721 | $asc = ord($x[$i]); |
| 722 | - if ($asc>0) $z = $z + $asc*pow(256,$i); |
|
| 722 | + if ($asc > 0) $z = $z + $asc * pow(256, $i); |
|
| 723 | 723 | } |
| 724 | 724 | return $z; |
| 725 | 725 | } |
| 726 | 726 | |
| 727 | 727 | function _GetHex($txt, $pos, $len) { |
| 728 | 728 | $x = substr($txt, $pos, $len); |
| 729 | - return 'h:'.bin2hex(strrev($x)); |
|
| 729 | + return 'h:' . bin2hex(strrev($x)); |
|
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | function _GetBin($txt, $pos, $len) { |
| 733 | 733 | $x = substr($txt, $pos, $len); |
| 734 | 734 | $z = ''; |
| 735 | - for ($i=0;$i<$len;$i++) { |
|
| 735 | + for ($i = 0; $i < $len; $i++) { |
|
| 736 | 736 | $asc = ord($x[$i]); |
| 737 | 737 | if (isset($x[$i])) { |
| 738 | - for ($j=0;$j<8;$j++) { |
|
| 739 | - $z .= ($asc & pow(2,$j)) ? '1' : '0'; |
|
| 738 | + for ($j = 0; $j < 8; $j++) { |
|
| 739 | + $z .= ($asc & pow(2, $j)) ? '1' : '0'; |
|
| 740 | 740 | } |
| 741 | 741 | } else { |
| 742 | 742 | $z .= '00000000'; |
| 743 | 743 | } |
| 744 | 744 | } |
| 745 | - return 'b:'.$z; |
|
| 745 | + return 'b:' . $z; |
|
| 746 | 746 | } |
| 747 | 747 | |
| 748 | 748 | // ---------------- |
@@ -751,17 +751,17 @@ discard block |
||
| 751 | 751 | |
| 752 | 752 | function _PutDec(&$txt, $val, $pos, $len) { |
| 753 | 753 | $x = ''; |
| 754 | - for ($i=0;$i<$len;$i++) { |
|
| 755 | - if ($val==0) { |
|
| 754 | + for ($i = 0; $i < $len; $i++) { |
|
| 755 | + if ($val == 0) { |
|
| 756 | 756 | $z = 0; |
| 757 | 757 | } else { |
| 758 | 758 | $z = intval($val % 256); |
| 759 | - if (($val<0) && ($z!=0)) { // ($z!=0) is very important, example: val=-420085702 |
|
| 759 | + if (($val < 0) && ($z != 0)) { // ($z!=0) is very important, example: val=-420085702 |
|
| 760 | 760 | // special opration for negative value. If the number id too big, PHP stores it into a signed integer. For example: crc32('coucou') => -256185401 instead of 4038781895. NegVal = BigVal - (MaxVal+1) = BigVal - 256^4 |
| 761 | - $val = ($val - $z)/256 -1; |
|
| 761 | + $val = ($val - $z) / 256 - 1; |
|
| 762 | 762 | $z = 256 + $z; |
| 763 | 763 | } else { |
| 764 | - $val = ($val - $z)/256; |
|
| 764 | + $val = ($val - $z) / 256; |
|
| 765 | 765 | } |
| 766 | 766 | } |
| 767 | 767 | $x .= chr($z); |
@@ -771,30 +771,30 @@ discard block |
||
| 771 | 771 | |
| 772 | 772 | function _MsDos_Date($Timestamp = false) { |
| 773 | 773 | // convert a date-time timstamp into the MS-Dos format |
| 774 | - $d = ($Timestamp===false) ? getdate() : getdate($Timestamp); |
|
| 775 | - return (($d['year']-1980)*512) + ($d['mon']*32) + $d['mday']; |
|
| 774 | + $d = ($Timestamp === false) ? getdate() : getdate($Timestamp); |
|
| 775 | + return (($d['year'] - 1980) * 512) + ($d['mon'] * 32) + $d['mday']; |
|
| 776 | 776 | } |
| 777 | 777 | function _MsDos_Time($Timestamp = false) { |
| 778 | 778 | // convert a date-time timstamp into the MS-Dos format |
| 779 | - $d = ($Timestamp===false) ? getdate() : getdate($Timestamp); |
|
| 780 | - return ($d['hours']*2048) + ($d['minutes']*32) + intval($d['seconds']/2); // seconds are rounded to an even number in order to save 1 bit |
|
| 779 | + $d = ($Timestamp === false) ? getdate() : getdate($Timestamp); |
|
| 780 | + return ($d['hours'] * 2048) + ($d['minutes'] * 32) + intval($d['seconds'] / 2); // seconds are rounded to an even number in order to save 1 bit |
|
| 781 | 781 | } |
| 782 | 782 | |
| 783 | 783 | function _MsDos_Debug($date, $time) { |
| 784 | 784 | // Display the formated date and time. Just for debug purpose. |
| 785 | 785 | // date end time are encoded on 16 bits (2 bytes) : date = yyyyyyymmmmddddd , time = hhhhhnnnnnssssss |
| 786 | - $y = ($date & 65024)/512 + 1980; |
|
| 787 | - $m = ($date & 480)/32; |
|
| 786 | + $y = ($date & 65024) / 512 + 1980; |
|
| 787 | + $m = ($date & 480) / 32; |
|
| 788 | 788 | $d = ($date & 31); |
| 789 | - $h = ($time & 63488)/2048; |
|
| 790 | - $i = ($time & 1984)/32; |
|
| 789 | + $h = ($time & 63488) / 2048; |
|
| 790 | + $i = ($time & 1984) / 32; |
|
| 791 | 791 | $s = ($time & 31) * 2; // seconds have been rounded to an even number in order to save 1 bit |
| 792 | - return $y.'-'.str_pad($m,2,'0',STR_PAD_LEFT).'-'.str_pad($d,2,'0',STR_PAD_LEFT).' '.str_pad($h,2,'0',STR_PAD_LEFT).':'.str_pad($i,2,'0',STR_PAD_LEFT).':'.str_pad($s,2,'0',STR_PAD_LEFT); |
|
| 792 | + return $y . '-' . str_pad($m, 2, '0', STR_PAD_LEFT) . '-' . str_pad($d, 2, '0', STR_PAD_LEFT) . ' ' . str_pad($h, 2, '0', STR_PAD_LEFT) . ':' . str_pad($i, 2, '0', STR_PAD_LEFT) . ':' . str_pad($s, 2, '0', STR_PAD_LEFT); |
|
| 793 | 793 | } |
| 794 | 794 | |
| 795 | 795 | function _TxtPos($pos) { |
| 796 | 796 | // Return the human readable position in both decimal and hexa |
| 797 | - return $pos." (h:".dechex($pos).")"; |
|
| 797 | + return $pos . " (h:" . dechex($pos) . ")"; |
|
| 798 | 798 | } |
| 799 | 799 | |
| 800 | 800 | /** |
@@ -807,15 +807,15 @@ discard block |
||
| 807 | 807 | $nbr = 1; |
| 808 | 808 | $p = false; |
| 809 | 809 | $pos = ftell($this->ArchHnd) - 4 - 256; |
| 810 | - while ( ($p===false) && ($nbr<256) ) { |
|
| 811 | - if ($pos<=0) { |
|
| 810 | + while (($p === false) && ($nbr < 256)) { |
|
| 811 | + if ($pos <= 0) { |
|
| 812 | 812 | $pos = 0; |
| 813 | 813 | $nbr = 256; // in order to make this a last check |
| 814 | 814 | } |
| 815 | 815 | $this->_MoveTo($pos); |
| 816 | 816 | $x = $this->_ReadData(256); |
| 817 | 817 | $p = strpos($x, $cd_info); |
| 818 | - if ($p===false) { |
|
| 818 | + if ($p === false) { |
|
| 819 | 819 | $nbr++; |
| 820 | 820 | $pos = $pos - 256 - 256; |
| 821 | 821 | } else { |
@@ -827,7 +827,7 @@ discard block |
||
| 827 | 827 | |
| 828 | 828 | function _DataOuputAddedFile($Idx, $PosLoc) { |
| 829 | 829 | |
| 830 | - $Ref =& $this->AddInfo[$Idx]; |
|
| 830 | + $Ref = & $this->AddInfo[$Idx]; |
|
| 831 | 831 | $this->_DataPrepare($Ref); // get data from external file if necessary |
| 832 | 832 | |
| 833 | 833 | // Other info |
@@ -835,46 +835,46 @@ discard block |
||
| 835 | 835 | $date = $this->_MsDos_Date($file_time); |
| 836 | 836 | $time = $this->_MsDos_Time($file_time); |
| 837 | 837 | $len_n = strlen($Ref['name']); |
| 838 | - $purp = 2048 ; // purpose // +8 to indicates that there is an extended local header |
|
| 838 | + $purp = 2048; // purpose // +8 to indicates that there is an extended local header |
|
| 839 | 839 | |
| 840 | 840 | // Header for file in the data section |
| 841 | - $b = 'PK'.chr(03).chr(04).str_repeat(' ',26); // signature |
|
| 842 | - $this->_PutDec($b,20,4,2); //vers = 20 |
|
| 843 | - $this->_PutDec($b,$purp,6,2); // purp |
|
| 844 | - $this->_PutDec($b,$Ref['meth'],8,2); // meth |
|
| 845 | - $this->_PutDec($b,$time,10,2); // time |
|
| 846 | - $this->_PutDec($b,$date,12,2); // date |
|
| 847 | - $this->_PutDec($b,$Ref['crc32'],14,4); // crc32 |
|
| 848 | - $this->_PutDec($b,$Ref['len_c'],18,4); // l_data_c |
|
| 849 | - $this->_PutDec($b,$Ref['len_u'],22,4); // l_data_u |
|
| 850 | - $this->_PutDec($b,$len_n,26,2); // l_name |
|
| 851 | - $this->_PutDec($b,0,28,2); // l_fields |
|
| 841 | + $b = 'PK' . chr(03) . chr(04) . str_repeat(' ', 26); // signature |
|
| 842 | + $this->_PutDec($b, 20, 4, 2); //vers = 20 |
|
| 843 | + $this->_PutDec($b, $purp, 6, 2); // purp |
|
| 844 | + $this->_PutDec($b, $Ref['meth'], 8, 2); // meth |
|
| 845 | + $this->_PutDec($b, $time, 10, 2); // time |
|
| 846 | + $this->_PutDec($b, $date, 12, 2); // date |
|
| 847 | + $this->_PutDec($b, $Ref['crc32'], 14, 4); // crc32 |
|
| 848 | + $this->_PutDec($b, $Ref['len_c'], 18, 4); // l_data_c |
|
| 849 | + $this->_PutDec($b, $Ref['len_u'], 22, 4); // l_data_u |
|
| 850 | + $this->_PutDec($b, $len_n, 26, 2); // l_name |
|
| 851 | + $this->_PutDec($b, 0, 28, 2); // l_fields |
|
| 852 | 852 | $b .= $Ref['name']; // name |
| 853 | 853 | $b .= ''; // fields |
| 854 | 854 | |
| 855 | 855 | // Output the data |
| 856 | - $this->OutputFromString($b.$Ref['data']); |
|
| 856 | + $this->OutputFromString($b . $Ref['data']); |
|
| 857 | 857 | $OutputLen = strlen($b) + $Ref['len_c']; // new position of the cursor |
| 858 | 858 | unset($Ref['data']); // save PHP memory |
| 859 | 859 | |
| 860 | 860 | // Information for file in the Central Directory |
| 861 | - $b = 'PK'.chr(01).chr(02).str_repeat(' ',42); // signature |
|
| 862 | - $this->_PutDec($b,20,4,2); // vers_used = 20 |
|
| 863 | - $this->_PutDec($b,20,6,2); // vers_necess = 20 |
|
| 864 | - $this->_PutDec($b,$purp,8,2); // purp |
|
| 865 | - $this->_PutDec($b,$Ref['meth'],10,2); // meth |
|
| 866 | - $this->_PutDec($b,$time,12,2); // time |
|
| 867 | - $this->_PutDec($b,$date,14,2); // date |
|
| 868 | - $this->_PutDec($b,$Ref['crc32'],16,4); // crc32 |
|
| 869 | - $this->_PutDec($b,$Ref['len_c'],20,4); // l_data_c |
|
| 870 | - $this->_PutDec($b,$Ref['len_u'],24,4); // l_data_u |
|
| 871 | - $this->_PutDec($b,$len_n,28,2); // l_name |
|
| 872 | - $this->_PutDec($b,0,30,2); // l_fields |
|
| 873 | - $this->_PutDec($b,0,32,2); // l_comm |
|
| 874 | - $this->_PutDec($b,0,34,2); // disk_num |
|
| 875 | - $this->_PutDec($b,0,36,2); // int_file_att |
|
| 876 | - $this->_PutDec($b,0,38,4); // ext_file_att |
|
| 877 | - $this->_PutDec($b,$PosLoc,42,4); // p_loc |
|
| 861 | + $b = 'PK' . chr(01) . chr(02) . str_repeat(' ', 42); // signature |
|
| 862 | + $this->_PutDec($b, 20, 4, 2); // vers_used = 20 |
|
| 863 | + $this->_PutDec($b, 20, 6, 2); // vers_necess = 20 |
|
| 864 | + $this->_PutDec($b, $purp, 8, 2); // purp |
|
| 865 | + $this->_PutDec($b, $Ref['meth'], 10, 2); // meth |
|
| 866 | + $this->_PutDec($b, $time, 12, 2); // time |
|
| 867 | + $this->_PutDec($b, $date, 14, 2); // date |
|
| 868 | + $this->_PutDec($b, $Ref['crc32'], 16, 4); // crc32 |
|
| 869 | + $this->_PutDec($b, $Ref['len_c'], 20, 4); // l_data_c |
|
| 870 | + $this->_PutDec($b, $Ref['len_u'], 24, 4); // l_data_u |
|
| 871 | + $this->_PutDec($b, $len_n, 28, 2); // l_name |
|
| 872 | + $this->_PutDec($b, 0, 30, 2); // l_fields |
|
| 873 | + $this->_PutDec($b, 0, 32, 2); // l_comm |
|
| 874 | + $this->_PutDec($b, 0, 34, 2); // disk_num |
|
| 875 | + $this->_PutDec($b, 0, 36, 2); // int_file_att |
|
| 876 | + $this->_PutDec($b, 0, 38, 4); // ext_file_att |
|
| 877 | + $this->_PutDec($b, $PosLoc, 42, 4); // p_loc |
|
| 878 | 878 | $b .= $Ref['name']; // v_name |
| 879 | 879 | $b .= ''; // v_fields |
| 880 | 880 | $b .= ''; // v_comm |
@@ -908,7 +908,7 @@ discard block |
||
| 908 | 908 | } |
| 909 | 909 | |
| 910 | 910 | // TODO support for data taken from okapi cache |
| 911 | - if ($DataType==self::TBSZIP_STRING) { |
|
| 911 | + if ($DataType == self::TBSZIP_STRING) { |
|
| 912 | 912 | $path = false; |
| 913 | 913 | if ($Compress) { |
| 914 | 914 | // we compress now in order to save PHP memory |
@@ -918,7 +918,7 @@ discard block |
||
| 918 | 918 | $len_c = strlen($Data); |
| 919 | 919 | } else { |
| 920 | 920 | $len_c = strlen($Data); |
| 921 | - if ($len_u===false) { |
|
| 921 | + if ($len_u === false) { |
|
| 922 | 922 | $len_u = $len_c; |
| 923 | 923 | $crc32 = crc32($Data); |
| 924 | 924 | } |
@@ -929,11 +929,11 @@ discard block |
||
| 929 | 929 | $fi = stat($path); |
| 930 | 930 | if ($fi !== false) { |
| 931 | 931 | $fz = $fi['size']; |
| 932 | - if ($len_u===false) $len_u = $fz; |
|
| 932 | + if ($len_u === false) $len_u = $fz; |
|
| 933 | 933 | $len_c = ($Compress) ? false : $fz; |
| 934 | 934 | $file_time = $fi['mtime']; |
| 935 | 935 | } else { |
| 936 | - return $this->RaiseError("Cannot add the file '".$path."' because it is not found."); |
|
| 936 | + return $this->RaiseError("Cannot add the file '" . $path . "' because it is not found."); |
|
| 937 | 937 | } |
| 938 | 938 | } |
| 939 | 939 | |
@@ -946,10 +946,10 @@ discard block |
||
| 946 | 946 | function _DataPrepare(&$Ref) { |
| 947 | 947 | // returns the real size of data |
| 948 | 948 | // TODO: support for data returned from okapi cache |
| 949 | - if ($Ref['path']!==false) { |
|
| 949 | + if ($Ref['path'] !== false) { |
|
| 950 | 950 | $Ref['data'] = file_get_contents($Ref['path']); |
| 951 | - if ($Ref['crc32']===false) $Ref['crc32'] = crc32($Ref['data']); |
|
| 952 | - if ($Ref['len_c']===false) { |
|
| 951 | + if ($Ref['crc32'] === false) $Ref['crc32'] = crc32($Ref['data']); |
|
| 952 | + if ($Ref['len_c'] === false) { |
|
| 953 | 953 | // means the data must be compressed |
| 954 | 954 | $Ref['data'] = gzdeflate($Ref['data']); |
| 955 | 955 | $Ref['len_c'] = strlen($Ref['data']); |
@@ -959,7 +959,7 @@ discard block |
||
| 959 | 959 | /** |
| 960 | 960 | * Return the size of the new archive, or false if it cannot be calculated (because of external file that must be compressed before to be insered) |
| 961 | 961 | */ |
| 962 | - function _EstimateNewArchSize($Optim=true) { |
|
| 962 | + function _EstimateNewArchSize($Optim = true) { |
|
| 963 | 963 | |
| 964 | 964 | if ($this->ArchIsNew) { |
| 965 | 965 | $Len = strlen($this->CdInfo['bin']); |
@@ -972,19 +972,19 @@ discard block |
||
| 972 | 972 | |
| 973 | 973 | // files to replace or delete |
| 974 | 974 | foreach ($this->ReplByPos as $i) { |
| 975 | - $Ref =& $this->ReplInfo[$i]; |
|
| 976 | - if ($Ref===false) { |
|
| 975 | + $Ref = & $this->ReplInfo[$i]; |
|
| 976 | + if ($Ref === false) { |
|
| 977 | 977 | // file to delete |
| 978 | - $Info =& $this->CdFileLst[$i]; |
|
| 978 | + $Info = & $this->CdFileLst[$i]; |
|
| 979 | 979 | if (!isset($this->VisFileLst[$i])) { |
| 980 | 980 | if ($Optim) return false; // if $Optimization is set to true, then we d'ont rewind to read information |
| 981 | 981 | $this->_MoveTo($Info['p_loc']); |
| 982 | 982 | $this->_ReadFile($i, false); |
| 983 | 983 | } |
| 984 | - $Vis =& $this->VisFileLst[$i]; |
|
| 985 | - $Len += -strlen($Vis['bin']) -strlen($Info['bin']) - $Info['l_data_c']; |
|
| 984 | + $Vis = & $this->VisFileLst[$i]; |
|
| 985 | + $Len += -strlen($Vis['bin']) - strlen($Info['bin']) - $Info['l_data_c']; |
|
| 986 | 986 | if (isset($Vis['desc_bin'])) $Len += -strlen($Vis['desc_bin']); |
| 987 | - } elseif ($Ref['len_c']===false) { |
|
| 987 | + } elseif ($Ref['len_c'] === false) { |
|
| 988 | 988 | return false; // information not yet known |
| 989 | 989 | } else { |
| 990 | 990 | // file to replace |
@@ -995,8 +995,8 @@ discard block |
||
| 995 | 995 | // files to add |
| 996 | 996 | $i_lst = array_keys($this->AddInfo); |
| 997 | 997 | foreach ($i_lst as $i) { |
| 998 | - $Ref =& $this->AddInfo[$i]; |
|
| 999 | - if ($Ref['len_c']===false) { |
|
| 998 | + $Ref = & $this->AddInfo[$i]; |
|
| 999 | + if ($Ref['len_c'] === false) { |
|
| 1000 | 1000 | return false; // information not yet known |
| 1001 | 1001 | } else { |
| 1002 | 1002 | $Len += $Ref['len_c'] + $Ref['diff']; |
@@ -73,15 +73,15 @@ discard block |
||
| 73 | 73 | { |
| 74 | 74 | if (!self::exists($service_name)) |
| 75 | 75 | throw new Exception(); |
| 76 | - require_once($GLOBALS['rootpath']."okapi/$service_name.php"); |
|
| 76 | + require_once($GLOBALS['rootpath'] . "okapi/$service_name.php"); |
|
| 77 | 77 | try |
| 78 | 78 | { |
| 79 | - return call_user_func(array('\\okapi\\'. |
|
| 80 | - str_replace('/', '\\', $service_name).'\\WebService', 'options')); |
|
| 79 | + return call_user_func(array('\\okapi\\' . |
|
| 80 | + str_replace('/', '\\', $service_name) . '\\WebService', 'options')); |
|
| 81 | 81 | } catch (Exception $e) |
| 82 | 82 | { |
| 83 | - throw new Exception("Make sure you've declared your WebService class ". |
|
| 84 | - "in an valid namespace (".'okapi\\'.str_replace('/', '\\', $service_name)."); ". |
|
| 83 | + throw new Exception("Make sure you've declared your WebService class " . |
|
| 84 | + "in an valid namespace (" . 'okapi\\' . str_replace('/', '\\', $service_name) . "); " . |
|
| 85 | 85 | $e->getMessage()); |
| 86 | 86 | } |
| 87 | 87 | } |
@@ -120,13 +120,13 @@ discard block |
||
| 120 | 120 | $options = self::options($service_name); |
| 121 | 121 | if ($options['min_auth_level'] >= 2 && $request->consumer == null) |
| 122 | 122 | { |
| 123 | - throw new Exception("Method '$service_name' called with mismatched OkapiRequest: ". |
|
| 124 | - "\$request->consumer MAY NOT be empty for Level 2 and Level 3 methods. Provide ". |
|
| 123 | + throw new Exception("Method '$service_name' called with mismatched OkapiRequest: " . |
|
| 124 | + "\$request->consumer MAY NOT be empty for Level 2 and Level 3 methods. Provide " . |
|
| 125 | 125 | "a dummy Consumer if you have to."); |
| 126 | 126 | } |
| 127 | 127 | if ($options['min_auth_level'] >= 3 && $request->token == null) |
| 128 | 128 | { |
| 129 | - throw new Exception("Method '$service_name' called with mismatched OkapiRequest: ". |
|
| 129 | + throw new Exception("Method '$service_name' called with mismatched OkapiRequest: " . |
|
| 130 | 130 | "\$request->token MAY NOT be empty for Level 3 methods."); |
| 131 | 131 | } |
| 132 | 132 | |
@@ -134,14 +134,14 @@ discard block |
||
| 134 | 134 | Okapi::gettext_domain_init(); |
| 135 | 135 | try |
| 136 | 136 | { |
| 137 | - require_once($GLOBALS['rootpath']."okapi/$service_name.php"); |
|
| 138 | - $response = call_user_func(array('\\okapi\\'. |
|
| 139 | - str_replace('/', '\\', $service_name).'\\WebService', 'call'), $request); |
|
| 137 | + require_once($GLOBALS['rootpath'] . "okapi/$service_name.php"); |
|
| 138 | + $response = call_user_func(array('\\okapi\\' . |
|
| 139 | + str_replace('/', '\\', $service_name) . '\\WebService', 'call'), $request); |
|
| 140 | 140 | if ($options['min_auth_level'] >= 3 && $request->token->token_type == "access") |
| 141 | 141 | { |
| 142 | 142 | Db::execute(" |
| 143 | 143 | update user set last_login=now() |
| 144 | - where user_id='".Db::escape_string($request->token->user_id)."' |
|
| 144 | + where user_id='".Db::escape_string($request->token->user_id) . "' |
|
| 145 | 145 | "); |
| 146 | 146 | } |
| 147 | 147 | Okapi::gettext_domain_restore(); |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | public static function save_stats_extra($extra_name, $request, $runtime) |
| 168 | 168 | { |
| 169 | - self::save_stats("extra/".$extra_name, $request, $runtime); |
|
| 169 | + self::save_stats("extra/" . $extra_name, $request, $runtime); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | private static function save_stats($service_name, $request, $runtime) |
@@ -195,11 +195,11 @@ discard block |
||
| 195 | 195 | insert into okapi_stats_temp (`datetime`, consumer_key, user_id, service_name, calltype, runtime) |
| 196 | 196 | values ( |
| 197 | 197 | now(), |
| 198 | - '".Db::escape_string($consumer_key)."', |
|
| 199 | - '".Db::escape_string($user_id)."', |
|
| 200 | - '".Db::escape_string($service_name)."', |
|
| 201 | - '".Db::escape_string($calltype)."', |
|
| 202 | - '".Db::escape_string($runtime)."' |
|
| 198 | + '".Db::escape_string($consumer_key) . "', |
|
| 199 | + '".Db::escape_string($user_id) . "', |
|
| 200 | + '".Db::escape_string($service_name) . "', |
|
| 201 | + '".Db::escape_string($calltype) . "', |
|
| 202 | + '".Db::escape_string($runtime) . "' |
|
| 203 | 203 | ); |
| 204 | 204 | "); |
| 205 | 205 | } |