cert-enroll.php 890 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. require('config.php');
  3. $db = new PDO($osu_db);
  4. if (!$db) {
  5. die($sqliteerror);
  6. }
  7. if (isset($_GET["id"]))
  8. $id = preg_replace("/[^a-fA-F0-9]/", "", $_GET["id"]);
  9. else
  10. die("Missing session id");
  11. if (strlen($id) < 32)
  12. die("Invalid session id");
  13. $row = $db->query("SELECT rowid,* FROM sessions WHERE id='$id'")->fetch();
  14. if ($row == false) {
  15. die("Session not found");
  16. }
  17. $uri = $row['redirect_uri'];
  18. $rowid = $row['rowid'];
  19. $realm = $row['realm'];
  20. $user = sha1(mt_rand());
  21. if (!$db->exec("UPDATE sessions SET user='$user', type='cert' WHERE rowid=$rowid")) {
  22. die("Failed to update session database");
  23. }
  24. $db->exec("INSERT INTO eventlog(user,realm,sessionid,timestamp,notes) " .
  25. "VALUES ('', '$realm', '$id', " .
  26. "strftime('%Y-%m-%d %H:%M:%f','now'), " .
  27. "'completed user input response for client certificate enrollment')");
  28. header("Location: $uri", true, 302);
  29. ?>