@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | public function setBaseURL($apiBaseURL) |
| 27 | 27 | { |
| 28 | - $this->_apiBaseURL = rtrim($apiBaseURL, '/') . '/'; |
|
| 28 | + $this->_apiBaseURL = rtrim($apiBaseURL, '/').'/'; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | protected function callAPI($resource, $method = "GET", $data = array(), $headers = array()) |
| 79 | 79 | { |
| 80 | 80 | $ch = curl_init(); |
| 81 | - curl_setopt($ch, CURLOPT_URL, $this->_apiBaseURL . ltrim($resource, '/')); |
|
| 81 | + curl_setopt($ch, CURLOPT_URL, $this->_apiBaseURL.ltrim($resource, '/')); |
|
| 82 | 82 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
| 83 | 83 | |
| 84 | 84 | // Explicitly empty null values, because http_build_query will throw away |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | $headerArray = array(); |
| 109 | 109 | foreach ($headers as $key => $value) { |
| 110 | - $headerArray[] = $key . ': ' . $value; |
|
| 110 | + $headerArray[] = $key.': '.$value; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArray); |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | public function userExists($userId) |
| 55 | 55 | { |
| 56 | 56 | $user = $this->_loadUser($userId, FALSE); |
| 57 | - return (is_array($user)||is_object($user)); |
|
| 57 | + return (is_array($user) || is_object($user)); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | if ($data = $this->_loadUser($userId)) { |
| 154 | 154 | $timestamp = $this->getTemporaryBlockTimestamp($userId); |
| 155 | 155 | // if not blocked or block is expired, return false |
| 156 | - if (!isset($data["blocked"]) || $data["blocked"]==false || (false !== $timestamp && false != $duration && (strtotime($timestamp) + $duration * 60) < time())) { |
|
| 156 | + if (!isset($data["blocked"]) || $data["blocked"] == false || (false !== $timestamp && false != $duration && (strtotime($timestamp) + $duration * 60) < time())) { |
|
| 157 | 157 | return false; |
| 158 | 158 | } |
| 159 | 159 | } |
@@ -46,25 +46,25 @@ discard block |
||
| 46 | 46 | * @param String $counter |
| 47 | 47 | * @return String hash |
| 48 | 48 | */ |
| 49 | - protected function _getHash ($secret, $counter) |
|
| 49 | + protected function _getHash($secret, $counter) |
|
| 50 | 50 | { |
| 51 | 51 | // Counter |
| 52 | 52 | //the counter value can be more than one byte long, so we need to go multiple times |
| 53 | - $cur_counter = array(0,0,0,0,0,0,0,0); |
|
| 54 | - for($i=7;$i>=0;$i--) |
|
| 53 | + $cur_counter = array(0, 0, 0, 0, 0, 0, 0, 0); |
|
| 54 | + for ($i = 7; $i >= 0; $i--) |
|
| 55 | 55 | { |
| 56 | - $cur_counter[$i] = pack ('C*', $counter); |
|
| 56 | + $cur_counter[$i] = pack('C*', $counter); |
|
| 57 | 57 | $counter = $counter >> 8; |
| 58 | 58 | } |
| 59 | 59 | $bin_counter = implode($cur_counter); |
| 60 | 60 | // Pad to 8 chars |
| 61 | - if (strlen ($bin_counter) < 8) |
|
| 61 | + if (strlen($bin_counter) < 8) |
|
| 62 | 62 | { |
| 63 | - $bin_counter = str_repeat (chr(0), 8 - strlen ($bin_counter)) . $bin_counter; |
|
| 63 | + $bin_counter = str_repeat(chr(0), 8 - strlen($bin_counter)).$bin_counter; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // HMAC |
| 67 | - $hash = hash_hmac ('sha1', $bin_counter, $secret); |
|
| 67 | + $hash = hash_hmac('sha1', $bin_counter, $secret); |
|
| 68 | 68 | return $hash; |
| 69 | 69 | } |
| 70 | 70 | |
@@ -77,9 +77,9 @@ discard block |
||
| 77 | 77 | protected function _truncate($hash, $length = 6) |
| 78 | 78 | { |
| 79 | 79 | // Convert to dec |
| 80 | - foreach(str_split($hash,2) as $hex) |
|
| 80 | + foreach (str_split($hash, 2) as $hex) |
|
| 81 | 81 | { |
| 82 | - $hmac_result[]=hexdec($hex); |
|
| 82 | + $hmac_result[] = hexdec($hex); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | // Find offset |
@@ -88,10 +88,10 @@ discard block |
||
| 88 | 88 | // Algorithm from RFC |
| 89 | 89 | return |
| 90 | 90 | ( |
| 91 | - (($hmac_result[$offset+0] & 0x7f) << 24 ) | |
|
| 92 | - (($hmac_result[$offset+1] & 0xff) << 16 ) | |
|
| 93 | - (($hmac_result[$offset+2] & 0xff) << 8 ) | |
|
| 94 | - ($hmac_result[$offset+3] & 0xff) |
|
| 95 | - ) % pow(10,$length); |
|
| 91 | + (($hmac_result[$offset + 0] & 0x7f) << 24) | |
|
| 92 | + (($hmac_result[$offset + 1] & 0xff) << 16) | |
|
| 93 | + (($hmac_result[$offset + 2] & 0xff) << 8) | |
|
| 94 | + ($hmac_result[$offset + 3] & 0xff) |
|
| 95 | + ) % pow(10, $length); |
|
| 96 | 96 | } |
| 97 | 97 | } |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | * @param boolean $temporary temporary failure? |
| 36 | 36 | * @param Exception $parent parent exception |
| 37 | 37 | */ |
| 38 | - public function __construct($message, $temporary=false, Exception $parent=null) |
|
| 38 | + public function __construct($message, $temporary = false, Exception $parent = null) |
|
| 39 | 39 | { |
| 40 | 40 | parent::__construct($message, $parent); |
| 41 | 41 | $this->_temporary = $temporary; |
@@ -102,7 +102,7 @@ |
||
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | if ($error != null) { |
| 105 | - throw new Tiqr_Message_Exception_SendFailure("Error in GCM response: " . $error, true); |
|
| 105 | + throw new Tiqr_Message_Exception_SendFailure("Error in GCM response: ".$error, true); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | } |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | * @param string $message exception message |
| 30 | 30 | * @param Exception $parent parent exception |
| 31 | 31 | */ |
| 32 | - public function __construct($message, $parent=null) |
|
| 32 | + public function __construct($message, $parent = null) |
|
| 33 | 33 | { |
| 34 | 34 | parent::__construct($message, 0, $parent); |
| 35 | 35 | } |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | * @param boolean $temporary temporary failure? |
| 36 | 36 | * @param Exception $parent parent exception |
| 37 | 37 | */ |
| 38 | - public function __construct($message, $temporary=false, Exception $parent=null) |
|
| 38 | + public function __construct($message, $temporary = false, Exception $parent = null) |
|
| 39 | 39 | { |
| 40 | 40 | parent::__construct($message, $parent); |
| 41 | 41 | $this->_temporary = $temporary; |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @throws Tiqr_Message_Exception_SendFailure |
| 59 | 59 | */ |
| 60 | - private function _sendFirebase($deviceToken, $alert, $challenge, $apiKey, $retry=false) |
|
| 60 | + private function _sendFirebase($deviceToken, $alert, $challenge, $apiKey, $retry = false) |
|
| 61 | 61 | { |
| 62 | 62 | $msg = array( |
| 63 | 63 | 'challenge' => $challenge, |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | ); |
| 72 | 72 | |
| 73 | 73 | $headers = array( |
| 74 | - 'Authorization: key=' . $apiKey, |
|
| 74 | + 'Authorization: key='.$apiKey, |
|
| 75 | 75 | 'Content-Type: application/json', |
| 76 | 76 | ); |
| 77 | 77 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | $result = curl_exec($ch); |
| 85 | 85 | $errors = curl_error($ch); |
| 86 | 86 | $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
| 87 | - $remoteip = curl_getinfo($ch,CURLINFO_PRIMARY_IP); |
|
| 87 | + $remoteip = curl_getinfo($ch, CURLINFO_PRIMARY_IP); |
|
| 88 | 88 | curl_close($ch); |
| 89 | 89 | |
| 90 | 90 | if ($result === false) { |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | if (!empty($errors)) { |
| 95 | - throw new Tiqr_Message_Exception_SendFailure("Http error occurred: ". $errors, true); |
|
| 95 | + throw new Tiqr_Message_Exception_SendFailure("Http error occurred: ".$errors, true); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | // Wait and retry once in case of a 502 Bad Gateway error |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | $response = json_decode($result, true); |
| 111 | 111 | foreach ($response['results'] as $k => $v) { |
| 112 | 112 | if (isset($v['error'])) { |
| 113 | - throw new Tiqr_Message_Exception_SendFailure("Error in GCM response: " . $v['error'], true); |
|
| 113 | + throw new Tiqr_Message_Exception_SendFailure("Error in GCM response: ".$v['error'], true); |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public static function autoload($className) { |
| 26 | - if($className === NULL) { |
|
| 26 | + if ($className === NULL) { |
|
| 27 | 27 | return; |
| 28 | 28 | } |
| 29 | 29 | |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | $substr5 = substr($className, 0, 5); |
| 33 | 33 | |
| 34 | 34 | if ($substr5 === 'Tiqr_' || $substr5 === 'OATH_') { |
| 35 | - $file = $self->tiqrPath . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; |
|
| 35 | + $file = $self->tiqrPath.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $className).'.php'; |
|
| 36 | 36 | } elseif ($className === 'QRcode') { |
| 37 | - $file = $self->qrcodePath . DIRECTORY_SEPARATOR . 'qrlib.php'; |
|
| 37 | + $file = $self->qrcodePath.DIRECTORY_SEPARATOR.'qrlib.php'; |
|
| 38 | 38 | } elseif ($substr5 === 'Zend_') { |
| 39 | - $file = $self->zendPath . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; |
|
| 39 | + $file = $self->zendPath.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $className).'.php'; |
|
| 40 | 40 | } else { |
| 41 | 41 | return; |
| 42 | 42 | } |
@@ -57,34 +57,34 @@ discard block |
||
| 57 | 57 | if (is_dir($tiqr_path)) { |
| 58 | 58 | $this->tiqrPath = $tiqr_path; |
| 59 | 59 | } else { |
| 60 | - throw new Exception('Directory not found: ' . var_export($tiqr_dir, TRUE)); |
|
| 60 | + throw new Exception('Directory not found: '.var_export($tiqr_dir, TRUE)); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | if (isset($options["phpqrcode.path"])) { |
| 64 | 64 | $qrcode_dir = $options["phpqrcode.path"]; |
| 65 | 65 | $qrcode_path = realpath($qrcode_dir); |
| 66 | 66 | } else { |
| 67 | - $qrcode_dir = dirname(dirname(dirname(__FILE__))) . '/phpqrcode'; |
|
| 67 | + $qrcode_dir = dirname(dirname(dirname(__FILE__))).'/phpqrcode'; |
|
| 68 | 68 | $qrcode_path = $qrcode_dir; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | if (is_dir($qrcode_path)) { |
| 72 | 72 | $this->qrcodePath = $qrcode_path; |
| 73 | 73 | } else { |
| 74 | - throw new Exception('Directory not found: ' . var_export($qrcode_dir, TRUE)); |
|
| 74 | + throw new Exception('Directory not found: '.var_export($qrcode_dir, TRUE)); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | if (isset($options["zend.path"])) { |
| 78 | 78 | $zend_dir = $options["zend.path"]; |
| 79 | 79 | $zend_path = realpath($zend_dir); |
| 80 | 80 | } else { |
| 81 | - $zend_dir = dirname(dirname(dirname(__FILE__))) . "/zend"; |
|
| 81 | + $zend_dir = dirname(dirname(dirname(__FILE__)))."/zend"; |
|
| 82 | 82 | $zend_path = $zend_dir; |
| 83 | 83 | } |
| 84 | 84 | if (is_dir($zend_path)) { |
| 85 | 85 | $this->zendPath = $zend_path; |
| 86 | 86 | } else { |
| 87 | - throw new Exception('Directory not found: ' . var_export($zend_dir, TRUE)); |
|
| 87 | + throw new Exception('Directory not found: '.var_export($zend_dir, TRUE)); |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | |