Просмотр файла guest/add.php

Размер файла: 6.81Kb
<?
	/////////// Powered by Giga!!! /////////
	/////////// http://gwap.net.ru /////////
	/////////// [email protected] /////////
	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/>- Вы не ввели сообщение\n";
      }
      if (empty($name))
      {
        $action = "";
        $error = $error."<br/>- Вы не ввели имя\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/>- Неверно введен е-mail. Введите e-mail
          в виде <i>[email protected]</i>";
        }
      if (!empty($url))
      /* если введен e-mail, то проверяем с помощью регулярного выражения
      правильность ввода */
      {
        if (!preg_match("/[0-9a-z_]+\.[0-9a-z_^\.]+\.[a-z]{2,3}/i", $url))
        {
          $action = "";
          $error = $error."<br/>- Неверно введен url сайта. Введите
          в виде <i>wap.mail.ru</i>";
          }
        }}
$name = substr($HTTP_POST_VARS["name"],0,32);
$name = htmlspecialchars(stripslashes($name));
$time = substr($HTTP_POST_VARS["time"],0,32);
$time = htmlspecialchars(stripslashes($time)); //некоторые умельцы научились добавлять в post левое вместо времени 
$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(":)",":(",":))",":=)",":cool",":love",":oo",":pivo",";)",":?");
$sm2= array(
"<img src=\"./sm/ulibka.gif\" alt=\":)\"/>",
"<img src=\"./sm/ogorchen.gif\" alt=\":(\"/>",
"<img src=\"./sm/bulibka.gif\" alt=\":))\"/>",
"<img src=\"./sm/zubastik.gif\" alt=\":=)\"/>",
"<img src=\"./sm/cool.gif\" alt=\"cool\"/>",
"<img src=\"./sm/love.gif\" alt=\"love\"/>",
"<img src=\"./sm/boggle.gif\" alt=\"oo\"/>",
"<img src=\"./sm/pivo.gif\" alt=\"pivo\"/>",
"<img src=\"./sm/wink.gif\" alt=\";)\"/>",
"<img src=\"./sm/vopros.gif\" alt=\"?\"/>"
);
$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);
  print "<HTML><HEAD>\n";
  print "<META HTTP-EQUIV='Refresh' CONTENT='0; URL=index.php'>\n";
  print "</HEAD></HTML>\n";
  }
  }
  if (empty($action))
  {
  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">
<head>
<meta http-equiv="Cache-Control" content="must-revalidate" forua="true"/>
<meta http-equiv="Cache-Control" content="no-cache" forua="true"/>
<meta http-equiv="Cache-control" content="max-age=2" forua="true"/>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>';
echo "<title>$site-гостевая</title>";
echo '<link rel="shortcut icon" href="/images/18.gif"/>
<link rel="home" href="/"/><link rel="up" href="../"/>
<style type="text/css">
	body {background-color:#FFFFFF; margin:0px; padding:0px; font-family: sans-serif; font-size: small;}
	h1 {color: #000000;font-size: medium;}
	h2 {color: #666666; font-size: medium;}
	img {border:0px; border-spacing:0;}
	table.header {border-spacing:0; font-size:0px; }
	td, div {margin: 0 0 0 0; padding: 0 0 0 0;}
	.block {display:block; float: left;}
	a {color: #ff0000; text-decoration: none; font-size: small}
	.UpLink a {text-transform: uppercase;}
</style>
</head>
<body>';
      echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"0\" align=\"center\" width=\"100%\" bgcolor=\"#faad1e\">
  <tr bgcolor=\"#fce1ae\" align=\"center\"><td><font color=\"#990000\">добавление записи</font></td></tr></table>";
    
    if (!empty($error))
     {
      print "<p align=\"center\"><font color=\"#FF0000\">Во время добавления записи произошли 
      следующие ошибки:</font></p>\n";
      print "<UL>\n";
      print $error;
      print "</UL>\n";
    }
   ?>
    <table align="center" width="1" border="0">
     <form action="add.php" method="post">
     <input type="hidden" name="action" value="post">
    <tr>
     <td align="center"><font color="red"><sup>*</sup></font>имя</td></tr><tr>
     <td align="center">
       <input type="text" name="name" maxlength="32" value="<? echo $name; ?>">
     </td>
    </tr>
    <tr>
      <td align="center">e-mail</td></tr>
      <tr><td align="center">
        <input type="text" name="email" maxlength="32" value="<? echo $email; ?>">
      </td>
    </tr>
    <tr>
      <td align="center">сайт</td></tr>
      <td align="center">
        <input type="text" name="url" maxlength="36" value="<? echo $url; ?>">
      </td>
    </tr>
    <tr>
      <td align="center"><font color="#FF0000">*</font>сообщение</td></tr>
        <tr>
      <td align="center"><input type="text" name="msg" maxlength="160" value="<? echo $msg; ?>">
      </td>
    </tr>
    <tr>
      <td align="center"><input type="submit" value="Добавить"></td>
    </tr>
  </form>
  </table>
   <div><font color="#FF0000">*</font> - поля,
      обязательные для заполнения
    
  </div>
  
  </BODY>
  </HTML>
  <?
  {
  	  echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"0\" align=\"center\" width=\"100%\" bgcolor=\"#faad1e\">
  <tr bgcolor=\"#fce1ae\" align=\"center\"><td><font color=\"#990000\"><a href=\"./\">гостевая</a></font></td></tr></table>";
  }
  ?>
  <?
  }
    /////////// Лучшая и к тому же беплатная коллекция php скриптов на http://visavi.net !!! /////////
    ////////// Опасайтесь подделок!!! ///////////
    ///////// Удачи!!! ////////
    	?>