Browse Source

command piface

tags/0.1.0
Robin Thoni 9 years ago
parent
commit
c292b99a13

+ 35
- 0
app/Http/Business/Commands/PiFaceCommand.php View File

1
+<?php
2
+/**
3
+ * Created by PhpStorm.
4
+ * User: robin
5
+ * Date: 11/24/15
6
+ * Time: 5:17 PM
7
+ */
8
+
9
+namespace App\Http\Business\Commands;
10
+
11
+
12
+class PiFaceCommand extends AbstractCommand
13
+{
14
+
15
+    /**
16
+     * @return bool
17
+     */
18
+    public function exec()
19
+    {
20
+        $data = $this->_command->getData();
21
+        $args = [
22
+            'camotion-pifaceo'
23
+        ];
24
+        foreach ($data["Commands"] as $cmd) {
25
+            $args[] = escapeshellarg("--" . $cmd);
26
+        }
27
+        $cli = implode(' ', $args);
28
+        $code = 0;
29
+        $output = [];
30
+        exec($cli, $output, $code);
31
+        if ($code != 0) {
32
+            abort(500, "PiFace failed with code " . $code);
33
+        }
34
+    }
35
+}

+ 3
- 3
app/Http/Business/Commands/WakeOnLanCommand.php View File

21
         $args = [
21
         $args = [
22
             'wakeonlan',
22
             'wakeonlan',
23
             '-i',
23
             '-i',
24
-            $data['IP'],
24
+            escapeshellarg($data['IP']),
25
             '-p',
25
             '-p',
26
-            $data['Port']
26
+            escapeshellarg($data['Port'])
27
         ];
27
         ];
28
         foreach ($data["MACs"] as $mac) {
28
         foreach ($data["MACs"] as $mac) {
29
-            $args[] = $mac;
29
+            $args[] = escapeshellarg($mac);
30
         }
30
         }
31
         $cli = implode(' ', $args);
31
         $cli = implode(' ', $args);
32
         $code = 0;
32
         $code = 0;

Loading…
Cancel
Save