View file edit.php

File size: 1.99Kb
<?php
@$pas=$_GET['pas'];
@$t=$_GET['t'];
@$n=$_GET['n'];
@$do=$_POST['do'];
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 or $t=='' or $n=='') die('Ошибка.<hr /></div></body></html>');
$tarr=file('themes.dat');
$tf=strtok($tarr[$t],':||:');
$marr=file('data/'.$tf);
$sa=explode(':||:',$marr[$n]);
if($do!='' and $pas==$admp and $t!='' and $n!=''){
 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="\\1">\\1</a></small>\\2',$text);
 $sa[0]=$nick;
 $sa[1]=$text;
 $marr[$n]=implode(':||:',$sa);
 $f=fopen('data/'.$tf,'w');
 $d=implode('',$marr);
 fputs($f,$d);
 fclose($f);
 echo 'Изменено.<hr />';
}else{
 $sa[1]=str_replace($simg,$sstr,$sa[1]);
 echo '<form action="edit.php?pas='.$pas.'&amp;t='.$t.'&amp;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="view.php?pas='.$pas.'&amp;n='.$t.'">Вернуться</a>]</div></body></html>';
?>