MrCraig
04-09-2008, 04:02 PM
Ok, basically this is the first time ive EVER made a templating engine, and as a result, having a few problems with it.
The commented lines are just the things ive taken out so i can test it without database access.
template.inc.php
<?php
#require("dbconfig.php");
#$fetch = mysql_fetch_array(mysql_query("select * from `dpan_config` where `asp` = 'template'"));
#$template = $fetch["pref"];
$template = "default";
if(file_exists("skins/".$template."/login.htm"))
$login_template = "skins/". $template ."/login.htm";
elseif(file_exists("skins/".$template."/login.html"))
$login_template = "skins/". $template ."/login.html";
elseif(file_exists("skins/".$template."/login.php"))
$login_template = "skins/". $template ."/login.php";
else
die("INVALID TEMPLATE SPECIFIED.");
if(file_exists("skins/".$template."/main.htm"))
$main_template = "skins/". $template ."/main.htm";
elseif(file_exists("skins/".$template."/main.html"))
$main_template = "skins/". $template ."/main.html";
elseif(file_exists("skins/".$template."/main.php"))
$main_template = "skins/". $template ."/main.php";
else
die("INVALID TEMPLATE SPECIFIED.");
function compiletemplate($type)
{
if($type == "login")
{
$getfile = file_get_contents($login_template);
#$panel_message = mysql_fetch_array(mysql_query("select * from `dpan_config` where `asp` = 'panel_message'"));
#$panel_message = $panel_message["pref"];
$panel_message = "Heyyy";
$getfile = str_replace("{panel_message}",$panel_message,$getfile);
$logincode = '<form action="?login=login" method="post">
<div align="center">
Username:<br />
<input type="text" name="username" /><br /><br />
Password:<br />
<input type="password" name="password" /><br /><br />
<input type="submit" value="Login" />
</div>
</form>';
$getfile = str_replace("{logincode}",$logincode,$getfile);
echo($getfile);
}
elseif($type == "main")
{
$getfile = file_get_contents($main_template);
}
else
die("NO TEMPLATE TYPE SPECIFIED.");
}
?>
index.php
<?php
require("inc/template.inc.php");
compiletemplate('login');
?>
(Il add html tags etc to it later, was just checking it worked before i continued any further with it)
Error is that the page is not showing at all.
(Like a blank page)
Thanks for any help anyone may have. :)!
The commented lines are just the things ive taken out so i can test it without database access.
template.inc.php
<?php
#require("dbconfig.php");
#$fetch = mysql_fetch_array(mysql_query("select * from `dpan_config` where `asp` = 'template'"));
#$template = $fetch["pref"];
$template = "default";
if(file_exists("skins/".$template."/login.htm"))
$login_template = "skins/". $template ."/login.htm";
elseif(file_exists("skins/".$template."/login.html"))
$login_template = "skins/". $template ."/login.html";
elseif(file_exists("skins/".$template."/login.php"))
$login_template = "skins/". $template ."/login.php";
else
die("INVALID TEMPLATE SPECIFIED.");
if(file_exists("skins/".$template."/main.htm"))
$main_template = "skins/". $template ."/main.htm";
elseif(file_exists("skins/".$template."/main.html"))
$main_template = "skins/". $template ."/main.html";
elseif(file_exists("skins/".$template."/main.php"))
$main_template = "skins/". $template ."/main.php";
else
die("INVALID TEMPLATE SPECIFIED.");
function compiletemplate($type)
{
if($type == "login")
{
$getfile = file_get_contents($login_template);
#$panel_message = mysql_fetch_array(mysql_query("select * from `dpan_config` where `asp` = 'panel_message'"));
#$panel_message = $panel_message["pref"];
$panel_message = "Heyyy";
$getfile = str_replace("{panel_message}",$panel_message,$getfile);
$logincode = '<form action="?login=login" method="post">
<div align="center">
Username:<br />
<input type="text" name="username" /><br /><br />
Password:<br />
<input type="password" name="password" /><br /><br />
<input type="submit" value="Login" />
</div>
</form>';
$getfile = str_replace("{logincode}",$logincode,$getfile);
echo($getfile);
}
elseif($type == "main")
{
$getfile = file_get_contents($main_template);
}
else
die("NO TEMPLATE TYPE SPECIFIED.");
}
?>
index.php
<?php
require("inc/template.inc.php");
compiletemplate('login');
?>
(Il add html tags etc to it later, was just checking it worked before i continued any further with it)
Error is that the page is not showing at all.
(Like a blank page)
Thanks for any help anyone may have. :)!