<?php

define('IN_PHPBB', true);
$phpbb_root_path = '../';
include($phpbb_root_path . 'extension.inc');
include('pagestart.'.$phpEx);
$file = $phpbb_root_path.'templates/index_body.tpl';

if (empty ($_POST['tex2'])) 
	{
 print '
<div class="menu"><img src="/themes/profmas/icrz.png" alt="*"><a href="index.php?sid='.$_GET['sid'].'">Админка</a> | Редактор</div>
<div class="menu">Редактирование</div>';
$tex=file_get_contents($file);
$tex = htmlentities($tex, ENT_QUOTES, 'UTF-8');
echo '<form action= "portal_edit.php?sid='.$_GET['sid'].'" method="post">
<textarea class="enter" cols="84" rows="50" name="tex2" maxlength="10024" value="">'.$tex.'</textarea><br><br>
<input class="buttom" type="submit" value="Изменить"></form></div>';
  }

   if ($_POST['tex2'])
  {
 echo '
<div class="menu"><a href="index.php?sid='.$_GET['sid'].'">Админка</a>|Редактор</div>
<p>Главная отредактирована.</p>
';
 $tex2=$_POST['tex2'];
  $tex2=str_replace('\"','"',$tex2);
 echo '<form action= "portal_edit.php?sid='.$_GET['sid'].'" method="post">
<textarea class="enter" cols="85" rows="30" name="tex2" maxlength="256" value="">'.$tex2.'</textarea><br><br>
<input class="buttom" type="submit" value="Изменить"></form></div>';
  			
////////////////////////////////
$fp = fopen($file,"w"); 
flock ($fp,LOCK_EX);
fputs($fp,$tex2);
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
 

 }
?>