From 83714213f2e9258f206c3cf247ea47b13ce9dd2a Mon Sep 17 00:00:00 2001 From: celestora Date: Sun, 11 Dec 2022 18:21:01 +0200 Subject: [PATCH] Use only attachPic for grabbing pic attachments TODO throw flashFail on bruh moment with pic attachments --- Web/Presenters/WallPresenter.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Web/Presenters/WallPresenter.php b/Web/Presenters/WallPresenter.php index fb7d26b6..6013db37 100644 --- a/Web/Presenters/WallPresenter.php +++ b/Web/Presenters/WallPresenter.php @@ -257,18 +257,17 @@ final class WallPresenter extends OpenVKPresenter $photo = Photo::fastMake($this->user->id, $this->postParam("text"), $_FILES["_pic_attachment"], $album, $anon); } */ - foreach($_FILES as $file) { - bdump($file); - if($file["error"] === UPLOAD_ERR_OK && preg_match('/^image\//', $file['type'])) { - $album = NULL; - if(!$anon && $wall > 0 && $wall === $this->user->id) - $album = (new Albums)->getUserWallAlbum($wallOwner); + $album = NULL; + if(!$anon && $wall > 0 && $wall === $this->user->id) + $album = (new Albums)->getUserWallAlbum($wallOwner); - $photos[] = Photo::fastMake($this->user->id, $this->postParam("text"), $file, $album, $anon); - } + foreach($_FILES as $fileId => $file) { + bdump([$fileId, $file, $file["error"] !== UPLOAD_ERR_OK, strncmp($fileId, "attachPic", 9) !== 0]); + if($file["error"] !== UPLOAD_ERR_OK || strncmp($fileId, "attachPic", 9) !== 0) + continue; + + $photos[] = Photo::fastMake($this->user->id, $this->postParam("text"), $file, $album, $anon); } - - bdump($photos); if($_FILES["_vid_attachment"]["error"] === UPLOAD_ERR_OK) $video = Video::fastMake($this->user->id, $this->postParam("text"), $_FILES["_vid_attachment"], $anon);