<?PHP
define('LOADED_TEMPLATE',true);
//
// PHPMyServer - A PHP System Information Script - Old project name was PHPMyStats
// http://www.phpmyserver.com/
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// $Id: index.php/index.php4.php/index.php5.php/etc ,v 2.6 13-08-2005 16:30 precision Exp $
//
// Date in $Id is as DD-MM-YY
//PHPMyServer - Lite Client v2.6
//Build version:
// split version at the DOT, before the DOT is the CORE version, AFTER the DOT is de RELEASE
//Every new release will get an higher number, so when i released version 2 of the script for the 126523st time, its version v2.126523
//Copyright 2004-2005 by KingOfDos Intra/Extra/Internet WebServices
//http://www.phpmyserver.com
//http://www.kingofdos.com
class tplSystem {
var $SHOWTPLINFO = FALSE;
var $FILES = array();
var $TEMPLATES = array();
var $TEMPLATESTOSHOW = array();
var $ORGLOOPS = array();
var $LOOPS = array();
var $RETLOOPS = array();
var $ROOT = '';
var $REPLACEBYLEFT = '{';
var $REPLACEBTRIGHT = '}';
function QPrint($templatename) {
if(!(empty($this->TEMPLATESTOSHOW[$templatename]))) {
return $this->TEMPLATESTOSHOW[$templatename];
} else {
$this->Error('Cannot find [<b>$templatename</b>] in templates array.',1);
}
}
function Clear($tpl_name) {
if (!(empty($this->TEMPLATESTOSHOW[$tpl_name]))) {
$this->TEMPLATESTOSHOW[$tpl_name] = false;
} else {
$this->Error('Cannot find [<b>$templatename</b>] in templates array.',1);
}
}
//----------------------------------------------------- USE IF's
function UseIF($tpl_name,$naam,$use=1) {
$naam = strtoupper($naam); //hoofdletters maken van de ifname
if (empty($this->TEMPLATES[$tpl_name]))
$this->Error('Cannot find [<b>$tpl_name</b>] in templates array.',1); //als de template helemaal niet bestaat een error
if (empty($this->TEMPLATESTOSHOW[$tpl_name]))
$this->TEMPLATESTOSHOW[$tpl_name] = $this->TEMPLATES[$tpl_name]; //als de template niet bestaat @ ingebruikarray, copyeren.
if ($use==0)
$this->TEMPLATESTOSHOW[$tpl_name] = preg_replace('/\\'.$this->REPLACEBYLEFT.'IF='.$naam.'\\'.$this->REPLACEBTRIGHT.'.*\\'.$this->REPLACEBYLEFT.'\/IF='.$naam.'\\'.$this->REPLACEBTRIGHT.'/sU','', $this->TEMPLATESTOSHOW[$tpl_name]);
else
$this->TEMPLATESTOSHOW[$tpl_name] = preg_replace('/(\\'.$this->REPLACEBYLEFT.'IF='.$naam.'\\'.$this->REPLACEBTRIGHT.')(.*)(\\'.$this->REPLACEBYLEFT.'\/IF='.$naam.'\\'.$this->REPLACEBTRIGHT.')/sU','\\2', $this->TEMPLATESTOSHOW[$tpl_name]); //was /U (eval)
}
//----------------------------------------------------- USE IF's
function UseIFInLOOP($loopname,$naam,$use=1) {
$loopname = strtoupper($loopname);
$naam = strtoupper($naam); //hoofdletters maken van de ifname
if (empty($this->ORGLOOPS[$loopname]))
$this->Error('Cannot find [<b>$naam</b>] in loop [<b>$loopname</b>].',1); //als de template helemaal niet bestaat een error
if (empty($this->LOOPS[$loopname]))
$this->LOOPS[$loopname] = $this->ORGLOOPS[$loopname];
if ($use==0)
$this->LOOPS[$loopname] = preg_replace('/\\'.$this->REPLACEBYLEFT.'IF='.$naam.'\\'.$this->REPLACEBTRIGHT.'.*\\'.$this->REPLACEBYLEFT.'\/IF='.$naam.'\\'.$this->REPLACEBTRIGHT.'/sU','', $this->LOOPS[$loopname]);
else
$this->LOOPS[$loopname] = preg_replace('/(\\'.$this->REPLACEBYLEFT.'IF='.$naam.'\\'.$this->REPLACEBTRIGHT.')(.*)(\\'.$this->REPLACEBYLEFT.'\/IF='.$naam.'\\'.$this->REPLACEBTRIGHT.')/sU','\\2', $this->LOOPS[$loopname]); //was /U (eval)
}
//------------------------------------------ Handle LOOP's
function GetLoop($tpl_name,$naam) {
$naam = strtoupper($naam);
if (empty($this->TEMPLATES[$tpl_name]))
$tpl->Error('Cannot find [<b>$tpl_name</b>] in templates array.',1); //als de template helemaal niet bestaat een error
if (empty($this->TEMPLATESTOSHOW[$tpl_name]))
$this->TEMPLATESTOSHOW[$tpl_name] = $this->TEMPLATES[$tpl_name]; //als de template niet bestaat @ ingebruikarray, copyeren.
$this->ORGLOOPS[$naam] = preg_replace('/.*\\'.$this->REPLACEBYLEFT.'LOOP='.$naam.'\\'.$this->REPLACEBTRIGHT.'(.*)\\'.$this->REPLACEBYLEFT.'\/LOOP='.$naam.'\\'.$this->REPLACEBTRIGHT.'.*/s','\\1', $this->TEMPLATESTOSHOW[$tpl_name]);
$this->TEMPLATESTOSHOW[$tpl_name] = preg_replace('/\\'.$this->REPLACEBYLEFT.'LOOP='.$naam.'\\'.$this->REPLACEBTRIGHT.'.*\\'.$this->REPLACEBYLEFT.'\/LOOP='.$naam.'\\'.$this->REPLACEBTRIGHT.'/s',$this->REPLACEBYLEFT.'LOOPNAME='.$naam.$this->REPLACEBTRIGHT, $this->TEMPLATESTOSHOW[$tpl_name]);
if (empty($this->ORGLOOPS[$naam]))
$this->Error('Cannot find loop [<b>$naam</b>] in template [<b>$tpl_name</b>].');
}
function LoopReturnClear($name) {
$name = strtoupper($name);
if (!empty($this->LOOPS[$name])) {
//blaat
if (empty($this->RETLOOPS[$name]))
$this->RETLOOPS[$name] = $this->LOOPS[$name];
else
$this->RETLOOPS[$name] .= $this->LOOPS[$name];
//blaatttttieee
$this->LOOPS[$name] = $this->ORGLOOPS[$name];
} else {
//$this->Error('Cannot find [<b>'.$name.'</b>] in loops array.',1);
//Disabled in PHPMyServer
}
}
function ReturnLoop($tpl_name,$name) {
$name = strtoupper($name);
if (isset($this->RETLOOPS[$name]))
$this->TEMPLATESTOSHOW[$tpl_name] = str_replace($this->REPLACEBYLEFT.'LOOPNAME='.$name.$this->REPLACEBTRIGHT, $this->RETLOOPS[$name], $this->TEMPLATESTOSHOW[$tpl_name]);
else
$this->TEMPLATESTOSHOW[$tpl_name] = str_replace($this->REPLACEBYLEFT.'LOOPNAME='.$name.$this->REPLACEBTRIGHT, '', $this->TEMPLATESTOSHOW[$tpl_name]);
}
function ClearLoop($name) {
$name = strtoupper($name);
if (!empty($this->RETLOOPS[$name])) {
$this->RETLOOPS[$name] = '';
}
}
function ReplaceLoop($naam,$tpl_arraytje,$valletje='') {
$naam = strtoupper($naam);
//echo $this->ORGLOOPS[$naam];exit;
if (empty($this->ORGLOOPS[$naam]))
$this->Error('Cannot find [<b>'.$naam.'</b>] in LOOP array.',1);
if (gettype($tpl_arraytje)=='array') {
while(list($key,$val)=each($tpl_arraytje)) {
if (!(empty($key))) {
$key = strtoupper($key);
if (empty($this->LOOPS[$naam]))
$this->LOOPS[$naam] = $this->ORGLOOPS[$naam];
$this->LOOPS[$naam] = str_replace($this->REPLACEBYLEFT.$key.$this->REPLACEBTRIGHT,$val,$this->LOOPS[$naam]);
}
}
} else {
if (empty($this->LOOPS[$naam]))
$this->LOOPS[$naam] = $this->ORGLOOPS[$naam];
$this->LOOPS[$naam] = str_replace($this->REPLACEBYLEFT.$tpl_arraytje.$this->REPLACEBTRIGHT,$valletje,$this->LOOPS[$naam]);
}
}
function Replace($tpl_name,$tpl_arraytje,$valletje='') {
if (empty($this->TEMPLATES[$tpl_name]))
$this->Error('Cannot find [<b>'.$templatename.'</b>] in templates array.',1);
if(gettype($tpl_arraytje)=='array') {
while (list($key,$val)=each($tpl_arraytje)) {
if (!(empty($key))) {
if (empty($this->TEMPLATESTOSHOW[$tpl_name])){
$this->TEMPLATESTOSHOW[$tpl_name] = $this->TEMPLATES[$tpl_name];
}
$this->TEMPLATESTOSHOW[$tpl_name] = str_replace($this->REPLACEBYLEFT.$key.$this->REPLACEBTRIGHT,$val,$this->TEMPLATESTOSHOW[$tpl_name]);
}
}
} else {
if (empty($this->TEMPLATESTOSHOW[$tpl_name])){
$this->TEMPLATESTOSHOW[$tpl_name] = $this->TEMPLATES[$tpl_name];
}
$this->TEMPLATESTOSHOW[$tpl_name] = str_replace($this->REPLACEBYLEFT.$key.$this->REPLACEBTRIGHT,$valetje,$this->TEMPLATESTOSHOW[$tpl_name]);
}
}
function Load($tmp) {
while (list($extention,$filename)=each($tmp)) {
$fileinfo = @implode('',(@file($this->ROOT.'/'.$filename)));
if ((!$fileinfo) or (empty($fileinfo))) {
$this->Error('Specified TEMPLATE file [<b>'.$filename.'</b>] cannot be found.',1);
} else {
$this->TEMPLATES[$extention] = $fileinfo;
$this->FILES[$extention] = $filename;
}
}
return true;
}
function AddLoad($extention,$filename) {
$fileinfo = @implode('',(@file($this->ROOT.'/'.$filename)));
if ((!$fileinfo) or (empty($fileinfo))) {
$this->Error('Specified TEMPLATE file [<b>'.$filename.'</b>] cannot be found.',1);
} else {
$this->TEMPLATES[$extention] = $fileinfo;
$this->FILES[$extention] = $filename;
}
return true;
}
function Error($message,$die=0) {
echo '<b>ERROR:</b> '.$message.'<br>';
if ($die==1) {
exit;
}
return;
}
function tplSystem($template_dir) {
if (!empty($template_dir)) {
if(is_dir($template_dir)) {
$this->ROOT = $template_dir;
} else {
$this->ROOT = '';
$this->Error('Specified TEMPLATE dir ['.$template_dir.'] is not a directory.',1);
}
}
}
}
/*
* Function that is needed to multi-use this class
*/
function &tplSystemStatic($dir) {
static $tplclass_instance;
if(!isset($tplclass_instance)){
$tplclass_instance=new tplSystem($dir);
}
return($tplclass_instance);
}
?>