View file MiniCMS/edit.php

File size: 3.6Kb
<?php
header("Content-type: text/vnd.wap.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("inc/" . 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];
}


$last_tag = '<img src="http://' . $server_name . 'wb/counter.php?id=' . $id . '" alt="counter"/>';
for($j = $i; $j < count($contents) && !(trim($contents[$j]) == '</p>' && trim($contents[$j+1]) == '</card>'); $j++)

{
   

   
   if(preg_match('/<a href=\"(.*?)\">.*?<\/a>/i', $contents[$j]))
      $contents[$j] = preg_replace('/<a href=\"(.*?)\">(.*?)<\/a>/i', '<a href="manager.php?st=edittext&amp;par=' . $par . '&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="manager.php?st=edittext&amp;par=' . $par . '&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="manager.php?st=edittext&amp;par=' . $par . '&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="manager.php?st=edittext&amp;par=' . $par . '&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="manager.php?st=edittext&amp;par=' . $par . '&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="manager.php?st=edittext&amp;par=' . $par . '&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="manager.php?st=edittext&amp;par=' . $par . '&amp;page=' . $_GET['page'] . '&amp;i=' . $j . '">$1</a></small>', $contents[$j]);

///.....MODULI

///.....


   else if(trim($contents[$j]) != '')
      $contents[$j] = preg_replace("/(.+)\n/i", '<a href="manager.php?st=edittext&amp;par=' . $par . '&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(inc . '/' . $_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></p>
';


$j++;
for($k = $j; $k < count($contents); $k++)
{
   echo $contents[$k];
}



?>