<?php
Error_Reporting(E_ALL & ~E_NOTICE);
Error_Reporting (ERROR | WARNING);
session_name("SESID");
session_start();
include"../../config.php";
$id="$_SESSION[id]";
$jdata = file("../../data/users/profil/$id.$raz");
$viewmess = explode("|", $jdata[0]);
$name=$viewmess[1];
$mail=$viewmess[3];
$url=$viewmess[2];
$wmz=$viewmess[4];
$pass=$viewmess[0];
$datu=$viewmess[5];
if($pass==$_SESSION[pass]) {
include ("../../templates/tr_to_win.php");
$banlist = file("../../data/ban.txt");
$base = '../../data/gb.txt';
if(!empty($_POST["for"]))
{
$for = "$_POST[for]";
$for = trim($for);
$for = stripslashes($for);
$for = htmlspecialchars($for);
$for = str_replace('|', '', $for);
if(strlen($for) > 20)
{
$err = "Имя кому не должно быть длиньше 20-ти символов<br>";
}
}
$email = "$mail";
$msg = "$_POST[msg]";
$msg = trim($msg);
$url = str_replace('http://','',$url);
$url = str_replace('|', '', $url);
$msg = stripslashes($msg);
$msg = htmlspecialchars($msg);
$msg = str_replace('|', '', $msg);
if ($_POST[msgtrans]==1)
{
$msg = tr_to_win($msg);
}
if ($_POST[nametrans]==1)
{
$name = tr_to_win($name);
}
$time = date("H:i", time());
$date = date("d.m.y", time());
$ip = getenv("REMOTE_ADDR");
$user_agent = getenv("HTTP_USER_AGENT");
$brauzer = strtok($user_agent," ");
$brauzer = htmlspecialchars($brauzer);
$brauzer = str_replace('|', '', $brauzer);
$ban = "$brauzer||$ip";
if(strlen($msg) > 1000)
{
$err = "Сообщение не должно быть длиньше 1000 символов<br>";
}
if(empty($msg))
{
$err .= "Не введено сообщение<br>";
}
if(!empty($email))
foreach ($banlist as $key => $string)
{
if($ban == trim(array_shift($banlist)))
{
$err .= "Доступ в гостевую для $brauzer : $ip закрыт!<br>" ;
}
}
if(!empty($err))
{
header ("Location: add.php?err=$err");
}
if(empty($err))
{
# Начало Смайлики ;-)
$sm_dir = opendir("../../sm");
while ($file = readdir($sm_dir))
{
if($file != "Thumbs.db" && $file != ".." && $file != ".")
{
$sm_array[] = "<img src=\"../../sm/$file\" alt=\"sm\" />";
}
}
closedir ($sm_dir);
sort($sm_array);
$sm_dir1 = opendir("../../sm");
while ($file1 = readdir($sm_dir1))
{
if($file1 != "Thumbs.db" && $file1 != ".." && $file1 != ".")
{
$file1 = explode(".", $file1);
$sm_array1[] = ":$file1[0]:";
}
}
sort($sm_array1);
closedir ($sm_dir1);
# Конец Смайлики ;-)
# Начало антимат
$mat_file = file("../../data/antimat.txt");
$count_mat_file = count($mat_file);
for ($i = 0; $i <= $count_mat_file; $i++)
{
$mat = explode("::", "$mat_file[$i]");
$mat_array[] = "$mat[0]";
}
$mat_file1 = file("../../data/antimat.txt");
$count_mat_file1 = count($mat_file1);
for ($i = 0; $i <= $count_mat_file1; $i++)
{
$mat1 = explode("::", "$mat_file1[$i]");
$mat1 = str_replace('
','',"$mat1[1]");
$mat_array1[] = "$mat1";
}
# Конец антимат
# Начало BB коды
$msg = str_replace("[b]","<b>",$msg);
$msg = str_replace("[/b]","</b>",$msg);
$msg = str_replace("[i]","<i>",$msg);
$msg = str_replace("[/i]","</i>",$msg);
$msg = str_replace("[s]","<s>",$msg);
$msg = str_replace("[/s]","</s>",$msg);
$msg = str_replace("[u]","<u>",$msg);
$msg = str_replace("[/u]","</u>",$msg);
$msg = str_replace("[u]","<u>",$msg);
# Конец BB коды
$msg = str_replace($sm_array1, $sm_array, $msg);
$msg = str_replace($mat_array, $mat_array1, $msg);
$msg = str_replace('
', '<br/>', $msg);
$back = @file_get_contents("$base");
$file = fopen("$base","w");
flock ($file,LOCK_EX);
fputs($file,"$name|$for|$brauzer|$ip|$time|$date|$email|$url|$msg|$id"."\r\n"."$back");
fflush ($file);
flock ($file,LOCK_UN);
fclose($file);
}}
header ("Location: index.php");
?>