} else { $SMARTY->assign('inform_msg', 'パラメータが不正です。'); } break; // デバイス起動 // デバイス起動 case 'wake': if (isset($GET_DATA['mac_addr']) && $GET_DATA['mac_addr'] != '') { if (isset($GET_DATA['ip_addr']) && $GET_DATA['ip_addr'] != '') { $device_name = $GET_DATA['ip_addr']; } else { $device_name = $DEV_LIST[$GET_DATA['mac_addr']]; } UtilLog::writeLog('WOLパケットを送信 Name:' . $device_name . ' MAC:' . $GET_DATA['mac_addr'], 'ACCESS'); $ipObj = new UtilIPv4(CIDR_INFO); if (!WakeOnLan($ipObj->broadcast(), $GET_DATA['mac_addr'])) { $SMARTY->assign('inform_msg', "「{$device_name}」の起動に失敗しました。"); } else { $SMARTY->assign('inform_msg', "「{$device_name}」の起動に成功しました。"); } } else { $SMARTY->assign('inform_msg', 'パラメータが不正です。'); } break; // 追加フォーム(手動) // 追加フォーム(手動) case 'append_form1': $SMARTY->assign('input_msg', 'MACアドレスとデバイス名を入力してください。'); $param = array(); $param['mode'] = 'append'; $SMARTY->assign('form_param', UtilString::buildQueryString($param));
exit; } if (isset($_GET["LaunchRemoteInstall"])) { LaunchRemoteInstall(); exit; } if (isset($_GET["restart-web-server"])) { RestartWebServer(); exit; } if (isset($_GET["restart-artica-status"])) { RestartArticaStatus(); exit; } if (isset($_GET["wake-on-lan"])) { WakeOnLan(); exit; } if (isset($_GET["net-ads-leave"])) { net_ads_leave(); exit; } if (isset($_GET["process1-force"])) { process1_force(); exit; } if (isset($_GET["right-status"])) { right_status(); exit; } if (isset($_GET["RestartApacheGroupwareForce"])) {
echo "Error creating socket!\n"; echo "Error code is '" . socket_last_error($s) . "' - " . socket_strerror(socket_last_error($s)); return FALSE; } else { // setting a broadcast option to socket: $opt_ret = socket_set_option($s, 1, 6, TRUE); if ($opt_ret < 0) { echo "setsockopt() failed, error: " . strerror($opt_ret) . "\n"; return FALSE; } if (socket_sendto($s, $msg, strlen($msg), 0, $ip_address, $socket_number)) { echo "Magic Packet sent successfully!"; socket_close($s); return TRUE; } else { echo "Magic packet failed!"; return FALSE; } } } } } // Port number where the computer is listening. Usually, any number between 1-50000 will do. Normally people choose 7 or 9. $socket_number = 7; // MAC Address of the listening computer's network device $max_address = "00:04:76:A2:F6:A3"; // IP address of the listening computer. Input the domain name if you are using a hostname (like when under Dynamic DNS/IP) //$ip_addy = gethostbyname("myhomeserver.dynamicdns.org"); $ip_address = '10.10.13.104'; WakeOnLan($ip_address, $max_address, $socket_number);
function switch_computer($device, $action) { debug("switch Computer for device='" . (string) $device->id . "' action='" . (string) $action . "'"); if (empty($device->address->masterdip)) { echo "ERROR: masterdip (PC-IP) ist ungültig für device id " . $device->id; return; } if (empty($device->address->slavedip)) { echo "ERROR: slavedip (MAC Adresse) ist ungültig für device id " . $device->id; return; } $IPpc = $device->address->masterdip; // MAC Address des lauschenden Computers $mac_addr = $device->address->slavedip; if ($action == "OFF") { // Shutdown eines Windows-PC, muss in den Computerrichtlinien für remote erlaubt werden //exec("shutdown.exe -s -f -m \\\\$IPpc -t 30"); // von einem Windowsserver exec("net rpc shutdown -I {$IPpc} -U gast%"); // von einem LINUXserver echo "Shutdown ausgeführt für {$IPpc} \n"; } else { /* Port number auf die der Computer hört. Normalerweise zwischen 1-50000. Standard ist 7 or 9. */ $socket_number = "7"; //Broadcast ip ermitteln $pos = strrpos($IPpc, '.'); if ($pos !== false) { $IPpc = substr($IPpc, 0, $pos) . ".255"; } WakeOnLan($IPpc, $mac_addr, $socket_number); echo "Wake on Lan ausgeführt für {$IPpc} {$mac_addr} \n"; } return ""; }
$count_system_max = "10000"; echo "<td>\n"; $hostname = $_GET["hostname"]; $mac = $_GET["mac"]; if (isset($_GET["socket_number"])) { $socket_number = $_GET["socket_number"]; } else { $socket_number = "12287"; } // Set the Search Button action echo "<div class=\"main_each\">"; echo "<form action=\"search.php?sub=no\" method=\"post\">"; echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\" width=\"100%\" class=\"content\">"; $this_error = ''; // Fire off the WOL magic packet. $result = WakeOnLan($hostname, $mac, $socket_number, $this_error); // Show the result $bgcolor = "#F1F1F1"; echo "<td><img src='images/tv_l.png' width='64' height='64' alt='' /><td><b>" . __("Wake on LAN") . "</b></td>"; // Show Hostname $bgcolor = change_row_color($bgcolor, $bg1, $bg2); echo "<tr bgcolor=\"" . $bgcolor . "\"><td>" . __("Hostname") . ":</td><td>" . $hostname . "</td></tr>"; // Show Target MAC address $bgcolor = change_row_color($bgcolor, $bg1, $bg2); echo "<tr bgcolor=\"" . $bgcolor . "\"><td>" . __("Mac Address") . ":</td><td>" . $mac . "</td></tr>"; // Show Target Socket Number $bgcolor = change_row_color($bgcolor, $bg1, $bg2); echo "<tr bgcolor=\"" . $bgcolor . "\"><td>" . __("Socket Number") . ":</td><td>" . $socket_number . "</td></tr>"; // Show Result $bgcolor = change_row_color($bgcolor, $bg1, $bg2); echo "<tr bgcolor=\"" . $bgcolor . "\"><td>" . __("Result") . ":</td><td>" . $result . "</td></tr>";
$content = bin2hex($msg); echo "Magic Packet Sent!<BR>\n"; echo "Data: <textarea readonly rows=\"1\" name=\"content\" cols=\"" . strlen($content) . "\">" . $content . "</textarea><BR>\n"; echo "Port: " . $socket_number . "<br>\n"; echo "MAC: " . $_GET['wake_machine'] . "<BR>\n"; socket_close($s); return TRUE; } else { echo "Magic Packet failed to send!<BR>"; return FALSE; } } } $result = null; if ($_GET["wake_machine"] != "") { $result = WakeOnLan("192.168.2.255", $_GET["wake_machine"], $port); } if ($result != null) { echo "<HR>WOL for " . $_GET["wake_machine"] . " was successful!<BR>\n"; } ?> <title>Wake On LAN</title> <s:select label="WakeOnLan" headerKey="-1" headerValue="Select Machine" list="machines" name="WakeOnLan" /> <form name="WakeOnLan" method="GET" action="index.php"> <td class="WOL">
// SQL_BROADCAST option isn't help!! $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)); return FALSE; } else { // setting a broadcast option to socket: $opt_ret = socket_set_option($s, 1, 6, TRUE); if ($opt_ret < 0) { echo "setsockopt() failed, error: " . strerror($opt_ret) . "\n"; return FALSE; } if (socket_sendto($s, $msg, strlen($msg), 0, $addr, $socket_number)) { echo "Magic Packet sent successfully!"; socket_close($s); return TRUE; } else { echo "Magic packet failed!"; return FALSE; } } } // Port number where the computer is listening. Usually, any number between 1-50000 will do. Normally people choose 7 or 9. $socket_number = "9"; // MAC Address of the listening computer's network device $mac_addy = "00:0E:A6:2D:A5:9C"; // IP address of the listening computer. Input the domain name if you are using a hostname (like when under Dynamic DNS/IP) $ip_addy = gethostbyname("10.96.4.47"); WakeOnLan($ip_addy, $mac_addy, $socket_number);
$timeout = 1; $socket = @fsockopen($ip, $port, $errno, $errstr, $timeout); $online = $socket !== false; if ($online) { return "on"; } else { return "off"; } fclose($socket); } $servers = array($array = ["id" => "0", "type" => "N", "name" => "Callant NAS", "ip" => "192.168.5.5", "publicip" => "78.22.186.5", "port" => "80", "mac" => "00-11-32-2E-86-FD", "wolport" => "9", "broadcastaddress" => "192.168.5.255"], $array = ["id" => "1", "type" => "S", "name" => "Plex Media Server", "ip" => "192.168.5.6", "publicip" => "78.22.186.5", "port" => "81", "mac" => "00:15:C5:3B:FF:23", "wolport" => "9", "broadcastaddress" => "192.168.5.255"], $array = ["id" => "2", "type" => "D", "name" => "Bart's Desktop", "ip" => "192.168.5.150", "mac" => ""]); if (isset($_POST['send']) && isset($_POST['id'])) { $server = $servers[$_POST['id']]; $send = $_POST['send']; if ($send == "Power On") { WakeOnLan($server["broadcastaddress"], $server["mac"], $server["wolport"]); } else { if ($send == "Power Off") { header('location: http://' . $server["publicip"] . ':' . $server["port"] . '/shutdown.php'); } else { print_r("Invalid action!"); } } } ?> <html> <head> <title>OnOff</title> <style> form, input, div
if(isset($_GET["SaveClusterConfigFile"])){SaveClusterConfigFile();exit;} if(isset($_GET["SmtpNotificationConfig"])){SmtpNotificationConfig();exit;} if(isset($_GET["refresh-frontend"])){Refresh_frontend();exit;} if(isset($_GET["find-program"])){find_sock_program();exit;} if(isset($_GET["syslog-query"])){SYSLOG_QUERY();exit;} if(isset($_GET["aptcheck"])){aptcheck();exit;} if(isset($_GET["SetServerTime"])){SetServerTime();exit;} if(isset($_GET["CompileSSHDRules"])){CompileSSHDRules();exit;} if(isset($_GET["ou-ldap-import-execute"])){LDAP_IMPORT_EXEC();exit;} if(isset($_GET["sys-sync-paquages"])){SysSyncPaquages();exit;} if(isset($_GET["LaunchRemoteInstall"])){LaunchRemoteInstall();exit;} if(isset($_GET["restart-web-server"])){RestartWebServer();exit;} if(isset($_GET["restart-artica-status"])){RestartArticaStatus();exit;} if(isset($_GET["wake-on-lan"])){WakeOnLan();exit;} if(isset($_GET["net-ads-leave"])){net_ads_leave();exit;} if(isset($_GET["process1-force"])){process1_force();exit;} if(isset($_GET["right-status"])){right_status();exit;} if(isset($_GET["RestartApacheGroupwareForce"])){RestartApacheGroupwareForce();exit;} if(isset($_GET["RestartApacheGroupwareNoForce"])){RestartApacheGroupwareNoForce();exit;} if(isset($_GET["ApacheDirDelete"])){ApacheDirDelete();exit;} //snort if(isset($_GET["snort-networks"])){snort_networks();exit;} if(isset($_GET["restart-snort"])){restart_snort();exit;}