login.php 2.3 KB

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