LonghornPHP 2026

Voting

: eight plus one?
(Example: nine)

The Note You're Voting On

f.moisant
20 years ago
This function to send Magic Packet works really !!!

/********/
<?php
function wake($ip, $mac, $port) 
{
  $nic = fsockopen("udp://" . $ip, $port); 
  if($nic) 
  { 
    $packet = ""; 
    for($i = 0; $i < 6; $i++) 
       $packet .= chr(0xFF);
    for($j = 0; $j < 16; $j++)
    {
      for($k = 0; $k < 6; $k++) 
      {
        $str = substr($mac, $k * 2, 2);
        $dec = hexdec($str);
        $packet .= chr($dec);
      }
    }
    $ret = fwrite($nic, $packet);
    fclose($nic); 
    if($ret)
      return true; 
  } 
  return false;
} 
?>

/********/

Executed with:
wake('123.123.123.123', '112233445566', 9);

<< Back to user notes page

To Top