@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @throws Exception |
44 | 44 | */ |
45 | - public static function getStorage($type="file", $options=array(), $secretoptions=array()) |
|
45 | + public static function getStorage($type = "file", $options = array(), $secretoptions = array()) |
|
46 | 46 | { |
47 | 47 | switch ($type) { |
48 | 48 | case "file": |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | if (!isset($type)) { |
62 | 62 | throw new Exception('Class name not set'); |
63 | 63 | } elseif (!class_exists($type)) { |
64 | - throw new Exception('Class not found: ' . var_export($type, TRUE)); |
|
64 | + throw new Exception('Class not found: '.var_export($type, TRUE)); |
|
65 | 65 | } |
66 | 66 | $instance = new $type($options, $secretoptions); |
67 | 67 | } |
@@ -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); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param mixed $value The data to store in state storage |
42 | 42 | * @param int $expire The expiration (in seconds) of the data |
43 | 43 | */ |
44 | - public abstract function setValue($key, $value, $expire=0); |
|
44 | + public abstract function setValue($key, $value, $expire = 0); |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Remove a value from the state storage |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * a state storage instance of a certain type. |
76 | 76 | * @param array $options An array of options for the state storage |
77 | 77 | */ |
78 | - public function __construct($options=array()) |
|
78 | + public function __construct($options = array()) |
|
79 | 79 | { |
80 | 80 | $this->_options = $options; |
81 | 81 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * The default configuration |
52 | 52 | */ |
53 | 53 | const DEFAULT_HOST = '127.0.0.1'; |
54 | - const DEFAULT_PORT = 11211; |
|
54 | + const DEFAULT_PORT = 11211; |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Get the prefix to use for all keys in memcache. |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * (non-PHPdoc) |
100 | 100 | * @see library/tiqr/Tiqr/StateStorage/Tiqr_StateStorage_Abstract::setValue() |
101 | 101 | */ |
102 | - public function setValue($key, $value, $expire=0) |
|
102 | + public function setValue($key, $value, $expire = 0) |
|
103 | 103 | { |
104 | 104 | $key = $this->_getKeyPrefix().$key; |
105 | 105 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $key = $this->_getKeyPrefix().$key; |
131 | 131 | |
132 | 132 | $result = $this->_memcache->get($key); |
133 | - if( $result === false ) |
|
133 | + if ($result === false) |
|
134 | 134 | return null; |
135 | 135 | return $result; |
136 | 136 | } |
@@ -45,14 +45,14 @@ discard block |
||
45 | 45 | * (non-PHPdoc) |
46 | 46 | * @see library/tiqr/Tiqr/StateStorage/Tiqr_StateStorage_Abstract::setValue() |
47 | 47 | */ |
48 | - public function setValue($key, $value, $expire=0) |
|
48 | + public function setValue($key, $value, $expire = 0) |
|
49 | 49 | { |
50 | 50 | if ($this->keyExists($key)) { |
51 | 51 | $sth = $this->handle->prepare("UPDATE ".$this->tablename." SET `value` = ?, `expire` = ? WHERE `key` = ?"); |
52 | 52 | } else { |
53 | 53 | $sth = $this->handle->prepare("INSERT INTO ".$this->tablename." (`value`,`expire`,`key`) VALUES (?,?,?)"); |
54 | 54 | } |
55 | - $sth->execute(array(serialize($value),time()+$expire,$key)); |
|
55 | + $sth->execute(array(serialize($value), time() + $expire, $key)); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | return NULL; |
84 | 84 | } |
85 | 85 | |
86 | - public function __construct($config=array()) |
|
86 | + public function __construct($config = array()) |
|
87 | 87 | { |
88 | 88 | $this->tablename = $config['table']; |
89 | - $this->handle = new PDO($config['dsn'],$config['username'],$config['password']); |
|
89 | + $this->handle = new PDO($config['dsn'], $config['username'], $config['password']); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * (non-PHPdoc) |
37 | 37 | * @see library/tiqr/Tiqr/StateStorage/Tiqr_StateStorage_Abstract::setValue() |
38 | 38 | */ |
39 | - public function setValue($key, $value, $expire=0) |
|
39 | + public function setValue($key, $value, $expire = 0) |
|
40 | 40 | { |
41 | 41 | $envelope = array("expire"=>$expire, |
42 | 42 | "createdAt"=>time(), |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | $filename = $this->_stateFilename($key); |
70 | 70 | if (file_exists($filename)) { |
71 | 71 | $envelope = unserialize(file_get_contents($filename)); |
72 | - if ($envelope["expire"]!=0) { |
|
72 | + if ($envelope["expire"] != 0) { |
|
73 | 73 | // This data is time-limited. If it's too old we discard it. |
74 | - if (time()-$envelope["createdAt"] > $envelope["expire"]) { |
|
74 | + if (time() - $envelope["createdAt"] > $envelope["expire"]) { |
|
75 | 75 | $this->unsetValue($key); |
76 | 76 | return NULL; |
77 | 77 | } |
@@ -38,21 +38,21 @@ |
||
38 | 38 | */ |
39 | 39 | public static function randomBytes($length) |
40 | 40 | { |
41 | - if(function_exists('openssl_random_pseudo_bytes')) { |
|
41 | + if (function_exists('openssl_random_pseudo_bytes')) { |
|
42 | 42 | $rnd = openssl_random_pseudo_bytes($length, $strong); |
43 | - if($strong === TRUE && $rnd !== FALSE) { |
|
43 | + if ($strong === TRUE && $rnd !== FALSE) { |
|
44 | 44 | return $rnd; |
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
48 | 48 | // When openssl_random_pseudo_bytes failed, fall back on a mt_rand based string. |
49 | 49 | |
50 | - $rnd=''; |
|
50 | + $rnd = ''; |
|
51 | 51 | |
52 | - for ($i=0;$i<$length;$i++) { |
|
53 | - $sha= sha1(mt_rand()); |
|
54 | - $char= mt_rand(0,30); |
|
55 | - $rnd.= chr(hexdec($sha[$char].$sha[$char+1])); |
|
52 | + for ($i = 0; $i < $length; $i++) { |
|
53 | + $sha = sha1(mt_rand()); |
|
54 | + $char = mt_rand(0, 30); |
|
55 | + $rnd .= chr(hexdec($sha[$char].$sha[$char + 1])); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | return $rnd; |
@@ -162,7 +162,7 @@ |
||
162 | 162 | * |
163 | 163 | * @return mixed LDAP attribute value |
164 | 164 | */ |
165 | - protected function _getLDAPAttribute($entry, $attribName, $index=0) |
|
165 | + protected function _getLDAPAttribute($entry, $attribName, $index = 0) |
|
166 | 166 | { |
167 | 167 | $attribName = strtolower($attribName); |
168 | 168 |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | parent::__construct($config, $secretconfig); |
45 | 45 | $this->tablename = isset($config['table']) ? $config['table'] : 'tiqruser'; |
46 | 46 | try { |
47 | - $this->handle = new PDO($config['dsn'],$config['username'],$config['password']); |
|
47 | + $this->handle = new PDO($config['dsn'], $config['username'], $config['password']); |
|
48 | 48 | } catch (PDOException $e) { |
49 | 49 | return false; |
50 | 50 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | } else { |
58 | 58 | $sth = $this->handle->prepare("INSERT INTO ".$this->tablename." (displayname,userid) VALUES (?,?)"); |
59 | 59 | } |
60 | - $sth->execute(array($displayName,$userId)); |
|
60 | + $sth->execute(array($displayName, $userId)); |
|
61 | 61 | return $this->userExists($userId); |
62 | 62 | } |
63 | 63 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | public function setNotificationType($userId, $type) |
86 | 86 | { |
87 | 87 | $sth = $this->handle->prepare("UPDATE ".$this->tablename." SET notificationtype = ? WHERE userid = ?"); |
88 | - $sth->execute(array($type,$userId)); |
|
88 | + $sth->execute(array($type, $userId)); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | public function getNotificationAddress($userId) |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | public function setNotificationAddress($userId, $address) |
99 | 99 | { |
100 | 100 | $sth = $this->handle->prepare("UPDATE ".$this->tablename." SET notificationaddress = ? WHERE userid = ?"); |
101 | - $sth->execute(array($address,$userId)); |
|
101 | + $sth->execute(array($address, $userId)); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | public function getLoginAttempts($userId) |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | public function setLoginAttempts($userId, $amount) |
112 | 112 | { |
113 | 113 | $sth = $this->handle->prepare("UPDATE ".$this->tablename." SET loginattempts = ? WHERE userid = ?"); |
114 | - $sth->execute(array($amount,$userId)); |
|
114 | + $sth->execute(array($amount, $userId)); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | public function isBlocked($userId, $duration) |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | |
143 | 143 | public function setTemporaryBlockAttempts($userId, $amount) { |
144 | 144 | $sth = $this->handle->prepare("UPDATE ".$this->tablename." SET tmpblockattempts = ? WHERE userid = ?"); |
145 | - $sth->execute(array($amount,$userId)); |
|
145 | + $sth->execute(array($amount, $userId)); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | public function getTemporaryBlockAttempts($userId) { |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | public function setTemporaryBlockTimestamp($userId, $timestamp) |
158 | 158 | { |
159 | 159 | $sth = $this->handle->prepare("UPDATE ".$this->tablename." SET tmpblocktimestamp = ? WHERE userid = ?"); |
160 | - $sth->execute(array($timestamp,$userId)); |
|
160 | + $sth->execute(array($timestamp, $userId)); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | public function getTemporaryBlockTimestamp($userId) |