I'm trying to make a template for my main site now...It hates me!
header.php:
<?php
$explodeMe = file_get_contents("database/replace.txt");
$settings = explode('||', $explodeMe);
$header = file_get_contents("header.txt");
$count = 0;
while ($settings[$count+1])
{
str_replace($settings[$count], $settings[$count+1], $header);
$count++;
$count++;
}
echo $header;
?>
index.php:
<html>
<head>
<title>
Purplenum.com :: Home
</title>
</head>
<?php include("header.php"); ?>
<?php
if($_GET['view'] == "all")
{
include("database/fetchNewsAll.php");
}
else
{
include("database/fetchNews.php");
echo ' <tr>
<td>
<div align="right">
<a href="index.php?view=all">View All News Entries</a>
</div>
</td>
</tr>'; } ?>
<?php include("includes/footer.php"); ?>
</html>
header.txt:
<link rel="stylesheet" type="text/css" href="{ROOT_URL}/purplenum.css" >
<body>
<div align="center" valign="middle">
<table class="main">
<tr>
<td class="banner_1" colspan="2">
<center>
<img src="{ROOT_URL}/images/pubanner2.jpg" />
</center>
</td>
</tr>
<tr>
<td class="banner_2" colspan="2">
<?php
if ($_COOKIE['purplenum.com_user'] && file_exists('users/' . $_COOKIE['purplenum.com_user'] . '.php'))
{
include (''users/' . $_COOKIE['purplenum.com_user'] . '.php');
if ($_COOKIE['purplenum.com_password'] === $password)
{
?>
<a href="{LOGOUT_URL}">{LOGOUT}</a> ::
<?php
}
else
{
echo 'Incorrect password! Resetting cookies';
setcookie('purplenum.com_user', '');
setcookie('purplenum.com_password', '');
die();
}
}
else
{
?>
<a href="{LOGIN_URL}">{LOGIN}</a> ::
<a href="{REGISTER_URL}">{REGISTER}</a> ::
<?php
}
?>
<a href="{MEMBERLIST_URL}">{MEMBERLIST}</a> ::
<a href="{SETTINGS_URL}">{SETTINGS}</a> ::
</td>
</tr>
<tr valign="top">
<td class="main_1">
<br />
<img src="images/seperator.png">
<br />
<img src="images/bullet.png" /> <a href="index.php">Home</a><br />
<img src="images/bullet.png" /> <a href="/textbb/index.php">Message Boards</a><br />
<img src="images/bullet.png" /> <a href="shipstatus.php">Schthack Ship Status</a><br />
<img src="images/bullet.png" /> <a href="contact.php">Contact Us</a><br />
<img src="images/bullet.png" /> <a href="submit.php">Submit A Guide</a><br />
<img src="images/bullet.png" /> <a href="staff.php">Staff</a><br />
<img src="images/bullet.png" /> <a href="http://pso.sega.com/community/profiles/pso_gcn/pc_front/gcn_pc_main.jhtml">Sega's PSO Site</a><br />
<img src="images/bullet.png" /> <a href="pso.php">PSO History</a><br />
<br />
<img src="images/seperator.png">
<br />
<img src="images/bullet.png" /> <a href="weapons.php">Weapons</a><br />
<img src="images/bullet.png" /> <a href="frames.php">Frames</a><br />
<img src="images/bullet.png" /> <a href="barriers.php">Barriers</a><br />
<img src="images/bullet.png" /> <a href="mags.php">Mags</a><br />
<img src="images/bullet.png" /> <a href="items.php">Misc. Items</a><br />
<br />
<img src="images/seperator.png">
<br />
<img src="images/bullet.png" /> <a href="classes.php">Classes</a><br />
<img src="images/bullet.png" /> <a href="beastiary.php">Beastiary</a><br />
<img src="images/bullet.png" /> <a href="bosses.php">Bosses</a><br />
<img src="images/bullet.png" /> <a href="quests.php">Quests</a><br />
<img src="images/bullet.png" /> <a href="guides.php">Misc. Guides</a><br />
<br />
<img src="images/seperator.png">
<br />
<img src="images/bullet.png" /> <a href="psopcc.php">PSOPC Cheating</a><br />
<img src="images/bullet.png" /> <a href="psodcc.php">PSODC Cheating</a><br />
<img src="images/bullet.png" /> <a href="psogcc.php">PSOGC Cheating</a><br />
<img src="images/bullet.png" /> <a href="psogcc.php">PSOGC: PSOLoad</a><br />
<br />
<img src="images/seperator.png">
<br />
<img src="images/bullet.png" /> <a href="http://schtserv.com">Schthack's Site</a><br />
<img src="images/bullet.png" /> <a href="http://pso3p.net">PSO3Project</a><br />
<img src="images/bullet.png" /> <a href="http://freewebs.com/dreamsiku">Ragol Hunters</a><br />
<img src="images/bullet.png" /> <a href="http://toastermage.ath.cx/">Toastermage's Site</a><br />
<img src="images/bullet.png" /> <a href="http://psoworm.funurl.com">PSOWorm</a><br />
</td>
<td class="main_2">
<center>
<br />
<table class="news">
replace.txt:
{ROOT_URL}||
http://www.purplenum.com/||
{LOGIN_URL}||
login.php||
{LOGIN}||
Login||
{REGISTER_URL}||
register.php||
{REGISTER}||
Register||
{MEMBERLIST_URL}||
members.php||
{MEMBERLIST}||
Members||
{SETTINGS_URL}||
settings.php||
{SETTINGS}||
Preferences
The index.php is what is being displayed, header.php is doing all the work replacing the {} tags in header.txt with their counterparts in replace.txt, which should act as a type of "template", but the final output is:
http://www.purplenum.com/
What am I doing wrong, this code seems all right to me?