Quellcode durchsuchen

command piface

tags/0.1.0
Robin Thoni vor 9 Jahren
Ursprung
Commit
c292b99a13

+ 35
- 0
app/Http/Business/Commands/PiFaceCommand.php Datei anzeigen

@@ -0,0 +1,35 @@
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 Datei anzeigen

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

Laden…
Abbrechen
Speichern