Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Very simple password protectetion for very simple php web pages
  5. */
  6.  
  7. $accessWord = 'nameOfMyGirlfriendOrDaughterWhereEsAreReplacedByThrees';
  8.  
  9. if (!isset($_COOKIE['accessWord']) || $_COOKIE['accessWord'] !== md5($accessWord)) {
  10. if (isset($_POST['accessWord']) && trim($_POST['accessWord']) === $accessWord) {
  11. setcookie('accessWord', md5($accessWord), time() + (7 * 24 * 3600));
  12. } else {
  13. echo '<meta charset="utf-8">';
  14. echo '<meta name="viewport" content="width=device-width, initial-scale=1">';
  15. echo '<style>';
  16. echo 'html { font-size: 20px; line-height: 1.5em; box-sizing: border-box; }';
  17. echo '*, *:before, *:after { box-sizing: inherit; }';
  18. echo 'input { font-size: 20px; line-height: 2.5em; padding: 0 0.5em; display: block; margin-bottom: 0.5em; }';
  19. echo 'input[type="submit"] { padding: 0.5em; }';
  20. echo '</style>';
  21. echo '<h1>Please enter accessword</h1>';
  22. echo '<form method="post" action="">';
  23. echo '<input type="password" name="accessWord" />';
  24. echo '<input type="submit" value="Send" />';
  25. echo '</form>';
  26. exit;
  27. }
  28. }
  29.  
  30. // continue here the rest of your php code. Remove above when there is no need for password protection any longer
  31. ?>
  32.  
  33. <h1>Hi, welcome on my web site</h1>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement