You must put this code at the first line!!!! of your php-file, before the HTML-Tags.
<?php
//your path Pfad to 4images-directory
$root_path = "./";
define('ROOT_PATH', $root_path);
include(ROOT_PATH.'global.php');
$random_image = $site_template->clean_template(get_random_image(0,0));
?>
i have had the same problem, but so it works.
Greetings Peter