From 49249c30cbb08b9b1185b5805c7a31139097b265 Mon Sep 17 00:00:00 2001 From: SVNET Libre Date: Sat, 4 Nov 2017 17:52:23 +0100 Subject: [PATCH] maj wol.php --- wol.php | 57 +++++++++++++++++++++++---------------------------------- 1 file changed, 23 insertions(+), 34 deletions(-) diff --git a/wol.php b/wol.php index 05cd52d..c4261af 100644 --- a/wol.php +++ b/wol.php @@ -1,44 +1,33 @@ -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -// Everyone is permitted to copy and distribute verbatim copies -// of this license document, but changing it is not allowed. - -// La suite : https://git.framasoft.org/svnet/PHP-WOL/blob/master/LICENSE - $addrmac = $_GET['mac']; //Préparation du lien pour atteindre l'ordinateur distant - class Wol{ - private $nic; - public function wake($mac){ - $host = "udp://".$_GET['host']; - $this->nic = fsockopen("$host", 9); - if( !$this->nic ){ - fclose($this->nic); - return false; - } - else{ - fwrite($this->nic, $this->pacquet($mac)); - fclose($this->nic); - return true; - } - } + class Wol { + private $nic; + public function wake($mac) { + $host = "udp://".$_GET['host']; + $this->nic = fsockopen("$host", 9); + if ( !$this->nic ) { + fclose($this->nic); + return false; + } else { + fwrite($this->nic, $this->pacquet($mac)); + fclose($this->nic); + return true; + } + } //Préparation des paquets à envoyer - private function pacquet($Mac){ - $packet = ""; - for($i = 0; $i < 6; $i++){$packet .= chr(0xFF);} - for ($j = 0; $j < 16; $j++){ - for($i = 0; $i < 12; $i=$i + 2){$packet .= chr(hexdec(substr($Mac, $i, 2)));} - } +private function pacquet($Mac) { + $packet = ""; + for($i = 0; $i < 6; $i++){$packet .= chr(0xFF); + } + for ($j = 0; $j < 16; $j++) { + for($i = 0; $i < 12; $i=$i + 2) { + $packet .= chr(hexdec(substr($Mac, $i, 2))); + } + } return $packet; } }