View file guest/add.php

File size: 4.34Kb
<?
	/////////// Powered by Giga!!! /////////
	/////////// http://gwap.net.ru /////////
	/////////// [email protected] /////////
	
	Error_Reporting(E_ALL & ~E_NOTICE);
	
	include "set.php";
  $error = "";
  $action = $HTTP_POST_VARS["action"];
  if (!empty($action)) 
  {
    $name = trim($name);
    $msg = trim($msg);
      if (empty($msg))
      {
        $action = "";
        $error = $error."<br/><span class=\"red\">Вы не ввели сообщение!</span>\n";
      }
      if (empty($name))
      {
        $action = "";
        $error = $error."<br/><span class=\"red\">Вы не ввели имя!</span>\n";
      }
      if (!empty($email))
      /* если введен e-mail, то проверяем с помощью регулярного выражения
      правильность ввода */
      {
        if (!preg_match("/[0-9a-z_]+@[0-9a-z_^\.]+\.[a-z]{2,3}/i", $email))
        {
          $action = "";
          $error = $error."<br/><span class=\"red\">Неверно введен е-mail. Введите e-mail
          в виде <i>[email protected]</i>!</span>";
        }
      if (!empty($url))
      /* если введен e-mail, то проверяем с помощью регулярного выражения
      правильность ввода */
      {
        if (!preg_match("/[0-9a-z_]+\.[0-9a-z_^\.]+\.[a-z]{2,3}/i", $url))
        {
          $action = "";
          $error = $error."<br/><span class=\"red\">Неверно введен url сайта. Введите
          в виде <i>wap.mail.ru</i>!</span>";
          }
        }}
$name = substr($HTTP_POST_VARS["name"],0,32);
$name = htmlspecialchars(stripslashes($name));
$time = substr($HTTP_POST_VARS["time"],0,32);
$time = htmlspecialchars(stripslashes($time)); 
$email = substr($HTTP_POST_VARS["email"],0,32);
$email = htmlspecialchars(stripslashes($email));
$url = substr($HTTP_POST_VARS["url"],0,36);
$url = htmlspecialchars(stripslashes($url));
$msg = substr($HTTP_POST_VARS["msg"],0,1024);
$msg = htmlspecialchars(stripslashes($msg));
if (empty($error)) 
  {
        $currHour=date("H",time());
	$currDate=date("d.m.y", time());
	$currTime=date("$currHour:i", time());
    $time="$currTime/$currDate";
	$msg = eregi_replace("(.*)\\[url\\](.*)\\[/url\\](.*)","\\1<a
                       href=\\2>\\2</a>\\3",$msg);
    $msg = str_replace("\n"," ",$msg);
    $msg = str_replace("\r"," ",$msg);
   $sm1 = array(':-))',':-)',':-P','8-)',':-(',':-O',';-)',':roll:',':rf:','8-(','-(');
$sm2 = array("$s1","$s2","$s3","$s4","$s5","$s6","$s7","$s8","$s9","$s10","$s11");
$msg=str_replace($sm1,$sm2,$msg);		
    $file = fopen("rec/rec.".time(),"w");
    fputs($file,$name."\n");
    fputs($file,$time."\n");
    fputs($file,$email."\n");
    fputs($file,$url."\n");
    fputs($file,$msg."\n");
    fclose($file);
  echo "<html><head>\n";
  echo "<meta http-equiv='refresh' content='0; url=index.php'>\n";
  echo "</head></html>\n";
  }
  }
  if (empty($action))
  {
  include "header.php";
      echo "<p class=\"class1\">добавление записи</p>";
    
    if (!empty($error))
     {
      echo "<p class=\"class1\">Во время добавления<br /> записи произошли <br />
      следующие ошибки</p>\n";
      echo "<p class=\"class2\">";
      echo $error;
      echo "</p>\n";
    }
echo   "<form action=\"add.php\" method=\"post\">
    <p class=\"class2\">
     <input type=\"hidden\" name=\"action\" value=\"post\" />
    <span class=\"red\">*</span>&nbsp;имя<br />
       <input type=\"text\" name=\"name\" maxlength=\"32\" value=\"$name\" />
     <br />e-mail<br />
        <input type=\"text\" name=\"email\" maxlength=\"32\" value=\"$email\" />
      <br />сайт<br />
        <input type=\"text\" name=\"url\" maxlength=\"36\" value=\"$url\" />
      <br /><span class=\"red\">*</span>&nbsp;сообщение<br />
        <input type=\"text\" name=\"msg\" maxlength=\"160\" value=\"$msg\" />
      <br />
      <input type=\"submit\" value=\"добавить\" />
    </p>
  </form>";

  echo "<p class=\"class3\"><span class=\"red\">*</span> - поля, обязательные для заполнения</p>";
  	  
  echo "<p class=\"class1\"><a href=\"smile.php\">смайлы</a><br /><a href=\"./\">$title</a></p>";
  }
  ?>