Ver código fonte da página
index.php
<?php
error_reporting(E_ALL);
$f = isset($_GET['f']) ? $_GET['f'] : 'home';
if (strpos($f, '/') !== false)
$f = 'notfound';
list($lang, $langfound) = GetLang($f);
$body = 'body.'.$lang.'.php';
$content = $f.'.'.$lang.'.php';
// content-type negotiation...
if (stristr($_SERVER['HTTP_USER_AGENT'],'validator') ||
strpos($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml') !== false)
$contenttype = 'application/xhtml+xml';
else
$contenttype = 'text/html';
header('Content-Type: '.$contenttype.'; charset=utf-8');
header('Content-Language: '.$lang);
header('Vary: Accept, Accept-Language');
echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="<?php echo $contenttype; ?>;charset=utf-8" />
<title>SQLiteFront</title>
<meta name="author" content="Hugo P.L." />
<link rel="author" href="?f=credits" />
<link rel="help" href="?f=faq" />
<link rel="copyright" href="?f=license" />
<link rel="bookmark" title="SQLite.org" href="http://www.sqlite.org" />
<link rel="bookmark" title="PHP.net" href="http://www.php.net" />
<link rel="stylesheet" type="text/css" href="style.css.php?bg=<?php echo $f; ?>" />
<link rel="alternate" type="application/rss+xml" title="News (RSS 2.0)" href="rss.php" />
</head>
<body>
<?php
if (!$langfound)
{
echo '<div id="langnotfound">This page still not translated for your language.<br />',
'<a href="?f=contact">Wanna be a translator?</a></div>';
}
include $body;
?>
<!-- Sourceforge logo/Firefox link -->
<div id="getfirefox">
<a href="http://www.spreadfirefox.com/?q=affiliates&id=35958&t=85"><img alt="Get Firefox!" title="Get Firefox!" src="http://www.spreadfirefox.com/community/images/affiliates/Buttons/80x15/firefox_80x15.png"/></a>
</div>
<div id="sflogo">
<a href="http://www.sourceforge.net"><img src="http://sourceforge.net/sflogo.php?group_id=124956&type=1" width="88" height="31" alt="Source Forge" /></a></div>
</body>
</html>
<?php
/**
* Detecta linguagem do navegador, retornando o arquivo do menu e do contedo
* \return array ( bodyfile, contentfile, language found? )
*/
function GetLang($f)
{
$language = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : null;
if ($language)
{
$aLanguages = explode(',', $language);
// ignore the q-rating, only follow the lang order. (ok, it is a bug...)
$aLang = array();
foreach($aLanguages as $l)
{
$qpos = strpos($l, ';'); // qrating index
if ($qpos === false)
$aLang[] = substr(trim($l), 0, 2);
else
$aLang[] = substr($l, 0, 2 );
}
// Verifica se existe a tradu�o.
$try = 0;
foreach ($aLang as $lang)
{
if (file_exists($f.'.'.$lang.'.php'))
return array($lang, $try == 0);
++$try;
}
return array('pt', false);
}
else
return array('pt', false);
}
?>
body.pt.php
<ul id="menu">
<li><a href="?f=home" id="home">Home</a></li>
<li><a href="?f=news" id="news">Notícias</a></li>
<li><a href="?f=features" id="features">Features</a></li>
<li><a href="?f=download" id="download">Download</a></li>
<li><a href="?f=installation" id="installation">Instalação</a></li>
<li><a href="?f=faq" id="faq">FAQ</a></li>
<li><a href="?f=license" id="license">Licença</a></li>
<li><a href="?f=bugs" id="bugs">Bugs</a></li>
<li><a href="?f=todo" id="todo">TODO</a></li>
<li><a href="?f=credits" id="credits">Créditos</a></li>
</ul>
<div id="content">
<?php
include $content;
?>
</div>
<div id="signature">
<p>
Copyright© 2004 Hugo Parente Lima<br />
<a href="?f=viewsource">Ver código fonte desta página</a>
</p>
</div>
notfound.pt.php
<h1>Error 404</h1>
<p>A URL requisitada <em><?php echo $_SERVER['REQUEST_URI']; ?></em> não foi encontrada no servidor.</p>
viewsource.php
<?php
// Exce�o a regra... o script gerador de RSS
if (isset($_GET['rss']) ? true : false)
{
echo '<h2>rss.php</h2>';
highlight_file('rss.php');
}
else
{
echo '<h2>index.php</h2>';
highlight_file('index.php');
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
if (preg_match('/f=([a-z]+)$/', $referer, $aReferer))
$rf = $aReferer[1];
else
$rf = 'notfound';
if (!strstr($rf, '/'))
{
list($rlang, $rlangfound) = GetLang($rf);
$rbody = 'body.'.$rlang.'.php';
$rcontent = $rf.'.'.$rlang.'.php';
echo '<h2>', $rbody, '</h2>';
highlight_file($rbody);
echo '<h2>', $rcontent, '</h2>';
highlight_file($rcontent);
}
}
echo '<h2>viewsource.php</h2>';
highlight_file('viewsource.php');
?>