HI!
how can i run php-code that is saved in a mysql-database in a template?
this is how the system works.
1) i get the data out of the database, lets say in $inhalt
so, now $inhalt = "<? phpinfo(); ?>"; // The code i got from the database and want to run
2) now i load the template in which the content of $inhalt should be placed
$tpl = tplload("whatever.tpl.php");
3) now i place the content of $inhalt into the template and display it:
echo tplprint($tpl, array(
"INHALT" => $inhalt
));
but unfortunatly the code wasn't run!! What did i forget to do??
// the two functions i called
function tplload($file) // LOAD TEMPLATE
{
// opens the template file
if($fp = @fopen($file, "r"))
{
$tpl = fread($fp, filesize ($file));
fclose ($fp);
}
else $tpl = "Template not found ($file)";
return $tpl;
}
function tplprint($tpl, $repla) // PRINT TEMPLATE
{
foreach($repla as $key=>$elem)
{
// Replaces key-words
$tpl = str_replace("{".$key."}", $elem, $tpl);
}
return $tpl;
}