(page.inc)
<body leftmargin = 0 topmargin = 0 marginwidth = 0 marginheight = 0>
<?
class Page
{
var $content;
var $title = "MySite";
var $buttons = array( "Home" => "home.php",
"Contact" => "contact.php",
"Services" => "services.php",
"Site Map" => "sitemap.php"
);
//class pages operations
function SetContent($newcontent)
{
$this->content = $newcontent;
}
function SetTitle($newtitle)
{
$this->title = $newtitle;
}
function SetButtons($newbuttons)
{
$this->buttons = $newbuttons;
}
function Display()
{
echo "<html>\n<head>\n";
$this -> DisplayTitle();
$this -> DisplayStyles();
echo "</head>\n<body>\n";
$this -> DisplayHeader();
$this -> DisplayMenu($this->buttons);
echo $this->content;
$this -> DisplayFooter();
echo "</body>\n</html>\n";
}
function DisplayTitle()
{
echo "<title> $this->title </title>";
}
function DisplayStyles()
{
?>
<style>
h1 {color:white; font-size:24pt; text-align:center; font-family:arial,sans-serif}
.menu {color:white; font-size:12pt; text-align:center; font-family:arial,sans-serif; font-weight:bold}
td {background:black}
p {color:black; font-size:12pt; text-align:justify; font-family:arial,sans-serif}
p.foot {color color:white; font-size:9pt; text-align:center; font-family:arial,sans-serif; font-weight:bold}
a:link,a:visited,a:active {color:white}
</style>
<?
}
function DisplayHeader()
{
?>
<table width = 100% cellpadding = 12 cellspacing = 0 border = 0>
<tr bgcolor = white>
<div align=center><img alt="My Site" src="pics\logo.gif" /></div>
</td>
</tr>
</table>
<?
}
function DisplayMenu($buttons)
{
echo "<table width = \"100%\" bgcolor = white"." cellspading = 4 cellspacing = 4>\n";
echo "<tr>\n";
$width = 100/count($buttons);
while (list($name, $url) = each($buttons));
{
$this -> DisplayButton($width, $name, $url, !$this->IsURLCurrentPage($url));
}
echo "</tr>\n";
echo "</table>\n";
}
function IsURLCurrentPage($url)
{
if(strpos( $GLOBALS["SCRIPT_NAME"], $url )==false)
{
return false;
}
else
{
return true;
}
}
function DisplayButton($width, $name, $url, $active = true)
{
if ($active)
{
echo "<td width = \"$width%\">
<a href = \"$url\">
<img scr = \"s-logo.gif\" alt = name \"$name\" border = 0></a>
<a href = \"$url\"><span class=menu>$name</span></a></td>";
}
else
{
echo "<td width = \"$width%\">
<span class=menu>$name</span></td>";
}
}
function DisplayFooter()
{
?>
<table width = 100% bgcolor = black cellspadding = 12 border = 0>
<tr>
<td>
<p class=foot>© My Site 2k - 2k3</p>
</td>
</tr>
</table>
<?
}
}
?>
End of Page.inc[\b]
This is the acctual page
(Index.php)
<?PHP
require ("page.inc");
$homepage = new Page();
$homepage -> SetContent("<p>I need help :\</p>");
$homepage -> Display();
?>