forked from puarudz/WHMCS-7.8.0-decoded
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverstatus.php
executable file
·94 lines (92 loc) · 4.11 KB
/
serverstatus.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/*
* @ PHP 5.6
* @ Decoder version : 1.0.0.1
* @ Release on : 24.03.2018
* @ Website : http://EasyToYou.eu
*/
define("CLIENTAREA", true);
require "init.php";
$pagetitle = $_LANG["serverstatustitle"];
$breadcrumbnav = "<a href=\"index.php\">" . $_LANG["globalsystemname"] . "</a> > <a href=\"serverstatus.php\">" . $_LANG["serverstatustitle"] . "</a>";
$templatefile = "serverstatus";
$pageicon = "images/status_big.gif";
$displayTitle = Lang::trans("networkstatustitle");
$tagline = Lang::trans("networkstatussubtitle");
initialiseClientArea($pagetitle, $displayTitle, $tagline, $pageicon, $breadcrumbnav);
if ($CONFIG["NetworkIssuesRequireLogin"] && !isset($_SESSION["uid"])) {
$goto = "serverstatus";
require "login.php";
}
WHMCS\Session::release();
$servers = array();
$result = select_query("tblservers", "", "disabled=0 AND statusaddress!=''", "name", "ASC");
while ($data = mysql_fetch_array($result)) {
$name = $data["name"];
$ipaddress = $data["ipaddress"];
$statusaddress = $data["statusaddress"];
if (substr($statusaddress, -1, 1) != "/") {
$statusaddress .= "/";
}
if (substr($statusaddress, -9, 9) != "index.php") {
$statusaddress .= "index.php";
}
$servers[] = array("name" => $name, "ipaddress" => $ipaddress, "statusaddr" => $statusaddress, "phpinfourl" => $statusaddress . "?action=phpinfo", "serverload" => $serverload, "uptime" => $uptime, "phpver" => $phpver, "mysqlver" => $mysqlver, "zendver" => $zendver);
}
$smarty->assign("servers", $servers);
$smarty->register_function("get_port_status", "getPortStatus");
if ($whmcs->get_req_var("getstats")) {
$num = $whmcs->get_req_var("num");
$statusaddress = $servers[$num]["statusaddr"];
if (strpos($statusaddress, "index.php") === false) {
if (substr($statusaddress, -1, 1) != "/") {
$statusaddress .= "/";
}
$statusaddress .= "index.php";
}
$filecontents = curlCall($statusaddress, "");
preg_match("/\\<load\\>(.*?)\\<\\/load\\>/", $filecontents, $serverload);
preg_match("/\\<uptime\\>(.*?)\\<\\/uptime\\>/", $filecontents, $uptime);
preg_match("/\\<phpver\\>(.*?)\\<\\/phpver\\>/", $filecontents, $phpver);
preg_match("/\\<mysqlver\\>(.*?)\\<\\/mysqlver\\>/", $filecontents, $mysqlver);
preg_match("/\\<zendver\\>(.*?)\\<\\/zendver\\>/", $filecontents, $zendver);
$serverload = $serverload[1];
$uptime = $uptime[1];
$phpver = $phpver[1];
$mysqlver = $mysqlver[1];
$zendver = $zendver[1];
if (!$serverload) {
$serverload = $_LANG["serverstatusnotavailable"];
}
if (!$uptime) {
$uptime = $_LANG["serverstatusnotavailable"];
}
echo json_encode(array("load" => WHMCS\Input\Sanitize::encode($serverload), "uptime" => WHMCS\Input\Sanitize::encode($uptime), "phpver" => WHMCS\Input\Sanitize::encode($phpver), "mysqlver" => WHMCS\Input\Sanitize::encode($mysqlver), "zendver" => WHMCS\Input\Sanitize::encode($zendver)));
exit;
}
if ($whmcs->get_req_var("ping")) {
$num = (int) $whmcs->get_req_var("num");
$port = (int) $whmcs->get_req_var("port");
if (is_array($servers[$num])) {
$res = @fsockopen($servers[$num]["ipaddress"], $port, $errno, $errstr, 5);
echo "<img src=\"" . DI::make("asset")->getImgPath() . "/status" . ($res ? "ok" : "failed") . ".gif\" alt=\"" . $_LANG["serverstatus" . ($res ? "on" : "off") . "line"] . "\" width=\"16\" height=\"16\" />";
if ($res) {
fclose($res);
}
}
exit;
}
include "networkissues.php";
Menu::addContext("networkIssueStatusCounts", $issueStatusCounts);
Menu::primarySidebar("networkIssueList");
Menu::secondarySidebar("networkIssueList");
outputClientArea($templatefile, false, array("ClientAreaPageServerStatus"));
function getPortStatus($params, &$smarty)
{
global $servers;
$num = $params["num"];
$res = @fsockopen($servers[$num]["ipaddress"], $params["port"], $errno, $errstr, 5);
$status = "<img src=\"" . DI::make("asset")->getImgPath() . "/status" . ($res ? "ok" : "failed") . ".gif\" alt=\"" . $_LANG["serverstatus" . ($res ? "on" : "off") . "line"] . "\" width=\"16\" height=\"16\" />";
return $status;
}
?>