maj wol.php

This commit is contained in:
SVNET Libre 2017-11-04 17:52:23 +01:00
parent 496bc2862e
commit 49249c30cb

23
wol.php
View File

@ -1,18 +1,5 @@
<?php
// PHP-Wake-On-LAN
// Par SVNET Libre
// GNU GENERAL PUBLIC LICENSE
// Version 2, June 1991
// Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
// 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
@ -24,8 +11,7 @@
if ( !$this->nic ) {
fclose($this->nic);
return false;
}
else{
} else {
fwrite($this->nic, $this->pacquet($mac));
fclose($this->nic);
return true;
@ -35,9 +21,12 @@
//Préparation des paquets à envoyer
private function pacquet($Mac) {
$packet = "";
for($i = 0; $i < 6; $i++){$packet .= chr(0xFF);}
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)));}
for($i = 0; $i < 12; $i=$i + 2) {
$packet .= chr(hexdec(substr($Mac, $i, 2)));
}
}
return $packet;
}