Home > Backend Development > PHP Tutorial > PHP implements http login verification

PHP implements http login verification

WBOY
Release: 2016-07-25 08:45:34
Original
950 people have browsed it
  1. /*
  2. http authentication
  3. Determine the source page
  4. Write a log
  5. */
  6. ////////////Disable error reporting////////// ////
  7. error_reporting(0);
  8. ///////////http authentication/////////////
  9. if(!isset($_SERVER['PHP_AUTH_USER']) )
  10. {
  11. header('WWW-Authenticate: Basic realm="login:"');
  12. header('HTTP/1.0 401 Unauthorized');
  13. echo 'login failed!';
  14. exit;
  15. }
  16. else
  17. {
  18. echo $_SERVER['PHP_AUTH_USER'].'
    ';
  19. echo $_SERVER['PHP_AUTH_PW'].'
    ';
  20. }
  21. ///////////Judgment Road page //////////////
  22. echo $_SERVER["HTTP_REFERER"];
  23. ///////////Write record//////////// ///////////
  24. $file='hack.log';
  25. $con="username:".$_SERVER['PHP_AUTH_USER']."rnpassword:".$_SERVER['PHP_AUTH_PW'] ."rntime:".date("H:i:s")."rn".$_SERVER["HTTP_REFERER"]."rn------------------- ----------------------------rn";
  26. if(file_put_contents($file,$con,FILE_APPEND))echo date("H :i:s")."
    success!
    ";
  27. ///////////////////////////// ////////
  28. ?>
Copy code

php, http


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template