Размер файла: 4.33Kb
<?php
header("Content-type: text/vnd.wap.wml");
require('includes/utils.php');
require('includes/db.php');
require('includes/auth.php');
require('includes/config.php');
if(!isset($_GET['page']))
$_GET['page'] = 'index.wml';
if(preg_match('/[^\w\.]/', $_GET['page']))
{
echo '<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">';
?>
<wml>
<card id="error" title="error" ontimer="main.php?id=<?php echo $id; ?>&p=<?php echo $login; ?>"><timer value="15"/>
<p align="center">
Неправильное имя страницы
</p>
</card>
</wml>
<?php
exit;
}
$contents = file("$login/" . addslashes($_GET['page']));
echo "\n";
// Выводим первую часть страницы без изменений
for($i = 0; $i < count($contents) && (trim($contents[$i]) != '<p align="center">' && trim($contents[$i]) != '<p align="left">' && trim($contents[$i]) != '<p align="right">'); $i++)
{
echo $contents[$i];
}
$banners = mysql_query('SELECT banner FROM users WHERE login = "' . $login . '"');
list($banner) = mysql_fetch_array($banners);
$last_tag = '<img src="http://' . $server_name . '/counter.php?id=' . $id . '" alt="counter"/>';
//for($j = $i; $j < count($contents) && !(trim($contents[$j]) == '</p>' && trim($contents[$j+1]) == '</card>'); $j++)
for($j = $i; $j < count($contents) && !(trim($contents[$j]) == $last_tag && trim($contents[$j+1]) == '</p>' && trim($contents[$j+2]) == '</card>'); $j++)
{
if(($j-1) == $i && $banner == 'top')
continue;
if($banner == 'bottom' && preg_match('/<a href=.*<\/a>/i', $contents[$j]) && trim($contents[$j+1]) == '</p>' && trim($contents[$j+2]) == '</card>')
continue;
if(preg_match('/<a href=\"(.*?)\">.*?<\/a>/i', $contents[$j]))
$contents[$j] = preg_replace('/<a href=\"(.*?)\">(.*?)<\/a>/i', '<a href="edittext.php?id=' . $id . '&p=' . $login . '&page=' . $_GET['page'] . '&i=' . $j . '">$2</a>', $contents[$j]);
else if(preg_match('/<br\/>/i', $contents[$j]))
$contents[$j] = preg_replace('/<br\/>/i', '<br/><a href="edittext.php?id=' . $id . '&p=' . $login . '&page=' . $_GET['page'] . '&i=' . $j . '"><br/></a><br/>', $contents[$j]);
else if(preg_match('/<p align=\"(.*?)\">/i', $contents[$j]))
$contents[$j] = preg_replace('/<p align=\"(.*?)\">/i', '<p align="$1"><a href="edittext.php?id=' . $id . '&p=' . $login . '&page=' . $_GET['page'] . '&i=' . $j . '">align=$1</a><br/>', $contents[$j]);
else if(preg_match('/<img src=\"(.*?)\" alt=\"(.*?)\"\/>/i', $contents[$j]))
$contents[$j] = preg_replace('/<img src=\"(.*?)\" alt=\"(.*?)\"\/>/i', '<a href="edittext.php?id=' . $id . '&p=' . $login . '&page=' . $_GET['page'] . '&i=' . $j . '">http://' . $server_name . '/$1</a>', $contents[$j]);
else if(preg_match('/<b>(.*?)<\/b>/i', $contents[$j]))
$contents[$j] = preg_replace('/<b>(.*?)<\/b>/i', '<b><a href="edittext.php?id=' . $id . '&p=' . $login . '&page=' . $_GET['page'] . '&i=' . $j . '">$1</a></b>', $contents[$j]);
else if(preg_match('/<i>(.*?)<\/i>/i', $contents[$j]))
$contents[$j] = preg_replace('/<i>(.*?)<\/i>/i', '<i><a href="edittext.php?id=' . $id . '&p=' . $login . '&page=' . $_GET['page'] . '&i=' . $j . '">$1</a></i>', $contents[$j]);
else if(preg_match('/<small>(.*?)<\/small>/i', $contents[$j]))
$contents[$j] = preg_replace('/<small>(.*?)<\/small>/i', '<small><a href="edittext.php?id=' . $id . '&p=' . $login . '&page=' . $_GET['page'] . '&i=' . $j . '">$1</a></small>', $contents[$j]);
else if(trim($contents[$j]) != '')
$contents[$j] = preg_replace("/(.+)\n/i", '<a href="edittext.php?id=' . $id . '&p=' . $login . '&page=' . $_GET['page'] . '&i=' . $j . '">$1</a>' . "\n", $contents[$j]);
echo $contents[$j];
}
echo '<br/>*********<br/>
имя:' . $_GET['page'] . ', Paзмep:' . filesize($login . '/' . $_GET['page']) . ' byte
<br/>
<a href="manager.php?id=' . $id . '&p=' . $login . '">Менеджер страниц</a>
';
// Выводим последнюю часть страницы без изменений
$j++;
for($k = $j; $k < count($contents); $k++)
{
echo $contents[$k];
}
//echo "</wml>';
?>