Benötigt jQuery.
<script type="text/javascript"> status("shutdown7.com", 5556); shutdown7("shutdown7.com", "Shutdown", 60, 5556, "Password"); wol("shutdown7.com", "0123456789ABCDEF"); function shutdown7(_url, _mode, _t, _port, _password) { ajax = $.ajax({ type: "POST", cache: false, url: "shutdown7.com/webui.php", data: { url: _url, modi: _mode, port: _port, password: _password, t: _t, client: "WebUI"}, dataType: "text", complete: function(msg, ok) { var status = msg.responseText; alert("Status: " + ok + "\nAntwort: " + status); } }); } function wol(_url, _mac) { ajax = $.ajax({ type: "POST", cache: false, url: "shutdown7.com/webui.php", data: { url: _url, modi: "WOL", mac: _mac, client: "WebUI"}, dataType: "text", complete: function(msg, ok) { var status = msg.responseText; alert("Status: " + ok + "\nAntwort: " + status); } }); } function status(_url, _port) { ajax = $.ajax({ type: "POST", cache: false, url: "shutdown7.com/webui.php", data: { url: _url, port: _port, status: true, client: "WebUI"}, dataType: "text", complete: function(msg, ok) { var status = msg.responseText; alert("Status: " + ok + "\nAntwort: " + status); } }); } </script>
<?php status("shutdown7.com", 5556); shutdown7("shutdown7.com", "Shutdown", 60, 5556, "Password"); wol("shutdown7.com", "0123456789ABCDEF"); function shutdown7($_url, $_mode, $_t, $_port, $_password) { $post_data = array( 'url' => $_url, 'modi' => $_mode, 't' => $_t, 'port' => $_port, 'password' => $_password, 'client' => 'WebUI', ); $result = post_request('http://shutdown7.com/webui.php', $post_data); if ($result['status'] == 'ok'){ //echo $result['header']; echo $result['content']; } else echo 'A error occured: ' . $result['error']; } function wol($_url, $_mac) { $post_data = array( 'url' => $_url, 'mac' => $_mac, 'client' => 'WebUI', ); $result = post_request('http://shutdown7.com/webui.php', $post_data); if ($result['status'] == 'ok'){ //echo $result['header']; echo $result['content']; } else echo 'A error occured: ' . $result['error']; } function status($_url, $_port) { $post_data = array( 'url' => $_url, 'port' => $_port, 'status' => true, 'client' => 'WebUI', ); $result = post_request('http://shutdown7.com/webui.php', $post_data); if ($result['status'] == 'ok'){ //echo $result['header']; echo $result['content']; } else echo 'A error occured: ' . $result['error']; } function post_request($url, $data, $referer='') { $data = http_build_query($data, '', '&'); $url = parse_url($url); if ($url['scheme'] != 'http') { die('Error: Only HTTP request are supported !'); } $host = $url['host']; $path = $url['path']; $fp = fsockopen($host, 80, $errno, $errstr, 30); if ($fp){ fputs($fp, "POST $path HTTP/1.1\r\n"); fputs($fp, "Host: $host\r\n"); if ($referer != '') fputs($fp, "Referer: $referer\r\n"); fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); fputs($fp, "Content-length: ". strlen($data) ."\r\n"); fputs($fp, "Connection: close\r\n\r\n"); fputs($fp, $data); $result = ''; while(!feof($fp)) { $result .= fgets($fp, 128); } } else { return array( 'status' => 'err', 'error' => "$errstr ($errno)" ); } fclose($fp); $result = explode("\r\n\r\n", $result, 2); $header = isset($result[0]) ? $result[0] : ''; $content = isset($result[1]) ? $result[1] : ''; return array( 'status' => 'ok', 'header' => $header, 'content' => $content ); } ?>