to vobec nevadi, ze includujes subory az po, skus tento kod (troska som ti zjednodusil ten tvoj):
Kód:
<?php
//zisti text medzi <h2> a </h2> z includovaneho suboru
function getTitle($file, $length=150) {
$fp = @fopen($file, "r");
if(!$fp) {
return "Not found";
}
$filecontent = fread($fp, $length);
eregi('<h2([^>]*)>(.*)</h2>', $filecontent, $zhoda);
return !empty($zhoda[2]) ? eregi_replace('<([^>]*)>', ' ', $zhoda[2]) : false;
}
$incfile = "sk/uvod.php";
if(!empty($_GET['o'])) {
$file = "sk/".$_GET['o'].".php";
if(file_exists($file)) {
$incfile = $file;
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><?php echo getTitle($incfile); ?> - nejaky ten titul</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body id="body">
<div id="telo">
<div id="menu">
<a href="?o=cinnost">Činnosť</a>
<a href="?o=produkty">Predaj</a>
<a href="?o=cennik">Cenník</a>
<a href="?o=partneri">Partneri</a>
<a href="?o=upravy">Úpravy</a>
<a href="?o=historia">História</a>
<a href="?o=kontakt">Kontakt</a>
<a href="?o=galeria">Galéria</a>
<a href="?o=uvod" class="k">Úvod</a>
</div>
<div id="obsah">
<div id="text">
<?php include_once($incfile); ?>
<div class="clear"></div>
</div>
</div>
</div>
</body>
</html>