<?php
	
	class Templater 
	{
	
  	private $title;
  	private $path;
    private $tpl;

  	    public function tpl_($title,$path=NULL)
		{
	     global $resting;
	
  			$this->title = $title;
  			$this->path = $path;
  			$this->tpl = file_get_contents($this->path);
  			$this->tpl = str_replace('{TITLE}',$this->title,$this->tpl);
        	$this->tpl = str_replace('{panel}',menu_users(),$this->tpl);
			$this->tpl = str_replace('{keywords}',$resting['keywords'],$this->tpl);
			$this->tpl = str_replace('{description}',$resting['description'],$this->tpl);
			$this->tpl = str_replace('{copyright}',$resting['copyright'],$this->tpl);
  			//$this->tpl = str_replace('{reklama}',reklama_head(),$this->tpl);
			$this->tpl = str_replace('{reklam_razd}',reklama_razd(),$this->tpl);
			$this->tpl = str_replace('{server_perehod}',server_pere(),$this->tpl);
			$this->tpl = str_replace('{home}',server_perehod(),$this->tpl);
			$this->tpl = str_replace('{reklama_foot}',reklama_foot(),$this->tpl);
			$this->tpl = str_replace('{copyright}',copyrightweb(),$this->tpl);
			$this->tpl = str_replace('{copyright_wap}',copyright(),$this->tpl);
	
		
		echo  eval(' ?'.'>'.$this->tpl.'<'.'?php ');
  	    }
    }
  
        $templater = new  Templater();

  function load_file($path,$files)
  {
  include_once($path."/".$files);
  }
 
  	function menu_users() 
	{
		global $user_id;
		global $new_mail;
		global $login;
		return (isset($user_id) ? '<a href="'.DIR_SHCMS.'private_menu.php">Меню: '.$login.'</a>
		 <a href="' . DIR_SHCMS . 'mails.php?act=mail"> Почта ('.mysql_result(mysql_query("SELECT COUNT(*) FROM `mails` WHERE `user_id` = '" .$user_id."' AND `read` = 'no'"), 0).')</a> <a href="'.DIR_SHCMS.'outcome.php">Выйти</a>' : '
		 <a  href="' . DIR_SHCMS . 'authorization.php">Войти</a>
		 <a  href="' . DIR_SHCMS . 'registration.php">Регистрация</a> ');
	}

    function server_pere()
	{
		if ($_SERVER['PHP_SELF']!=='/index.php')
		{
            return '
            <a href="/"><div class="posts"><strong>На главную</strong></div></a>';
        }
    }
    
	function server_perehod()
	{
		if ($_SERVER['PHP_SELF']!=='/index.php')
		{
            return '<a href="/">На главную</a>';
		}
	}
  
?>