File size: 1.84Kb
<?php
@$pas=$_GET['pas'];
@$n=intval($_GET['n']);
require('ini.php');
require('smiles.ini.php');
Header('Content-Type: application/xhtml+xml;charset=utf-8');
Header('Cache-Control: no-cache, must-revalidate');
print '<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru"><head><title>Edit</title>
<link rel="stylesheet" type="text/css" href="style.css" /></head><body><div>';
if($pas!=$admp) die('Ошибка.<hr /></div></body></html>');
$arr=file('book.dat');
$sa=explode(':||:',$arr[$n]);
if(isset($_POST['do'])){
function safe($str)
{
$str=trim(stripslashes(htmlspecialchars($str)));
$str=strtr($str,array(':||:'=>' ',"\n"=>' '));
return $str;
}
@$nick=safe($_POST['nick']);
@$text=safe($_POST['text']);
if($nick=='' || $text=='') die('Ошибка. <i>Не заполнено поле</i></div></body></html>');
$text=str_replace($sstr,$simg,$text);
$text=preg_replace('!(http://[\S]+)([\s]|$)!i','<small><a href="go.php?\\1">\\1</a></small>\\2',$text);
$sa[0]=$nick;
$sa[1]=$text;
$arr[$n]=implode(':||:',$sa);
$f=fopen('book.dat','w');
$d=implode('',$arr);
fputs($f,$d);
fclose($f);
echo('Изменено.<hr />');
}else{
$sa[1]=str_replace($simg,$sstr,$sa[1]);
echo '<form action="edit.php?pas='.$pas.'&n='.$n.'" method="post"><div>
<span class="bl">Имя:</span>
<input type="text" name="nick" value="'.$sa[0].'" maxlength="20" size="8" /><br />
<span class="bl">Сообщение:</span>
<input type="text" name="text" value="'.strip_tags($sa[1]).'" size="12" /><br />
<input type="submit" name="do" value="Изменить" />
</div></form><hr />';
}
print '[<a href="index.php?pas='.$pas.'">Вернуться</a>]</div></body></html>';
?>