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

Размер файла: 3.46Kb
<?php
@$pas=$_GET['pas'];
@$do=$_POST['do'];
@$tr=$_POST['tr'];
require('ini.php');
if($pas!=$admp) include('ban.ini.php');
$arr=file('book.dat');
if($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(!isset($_COOKIE['name']) or $_COOKIE['name']!=$nick) setcookie('name',$nick,time()+86400,'/');
if(strlen($nick)>50)
{
 if($pas) Header('Location: index.php?pas='.$pas); else Header('Location: index.php');
 exit;
}
if(strlen($text)>3072)
{
 if($pas) Header('Location: index.php?pas='.$pas); else Header('Location: index.php');
 exit;
}
if($text=='' || $nick=='')
{
 if($pas) Header('Location: say.php?pas='.$pas); else Header('Location: say.php');
 exit;
}
$cnt=count($arr);
if($cnt>0){
$a=explode(':||:',$arr[0]);
if($nick==$a[0] and $text==$a[1])
{
 if($pas) Header('Location: index.php?pas='.$pas); else Header('Location: index.php');
 exit;
} }
if($tr=='on'){
$text=strtr($text,array(
'A'=>'А','a'=>'а','B'=>'Б','b'=>'б',
'V'=>'В','v'=>'в','G'=>'Г','g'=>'г',
'D'=>'Д','d'=>'д','E'=>'Е','e'=>'е',
'yo'=>'Ё','Zh'=>'Ж','zh'=>'ж','Z'=>'З',
'z'=>'з','I'=>'И','i'=>'и','J'=>'Й',
'j'=>'й','K'=>'К','k'=>'к','L'=>'Л',
'l'=>'л','M'=>'М','m'=>'м','N'=>'Н',
'n'=>'н','O'=>'О','o'=>'о','P'=>'П',
'p'=>'п','R'=>'Р','r'=>'р','S'=>'С',
's'=>'с','T'=>'Т','t'=>'т','U'=>'У',
'u'=>'у','F'=>'Ф','f'=>'ф','H'=>'Х',
'h'=>'х','C'=>'Ц','c'=>'ц','Ch'=>'Ч',
'ch'=>'ч','Sh'=>'Ш','sh'=>'ш','Sch'=>'Щ',
'sch'=>'щ',"''"=>'ъ',"'"=>'ь','Y'=>'Ы',
'y'=>'ы','Ye'=>'Э','ye'=>'э','Yu'=>'Ю',
'yu'=>'ю','Ya'=>'Я','ya'=>'я','Yo'=>'ё')); }
$text=preg_replace('!(http://[\S]+)([\s]|$)!i','<small><a href="go.php?\\1">\\1</a></small>\\2',$text);
$date=date('d.m G:i', time());
require('smiles.ini.php');
$text=str_replace($sstr,$simg,$text);
if($cnt>$np) unset($arr[$cnt-1]);
$f=fopen('book.dat','w');
$sd=trim($nick).':||:'.$text.':||:'.$date.':||:'.$br.':||:'.$ip."\n";
fputs($f,$sd.implode('',$arr));
fclose($f);
if($pas) Header('Location: index.php?pas='.$pas); else Header('Location: index.php');
}else{
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>Say</title>
<link rel="stylesheet" type="text/css" href="style.css" /></head><body>
<div style="text-align: center"><hr />[<a href="prav.php">Пpaвилa</a>]</div><div>
<form action="say.php');
if($pas) print('?pas='.$pas);
print('" method="post">
<div>Имя:</div>
<input type="text" name="nick"  maxlength="24" size="8" ');
if(isset($_COOKIE['name'])) print('value="'.$_COOKIE['name'].'"');
print(' /><br />
<div>Сообщение:</div>
<input type="text" name="text" value="');
if(isset($_GET['n'])) @print(strtok($arr[$_GET['n']],':||:').', ');
print('" size="14" /><br />
Tpaнcлит: <input type="checkbox" name="tr" /><br />
<input type="submit" name="do" value="Добавить" />
</form><hr />
[<a href="smile.php');
if($pas) print('?pas='.$pas);
print('">Cмaйлы</a>]<br />');
}
print('[<a href="index.php');
if($pas) print('?pas='.$pas);
echo('">B гocтeвую</a>]</div></body></html>');
?>