'; $action = $_GET['action']; $sure = $_GET['sure']; if ('boot' == $action && empty($sure)) { echo '您確定要啟動VPS嗎 ?確定'; } elseif ('shutdown' == $action && empty($sure)) { echo '您確定要關閉VPS嗎 ?確定'; } elseif ('reboot' == $action && empty($sure)) { echo '您確定要重新啟動VPS嗎 ?確定'; } elseif ('info' == $action) { $url = "https://central.idc-service.net/api/client/command.php?key=$key&hash=$hash&action=$action&bw=true"; $data = file_get_contents($url); // Parse the returned data and build an array preg_match_all('/<(.*?)>([^<]+)<\/\\1>/i', $data, $match); $result = array(); foreach ($match[1] as $x => $y) { $result[$y] = $match[2][$x]; } echo '流量使用(total,used,free,percentused) : '.$result['bw']; } elseif ($action != 'status' && $action != 'boot' && $action != 'shutdown' && $action != 'reboot' && $action != 'info') { echo "操作錯誤!"; } else { $url = "https://central.idc-service.net/api/client/command.php?key=$key&hash=$hash&action=$action"; $data = file_get_contents($url); // Parse the returned data and build an array preg_match_all('/<(.*?)>([^<]+)<\/\\1>/i', $data, $match); $result = array(); foreach ($match[1] as $x => $y) { $result[$y] = $match[2][$x]; } //錯誤訊息 if ($result["status"] == "error") { echo $result["statusmsg"]; } elseif ($result["status"] == "success") { if ($result["statusmsg"] == "online") { echo "目前主機狀態為 online !"; } elseif ($result["statusmsg"] == "offline") { echo "目前主機狀態為 offline !"; } elseif ($result["statusmsg"] == "rebooted") { echo "目前主機正執行 reboot !"; } elseif ($result["statusmsg"] == "shutdown") { echo "目前主機正執行 shutdown !"; } elseif ($result["statusmsg"] == "booted") { echo "目前主機正執行 boot !"; } else { echo "Status message unknown!"; } } } echo '
'; } ?>