Auto-commit: 2025-10-31 08:58:35
This commit is contained in:
76
Synology-WOL/index.html
Normal file
76
Synology-WOL/index.html
Normal file
@@ -0,0 +1,76 @@
|
||||
<!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>
|
||||
|
||||
<!-- Importing jQuery -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
|
||||
<!-- Script to handle Wake-on-LAN requests -->
|
||||
<script>
|
||||
function sendWakeOnLan(macAddress) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "wol.php", // Ensure this URL is correct
|
||||
data: { mac: macAddress },
|
||||
success: function(response) {
|
||||
alert(response);
|
||||
},
|
||||
error: function() {
|
||||
alert("Error sending the magic packet.");
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Basic styling for the page and buttons -->
|
||||
<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; /* Adjust this width as needed */
|
||||
}
|
||||
|
||||
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">
|
||||
<!-- Buttons to trigger Wake-on-LAN for different devices -->
|
||||
<button onclick="sendWakeOnLan('00:C6:91:00:72:0A')">Réveiller NUC3</button>
|
||||
<button onclick="sendWakeOnLan('94:00:91:00:3D:00')">Réveiller NUC5</button>
|
||||
<button onclick="sendWakeOnLan('00:00:32:00:EF:09')">Réveiller NAS2</button>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
18
Synology-WOL/readme.md
Normal file
18
Synology-WOL/readme.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# Wake-on-LAN with Synology
|
||||
|
||||
This project shows how to create a simple **Wake-on-LAN (WOL) web interface** hosted on a Synology NAS using **Apache, PHP and Web Station**.
|
||||
|
||||
## ✨ Features
|
||||
- Wake up computers on your LAN directly from a **web page**
|
||||
- Simple HTML + JavaScript + PHP implementation
|
||||
- Customizable buttons for multiple computers
|
||||
- Runs on Synology NAS with **Web Station + PHP**
|
||||
|
||||
## 📌 Prerequisites
|
||||
- Synology NAS with **Web Station** and **PHP** installed
|
||||
- Apache enabled
|
||||
- Basic network configuration (broadcast address of your subnet)
|
||||
|
||||
## 🚀 Installation
|
||||
|
||||
[WOL with synology](https://blog.wuibaille.fr/2024/08/wol-with-synology/)
|
||||
31
Synology-WOL/wol.php
Normal file
31
Synology-WOL/wol.php
Normal file
@@ -0,0 +1,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";
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user