Ver código fonte da página
rss.php
<?php
$parser = xml_parser_create('UTF-8');
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_set_element_handler($parser, 'StartTag', 'EndTag');
xml_set_character_data_handler($parser, 'CDATA');
// Se um dia alguém se disponibilizar para traduzir o site, vou ter que mudar isso.
// Você ai que ta lendo isso... quer ser um tradutor?
$file = 'news.pt.php';
$content = file_get_contents($file);
$data = '<?xml version="1.0" encoding="utf-8" ?><h1>'.$content.'</h1>';
$out = ''; // buffer de saida
$indescription = false; // lendo as noticias?
$lastcdata = ''; // Serve apenas para guardar o título (data) da notícia...
xml_parse($parser, $data, true);
if ($indescription)
$out .= ']]></description></item>';
function StartTag($p, $name, $attr)
{
global $out, $current, $indescription;
if ($name == 'h2')
{
if ($indescription)
$out .= ']]></description></item>';
$alsop = false;
$out .= '<item><title>';
$indescription = true;
}
elseif ($name != 'h1')
{
$out .= '<'.$name.'>';
}
}
function EndTag($p, $name)
{
global $out, $lastcdata;
if ($name == 'h2')
{
$out .= '</title><link>http://sqlitefront.sourceforge.net/?f=news</link>';
list($y, $m, $d) = explode('.', $lastcdata);
$out .= '<pubDate>'.date('r', mktime(0, 0, 0, $m, $d, $y)).'</pubDate>';
$out .= '<description><![CDATA[';
}
elseif ($name != 'h1')
$out .= '</'.$name.'>';
}
function CData($p, $data)
{
global $out, $lastcdata, $indescription;
if ($indescription)
{
$lastcdata = $data;
$out .= $data;
}
}
header('Content-Type: application/xml; charset=utf-8');
echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
?>
<rss version="2.0">
<channel>
<title>SQLiteFront</title>
<link>http://sqlitefront.sourceforge.net/</link>
<description>News about SQLiteFront</description>
<language>pt-br</language>
<copyright>2004 Hugo P.L.</copyright>
<pubDate><?php echo date('r', filemtime($file)); ?></pubDate>
<?php echo $out; ?>
</channel>
</rss>
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');
?>