Gå til innhold

Wake on Lan PHP [LØST]


Anbefalte innlegg

hei, jeg fant dette php scriptet på nettet for WoL, men det virker ikke.

<?php

flush();
function wol($addr, $mac,$socket_number)
{
  $addr_byte = explode(':', $mac);
  $hw_addr = '';


  for ($a=0; $a < 6; $a++) {
  $hw_addr .= chr(hexdec($addr_byte[$a]));

  }

  $msg = chr(255).chr(255).chr(255).chr(255).chr(255).chr(255);

  for ($a = 1; $a <= 16; $a++){
  $msg .= $hw_addr;
  }

  $s = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
  if ($s == false)
  {
  echo "Error creating socket!\n";
  echo "Error code is '".socket_last_error($s)."' - " . socket_strerror(socket_last_error($s));
  }
  else
  {
  $opt_ret = socket_set_option($s, 1, 6, TRUE);
  if($opt_ret < 0)
	 echo "setsockopt() failed, error: " . strerror($opt_ret) . "\n";
  $e = socket_sendto($s, $msg, strlen($msg), 0, $addr, $socket_number);
  socket_close($s);
  echo "Magic Packet sent (".$e.") to ".$addr;
  }
}

$socket_number = "9";		// any number between 1-40000
$mac_addy = "00:19:21:3E:E9:0E"; // superman (wired lan)
$ip_addy = "10.0.0.3";	 // broadcast address of my network

/*
The broadcast address is the IP address prefix with 255 appended at the end.
Mine is 192.168.0.255. Everything that is directed to the broadcast address
goes to every computer on the network.
*/

wol($ip_addy, $mac_addy,$socket_number);

?>

noen som kan hjelpe meg?

Endret av The_Lozer
Lenke til kommentar
Videoannonse
Annonse

WOL: Wake-on-LAN Tutorial with Bonus PHP Script

Har du sjekket følgende? Kan du bruke WoL uten dette skriptet?

Common Hurdles

 

There are a couple of common problems computer users come across when trying to implement Wake-on-LAN.

 

* Physical Network Layer - To my knowledge, WOL will only work with Ethernet. Sorry! No Wi-fi! (Though, I heard that there are some very rare exceptions!)

* Incompatible BIOS or network device - Sometimes the BIOS or the Ethernet Device will not support WOL. These are the two main components of Wake-on-LAN. The Ethernet detects the "magic packet" and the BIOS turns the computer on.

* Network Infrastructure - In order for WOL to work, the "magic packet" must go through a direct, IP-address-specific route. That means if there are any routers or if your computers on the network share a public IP address then you'll need to do some port mapping when send magic packet via the Internet.

Har du satt opp IP og mac-adresse skikkelig? Du må gi mer info enn bare det skriptet.

Lenke til kommentar

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
  • Hvem er aktive   0 medlemmer

    • Ingen innloggede medlemmer aktive
×
×
  • Opprett ny...