@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Saito - The Threaded Web Forum |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | Router::plugin( |
| 7 | 7 | 'ImageUploader', |
| 8 | 8 | ['path' => '/api/v2'], |
| 9 | - function (RouteBuilder $routes) { |
|
| 9 | + function(RouteBuilder $routes) { |
|
| 10 | 10 | $routes->get( |
| 11 | 11 | '/uploads/thumb/:id', |
| 12 | 12 | ['controller' => 'Thumbnail', 'action' => 'thumb'], |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Saito - The Threaded Web Forum |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Saito - The Threaded Web Forum |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Saito - The Threaded Web Forum |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | 'id' => $image->get('id'), |
| 41 | 41 | 'name' => $image->get('name'), |
| 42 | 42 | 'url' => $this->Url->assetUrl( |
| 43 | - 'useruploads/' . $image->get('name'), |
|
| 43 | + 'useruploads/'.$image->get('name'), |
|
| 44 | 44 | ['fullBase' => true] |
| 45 | 45 | ), |
| 46 | 46 | 'thumbnail_url' => $this->Url->build( |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Saito - The Threaded Web Forum |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | } |
| 58 | 58 | $data = [ |
| 59 | 59 | 'document' => $submitted, |
| 60 | - 'name' => $this->CurrentUser->getId() . '_' . $submitted['name'], |
|
| 60 | + 'name' => $this->CurrentUser->getId().'_'.$submitted['name'], |
|
| 61 | 61 | 'size' => $submitted['size'], |
| 62 | 62 | 'type' => $submitted['type'], |
| 63 | 63 | 'user_id' => $this->CurrentUser->getId(), |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | throw new GenericApiException($msg); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - Cache::delete((string)$imageId, 'uploadsThumbnails'); |
|
| 97 | + Cache::delete((string) $imageId, 'uploadsThumbnails'); |
|
| 98 | 98 | |
| 99 | 99 | $this->autoRender = false; |
| 100 | 100 | $this->response = $this->response->withStatus(204); |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Saito - The Threaded Web Forum |
@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function thumb(): Response |
| 36 | 36 | { |
| 37 | - $id = (int)$this->request->getParam('id'); |
|
| 38 | - ['hash' => $fingerprint, 'type' => $type, 'raw' => $raw] = Cache::remember((string)$id, function () use ($id) { |
|
| 37 | + $id = (int) $this->request->getParam('id'); |
|
| 38 | + ['hash' => $fingerprint, 'type' => $type, 'raw' => $raw] = Cache::remember((string) $id, function() use ($id) { |
|
| 39 | 39 | $Uploads = $this->loadModel('ImageUploader.Uploads'); |
| 40 | 40 | $document = $Uploads->get($id); |
| 41 | 41 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | return compact('hash', 'raw', 'type'); |
| 55 | 55 | }, 'uploadsThumbnails'); |
| 56 | 56 | |
| 57 | - $hash = (string)$this->request->getQuery('h'); |
|
| 57 | + $hash = (string) $this->request->getQuery('h'); |
|
| 58 | 58 | if ($hash !== $fingerprint) { |
| 59 | 59 | throw new SaitoForbiddenException( |
| 60 | 60 | "Attempt to access image-thumbnail $id." |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Saito - The Threaded Web Forum |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | $ext = array_pop($parts); |
| 38 | - $text = Text::slug(implode('.', $parts), '_') . '.' . $ext; |
|
| 38 | + $text = Text::slug(implode('.', $parts), '_').'.'.$ext; |
|
| 39 | 39 | |
| 40 | 40 | return $text; |
| 41 | 41 | } |
@@ -47,8 +47,8 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | public function _getFile(): File |
| 49 | 49 | { |
| 50 | - $folderPath = rtrim(Configure::read('Saito.Settings.uploadDirectory'), DS) . DS; |
|
| 51 | - return new File($folderPath . $this->get('name')); |
|
| 50 | + $folderPath = rtrim(Configure::read('Saito.Settings.uploadDirectory'), DS).DS; |
|
| 51 | + return new File($folderPath.$this->get('name')); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Saito - The Threaded Web Forum |
@@ -51,12 +51,12 @@ discard block |
||
| 51 | 51 | ->notBlank('user_id') |
| 52 | 52 | ->requirePresence(['name', 'size', 'type', 'user_id'], 'create'); |
| 53 | 53 | |
| 54 | - $maxUploadSize = (int)Configure::read('Saito.Settings.upload_max_img_size'); |
|
| 54 | + $maxUploadSize = (int) Configure::read('Saito.Settings.upload_max_img_size'); |
|
| 55 | 55 | $validator->add( |
| 56 | 56 | 'document', |
| 57 | 57 | [ |
| 58 | 58 | 'fileSize' => [ |
| 59 | - 'rule' => ['fileSize', '<', $maxUploadSize . 'kB'], |
|
| 59 | + 'rule' => ['fileSize', '<', $maxUploadSize.'kB'], |
|
| 60 | 60 | 'message' => __d( |
| 61 | 61 | 'image_uploader', |
| 62 | 62 | 'validation.error.fileSize', |
@@ -83,9 +83,9 @@ discard block |
||
| 83 | 83 | public function buildRules(RulesChecker $rules) |
| 84 | 84 | { |
| 85 | 85 | // check max allowed number of uploads per user |
| 86 | - $nMax = (int)Configure::read('Saito.Settings.upload_max_number_of_uploads'); |
|
| 86 | + $nMax = (int) Configure::read('Saito.Settings.upload_max_number_of_uploads'); |
|
| 87 | 87 | $rules->add( |
| 88 | - function (Upload $entity, array $options) use ($nMax) { |
|
| 88 | + function(Upload $entity, array $options) use ($nMax) { |
|
| 89 | 89 | $count = $this->findByUserId($entity->get('user_id'))->count(); |
| 90 | 90 | |
| 91 | 91 | return $count < $nMax; |
@@ -205,8 +205,8 @@ discard block |
||
| 205 | 205 | $ratio = $size / $target; |
| 206 | 206 | $ratio = sqrt($ratio); |
| 207 | 207 | |
| 208 | - $newwidth = (int)($width / $ratio); |
|
| 209 | - $newheight = (int)($height / $ratio); |
|
| 208 | + $newwidth = (int) ($width / $ratio); |
|
| 209 | + $newheight = (int) ($height / $ratio); |
|
| 210 | 210 | $destination = imagecreatetruecolor($newwidth, $newheight); |
| 211 | 211 | |
| 212 | 212 | $source = imagecreatefromstring($raw); |