You are hereScript Wake on WAN
Script Wake on WAN
Questo script lo lancio per accedere da remoto il mio computer usando il WOL (Wake on LAN).
Sul mio router ho impostato una regola di NAT che se riceve una richiesta UDP su una determinata porta la gira in broadcast alla mia rete locale.
In questo modo ottengo un Wake on LAN remoto.
Mi faccio inoltre mandare una mail di avviso.
Ammetto di non ricordare dove ho trovato lo script iniziale che poi ho modificato per le mie esigenze.
So solo che l'intestazione dello script riportava:
# Wake on LAN - (c) HotKey@spr.at, upgraded by Murzik
# Modified by Allan Barizo http://www.hackernotcracker.com
Ecco il codice
include("Mail.php");
//Invia la mail usando la classe di pear
function Invia_Mail($mittente,$destinatario,$soggetto,$messaggio)
{
$recipients = $destinatario;
$headers["From"] = $mittente;
$headers["To"] = $destinatario;
$headers["Subject"] = $soggetto;
$body = $messaggio;
$params["host"] = "localhost";
$params["port"] = "25";
$params["auth"] = false;
$params["username"] = "";
$params["password"] = "";
// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory("smtp", $params);
$mail_object->send($recipients, $headers, $body);
}
function WakeOnLan($addr, $mac,$socket_number)
{
$addr_byte = explode(':', $mac);
$hw_addr = '';
for ($a=0; $a < 6; $a++) $hw_addr .= chr(hexdec($addr_byte[$a]));
$msg = chr(255).chr(255).chr(255).chr(255).chr(255).chr(255);
for ($a = 1; $a <= 16; $a++) $msg .= $hw_addr;
// send it to the broadcast address using UDP
// SQL_BROADCAST option isn't help!!
$s = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
if ($s == false)
{
echo "Error creating socket!\n";
echo "Error code is '".socket_last_error($s)."' - " . socket_strerror(socket_last_error($s));
}
else
{
// setting a broadcast option to socket:
$opt_ret = socket_set_option($s, 1, 6, TRUE);
if($opt_ret < 0)
{
echo "setsockopt() failed, error: " . strerror($opt_ret) . "\n";
}
$e = socket_sendto($s, $msg, strlen($msg), 0, $addr, $socket_number);
socket_close($s);
echo "Magic Packet sent (".$e.") to ".$addr;
}
}
// Port number where the computer is listening. Usually, any number between 1-40000 will do. Normally people choose 7 or 9.
$socket_number = "12345";
// MAC Address of the listening computer's network device
//$mac_addy = "FF:FF:FF:FF:FF:FF";
$mac_addy = "";
// IP address of the listening computer. Input the domain name if you are using a hostname (like when under Dynamic DNS/IP)
$ip_addy = "";
WakeOnLan($ip_addy, $mac_addy,$socket_number);
Invia_Mail("pippo@pluto.it","pippo@pluto.it","Attivazione WOW","Ciao Roberto,\nqualcuno ha attivato yoda usando il meccanismo WOW.\nSpero sia stato tu!");
- Login per inviare commenti






Prova a guardare questo e dimmi cosa ne pensi.
Ciao
http://www.wollydigital.eu
Fa la stessa cosa... L'importante è che ci sia il WOL (Wake on lan) sul pc che vuoi accendere.
Però una volta che hai un router e i pc sono abilitati al WOL non è difficile con uno scrippettino fare in modo che funzioni anche via internet.
Se non hai tempo e non sei un programmatore visto il prezzo non eccessivo sembra una bella soluzione