<?php
include "config.php";
$error="";
$action=$HTTP_POST_VARS["action"];
if ($action !="")
{
$lenmsg=strlen($msg);
$templen=0;
$temp=strtok($msg, " ");
if (strlen($msg) > 60)
{
while ($templen < $lenmsg)
{
if (strlen($temp) > 60)
{
$action="";
$error=$error."<li> Текст сообщения содержит слишком много символов без пробелов";
break;
}
else
{
$templen=$templen + $strlen($temp) + 1;
}
$temp=strtok(" ");
}
}
$name=trim($name);
$msg=trim($msg);
if (empty ($msg))
{
$action="";
$error=$error."<li> Вы не ввели сообщение";
}
if (empty ($name))
{
$action="";
$error=$error."<li> Вы не ввели имя";
}
if (!empty($email))
{
if (preg_match("/[0-9a-z]+@[0-9a-z_^\.]+\.[a-z]{2,3}/i", $email))
{
$action="";
$error=$error."<li> Не верно введён e-mail. Ввдите e-mail в виде <i>admin@promoney.com.ru</i>";
}
}
$name=substr($HTTP_POST_VARS["name"],0,32);
$name=htmlspecialchars(stripslashes($name));
$city=substr($HTTP_POST_VARS["city"],0,32);
$city=htmlspecialchars(stripslashes($city));
$email=substr($HTTP_POST_VARS["email"],0,32);
$name=htmlspecialchars(stripslashes($email));
$url=substr($HTTP_POST_VARS["url"],0,32);
$url=htmlspecialchars(stripslashes($url));
$msg=substr($msg,0,1024);
if (empty($error))
{
$msg=nl2br($msg);
$msg=str_replace("[u]","<u>",$msg);
$msg=str_replace("[U]","<u>",$msg);
$msg=str_replace("","<i>",$msg);
$msg=str_replace("","<B>",$msg);
$msg=str_replace("[B]","<B>",$msg);
$msg=str_replace("[sub]","<SUB>",$msg);
$msg=str_replace("[sup]","<SUP>",$msg);
$msg=str_replace("[SUp]","<SUP>",$msg);
$msg=str_replace("[/u]","</u>",$msg);
$msg=str_replace("[/U]","</u>",$msg);
$msg=str_replace("","</i>",$msg);
$msg=str_replace("[/I]","</i>",$msg);
$msg=str_replace("","</B>",$msg);
$msg=str_replace("[/B]","</B>",$msg);
$msg=str_replace("[/SUB]","</SUB>",$msg);
$msg=str_replace("[/sub]","</SUB>",$msg);
$msg=str_replace("[/SUP]","</SUP>",$msg);
$msg=str_replace("[/sup]","</SUP>",$msg);
$msg=eregi_replace("(.*)\\[url\\](.*)\\[/url\\](.*)","\\1<a href=\\2>\\2</a>\\3",$msg);
$query="insert into guest values (0,'$name','$city','$email','$url','$msg','-',now(),0);";
if (mysql_query($query))
{
print "<html><head>\n";
print "<meta http-equev='Refresh' content='0; url=index.php'>\n";
print "</head></html>\n";
exit();
}
else
{
echo "<a href='index.php'>Вернуться</a>";
echo ("<p>Ошибка при добавлении сообщения</p>");
echo("<p>$query</p>");
exit();
}
}
}
if (empty($action))
{
?>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=windows-1251">
<title>Новое сообщение</title>
</head>
<body bottommarign="0" marignheight="0" marignwidht="0" rightmarign="0" leftmarign="0" topmarign="0">
<table>
<tr>
<td>
<form action="addrec.php" method="post">
<input type="hidden" name="action" value="post">
<table aligne="center" cellpading="0" cellspacing="0">
<tr>
<td colspan=2><b>Добавление сообщения</b></td>
</tr>
<tr>
<td width="50"><b> Имя </b></td>
<td><input type="text" name="name" maxlength=32 size=25 value='<?echo $name;?>'></td>
<td rowspan="3" width="120">* Обязательные для заполнения поля</td>
</tr>
<tr>
<td><b> Город</b></td>
<td><input type="text" name="city" maxlength=32 size=25 value='<?echo $city;?>'></td>
</tr>
<tr>
<td><b> E-mail</b></td>
<td><input type="text" name="email" maxlength=32 size=25 value='<?echo $email;?>'></td>
</tr>
<tr>
<td><b> URL</b></td>
<td colspan="2"><input type="text" name="url" maxlength=36 size=40 value='<?echo $url;?>'></td>
</tr>
<tr>
<td colspan"3">
<b>Сообщение *</b><br>
<textarea name="msg" cols=42 rows=5><?echo $msg;?></textarea>
</td>
</tr>
<tr>
<td colspan"3">
<input type="submit" value="Добавить">
</td>
</tr>
</table>
<td>
<table border"0" cellspacing="1" cellpading="4">
<tr align="left">
<td>
<u><i><b>Поддерживаемые теги:</u></i></b>
</td>
</tr>
<tr><td><b>Жирный</b></td></tr>
<tr><td><i>Наклонный</i></td></tr>
<tr><td>[u]<u>Подчёркнутый</u>[/u]</td></tr>
<tr><td><sup>Верхний индекс</sup></td></tr>
<tr><td><sub>Нижний индекс</sub></td></tr>
</table>
</td>
</form>
</td>
</tr>
</table>
</body>
</html>
<?
if (!empty($error))
{
print "<P>Во время добавления записи произошли следующие ошибки:</P>";
print "<UL>\n";
print $error;
print "</UL>\n";
}
?>
<?}?>
|