Also, und zwar hab ich ein Templatesystem (siehe Code) mit diesem lad kann ich Templats einladen (Normal oder?

) So darunter gibts die usercp.php diese laded template_oben und _unten. Dort sind alle nötigen Configurationen gemacht. In der usercp.php befindet sich auch die Abfragen "open=login" dieses {userlogin} sollte dann ersetzt werden mit der Navigationsleiste. Aber die Navigationsleiste beinhaltet Rechte Abfrgen (1 User, 2 Moderator, 3 Administrator). Genau hier liegt mein Problem. Ich kriege die Abfrge einfach nicht zum Laufen, ich hab nun gut 2h dran gearbeitet imma was anders versucht aber es kamm nichts raus.
Vielleicht könnt ihr mir helfen, (Code Durchfliegen sollte eigentlich reichen)
Das Template System (Klasse) PHP-Code:
<?php
class template{
var $tpl=array();
var $temppfad;
var $gzip;
var $gziplevel;
var $magic_quotes_runtime;
var $magic_quotes_gpc=true;
function get($array)
{
$this->tpl[$array]=file_get_contents($this->temppfad.'/'.$array.'.tpl') or die($this->tpl[$array]='File '.$array.'.tpl'.$this->phpex.' doesn\'t Exists');
#if(@file_exists($this->temppfad.'/'.$array.'.'.$this->phpex))$this->tpl[$array]=implode('',file($this->temppfad.'/'.$array.'.'.$this->phpex));
}
function get_now($array)
{
$this->get($array);
return $this->tpl[$array];
}
function out(&$out_tpl){
global $_SERVER,$starttime,$db;
if($this->gzip){
$compress=1;
if(strpos($_SERVER['HTTP_ACCEPT_ENCODING'],'x-gzip')!==false) @header('Content-Encoding: x-gzip');
elseif(strpos($_SERVER['HTTP_ACCEPT_ENCODING'],'gzip')!==false) @header('Content-Encoding: gzip');
else $compress=0;
if($compress==1) $out_tpl="\x1f\x8b\x08\x00\x00\x00\x00\x00".substr(gzcompress($out_tpl,$this->gziplevel),0,-4).pack('V',strlen($out_tpl));
}
@header('Expires: Fri, 31 Jan 1986 05:00:00 GMT');
@header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
@header('Content-length: '.strlen($out_tpl));
@header('Cache-Control: pre-check=0, post-check=0, max-age=0');
@header('Cache-Control: no-store, no-cache, must-revalidate');
@header('Pragma: no-cache');
echo $out_tpl.round(microtime()-$starttime, 5).'Querys:'.$db->query;
flush();
clearstatcache();
}
function get_tpl_array($array)
{
if(is_array($array))foreach($array AS $key=>$tplname)$this->get($tplname);
else $this->get($array);
}
}
?>
So nun Die Datei (usercp): PHP-Code:
<?php
require_once("templates/template_oben.php");
$tpl->get('index');
if(isset($_REQUEST['open']))
{
$replace = str_replace('{CONTENT}',$tpl->get_now('usersystem/start'),$tpl->tpl['index']);
$replace = str_replace('{CONTENT_NAME}', "Du bist nicht Berechtig diese Seite zu betreten!", $replace);
}
#################################################
if($_REQUEST['open'] == "login")
{
$sql = "SELECT Id, Nickname, Nachname, Vorname, icq, msn, skype, yim, rechte, wohnort, land, homepage, pc, motto, signatur, email, u_alter FROM benutzerdaten WHERE Nickname like '".$_REQUEST["name"]."' AND Kennwort = '".md5 ($_REQUEST["pwd"])."'" or die (mysql_error());
$result = mysql_query ($sql);
if (mysql_num_rows ($result) > 0)
{
// Benutzerdaten in ein Array auslesen.
$data = mysql_fetch_array ($result);
// Sessionvariablen erstellen und registrieren
$_SESSION["user_id"] = $data["Id"];
$_SESSION["user_rechte"] = $data["rechte"];
$_SESSION["user_nickname"] = $data["Nickname"];
$_SESSION["user_nachname"] = $data["Nachname"];
$_SESSION["user_vorname"] = $data["Vorname"];
$_SESSION["user_profil_icq"] = $data["icq"];
$_SESSION["user_profil_msn"] = $data["msn"];
$_SESSION["user_profil_yim"] = $data["yim"];
$_SESSION["user_profil_skype"] = $data["skype"];
$_SESSION["user_profil_alter"] = $data["u_alter"];
$_SESSION["user_profil_wohnort"] = $data["wohnort"];
$_SESSION["user_profil_land"] = $data["land"];
$_SESSION["user_profil_email"] = $data["email"];
$_SESSION["user_profil_homepage"] = $data["homepage"];
$_SESSION["user_profil_motto"] = $data["motto"];
$_SESSION["user_profil_signatur"] = $data["signatur"];
$_SESSION["user_profil_pc"] = $data["pc"];
}
$replace = str_replace('{CONTENT}',$tpl->get_now('usersystem/start'),$tpl->tpl['index']);
$replace = str_replace('{username}', $_SESSION["user_nickname"], $replace);
$replace = str_replace('{BLAETTERN}', '', $replace);
$replace = str_replace('{PAGE_START}', '', $replace);
$replace = str_replace('{PAGE_BACK}', '', $replace);
$replace = str_replace('{PAGE_NUMBERS}', '', $replace);
$replace = str_replace('{PAGE_FORWARD}', '', $replace);
$replace = str_replace('{PAGE_END}', '', $replace);
}
############################
######### Logout ###########
############################
if($_REQUEST['open'] == "logout")
{
// Wird ausgeführt um mit der Ausgabe des Headers zu warten.
ob_start ();
session_start ();
session_unset ();
session_destroy ();
header ("Location: index.php");
ob_end_flush ();
}
#############################
require_once("templates/template_unten.php");
?>
Su und non die Funktion "check_rechte": PHP-Code:
<?php
############################################
function check_rechte()
{
#########################
if($_SESSION['user_rechte'] == '1')
{
$ausgabe_rechte_user = array('[url="index.php?section=user_cp"]User CP[/url]
',
'[url="index.php?section=user_guthaben"]Guthaben[/url]
',
'[url="usercp.php?open=logout"]Ausloggen[/url]');
$replace = str_replace('{userlogin}', "
".$ausgabe_rechte_user[0]."
".$ausgabe_rechte_user[1]."
".$ausgabe_rechte_user[2]."
",$replace);
}
#########################
if($_SESSION['user_rechte'] == '2')
{
$ausgabe_rechte_mod = array('[url="index.php?section=user_cp"]User CP2[/url]
',
'[url="index.php?section=user_guthaben"]Guthaben2[/url]
',
'[url="usercp.php?open=logout"]Ausloggen2[/url]');
$replace = str_replace('{userlogin}', "
".$ausgabe_rechte[0]."
".$ausgabe_rechte[1]."
".$ausgabe_rechte[2]."
",$replace);
}
#########################
if($_SESSION['user_rechte'] == '3')
{
$ausgabe_rechte_admin = array('[url="index.php?section=user_cp"]User CP3[/url]
',
'[url="index.php?section=user_guthaben"]Guthaben3[/url]
',
'[url="usercp.php?open=logout"]Ausloggen3[/url]');
$replace = str_replace('{userlogin}', "
".$ausgabe_rechte_admin[0]."
".$ausgabe_rechte_admin[1]."
".$ausgabe_rechte_admin[2]."
",$replace);
}
#########################
}
?>
Wie ihr sehen könnt benutzen alle die $replace Variable. Bloss diese ist ja festgesetzt diese kann ich nicht ümändern, sonst ersetzt er es ja nichtmehr. Hat jemand eine Idee wie ich es sonst noch realsieren könnte?
Thx s1x