Completed
Push — 123 ( d13f38 )
by Vasily
05:11
created
lib/BoundSocket.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
69 69
 		}
70 70
 	}
71 71
 	
72
-	public function onListenerAcceptedEvent($listener, $fd, $addrPort, $ctx)  {
72
+	public function onListenerAcceptedEvent($listener, $fd, $addrPort, $ctx) {
73 73
 		$class = $this->pool->connectionClass;
74 74
 		$conn = new $class($fd, $this->pool);
75
-		$conn->addr = $addrPort[0].':'.$addrPort[1];
75
+		$conn->addr = $addrPort[0] . ':' . $addrPort[1];
76 76
 		$conn->host = $addrPort[0];
77 77
 		$conn->port = $addrPort[1];
78 78
 	}
@@ -179,12 +179,12 @@  discard block
 block discarded – undo
179 179
 			return FALSE;
180 180
 		}
181 181
 
182
-		$e = explode ('/', $CIDR, 2);
182
+		$e = explode('/', $CIDR, 2);
183 183
 
184 184
 		if (!isset($e[1])) {
185 185
 			return $e[0] === $IP;
186 186
 		}
187 187
 
188
-		return (ip2long ($IP) & ~((1 << (32 - $e[1])) - 1)) === ip2long($e[0]);
188
+		return (ip2long($IP) & ~((1 << (32 - $e[1])) - 1)) === ip2long($e[0]);
189 189
 	}
190 190
 }
Please login to merge, or discard this patch.
lib/XMPPClient.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
 		$this->write($s);
73 73
 	}
74 74
 	public function startXMLStream() {
75
-		$this->sendXML('<?xml version="1.0"?>'.
76
-			'<stream:stream xmlns:stream="http://etherx.jabber.org/streams" version="1.0" xmlns="jabber:client" to="'.$this->host.'" xml:lang="en" xmlns:xml="http://www.w3.org/XML/1998/namespace">'
75
+		$this->sendXML('<?xml version="1.0"?>' .
76
+			'<stream:stream xmlns:stream="http://etherx.jabber.org/streams" version="1.0" xmlns="jabber:client" to="' . $this->host . '" xml:lang="en" xmlns:xml="http://www.w3.org/XML/1998/namespace">'
77 77
 		);
78 78
 	}
79 79
 	public function iqSet($xml, $cb) {
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 		}
83 83
 		$id = $this->getId();
84 84
 		$this->xml->addIdHandler($id, $cb);
85
-		$this->sendXML('<iq xmlns="jabber:client" type="set" id="'.$id.'">'.$xml.'</iq>');
85
+		$this->sendXML('<iq xmlns="jabber:client" type="set" id="' . $id . '">' . $xml . '</iq>');
86 86
 		return true;
87 87
 	}
88 88
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		}
93 93
 		$id = $this->getId();
94 94
 		$this->xml->addIdHandler($id, $cb);
95
-		$this->sendXML('<iq xmlns="jabber:client" type="set" id="'.$id.'" to="'.htmlspecialchars($to).'">'.$xml.'</iq>');
95
+		$this->sendXML('<iq xmlns="jabber:client" type="set" id="' . $id . '" to="' . htmlspecialchars($to) . '">' . $xml . '</iq>');
96 96
 		return true;
97 97
 
98 98
 	}
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 		}
104 104
 		$id = $this->getId();
105 105
 		$this->xml->addIdHandler($id, $cb);
106
-		$this->sendXML('<iq xmlns="jabber:client" type="get" id="'.$id.'">'.$xml.'</iq>');
106
+		$this->sendXML('<iq xmlns="jabber:client" type="get" id="' . $id . '">' . $xml . '</iq>');
107 107
 		return true;
108 108
 	}
109 109
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		}
114 114
 		$id = $this->getId();
115 115
 		$this->xml->addIdHandler($id, $cb);
116
-		$this->sendXML('<iq xmlns="jabber:client" type="get" id="'.$id.'" to="'.htmlspecialchars($to).'">'.$xml.'</iq>');
116
+		$this->sendXML('<iq xmlns="jabber:client" type="get" id="' . $id . '" to="' . htmlspecialchars($to) . '">' . $xml . '</iq>');
117 117
 		return true;
118 118
 
119 119
 	}
@@ -130,16 +130,16 @@  discard block
 block discarded – undo
130 130
 	}
131 131
 
132 132
 	public function queryGet($ns, $cb) {
133
-		return $this->iqGet('<query xmlns="'.$ns.'" />', $cb);
133
+		return $this->iqGet('<query xmlns="' . $ns . '" />', $cb);
134 134
 	}
135 135
 
136 136
 
137 137
 	public function querySet($ns, $xml, $cb) {
138
-		return $this->iqSet('<query xmlns="'.$ns.'">'.$xml.'</query>', $cb);
138
+		return $this->iqSet('<query xmlns="' . $ns . '">' . $xml . '</query>', $cb);
139 139
 	}
140 140
 
141 141
 	public function querySetTo($to, $ns, $xml, $cb) {
142
-		return $this->iqSetTo($to, '<query xmlns="'.$ns.'">'.$xml.'</query>', $cb);
142
+		return $this->iqSetTo($to, '<query xmlns="' . $ns . '">' . $xml . '</query>', $cb);
143 143
 	}
144 144
 
145 145
 	public function createXMLStream() {
@@ -147,15 +147,15 @@  discard block
 block discarded – undo
147 147
 		$this->xml->setDefaultNS('jabber:client');
148 148
 		$this->xml->conn = $this;
149 149
 		$conn = $this;
150
-		$this->xml->addXPathHandler('{http://etherx.jabber.org/streams}features', function ($xml) use ($conn) {
150
+		$this->xml->addXPathHandler('{http://etherx.jabber.org/streams}features', function($xml) use ($conn) {
151 151
 			if ($xml->hasSub('starttls') and $this->use_encryption) {
152 152
 				$conn->sendXML("<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'><required /></starttls>");
153 153
 			} elseif ($xml->hasSub('bind') and $this->authorized) {
154 154
 				$id = $this->getId();
155
-				$this->iqSet('<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><resource>'.$this->path.'</resource></bind>', function ($xml) use ($conn) {
156
-					if($xml->attrs['type'] == 'result') {
155
+				$this->iqSet('<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><resource>' . $this->path . '</resource></bind>', function($xml) use ($conn) {
156
+					if ($xml->attrs['type'] == 'result') {
157 157
 						$conn->fulljid = $xml->sub('bind')->sub('jid')->data;
158
-						$jidarray = explode('/',$this->fulljid);
158
+						$jidarray = explode('/', $this->fulljid);
159 159
 						$conn->jid = $jidarray[0];
160 160
 					}
161 161
 					$conn->iqSet('<session xmlns="urn:ietf:params:xml:ns:xmpp-session" />', function($xml) use ($conn) {
@@ -176,13 +176,13 @@  discard block
 block discarded – undo
176 176
 				}	
177 177
 			}
178 178
 		});
179
-		$this->xml->addXPathHandler('{urn:ietf:params:xml:ns:xmpp-sasl}success', function ($xml) {
179
+		$this->xml->addXPathHandler('{urn:ietf:params:xml:ns:xmpp-sasl}success', function($xml) {
180 180
 			$this->authorized = true;
181 181
 			$this->xml->finish();
182 182
 			$this->createXMLStream();
183 183
 			$this->startXMLStream();
184 184
 		});
185
-		$this->xml->addXPathHandler('{urn:ietf:params:xml:ns:xmpp-sasl}failure', function ($xml) {
185
+		$this->xml->addXPathHandler('{urn:ietf:params:xml:ns:xmpp-sasl}failure', function($xml) {
186 186
 			if ($this->onConnected) {
187 187
 				$this->connected = false;
188 188
 				call_user_func($this->onConnected, $this);
@@ -190,11 +190,11 @@  discard block
 block discarded – undo
190 190
 			}
191 191
 			$this->finish();
192 192
 		});
193
-		$this->xml->addXPathHandler('{urn:ietf:params:xml:ns:xmpp-tls}proceed', function ($xml) {
193
+		$this->xml->addXPathHandler('{urn:ietf:params:xml:ns:xmpp-tls}proceed', function($xml) {
194 194
 			Daemon::log("XMPPClient: TLS not supported.");
195 195
 		});
196 196
 		$this->xml->addXPathHandler('{jabber:client}message', function($xml) {
197
-			if( isset($xml->attrs['type'])) {
197
+			if (isset($xml->attrs['type'])) {
198 198
 				$payload['type'] = $xml->attrs['type'];
199 199
 			} else {
200 200
 				$payload['type'] = 'chat';
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
 		$body	= htmlspecialchars($body);
243 243
 		$subject = htmlspecialchars($subject);
244 244
 		
245
-		$out = '<message from="'.$this->fulljid.'" to="'.$to.'" type="'.$type.'">';
246
-		if($subject) {
247
-			$out .= '<subject>'.$subject.'</subject>';
245
+		$out = '<message from="' . $this->fulljid . '" to="' . $to . '" type="' . $type . '">';
246
+		if ($subject) {
247
+			$out .= '<subject>' . $subject . '</subject>';
248 248
 		}
249
-		$out .= '<body>'.$body.'</body>';
249
+		$out .= '<body>' . $body . '</body>';
250 250
 		if ($payload) {
251 251
 			$out .= $payload;
252 252
 		}
@@ -262,19 +262,19 @@  discard block
 block discarded – undo
262 262
 	 * @param string $show
263 263
 	 * @param string $to
264 264
 	 */
265
-	public function presence($status = null, $show = 'available', $to = null, $type='available', $priority = 0 ) {
266
-		if($type == 'available') $type = '';
267
-		$to	 = htmlspecialchars($to);
265
+	public function presence($status = null, $show = 'available', $to = null, $type = 'available', $priority = 0) {
266
+		if ($type == 'available') $type = '';
267
+		$to = htmlspecialchars($to);
268 268
 		$status = htmlspecialchars($status);
269
-		if($show == 'unavailable') $type = 'unavailable';
269
+		if ($show == 'unavailable') $type = 'unavailable';
270 270
 		
271 271
 		$out = "<presence";
272
-		$out .= ' from="'.$this->fulljid.'"';
272
+		$out .= ' from="' . $this->fulljid . '"';
273 273
 		if ($to) {
274
-			$out .= ' to="'.$to.'"';
274
+			$out .= ' to="' . $to . '"';
275 275
 		}
276 276
 		if ($type) {
277
-			$out .= ' type="'.$type.'"';
277
+			$out .= ' type="' . $type . '"';
278 278
 		}
279 279
 		$inner = '';
280 280
 		if ($show != 'available') {
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 
298 298
 	public function getVCard($jid = null, $cb) {
299 299
 		$id = $this->getId();
300
-		$this->xml->addIdHandler($id, function ($xml) use ($cb) {
300
+		$this->xml->addIdHandler($id, function($xml) use ($cb) {
301 301
 			$vcard = array();
302 302
 			$vcardXML = $xml->sub('vcard');
303 303
 			foreach ($vcardXML->subs as $sub) {
@@ -313,10 +313,10 @@  discard block
 block discarded – undo
313 313
 			$vcard['from'] = $xml->attrs['from'];
314 314
 			call_user_func($cb, $vcard);
315 315
 		});
316
-		if($jid) {
317
-			$this->send('<iq type="get" id="'.$id.'" to="'.$jid.'"><vCard xmlns="vcard-temp" /></iq>');
316
+		if ($jid) {
317
+			$this->send('<iq type="get" id="' . $id . '" to="' . $jid . '"><vCard xmlns="vcard-temp" /></iq>');
318 318
 		} else {
319
-			$this->send('<iq type="get" id="'.$id.'"><vCard xmlns="vcard-temp" /></iq>');
319
+			$this->send('<iq type="get" id="' . $id . '"><vCard xmlns="vcard-temp" /></iq>');
320 320
 		}
321 321
 	}
322 322
 
Please login to merge, or discard this patch.
lib/Daemon_Config.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	public $configfile     = '/etc/phpdaemon/phpd.conf;/etc/phpd/phpd.conf;./conf/phpd.conf';
21 21
 	public $path           = '/etc/phpdaemon/AppResolver.php;./conf/AppResolver.php';
22 22
 	public $appfilepath    = '{app-*,applications}/%s.php';
23
-	public $autoload   	 	= NULL;
23
+	public $autoload = NULL;
24 24
 			
25 25
 	// Master-related
26 26
 	public $mpmdelay        = '0.1s';
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 		static $sizes = array('maxmemoryusage');
77 77
 		static $times = array('maxidle', 'autoreload', 'mpmdelay', 'eiosetmaxpolltime');
78 78
 		static $numbers = array(
79
-			'maxrequests', 'autogc','minworkers','maxworkers','minspareworkers','maxspareworkers','masterpriority', 'ipcthreadpriority',
79
+			'maxrequests', 'autogc', 'minworkers', 'maxworkers', 'minspareworkers', 'maxspareworkers', 'masterpriority', 'ipcthreadpriority',
80 80
 			'eiosetmaxidle', 'eiosetmaxparallel', 'eiosetmaxpollreqs', 'eiosetminparallel', 'verbose', 'verbosetty'
81 81
 		);
82 82
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	}
104 104
 
105 105
 	public function loadFile($path) {
106
-		$parser = new Daemon_ConfigParser($path,$this);
106
+		$parser = new Daemon_ConfigParser($path, $this);
107 107
 		$this->onLoad();
108 108
 		return !$parser->errorneus;
109 109
 	}
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		return isset($this->{$offset}) ? $this->{$offset}->value : NULL;
144 144
 	}
145 145
 	
146
-	public function offsetSet($offset,$value) {
146
+	public function offsetSet($offset, $value) {
147 147
 		$offset = $this->getRealOffsetName($offset);
148 148
 
149 149
 		$this->{$offset} = $value;
Please login to merge, or discard this patch.
lib/Daemon_ConfigEntryTime.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
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];
Please login to merge, or discard this patch.
lib/ComplexJob.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
lib/WebSocketProtocolV13.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	const BINARY = 0x2;
13 13
 	const CONNCLOSE = 0x8;
14 14
 	const PING = 0x9;
15
-	const PONG = 0xA ;
15
+	const PONG = 0xA;
16 16
 	public $opcodes;
17 17
 	public $outgoingCompression = 0;
18 18
 		
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
 		);
29 29
 	}
30 30
 
31
-	public function onHandshake(){
32
-        if (!isset($this->connection->server['HTTP_SEC_WEBSOCKET_KEY'])	|| !isset($this->connection->server['HTTP_SEC_WEBSOCKET_VERSION'])) {
31
+	public function onHandshake() {
32
+        if (!isset($this->connection->server['HTTP_SEC_WEBSOCKET_KEY']) || !isset($this->connection->server['HTTP_SEC_WEBSOCKET_VERSION'])) {
33 33
 			return false;
34 34
 		}
35 35
 		if ($this->connection->server['HTTP_SEC_WEBSOCKET_VERSION'] != '13' && $this->connection->server['HTTP_SEC_WEBSOCKET_VERSION'] != '8') {
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
 			}
53 53
             if (!isset($this->connection->server['HTTP_SEC_WEBSOCKET_ORIGIN']))
54 54
 			{
55
-                $this->connection->server['HTTP_SEC_WEBSOCKET_ORIGIN'] = '' ;
55
+                $this->connection->server['HTTP_SEC_WEBSOCKET_ORIGIN'] = '';
56 56
             }
57 57
             $reply = "HTTP/1.1 101 Switching Protocols\r\n"
58 58
                 . "Upgrade: WebSocket\r\n"
59 59
                 . "connection: Upgrade\r\n"
60
-                . "Date: ".date('r')."\r\n"
60
+                . "Date: " . date('r') . "\r\n"
61 61
                 . "Sec-WebSocket-Origin: " . $this->connection->server['HTTP_SEC_WEBSOCKET_ORIGIN'] . "\r\n"
62 62
                 . "Sec-WebSocket-Location: ws://" . $this->connection->server['HTTP_HOST'] . $this->connection->server['REQUEST_URI'] . "\r\n"
63 63
                 . "Sec-WebSocket-Accept: " . base64_encode(sha1(trim($this->connection->server['HTTP_SEC_WEBSOCKET_KEY']) . "258EAFA5-E914-47DA-95CA-C5AB0DC85B11", true)) . "\r\n";
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 			}
72 72
 
73 73
             $reply .= "\r\n";
74
-            return $reply ;
74
+            return $reply;
75 75
         }
76 76
 
77 77
 		return false;
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
     }
97 97
 
98 98
 	protected function encodeFragment($data, $type, $fin = 1, $rsv1 = 0, $rsv2 = 0, $rsv3 = 0) {
99
-        $mask =	chr(rand(0, 0xFF)) .
99
+        $mask = chr(rand(0, 0xFF)) .
100 100
  						chr(rand(0, 0xFF)) . 
101 101
 						chr(rand(0, 0xFF)) . 
102
-						chr(rand(0, 0xFF)) ;
102
+						chr(rand(0, 0xFF));
103 103
 		$packet = chr(bindec($fin . $rsv1 . $rsv2 . $rsv3 . str_pad(decbin($this->getFrameType($type)), 4, '0', STR_PAD_LEFT)));
104 104
         $dataLength = strlen($data);
105 105
 		$isMasked = false;
@@ -110,31 +110,31 @@  discard block
 block discarded – undo
110 110
         }
111 111
         elseif ($dataLength <= 65535)
112 112
         {
113
-            $packet .=	chr(126 + $isMaskedInt) . // 126 + 128
113
+            $packet .= chr(126 + $isMaskedInt) . // 126 + 128
114 114
             			chr($dataLength >> 8) .
115 115
             			chr($dataLength & 0xFF);
116 116
         }
117 117
         else {
118
-            $packet .=	chr(127 + $isMaskedInt) . // 127 + 128
118
+            $packet .= chr(127 + $isMaskedInt) . // 127 + 128
119 119
              			chr($dataLength >> 56) .
120 120
            				chr($dataLength >> 48) .
121 121
             			chr($dataLength >> 40) .
122 122
              			chr($dataLength >> 32) .
123 123
              			chr($dataLength >> 24) .
124 124
              			chr($dataLength >> 16) .
125
-               			chr($dataLength >>  8) .
125
+               			chr($dataLength >> 8) .
126 126
              			chr($dataLength & 0xFF);
127 127
         }
128 128
         if ($isMasked) { 
129
-        	$packet .=	$mask . $this->mask($data, $mask);
129
+        	$packet .= $mask . $this->mask($data, $mask);
130 130
 		} else {
131 131
  			$packet .= $data;
132 132
 		}
133 133
 		return $packet;
134 134
 	}
135
-	public function mask ($data, $mask) {
135
+	public function mask($data, $mask) {
136 136
    		for ($i = 0, $l = strlen($data), $ml = strlen($mask); $i < $l; $i++) {
137
-	     	$data[$i] = $data[$i] ^ $mask[$i % $ml] ;
137
+	     	$data[$i] = $data[$i] ^ $mask[$i % $ml];
138 138
 	     }
139 139
 		return $data;
140 140
 	}
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 		$dec = 0;
154 154
 		$len = strlen($str);
155 155
 		
156
-		for($i = 0; $i < $len; ++$i) {
156
+		for ($i = 0; $i < $len; ++$i) {
157 157
 			$dec += ord(binarySubstr($str, $i, 1)) * pow(0x100, $len - $i - 1);
158 158
 		}
159 159
 		
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 
173 173
 		if ($len === NULL) {
174 174
 			if (strlen($hexstr) % 2) {
175
-				$hexstr = "0".$hexstr;
175
+				$hexstr = "0" . $hexstr;
176 176
 			}
177 177
 		} else {
178 178
 			$hexstr = str_repeat('0', $len * 2 - strlen($hexstr)) . $hexstr;
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 		$bytes = strlen($hexstr) / 2;
182 182
 		$bin = '';
183 183
 		
184
-		for($i = 0; $i < $bytes; ++$i) {
184
+		for ($i = 0; $i < $bytes; ++$i) {
185 185
 			$bin .= chr(hexdec(substr($hexstr, $i * 2, 2)));
186 186
 		}
187 187
 		
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 			}
210 210
 			$opcodeName = $this->opcodes[$opcode];
211 211
 			$second = ord(binarySubstr($this->connection->buf, $p++, 1)); // second byte integer (masked, payload length)
212
-			$fin =	(bool) ($first >> 7);
212
+			$fin = (bool) ($first >> 7);
213 213
         	$isMasked   = (bool) ($second >> 7);
214 214
         	$dataLength = $second & 0x7f;
215 215
           	if ($dataLength === 0x7e) { // 2 bytes-length
Please login to merge, or discard this patch.
lib/PostgreSQLClient.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -27,25 +27,25 @@  discard block
 block discarded – undo
27 27
 }
28 28
 
29 29
 class PostgreSQLClientConnection extends NetworkClientConnection {
30
-	public $url;                       // Connection's URL.
30
+	public $url; // Connection's URL.
31 31
 	public $protover      = '3.0';
32 32
 	public $maxPacketSize = 0x1000000; // Maximum packet size.
33
-	public $charsetNumber = 0x08;      // Charset number.
34
-	public $dbname        = '';        // Default database name.
35
-	public $user          = 'root';    // Username
36
-	public $password      = '';        // Password
37
-	public $options       = '';        // Default options
38
-	public $state        = 0;         // Connection's state. 0 - start,  1 - got initial packet,  2 - auth. packet sent,  3 - auth. error,  4 - handshaked OK
39
-	public $instate       = 0;         // State of pointer of incoming data. 0 - Result Set Header Packet,  1 - Field Packet,  2 - Row Packet
40
-	public $resultRows    = array();   // Resulting rows.
41
-	public $resultFields  = array();   // Resulting fields
42
-	public $onConnected   = array();   // Callback. Called when connection's handshaked.
43
-	public $context;                   // Property holds a reference to user's object.
44
-	public $insertId;                  // Equals with INSERT_ID().
45
-	public $insertNum;                 // Equals with INSERT_ID().
46
-	public $affectedRows;              // Number of affected rows.
33
+	public $charsetNumber = 0x08; // Charset number.
34
+	public $dbname        = ''; // Default database name.
35
+	public $user          = 'root'; // Username
36
+	public $password      = ''; // Password
37
+	public $options       = ''; // Default options
38
+	public $state = 0; // Connection's state. 0 - start,  1 - got initial packet,  2 - auth. packet sent,  3 - auth. error,  4 - handshaked OK
39
+	public $instate       = 0; // State of pointer of incoming data. 0 - Result Set Header Packet,  1 - Field Packet,  2 - Row Packet
40
+	public $resultRows    = array(); // Resulting rows.
41
+	public $resultFields  = array(); // Resulting fields
42
+	public $onConnected   = array(); // Callback. Called when connection's handshaked.
43
+	public $context; // Property holds a reference to user's object.
44
+	public $insertId; // Equals with INSERT_ID().
45
+	public $insertNum; // Equals with INSERT_ID().
46
+	public $affectedRows; // Number of affected rows.
47 47
 	public $ready         = FALSE;
48
-	public $parameters    = array();   // Runtime parameters from server
48
+	public $parameters    = array(); // Runtime parameters from server
49 49
 	public $backendKey;
50 50
 	const STATE_AUTH_ERROR = 3;
51 51
 	const STATE_AUTH_OK = 4;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 		$dec = 0;
109 109
 		$len = strlen($str);
110 110
 		
111
-		for($i = 0; $i < $len; ++$i) {
111
+		for ($i = 0; $i < $len; ++$i) {
112 112
 			$dec += ord(binarySubstr($str, $i, 1)) * pow(0x100, $len - $i - 1);
113 113
 		}
114 114
 		
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 
128 128
 		if ($len === NULL) {
129 129
 			if (strlen($hexstr) % 2) {
130
-				$hexstr = "0".$hexstr;
130
+				$hexstr = "0" . $hexstr;
131 131
 			}
132 132
 		} else {
133 133
 			$hexstr = str_repeat('0', $len * 2 - strlen($hexstr)) . $hexstr;
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 		$bytes = strlen($hexstr) / 2;
137 137
 		$bin = '';
138 138
 		
139
-		for($i = 0; $i < $bytes; ++$i) {
139
+		for ($i = 0; $i < $bytes; ++$i) {
140 140
 			$bin .= chr(hexdec(substr($hexstr, $i * 2, 2)));
141 141
 		}
142 142
 		
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 * @param string Data
149 149
 	 * @return boolean Success
150 150
 	 */
151
-	public function sendPacket($type = '',  $packet) {
151
+	public function sendPacket($type = '', $packet) {
152 152
 		$header = $type . pack('N', strlen($packet) + 4); 
153 153
 
154 154
 		$this->write($header);
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		}
225 225
 		
226 226
 		$o = $p;
227
-		$p =+ 8;
227
+		$p = + 8;
228 228
 
229 229
 		return $this->bytes2int(binarySubstr($s, $o, 8));
230 230
 	}
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 			}
403 403
 			elseif ($authType == 9) {
404 404
 				// GSS
405
-				Daemon::log(__CLASS__.': Unsupported authentication method: GSS.');
405
+				Daemon::log(__CLASS__ . ': Unsupported authentication method: GSS.');
406 406
 				$this->state = self::STATE_AUTH_ERROR; // Auth. error
407 407
 				$this->finish(); // Unsupported,  finish
408 408
 			}
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
 		elseif ($type === 'K') {
551 551
 			// Backend Key Data
552 552
 			list(, $this->backendKey) = unpack('N', $packet);
553
-			$this->backendKey = isset($u[1])?$u[1]:NULL;
553
+			$this->backendKey = isset($u[1]) ? $u[1] : NULL;
554 554
 	
555 555
 			if ($this->pool->config->protologging->value) {
556 556
 				Daemon::log(__CLASS__ . ': BackendKey is ' . $this->backendKey);
Please login to merge, or discard this patch.
lib/IdentServer.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
lib/File.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		if ($this->stat) {
70 70
 			call_user_func($cb, $this, $this->stat);
71 71
 		} else {
72
-			eio_fstat($this->fd, $pri, function ($file, $stat) use ($cb) {
72
+			eio_fstat($this->fd, $pri, function($file, $stat) use ($cb) {
73 73
 				$stat = FS::statPrepare($stat);
74 74
 				$file->stat = $stat;
75 75
 				call_user_func($cb, $file, $stat);
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 			call_user_func($cb, $this, FS::statPrepare(fstat($this->fd)));
89 89
 			return;
90 90
 		}
91
-		eio_fstat($this->fd, $pri, function ($file, $stat) use ($cb) {
91
+		eio_fstat($this->fd, $pri, function($file, $stat) use ($cb) {
92 92
 			$stat = FS::statPrepare($stat);
93 93
 			$file->stat = $stat;
94 94
 			call_user_func($cb, $file, $stat);
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		if ($this->statvfs) {
112 112
 			call_user_func($cb, $this, $this->statvfs);
113 113
 		} else {
114
-			eio_fstatvfs($this->fd, $pri, function ($file, $stat) use ($cb) {
114
+			eio_fstatvfs($this->fd, $pri, function($file, $stat) use ($cb) {
115 115
 				$file->statvfs = $stat;
116 116
 				call_user_func($cb, $file, $stat);
117 117
 			}, $this);		
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 			$length,
230 230
 			$offset !== null ? $offset : $this->offset,
231 231
 			$pri,
232
-			$cb ? $cb: $this->onRead,
232
+			$cb ? $cb : $this->onRead,
233 233
 			$this
234 234
 		);
235 235
 		return true;
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 		}
251 251
 		static $chunkSize = 1024;
252 252
 		$ret = true;
253
-		$handler = function ($file, $sent) use (&$ret, $outfd, $cb, &$handler, &$offset, &$length, $pri, $chunkSize) {
253
+		$handler = function($file, $sent) use (&$ret, $outfd, $cb, &$handler, &$offset, &$length, $pri, $chunkSize) {
254 254
 			if (!$ret) {
255 255
 				call_user_func($cb, $file, false);
256 256
 				return;
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 			$handler($this, -1);
275 275
 			return;
276 276
 		}
277
-		$this->statRefresh(function ($file, $stat) use ($handler, &$length) {
277
+		$this->statRefresh(function($file, $stat) use ($handler, &$length) {
278 278
 			$length = $stat['size'];
279 279
 			$handler($file, -1);
280 280
 		}, $pri);
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 			}
313 313
 			return false;
314 314
 		}
315
-		$this->statRefresh(function ($file, $stat) use ($cb, $pri) {
315
+		$this->statRefresh(function($file, $stat) use ($cb, $pri) {
316 316
 			if (!$stat) {
317 317
 				if ($cb) {
318 318
 					call_user_func($cb, $file, false);
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 			$offset = 0;
323 323
 			$buf = '';
324 324
 			$size = $stat['size'];
325
-			$handler = function ($file, $data) use ($cb, &$handler, $size, &$offset, $pri, &$buf) {
325
+			$handler = function($file, $data) use ($cb, &$handler, $size, &$offset, $pri, &$buf) {
326 326
 				$buf .= $data;
327 327
 				$offset += strlen($data);
328 328
 				$len = min($file->chunkSize, $size - $offset);
@@ -345,14 +345,14 @@  discard block
 block discarded – undo
345 345
 			}
346 346
 			return false;
347 347
 		}
348
-		$this->statRefresh(function ($file, $stat) use ($cb, $chunkcb, $pri) {
348
+		$this->statRefresh(function($file, $stat) use ($cb, $chunkcb, $pri) {
349 349
 			if (!$stat) {
350 350
 				call_user_func($cb, $file, false);
351 351
 				return;
352 352
 			}
353 353
 			$offset = 0;
354 354
 			$size = $stat['size'];
355
-			$handler = function ($file, $data) use ($cb, $chunkcb, &$handler, $size, &$offset, $pri) {
355
+			$handler = function($file, $data) use ($cb, $chunkcb, &$handler, $size, &$offset, $pri) {
356 356
 				call_user_func($chunkcb, $file, $data);
357 357
 				$offset += strlen($data);
358 358
 				$len = min($file->chunkSize, $size - $offset);
Please login to merge, or discard this patch.