Install
- Apache

- WebStation

- PHP

PHP Profile
On Web station
- Create a new php profile

- I used an existing PHP configuration with all features enabled

New Web service
On web Station
- Create a new web station using your PHP profile

- Select Name and directory

Create file
Create two files with the same name in the web directory :
- Index.html
Change button onclick
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | <! DOCTYPE html> < html lang = "en" > < head > < meta charset = "UTF-8" > < meta name = "viewport" content = "width=device-width, initial-scale=1.0" > < title >Wake-on-LAN</ title > < script > function sendWakeOnLan(macAddress) { $.ajax({ type: "POST", url: "wol.php", // Assurez-vous que cette URL est correcte data: { mac: macAddress }, success: function(response) { alert(response); }, error: function() { alert("Error sending the magic packet."); } }); } </ script > < style > body { font-family: Arial, sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #f4f4f4; } .button-container { display: flex; justify-content: space-around; width: 100%; max-width: 600px; /* Vous pouvez ajuster cette largeur selon vos besoins */ } button { font-size: 16px; padding: 10px 20px; color: white; background-color: #007BFF; border: none; border-radius: 5px; cursor: pointer; transition: background-color 0.3s, transform 0.2s; } button:hover { background-color: #0056b3; transform: scale(1.05); } button:active { transform: scale(0.95); } </ style > </ head > < body > < div class = "button-container" > < button onclick = "sendWakeOnLan('00:CC:91:AA:72:DA')" >Computer3</ button > < button onclick = "sendWakeOnLan('00:C6:91:AF:3D:00')" >Computer4</ button > </ div > </ body > </ html > |
- wol.php
Change 192.168.0.255 by your subnet network
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | <? php function wakeOnLan($broadcastAddress, $macAddress) { $ macAddress = str_replace ([':', '-'], '', $macAddress); $ magicPacket = str_repeat (chr(255), 6) . str_repeat(pack('H12', $macAddress), 16); if (!($ sock = socket_create (AF_INET, SOCK_DGRAM, SOL_UDP))) { return "Cannot create socket"; } $ options = socket_set_option ($sock, SOL_SOCKET, SO_BROADCAST, 1); if (!$options) { socket_close($sock); return "Failed to set socket option"; } $ send = socket_sendto ($sock, $magicPacket, strlen($magicPacket), 0, $broadcastAddress, 9); socket_close($sock); if (!$send) { return "Failed to send magic packet"; } return "Wake-on-LAN packet has been sent to $macAddress."; } if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['mac'])) { echo wakeOnLan('192.168.0.255', $_POST['mac']); } else { echo "Invalid request"; } ?> |
Result
On your web site https://synologyserver/wol

https://github.com/DavidWuibaille/Repository/tree/main/Synology/WOL
0 Comments