]> git.mxchange.org Git - friendica.git/blobdiff - mod/wall_upload.php
Fix travis services entry
[friendica.git] / mod / wall_upload.php
index 2f92b2f03cde260121aab3f85bfa71434948d588..ad0b5d3c0b9a0ae04546bf5027cbd44c78c16950 100644 (file)
@@ -1,15 +1,31 @@
 <?php
 /**
- * @file mod/wall_upload.php
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
  * Module for uploading a picture to the profile wall
  *
  * By default the picture will be stored in the photo album with the name Wall Photos.
  * You can specify a different album by adding an optional query string "album="
  * to the url
+ *
  */
 
 use Friendica\App;
-use Friendica\Core\Config;
 use Friendica\Core\Logger;
 use Friendica\Core\Session;
 use Friendica\Database\DBA;
@@ -25,7 +41,7 @@ function wall_upload_post(App $a, $desktopmode = true)
        Logger::log("wall upload: starting new upload", Logger::DEBUG);
 
        $r_json = (!empty($_GET['response']) && $_GET['response'] == 'json');
-       $album = (!empty($_GET['album']) ? Strings::escapeTags(trim($_GET['album'])) : '');
+       $album = trim($_GET['album'] ?? '');
 
        if ($a->argc > 1) {
                if (empty($_FILES['media'])) {
@@ -158,28 +174,12 @@ function wall_upload_post(App $a, $desktopmode = true)
                exit();
        }
 
-       // This is a special treatment for picture upload from Twidere
-       if (($filename == "octet-stream") && ($filetype != "")) {
-               $filename = $filetype;
-               $filetype = "";
-       }
-
-       if ($filetype == "") {
-               $filetype = Images::guessType($filename);
-       }
-
-       // If there is a temp name, then do a manual check
-       // This is more reliable than the provided value
-
-       $imagedata = getimagesize($src);
-       if ($imagedata) {
-               $filetype = $imagedata['mime'];
-       }
+       $filetype = Images::getMimeTypeBySource($src, $filename, $filetype);
 
        Logger::log("File upload src: " . $src . " - filename: " . $filename .
                " - size: " . $filesize . " - type: " . $filetype, Logger::DEBUG);
 
-       $maximagesize = Config::get('system', 'maximagesize');
+       $maximagesize = DI::config()->get('system', 'maximagesize');
 
        if (($maximagesize) && ($filesize > $maximagesize)) {
                $msg = DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize));
@@ -209,7 +209,7 @@ function wall_upload_post(App $a, $desktopmode = true)
        $Image->orient($src);
        @unlink($src);
 
-       $max_length = Config::get('system', 'max_image_length');
+       $max_length = DI::config()->get('system', 'max_image_length');
        if (!$max_length) {
                $max_length = MAX_IMAGE_LENGTH;
        }