<?
/*
stdvars.php ersetzt Standardvariablen
Copyright (C) 2004 Thomas Meinusch
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.
/********************************
* CREATED BY Thomas Meinusch *
* www.meinsoft.de *
********************************/
function stdVars($area){
global $PATH;
global $logingroup;
global $config, $thisfile;
global $_SESSION;
// INFO Templateparser Engine
/**
{ENGINE} = Templateparser Engine
{VERSION} = Version der Software
{AUTHOR} = Thomas Meinusch
{LICENSE} = Lizenzinformationen
{WARNING} = Softwarehinweise
*/
$area=str_replace("{ENGINE}", "Templateparser Engine", $area);
$area=str_replace("{VERSION}", "1.4.3", $area);
$area=str_replace("{AUTHOR}", "Thomas Meinusch", $area);
$area=str_replace("{LICENSE}", "GNU General Public License (version 2)", $area);
$area=str_replace("{WARNING}", "THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK!", $area);
// Pragramminfo
if(file_exists("appvars.php")) include("appvars.php");
// Pfade
/**
[:DIR] wird ersetzt duch richtigen Pfad
*/
if(is_array($PATH)){
foreach(array_keys($PATH) as $key){
if(is_array($PATH[$key])){
$area=str_replace("[:".$key."]",$PATH[$key]["path"],$area);
}else{
$area=str_replace("[:".$key."]",$PATH[$key],$area);
}
}
}
// Standard Variablen
/**
[!SERVERkonstante] wird ersetzt durch Serverkonstanten
*/
$area=str_replace("[!tpeversion]", "1.4.3", $area);
$area=str_replace("[!phpversion]", phpversion(), $area);
$area=str_replace("[!boundary]", md5(uniqid(time())), $area);
$area=str_replace("[!CONFIG]", $config,$area);
$area=str_replace("[!ACCESS]", $logingroup,$area);
if($_SESSION[$config]["LOGINDATA"]){
foreach(array_keys($_SESSION[$config]["LOGINDATA"]) as $key){
$area=str_replace("[!".$key."]", $_SESSION[$config]["LOGINDATA"][$key], $area);
}
}
// Client abhängige Servervariablen
$area=str_replace("[!REMOTEIP]", $_SERVER["REMOTE_ADDR"],$area);
if(file_exists($thisfile)){
$area=str_replace("[!template]", $thisfile, $area);
$area=str_replace("[!lastmod]", date("Y-m-d H:i:s", filemtime("$thisfile")), $area);
}
// Ersetze alle Platzhalter durch die REQUEST Variablen
/**
[$REQUEST] wird ersetzt durch REQUEST-Variablen
*/
foreach(array_keys($_REQUEST) as $key){
$key=preg_replace ("/(<[A-Z]*>)/i", "", $key);
$key=preg_replace ("/(<\/[A-Z]*>)/i", "", $key);
$area=str_replace("[$".$key."]",$_REQUEST[$key],$area);
}
// Ersetze alle Platzhalter durch globale Variablen
/**
[$GLOBAL] wird ersetzt durch Global gesetzte REQUEST-Variablen
*/
if(isset($_SESSION["SET"])){
foreach(array_keys($_SESSION["SET"]) as $key){
$area=str_replace("[$".$key."]",$_SESSION["SET"][$key],$area);
}
}
// Entferne alle Platzhalte des Typs [$....]
/**
[$....] Beseitigung von nicht übermittelten Variablen dieser Form
*/
$area=preg_replace ('/\[\$[A-Za-z0-9_]*]/', "", $area);
return $area;
}
?>