PHP uptime script in a HTML block?

PHP uptime script in a HTML block?

by Just Dave -
Number of replies: 1

Hi,

I'd like to know is it possible to add a custom block with some php code in it? I would like to add a HTML block that will run the unix uptime command and print the server uptime.

I did this a while ago with a block using the drupal CMS and it worked ok, it used the exec() php function. Sorry, my PHP is really really basic... sad

This is the code I am trying to add into an HTML block:

<?php
$uptime = shell_exec("/usr/bin/uptime");
echo "Uptime is: $uptime";
?>

When I try adding this to a HTML block the block displays nothing. When I go back into edit mode and view the block source, it seems to have stripped out some stuff, or commented my code out(?), see below:

<!--p
$uptime = shell_exec("/usr/bin/uptime");
echo "Uptime is: $uptime";
-->

I'm sorry to post this if someone has already posted this before but I couldn't find a solution in the forums. I saw somewhere that there is a way to add custom php blocks for admins to view only but I'd like all users(and guests) to be able to view this block.

Any pointers or knocks over the head because I am doing something stupid will be greatly appreciated big grin

Thanks!

Dave

Average of ratings: -