login.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. if (session_status() === PHP_SESSION_NONE) session_start();
  3. if (!empty($_SESSION['pl_authed'])) {
  4. header('Location: /index.php');
  5. exit;
  6. }
  7. $error = '';
  8. if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  9. $pw = $_POST['password'] ?? '';
  10. $codes = file_exists(__DIR__ . '/_private/config.php')
  11. ? (require __DIR__ . '/_private/config.php')
  12. : [];
  13. $ok = false;
  14. foreach ($codes as $code) {
  15. if (password_verify($pw, $code['hash'])) { $ok = true; break; }
  16. }
  17. if ($ok) {
  18. session_regenerate_id(true);
  19. $_SESSION['pl_authed'] = true;
  20. $next = $_GET['next'] ?? '/index.php';
  21. // Prevent open redirect — only allow relative paths on this host
  22. if (!preg_match('/^\/[a-zA-Z0-9\/_\-\.]*$/', $next)) $next = '/index.php';
  23. header('Location: ' . $next);
  24. exit;
  25. }
  26. usleep(600000); // throttle brute-force
  27. $error = 'Incorrect password. Please try again.';
  28. }
  29. ?>
  30. <!DOCTYPE html>
  31. <html lang="en">
  32. <head>
  33. <meta charset="UTF-8">
  34. <title>Sign In — ICG Magnetics</title>
  35. <style>
  36. *{box-sizing:border-box;margin:0;padding:0}
  37. html,body{height:100%;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;background:#0f172a;display:flex;align-items:center;justify-content:center}
  38. .card{background:#1e293b;border-radius:12px;padding:40px 44px;width:100%;max-width:380px;box-shadow:0 20px 60px rgba(0,0,0,.5)}
  39. .logo{font-size:13px;font-weight:600;color:#64748b;letter-spacing:.8px;text-transform:uppercase;margin-bottom:6px}
  40. h1{font-size:22px;font-weight:700;color:#f8fafc;margin-bottom:28px}
  41. label{display:block;font-size:12px;font-weight:600;color:#94a3b8;margin-bottom:6px;letter-spacing:.3px}
  42. input[type=password]{
  43. display:block;width:100%;padding:11px 14px;
  44. background:#0f172a;border:1px solid #334155;border-radius:7px;
  45. color:#f1f5f9;font-size:15px;outline:none;
  46. transition:border-color .15s
  47. }
  48. input[type=password]:focus{border-color:#3b82f6}
  49. .err{margin-top:14px;padding:10px 14px;background:#450a0a;border:1px solid #7f1d1d;border-radius:6px;color:#fca5a5;font-size:13px}
  50. button{
  51. margin-top:22px;width:100%;padding:12px;
  52. background:#3b82f6;border:none;border-radius:7px;
  53. color:white;font-size:15px;font-weight:600;cursor:pointer;
  54. transition:background .15s
  55. }
  56. button:hover{background:#2563eb}
  57. </style>
  58. </head>
  59. <body>
  60. <div class="card">
  61. <div class="logo">ICG Magnetics</div>
  62. <h1>Profit &amp; Loss</h1>
  63. <form method="post" autocomplete="off">
  64. <label for="pw">Access Code</label>
  65. <input type="password" id="pw" name="password" autofocus placeholder="Enter access code">
  66. <?php if ($error): ?>
  67. <div class="err"><?= htmlspecialchars($error) ?></div>
  68. <?php endif; ?>
  69. <button type="submit">Sign In</button>
  70. </form>
  71. </div>
  72. </body>
  73. </html>