@@ -263,10 +263,14 @@ |
||
263 | 263 | * @param string $to |
264 | 264 | */ |
265 | 265 | public function presence($status = null, $show = 'available', $to = null, $type='available', $priority = 0 ) { |
266 | - if($type == 'available') $type = ''; |
|
266 | + if($type == 'available') { |
|
267 | + $type = ''; |
|
268 | + } |
|
267 | 269 | $to = htmlspecialchars($to); |
268 | 270 | $status = htmlspecialchars($status); |
269 | - if($show == 'unavailable') $type = 'unavailable'; |
|
271 | + if($show == 'unavailable') { |
|
272 | + $type = 'unavailable'; |
|
273 | + } |
|
270 | 274 | |
271 | 275 | $out = "<presence"; |
272 | 276 | $out .= ' from="'.$this->fulljid.'"'; |
@@ -83,14 +83,11 @@ discard block |
||
83 | 83 | foreach ($this as $name => $value) { |
84 | 84 | if (in_array($name, $sizes)) { |
85 | 85 | $entry = new Daemon_ConfigEntrySize; |
86 | - } |
|
87 | - elseif (in_array($name, $times)) { |
|
86 | + } elseif (in_array($name, $times)) { |
|
88 | 87 | $entry = new Daemon_ConfigEntryTime; |
89 | - } |
|
90 | - elseif (in_array($name, $numbers)) { |
|
88 | + } elseif (in_array($name, $numbers)) { |
|
91 | 89 | $entry = new Daemon_ConfigEntryNumber; |
92 | - } |
|
93 | - elseif ($name === 'configfile') { |
|
90 | + } elseif ($name === 'configfile') { |
|
94 | 91 | $entry = new Daemon_ConfigEntryConfigFile; |
95 | 92 | } else { |
96 | 93 | $entry = new Daemon_ConfigEntry; |
@@ -184,8 +181,7 @@ discard block |
||
184 | 181 | Daemon::$config->{$k}->setHumanValue($v); |
185 | 182 | Daemon::$config->{$k}->source = 'cmdline'; |
186 | 183 | |
187 | - } |
|
188 | - else { |
|
184 | + } else { |
|
189 | 185 | Daemon::log('Unrecognized parameter \'' . $k . '\''); |
190 | 186 | $error = TRUE; |
191 | 187 | } |
@@ -35,14 +35,11 @@ |
||
35 | 35 | |
36 | 36 | if ($l === 's') { |
37 | 37 | $time += $n; |
38 | - } |
|
39 | - elseif ($l === 'm') { |
|
38 | + } elseif ($l === 'm') { |
|
40 | 39 | $time += $n * 60; |
41 | - } |
|
42 | - elseif ($l === 'h') { |
|
40 | + } elseif ($l === 'h') { |
|
43 | 41 | $time += $n * 60 * 60; |
44 | - } |
|
45 | - elseif ($l === 'd') { |
|
42 | + } elseif ($l === 'd') { |
|
46 | 43 | $time += $n * 60 * 60 * 24; |
47 | 44 | } |
48 | 45 | }, $value); |
@@ -107,14 +107,12 @@ discard block |
||
107 | 107 | if ($dataLength <= 125) |
108 | 108 | { |
109 | 109 | $packet .= chr($dataLength + $isMaskedInt); |
110 | - } |
|
111 | - elseif ($dataLength <= 65535) |
|
110 | + } elseif ($dataLength <= 65535) |
|
112 | 111 | { |
113 | 112 | $packet .= chr(126 + $isMaskedInt) . // 126 + 128 |
114 | 113 | chr($dataLength >> 8) . |
115 | 114 | chr($dataLength & 0xFF); |
116 | - } |
|
117 | - else { |
|
115 | + } else { |
|
118 | 116 | $packet .= chr(127 + $isMaskedInt) . // 127 + 128 |
119 | 117 | chr($dataLength >> 56) . |
120 | 118 | chr($dataLength >> 48) . |
@@ -218,8 +216,7 @@ discard block |
||
218 | 216 | } |
219 | 217 | $dataLength = $this->bytes2int(binarySubstr($this->connection->buf, $p, 2), false); |
220 | 218 | $p += 2; |
221 | - } |
|
222 | - elseif ($dataLength === 0x7f) { // 4 bytes-length |
|
219 | + } elseif ($dataLength === 0x7f) { // 4 bytes-length |
|
223 | 220 | if ($buflen < $p + 4) { |
224 | 221 | return; // not enough data yet |
225 | 222 | } |
@@ -83,8 +83,7 @@ discard block |
||
83 | 83 | public function onConnected($cb) { |
84 | 84 | if ($this->state == self::STATE_AUTH_ERROR) { |
85 | 85 | call_user_func($cb, $this, false); |
86 | - } |
|
87 | - elseif ($this->state === self::STATE_AUTH_OK) { |
|
86 | + } elseif ($this->state === self::STATE_AUTH_OK) { |
|
88 | 87 | call_user_func($cb, $this, true); |
89 | 88 | } else { |
90 | 89 | if (!$this->onConnected) { |
@@ -376,38 +375,32 @@ discard block |
||
376 | 375 | Daemon::log(__CLASS__ . ': Unsupported authentication method: KerberosV5.'); |
377 | 376 | $this->state = self::STATE_AUTH_ERROR; // Auth. error |
378 | 377 | $this->finish(); // Unsupported, finish |
379 | - } |
|
380 | - elseif ($authType === 3) { |
|
378 | + } elseif ($authType === 3) { |
|
381 | 379 | // Cleartext |
382 | 380 | $this->sendPacket('p', $this->password); // Password Message |
383 | 381 | $this->state = self::STATE_AUTH_PACKET_SENT; |
384 | - } |
|
385 | - elseif ($authType === 4) { |
|
382 | + } elseif ($authType === 4) { |
|
386 | 383 | // Crypt |
387 | 384 | $salt = binarySubstr($packet, 4, 2); |
388 | 385 | $this->sendPacket('p', crypt($this->password, $salt)); // Password Message |
389 | 386 | $this->state = self::STATE_AUTH_PACKET_SENT; |
390 | - } |
|
391 | - elseif ($authType === 5) { |
|
387 | + } elseif ($authType === 5) { |
|
392 | 388 | // MD5 |
393 | 389 | $salt = binarySubstr($packet, 4, 4); |
394 | 390 | $this->sendPacket('p', 'md5' . md5(md5($this->password . $this->user) . $salt)); // Password Message |
395 | 391 | $this->state = self::STATE_AUTH_PACKET_SENT; |
396 | - } |
|
397 | - elseif ($authType === 6) { |
|
392 | + } elseif ($authType === 6) { |
|
398 | 393 | // SCM |
399 | 394 | Daemon::log(__CLASS__ . ': Unsupported authentication method: SCM.'); |
400 | 395 | $this->state = self::STATE_AUTH_ERROR; // Auth. error |
401 | 396 | $this->finish(); // Unsupported, finish |
402 | - } |
|
403 | - elseif ($authType == 9) { |
|
397 | + } elseif ($authType == 9) { |
|
404 | 398 | // GSS |
405 | 399 | Daemon::log(__CLASS__.': Unsupported authentication method: GSS.'); |
406 | 400 | $this->state = self::STATE_AUTH_ERROR; // Auth. error |
407 | 401 | $this->finish(); // Unsupported, finish |
408 | 402 | } |
409 | - } |
|
410 | - elseif ($type === 'T') { |
|
403 | + } elseif ($type === 'T') { |
|
411 | 404 | // Row Description |
412 | 405 | list(, $numfields) = unpack('n', binarySubstr($packet, 0, 2)); |
413 | 406 | $p = 2; |
@@ -419,8 +412,7 @@ discard block |
||
419 | 412 | $field['name'] = $name; |
420 | 413 | $this->resultFields[] = $field; |
421 | 414 | } |
422 | - } |
|
423 | - elseif ($type === 'D') { |
|
415 | + } elseif ($type === 'D') { |
|
424 | 416 | // Data Row |
425 | 417 | list(, $numfields) = unpack('n', binarySubstr($packet, 0, 2)); |
426 | 418 | $p = 2; |
@@ -446,8 +438,7 @@ discard block |
||
446 | 438 | } |
447 | 439 | |
448 | 440 | $this->resultRows[] = $row; |
449 | - } |
|
450 | - elseif ( |
|
441 | + } elseif ( |
|
451 | 442 | $type === 'G' |
452 | 443 | || $type === 'H' |
453 | 444 | ) { |
@@ -456,8 +447,7 @@ discard block |
||
456 | 447 | if ($this->pool->config->protologging->value) { |
457 | 448 | Daemon::log(__CLASS__ . ': Caught CopyInResponse'); |
458 | 449 | } |
459 | - } |
|
460 | - elseif ($type === 'C') { |
|
450 | + } elseif ($type === 'C') { |
|
461 | 451 | // Close command |
462 | 452 | $type = binarySubstr($packet, 0, 1); |
463 | 453 | |
@@ -473,8 +463,7 @@ discard block |
||
473 | 463 | if ($tag[0] === 'INSERT') { |
474 | 464 | $this->insertId = $tag[1]; |
475 | 465 | $this->insertNum = $tag[2]; |
476 | - } |
|
477 | - elseif ( |
|
466 | + } elseif ( |
|
478 | 467 | ($tag[0] === 'DELETE') |
479 | 468 | || ($tag[0] === 'UPDATE') |
480 | 469 | || ($tag[0] === 'MOVE') |
@@ -486,12 +475,10 @@ discard block |
||
486 | 475 | } |
487 | 476 | |
488 | 477 | $this->onResultDone(); |
489 | - } |
|
490 | - elseif ($type === 'n') { |
|
478 | + } elseif ($type === 'n') { |
|
491 | 479 | // No Data |
492 | 480 | $this->onResultDone(); |
493 | - } |
|
494 | - elseif ($type === 'E') { |
|
481 | + } elseif ($type === 'E') { |
|
495 | 482 | // Error Response |
496 | 483 | $code = ord($packet); |
497 | 484 | $message = ''; |
@@ -522,20 +509,17 @@ discard block |
||
522 | 509 | if ($this->pool->config->protologging->value) { |
523 | 510 | Daemon::log(__CLASS__ . ': Error response caught (0x' . dechex($code) . '): ' . $message); |
524 | 511 | } |
525 | - } |
|
526 | - elseif ($type === 'I') { |
|
512 | + } elseif ($type === 'I') { |
|
527 | 513 | // Empty Query Response |
528 | 514 | $this->errno = -1; |
529 | 515 | $this->errmsg = 'Query was empty'; |
530 | 516 | $this->onError(); |
531 | - } |
|
532 | - elseif ($type === 'S') { |
|
517 | + } elseif ($type === 'S') { |
|
533 | 518 | // Portal Suspended |
534 | 519 | if ($this->pool->config->protologging->value) { |
535 | 520 | Daemon::log(__CLASS__ . ': Caught PortalSuspended'); |
536 | 521 | } |
537 | - } |
|
538 | - elseif ($type === 'S') { |
|
522 | + } elseif ($type === 'S') { |
|
539 | 523 | // Parameter Status |
540 | 524 | $u = $this->decodeNULstrings($packet, 2); |
541 | 525 | |
@@ -546,8 +530,7 @@ discard block |
||
546 | 530 | Daemon::log(__CLASS__ . ': Parameter ' . $u[0] . ' = \'' . $this->parameters[$u[0]] . '\''); |
547 | 531 | } |
548 | 532 | } |
549 | - } |
|
550 | - elseif ($type === 'K') { |
|
533 | + } elseif ($type === 'K') { |
|
551 | 534 | // Backend Key Data |
552 | 535 | list(, $this->backendKey) = unpack('N', $packet); |
553 | 536 | $this->backendKey = isset($u[1])?$u[1]:NULL; |
@@ -555,8 +538,7 @@ discard block |
||
555 | 538 | if ($this->pool->config->protologging->value) { |
556 | 539 | Daemon::log(__CLASS__ . ': BackendKey is ' . $this->backendKey); |
557 | 540 | } |
558 | - } |
|
559 | - elseif ($type === 'Z') { |
|
541 | + } elseif ($type === 'Z') { |
|
560 | 542 | // Ready For Query |
561 | 543 | $this->status = $packet; |
562 | 544 |
@@ -33,8 +33,7 @@ |
||
33 | 33 | if ($method === 'registerPair') { |
34 | 34 | list ($local, $foreign, $user) = $args; |
35 | 35 | $this->pairs[$local . ':' .$foreign] = $user; |
36 | - } |
|
37 | - elseif ($method === 'unregisterPair') { |
|
36 | + } elseif ($method === 'unregisterPair') { |
|
38 | 37 | list ($local, $foreign) = $args; |
39 | 38 | unset($this->pairs[$local . ':' .$foreign]); |
40 | 39 | } |
@@ -50,7 +50,9 @@ discard block |
||
50 | 50 | $this->current_ns[$this->xml_depth] = $attr['XMLNS']; |
51 | 51 | } else { |
52 | 52 | $this->current_ns[$this->xml_depth] = $this->current_ns[$this->xml_depth - 1]; |
53 | - if(!$this->current_ns[$this->xml_depth]) $this->current_ns[$this->xml_depth] = $this->default_ns; |
|
53 | + if(!$this->current_ns[$this->xml_depth]) { |
|
54 | + $this->current_ns[$this->xml_depth] = $this->default_ns; |
|
55 | + } |
|
54 | 56 | } |
55 | 57 | $ns = $this->current_ns[$this->xml_depth]; |
56 | 58 | foreach($attr as $key => $value) { |
@@ -318,7 +320,9 @@ discard block |
||
318 | 320 | */ |
319 | 321 | public function hasSub($name, $ns = null) { |
320 | 322 | foreach($this->subs as $sub) { |
321 | - if(($name == "*" or $sub->name == $name) and ($ns == null or $sub->ns == $ns)) return true; |
|
323 | + if(($name == "*" or $sub->name == $name) and ($ns == null or $sub->ns == $ns)) { |
|
324 | + return true; |
|
325 | + } |
|
322 | 326 | } |
323 | 327 | return false; |
324 | 328 | } |
@@ -91,8 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | if ($c === "\x20") { |
93 | 93 | ++$spaces; |
94 | - } |
|
95 | - elseif (ctype_digit($c)) { |
|
94 | + } elseif (ctype_digit($c)) { |
|
96 | 95 | $digits .= $c; |
97 | 96 | } |
98 | 97 | } |
@@ -169,8 +168,7 @@ discard block |
||
169 | 168 | $decodedData = binarySubstr($this->connection->buf, 2, $len) ; |
170 | 169 | $this->connection->buf = binarySubstr($this->connection->buf, 2 + $len) ; |
171 | 170 | $this->connection->onFrame($decodedData, 'BINARY'); |
172 | - } |
|
173 | - else { |
|
171 | + } else { |
|
174 | 172 | if (($p = strpos($this->connection->buf, "\xFF")) !== FALSE) { |
175 | 173 | if ($this->connection->pool->maxAllowedPacket <= $p - 1) { |
176 | 174 | // Too big packet |
@@ -181,8 +179,7 @@ discard block |
||
181 | 179 | $decodedData = binarySubstr($this->connection->buf, 1, $p - 1) ; |
182 | 180 | $this->connection->buf = binarySubstr($this->connection->buf, $p + 1) ; |
183 | 181 | $this->connection->onFrame($decodedData, 'STRING'); |
184 | - } |
|
185 | - else { |
|
182 | + } else { |
|
186 | 183 | if ($this->connection->pool->maxAllowedPacket <= $buflen - 1) { |
187 | 184 | // Too big packet |
188 | 185 | $this->connection->finish() ; |
@@ -64,8 +64,7 @@ discard block |
||
64 | 64 | if ($c === $q) { |
65 | 65 | ++$cfg->p; |
66 | 66 | break; |
67 | - } |
|
68 | - elseif ($c === '\\') { |
|
67 | + } elseif ($c === '\\') { |
|
69 | 68 | if ($cfg->getNextChar() === $q) { |
70 | 69 | $str .= $q; |
71 | 70 | ++$cfg->p; |
@@ -84,19 +83,16 @@ discard block |
||
84 | 83 | return $str; |
85 | 84 | }, |
86 | 85 | self::T_ALL => function($cfg, $c) { |
87 | - if (ctype_space($c)) { } |
|
88 | - elseif ($c === '#') { |
|
86 | + if (ctype_space($c)) { } elseif ($c === '#') { |
|
89 | 87 | $cfg->state[] = array(Daemon_ConfigParser::T_COMMENT); |
90 | - } |
|
91 | - elseif ($c === '}') { |
|
88 | + } elseif ($c === '}') { |
|
92 | 89 | if (sizeof($cfg->state) > 1) { |
93 | 90 | $cfg->purgeScope($cfg->getCurrentScope()); |
94 | 91 | array_pop($cfg->state); |
95 | 92 | } else { |
96 | 93 | $cfg->raiseError('Unexpected \'}\''); |
97 | 94 | } |
98 | - } |
|
99 | - elseif (ctype_alnum($c)) { |
|
95 | + } elseif (ctype_alnum($c)) { |
|
100 | 96 | $elements = array(''); |
101 | 97 | $elTypes = array(NULL); |
102 | 98 | $i = 0; |
@@ -115,8 +111,7 @@ discard block |
||
115 | 111 | ++$i; |
116 | 112 | $elTypes[$i] = NULL; |
117 | 113 | } |
118 | - } |
|
119 | - elseif ( |
|
114 | + } elseif ( |
|
120 | 115 | ($c === '"') |
121 | 116 | || ($c === '\'') |
122 | 117 | ) { |
@@ -131,18 +126,15 @@ discard block |
||
131 | 126 | $elements[$i] = $string; |
132 | 127 | $elTypes[$i] = Daemon_ConfigParser::T_STRING; |
133 | 128 | } |
134 | - } |
|
135 | - elseif ($c === '}') { |
|
129 | + } elseif ($c === '}') { |
|
136 | 130 | $cfg->raiseError('Unexpected \'}\' instead of \';\' or \'{\''); |
137 | - } |
|
138 | - elseif ($c === ';') { |
|
131 | + } elseif ($c === ';') { |
|
139 | 132 | if ($newLineDetected) { |
140 | 133 | $this->raiseError('Unexpected new-line instead of \';\'', 'notice', $newLineDetected[0], $newLineDetected[1]); |
141 | 134 | } |
142 | 135 | $tokenType = Daemon_ConfigParser::T_VAR; |
143 | 136 | break; |
144 | - } |
|
145 | - elseif ($c === '{') { |
|
137 | + } elseif ($c === '{') { |
|
146 | 138 | $tokenType = Daemon_ConfigParser::T_BLOCK; |
147 | 139 | break; |
148 | 140 | } else { |
@@ -163,19 +155,16 @@ discard block |
||
163 | 155 | if (Daemon_ConfigParser::T_CVALUE === $v) { |
164 | 156 | if (ctype_digit($elements[$k])) { |
165 | 157 | $elements[$k] = (int) $elements[$k]; |
166 | - } |
|
167 | - elseif (is_numeric($elements[$k])) { |
|
158 | + } elseif (is_numeric($elements[$k])) { |
|
168 | 159 | $elements[$k] = (float) $elements[$k]; |
169 | 160 | } else { |
170 | 161 | $l = strtolower($elements[$k]); |
171 | 162 | |
172 | 163 | if (($l === 'true') || ($l === 'on')) { |
173 | 164 | $elements[$k] = true; |
174 | - } |
|
175 | - elseif (($l === 'false') || ($l === 'off')) { |
|
165 | + } elseif (($l === 'false') || ($l === 'off')) { |
|
176 | 166 | $elements[$k] = false; |
177 | - } |
|
178 | - elseif ($l === 'null') { |
|
167 | + } elseif ($l === 'null') { |
|
179 | 168 | $elements[$k] = null; |
180 | 169 | } |
181 | 170 | } |
@@ -183,8 +172,7 @@ discard block |
||
183 | 172 | } |
184 | 173 | if ($tokenType === 0) { |
185 | 174 | $cfg->raiseError('Expected \';\' or \'{\''); |
186 | - } |
|
187 | - elseif ($tokenType === Daemon_ConfigParser::T_VAR) { |
|
175 | + } elseif ($tokenType === Daemon_ConfigParser::T_VAR) { |
|
188 | 176 | $name = str_replace('-', '', strtolower($elements[0])); |
189 | 177 | $scope = $cfg->getCurrentScope(); |
190 | 178 | |
@@ -232,11 +220,9 @@ discard block |
||
232 | 220 | } |
233 | 221 | $scope->{$name}->setValue($elements[1]); |
234 | 222 | $scope->{$name}->setValueType($elTypes[1]); |
235 | - } |
|
236 | - else {$cfg->raiseError('Unrecognized parameter \''.$name.'\'');} |
|
223 | + } else {$cfg->raiseError('Unrecognized parameter \''.$name.'\'');} |
|
237 | 224 | } |
238 | - } |
|
239 | - elseif ($tokenType === Daemon_ConfigParser::T_BLOCK) { |
|
225 | + } elseif ($tokenType === Daemon_ConfigParser::T_BLOCK) { |
|
240 | 226 | $scope = $cfg->getCurrentScope(); |
241 | 227 | $sectionName = implode('-', $elements); |
242 | 228 | $sectionName = strtr($sectionName, '-. ', ':::'); |
@@ -277,14 +263,12 @@ discard block |
||
277 | 263 | unset($scope->{$name}); |
278 | 264 | } |
279 | 265 | } |
280 | - } |
|
281 | - elseif ($obj instanceof Daemon_ConfigSection) { |
|
266 | + } elseif ($obj instanceof Daemon_ConfigSection) { |
|
282 | 267 | |
283 | 268 | if ($obj->source === 'config' && ($obj->revision < $cfg->revision)) { |
284 | 269 | if (sizeof($obj) === 0) { |
285 | 270 | unset($scope->{$name}); |
286 | - } |
|
287 | - elseif (isset($obj->enable)) { |
|
271 | + } elseif (isset($obj->enable)) { |
|
288 | 272 | $obj->enable->setValue(FALSE); |
289 | 273 | } |
290 | 274 | } |