Forum Moderators: coopster
<?PHP
if (!defined('DIRECT_ACCESS')) { die('Forbidden!'); }
class PSOUP_template {
public $PSOUP_template;
/*
* Loads a template file
*/
public function PSOUP_template($template) {
if (file_exists($template)) {
$this->PSOUP_template = file_get_contents($template);
} else {
die ("Couldn't load template file {$template}!");
}
}
/*
* Replaces and assigns tags for each template file
*/
public function assign_vars($vars = array()) {
if (sizeof($vars) > 0) {
foreach ($vars as $tag => $content) {
$replace_tag = "{" .$tag. "}";
$this->PSOUP_template = str_replace($replace_tag, $content, $this->PSOUP_template);
}
} else {
die ("You didn't specify any tags!");
}
}
/*
* Displays the template and enables PHP tags
*/
public function display() {
global $title, $_SERVER, $PSOUP_CONTENT_DIR, $PSOUP_SETTINGS, $pagecat, $postcat, $i, $error, $post, $PSOUP_sessions, $post_comment, $post_featured, $post_published, $PSOUP_load_tpl, $homepage, $users_hideemail, $comments, $user;
$output = $this->PSOUP_template;
eval ("php?>".$output."<?");
}
}
?> eval ("php?>".$output."<?"); // Adding a space after the open tag fixes it
eval ('?>' . $output . '<?php ');