Просмотр файла wapbuilder/edit.php

Размер файла: 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; ?>&amp;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 . '&amp;p=' . $login . '&amp;page=' . $_GET['page'] . '&amp;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 . '&amp;p=' . $login . '&amp;page=' . $_GET['page'] . '&amp;i=' . $j . '">&lt;br/&gt;</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 . '&amp;p=' . $login . '&amp;page=' . $_GET['page'] . '&amp;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 . '&amp;p=' . $login . '&amp;page=' . $_GET['page'] . '&amp;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 . '&amp;p=' . $login . '&amp;page=' . $_GET['page'] . '&amp;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 . '&amp;p=' . $login . '&amp;page=' . $_GET['page'] . '&amp;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 . '&amp;p=' . $login . '&amp;page=' . $_GET['page'] . '&amp;i=' . $j . '">$1</a></small>', $contents[$j]);

   else if(trim($contents[$j]) != '')
      $contents[$j] = preg_replace("/(.+)\n/i", '<a href="edittext.php?id=' . $id . '&amp;p=' . $login . '&amp;page=' . $_GET['page'] . '&amp;i=' . $j . '">$1</a>' . "\n", $contents[$j]);

   echo $contents[$j];
}

echo '<br/>*********<br/>
&#x0438;&#x043C;&#x044F;:' . $_GET['page'] . ', Pa&#x0437;&#x043C;ep:' . filesize($login . '/' . $_GET['page']) . ' byte
<br/>
<a href="manager.php?id=' . $id . '&amp;p=' . $login . '">&#x041C;&#x0435;&#x043D;&#x0435;&#x0434;&#x0436;&#x0435;&#x0440; &#x0441;&#x0442;&#x0440;&#x0430;&#x043D;&#x0438;&#x0446;</a>
';

// Выводим последнюю часть страницы без изменений
$j++;
for($k = $j; $k < count($contents); $k++)
{
   echo $contents[$k];
}

//echo "</wml>';

?>