Gdzieś w internecie znalazłem bardzo prosty parser.
[php:1:6a97ad5b05]<?
class template
{
var $unparsed = array(0 => "");
var $parsed = "";
var $blocks = array("default" => "");
function load($plik)
{
$this -> unparsed = @file("templates/".$plik.".tpl");
}
function parse()
{
$this -> parsed = "";
$cnt = count($this -> unparsed);
for($i = 0; $i <= $cnt; $i++)
{
$tekst = $this -> unparsed[$i];
$found = array();
if(preg_match_all("#{(.+?)}#is", $tekst, $found))
{
foreach($found[0] as $block)
{
$block = str_replace("{", "", $block);
$block = str_replace("}", "", $block);
$tekst = str_replace("{".$block."}", $this -> blocks[$block], $tekst);
}
}
$this -> parsed .= $tekst;
}
}
}
?>[/php:1:6a97ad5b05]
Wszystko działa dobrze na necie, możecie zobaczyć http://www.portal.p2.pl. Problem jest na serwerze wirtualnym Xitami. Skrypt działa poprawnie, ale ni stąd, ni z owąd, nad każdym z napisów wyskakuje "Warning: Undefined offset: 6 in E:PROGRAMYXITAMIwebpagesnewincludestemplate.php on line 19". Co mam o tym myśleć?