maj wol.php
This commit is contained in:
parent
496bc2862e
commit
49249c30cb
57
wol.php
57
wol.php
@ -1,44 +1,33 @@
|
|||||||
<?php
|
<?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'];
|
$addrmac = $_GET['mac'];
|
||||||
|
|
||||||
//Préparation du lien pour atteindre l'ordinateur distant
|
//Préparation du lien pour atteindre l'ordinateur distant
|
||||||
class Wol{
|
class Wol {
|
||||||
private $nic;
|
private $nic;
|
||||||
public function wake($mac){
|
public function wake($mac) {
|
||||||
$host = "udp://".$_GET['host'];
|
$host = "udp://".$_GET['host'];
|
||||||
$this->nic = fsockopen("$host", 9);
|
$this->nic = fsockopen("$host", 9);
|
||||||
if( !$this->nic ){
|
if ( !$this->nic ) {
|
||||||
fclose($this->nic);
|
fclose($this->nic);
|
||||||
return false;
|
return false;
|
||||||
}
|
} else {
|
||||||
else{
|
fwrite($this->nic, $this->pacquet($mac));
|
||||||
fwrite($this->nic, $this->pacquet($mac));
|
fclose($this->nic);
|
||||||
fclose($this->nic);
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//Préparation des paquets à envoyer
|
//Préparation des paquets à envoyer
|
||||||
private function pacquet($Mac){
|
private function pacquet($Mac) {
|
||||||
$packet = "";
|
$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 ($j = 0; $j < 16; $j++) {
|
||||||
}
|
for($i = 0; $i < 12; $i=$i + 2) {
|
||||||
|
$packet .= chr(hexdec(substr($Mac, $i, 2)));
|
||||||
|
}
|
||||||
|
}
|
||||||
return $packet;
|
return $packet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user