user_verify_image.php 530 B

123456789101112131415161718192021222324252627
  1. <?php
  2. $user = User::get($id);
  3. if(!$user) throw new Exception("User not found.");
  4. switch($type) {
  5. case "id-document":
  6. $file_type = UserFile::TYPE_ID;
  7. break;
  8. case "photo":
  9. $file_type = UserFile::TYPE_PHOTO;
  10. break;
  11. }
  12. $nvp = [
  13. "user_id" => $id,
  14. "type" => $file_type
  15. ];
  16. $file = UserFile::queryOne($nvp);
  17. if(!$file) HTTP::redirect("/img/blank.png");
  18. $path = $user->getDirectory() . "/" . $file->id . ".jpg";
  19. if(!file_exists($path)) HTTP::redirect("/img/blank.png");
  20. header("Content-Type: image/jpeg");
  21. readfile($path);