login.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. require_once "config.php";
  3. require_once "sessions.php";
  4. @$op = $_REQUEST["op"];
  5. if ($op == "perform-login") {
  6. $user = SQLite3::escapeString($_REQUEST["user"]);
  7. $password = SQLite3::escapeString('SHA256:' . hash('sha256', "$user:" . $_REQUEST["password"]));
  8. $dbh = Db::get();
  9. $res = $dbh->query("SELECT id FROM epube_users WHERE user = '$user' AND pass = '$password'");
  10. if ($line = $res->fetchArray(SQLITE3_ASSOC)) {
  11. $_SESSION["owner"] = $user;
  12. header("Location: index.php");
  13. }
  14. }
  15. ?>
  16. <!DOCTYPE html>
  17. <html>
  18. <head>
  19. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  20. <link href="lib/bootstrap/v3/css/bootstrap.min.css" rel="stylesheet" media="screen">
  21. <link href="lib/bootstrap/v3/css/bootstrap-theme.min.css" rel="stylesheet" media="screen">
  22. <link href="lib/qtip2/jquery.qtip.min.css" rel="stylesheet" media="screen">
  23. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  24. <script src="lib/bootstrap/v3/js/jquery.js"></script>
  25. <script src="lib/bootstrap/v3/js/bootstrap.min.js"></script>
  26. <script src="lib/holder.min.js"></script>
  27. <script src="lib/localforage.min.js"></script>
  28. <script src="lib/qtip2/jquery.qtip.min.js"></script>
  29. <title>The Epube</title>
  30. <link type="text/css" rel="stylesheet" media="screen" href="css/index.css" />
  31. <link rel="shortcut icon" type="image/png" href="img/favicon.png" />
  32. <link rel="icon" sizes="192x192" href="img/favicon_hires.png">
  33. <link rel="manifest" href="manifest.json">
  34. <meta name="mobile-web-app-capable" content="yes">
  35. <script src="js/index.js"></script>
  36. <script src="js/common.js"></script>
  37. </head>
  38. <body>
  39. <div class="navbar navbar-default navbar-static-top">
  40. <div class="container">
  41. <div class="navbar-header">
  42. <span class="navbar-brand"><a href="?">The Epube</a></span>
  43. </div>
  44. </div>
  45. </div>
  46. <div class="container">
  47. <form method="post">
  48. <input type="hidden" name="op" value="perform-login">
  49. <div class="form-group">
  50. <label>User</label>
  51. <input class="form-control" required="true" name="user">
  52. </div>
  53. <div class="form-group">
  54. <label>Password</label>
  55. <input type="password" class="form-control" name="password" required="true">
  56. </div>
  57. <button type="submit" class="btn btn-default">Log in</button>
  58. </form>
  59. </div>
  60. </body>
  61. </html>