]> git.mxchange.org Git - friendica.git/blobdiff - mod/wall_upload.php
Merge pull request #12029 from annando/warning
[friendica.git] / mod / wall_upload.php
index 36e313cecef2e4fd5b60bee68ee1eac1c5e0ef5e..efea196fdc3a3681e11d9b033846cca82047a290 100644 (file)
@@ -88,7 +88,7 @@ function wall_upload_post(App $a, $desktopmode = true)
                if ($r_json) {
                        System::jsonExit(['error' => DI::l10n()->t('Permission denied.')]);
                }
-               notice(DI::l10n()->t('Permission denied.'));
+               DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
                System::exit();
        }
 
@@ -147,7 +147,7 @@ function wall_upload_post(App $a, $desktopmode = true)
                if ($r_json) {
                        System::jsonExit(['error' => DI::l10n()->t('Invalid request.')]);
                }
-               notice(DI::l10n()->t('Invalid request.'));
+               DI::sysmsg()->addNotice(DI::l10n()->t('Invalid request.'));
                System::exit();
        }
 
@@ -157,31 +157,31 @@ function wall_upload_post(App $a, $desktopmode = true)
                " - size: " . $filesize . " - type: " . $filetype);
 
        $imagedata = @file_get_contents($src);
-       $Image = new Image($imagedata, $filetype);
+       $image = new Image($imagedata, $filetype);
 
-       if (!$Image->isValid()) {
+       if (!$image->isValid()) {
                $msg = DI::l10n()->t('Unable to process image.');
                @unlink($src);
                if ($r_json) {
                        System::jsonExit(['error' => $msg]);
                } else {
-                       echo  $msg. EOL;
+                       echo  $msg . '<br />';
                }
                System::exit();
        }
 
-       $Image->orient($src);
+       $image->orient($src);
        @unlink($src);
 
        $max_length = DI::config()->get('system', 'max_image_length');
        if ($max_length > 0) {
-               $Image->scaleDown($max_length);
-               $filesize = strlen($Image->asString());
+               $image->scaleDown($max_length);
+               $filesize = strlen($image->asString());
                Logger::info("File upload: Scaling picture to new size " . $max_length);
        }
 
-       $width = $Image->getWidth();
-       $height = $Image->getHeight();
+       $width = $image->getWidth();
+       $height = $image->getHeight();
 
        $maximagesize = DI::config()->get('system', 'maximagesize');
 
@@ -190,10 +190,10 @@ function wall_upload_post(App $a, $desktopmode = true)
                foreach ([5120, 2560, 1280, 640] as $pixels) {
                        if (($filesize > $maximagesize) && (max($width, $height) > $pixels)) {
                                Logger::info('Resize', ['size' => $filesize, 'width' => $width, 'height' => $height, 'max' => $maximagesize, 'pixels' => $pixels]);
-                               $Image->scaleDown($pixels);
-                               $filesize = strlen($Image->asString());
-                               $width = $Image->getWidth();
-                               $height = $Image->getHeight();
+                               $image->scaleDown($pixels);
+                               $filesize = strlen($image->asString());
+                               $width = $image->getWidth();
+                               $height = $image->getHeight();
                        }
                }
                if ($filesize > $maximagesize) {
@@ -203,7 +203,7 @@ function wall_upload_post(App $a, $desktopmode = true)
                        if ($r_json) {
                                System::jsonExit(['error' => $msg]);
                        } else {
-                               echo  $msg. EOL;
+                               echo  $msg . '<br />';
                        }
                        System::exit();
                }
@@ -220,29 +220,29 @@ function wall_upload_post(App $a, $desktopmode = true)
 
        $defperm = '<' . $default_cid . '>';
 
-       $r = Photo::store($Image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 0, Photo::DEFAULT, $defperm);
+       $r = Photo::store($image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 0, Photo::DEFAULT, $defperm);
 
        if (!$r) {
                $msg = DI::l10n()->t('Image upload failed.');
                if ($r_json) {
                        System::jsonExit(['error' => $msg]);
                } else {
-                       echo  $msg. EOL;
+                       echo  $msg . '<br />';
                }
                System::exit();
        }
 
        if ($width > 640 || $height > 640) {
-               $Image->scaleDown(640);
-               $r = Photo::store($Image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 1, Photo::DEFAULT, $defperm);
+               $image->scaleDown(640);
+               $r = Photo::store($image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 1, Photo::DEFAULT, $defperm);
                if ($r) {
                        $smallest = 1;
                }
        }
 
        if ($width > 320 || $height > 320) {
-               $Image->scaleDown(320);
-               $r = Photo::store($Image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 2, Photo::DEFAULT, $defperm);
+               $image->scaleDown(320);
+               $r = Photo::store($image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 2, Photo::DEFAULT, $defperm);
                if ($r && ($smallest == 0)) {
                        $smallest = 2;
                }
@@ -264,8 +264,8 @@ function wall_upload_post(App $a, $desktopmode = true)
                $picture["height"]    = $photo["height"];
                $picture["type"]      = $photo["type"];
                $picture["albumpage"] = DI::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $resource_id;
-               $picture["picture"]   = DI::baseUrl() . "/photo/{$resource_id}-0." . $Image->getExt();
-               $picture["preview"]   = DI::baseUrl() . "/photo/{$resource_id}-{$smallest}." . $Image->getExt();
+               $picture["picture"]   = DI::baseUrl() . "/photo/{$resource_id}-0." . $image->getExt();
+               $picture["preview"]   = DI::baseUrl() . "/photo/{$resource_id}-{$smallest}." . $image->getExt();
 
                if ($r_json) {
                        System::jsonExit(['picture' => $picture]);
@@ -280,7 +280,7 @@ function wall_upload_post(App $a, $desktopmode = true)
                System::jsonExit(['ok' => true]);
        }
 
-       echo  "\n\n" . '[url=' . DI::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $resource_id . '][img]' . DI::baseUrl() . "/photo/{$resource_id}-{$smallest}.".$Image->getExt()."[/img][/url]\n\n";
+       echo  "\n\n" . '[url=' . DI::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $resource_id . '][img]' . DI::baseUrl() . "/photo/{$resource_id}-{$smallest}." . $image->getExt() . "[/img][/url]\n\n";
        System::exit();
        // NOTREACHED
 }