authcheck.php 668 B

123456789101112131415161718192021222324
  1. <?php
  2. if (isset($_GET['username']) && isset($_GET['password'])){
  3. $username = $_GET['username'];
  4. $password = hash("sha512",$_GET['password']);
  5. include_once("requestView.php");
  6. //Usage: RequestView ("view URL", "key"); --> Key is the MapReduce outcome key
  7. $results = requestView("auth/_design/chkauth/_view/authv1/",$username);
  8. if (count($results["rows"]) == 0){
  9. //Username not found.
  10. echo "Username Not Found.";
  11. exit(0);
  12. }
  13. //Check if the password hash match
  14. if ($results["rows"][0]["value"] == $password){
  15. echo "Password Correct";
  16. }else{
  17. echo "Password Incorrect";
  18. }
  19. }else{
  20. //Some parameter missing
  21. die("Username or Password not defined.");
  22. }
  23. ?>