1<?php
2/**
3 * Server Status Monitoring Endpoint
4 *
5 * This file can be uploaded to each of your linux web servers in order to
6 * display current load and uptime statistics for the server in the Server
7 * Status page of the WHMCS Client Area and Admin Area Homepage.
8 *
9 * @package WHMCS
10 * @author WHMCS Limited <development@whmcs.com>
11 * @copyright Copyright (c) WHMCS Limited 2005-2019
12 * @license https://www.whmcs.com/license/ WHMCS Eula
13 * @version $Id$
14 * @link https://www.whmcs.com/
15 */
16
17error_reporting(0);
18
19$action = (isset($_GET['action'])) ? $_GET['action'] : '';
20
21if ($action=="phpinfo") {
22
23 /**
24 * Uncomment the line below to allow users to view PHP Info for your
25 * server. This potentially allows access to information a malicious
26 * user could use to find weaknesses in your server.
27 */
28
29 //phpinfo();
30
31} else {
32
33 $load = file_get_contents("/proc/loadavg");
34 $load = explode(' ',$load);
35 $load = $load[0];
36 if (!$load && function_exists('exec')) {
37 $reguptime=trim(exec("uptime"));
38 if ($reguptime) if (preg_match("/, *(\d) (users?), .*: (.*), (.*), (.*)/",$reguptime,$uptime)) $load = $uptime[3];
39 }
40
41 $uptime_text = file_get_contents("/proc/uptime");
42 $uptime = substr($uptime_text,0,strpos($uptime_text," "));
43 if (!$uptime && function_exists('shell_exec')) $uptime = shell_exec("cut -d. -f1 /proc/uptime");
44 $days = floor($uptime/60/60/24);
45 $hours = str_pad($uptime/60/60%24,2,"0",STR_PAD_LEFT);
46 $mins = str_pad($uptime/60%60,2,"0",STR_PAD_LEFT);
47 $secs = str_pad($uptime%60,2,"0",STR_PAD_LEFT);
48
49 $phpver = phpversion();
50 $mysqlver = (function_exists("mysql_get_client_info")) ? mysql_get_client_info() : '-';
51 $zendver = (function_exists("zend_version")) ? zend_version() : '-';
52
53 echo "<load>$load</load>\n";
54 echo "<uptime>$days Days $hours:$mins:$secs</uptime>\n";
55
56 /**
57 * WHMCS does not rely on the following version information for tracking
58 * server status.
59 *
60 * Some 3rd-party integrations may rely on previous revisions of this file that
61 * exposed said information. Users who have 3rd-party functionality which
62 * require this may uncomment the lines at their own risk.
63 *
64 * Future revisions to this file may remove those commented lines and this
65 * documentation block entirely. If a 3rd-party integration that you use
66 * relies on this, please notify them that access to that information via
67 * this script is deprecated as of WHMCS 5.3.9-release.1.
68 *
69 * Anyone is free to contact WHMCS Support for further information or help
70 * resolving integration issues.
71 */
72
73 //echo "<phpver>$phpver</phpver>\n";
74 //echo "<mysqlver>$mysqlver</mysqlver>\n";
75 //echo "<zendver>$zendver</zendver>\n";
76
77}
78