Advertisement
Guest User

Untitled

a guest
Oct 6th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.42 KB | None | 0 0
  1. function checkPasswd($passwd, $user) {
  2.     $authenticated = false;
  3.  
  4.     if($fh = fopen('passwd.txt', 'r')) {
  5.         while(!feof($fh)) {
  6.             $line = trim(fgets($fh));
  7.             $account = explode(':', $line);
  8.  
  9.             if(count($account) == 2) {
  10.                 list($username, $password) = $account;
  11.  
  12.                 if($username == $user && $password == $passwd) {
  13.                     $authenticated = true;
  14.                 }
  15.             }
  16.         }
  17.  
  18.         fclose($fh);
  19.     }
  20.  
  21.     return $authenticated;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement