<?php
header("Location:
index.php", true, 301);
if (isset($_REQUEST["MAC"]) && (strlen($_REQUEST["MAC"]) == 17))
{
$MAC = $_REQUEST["MAC"];
$pole = explode(':', $MAC);
if (sizeof($pole) == 6) // je MAC dost dlouhá
na MAC?
{
$i = 0;
foreach ($pole as $Hodnota)
{
$MAC[$i] = sprintf("%02X", hexdec($Hodnota)); // projedeme a
převedeme HEX na BIN a zpět
}
print_r($MAC);
$MAC_wol = implode(":", $pole);
shell_exec('echo "'.$MAC_wol.'" >
/tmp/WOL.txt');
}
}
exit();
?>
Vlastní skript WOL.sh
#!/bin/sh
File="/tmp/WOL.txt"
if [ -f $File ]; then
MAC=$(cat $File)
echo $MAC
/usr/bin/etherwake -D -i "br-lan" "$MAC"
logger -s "Wake On Lan $MAC"
rm $File
fi
* * * * * root /usr/sbin/WOL.sh