Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =====================================
- <?php
- /*
- 230209B - OK WORKING
- */
- //PHP_WOL::send('lab13-bl64-laptopprobpw', '64:31:50:69:7c:06', 9);
- //https://stackoverflow.com/questions/6055293/wake-on-lan-script-that-works/20065289
- $broadcast_ip="192.168.1.255";
- /*
- $pc_array= array((64:31:50:69:7e:9e),(00:19:99:6d:54:66),(00:19:99:6a:a2:56)
- ,(00:19:99:78:cf:5d),(00:19:99:6e:e7:a1),(00:24:7e:02:01:62),(00:19:99:72:4c:79)
- ,(00:18:8b:03:21:8c),(64:31:50:69:3c:85),(00:19:99:7a:36:70),(00:19:99:78:51:f5),(64:31:50:69:7c:06)
- );
- */
- function wol($broadcast, $mac){
- $mac_array = preg_split('#:#', $mac); //print_r($mac_array);
- $hwaddr = '';
- foreach($mac_array AS $octet){
- $hwaddr .= chr(hexdec($octet));
- }
- //Magic Packet
- $packet = '';
- for ($i = 1; $i <= 6; $i++){
- $packet .= chr(255);
- }
- for ($i = 1; $i <= 16; $i++){
- $packet .= $hwaddr;
- }
- //set up socket
- $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
- if ($sock){
- $options = socket_set_option($sock, 1, 6, true);
- if ($options >=0){
- $e = socket_sendto($sock, $packet, strlen($packet), 0, $broadcast, 7);
- socket_close($sock);
- }
- }
- } //end function wol
- $mymac = "64:31:50:69:7c:06";
- wol($broadcast_ip, $mymac);
- echo 'WOL sent to '.$mymac;
- ?>
- ===================================
- ======================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement