Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trying to make simple WakeOnLan script with PHP
- <?php
- //check if server is up and running
- $alive = fsockopen("XXX.168.1.1", 80, $errno, $errstr, 2);
- if (!$alive) {
- echo "<h1>Server is Down!</h1>";
- echo "I will try to turn it on now...";
- //Creating magic packet
- $mac_address = str_repeat("XXX5XXXX5XXX", 16);
- $msg = "FFFFFFFFFFFF " . "$mac_address" . "000000000000";
- $host_addr = "XXX.168.1.1";
- $host_port = "X";
- //Connect send and close connection
- $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
- $socket_data = socket_send($socket, $msg, strlen($msg), 0, $host_addr, $host_port);
- socket_close($socket);
- //testing
- //echo
- } else {
- echo "<h1>Server is Up!</h1>";
- fclose($alive);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment