Файл: sources/skin.php
Строк: 103
<?php
if (!defined('VAPHP'))
{
die("Этот файл недоступен.");
}
class skin
{
var $filename;
function skin($filename)
{
$this->filename = $filename;
}
function make()
{
global $CONF, $TMPL;
$file = "{$CONF['skins_path']}/{$TMPL['skin_name']}/{$this->filename}.html";
$fh_skin = fopen($file, 'r');
$skin = @fread($fh_skin, filesize($file));
fclose($fh_skin);
$parse = 1;
if ($this->filename == 'wrapper')
{
$return = $skin;
}
elseif ($this->filename == 'admin' || $this->filename == 'ssi_top' || $this->filename == 'ssi_members') {
$return = $skin;
}
else {
$return = "<!-- Begin {$this->filename}.html -->n{$skin}<!-- End {$this->filename}.html -->nn";
}
if ($parse)
{
return $this->parse($return);
}
else {
return $return;
}
}
function send_email($email)
{
global $CONF, $TMPL;
if($CONF['email_from_site']){
$file = "{$CONF['skins_path']}/{$CONF['default_skin']}/{$this->filename}.html";
$fh_skin = fopen($file, "r");
$skin = @fread($fh_skin, filesize($file));
fclose($fh_skin);
$skin_array = explode("n", $skin);
$subject = array_shift($skin_array);
$subject = str_replace('Subject: ', '', $subject);
$body = implode("n", $skin_array);
$subject = $this->parse($subject);
$body = $this->parse($body);
mail($email, $subject, $body, "From: {$CONF['your_email']}rn");
}
}
function parse($skin) {
global $LNG, $TMPL, $n, $parse_time;
$skin = preg_replace_callback('/{$lng->(.+?)}/i', create_function('$matches', 'global $LNG; return $LNG[$matches[1]];'), $skin);
$skin = preg_replace_callback('/{$(.+?)}/i', create_function('$matches', 'global $TMPL; return $TMPL[$matches[1]];'), $skin);
$skin = preg_replace_callback('/{include "(.+?)"}/i', create_function('$matches', 'return file_get_contents($matches[1]);'), $skin);
return $skin;
}
function callback($matches) {
return $matches[1];
}
}
class main_skin extends skin
{
function main_skin($filename)
{
global $CONF, $DB, $FORM, $LNG, $TIMER, $TMPL;
$this->filename = $filename;
$TMPL['num_queries'] = $DB->num_queries;
$TMPL['execution_time'] = $TIMER->get_time();
}
}
?>