07-26-2023, 11:59 PM
Our billing system supports network monitoring and shows uptime and load percentage, however, the PHP status script they provide says it is Linux only. Configuring PHP to work with Server 2008 is not an issue, but I don't know PHP. Would it be possible to manipulate this code to work on Windows?
<?php
/*
*************************************************************************
* *
* WHMCompleteSolution - Client Management, Billing & Support System *
* Copyright © 2007-2008 WHMCS. All Rights Reserved, *
* Release Date: 12th December 2008 *
* Version 3.8.1 Stable *
* *
*************************************************************************
* *
* Email: [email protected] *
* Website: htttp://www.whmcs.com *
* *
*************************************************************************
This file can be uploaded to each of your linux web servers in order to
display current load and uptime statistics for the server in the Server
Status page of the WHMCS Client Area and Admin Area Homepage
*/
error_reporting(0);
if (ini_get('disable_functions')) {
$disabled_funcs=array_map('trim',explode(',',ini_get('disable_functions')));
}
$action=$_GET["action"];
if ($action=="phpinfo") {
} else {
$users[0]="Unavailable";
$users[1]="--";
$loadnow="Unavailable";
$load15="--";
$load30="--";
if (in_array('exec',$disabled_funcs)) {
$load=file_get_contents("/proc/loadavg");
$load=explode(' ',$load);
$loadnow=$load[0];
$load15=$load[1];
$load30=$load[2];
} else {
$reguptime=trim(exec("uptime"));
if ($reguptime) {
if (preg_match("/, *(\d) (users?), .*: (.*), (.*), (.*)/",$reguptime,$uptime)) {
$users[0]=$uptime[1];
$users[1]=$uptime[2];
$loadnow=$uptime[3];
$load15=$uptime[4];
$load30=$uptime[5];
}
}
}
if (in_array('shell_exec',$disabled_funcs)) {
$uptime_text=file_get_contents("/proc/uptime");
$uptime=substr($uptime_text,0,strpos($uptime_text," "));
} else {
$uptime=shell_exec("cut -d. -f1 /proc/uptime");
}
$days=floor($uptime/60/60/24);
$hours=str_pad($uptime/60/60%24,2,"0",STR_PAD_LEFT);
$mins=str_pad($uptime/60%60,2,"0",STR_PAD_LEFT);
$secs=str_pad($uptime%60,2,"0",STR_PAD_LEFT);
$phpver=phpversion();
if(function_exists("mysql_get_client_info()")) $mysqlver=mysql_get_client_info();
if(function_exists("zend_version()")) $zendver=zend_version();
echo "<load>$loadnow</load>\n";
echo "<uptime>$days Days $hours:$mins:$secs</uptime>\n";
echo "<phpver>$phpver</phpver>\n";
echo "<mysqlver>$mysqlver</mysqlver>\n";
echo "<zendver>$zendver</zendver>\n";
}
?>
<?php
/*
*************************************************************************
* *
* WHMCompleteSolution - Client Management, Billing & Support System *
* Copyright © 2007-2008 WHMCS. All Rights Reserved, *
* Release Date: 12th December 2008 *
* Version 3.8.1 Stable *
* *
*************************************************************************
* *
* Email: [email protected] *
* Website: htttp://www.whmcs.com *
* *
*************************************************************************
This file can be uploaded to each of your linux web servers in order to
display current load and uptime statistics for the server in the Server
Status page of the WHMCS Client Area and Admin Area Homepage
*/
error_reporting(0);
if (ini_get('disable_functions')) {
$disabled_funcs=array_map('trim',explode(',',ini_get('disable_functions')));
}
$action=$_GET["action"];
if ($action=="phpinfo") {
} else {
$users[0]="Unavailable";
$users[1]="--";
$loadnow="Unavailable";
$load15="--";
$load30="--";
if (in_array('exec',$disabled_funcs)) {
$load=file_get_contents("/proc/loadavg");
$load=explode(' ',$load);
$loadnow=$load[0];
$load15=$load[1];
$load30=$load[2];
} else {
$reguptime=trim(exec("uptime"));
if ($reguptime) {
if (preg_match("/, *(\d) (users?), .*: (.*), (.*), (.*)/",$reguptime,$uptime)) {
$users[0]=$uptime[1];
$users[1]=$uptime[2];
$loadnow=$uptime[3];
$load15=$uptime[4];
$load30=$uptime[5];
}
}
}
if (in_array('shell_exec',$disabled_funcs)) {
$uptime_text=file_get_contents("/proc/uptime");
$uptime=substr($uptime_text,0,strpos($uptime_text," "));
} else {
$uptime=shell_exec("cut -d. -f1 /proc/uptime");
}
$days=floor($uptime/60/60/24);
$hours=str_pad($uptime/60/60%24,2,"0",STR_PAD_LEFT);
$mins=str_pad($uptime/60%60,2,"0",STR_PAD_LEFT);
$secs=str_pad($uptime%60,2,"0",STR_PAD_LEFT);
$phpver=phpversion();
if(function_exists("mysql_get_client_info()")) $mysqlver=mysql_get_client_info();
if(function_exists("zend_version()")) $zendver=zend_version();
echo "<load>$loadnow</load>\n";
echo "<uptime>$days Days $hours:$mins:$secs</uptime>\n";
echo "<phpver>$phpver</phpver>\n";
echo "<mysqlver>$mysqlver</mysqlver>\n";
echo "<zendver>$zendver</zendver>\n";
}
?>