Pārlūkot izejas kodu

command wake on lan

tags/0.1.0
Robin Thoni 9 gadus atpakaļ
vecāks
revīzija
1a9089db9b
1 mainītis faili ar 39 papildinājumiem un 0 dzēšanām
  1. 39
    0
      app/Http/Business/Commands/WakeOnLanCommand.php

+ 39
- 0
app/Http/Business/Commands/WakeOnLanCommand.php Parādīt failu

@@ -0,0 +1,39 @@
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 WakeOnLanCommand extends AbstractCommand
13
+{
14
+
15
+    /**
16
+     * @return bool
17
+     */
18
+    public function exec()
19
+    {
20
+        $data = $this->_command->getData();
21
+        $args = [
22
+            'wakeonlan',
23
+            '-i',
24
+            $data['IP'],
25
+            '-p',
26
+            $data['Port']
27
+        ];
28
+        foreach ($data["MACs"] as $mac) {
29
+            $args[] = $mac;
30
+        }
31
+        $cli = implode(' ', $args);
32
+        $code = 0;
33
+        $output = [];
34
+        exec($cli, $output, $code);
35
+        if ($code != 0) {
36
+            abort(500, "Wakeonlan failed with code " . $code);
37
+        }
38
+    }
39
+}

Notiek ielāde…
Atcelt
Saglabāt