@@ -93,24 +93,24 @@ discard block |
||
93 | 93 | { |
94 | 94 | foreach ($contents as $i) |
95 | 95 | { |
96 | - if (is_file($handler.'/'.$i)) |
|
96 | + if (is_file($handler . '/' . $i)) |
|
97 | 97 | { |
98 | - $allContents[] = $handler.'/'.$i; |
|
98 | + $allContents[] = $handler . '/' . $i; |
|
99 | 99 | |
100 | - $this->buffer = $handler.'/'.$i; |
|
100 | + $this->buffer = $handler . '/' . $i; |
|
101 | 101 | call_user_func($fileCallback, $this); |
102 | 102 | } |
103 | - elseif (is_dir($handler.'/'.$i)) |
|
103 | + elseif (is_dir($handler . '/' . $i)) |
|
104 | 104 | { |
105 | - $allContents[] = $handler.'/'.$i; |
|
105 | + $allContents[] = $handler . '/' . $i; |
|
106 | 106 | |
107 | - $this->buffer = $handler.'/'.$i; |
|
108 | - $this->getContents($handler.'/'.$i, $fileCallback, $dirCallback); |
|
107 | + $this->buffer = $handler . '/' . $i; |
|
108 | + $this->getContents($handler . '/' . $i, $fileCallback, $dirCallback); |
|
109 | 109 | |
110 | 110 | $directory = scandir($handler); |
111 | 111 | |
112 | 112 | if (!count($directory) < 3) |
113 | - $this->buffer = $handler.'/'.$i; |
|
113 | + $this->buffer = $handler . '/' . $i; |
|
114 | 114 | |
115 | 115 | call_user_func($dirCallback, $this); |
116 | 116 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | if (!empty($path)) |
198 | 198 | if (!strlen(stristr($item, $path)) > 0) |
199 | 199 | continue; |
200 | - if (strstr($item,'~') === false && $item != '.' && $item != '..') |
|
200 | + if (strstr($item, '~') === false && $item != '.' && $item != '..') |
|
201 | 201 | $filesToReturn[] = $item; |
202 | 202 | } |
203 | 203 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | if (is_dir($dest)) |
301 | 301 | { |
302 | 302 | if (!$recursive) |
303 | - copy($file, $dest.'/'.$file); |
|
303 | + copy($file, $dest . '/' . $file); |
|
304 | 304 | else { |
305 | 305 | |
306 | 306 | $files = array(); |
@@ -319,14 +319,14 @@ discard block |
||
319 | 319 | |
320 | 320 | foreach ($files[1] as $item) |
321 | 321 | { |
322 | - if (!file_exists($dest.'/'.$item)) |
|
322 | + if (!file_exists($dest . '/' . $item)) |
|
323 | 323 | mkdir("$dest/$item", 0777, true); |
324 | 324 | } |
325 | 325 | |
326 | 326 | foreach ($files[0] as $item) |
327 | 327 | { |
328 | 328 | if (!file_exists("$dest/$files")) |
329 | - copy($item, $dest.'/'.$item); |
|
329 | + copy($item, $dest . '/' . $item); |
|
330 | 330 | } |
331 | 331 | }); |
332 | 332 | } |
@@ -351,12 +351,12 @@ discard block |
||
351 | 351 | throw new Exception("Missing parameter for mv!"); |
352 | 352 | |
353 | 353 | if (is_dir($newfile)) |
354 | - $newfile .= '/'.basename($oldfile); |
|
354 | + $newfile .= '/' . basename($oldfile); |
|
355 | 355 | |
356 | 356 | if ($oldfile == $newfile) |
357 | 357 | return $this; |
358 | 358 | |
359 | - if(!rename($oldfile, $newfile)) |
|
359 | + if (!rename($oldfile, $newfile)) |
|
360 | 360 | return false; |
361 | 361 | |
362 | 362 | return true; |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | else { |
387 | 387 | if (!is_dir($dir)) |
388 | 388 | { |
389 | - if(!mkdir("$dir", 0777)) |
|
389 | + if (!mkdir("$dir", 0777)) |
|
390 | 390 | return false; |
391 | 391 | } |
392 | 392 | } |
@@ -17,67 +17,67 @@ |
||
17 | 17 | */ |
18 | 18 | interface ShellInterface |
19 | 19 | { |
20 | - /** |
|
21 | - * Prints the name of current/workinf directory |
|
22 | - */ |
|
23 | - public function pwd(); |
|
20 | + /** |
|
21 | + * Prints the name of current/workinf directory |
|
22 | + */ |
|
23 | + public function pwd(); |
|
24 | 24 | |
25 | - /** |
|
26 | - * Lists all directory contents |
|
27 | - * |
|
28 | - * @param string $path |
|
29 | - */ |
|
30 | - public function ls($path); |
|
25 | + /** |
|
26 | + * Lists all directory contents |
|
27 | + * |
|
28 | + * @param string $path |
|
29 | + */ |
|
30 | + public function ls($path); |
|
31 | 31 | |
32 | - /** |
|
33 | - * Changes the current/working directory |
|
34 | - * |
|
35 | - * @param string $path |
|
36 | - */ |
|
37 | - public function cd($path); |
|
32 | + /** |
|
33 | + * Changes the current/working directory |
|
34 | + * |
|
35 | + * @param string $path |
|
36 | + */ |
|
37 | + public function cd($path); |
|
38 | 38 | |
39 | - /** |
|
40 | - * Creates a file |
|
41 | - * |
|
42 | - * @param string $file |
|
43 | - */ |
|
44 | - public function touch($file); |
|
39 | + /** |
|
40 | + * Creates a file |
|
41 | + * |
|
42 | + * @param string $file |
|
43 | + */ |
|
44 | + public function touch($file); |
|
45 | 45 | |
46 | - /** |
|
47 | - * Deletes files or directories |
|
48 | - * |
|
49 | - * @param string $file |
|
50 | - */ |
|
51 | - public function rm($file); |
|
46 | + /** |
|
47 | + * Deletes files or directories |
|
48 | + * |
|
49 | + * @param string $file |
|
50 | + */ |
|
51 | + public function rm($file); |
|
52 | 52 | |
53 | - /** |
|
54 | - * Prints the name of current/workinf directory |
|
55 | - * |
|
56 | - * @param string $source |
|
57 | - * @param string $dest |
|
58 | - */ |
|
59 | - public function cp($source, $dest); |
|
53 | + /** |
|
54 | + * Prints the name of current/workinf directory |
|
55 | + * |
|
56 | + * @param string $source |
|
57 | + * @param string $dest |
|
58 | + */ |
|
59 | + public function cp($source, $dest); |
|
60 | 60 | |
61 | - /** |
|
62 | - * Moves or renames files |
|
63 | - * |
|
64 | - * @param string $oldfile |
|
65 | - * @param string $newfile |
|
66 | - */ |
|
67 | - public function mv($oldfile, $newfile); |
|
61 | + /** |
|
62 | + * Moves or renames files |
|
63 | + * |
|
64 | + * @param string $oldfile |
|
65 | + * @param string $newfile |
|
66 | + */ |
|
67 | + public function mv($oldfile, $newfile); |
|
68 | 68 | |
69 | - /** |
|
70 | - * Creates directories |
|
71 | - * |
|
72 | - * @param string $dir |
|
73 | - * @param string $dest |
|
74 | - */ |
|
75 | - public function mkdir($dir, $dest); |
|
69 | + /** |
|
70 | + * Creates directories |
|
71 | + * |
|
72 | + * @param string $dir |
|
73 | + * @param string $dest |
|
74 | + */ |
|
75 | + public function mkdir($dir, $dest); |
|
76 | 76 | |
77 | - /** |
|
78 | - * Deletes empty directories |
|
79 | - * |
|
80 | - * @param string $dir |
|
81 | - */ |
|
82 | - public function rmdir($dir); |
|
77 | + /** |
|
78 | + * Deletes empty directories |
|
79 | + * |
|
80 | + * @param string $dir |
|
81 | + */ |
|
82 | + public function rmdir($dir); |
|
83 | 83 | } |
84 | 84 | \ No newline at end of file |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | throw new \RuntimeException("Could not create the socket"); |
121 | 121 | } |
122 | - } |
|
122 | + } |
|
123 | 123 | |
124 | 124 | /** |
125 | 125 | * Binds the socket |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @return bool |
145 | 145 | */ |
146 | - public function close() |
|
147 | - { |
|
146 | + public function close() |
|
147 | + { |
|
148 | 148 | return socket_close($this->socket); |
149 | - } |
|
149 | + } |
|
150 | 150 | } |
151 | 151 | \ No newline at end of file |
@@ -108,8 +108,8 @@ |
||
108 | 108 | { |
109 | 109 | foreach ($options as $option => $value) |
110 | 110 | { |
111 | - if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) |
|
112 | - $this->{'set'.$option}($value); |
|
111 | + if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set' . $option)) |
|
112 | + $this->{'set' . $option}($value); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | if (!($this->socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) |
@@ -26,18 +26,18 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return string |
28 | 28 | */ |
29 | - public function read($socket) |
|
30 | - { |
|
31 | - if (($message = @socket_read($socket, 1024)) === false) |
|
32 | - { |
|
33 | - $errno = socket_last_error(); |
|
34 | - $this->error($errno, socket_strerror($errno)); |
|
29 | + public function read($socket) |
|
30 | + { |
|
31 | + if (($message = @socket_read($socket, 1024)) === false) |
|
32 | + { |
|
33 | + $errno = socket_last_error(); |
|
34 | + $this->error($errno, socket_strerror($errno)); |
|
35 | 35 | |
36 | - throw new \RuntimeException("Could not read message from client socket"); |
|
37 | - } |
|
36 | + throw new \RuntimeException("Could not read message from client socket"); |
|
37 | + } |
|
38 | 38 | |
39 | - return $message; |
|
40 | - } |
|
39 | + return $message; |
|
40 | + } |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Sends a message to client socket |
@@ -49,18 +49,18 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @return integer |
51 | 51 | */ |
52 | - public function send($socket, $message) |
|
53 | - { |
|
54 | - if (($bytes = @socket_write($socket, $message, strlen($message))) === false) |
|
55 | - { |
|
56 | - $errno = socket_last_error(); |
|
57 | - $this->error($errno, socket_strerror($errno)); |
|
52 | + public function send($socket, $message) |
|
53 | + { |
|
54 | + if (($bytes = @socket_write($socket, $message, strlen($message))) === false) |
|
55 | + { |
|
56 | + $errno = socket_last_error(); |
|
57 | + $this->error($errno, socket_strerror($errno)); |
|
58 | 58 | |
59 | - throw new \RuntimeException("Could not send message to the client socket"); |
|
60 | - } |
|
59 | + throw new \RuntimeException("Could not send message to the client socket"); |
|
60 | + } |
|
61 | 61 | |
62 | - return $bytes; |
|
63 | - } |
|
62 | + return $bytes; |
|
63 | + } |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Sets socket to listening |
@@ -71,54 +71,54 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @return null |
73 | 73 | */ |
74 | - public function listen(Array $eventHandlers = array()) |
|
75 | - { |
|
76 | - $event = $eventHandlers; |
|
77 | - $clousure = function(){}; |
|
74 | + public function listen(Array $eventHandlers = array()) |
|
75 | + { |
|
76 | + $event = $eventHandlers; |
|
77 | + $clousure = function(){}; |
|
78 | 78 | |
79 | - if (!array_key_exists('success', $event)) |
|
80 | - $event["success"] = $clousure; |
|
79 | + if (!array_key_exists('success', $event)) |
|
80 | + $event["success"] = $clousure; |
|
81 | 81 | |
82 | - if (!array_key_exists('error', $event)) |
|
83 | - $event["error"] = $clousure; |
|
82 | + if (!array_key_exists('error', $event)) |
|
83 | + $event["error"] = $clousure; |
|
84 | 84 | |
85 | - $listener = false; |
|
85 | + $listener = false; |
|
86 | 86 | |
87 | - if (!($listener = @socket_listen($this->socket, 30))) |
|
88 | - { |
|
89 | - $errno = socket_last_error(); |
|
90 | - $this->error($errno, socket_strerror($errno)); |
|
87 | + if (!($listener = @socket_listen($this->socket, 30))) |
|
88 | + { |
|
89 | + $errno = socket_last_error(); |
|
90 | + $this->error($errno, socket_strerror($errno)); |
|
91 | 91 | |
92 | - throw new \RuntimeException("Could not set socket to listen"); |
|
93 | - } |
|
94 | - else { |
|
92 | + throw new \RuntimeException("Could not set socket to listen"); |
|
93 | + } |
|
94 | + else { |
|
95 | 95 | |
96 | - echo "\n"; |
|
97 | - echo "Server Started : " . date('Y-m-d H:i:s') . "\n"; |
|
98 | - echo "Master socket : " . $this->socket . "\n"; |
|
99 | - echo "Listening on : " . $this->host . " port " . $this->port . "\n\n"; |
|
96 | + echo "\n"; |
|
97 | + echo "Server Started : " . date('Y-m-d H:i:s') . "\n"; |
|
98 | + echo "Master socket : " . $this->socket . "\n"; |
|
99 | + echo "Listening on : " . $this->host . " port " . $this->port . "\n\n"; |
|
100 | 100 | |
101 | - $socket = $this->socket; |
|
101 | + $socket = $this->socket; |
|
102 | 102 | |
103 | - if (!($spawn = @socket_accept($this->socket))) |
|
104 | - { |
|
105 | - $errno = socket_last_error(); |
|
106 | - $this->error($errno, socket_strerror($errno)); |
|
103 | + if (!($spawn = @socket_accept($this->socket))) |
|
104 | + { |
|
105 | + $errno = socket_last_error(); |
|
106 | + $this->error($errno, socket_strerror($errno)); |
|
107 | 107 | |
108 | - throw new \RuntimeException("Could not accept incoming connection"); |
|
109 | - } |
|
108 | + throw new \RuntimeException("Could not accept incoming connection"); |
|
109 | + } |
|
110 | 110 | |
111 | - $input = $this->read($spawn); |
|
111 | + $input = $this->read($spawn); |
|
112 | 112 | |
113 | - $input = trim($input); |
|
114 | - call_user_func($event["success"], $input, $this, $spawn); |
|
113 | + $input = trim($input); |
|
114 | + call_user_func($event["success"], $input, $this, $spawn); |
|
115 | 115 | |
116 | - socket_close($spawn); |
|
117 | - } |
|
116 | + socket_close($spawn); |
|
117 | + } |
|
118 | 118 | |
119 | - if (!$listener) |
|
120 | - call_user_func($event["error"], $this->getLastError()); |
|
119 | + if (!$listener) |
|
120 | + call_user_func($event["error"], $this->getLastError()); |
|
121 | 121 | |
122 | - return $listener; |
|
123 | - } |
|
122 | + return $listener; |
|
123 | + } |
|
124 | 124 | } |
125 | 125 | \ No newline at end of file |
@@ -74,7 +74,7 @@ |
||
74 | 74 | public function listen(Array $eventHandlers = array()) |
75 | 75 | { |
76 | 76 | $event = $eventHandlers; |
77 | - $clousure = function(){}; |
|
77 | + $clousure = function() {}; |
|
78 | 78 | |
79 | 79 | if (!array_key_exists('success', $event)) |
80 | 80 | $event["success"] = $clousure; |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | $ht = $this->http; |
30 | 30 | |
31 | 31 | $this->http->writeStatus($ht::HTTP_UNAUTHORIZED); |
32 | - header('WWW-Authenticate: Basic realm="'.$this->realm.'"'); |
|
33 | - die('Error ' . $ht::HTTP_UNAUTHORIZED .' (' . $this->http->getStatusText($ht::HTTP_UNAUTHORIZED) . ')!!'); |
|
32 | + header('WWW-Authenticate: Basic realm="' . $this->realm . '"'); |
|
33 | + die('Error ' . $ht::HTTP_UNAUTHORIZED . ' (' . $this->http->getStatusText($ht::HTTP_UNAUTHORIZED) . ')!!'); |
|
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | public function response() |
77 | 77 | { |
78 | 78 | $status = http_response_code(); |
79 | - $this->response = 'Error ' . $status .' (' . $this->http->getStatusText($status) . ')!!'; |
|
79 | + $this->response = 'Error ' . $status . ' (' . $this->http->getStatusText($status) . ')!!'; |
|
80 | 80 | echo $this->response; |
81 | 81 | } |
82 | 82 | } |
83 | 83 | \ No newline at end of file |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | $ht = $this->http; |
30 | 30 | |
31 | 31 | $this->http->writeStatus($ht::HTTP_UNAUTHORIZED); |
32 | - header('WWW-Authenticate: Digest realm="'.$this->realm.'",qop="auth",nonce="'.uniqid().'",opaque="'.md5($this->realm).'"'); |
|
33 | - die('Error ' . $ht::HTTP_UNAUTHORIZED .' (' . $this->http->getStatusText($ht::HTTP_UNAUTHORIZED) . ')!!'); |
|
32 | + header('WWW-Authenticate: Digest realm="' . $this->realm . '",qop="auth",nonce="' . uniqid() . '",opaque="' . md5($this->realm) . '"'); |
|
33 | + die('Error ' . $ht::HTTP_UNAUTHORIZED . ' (' . $this->http->getStatusText($ht::HTTP_UNAUTHORIZED) . ')!!'); |
|
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | } |
51 | 51 | |
52 | 52 | $A1 = md5($data['username'] . ':' . $this->realm . ':' . $this->whiteList[$data['username']]); |
53 | - $A2 = md5($_SERVER['REQUEST_METHOD'].':'.$data['uri']); |
|
54 | - $valid_response = md5($A1.':'.$data['nonce'].':'.$data['nc'].':'.$data['cnonce'].':'.$data['qop'].':'.$A2); |
|
53 | + $A2 = md5($_SERVER['REQUEST_METHOD'] . ':' . $data['uri']); |
|
54 | + $valid_response = md5($A1 . ':' . $data['nonce'] . ':' . $data['nc'] . ':' . $data['cnonce'] . ':' . $data['qop'] . ':' . $A2); |
|
55 | 55 | |
56 | 56 | if ($data['response'] != $valid_response) |
57 | 57 | { |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | public function response() |
98 | 98 | { |
99 | 99 | $status = http_response_code(); |
100 | - $this->response = 'Error ' . $status .' (' . $this->http->getStatusText($status) . ')!!'; |
|
100 | + $this->response = 'Error ' . $status . ' (' . $this->http->getStatusText($status) . ')!!'; |
|
101 | 101 | echo $this->response; |
102 | 102 | } |
103 | 103 | } |
104 | 104 | \ No newline at end of file |
@@ -156,8 +156,8 @@ |
||
156 | 156 | { |
157 | 157 | foreach ($options as $option => $value) |
158 | 158 | { |
159 | - if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) |
|
160 | - $this->{'set'.$option}($value); |
|
159 | + if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set' . $option)) |
|
160 | + $this->{'set' . $option}($value); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | # HTTP instance |
@@ -131,7 +131,7 @@ |
||
131 | 131 | if (\PEAR::isError($mail)) |
132 | 132 | { |
133 | 133 | $this->error( |
134 | - $mail->getCode(), $mail->getMessage() |
|
134 | + $mail->getCode(), $mail->getMessage() |
|
135 | 135 | ); |
136 | 136 | |
137 | 137 | return false; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function send($from, $to, $subject, $body) |
116 | 116 | { |
117 | - $headers = array ( |
|
117 | + $headers = array( |
|
118 | 118 | 'From' => $from, |
119 | 119 | 'To' => $to, |
120 | 120 | 'Subject' => $subject, |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | $smtp = \Mail::factory( |
125 | 125 | 'smtp', |
126 | - array ('host' => $this->host, 'auth' => false) |
|
126 | + array('host' => $this->host, 'auth' => false) |
|
127 | 127 | ); |
128 | 128 | |
129 | 129 | $mail = $smtp->send($to, $headers, $body); |
@@ -22,10 +22,10 @@ |
||
22 | 22 | * |
23 | 23 | * @var integer |
24 | 24 | */ |
25 | - const FILE_PERMISSION_DENIED = 1; |
|
26 | - const FILE_NOT_FOUND = 2; |
|
27 | - const FILE_EXISTS = 3; |
|
28 | - const NOT_DIRECTORY = 4; |
|
25 | + const FILE_PERMISSION_DENIED = 1; |
|
26 | + const FILE_NOT_FOUND = 2; |
|
27 | + const FILE_EXISTS = 3; |
|
28 | + const NOT_DIRECTORY = 4; |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Common JSON errors |
@@ -58,7 +58,7 @@ |
||
58 | 58 | |
59 | 59 | $constName = null; |
60 | 60 | |
61 | - foreach ($constants as $name => $value ) |
|
61 | + foreach ($constants as $name => $value) |
|
62 | 62 | { |
63 | 63 | if ($value == $code) |
64 | 64 | { |