|
|
@@ -18,32 +18,29 @@ if($submit) {
|
|
|
$id_document = (object) $_FILES["id_document"];
|
|
|
$photo = (object) $_FILES["photo"];
|
|
|
|
|
|
- if($id_document->error != UPLOAD_ERR_OK) $form_exception->addError(HTTP::getUploadErrorString($id_document->error));
|
|
|
- if($photo->error != UPLOAD_ERR_OK) $form_exception->addError(HTTP::getUploadErrorString($photo->error));
|
|
|
+ if($id_document->error !== UPLOAD_ERR_OK) $form_exception->addError(HTTP::getUploadErrorString($id_document->error));
|
|
|
+ if($photo->error !== UPLOAD_ERR_OK) $form_exception->addError(HTTP::getUploadErrorString($photo->error));
|
|
|
|
|
|
$size = @getimagesize($id_document->tmp_name);
|
|
|
if(!$size) $form_exception->addError(__("The uploaded ID document is not an image."));
|
|
|
- list($width, $height, $type) = $size;
|
|
|
- if($type != IMAGETYPE_JPEG) $form_exception->addError(__("The uploaded ID document is not a JPEG."));
|
|
|
+ [$width, $height, $type] = $size;
|
|
|
+ if($type !== IMAGETYPE_JPEG) $form_exception->addError(__("The uploaded ID document is not a JPEG."));
|
|
|
|
|
|
$size = @getimagesize($photo->tmp_name);
|
|
|
if(!$size) $form_exception->addError(__("The uploaded photo is not an image."));
|
|
|
- list($width, $height, $type) = $size;
|
|
|
- if($type != IMAGETYPE_JPEG) $form_exception->addError(__("The uploaded photo is not a JPEG."));
|
|
|
+ [$width, $height, $type] = $size;
|
|
|
+ if($type !== IMAGETYPE_JPEG) $form_exception->addError(__("The uploaded photo is not a JPEG."));
|
|
|
|
|
|
if($form_exception->hasErrors()) throw $form_exception;
|
|
|
|
|
|
- $files = [$id_document, $photo];
|
|
|
- foreach($files as $index => $file) {
|
|
|
+ $files = [
|
|
|
+ ["file" => $id_document, "name" => "ID document", "type" => UserFile::TYPE_ID],
|
|
|
+ ["file" => $photo, "name" => "photo", "type" => UserFile::TYPE_PHOTO],
|
|
|
+ ];
|
|
|
|
|
|
- if($index == 0) {
|
|
|
- $name = "ID document";
|
|
|
- $type = UserFile::TYPE_ID;
|
|
|
- }
|
|
|
- if($index == 1) {
|
|
|
- $name = "photo";
|
|
|
- $type = UserFile::TYPE_PHOTO;
|
|
|
- }
|
|
|
+ foreach($files as $file_info) {
|
|
|
+
|
|
|
+ ["file" => $file, "name" => $name, "type" => $type] = $file_info;
|
|
|
|
|
|
$output_image = Image::normalise($file->tmp_name);
|
|
|
|
|
|
@@ -57,8 +54,10 @@ if($submit) {
|
|
|
|
|
|
$output_path = $user->getDirectory() . "/" . $user_file->id . ".jpg";
|
|
|
|
|
|
- imagejpeg($output_image, $output_path, 60);
|
|
|
+ $success = imagejpeg($output_image, $output_path, 60);
|
|
|
imagedestroy($output_image);
|
|
|
+
|
|
|
+ if(!$success) throw new Exception(__("Failed to save %s.", $name));
|
|
|
}
|
|
|
|
|
|
$user->level = User::LEVEL_UNVERIFIED;
|
|
|
@@ -81,5 +80,3 @@ if($submit) {
|
|
|
View::includeOnce("header", compact("page_title"));
|
|
|
View::include("submit_id");
|
|
|
View::includeOnce("footer");
|
|
|
-
|
|
|
-?>
|