    PHP (  )



    "   PHP".

    ,     RECORDS (     ,       ).     : index.php ( )  addrec.php ( ,      ).

,   addrec.php     ,        RECORDS.

 ,          :

<?
  $error = "";
  $action = $HTTP_POST_VARS["action"];
  if (!empty($action))
  {
  $name = trim($name);
  $msg = trim($msg);
  if (empty($msg)) //    
  {
  $action = "";
  $error = $error."<LI>   \n";
  }
  if (empty($name)) //    
  {
  $action = "";
  $error = $error."<LI>   \n";
  }
  if (!empty($email))
  /*   e-mail,      
    */
  {
  if (!preg_match("/[0-9a-z_]+@[0-9a-z_^\.]+\.[a-z]{2,3}/i", $email))
  {
  $action = "";
  $error = $error."<LI>   -mail.&nbs  e-mail
    <i>softtime@softtime.ru</i> \n";
  }
  }

       HTML-   :

$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);
$email = htmlspecialchars(stripslashes($email)); //  e-mail
$url = substr($HTTP_POST_VARS["url"],0,36);
$url = htmlspecialchars(stripslashes($url)); //  url-
$msg = substr($HTTP_POST_VARS["msg"],0,1024);
$msg = htmlspecialchars(stripslashes($msg)); //  

      , , ,    .  ,   ,  ,      ,      <i></i>  ..    ,   ,         HTML-:

if (empty($error)) //   ,  
  {
  $msg = nl2br($msg);
  $msg = str_replace("[u]","<u>",$msg);
  $msg = str_replace("[U]","<u>",$msg);
  $msg = str_replace("[i]","<i>",$msg);
  $msg = str_replace("[I]","<i>",$msg);
  $msg = str_replace("[b]","<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 = str_replace("[/u]","</u>",$msg);
  $msg = str_replace("[/U]","</u>",$msg);
  $msg = str_replace("[/i]","</i>",$msg);
  $msg = str_replace("[/I]","</i>",$msg);
  $msg = str_replace("[/b]","</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);
  $msg = str_replace("\n"," ",$msg);
  $msg = str_replace("\r"," ",$msg);

     ,   :

  /*      "rec.+  " */
  $file = fopen("records/rec.".time(),"w");
  //    ,      
  fputs($file,$name."\n");
  fputs($file,$city."\n");
  fputs($file,$email."\n");
  fputs($file,$url."\n");
  fputs($file,$msg."\n");
  //  
  fclose($file);

  index.php,    :

  print "<HTML><HEAD>\n";
  print "<META HTTP-EQUIV='Refresh' CONTENT='0; URL=index.php'>\n";
  print "</HEAD></HTML>\n";
  }
  }

       HTML-   :

  if (empty($action))
  {
  <?
  <HTML>
  <HEAD>
  <TITLE>  -  </TITLE>
  </HEAD&tg;
  <BODY>
  <H3>
  <? print "<center>"; ?>
  <font color=#1E90FF> </font>
  </H3>
  <?
  if (!empty($error))
  /*   ,     */
  {
  print "<P><font color=green>    
   :</font></P>\n";
  print "<UL>\n";
  print $error;
  print "</UL>\n";
  }
  ?>
  <!--  HTML-    !-->
  <center>
  <table width=1 border=0>
  <form action=addrec.php method=post>
  <input type=hidden name=action value=post>
  <tr>
  <td width=50%>:<font color=red><sup>*</sup><font></td>
  <td align=right>
  <input type=text name=name maxlength=32 value='<? echo $name; ?>'>
  </td>
  </tr>
  <tr>
  <td width=50%>:</td>
  <td align=right>
  <input type=text name=city maxlength=32 value='<? echo $city;; ?>'>
  </td>
  </tr>
  <tr>
  <td width=50%>E-Mail:</td>
  <td align=right>
  <input type=text name=email maxlength=32 value='<? echo $email; ?>'>
  </td>
  </tr>
  <tr>
  <td width=50%>URL:</td>
  <td align=right>
  <input type=text name=url maxlength=36 value='<? echo $url; ?>'>
  </td>
  </tr>
  <tr>
  <td colspan=2>:<font color=red<sup>*</sup></font><br>
  <textarea cols=50 rows=8 name=msg><? echo $url; ?>
  </textarea>
  </td>
  </tr>
  <tr>
  <td colspan=2><input type=submit value=''></td>
  </tr>
  </form>
  <tr>
  <td colspan=2><font color=red><sup>*</sup></font> - ,
    
  </td><td align=left>
  </table>
  </center>
  </BODY>
  </HTML>
  <?
  }
  ?>

  index.php,    :

  <HTML>
  <HEAD>
  <TITLE> </TITLE>
  </HEAD>
  <BODY>
  <?
  /*        */
  $dir_rec = dir("records");
  $i = 0;
  while($entry = $dir_rec->read())
  {
  if (substr($entry,0,3)=="rec")
  {
  $names[$i]=substr($entry,4);
  $i++;
  }
  }
  $dir_rec->close(); //  
  @rsort($names); //  
  /*       */
  $count = $i;
  $count1 = $count;
  if (empty($start))
  {
  $start = 0;
  }
  $start = intval($start);
  if ($start < 0)
  {
  $start = 0;
  }
  print "<center>";
  if ($count > $start + 10) $count = $start + 10;
  if ($start != 0)
  {
  print "<A href=index.php?start=".($start - 10)."></A>";
  }
  print "<a href=addrec.php> </A>";
  if ($count1 > $start + 10)
  {
  print "<A href=index.php?start=".($start + 10)."></A> \n";
  }
  print "</center><br>";
  /*      */
  for ($i = $start; $i < $count; $i++)
  {
  $entry = $names[$i];
  $data = file("records/rec.".$entry);
  $date = $entry;
  $name = trim($data[0]);
  $city = trim($data[1]);
  $email = trim($data[2]);
  $url = trim($data[3]);
  $msg = trim($data[4]);
  /* ,       */
  $answer = trim($data[5]);
  print "<table border=0 cellspacing=0 cellpadding=2 width=100%>
  <tr bgcolor=#F0F0F0><td>&nbs;";
  print "<b>$name</b>&nbs;";
  if (!empty($city)) print "$city&nbs";
  if (!empty($email)) print "<a href=mailto:$email><i>$email</i></A>\n";
  if (!empty($url)) print "<a href=$url>$url</a>";
  print "</td><td align=right>".date("<b>d-m-Y</b> H - i, $date)."
  </td></tr>\n<tr><td colspan=2>\n";
  print "<P>".$msg."</P>\n";
  if (!empty($answer)) //   - 
  {
  print "<P><font color=#1E90FF>admin:&nbs$answer</font></P>\n";
  }
  print "</td></tr></table>\n<br><br>\n";
  }
  print "<center>";
  if ($start != 0)
  {
  print "<A href=index.php?start=".($start - 10)."></A>";
  }
  print "<a href=addrec.php> </A>";
  if ($count1 > $start + 10)
  {
  print "<A href=index.php?start=".($start + 10)."></A> \n";
  }
  print "</center>";
  ?>
  </BODY>
  </HTML>

  .