las variables globales deben de ir dentro de la funcion:
Código PHP:
function theindex($new_topic="0")
{
global $prefix, $db, $sitename, $username, $user, $cookie, $theme, $pagetitle;
include("header.php");
cookiedecode($user);
$ip = getenv("REMOTE_ADDR");
$username = $cookie[1];
if (!isset($username))
{
$username = "$ip";
$guest = 1;
}
}