0الارم گھڑی لوگوپی ایچ پی / JavaScript to wake a PC remotely

I have an HTPC and a net­work serv­er on my net­work. My serv­er is always on, لیکن HTPC sleeps when it is not in use. If I want to sched­ule record­ings remotely I need a way to wake the HTPCThe solu­tion I came up with is to provide a webpage on my serv­er (pass­word pro­tec­ted) that wakes the HTPC and then redir­ects to the web inter­face of the remote con­trol app of the HTPCBelow is the code for any­one interested…

[php language=“htmlscript”]<ایچ ٹی ایم ایل>
<head>
<meta http-equiv=‘refresh’ content=’11;url=address of htpc here’ />
<script type=“text/javascript”>
// time is the num­ber of seconds left
// name is the text part of the con­tain­er to insert count­down in
// num is the unique id of the con­tain­er. Allows for more than 1 per page
func­tion countdown(وقت, نام, num)
{
// grab the ele­ment object of the count­down container
count­down­Div = document.getElementById(name + num);
// cal­cu­late num­ber of minutes from the seconds
minutes = Math.floor(time / 60);
// remainder is num­ber of seconds
seconds = time % 60;
// add the cur­rent count­down dis­play to the con­tain­er specified
countdownDiv.innerHTML = ‘after ’ + چلیں + ’ seconds, please wait’;
اگر(time == 1)countdownDiv.innerHTML = ‘after ’ + چلیں + ’ second, please wait’;
// if time is up remove the edit div, oth­er­wise repeat every second
اگر(وقت <= 0) countdownDiv.innerHTML = ‘now…’;
else setTimeout(‘countdown( + –time + ,“ ‘ + نام + ’ ”,“ ‘ + num + ‘”);, 1000);
}
</سکرپٹ>
</head>
<body bgcolor=‘#000022’ style=‘text-align: cen­ter; col­or: سفید; pad­ding-top: 30پکسلز;>
<h2>
The ٹی وی inter­face will auto­mat­ic­ally load <div id=“div_name1” style=“display:inline;"></div کے>
<script type=“text/javascript”>countdown(12, “div_name”, 1)</سکرپٹ>
</h2>
<?پی ایچ پی
flush();
$addr_byte = explode(:, “MAC Address of htpc here”);
$hw_addr = ”;
کے لئے ($a=0; $ایک <6; $a++) $hw_addr .= chr(hexdec($addr_byte[$ایک]));
$msg = chr(255).chr(255).chr(255).chr(255).chr(255).chr(255);
کے لئے ($a = 1; $ایک <= 16; $a++) $msg .= $hw_addr;
$s = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
$opt_ret = socket_set_option($ے, 1, 6, TRUE);
اگر(socket_sendto($ے, $msg, strlen($msg), 0, “loc­al sub­net address here”, “7”)) {socket_close($ے);return TRUE;}اور {return FALSE;}
?>
</جسم>
</ایچ ٹی ایم ایل>[/پی ایچ پی]

جواب چھوڑیں