@@ -29,8 +29,8 @@ discard block |
||
| 29 | 29 | $ht = $this->http; |
| 30 | 30 | |
| 31 | 31 | $this->http->writeStatus($ht::HTTP_UNAUTHORIZED); |
| 32 | - header('WWW-Authenticate: Basic realm="'.$this->realm.'"'); |
|
| 33 | - die('Error ' . $ht::HTTP_UNAUTHORIZED .' (' . $this->http->getStatusText($ht::HTTP_UNAUTHORIZED) . ')!!'); |
|
| 32 | + header('WWW-Authenticate: Basic realm="' . $this->realm . '"'); |
|
| 33 | + die('Error ' . $ht::HTTP_UNAUTHORIZED . ' (' . $this->http->getStatusText($ht::HTTP_UNAUTHORIZED) . ')!!'); |
|
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | public function response() |
| 77 | 77 | { |
| 78 | 78 | $status = http_response_code(); |
| 79 | - $this->response = 'Error ' . $status .' (' . $this->http->getStatusText($status) . ')!!'; |
|
| 79 | + $this->response = 'Error ' . $status . ' (' . $this->http->getStatusText($status) . ')!!'; |
|
| 80 | 80 | echo $this->response; |
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | \ No newline at end of file |
@@ -29,8 +29,8 @@ discard block |
||
| 29 | 29 | $ht = $this->http; |
| 30 | 30 | |
| 31 | 31 | $this->http->writeStatus($ht::HTTP_UNAUTHORIZED); |
| 32 | - header('WWW-Authenticate: Digest realm="'.$this->realm.'",qop="auth",nonce="'.uniqid().'",opaque="'.md5($this->realm).'"'); |
|
| 33 | - die('Error ' . $ht::HTTP_UNAUTHORIZED .' (' . $this->http->getStatusText($ht::HTTP_UNAUTHORIZED) . ')!!'); |
|
| 32 | + header('WWW-Authenticate: Digest realm="' . $this->realm . '",qop="auth",nonce="' . uniqid() . '",opaque="' . md5($this->realm) . '"'); |
|
| 33 | + die('Error ' . $ht::HTTP_UNAUTHORIZED . ' (' . $this->http->getStatusText($ht::HTTP_UNAUTHORIZED) . ')!!'); |
|
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | $A1 = md5($data['username'] . ':' . $this->realm . ':' . $this->whiteList[$data['username']]); |
| 53 | - $A2 = md5($_SERVER['REQUEST_METHOD'].':'.$data['uri']); |
|
| 54 | - $valid_response = md5($A1.':'.$data['nonce'].':'.$data['nc'].':'.$data['cnonce'].':'.$data['qop'].':'.$A2); |
|
| 53 | + $A2 = md5($_SERVER['REQUEST_METHOD'] . ':' . $data['uri']); |
|
| 54 | + $valid_response = md5($A1 . ':' . $data['nonce'] . ':' . $data['nc'] . ':' . $data['cnonce'] . ':' . $data['qop'] . ':' . $A2); |
|
| 55 | 55 | |
| 56 | 56 | if ($data['response'] != $valid_response) |
| 57 | 57 | { |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | public function response() |
| 98 | 98 | { |
| 99 | 99 | $status = http_response_code(); |
| 100 | - $this->response = 'Error ' . $status .' (' . $this->http->getStatusText($status) . ')!!'; |
|
| 100 | + $this->response = 'Error ' . $status . ' (' . $this->http->getStatusText($status) . ')!!'; |
|
| 101 | 101 | echo $this->response; |
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | \ No newline at end of file |
@@ -156,8 +156,8 @@ |
||
| 156 | 156 | { |
| 157 | 157 | foreach ($options as $option => $value) |
| 158 | 158 | { |
| 159 | - if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) |
|
| 160 | - $this->{'set'.$option}($value); |
|
| 159 | + if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set' . $option)) |
|
| 160 | + $this->{'set' . $option}($value); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | # HTTP instance |
@@ -127,8 +127,9 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function setWhiteList(array $whiteList) |
| 129 | 129 | { |
| 130 | - if (empty($whiteList)) |
|
| 131 | - throw new \RuntimeException("Empty whitelist!"); |
|
| 130 | + if (empty($whiteList)) { |
|
| 131 | + throw new \RuntimeException("Empty whitelist!"); |
|
| 132 | + } |
|
| 132 | 133 | |
| 133 | 134 | $this->whiteList = $whiteList; |
| 134 | 135 | } |
@@ -156,8 +157,9 @@ discard block |
||
| 156 | 157 | { |
| 157 | 158 | foreach ($options as $option => $value) |
| 158 | 159 | { |
| 159 | - if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) |
|
| 160 | - $this->{'set'.$option}($value); |
|
| 160 | + if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) { |
|
| 161 | + $this->{'set'.$option}($value); |
|
| 162 | + } |
|
| 161 | 163 | } |
| 162 | 164 | |
| 163 | 165 | # HTTP instance |
@@ -64,11 +64,13 @@ |
||
| 64 | 64 | */ |
| 65 | 65 | public static function getClientIP() |
| 66 | 66 | { |
| 67 | - if (!empty($_SERVER['HTTP_CLIENT_IP'])) |
|
| 68 | - return $_SERVER['HTTP_CLIENT_IP']; |
|
| 67 | + if (!empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
| 68 | + return $_SERVER['HTTP_CLIENT_IP']; |
|
| 69 | + } |
|
| 69 | 70 | |
| 70 | - if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) |
|
| 71 | - return $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 71 | + if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
| 72 | + return $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 73 | + } |
|
| 72 | 74 | |
| 73 | 75 | return $_SERVER['REMOTE_ADDR']; |
| 74 | 76 | } |
@@ -131,7 +131,7 @@ |
||
| 131 | 131 | if (\PEAR::isError($mail)) |
| 132 | 132 | { |
| 133 | 133 | $this->error( |
| 134 | - $mail->getCode(), $mail->getMessage() |
|
| 134 | + $mail->getCode(), $mail->getMessage() |
|
| 135 | 135 | ); |
| 136 | 136 | |
| 137 | 137 | return false; |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | public function send($from, $to, $subject, $body) |
| 116 | 116 | { |
| 117 | - $headers = array ( |
|
| 117 | + $headers = array( |
|
| 118 | 118 | 'From' => $from, |
| 119 | 119 | 'To' => $to, |
| 120 | 120 | 'Subject' => $subject, |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | $smtp = \Mail::factory( |
| 125 | 125 | 'smtp', |
| 126 | - array ('host' => $this->host, 'auth' => false) |
|
| 126 | + array('host' => $this->host, 'auth' => false) |
|
| 127 | 127 | ); |
| 128 | 128 | |
| 129 | 129 | $mail = $smtp->send($to, $headers, $body); |
@@ -74,18 +74,21 @@ discard block |
||
| 74 | 74 | { |
| 75 | 75 | @include_once 'System.php'; |
| 76 | 76 | |
| 77 | - if (!class_exists('System', false)) |
|
| 78 | - throw new \RuntimeException("PEAR is not installed in your system!"); |
|
| 77 | + if (!class_exists('System', false)) { |
|
| 78 | + throw new \RuntimeException("PEAR is not installed in your system!"); |
|
| 79 | + } |
|
| 79 | 80 | |
| 80 | 81 | include_once 'Net/SMTP.php'; |
| 81 | 82 | |
| 82 | - if (!class_exists('\Net_SMTP', false)) |
|
| 83 | - throw new \RuntimeException("PEAR::Net_SMTP is not installed!"); |
|
| 83 | + if (!class_exists('\Net_SMTP', false)) { |
|
| 84 | + throw new \RuntimeException("PEAR::Net_SMTP is not installed!"); |
|
| 85 | + } |
|
| 84 | 86 | |
| 85 | 87 | @include_once 'Mail.php'; |
| 86 | 88 | |
| 87 | - if (!class_exists('\Mail', false)) |
|
| 88 | - throw new \RuntimeException("PEAR::Mail is not installed!"); |
|
| 89 | + if (!class_exists('\Mail', false)) { |
|
| 90 | + throw new \RuntimeException("PEAR::Mail is not installed!"); |
|
| 91 | + } |
|
| 89 | 92 | } |
| 90 | 93 | |
| 91 | 94 | /** |
@@ -98,8 +101,9 @@ discard block |
||
| 98 | 101 | */ |
| 99 | 102 | protected function error($code, $message = null) |
| 100 | 103 | { |
| 101 | - if (!array_key_exists($code, $this->errors)) |
|
| 102 | - $this->errors[$message] = (is_null($message) && array_key_exists($code, $this->errors)) ? $this->errors[$code] : $message; |
|
| 104 | + if (!array_key_exists($code, $this->errors)) { |
|
| 105 | + $this->errors[$message] = (is_null($message) && array_key_exists($code, $this->errors)) ? $this->errors[$code] : $message; |
|
| 106 | + } |
|
| 103 | 107 | } |
| 104 | 108 | |
| 105 | 109 | /** |
@@ -70,8 +70,9 @@ |
||
| 70 | 70 | { |
| 71 | 71 | $parameters = $this->getParams(); |
| 72 | 72 | |
| 73 | - if (array_key_exists($param, $parameters)) |
|
| 74 | - return true; |
|
| 73 | + if (array_key_exists($param, $parameters)) { |
|
| 74 | + return true; |
|
| 75 | + } |
|
| 75 | 76 | |
| 76 | 77 | return false; |
| 77 | 78 | } |
@@ -60,7 +60,7 @@ |
||
| 60 | 60 | |
| 61 | 61 | if (!empty($string)) |
| 62 | 62 | { |
| 63 | - $data = json_decode($string, true); |
|
| 63 | + $data = json_decode($string, true); |
|
| 64 | 64 | |
| 65 | 65 | # json_encode can return TRUE, FALSE or NULL (http://php.net/manual/en/function.json-decode.php) |
| 66 | 66 | if (is_null($data) || $data === false) |
@@ -69,8 +69,7 @@ discard block |
||
| 69 | 69 | return false; |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | - } |
|
| 73 | - else |
|
| 72 | + } else |
|
| 74 | 73 | { |
| 75 | 74 | $directory = strstr($this->outputFile, basename($this->outputFile), true); |
| 76 | 75 | |
@@ -86,17 +85,20 @@ discard block |
||
| 86 | 85 | "object" => serialize($exception) |
| 87 | 86 | ]; |
| 88 | 87 | |
| 89 | - if (!function_exists('mb_detect_encoding')) |
|
| 90 | - throw new \RuntimeException("mbstring library is not installed!"); |
|
| 88 | + if (!function_exists('mb_detect_encoding')) { |
|
| 89 | + throw new \RuntimeException("mbstring library is not installed!"); |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | 92 | /* |
| 93 | 93 | * Encodes to UTF8 all messages. It ensures JSON encoding. |
| 94 | 94 | */ |
| 95 | - if (!mb_detect_encoding($data[$id]["message"], 'UTF-8', true)) |
|
| 96 | - $data[$id]["message"] = utf8_encode($data[$id]["message"]); |
|
| 95 | + if (!mb_detect_encoding($data[$id]["message"], 'UTF-8', true)) { |
|
| 96 | + $data[$id]["message"] = utf8_encode($data[$id]["message"]); |
|
| 97 | + } |
|
| 97 | 98 | |
| 98 | - if (!mb_detect_encoding($data[$id]["object"], 'UTF-8', true)) |
|
| 99 | - $data[$id]["object"] = utf8_decode($data[$id]["object"]); |
|
| 99 | + if (!mb_detect_encoding($data[$id]["object"], 'UTF-8', true)) { |
|
| 100 | + $data[$id]["object"] = utf8_decode($data[$id]["object"]); |
|
| 101 | + } |
|
| 100 | 102 | |
| 101 | 103 | if (($encoded_data = json_encode($data)) === false) |
| 102 | 104 | { |
@@ -298,8 +298,8 @@ |
||
| 298 | 298 | { |
| 299 | 299 | foreach ($options as $option => $value) |
| 300 | 300 | { |
| 301 | - if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) |
|
| 302 | - $this->{'set'.$option}($value); |
|
| 301 | + if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set' . $option)) |
|
| 302 | + $this->{'set' . $option}($value); |
|
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | 305 | |
@@ -216,8 +216,9 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | public function getArrayResult() |
| 218 | 218 | { |
| 219 | - if (!empty($this->arrayResult)) |
|
| 220 | - return $this->arrayResult; |
|
| 219 | + if (!empty($this->arrayResult)) { |
|
| 220 | + return $this->arrayResult; |
|
| 221 | + } |
|
| 221 | 222 | |
| 222 | 223 | return $this->toArray(); |
| 223 | 224 | } |
@@ -313,8 +314,9 @@ discard block |
||
| 313 | 314 | */ |
| 314 | 315 | public function autocommit($value) |
| 315 | 316 | { |
| 316 | - if ($this->transac_mode) |
|
| 317 | - throw new \LogicException("You cannot change autocommit behavior during a transaction"); |
|
| 317 | + if ($this->transac_mode) { |
|
| 318 | + throw new \LogicException("You cannot change autocommit behavior during a transaction"); |
|
| 319 | + } |
|
| 318 | 320 | |
| 319 | 321 | $this->autocommit = $value; |
| 320 | 322 | } |
@@ -330,8 +332,9 @@ discard block |
||
| 330 | 332 | { |
| 331 | 333 | foreach ($options as $option => $value) |
| 332 | 334 | { |
| 333 | - if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) |
|
| 334 | - $this->{'set'.$option}($value); |
|
| 335 | + if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) { |
|
| 336 | + $this->{'set'.$option}($value); |
|
| 337 | + } |
|
| 335 | 338 | } |
| 336 | 339 | } |
| 337 | 340 | |
@@ -375,8 +378,9 @@ discard block |
||
| 375 | 378 | */ |
| 376 | 379 | public function reconnect() |
| 377 | 380 | { |
| 378 | - if (!$this->isConnected()) |
|
| 379 | - throw new \LogicException("Connection was not established"); |
|
| 381 | + if (!$this->isConnected()) { |
|
| 382 | + throw new \LogicException("Connection was not established"); |
|
| 383 | + } |
|
| 380 | 384 | |
| 381 | 385 | $this->disconnect(); |
| 382 | 386 | return $this->connect(); |
@@ -405,8 +409,9 @@ discard block |
||
| 405 | 409 | */ |
| 406 | 410 | public function disconnect() |
| 407 | 411 | { |
| 408 | - if (!$this->isConnected()) |
|
| 409 | - throw new \LogicException("Connection was not established"); |
|
| 412 | + if (!$this->isConnected()) { |
|
| 413 | + throw new \LogicException("Connection was not established"); |
|
| 414 | + } |
|
| 410 | 415 | } |
| 411 | 416 | |
| 412 | 417 | /** |
@@ -418,11 +423,13 @@ discard block |
||
| 418 | 423 | */ |
| 419 | 424 | public function beginTransaction() |
| 420 | 425 | { |
| 421 | - if (!$this->isConnected()) |
|
| 422 | - $this->connect(); |
|
| 426 | + if (!$this->isConnected()) { |
|
| 427 | + $this->connect(); |
|
| 428 | + } |
|
| 423 | 429 | |
| 424 | - if ($this->transac_mode) |
|
| 425 | - throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_STARTED]); |
|
| 430 | + if ($this->transac_mode) { |
|
| 431 | + throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_STARTED]); |
|
| 432 | + } |
|
| 426 | 433 | |
| 427 | 434 | $this->transac_mode = true; |
| 428 | 435 | } |
@@ -436,16 +443,19 @@ discard block |
||
| 436 | 443 | */ |
| 437 | 444 | public function endTransaction() |
| 438 | 445 | { |
| 439 | - if (!$this->transac_mode) |
|
| 440 | - throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_NOT_STARTED]); |
|
| 446 | + if (!$this->transac_mode) { |
|
| 447 | + throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_NOT_STARTED]); |
|
| 448 | + } |
|
| 441 | 449 | |
| 442 | - if (is_null($this->transac_result)) |
|
| 443 | - throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_EMPTY]); |
|
| 450 | + if (is_null($this->transac_result)) { |
|
| 451 | + throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_EMPTY]); |
|
| 452 | + } |
|
| 444 | 453 | |
| 445 | - if ($this->transac_result) |
|
| 446 | - $this->commit(); |
|
| 447 | - else |
|
| 448 | - $this->rollback(); |
|
| 454 | + if ($this->transac_result) { |
|
| 455 | + $this->commit(); |
|
| 456 | + } else { |
|
| 457 | + $this->rollback(); |
|
| 458 | + } |
|
| 449 | 459 | |
| 450 | 460 | $this->result = $this->transac_result; |
| 451 | 461 | |
@@ -77,8 +77,9 @@ |
||
| 77 | 77 | |
| 78 | 78 | foreach ($arguments as $key => $arg) |
| 79 | 79 | { |
| 80 | - if (is_string($arg)) |
|
| 81 | - $arguments[$key] = "'$arg'"; |
|
| 80 | + if (is_string($arg)) { |
|
| 81 | + $arguments[$key] = "'$arg'"; |
|
| 82 | + } |
|
| 82 | 83 | } |
| 83 | 84 | |
| 84 | 85 | $arguments = implode(", ", array_values($arguments)); |