<?php
$mac = '80:E8:2C:EF:0A:53'; // MAC-Adresse des PCs
$broadcast = '192.168.178.255'; // Broadcast-Adresse des Netzwerks
$mac_array = explode(':', $mac);
$hwaddr = '';
foreach($mac_array as $octet) {
$hwaddr .= chr(hexdec($octet));
}
$packet = str_repeat(chr(0xff), 6).str_repeat($hwaddr, 16);
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_set_option($sock, SOL_SOCKET, SO_BROADCAST, 1);
socket_sendto($sock, $packet, strlen($packet), 0, $broadcast, 7);
socket_close($sock);
if (extension_loaded('gmp')) {
echo 'Magic Packet gesendet.';
} else {
echo 'gmp-Erweiterung ist nicht aktiviert.';
}
?>