Просмотр файла say.php

Размер файла: 2.37Kb
<?php
@$pas=$_GET['pas'];
@$n=$_GET['n'];
@$do=$_POST['do'];
include'ini.php';
Header('Content-type: application/xhtml+xml;charset=utf-8');
Header('Cache-control: no-cache, must-revalidate');
echo '<?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>Say</title><link rel="stylesheet" type="text/css" href="style.css" /></head><body><div>';
if($do!='' && $n!=''){
@$nick=stripslashes(htmlspecialchars($_POST['nick']));
@$text=stripslashes(htmlspecialchars($_POST['text']));
$nick=trim($nick);
$text=trim($text);
if($text=='' || $nick==''){die('Не заполнено одно из обязательных полей!</div></body></html>');}
$nick=str_replace(':||:','',$nick);
$text=str_replace(':||:','',$text);
$nick=str_replace("\n",'',$nick);
$text=str_replace("\n",'',$text);
$br=getenv('HTTP_USER_AGENT');
$ip=getenv('REMOTE_ADDR');
$date=date('d.m G:i', time());
$tarr=file('themes.dat');
$sarr=explode(':||:',$tarr[$n]);
$marr=file('data/'.$sarr[0]);
$cnt=count($marr);
$sarr[2]=trim($nick);
$sarr[3]=$date;
$sarr[4]=($cnt+1)."\n";
$data=implode(':||:',$sarr);
$tarr[$n]='';
$f=fopen('themes.dat','w');
$d=implode('',$tarr);
fputs($f,$data.$d);
fclose($f);
include'smiles.ini.php';
$text=str_replace($sstr,$simg,$text);
$f=fopen('data/'.$sarr[0],'a');
$sd=trim($nick).':||:'.trim($text).':||:'.$date.':||:'.$br.':||:'.$ip."\n";
fputs($f,$sd);
fclose($f);
print'Сообщение добавлено.';
print'<br /><a href="view.php?';
if($pas!=''){print'pas='.$pas.'&amp;';}
print'n=0';
if($cnt>$ns || $cnt==$ns){print'&amp;c='.($cnt-$ns+1);}
echo '">Просмотр сообщения</a><hr />';
}
else{
print'<form action="say.php?n='.$n;
if($pas!=''){print'&amp;pas='.$pas;}
echo '" method="post">
<div>Имя:</div>
<input type="text" name="nick"  maxlength="20" size="8" /><br />
<div>Сообщение:</div>
<input type="text" name="text" value="" size="14" /><br />
<input type="submit" name="do" value="Добавить" />
</form><hr />';
echo'[<a href="view.php?';
if($pas!=''){print'pas='.$pas.'&amp;';}
print'n='.$n.'">Вернуться</a>]<br />';
}
echo'[<a href="index.php';
if($pas!=''){print'?pas='.$pas;}
echo '">К темам</a>]</div></body></html>';
?>