]> git.mxchange.org Git - friendica.git/blobdiff - mod/wall_upload.php
Remove album name bin2hex conversion in file browser
[friendica.git] / mod / wall_upload.php
index b7504bede1f3740c92318de157c9e793f04783a2..ad0b5d3c0b9a0ae04546bf5027cbd44c78c16950 100644 (file)
@@ -1,11 +1,28 @@
 <?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;
@@ -24,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'])) {
@@ -157,23 +174,7 @@ 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);