Files
TravianZ/GameEngine/functions.php
T
2012-03-29 13:00:34 +02:00

37 lines
887 B
PHP

<?php
############################################################
## ##
## Test functions so far mini template parser ##
## Author : Advocaite ##
## Project : TravianX ##
## ##
############################################################
function addSub($subName, $sub)
{
$GLOBALS['subs']["{".$subName."}"] = $sub;
}
function template($filepath, $subs)
{
global $s;
if(file_exists($filepath))
{
$text = file_get_contents($filepath);
} else {
print "File '$filepath' not found";
return false;
}
foreach($subs as $sub => $repl)
{
$text = str_replace($sub, $repl, $text);
}
ob_start();
eval("?>".$text);
$text = ob_get_contents();
ob_end_clean();
return $text;
}
?>