@@ -11,7 +11,7 @@ |
||
| 11 | 11 | public $busy = false; |
| 12 | 12 | public $timeout = 60; |
| 13 | 13 | |
| 14 | - public $onResponse; // stack of onResponse callbacks |
|
| 14 | + public $onResponse; // stack of onResponse callbacks |
|
| 15 | 15 | |
| 16 | 16 | public $alive = true; |
| 17 | 17 | |
@@ -41,8 +41,7 @@ |
||
| 41 | 41 | } |
| 42 | 42 | if ($this->busy) { |
| 43 | 43 | $this->pool->servConnFree[$this->url]->detach($this); |
| 44 | - } |
|
| 45 | - else { |
|
| 44 | + } else { |
|
| 46 | 45 | $this->pool->servConnFree[$this->url]->attach($this); |
| 47 | 46 | $this->release(); |
| 48 | 47 | } |
@@ -15,12 +15,12 @@ |
||
| 15 | 15 | if (Daemon::$process instanceof Daemon_MasterThread) { |
| 16 | 16 | if (Daemon::$config->autoreload->value > 0) { |
| 17 | 17 | if ($old) { |
| 18 | - $e = explode(';',$old); |
|
| 18 | + $e = explode(';', $old); |
|
| 19 | 19 | foreach ($e as $path) { |
| 20 | 20 | Daemon::$process->fileWatcher->rmWatch($path); |
| 21 | 21 | } |
| 22 | 22 | } |
| 23 | - $e = explode(';',$this->value); |
|
| 23 | + $e = explode(';', $this->value); |
|
| 24 | 24 | foreach ($e as $path) { |
| 25 | 25 | Daemon::$process->fileWatcher->addWatch($path, array(Daemon::$process, 'sighup')); |
| 26 | 26 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @return void |
| 42 | 42 | */ |
| 43 | 43 | public function set($key, $value, $exp = 0, $onResponse = NULL) { |
| 44 | - $this->getConnectionByKey($key, function ($conn) use ($key, $value, $exp, $onResponse) { |
|
| 44 | + $this->getConnectionByKey($key, function($conn) use ($key, $value, $exp, $onResponse) { |
|
| 45 | 45 | if (!$conn->connected) { |
| 46 | 46 | return; |
| 47 | 47 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * @return void |
| 65 | 65 | */ |
| 66 | 66 | public function add($key, $value, $exp = 0, $onResponse = NULL) { |
| 67 | - $this->getConnectionByKey($key, function ($conn) use ($key, $value, $exp, $onResponse) { |
|
| 67 | + $this->getConnectionByKey($key, function($conn) use ($key, $value, $exp, $onResponse) { |
|
| 68 | 68 | if (!$conn->connected) { |
| 69 | 69 | return; |
| 70 | 70 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * @return void |
| 86 | 86 | */ |
| 87 | 87 | public function delete($key, $onResponse = NULL, $time = 0) { |
| 88 | - $this->getConnectionByKey($key, function ($conn) use ($key, $time, $onResponse) { |
|
| 88 | + $this->getConnectionByKey($key, function($conn) use ($key, $time, $onResponse) { |
|
| 89 | 89 | if (!$conn->connected) { |
| 90 | 90 | return; |
| 91 | 91 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * @return void |
| 107 | 107 | */ |
| 108 | 108 | public function replace($key, $value, $exp = 0, $onResponse = NULL) { |
| 109 | - $this->getConnectionByKey($key, function ($conn) use ($key, $value, $exp, $onResponse) { |
|
| 109 | + $this->getConnectionByKey($key, function($conn) use ($key, $value, $exp, $onResponse) { |
|
| 110 | 110 | if (!$conn->connected) { |
| 111 | 111 | return; |
| 112 | 112 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * @return void |
| 129 | 129 | */ |
| 130 | 130 | public function append($key, $value, $exp = 0, $onResponse = NULL) { |
| 131 | - $this->getConnectionByKey($key, function ($conn) use ($key, $value, $exp, $onResponse) { |
|
| 131 | + $this->getConnectionByKey($key, function($conn) use ($key, $value, $exp, $onResponse) { |
|
| 132 | 132 | if (!$conn->connected) { |
| 133 | 133 | return; |
| 134 | 134 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | * @return void |
| 151 | 151 | */ |
| 152 | 152 | public function prepend($key, $value, $exp = 0, $onResponse = NULL) { |
| 153 | - $this->getConnectionByKey($key, function ($conn) use ($key, $value, $exp, $onResponse) { |
|
| 153 | + $this->getConnectionByKey($key, function($conn) use ($key, $value, $exp, $onResponse) { |
|
| 154 | 154 | if (!$conn->connected) { |
| 155 | 155 | return; |
| 156 | 156 | } |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | return; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - if (!empty($m[2])) { |
|
| 28 | + if (!empty($m[2])) { |
|
| 29 | 29 | $n = (float) $m[1]; |
| 30 | 30 | } else { |
| 31 | 31 | $n = (int) $m[1]; |
@@ -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); |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | |
| 19 | 19 | public function __construct($cb = null) { |
| 20 | 20 | $this->state = self::STATE_WAITING; |
| 21 | - if($cb !== null) { |
|
| 21 | + if ($cb !== null) { |
|
| 22 | 22 | $this->addListener($cb); |
| 23 | 23 | } |
| 24 | 24 | } |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | public function RPCall($method, $args) { |
| 33 | 33 | if ($method === 'registerPair') { |
| 34 | 34 | list ($local, $foreign, $user) = $args; |
| 35 | - $this->pairs[$local . ':' .$foreign] = $user; |
|
| 35 | + $this->pairs[$local . ':' . $foreign] = $user; |
|
| 36 | 36 | } |
| 37 | 37 | elseif ($method === 'unregisterPair') { |
| 38 | 38 | list ($local, $foreign) = $args; |
| 39 | - unset($this->pairs[$local . ':' .$foreign]); |
|
| 39 | + unset($this->pairs[$local . ':' . $foreign]); |
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | public function findPair($local, $foreign) { |
| 50 | 50 | return |
| 51 | - isset($this->pairs[$local . ':' .$foreign]) |
|
| 52 | - ? $this->pairs[$local . ':' .$foreign] |
|
| 51 | + isset($this->pairs[$local . ':' . $foreign]) |
|
| 52 | + ? $this->pairs[$local . ':' . $foreign] |
|
| 53 | 53 | : false; |
| 54 | 54 | } |
| 55 | 55 | } |
@@ -71,17 +71,17 @@ discard block |
||
| 71 | 71 | while (($line = $this->gets()) !== false) { |
| 72 | 72 | $e = explode(',', str_replace("\x20", '', $line = trim($line))); |
| 73 | 73 | if ((sizeof($e) <> 2) || !ctype_digit($e[0]) || !ctype_digit($e[1])) { |
| 74 | - $this->writeln($line. ' : ERROR : INVALID-PORT'); |
|
| 74 | + $this->writeln($line . ' : ERROR : INVALID-PORT'); |
|
| 75 | 75 | $this->finish(); |
| 76 | 76 | return; |
| 77 | 77 | } |
| 78 | 78 | $local = (int) $e[0]; |
| 79 | 79 | $foreign = (int) $e[1]; |
| 80 | 80 | if ($user = $this->pool->findPair($local, $foreign)) { |
| 81 | - $this->writeln($line. ' : USERID : ' . $user); |
|
| 81 | + $this->writeln($line . ' : USERID : ' . $user); |
|
| 82 | 82 | |
| 83 | 83 | } else { |
| 84 | - $this->writeln($line. ' : ERROR : NO-USER'); |
|
| 84 | + $this->writeln($line . ' : ERROR : NO-USER'); |
|
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | } |
@@ -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 | } |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | if ($this->isEnabled()) { |
| 28 | 28 | list ($class, $name) = explode(':', $this->name . ':'); |
| 29 | 29 | if (!class_exists($class)) { |
| 30 | - Daemon::log($class. ' class not exists.'); |
|
| 30 | + Daemon::log($class . ' class not exists.'); |
|
| 31 | 31 | return; |
| 32 | 32 | } |
| 33 | 33 | $this->pool = call_user_func(array($class, 'getInstance'), $name); |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | const STRING = 0x00; |
| 11 | 11 | const BINARY = 0x80; |
| 12 | 12 | |
| 13 | - public function onHandshake() { |
|
| 13 | + public function onHandshake() { |
|
| 14 | 14 | if (!isset($this->connection->server['HTTP_SEC_WEBSOCKET_KEY1']) || !isset($this->connection->server['HTTP_SEC_WEBSOCKET_KEY2'])) { |
| 15 | 15 | return false; |
| 16 | 16 | } |
@@ -18,13 +18,13 @@ discard block |
||
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | - * Returns handshaked data for reply |
|
| 21 | + * Returns handshaked data for reply |
|
| 22 | 22 | * @param string Received data (no use in this class) |
| 23 | - * @return string Handshaked data |
|
| 24 | - */ |
|
| 23 | + * @return string Handshaked data |
|
| 24 | + */ |
|
| 25 | 25 | |
| 26 | 26 | public function getHandshakeReply($data) { |
| 27 | - if ($this->onHandshake()) { |
|
| 27 | + if ($this->onHandshake()) { |
|
| 28 | 28 | if (strlen($data) < 8) { |
| 29 | 29 | return 0; // not enough data yet; |
| 30 | 30 | } |
@@ -34,27 +34,27 @@ discard block |
||
| 34 | 34 | return false; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - if (!isset($this->connection->server['HTTP_SEC_WEBSOCKET_ORIGIN'])) { |
|
| 38 | - $this->connection->server['HTTP_SEC_WEBSOCKET_ORIGIN'] = '' ; |
|
| 39 | - } |
|
| 37 | + if (!isset($this->connection->server['HTTP_SEC_WEBSOCKET_ORIGIN'])) { |
|
| 38 | + $this->connection->server['HTTP_SEC_WEBSOCKET_ORIGIN'] = '' ; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - $reply = "HTTP/1.1 101 Web Socket Protocol Handshake\r\n" |
|
| 42 | - . "Upgrade: WebSocket\r\n" |
|
| 43 | - . "Connection: Upgrade\r\n" |
|
| 44 | - . "Sec-WebSocket-Origin: " . $this->connection->server['HTTP_ORIGIN'] . "\r\n" |
|
| 45 | - . "Sec-WebSocket-Location: ws://" . $this->connection->server['HTTP_HOST'] . $this->connection->server['REQUEST_URI'] . "\r\n" ; |
|
| 41 | + $reply = "HTTP/1.1 101 Web Socket Protocol Handshake\r\n" |
|
| 42 | + . "Upgrade: WebSocket\r\n" |
|
| 43 | + . "Connection: Upgrade\r\n" |
|
| 44 | + . "Sec-WebSocket-Origin: " . $this->connection->server['HTTP_ORIGIN'] . "\r\n" |
|
| 45 | + . "Sec-WebSocket-Location: ws://" . $this->connection->server['HTTP_HOST'] . $this->connection->server['REQUEST_URI'] . "\r\n" ; |
|
| 46 | 46 | if ($this->connection->pool->config->expose->value) { |
| 47 | 47 | $reply .= 'X-Powered-By: phpDaemon/' . Daemon::$version . "\r\n"; |
| 48 | 48 | } |
| 49 | - if (isset($this->connection->server['HTTP_SEC_WEBSOCKET_PROTOCOL'])) { |
|
| 49 | + if (isset($this->connection->server['HTTP_SEC_WEBSOCKET_PROTOCOL'])) { |
|
| 50 | 50 | $reply .= "Sec-WebSocket-Protocol: " . $this->connection->server['HTTP_SEC_WEBSOCKET_PROTOCOL'] . "\r\n"; |
| 51 | - } |
|
| 52 | - $reply .= "\r\n" . $final_key; |
|
| 53 | - return $reply; |
|
| 54 | - } |
|
| 51 | + } |
|
| 52 | + $reply .= "\r\n" . $final_key; |
|
| 53 | + return $reply; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - return FALSE ; |
|
| 57 | - } |
|
| 56 | + return FALSE ; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * Computes final key for Sec-WebSocket. |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | return pack('N', $result); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - public function encodeFrame($data, $type) { |
|
| 109 | + public function encodeFrame($data, $type) { |
|
| 110 | 110 | // Binary |
| 111 | 111 | $type = $this->getFrameType($type); |
| 112 | 112 | if (($type & self::BINARY) === self::BINARY) |
@@ -139,9 +139,9 @@ discard block |
||
| 139 | 139 | { |
| 140 | 140 | return chr(self::STRING) . $data . "\xFF" ; |
| 141 | 141 | } |
| 142 | - } |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - public function onRead() { |
|
| 144 | + public function onRead() { |
|
| 145 | 145 | while ($this->connection && (($buflen = strlen($this->connection->buf)) >= 1)) { |
| 146 | 146 | $frametype = ord(binarySubstr($this->connection->buf, 0, 1)) ; |
| 147 | 147 | if (($frametype & 0x80) === 0x80) { |
@@ -193,5 +193,5 @@ discard block |
||
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | - } |
|
| 196 | + } |
|
| 197 | 197 | } |
| 198 | 198 | \ No newline at end of file |
@@ -28,21 +28,21 @@ discard block |
||
| 28 | 28 | if (strlen($data) < 8) { |
| 29 | 29 | return 0; // not enough data yet; |
| 30 | 30 | } |
| 31 | - $final_key = $this->_computeFinalKey($this->connection->server['HTTP_SEC_WEBSOCKET_KEY1'], $this->connection->server['HTTP_SEC_WEBSOCKET_KEY2'], $data) ; |
|
| 31 | + $final_key = $this->_computeFinalKey($this->connection->server['HTTP_SEC_WEBSOCKET_KEY1'], $this->connection->server['HTTP_SEC_WEBSOCKET_KEY2'], $data); |
|
| 32 | 32 | |
| 33 | 33 | if (!$final_key) { |
| 34 | 34 | return false; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | if (!isset($this->connection->server['HTTP_SEC_WEBSOCKET_ORIGIN'])) { |
| 38 | - $this->connection->server['HTTP_SEC_WEBSOCKET_ORIGIN'] = '' ; |
|
| 38 | + $this->connection->server['HTTP_SEC_WEBSOCKET_ORIGIN'] = ''; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | $reply = "HTTP/1.1 101 Web Socket Protocol Handshake\r\n" |
| 42 | 42 | . "Upgrade: WebSocket\r\n" |
| 43 | 43 | . "Connection: Upgrade\r\n" |
| 44 | 44 | . "Sec-WebSocket-Origin: " . $this->connection->server['HTTP_ORIGIN'] . "\r\n" |
| 45 | - . "Sec-WebSocket-Location: ws://" . $this->connection->server['HTTP_HOST'] . $this->connection->server['REQUEST_URI'] . "\r\n" ; |
|
| 45 | + . "Sec-WebSocket-Location: ws://" . $this->connection->server['HTTP_HOST'] . $this->connection->server['REQUEST_URI'] . "\r\n"; |
|
| 46 | 46 | if ($this->connection->pool->config->expose->value) { |
| 47 | 47 | $reply .= 'X-Powered-By: phpDaemon/' . Daemon::$version . "\r\n"; |
| 48 | 48 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | return $reply; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - return FALSE ; |
|
| 56 | + return FALSE; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | protected function _computeFinalKey($key1, $key2, $data) { |
| 68 | 68 | if (strlen($data) < 8) |
| 69 | 69 | { |
| 70 | - Daemon::$process->log(get_class($this) . '::' . __METHOD__ . ' : Invalid handshake data for client "' . $this->connection->addr . '"') ; |
|
| 71 | - return FALSE ; |
|
| 70 | + Daemon::$process->log(get_class($this) . '::' . __METHOD__ . ' : Invalid handshake data for client "' . $this->connection->addr . '"'); |
|
| 71 | + return FALSE; |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - $bodyData = binarySubstr($data, 0, 8) ; |
|
| 74 | + $bodyData = binarySubstr($data, 0, 8); |
|
| 75 | 75 | |
| 76 | - return md5($this->_computeKey($key1) . $this->_computeKey($key2) . binarySubstr($data, 0, 8), TRUE) ; |
|
| 76 | + return md5($this->_computeKey($key1) . $this->_computeKey($key2) . binarySubstr($data, 0, 8), TRUE); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -132,61 +132,61 @@ discard block |
||
| 132 | 132 | goto char; |
| 133 | 133 | }; |
| 134 | 134 | |
| 135 | - return chr(self::BINARY) . $len . $data ; |
|
| 135 | + return chr(self::BINARY) . $len . $data; |
|
| 136 | 136 | } |
| 137 | 137 | // String |
| 138 | 138 | else |
| 139 | 139 | { |
| 140 | - return chr(self::STRING) . $data . "\xFF" ; |
|
| 140 | + return chr(self::STRING) . $data . "\xFF"; |
|
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | public function onRead() { |
| 145 | 145 | while ($this->connection && (($buflen = strlen($this->connection->buf)) >= 1)) { |
| 146 | - $frametype = ord(binarySubstr($this->connection->buf, 0, 1)) ; |
|
| 146 | + $frametype = ord(binarySubstr($this->connection->buf, 0, 1)); |
|
| 147 | 147 | if (($frametype & 0x80) === 0x80) { |
| 148 | - $len = 0 ; |
|
| 149 | - $i = 0 ; |
|
| 148 | + $len = 0; |
|
| 149 | + $i = 0; |
|
| 150 | 150 | |
| 151 | 151 | do { |
| 152 | 152 | $b = ord(binarySubstr($this->connection->buf, ++$i, 1)); |
| 153 | - $n = $b & 0x7F ; |
|
| 154 | - $len *= 0x80 ; |
|
| 155 | - $len += $n ; |
|
| 156 | - } while ($b > 0x80) ; |
|
| 153 | + $n = $b & 0x7F; |
|
| 154 | + $len *= 0x80; |
|
| 155 | + $len += $n; |
|
| 156 | + } while ($b > 0x80); |
|
| 157 | 157 | |
| 158 | 158 | if ($this->connection->pool->maxAllowedPacket <= $len) { |
| 159 | 159 | // Too big packet |
| 160 | 160 | $this->connection->finish(); |
| 161 | - return FALSE ; |
|
| 161 | + return FALSE; |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - if ($buflen < $len + 2) { |
|
| 164 | + if ($buflen < $len + 2) { |
|
| 165 | 165 | // not enough data yet |
| 166 | - return FALSE ; |
|
| 166 | + return FALSE; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - $decodedData = binarySubstr($this->connection->buf, 2, $len) ; |
|
| 170 | - $this->connection->buf = binarySubstr($this->connection->buf, 2 + $len) ; |
|
| 169 | + $decodedData = binarySubstr($this->connection->buf, 2, $len); |
|
| 170 | + $this->connection->buf = binarySubstr($this->connection->buf, 2 + $len); |
|
| 171 | 171 | $this->connection->onFrame($decodedData, 'BINARY'); |
| 172 | 172 | } |
| 173 | 173 | else { |
| 174 | 174 | if (($p = strpos($this->connection->buf, "\xFF")) !== FALSE) { |
| 175 | 175 | if ($this->connection->pool->maxAllowedPacket <= $p - 1) { |
| 176 | 176 | // Too big packet |
| 177 | - $this->connection->finish() ; |
|
| 178 | - return FALSE ; |
|
| 177 | + $this->connection->finish(); |
|
| 178 | + return FALSE; |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - $decodedData = binarySubstr($this->connection->buf, 1, $p - 1) ; |
|
| 182 | - $this->connection->buf = binarySubstr($this->connection->buf, $p + 1) ; |
|
| 181 | + $decodedData = binarySubstr($this->connection->buf, 1, $p - 1); |
|
| 182 | + $this->connection->buf = binarySubstr($this->connection->buf, $p + 1); |
|
| 183 | 183 | $this->connection->onFrame($decodedData, 'STRING'); |
| 184 | 184 | } |
| 185 | 185 | else { |
| 186 | 186 | if ($this->connection->pool->maxAllowedPacket <= $buflen - 1) { |
| 187 | 187 | // Too big packet |
| 188 | - $this->connection->finish() ; |
|
| 189 | - return FALSE ; |
|
| 188 | + $this->connection->finish(); |
|
| 189 | + return FALSE; |
|
| 190 | 190 | } |
| 191 | 191 | // not enough data yet |
| 192 | 192 | return; |
@@ -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() ; |
@@ -8,54 +8,54 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | class MySQLClient extends NetworkClient { |
| 10 | 10 | |
| 11 | - const CLIENT_LONG_PASSWORD = 1; // new more secure passwords |
|
| 12 | - const CLIENT_FOUND_ROWS = 2; // Found instead of affected rows |
|
| 13 | - const CLIENT_LONG_FLAG = 4; // Get all column flags |
|
| 14 | - const CLIENT_CONNECT_WITH_DB = 8; // One can specify db on connect |
|
| 15 | - const CLIENT_NO_SCHEMA = 16; // Don't allow database.table.column |
|
| 16 | - const CLIENT_COMPRESS = 32; // Can use compression protocol |
|
| 17 | - const CLIENT_ODBC = 64; // Odbc client |
|
| 18 | - const CLIENT_LOCAL_FILES = 128; // Can use LOAD DATA LOCAL |
|
| 19 | - const CLIENT_IGNORE_SPACE = 256; // Ignore spaces before '(' |
|
| 20 | - const CLIENT_PROTOCOL_41 = 512; // New 4.1 protocol |
|
| 21 | - const CLIENT_INTERACTIVE = 1024; // This is an interactive client |
|
| 22 | - const CLIENT_SSL = 2048; // Switch to SSL after handshake |
|
| 23 | - const CLIENT_IGNORE_SIGPIPE = 4096; // IGNORE sigpipes |
|
| 24 | - const CLIENT_TRANSACTIONS = 8192; // Client knows about transactions |
|
| 25 | - const CLIENT_RESERVED = 16384; // Old flag for 4.1 protocol |
|
| 26 | - const CLIENT_SECURE_CONNECTION = 32768; // New 4.1 authentication |
|
| 27 | - const CLIENT_MULTI_STATEMENTS = 65536; // Enable/disable multi-stmt support |
|
| 28 | - const CLIENT_MULTI_RESULTS = 131072; // Enable/disable multi-results |
|
| 11 | + const CLIENT_LONG_PASSWORD = 1; // new more secure passwords |
|
| 12 | + const CLIENT_FOUND_ROWS = 2; // Found instead of affected rows |
|
| 13 | + const CLIENT_LONG_FLAG = 4; // Get all column flags |
|
| 14 | + const CLIENT_CONNECT_WITH_DB = 8; // One can specify db on connect |
|
| 15 | + const CLIENT_NO_SCHEMA = 16; // Don't allow database.table.column |
|
| 16 | + const CLIENT_COMPRESS = 32; // Can use compression protocol |
|
| 17 | + const CLIENT_ODBC = 64; // Odbc client |
|
| 18 | + const CLIENT_LOCAL_FILES = 128; // Can use LOAD DATA LOCAL |
|
| 19 | + const CLIENT_IGNORE_SPACE = 256; // Ignore spaces before '(' |
|
| 20 | + const CLIENT_PROTOCOL_41 = 512; // New 4.1 protocol |
|
| 21 | + const CLIENT_INTERACTIVE = 1024; // This is an interactive client |
|
| 22 | + const CLIENT_SSL = 2048; // Switch to SSL after handshake |
|
| 23 | + const CLIENT_IGNORE_SIGPIPE = 4096; // IGNORE sigpipes |
|
| 24 | + const CLIENT_TRANSACTIONS = 8192; // Client knows about transactions |
|
| 25 | + const CLIENT_RESERVED = 16384; // Old flag for 4.1 protocol |
|
| 26 | + const CLIENT_SECURE_CONNECTION = 32768; // New 4.1 authentication |
|
| 27 | + const CLIENT_MULTI_STATEMENTS = 65536; // Enable/disable multi-stmt support |
|
| 28 | + const CLIENT_MULTI_RESULTS = 131072; // Enable/disable multi-results |
|
| 29 | 29 | |
| 30 | - const COM_SLEEP = 0x00; // (none, this is an internal thread state) |
|
| 31 | - const COM_QUIT = 0x01; // mysql_close |
|
| 32 | - const COM_INIT_DB = 0x02; // mysql_select_db |
|
| 33 | - const COM_QUERY = 0x03; // mysql_real_query |
|
| 34 | - const COM_FIELD_LIST = 0x04; // mysql_list_fields |
|
| 35 | - const COM_CREATE_DB = 0x05; // mysql_create_db (deprecated) |
|
| 36 | - const COM_DROP_DB = 0x06; // mysql_drop_db (deprecated) |
|
| 37 | - const COM_REFRESH = 0x07; // mysql_refresh |
|
| 38 | - const COM_SHUTDOWN = 0x08; // mysql_shutdown |
|
| 39 | - const COM_STATISTICS = 0x09; // mysql_stat |
|
| 40 | - const COM_PROCESS_INFO = 0x0a; // mysql_list_processes |
|
| 41 | - const COM_CONNECT = 0x0b; // (none, this is an internal thread state) |
|
| 42 | - const COM_PROCESS_KILL = 0x0c; // mysql_kill |
|
| 43 | - const COM_DEBUG = 0x0d; // mysql_dump_debug_info |
|
| 44 | - const COM_PING = 0x0e; // mysql_ping |
|
| 45 | - const COM_TIME = 0x0f; // (none, this is an internal thread state) |
|
| 46 | - const COM_DELAYED_INSERT = 0x10; // (none, this is an internal thread state) |
|
| 47 | - const COM_CHANGE_USER = 0x11; // mysql_change_user |
|
| 48 | - const COM_BINLOG_DUMP = 0x12; // sent by the slave IO thread to request a binlog |
|
| 49 | - const COM_TABLE_DUMP = 0x13; // LOAD TABLE ... FROM MASTER (deprecated) |
|
| 50 | - const COM_CONNECT_OUT = 0x14; // (none, this is an internal thread state) |
|
| 51 | - const COM_REGISTER_SLAVE = 0x15; // sent by the slave to register with the master (optional) |
|
| 52 | - const COM_STMT_PREPARE = 0x16; // mysql_stmt_prepare |
|
| 53 | - const COM_STMT_EXECUTE = 0x17; // mysql_stmt_execute |
|
| 54 | - const COM_STMT_SEND_LONG_DATA = 0x18; // mysql_stmt_send_long_data |
|
| 55 | - const COM_STMT_CLOSE = 0x19; // mysql_stmt_close |
|
| 56 | - const COM_STMT_RESET = 0x1a; // mysql_stmt_reset |
|
| 57 | - const COM_SET_OPTION = 0x1b; // mysql_set_server_option |
|
| 58 | - const COM_STMT_FETCH = 0x1c; // mysql_stmt_fetch |
|
| 30 | + const COM_SLEEP = 0x00; // (none, this is an internal thread state) |
|
| 31 | + const COM_QUIT = 0x01; // mysql_close |
|
| 32 | + const COM_INIT_DB = 0x02; // mysql_select_db |
|
| 33 | + const COM_QUERY = 0x03; // mysql_real_query |
|
| 34 | + const COM_FIELD_LIST = 0x04; // mysql_list_fields |
|
| 35 | + const COM_CREATE_DB = 0x05; // mysql_create_db (deprecated) |
|
| 36 | + const COM_DROP_DB = 0x06; // mysql_drop_db (deprecated) |
|
| 37 | + const COM_REFRESH = 0x07; // mysql_refresh |
|
| 38 | + const COM_SHUTDOWN = 0x08; // mysql_shutdown |
|
| 39 | + const COM_STATISTICS = 0x09; // mysql_stat |
|
| 40 | + const COM_PROCESS_INFO = 0x0a; // mysql_list_processes |
|
| 41 | + const COM_CONNECT = 0x0b; // (none, this is an internal thread state) |
|
| 42 | + const COM_PROCESS_KILL = 0x0c; // mysql_kill |
|
| 43 | + const COM_DEBUG = 0x0d; // mysql_dump_debug_info |
|
| 44 | + const COM_PING = 0x0e; // mysql_ping |
|
| 45 | + const COM_TIME = 0x0f; // (none, this is an internal thread state) |
|
| 46 | + const COM_DELAYED_INSERT = 0x10; // (none, this is an internal thread state) |
|
| 47 | + const COM_CHANGE_USER = 0x11; // mysql_change_user |
|
| 48 | + const COM_BINLOG_DUMP = 0x12; // sent by the slave IO thread to request a binlog |
|
| 49 | + const COM_TABLE_DUMP = 0x13; // LOAD TABLE ... FROM MASTER (deprecated) |
|
| 50 | + const COM_CONNECT_OUT = 0x14; // (none, this is an internal thread state) |
|
| 51 | + const COM_REGISTER_SLAVE = 0x15; // sent by the slave to register with the master (optional) |
|
| 52 | + const COM_STMT_PREPARE = 0x16; // mysql_stmt_prepare |
|
| 53 | + const COM_STMT_EXECUTE = 0x17; // mysql_stmt_execute |
|
| 54 | + const COM_STMT_SEND_LONG_DATA = 0x18; // mysql_stmt_send_long_data |
|
| 55 | + const COM_STMT_CLOSE = 0x19; // mysql_stmt_close |
|
| 56 | + const COM_STMT_RESET = 0x1a; // mysql_stmt_reset |
|
| 57 | + const COM_SET_OPTION = 0x1b; // mysql_set_server_option |
|
| 58 | + const COM_STMT_FETCH = 0x1c; // mysql_stmt_fetch |
|
| 59 | 59 | |
| 60 | 60 | const FIELD_TYPE_DECIMAL = 0x00; |
| 61 | 61 | const FIELD_TYPE_TINY = 0x01; |