И запросы в функции можно "скучковать"
//$users = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE `lastdate` > '" . (time() - 300) . "'"), 0);
//$guests = mysql_result(mysql_query("SELECT COUNT(*) FROM `cms_sessions` WHERE `lastdate` > '" . (time() - 300) . "'"), 0);
//$online = mysql_fetch_assoc(mysql_query('SELECT * FROM `online`'));
$online = mysql_fetch_assoc(mysql_query('SELECT * FROM (
SELECT COUNT(*) users FROM `users` WHERE `lastdate`>' . (time() - 300) . ')q1, (
SELECT COUNT(*) guests FROM `cms_sessions` WHERE `lastdate`> ' . (time() - 300) . ')q2, (
SELECT onl_all, onl_time FROM `online`)q3'));