authenticate(); } else { if ($this->check_pass(m3_user(), m3_legacy_password(), $mode, '%%SYSTEM%%')) { return $next($request); } else { $this->authenticate(); } } } public static function check_pass($login, $password, $mode, $password_file) { if (! $fh = fopen($password_file, 'r')) { exit('

Could Not Open Password File'); } $match = 0; while (! feof($fh)) { $line = fgets($fh, 4096); $from_file = explode(':', $line); if ($from_file[0] == $login) { if ($mode == 'crypt') { $salt = substr($from_file[1], 0, 2); $user_pass = crypt($password, $salt); } elseif ($mode == 'md5') { $user_pass = md5($password); } if (rtrim($from_file[1]) == $user_pass) { $match = 1; break; } } } if ($match) { return 1; } else { return 0; } fclose($fh); } public static function authenticate() { header('WWW-Authenticate: Basic realm="RESTRICTED ACCESS"'); header('HTTP/1.0 401 Unauthorized'); echo '

INVALID USERNAME OR PASSWORD. ACCESS DENIED

'; exit; } }