Permalink
Browse files

Merge pull request #1 from apfelbox/master

Two small suggestions
  • Loading branch information...
2 parents ffa66a8 + 33c3ed8 commit 53d531eb92e79cabb0b68fd11d69ff7fd489cb8e @PHPGangsta committed Sep 3, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 PHPGangsta/WakeOnLAN.php
View
@@ -9,7 +9,7 @@ public static function wakeUp($macAddressHexadecimal, $broadcastAddress)
$macAddressHexadecimal = str_replace(':', '', $macAddressHexadecimal);
// check if $macAddress is a valid mac address
- if (!preg_match('/[a-f0-9]/i', $macAddressHexadecimal)) {
+ if (!ctype_xdigit($macAddressHexadecimal)) {
throw new \Exception('Mac address invalid, only 0-9 and a-f are allowed');
}
@@ -18,7 +18,7 @@ public static function wakeUp($macAddressHexadecimal, $broadcastAddress)
$magicPacket = str_repeat(chr(0xff), 6).str_repeat($macAddressBinary, 16);
if (!$fp = fsockopen('udp://' . $broadcastAddress, 7, $errno, $errstr, 2)) {
- throw new \Exception('Cannot open UDP socket');
+ throw new \Exception("Cannot open UDP socket: {$errstr}", $errno);
}
fputs($fp, $magicPacket);
fclose($fp);

0 comments on commit 53d531e

Please sign in to comment.