@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | self::$fd = eio_get_event_stream(); |
40 | 40 | self::$ev = new Event(Daemon::$process->eventBase, self::$fd, Event::READ | Event::PERSIST, function ($fd, $events, $arg) { |
41 | 41 | while (eio_nreqs()) { |
42 | - eio_poll(); |
|
43 | - } |
|
42 | + eio_poll(); |
|
43 | + } |
|
44 | 44 | }); |
45 | 45 | self::$ev->add(); |
46 | 46 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | return; |
51 | 51 | } |
52 | 52 | while (eio_nreqs()) { |
53 | - eio_poll(); |
|
53 | + eio_poll(); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
51 | - * Output some data |
|
52 | - * @param string String to out |
|
53 | - * @return boolean Success |
|
54 | - */ |
|
51 | + * Output some data |
|
52 | + * @param string String to out |
|
53 | + * @return boolean Success |
|
54 | + */ |
|
55 | 55 | public function out($s, $flush = true) { |
56 | 56 | } |
57 | 57 | |
@@ -195,11 +195,11 @@ discard block |
||
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
198 | - * Get integer value from the given variable |
|
199 | - * @param Reference of variable. |
|
200 | - * @param array Optional. Possible values. |
|
201 | - * @return string Value. |
|
202 | - */ |
|
198 | + * Get integer value from the given variable |
|
199 | + * @param Reference of variable. |
|
200 | + * @param array Optional. Possible values. |
|
201 | + * @return string Value. |
|
202 | + */ |
|
203 | 203 | public static function getInteger(&$var, $values = null) { |
204 | 204 | if (is_string($var) && ctype_digit($var)) { |
205 | 205 | $var = (int) $var; |
@@ -14,7 +14,7 @@ |
||
14 | 14 | return 0; |
15 | 15 | } |
16 | 16 | return $pri1 < $pri2 ? -1 : 1; |
17 | - } |
|
17 | + } |
|
18 | 18 | public function executeOne() { |
19 | 19 | if ($this->isEmpty()) { |
20 | 20 | return false; |
@@ -23,11 +23,11 @@ discard block |
||
23 | 23 | if ($type === null) { |
24 | 24 | $type = 'STRING'; |
25 | 25 | } |
26 | - $frametype = @constant($a = get_class($this) .'::' . $type) ; |
|
27 | - if ($frametype === null) { |
|
28 | - Daemon::log(__METHOD__ . ' : Undefined frametype "' . $type . '"') ; |
|
29 | - } |
|
30 | - return $frametype ; |
|
26 | + $frametype = @constant($a = get_class($this) .'::' . $type) ; |
|
27 | + if ($frametype === null) { |
|
28 | + Daemon::log(__METHOD__ . ' : Undefined frametype "' . $type . '"') ; |
|
29 | + } |
|
30 | + return $frametype ; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | public function onHandshake() { |
@@ -42,14 +42,14 @@ discard block |
||
42 | 42 | $this->connection->buf = "" ; |
43 | 43 | } |
44 | 44 | |
45 | - /** |
|
46 | - * Returns handshaked data for reply |
|
45 | + /** |
|
46 | + * Returns handshaked data for reply |
|
47 | 47 | * @param string Received data (no use in this class) |
48 | - * @return string Handshaked data |
|
49 | - */ |
|
48 | + * @return string Handshaked data |
|
49 | + */ |
|
50 | 50 | |
51 | - public function getHandshakeReply($data) { |
|
51 | + public function getHandshakeReply($data) { |
|
52 | 52 | return false; |
53 | - } |
|
53 | + } |
|
54 | 54 | |
55 | 55 | } |
56 | 56 | \ No newline at end of file |
@@ -5,114 +5,114 @@ discard block |
||
5 | 5 | * @version 1.1 |
6 | 6 | * @link http://www.framework2.com.ar/dzone/forceUTF8-es/ |
7 | 7 | * @example http://www.framework2.com.ar/dzone/forceUTF8-es/ |
8 | - */ |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | class Encoding { |
11 | 11 | |
12 | 12 | protected static $win1252ToUtf8 = array( |
13 | - 128 => "\xe2\x82\xac", |
|
13 | + 128 => "\xe2\x82\xac", |
|
14 | 14 | |
15 | - 130 => "\xe2\x80\x9a", |
|
16 | - 131 => "\xc6\x92", |
|
17 | - 132 => "\xe2\x80\x9e", |
|
18 | - 133 => "\xe2\x80\xa6", |
|
19 | - 134 => "\xe2\x80\xa0", |
|
20 | - 135 => "\xe2\x80\xa1", |
|
21 | - 136 => "\xcb\x86", |
|
22 | - 137 => "\xe2\x80\xb0", |
|
23 | - 138 => "\xc5\xa0", |
|
24 | - 139 => "\xe2\x80\xb9", |
|
25 | - 140 => "\xc5\x92", |
|
15 | + 130 => "\xe2\x80\x9a", |
|
16 | + 131 => "\xc6\x92", |
|
17 | + 132 => "\xe2\x80\x9e", |
|
18 | + 133 => "\xe2\x80\xa6", |
|
19 | + 134 => "\xe2\x80\xa0", |
|
20 | + 135 => "\xe2\x80\xa1", |
|
21 | + 136 => "\xcb\x86", |
|
22 | + 137 => "\xe2\x80\xb0", |
|
23 | + 138 => "\xc5\xa0", |
|
24 | + 139 => "\xe2\x80\xb9", |
|
25 | + 140 => "\xc5\x92", |
|
26 | 26 | |
27 | - 142 => "\xc5\xbd", |
|
27 | + 142 => "\xc5\xbd", |
|
28 | 28 | |
29 | 29 | |
30 | - 145 => "\xe2\x80\x98", |
|
31 | - 146 => "\xe2\x80\x99", |
|
32 | - 147 => "\xe2\x80\x9c", |
|
33 | - 148 => "\xe2\x80\x9d", |
|
34 | - 149 => "\xe2\x80\xa2", |
|
35 | - 150 => "\xe2\x80\x93", |
|
36 | - 151 => "\xe2\x80\x94", |
|
37 | - 152 => "\xcb\x9c", |
|
38 | - 153 => "\xe2\x84\xa2", |
|
39 | - 154 => "\xc5\xa1", |
|
40 | - 155 => "\xe2\x80\xba", |
|
41 | - 156 => "\xc5\x93", |
|
30 | + 145 => "\xe2\x80\x98", |
|
31 | + 146 => "\xe2\x80\x99", |
|
32 | + 147 => "\xe2\x80\x9c", |
|
33 | + 148 => "\xe2\x80\x9d", |
|
34 | + 149 => "\xe2\x80\xa2", |
|
35 | + 150 => "\xe2\x80\x93", |
|
36 | + 151 => "\xe2\x80\x94", |
|
37 | + 152 => "\xcb\x9c", |
|
38 | + 153 => "\xe2\x84\xa2", |
|
39 | + 154 => "\xc5\xa1", |
|
40 | + 155 => "\xe2\x80\xba", |
|
41 | + 156 => "\xc5\x93", |
|
42 | 42 | |
43 | - 158 => "\xc5\xbe", |
|
44 | - 159 => "\xc5\xb8" |
|
43 | + 158 => "\xc5\xbe", |
|
44 | + 159 => "\xc5\xb8" |
|
45 | 45 | ); |
46 | 46 | |
47 | - protected static $brokenUtf8ToUtf8 = array( |
|
48 | - "\xc2\x80" => "\xe2\x82\xac", |
|
47 | + protected static $brokenUtf8ToUtf8 = array( |
|
48 | + "\xc2\x80" => "\xe2\x82\xac", |
|
49 | 49 | |
50 | - "\xc2\x82" => "\xe2\x80\x9a", |
|
51 | - "\xc2\x83" => "\xc6\x92", |
|
52 | - "\xc2\x84" => "\xe2\x80\x9e", |
|
53 | - "\xc2\x85" => "\xe2\x80\xa6", |
|
54 | - "\xc2\x86" => "\xe2\x80\xa0", |
|
55 | - "\xc2\x87" => "\xe2\x80\xa1", |
|
56 | - "\xc2\x88" => "\xcb\x86", |
|
57 | - "\xc2\x89" => "\xe2\x80\xb0", |
|
58 | - "\xc2\x8a" => "\xc5\xa0", |
|
59 | - "\xc2\x8b" => "\xe2\x80\xb9", |
|
60 | - "\xc2\x8c" => "\xc5\x92", |
|
50 | + "\xc2\x82" => "\xe2\x80\x9a", |
|
51 | + "\xc2\x83" => "\xc6\x92", |
|
52 | + "\xc2\x84" => "\xe2\x80\x9e", |
|
53 | + "\xc2\x85" => "\xe2\x80\xa6", |
|
54 | + "\xc2\x86" => "\xe2\x80\xa0", |
|
55 | + "\xc2\x87" => "\xe2\x80\xa1", |
|
56 | + "\xc2\x88" => "\xcb\x86", |
|
57 | + "\xc2\x89" => "\xe2\x80\xb0", |
|
58 | + "\xc2\x8a" => "\xc5\xa0", |
|
59 | + "\xc2\x8b" => "\xe2\x80\xb9", |
|
60 | + "\xc2\x8c" => "\xc5\x92", |
|
61 | 61 | |
62 | - "\xc2\x8e" => "\xc5\xbd", |
|
62 | + "\xc2\x8e" => "\xc5\xbd", |
|
63 | 63 | |
64 | 64 | |
65 | - "\xc2\x91" => "\xe2\x80\x98", |
|
66 | - "\xc2\x92" => "\xe2\x80\x99", |
|
67 | - "\xc2\x93" => "\xe2\x80\x9c", |
|
68 | - "\xc2\x94" => "\xe2\x80\x9d", |
|
69 | - "\xc2\x95" => "\xe2\x80\xa2", |
|
70 | - "\xc2\x96" => "\xe2\x80\x93", |
|
71 | - "\xc2\x97" => "\xe2\x80\x94", |
|
72 | - "\xc2\x98" => "\xcb\x9c", |
|
73 | - "\xc2\x99" => "\xe2\x84\xa2", |
|
74 | - "\xc2\x9a" => "\xc5\xa1", |
|
75 | - "\xc2\x9b" => "\xe2\x80\xba", |
|
76 | - "\xc2\x9c" => "\xc5\x93", |
|
65 | + "\xc2\x91" => "\xe2\x80\x98", |
|
66 | + "\xc2\x92" => "\xe2\x80\x99", |
|
67 | + "\xc2\x93" => "\xe2\x80\x9c", |
|
68 | + "\xc2\x94" => "\xe2\x80\x9d", |
|
69 | + "\xc2\x95" => "\xe2\x80\xa2", |
|
70 | + "\xc2\x96" => "\xe2\x80\x93", |
|
71 | + "\xc2\x97" => "\xe2\x80\x94", |
|
72 | + "\xc2\x98" => "\xcb\x9c", |
|
73 | + "\xc2\x99" => "\xe2\x84\xa2", |
|
74 | + "\xc2\x9a" => "\xc5\xa1", |
|
75 | + "\xc2\x9b" => "\xe2\x80\xba", |
|
76 | + "\xc2\x9c" => "\xc5\x93", |
|
77 | 77 | |
78 | - "\xc2\x9e" => "\xc5\xbe", |
|
79 | - "\xc2\x9f" => "\xc5\xb8" |
|
78 | + "\xc2\x9e" => "\xc5\xbe", |
|
79 | + "\xc2\x9f" => "\xc5\xb8" |
|
80 | 80 | ); |
81 | 81 | |
82 | 82 | protected static $utf8ToWin1252 = array( |
83 | - "\xe2\x82\xac" => "\x80", |
|
83 | + "\xe2\x82\xac" => "\x80", |
|
84 | 84 | |
85 | - "\xe2\x80\x9a" => "\x82", |
|
86 | - "\xc6\x92" => "\x83", |
|
87 | - "\xe2\x80\x9e" => "\x84", |
|
88 | - "\xe2\x80\xa6" => "\x85", |
|
89 | - "\xe2\x80\xa0" => "\x86", |
|
90 | - "\xe2\x80\xa1" => "\x87", |
|
91 | - "\xcb\x86" => "\x88", |
|
92 | - "\xe2\x80\xb0" => "\x89", |
|
93 | - "\xc5\xa0" => "\x8a", |
|
94 | - "\xe2\x80\xb9" => "\x8b", |
|
95 | - "\xc5\x92" => "\x8c", |
|
85 | + "\xe2\x80\x9a" => "\x82", |
|
86 | + "\xc6\x92" => "\x83", |
|
87 | + "\xe2\x80\x9e" => "\x84", |
|
88 | + "\xe2\x80\xa6" => "\x85", |
|
89 | + "\xe2\x80\xa0" => "\x86", |
|
90 | + "\xe2\x80\xa1" => "\x87", |
|
91 | + "\xcb\x86" => "\x88", |
|
92 | + "\xe2\x80\xb0" => "\x89", |
|
93 | + "\xc5\xa0" => "\x8a", |
|
94 | + "\xe2\x80\xb9" => "\x8b", |
|
95 | + "\xc5\x92" => "\x8c", |
|
96 | 96 | |
97 | - "\xc5\xbd" => "\x8e", |
|
97 | + "\xc5\xbd" => "\x8e", |
|
98 | 98 | |
99 | 99 | |
100 | - "\xe2\x80\x98" => "\x91", |
|
101 | - "\xe2\x80\x99" => "\x92", |
|
102 | - "\xe2\x80\x9c" => "\x93", |
|
103 | - "\xe2\x80\x9d" => "\x94", |
|
104 | - "\xe2\x80\xa2" => "\x95", |
|
105 | - "\xe2\x80\x93" => "\x96", |
|
106 | - "\xe2\x80\x94" => "\x97", |
|
107 | - "\xcb\x9c" => "\x98", |
|
108 | - "\xe2\x84\xa2" => "\x99", |
|
109 | - "\xc5\xa1" => "\x9a", |
|
110 | - "\xe2\x80\xba" => "\x9b", |
|
111 | - "\xc5\x93" => "\x9c", |
|
100 | + "\xe2\x80\x98" => "\x91", |
|
101 | + "\xe2\x80\x99" => "\x92", |
|
102 | + "\xe2\x80\x9c" => "\x93", |
|
103 | + "\xe2\x80\x9d" => "\x94", |
|
104 | + "\xe2\x80\xa2" => "\x95", |
|
105 | + "\xe2\x80\x93" => "\x96", |
|
106 | + "\xe2\x80\x94" => "\x97", |
|
107 | + "\xcb\x9c" => "\x98", |
|
108 | + "\xe2\x84\xa2" => "\x99", |
|
109 | + "\xc5\xa1" => "\x9a", |
|
110 | + "\xe2\x80\xba" => "\x9b", |
|
111 | + "\xc5\x93" => "\x9c", |
|
112 | 112 | |
113 | - "\xc5\xbe" => "\x9e", |
|
114 | - "\xc5\xb8" => "\x9f" |
|
115 | - ); |
|
113 | + "\xc5\xbe" => "\x9e", |
|
114 | + "\xc5\xb8" => "\x9f" |
|
115 | + ); |
|
116 | 116 | |
117 | 117 | static function toUTF8($text){ |
118 | 118 | /** |
@@ -140,123 +140,123 @@ discard block |
||
140 | 140 | * |
141 | 141 | */ |
142 | 142 | |
143 | - if(is_array($text)) |
|
144 | - { |
|
145 | - foreach($text as $k => $v) |
|
146 | - { |
|
147 | - $text[$k] = self::toUTF8($v); |
|
148 | - } |
|
149 | - return $text; |
|
150 | - } elseif(is_string($text)) { |
|
143 | + if(is_array($text)) |
|
144 | + { |
|
145 | + foreach($text as $k => $v) |
|
146 | + { |
|
147 | + $text[$k] = self::toUTF8($v); |
|
148 | + } |
|
149 | + return $text; |
|
150 | + } elseif(is_string($text)) { |
|
151 | 151 | |
152 | - $max = strlen($text); |
|
153 | - $buf = ""; |
|
154 | - for($i = 0; $i < $max; $i++){ |
|
155 | - $c1 = $text{$i}; |
|
156 | - if($c1>="\xc0"){ //Should be converted to UTF8, if it's not UTF8 already |
|
157 | - $c2 = $i+1 >= $max? "\x00" : $text{$i+1}; |
|
158 | - $c3 = $i+2 >= $max? "\x00" : $text{$i+2}; |
|
159 | - $c4 = $i+3 >= $max? "\x00" : $text{$i+3}; |
|
160 | - if($c1 >= "\xc0" & $c1 <= "\xdf"){ //looks like 2 bytes UTF8 |
|
161 | - if($c2 >= "\x80" && $c2 <= "\xbf"){ //yeah, almost sure it's UTF8 already |
|
162 | - $buf .= $c1 . $c2; |
|
163 | - $i++; |
|
164 | - } else { //not valid UTF8. Convert it. |
|
165 | - $cc1 = (chr(ord($c1) / 64) | "\xc0"); |
|
166 | - $cc2 = ($c1 & "\x3f") | "\x80"; |
|
167 | - $buf .= $cc1 . $cc2; |
|
168 | - } |
|
169 | - } elseif($c1 >= "\xe0" & $c1 <= "\xef"){ //looks like 3 bytes UTF8 |
|
170 | - if($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf"){ //yeah, almost sure it's UTF8 already |
|
171 | - $buf .= $c1 . $c2 . $c3; |
|
172 | - $i = $i + 2; |
|
173 | - } else { //not valid UTF8. Convert it. |
|
174 | - $cc1 = (chr(ord($c1) / 64) | "\xc0"); |
|
175 | - $cc2 = ($c1 & "\x3f") | "\x80"; |
|
176 | - $buf .= $cc1 . $cc2; |
|
177 | - } |
|
178 | - } elseif($c1 >= "\xf0" & $c1 <= "\xf7"){ //looks like 4 bytes UTF8 |
|
179 | - if($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf"){ //yeah, almost sure it's UTF8 already |
|
180 | - $buf .= $c1 . $c2 . $c3; |
|
181 | - $i = $i + 2; |
|
182 | - } else { //not valid UTF8. Convert it. |
|
183 | - $cc1 = (chr(ord($c1) / 64) | "\xc0"); |
|
184 | - $cc2 = ($c1 & "\x3f") | "\x80"; |
|
185 | - $buf .= $cc1 . $cc2; |
|
186 | - } |
|
187 | - } else { //doesn't look like UTF8, but should be converted |
|
188 | - $cc1 = (chr(ord($c1) / 64) | "\xc0"); |
|
189 | - $cc2 = (($c1 & "\x3f") | "\x80"); |
|
190 | - $buf .= $cc1 . $cc2; |
|
191 | - } |
|
192 | - } elseif(($c1 & "\xc0") == "\x80"){ // needs conversion |
|
193 | - if(isset(self::$win1252ToUtf8[ord($c1)])) { //found in Windows-1252 special cases |
|
194 | - $buf .= self::$win1252ToUtf8[ord($c1)]; |
|
195 | - } else { |
|
196 | - $cc1 = (chr(ord($c1) / 64) | "\xc0"); |
|
197 | - $cc2 = (($c1 & "\x3f") | "\x80"); |
|
198 | - $buf .= $cc1 . $cc2; |
|
199 | - } |
|
200 | - } else { // it doesn't need convesion |
|
201 | - $buf .= $c1; |
|
202 | - } |
|
203 | - } |
|
204 | - return $buf; |
|
205 | - } else { |
|
206 | - return $text; |
|
207 | - } |
|
152 | + $max = strlen($text); |
|
153 | + $buf = ""; |
|
154 | + for($i = 0; $i < $max; $i++){ |
|
155 | + $c1 = $text{$i}; |
|
156 | + if($c1>="\xc0"){ //Should be converted to UTF8, if it's not UTF8 already |
|
157 | + $c2 = $i+1 >= $max? "\x00" : $text{$i+1}; |
|
158 | + $c3 = $i+2 >= $max? "\x00" : $text{$i+2}; |
|
159 | + $c4 = $i+3 >= $max? "\x00" : $text{$i+3}; |
|
160 | + if($c1 >= "\xc0" & $c1 <= "\xdf"){ //looks like 2 bytes UTF8 |
|
161 | + if($c2 >= "\x80" && $c2 <= "\xbf"){ //yeah, almost sure it's UTF8 already |
|
162 | + $buf .= $c1 . $c2; |
|
163 | + $i++; |
|
164 | + } else { //not valid UTF8. Convert it. |
|
165 | + $cc1 = (chr(ord($c1) / 64) | "\xc0"); |
|
166 | + $cc2 = ($c1 & "\x3f") | "\x80"; |
|
167 | + $buf .= $cc1 . $cc2; |
|
168 | + } |
|
169 | + } elseif($c1 >= "\xe0" & $c1 <= "\xef"){ //looks like 3 bytes UTF8 |
|
170 | + if($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf"){ //yeah, almost sure it's UTF8 already |
|
171 | + $buf .= $c1 . $c2 . $c3; |
|
172 | + $i = $i + 2; |
|
173 | + } else { //not valid UTF8. Convert it. |
|
174 | + $cc1 = (chr(ord($c1) / 64) | "\xc0"); |
|
175 | + $cc2 = ($c1 & "\x3f") | "\x80"; |
|
176 | + $buf .= $cc1 . $cc2; |
|
177 | + } |
|
178 | + } elseif($c1 >= "\xf0" & $c1 <= "\xf7"){ //looks like 4 bytes UTF8 |
|
179 | + if($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf"){ //yeah, almost sure it's UTF8 already |
|
180 | + $buf .= $c1 . $c2 . $c3; |
|
181 | + $i = $i + 2; |
|
182 | + } else { //not valid UTF8. Convert it. |
|
183 | + $cc1 = (chr(ord($c1) / 64) | "\xc0"); |
|
184 | + $cc2 = ($c1 & "\x3f") | "\x80"; |
|
185 | + $buf .= $cc1 . $cc2; |
|
186 | + } |
|
187 | + } else { //doesn't look like UTF8, but should be converted |
|
188 | + $cc1 = (chr(ord($c1) / 64) | "\xc0"); |
|
189 | + $cc2 = (($c1 & "\x3f") | "\x80"); |
|
190 | + $buf .= $cc1 . $cc2; |
|
191 | + } |
|
192 | + } elseif(($c1 & "\xc0") == "\x80"){ // needs conversion |
|
193 | + if(isset(self::$win1252ToUtf8[ord($c1)])) { //found in Windows-1252 special cases |
|
194 | + $buf .= self::$win1252ToUtf8[ord($c1)]; |
|
195 | + } else { |
|
196 | + $cc1 = (chr(ord($c1) / 64) | "\xc0"); |
|
197 | + $cc2 = (($c1 & "\x3f") | "\x80"); |
|
198 | + $buf .= $cc1 . $cc2; |
|
199 | + } |
|
200 | + } else { // it doesn't need convesion |
|
201 | + $buf .= $c1; |
|
202 | + } |
|
203 | + } |
|
204 | + return $buf; |
|
205 | + } else { |
|
206 | + return $text; |
|
207 | + } |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | static function toWin1252($text) { |
211 | - if(is_array($text)) { |
|
212 | - foreach($text as $k => $v) { |
|
213 | - $text[$k] = self::toWin1252($v); |
|
214 | - } |
|
215 | - return $text; |
|
216 | - } elseif(is_string($text)) { |
|
217 | - return utf8_decode(str_replace(array_keys(self::$utf8ToWin1252), array_values(self::$utf8ToWin1252), self::toUTF8($text))); |
|
218 | - } else { |
|
219 | - return $text; |
|
220 | - } |
|
211 | + if(is_array($text)) { |
|
212 | + foreach($text as $k => $v) { |
|
213 | + $text[$k] = self::toWin1252($v); |
|
214 | + } |
|
215 | + return $text; |
|
216 | + } elseif(is_string($text)) { |
|
217 | + return utf8_decode(str_replace(array_keys(self::$utf8ToWin1252), array_values(self::$utf8ToWin1252), self::toUTF8($text))); |
|
218 | + } else { |
|
219 | + return $text; |
|
220 | + } |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | static function toISO8859($text) { |
224 | - return self::toWin1252($text); |
|
224 | + return self::toWin1252($text); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | static function toLatin1($text) { |
228 | - return self::toWin1252($text); |
|
228 | + return self::toWin1252($text); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | static function fixUTF8($text){ |
232 | - if(is_array($text)) { |
|
233 | - foreach($text as $k => $v) { |
|
234 | - $text[$k] = self::fixUTF8($v); |
|
235 | - } |
|
236 | - return $text; |
|
237 | - } |
|
232 | + if(is_array($text)) { |
|
233 | + foreach($text as $k => $v) { |
|
234 | + $text[$k] = self::fixUTF8($v); |
|
235 | + } |
|
236 | + return $text; |
|
237 | + } |
|
238 | 238 | |
239 | - $last = ""; |
|
240 | - while($last <> $text){ |
|
241 | - $last = $text; |
|
242 | - $text = self::toUTF8(utf8_decode(str_replace(array_keys(self::$utf8ToWin1252), array_values(self::$utf8ToWin1252), $text))); |
|
243 | - } |
|
244 | - $text = self::toUTF8(utf8_decode(str_replace(array_keys(self::$utf8ToWin1252), array_values(self::$utf8ToWin1252), $text))); |
|
245 | - return $text; |
|
239 | + $last = ""; |
|
240 | + while($last <> $text){ |
|
241 | + $last = $text; |
|
242 | + $text = self::toUTF8(utf8_decode(str_replace(array_keys(self::$utf8ToWin1252), array_values(self::$utf8ToWin1252), $text))); |
|
243 | + } |
|
244 | + $text = self::toUTF8(utf8_decode(str_replace(array_keys(self::$utf8ToWin1252), array_values(self::$utf8ToWin1252), $text))); |
|
245 | + return $text; |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | static function UTF8FixWin1252Chars($text){ |
249 | - // If you received an UTF-8 string that was converted from Windows-1252 as it was ISO8859-1 |
|
250 | - // (ignoring Windows-1252 chars from 80 to 9F) use this function to fix it. |
|
251 | - // See: http://en.wikipedia.org/wiki/Windows-1252 |
|
249 | + // If you received an UTF-8 string that was converted from Windows-1252 as it was ISO8859-1 |
|
250 | + // (ignoring Windows-1252 chars from 80 to 9F) use this function to fix it. |
|
251 | + // See: http://en.wikipedia.org/wiki/Windows-1252 |
|
252 | 252 | |
253 | - return str_replace(array_keys(self::$brokenUtf8ToUtf8), array_values(self::$brokenUtf8ToUtf8), $text); |
|
253 | + return str_replace(array_keys(self::$brokenUtf8ToUtf8), array_values(self::$brokenUtf8ToUtf8), $text); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | static function removeBOM($str=""){ |
257 | - if(substr($str, 0,3) == pack("CCC",0xef,0xbb,0xbf)) { |
|
258 | - $str=substr($str, 3); |
|
259 | - } |
|
260 | - return $str; |
|
257 | + if(substr($str, 0,3) == pack("CCC",0xef,0xbb,0xbf)) { |
|
258 | + $str=substr($str, 3); |
|
259 | + } |
|
260 | + return $str; |
|
261 | 261 | } |
262 | 262 | } |
@@ -155,10 +155,10 @@ discard block |
||
155 | 155 | posix_setsid(); |
156 | 156 | proc_nice(Daemon::$config->masterpriority->value); |
157 | 157 | if (!Daemon::$config->verbosetty->value) { |
158 | - fclose(STDIN); |
|
159 | - fclose(STDOUT); |
|
160 | - fclose(STDERR); |
|
161 | - } |
|
158 | + fclose(STDIN); |
|
159 | + fclose(STDOUT); |
|
160 | + fclose(STDERR); |
|
161 | + } |
|
162 | 162 | |
163 | 163 | $this->setproctitle( |
164 | 164 | Daemon::$runName . ': master process' |
@@ -212,10 +212,10 @@ discard block |
||
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
215 | - * Spawn IPC process |
|
216 | - * @param $n - integer - number of workers to spawn |
|
217 | - * @return boolean - success |
|
218 | - */ |
|
215 | + * Spawn IPC process |
|
216 | + * @param $n - integer - number of workers to spawn |
|
217 | + * @return boolean - success |
|
218 | + */ |
|
219 | 219 | public function spawnIPCThread() { |
220 | 220 | if (FS::$supported) { |
221 | 221 | eio_event_loop(); |
@@ -41,16 +41,16 @@ discard block |
||
41 | 41 | return FALSE; |
42 | 42 | } |
43 | 43 | |
44 | - if (!isset($this->protocol)) |
|
45 | - { |
|
46 | - Daemon::$process->log(get_class($this) . '::' . __METHOD__ . ' : Cannot find session-related websocket protocol for client ' . $this->addr) ; |
|
47 | - return FALSE ; |
|
48 | - } |
|
44 | + if (!isset($this->protocol)) |
|
45 | + { |
|
46 | + Daemon::$process->log(get_class($this) . '::' . __METHOD__ . ' : Cannot find session-related websocket protocol for client ' . $this->addr) ; |
|
47 | + return FALSE ; |
|
48 | + } |
|
49 | 49 | |
50 | - $this->protocol->sendFrame($data, $type) ; |
|
51 | - if ($cb) { |
|
52 | - $this->onWriteOnce($cb); |
|
53 | - } |
|
50 | + $this->protocol->sendFrame($data, $type) ; |
|
51 | + if ($cb) { |
|
52 | + $this->onWriteOnce($cb); |
|
53 | + } |
|
54 | 54 | return TRUE; |
55 | 55 | } |
56 | 56 | |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | return false; |
125 | 125 | } |
126 | 126 | |
127 | - if (!isset($this->protocol)) { |
|
128 | - Daemon::$process->log(get_class($this) . '::' . __METHOD__ . ' : Cannot find session-related websocket protocol for client "' . $this->addr . '"') ; |
|
129 | - return FALSE ; |
|
130 | - } |
|
127 | + if (!isset($this->protocol)) { |
|
128 | + Daemon::$process->log(get_class($this) . '::' . __METHOD__ . ' : Cannot find session-related websocket protocol for client "' . $this->addr . '"') ; |
|
129 | + return FALSE ; |
|
130 | + } |
|
131 | 131 | |
132 | 132 | if ($this->protocol->onHandshake() === FALSE) { |
133 | 133 | return FALSE ; |
@@ -305,13 +305,13 @@ discard block |
||
305 | 305 | } |
306 | 306 | if ($this->state === self::STATE_HANDSHAKED) |
307 | 307 | { |
308 | - if (!isset($this->protocol)) |
|
309 | - { |
|
310 | - Daemon::$process->log(get_class($this) . '::' . __METHOD__ . ' : Cannot find session-related websocket protocol for client "' . $this->addr . '"'); |
|
311 | - $this->finish(); |
|
312 | - return; |
|
313 | - } |
|
314 | - $this->protocol->onRead(); |
|
308 | + if (!isset($this->protocol)) |
|
309 | + { |
|
310 | + Daemon::$process->log(get_class($this) . '::' . __METHOD__ . ' : Cannot find session-related websocket protocol for client "' . $this->addr . '"'); |
|
311 | + $this->finish(); |
|
312 | + return; |
|
313 | + } |
|
314 | + $this->protocol->onRead(); |
|
315 | 315 | } |
316 | 316 | } |
317 | 317 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | 319 => 'RPL_WHOISCHANNELS', 321 => 'RPL_LISTSTART', |
31 | 31 | 322 => 'RPL_LIST', 323 => 'RPL_LISTEND', |
32 | 32 | 324 => 'RPL_CHANNELMODEIS', 325 => 'RPL_UNIQOPIS', |
33 | - 328 => 'RPL_CHANNEL_URL', 329 => 'RPL_CREATIONTIME', |
|
33 | + 328 => 'RPL_CHANNEL_URL', 329 => 'RPL_CREATIONTIME', |
|
34 | 34 | 331 => 'RPL_NOTOPIC', 332 => 'RPL_TOPIC', 333 => 'RPL_TOPIC_TS', |
35 | 35 | 341 => 'RPL_INVITING', 342 => 'RPL_SUMMONING', |
36 | 36 | 346 => 'RPL_INVITELIST', 347 => 'RPL_ENDOFINVITELIST', |
@@ -76,19 +76,19 @@ discard block |
||
76 | 76 | ); |
77 | 77 | public static $codesFlip; |
78 | 78 | public static function getCommandByCode($code) { |
79 | - if (isset(self::$codes[$code])) { |
|
80 | - return self::$codes[$code]; |
|
81 | - } |
|
82 | - return false; |
|
79 | + if (isset(self::$codes[$code])) { |
|
80 | + return self::$codes[$code]; |
|
81 | + } |
|
82 | + return false; |
|
83 | 83 | } |
84 | 84 | public static function getCodeByCommand($cmd) { |
85 | - if (self::$codesFlip === null) { |
|
86 | - self::$codesFlip = array_flip(self::$codes); |
|
87 | - } |
|
88 | - if (isset(self::$codesFlip[$cmd])) { |
|
89 | - return sprintf('%03u', self::$codesFlip[$cmd]); |
|
90 | - } |
|
91 | - return $cmd; |
|
85 | + if (self::$codesFlip === null) { |
|
86 | + self::$codesFlip = array_flip(self::$codes); |
|
87 | + } |
|
88 | + if (isset(self::$codesFlip[$cmd])) { |
|
89 | + return sprintf('%03u', self::$codesFlip[$cmd]); |
|
90 | + } |
|
91 | + return $cmd; |
|
92 | 92 | |
93 | 93 | } |
94 | 94 | public static function parseUsermask($mask) { |
@@ -357,7 +357,7 @@ |
||
357 | 357 | * Called when new data received |
358 | 358 | * @param string New data |
359 | 359 | * @return void |
360 | - */ |
|
360 | + */ |
|
361 | 361 | public function stdin($buf) { |
362 | 362 | $this->buf .= $buf; |
363 | 363 | while (($line = $this->gets()) !== false) { |