jeg har lige flyttet mine sider over til netplads og har problemer med at få nedestående kode til at virke:
<table cellspacing="1" cellpadding="1" align="center" border="0" style="width: 67.42%; height: 107px">
<tbody>
<tr>
<td style="width: 50%">
<p align="left"><?php function get_server_load($windows = false) {
$os = strtolower(PHP_OS);
if(strpos($os, "win") === false) {
if(file_exists("/proc/loadavg")) {
$load = file_get_contents("/proc/loadavg");
$load = explode(' ', $load);
return $load[0];
}
elseif(function_exists("shell_exec")) {
$load = explode(' ', `uptime`); return $load[count($load)-1];
} else {
return false;
}
} elseif($windows) {
if(class_exists("COM")) {
$wmi = new COM("WinMgmts:\\\\.");
$cpus = $wmi->InstancesOf("Win32_Processor");
$cpuload = 0;
$i = 0;
if(version_compare('4.50.0', PHP_VERSION) == 1) {
// PHP 4
while ($cpu = $cpus->Next()) {
$cpuload += $cpu->LoadPercentage;
$i++;
}
} else {
// PHP 5
foreach($cpus as $cpu) {
$cpuload += $cpu->LoadPercentage;
$i++;
}
}
$cpuload = round($cpuload / $i, 2);
return "$cpuload%";
} else {
return false;
}
}
} ?>
<?php $decimalval = get_server_load(true);
$percentage = $decimalval * (12.5) ; ?>
<?php echo "Server belastning i % : ".$percentage."";?>
</p>
</td>
<td style="width: 50%">
<p align="left"><?php function linuxUptime() {
$ut = strtok( exec( "cat /proc/uptime" ), "." );
$days = sprintf( "%2d", ($ut/(3600*24)) );
$hours = sprintf( "%2d", ( ($ut % (3600*24)) / 3600) );
$min = sprintf( "%2d", ($ut % (3600*24) % 3600)/60 );
$sec = sprintf( "%2d", ($ut % (3600*24) % 3600)%60 );
return array( $days, $hours, $min, $sec );
}
$ut = linuxUptime();
// If you would like to show the seconds as well just add [ , $ut[3] seconds ] after minutes.
echo "Tid siden sidste genstart af server: $ut[0] dage, $ut[1] timer, $ut[2] minutter";?></p>
</td>
</tr>
</tbody>
</table>