@@ -54,7 +54,7 @@ |
||
54 | 54 | */ |
55 | 55 | public function init() { |
56 | 56 | |
57 | - try {$this->header('Content-Type: text/html');} catch (Exception $e) {} |
|
57 | + try {$this->header('Content-Type: text/html'); } catch (Exception $e) {} |
|
58 | 58 | |
59 | 59 | $this->appInstance->httpclient->post( |
60 | 60 | ['http://phpdaemon.net/Example/', 'foo' => 'bar'], ['postField' => 'value'], |
@@ -58,7 +58,7 @@ |
||
58 | 58 | * @return integer Status. |
59 | 59 | */ |
60 | 60 | public function run() { |
61 | - try {$this->header('Content-Type: text/plain');} catch (Exception $e) {} |
|
61 | + try {$this->header('Content-Type: text/plain'); } catch (Exception $e) {} |
|
62 | 62 | var_dump($this->job->getResult('query')); |
63 | 63 | var_dump($this->job->getResult('resolve')); |
64 | 64 | } |
@@ -85,7 +85,7 @@ |
||
85 | 85 | $user = posix_getpwuid(posix_getuid()); |
86 | 86 | $group = posix_getgrgid(posix_getgid()); |
87 | 87 | ?> |
88 | -<br />My user/group: <?php echo $user['name'].'/'.$group['name']; ?> |
|
88 | +<br />My user/group: <?php echo $user['name'] . '/' . $group['name']; ?> |
|
89 | 89 | <?php |
90 | 90 | $displaystate = TRUE; |
91 | 91 |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | * @return array|false |
19 | 19 | */ |
20 | 20 | protected function getConfigDefaults() { |
21 | - $random = sprintf('%x', crc32(posix_getpid() . "\x00". microtime(true))); |
|
21 | + $random = sprintf('%x', crc32(posix_getpid() . "\x00" . microtime(true))); |
|
22 | 22 | return array( |
23 | - 'url' => 'irc://guest_'.$random.':[email protected]/Bot_phpDaemon' |
|
23 | + 'url' => 'irc://guest_' . $random . ':[email protected]/Bot_phpDaemon' |
|
24 | 24 | ); |
25 | 25 | } |
26 | 26 | /** |
@@ -46,24 +46,24 @@ discard block |
||
46 | 46 | |
47 | 47 | public function connect() { |
48 | 48 | $app = $this; |
49 | - $r = $this->client->getConnection($this->config->url->value, function ($conn) use ($app) { |
|
49 | + $r = $this->client->getConnection($this->config->url->value, function($conn) use ($app) { |
|
50 | 50 | $app->conn = $conn; |
51 | 51 | if ($conn->connected) { |
52 | - Daemon::log('IRC bot connected at '.$this->config->url->value); |
|
52 | + Daemon::log('IRC bot connected at ' . $this->config->url->value); |
|
53 | 53 | $conn->join('#botwar_phpdaemon'); |
54 | 54 | $conn->bind('motd', function($conn) { |
55 | 55 | //Daemon::log($conn->motd); |
56 | 56 | }); |
57 | 57 | $conn->bind('privateMsg', function($conn, $msg) { |
58 | - Daemon::log('IRCBot: got private message \''.$msg['body'].'\' from \''.$msg['from']['orig'].'\''); |
|
59 | - $conn->message($msg['from']['nick'], 'You just wrote: '.$msg['body']); // send the message back |
|
58 | + Daemon::log('IRCBot: got private message \'' . $msg['body'] . '\' from \'' . $msg['from']['orig'] . '\''); |
|
59 | + $conn->message($msg['from']['nick'], 'You just wrote: ' . $msg['body']); // send the message back |
|
60 | 60 | }); |
61 | 61 | $conn->bind('disconnect', function() use ($app) { |
62 | 62 | $app->connect(); |
63 | 63 | }); |
64 | 64 | } |
65 | 65 | else { |
66 | - Daemon::log('IRCBot: unable to connect ('.$this->config->url->value.')'); |
|
66 | + Daemon::log('IRCBot: unable to connect (' . $this->config->url->value . ')'); |
|
67 | 67 | } |
68 | 68 | }); |
69 | 69 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | |
36 | 36 | $job('pingjob', function($name, $job) use ($req) { // registering job named 'pingjob' |
37 | 37 | |
38 | - ICMPClient::getInstance()->sendPing('8.8.8.8', function ($latency) use ($name, $job) { |
|
38 | + ICMPClient::getInstance()->sendPing('8.8.8.8', function($latency) use ($name, $job) { |
|
39 | 39 | $job->setResult($name, $latency); |
40 | 40 | }); |
41 | 41 | }); |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | public function onReady() { |
10 | 10 | $appInstance = $this; // a reference to this application instance for ExampleWebSocketRoute |
11 | - WebSocketServer::getInstance()->addRoute('ExamplePubSub', function ($client) use ($appInstance) { |
|
11 | + WebSocketServer::getInstance()->addRoute('ExamplePubSub', function($client) use ($appInstance) { |
|
12 | 12 | return new ExamplePubSubWebSocketRoute($client, $appInstance); |
13 | 13 | }); |
14 | 14 | $this->sql = MySQLClient::getInstance(); |
@@ -21,18 +21,18 @@ discard block |
||
21 | 21 | return; |
22 | 22 | } |
23 | 23 | $pubsub->event = setTimeout(function($timer) use ($pubsub, $appInstance) { |
24 | - $appInstance->sql->getConnection(function ($sql) use ($pubsub) { |
|
24 | + $appInstance->sql->getConnection(function($sql) use ($pubsub) { |
|
25 | 25 | if (!$sql->connected) { |
26 | 26 | return; |
27 | 27 | } |
28 | - $sql->query('SELECT COUNT(*) `num` FROM `dle_users`', function ($sql, $success) use ($pubsub) { |
|
28 | + $sql->query('SELECT COUNT(*) `num` FROM `dle_users`', function($sql, $success) use ($pubsub) { |
|
29 | 29 | $pubsub->pub(sizeof($sql->resultRows) ? $sql->resultRows[0]['num'] : 'null'); |
30 | 30 | }); |
31 | 31 | }); |
32 | 32 | $timer->timeout(5e6); // 5 seconds |
33 | 33 | }, 0); |
34 | 34 | }) |
35 | - ->onDeactivation(function ($pubsub) { |
|
35 | + ->onDeactivation(function($pubsub) { |
|
36 | 36 | if (isset($pubsub->event)) { |
37 | 37 | Timer::cancelTimeout($pubsub->event); |
38 | 38 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $req = json_decode($data, true); |
65 | 65 | if ($req['type'] === 'subscribe') { |
66 | 66 | $eventName = $req['event']; |
67 | - $this->appInstance->pubsub->sub($req['event'], $this, function ($data) use ($ws, $eventName) { |
|
67 | + $this->appInstance->pubsub->sub($req['event'], $this, function($data) use ($ws, $eventName) { |
|
68 | 68 | $ws->sendObject(array( |
69 | 69 | 'type' => 'event', |
70 | 70 | 'event' => $eventName, |
@@ -62,10 +62,10 @@ |
||
62 | 62 | 'allow_url_fopen' => 'false', |
63 | 63 | 'disable_functions'=>'exec,shell_exec,passthru,system', |
64 | 64 | 'disable_classes' => '', |
65 | - 'output_handler' => array($this,'out') |
|
65 | + 'output_handler' => array($this, 'out') |
|
66 | 66 | )); |
67 | 67 | |
68 | - $sandbox->ini_set('html_errors',true); |
|
68 | + $sandbox->ini_set('html_errors', true); |
|
69 | 69 | $sandbox->call_user_func(function() { |
70 | 70 | echo "Hello World!"; |
71 | 71 | }); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @return void |
29 | 29 | */ |
30 | 30 | public function init() { |
31 | - try {$this->header('Content-Type: text/html');} catch (Exception $e) {} |
|
31 | + try {$this->header('Content-Type: text/html'); } catch (Exception $e) {} |
|
32 | 32 | $req = $this; |
33 | 33 | |
34 | 34 | $job = $this->job = new ComplexJob(function() use ($req) { // called when job is done |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | } else { |
74 | 74 | echo '<h1>Something went wrong! We have no result.</h1>'; |
75 | 75 | } |
76 | -echo '<br />Request (http) took: '.round(microtime(TRUE) - $this->attrs->server['REQUEST_TIME_FLOAT'],6); |
|
76 | +echo '<br />Request (http) took: ' . round(microtime(TRUE) - $this->attrs->server['REQUEST_TIME_FLOAT'], 6); |
|
77 | 77 | ?> |
78 | 78 | </body> |
79 | 79 | </html> |
@@ -14,7 +14,7 @@ |
||
14 | 14 | public function onReady() { |
15 | 15 | $appInstance = $this; // a reference to this application instance for ExampleWebSocketRoute |
16 | 16 | // URI /exampleApp should be handled by ExampleWebSocketRoute |
17 | - WebSocketServer::getInstance()->addRoute('exampleApp', function ($client) use ($appInstance) { |
|
17 | + WebSocketServer::getInstance()->addRoute('exampleApp', function($client) use ($appInstance) { |
|
18 | 18 | return new ExampleWebSocketRoute($client, $appInstance); |
19 | 19 | }); |
20 | 20 | } |