search
Homephp教程php手册挑战最棒的留言本的源码(三)

action.php文件:

<?php
require(&#39;config.php&#39;);  
$action=$arr_request[&#39;action&#39;];
$key_liuyan=$arr_request[&#39;key_liuyan&#39;];
if (!isset($PHP_AUTH_USER)) 
  {
    Header(&#39;WWW-Authenticate:Basic realm="管理留言"&#39;);
    Header(&#39;HTTP/1.0 401 Unauthorized&#39;);
    echo &#39;需要受权,你没有这权限!<BR>&#39;;
    echo &#39;单击刷新来重试.<br>&#39;;
    exit;        
  }
else
  {
         if (strlen($PHP_AUTH_USER)!=0)
            {
             if ($action=="delete")  
              echo "对不起,你没有删除留言的权限!!!<br>";
             else if ($action="huifu")
              echo "对不起,你暂时还不能恢复,现在只有版主有这权限!!!<br>";
             else 
              echo "对不起,你没有管理留言本的权限!!!"; 
             exit;   
            }
         $pass=$PHP_AUTH_PW;
        // echo $pass;  
         $result=0;
         while($pass%10!=0)
             {
                $result=$result+$pass%10;
                $pass=($pass-$pass%10)/10;
               // echo $result;
               // echo "<br>"; 
             } 
         $tt=$result*222;
         //echo $tt;
         if (!checkpass($tt,$action,$db_name,$table_name_control,$id_link))
            {
             if ($action=="delete")  
              echo "对不起,你没有删除留言的权限!!!<br>";
             else if ($action="huifu")
              echo "对不起,你暂时还不能恢复,现在只有版主有这权限!!!<br>";
             else 
              echo "对不起,你没有管理留言本的权限!!!"; 
             exit;   
            }
  }
if ($action=="delete")
  {
   //printf("delete");
   //echo $key_liuyan;
   $str_sql="delete from $table_name where key_liuyan=$key_liuyan";
   $re=mysql_db_query($db_name,$str_sql,$id_link);
   if (!$re)
      {
        echo "删除出错";
      }
   else
      {
          echo "成功删除";  
          echo "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">";
          echo "<HTML><HEAD><TITLE>发表文章</TITLE>";
          echo "<META content="text/html; charset=gb2312" http-equiv=Content-Type>";
          echo "<meta HTTP-EQUIV="REFRESH" CONTENT="2;URL=display.php">";
          echo "</head><body topmargin="0"><br>";
          echo "<ul>回复成功,将自动显示留言内容";
          echo " <br>";
          echo "<a href=display.php>如果你的浏览器没有自动的返回到留言簿首页,请点击这里";
          echo "</a></ul>";
       }          
   }
else if ($action=="huifu")
 {
   //printf("huifu");
  // echo $key_liuyan;
      
?>
   <form action="action.php?action=ok" method="post">
   <input type="hidden" name="key" value="<?php echo $key_liuyan?>">
   <textarea name="huifu" cols="50" rows="6"></textarea>
   <input type="submit" value="回复">
   </form>
<?php
  }
else if ($action=="ok")
   {  
      $key=$arr_request[&#39;key&#39;];
      $huifuold=$huifu;
      $time=date(&#39;Y/m/d H:i:s&#39;);
      $time=&#39;(&#39;.$time . &#39;)<br>&#39;;
      $huifuold=$time .$huifuold ;
         
      $huifu_ok=computer_message($huifuold,$hang_zifu_number);      
      if (strlen($key)==0)
         {  echo "error";
            exit;   
         }
      $str_sql="update $table_name set huifu_biaozi=1,
                  huifu=&#39;$huifu_ok&#39;  where key_liuyan=$key";   
   //   echo $str_sql;     
      $re=mysql_db_query($db_name,$str_sql,$id_link);
      if (!$re)
         {
            echo "更新出错";
         }
      else
          {
   
            echo "回复成功";  
    
            echo "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">";
            echo "<HTML><HEAD><TITLE>发表文章</TITLE>";
            echo "<META content="text/html; charset=gb2312" http-equiv=Content-Type>";
            echo "<meta HTTP-EQUIV="REFRESH" CONTENT="2;URL=display.php">";
            echo "</head><body topmargin="0"><br>";
            echo "<ul>回复成功,将自动显示留言内容";
            echo " <br>";
            echo "<a href=display.php>如果你的浏览器没有自动的返回到留言簿首页,?
            请点这里返回.";
            echo "</a></ul>";
            exit; 
    
          }
   }
else
  printf("error");
?>
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.