-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.php
72 lines (66 loc) · 2.1 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
$mac1 = str_replace ( "-", "",$_GET['MAC'] ) ;
$mac = str_replace ( ":", "",$mac1 ) ;
$IP_ADDRESS=$_GET['IP'];
$MAC_ADDRESS=$mac;
$PORT = $_GET['PORT'];
class Wol{
private $nic;
public function wake($mac,$ip,$port){
$this->nic = fsockopen("udp://$ip", "$port");
if( !$this->nic ){
fclose($this->nic);
return false;
}
else{
fwrite($this->nic, $this->pacquet($mac));
fclose($this->nic);
return true;
}
}
private function pacquet($Mac){
$packet = "";
$packet = "\xFF\xFF\xFF\xFF\xFF\xFF";
for ($j = 0; $j < 16; $j++){
for($i = 0; $i < 12; $i=$i + 2){$packet .= chr(hexdec(substr($Mac, $i, 2)));}
}
return $packet;
}
}
$wol = new Wol();
$php_wal=$_GET['WAL'];
if ($php_wal!="OK") {
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Wake On Lan</title>
</head>
<body>
<form action="<?php echo $_SERVER['SCRIPT_NAME'];?>" method="get">
<input type="hidden" name="WAL" value="OK" >
<label for="ipa">IP :</label><input type="text" name="IP" id="ipa" value="0.0.0.0">
<label for="maca">MAC :</label><input type="text" name="MAC" id="maca" value="00000AAAAVVR">
<label for="porta">PORT :</label><input type="text" name="PORT" id="porta" value="9">
<input type="submit" value="Démarrer">
</form>
<h2>Vous voulez réveillez un pc sur votre reseau local ? Utilisez cette page ! <a href="local.html">Cliquez ICI !</a></h2>
</body>
</html>
<?php
exit();
}
$wol->wake("$MAC_ADDRESS","$IP_ADDRESS", "$PORT");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Wake On Lan</title>
</head>
<body>
Démarrage en cours...<br>
Vous revenez souvent ? Mettez cette page en racourci ! Quand vous la chargerez, elle lancera automatiquement l'ordinateur correspondant au ardresses IP, MAC entré.
</body>
</html>