Voici un script que j’utilise régulièrement pour démarrer mon pc à distance et pouvoir ensuite y accéder en ssh.

[php]<?php

$IP_ADDRESS="10.0.0.1";
$MAC_ADDRESS="0123456789ab";

class Wol{
private $nic;
public function wake($mac,$ip){
$this->nic = fsockopen("udp://$ip", 9);
if( !$this->nic ){
fclose($this->nic);
return false;
}
else{
fwrite($this->nic, $this->pacquet($mac));
fclose($this->nic);
return true;
}
}
private function pacquet($Mac){
$packet = "";
//for($i = 0; $i < 6; $i++){$packet .= chr(0xFF);}
$packet = "\xFF\xFF\xFF\xFF\xFF\xFF";
for ($j = 0; $j < 16; $j++){
for($i = 0; $i < 12; $i=$i + 2){$packet .= chr(hexdec(substr($Mac, $i, 2)));}
}
return $packet;
}
}

$wol = new Wol();

$php_wal=$_POST[‘WAL’];

if ($php_wal!="OK") {

?>
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Wake On Lan</title>
</head>
<body>
<form action="<?php echo $_SERVER[‘SCRIPT_NAME’];?>" method="post">
<input type="hidden" name="WAL" value="OK" >
<input type="submit" value="Démarrer" autofocus>
</form>
</body>
</html>

<?php
exit();
}
$wol->wake("$MAC_ADDRESS","$IP_ADDRESS");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Wake On Lan</title>
</head>
<body>
Démarrage en cours…
</body>
</html>[/php]