Código PHP:
<?
class Pagina{
private $title="Mi pagina";
private $keywords="";
private $encode="iso-8859-1";
private $style="style.css";
private $restricted=false;
private $javaUrl=array();
private $javaCount=0;
function changeTitle($new){ $this->title=$new; }
function changeKeywords($new){ $this->keywords=$new; }
function changeEncode($new){ $this->encode=$new; }
function changeStyle($new){ $this->estilo=$new; }
function restricted(){ $this->restricted=true; }
function javaScript($url){ $this->javaUrl[$this->javaCount]=$url; $this->javaCount++; }
function dataBase(){
@$db = mysql_connect("localhost", "root", "");
@mysql_select_db("base", $db);
}
function isCurrentURL($url){ return strpos($GLOBALS["SCRIPT_NAME"],$url); }
function head(){
session_start();
$this->dataBase();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns=\"http://www.w3.org/1999/xhtml\">
<HEAD>
<link href="<?=$this->style?>" type="text/css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=<?=$this->encode?>">
<meta name="Keywords" content="<?=$this->keywords?>">
<?
// Añadir javascripts entre las etiquetas HEAD
if($this->javaCount>0){
for($i=0;$i<$this->javaCount;$i++)
?><script type="text/javascript" src="<?=$this->javaUrl[$i]?>"></script><?
}
?>
<title><?=$this->title?></title>
</HEAD>
<BODY>
<?
if($this->restricted){
if(!isset($_SESSION["login"])){ echo "<h1>Área Restringida</h1>"; $this->footer(); exit; }
}
}
function foot(){
?>
</BODY>
</HTML>
<?
}
}
?>