PHP expert |
|
zie hierboven voor edit
edit: ik weet niet welke line hij bedoelt. wat is template(40)?? on line 1. ik zal de code posten zonder de copyright;)
<?php
class template {
var $tpList;
function parseVar($text) {
$lines = explode("\n", $text);
$parsed = '';
foreach($lines as $line) {
if(preg_match("/{.+?}/", $line, $match)) {
$parsed .= preg_replace_callback("/\{(.*?)\}/", array($this, 'doParse'), $line);
} else {
$parsed .= $line;
}
}
return $parsed;
}
function doParse($matches) {
if (strpos($matches[1], '='))
{
list($code, $parameter) = explode("=", $matches[1], 2);
} else {
$code = $matches[1];
$parameter = '';
}
$parameter = trim(chop($parameter));
if(is_array($this -> tpList) && array_key_exists($code, $this -> tpList)) {
$tpCode = eval($this -> tpList[$code]);
} else {
$tpFile = LN_ROOT. "files/tpcodes/".strtolower($code).".tpc";
if(file_exists($tpFile)) {
$tpCode = file($tpFile);
$this -> tpList[$code] = $tpCode;
$tpCode = eval($tpCode);
}
}
return $tpCode;
}
}
?>
<?php class template { var $tpList; function parseVar($text) { $parsed = ''; foreach($lines as $line) { } else { $parsed .= $line; } } return $parsed; } function doParse($matches) { { list($code, $parameter) = explode("=", $matches[1], 2); } else { $code = $matches[1]; $parameter = ''; } $tpCode = eval($this -> tpList[$code]); } else { $tpFile = LN_ROOT . "files/tpcodes/".strtolower($code).".tpc"; $this -> tpList[$code] = $tpCode; } } return $tpCode; } } ?>
|