e107inc/e107

View on GitHub
e107_handlers/upload_handler.php

Summary

Maintainability
A
3 hrs
Test Coverage
F
2%

Avoid deeply nested control flow statements.
Open

                        if (UH_DEBUG)
                        {
                            e107::getLog()->addEvent(10, __FILE__."|".__FUNCTION__."@".__LINE__, "DEBUG", "Upload Handler test", "Move {$tempfilename} to {$uploadfile} ", FALSE, LOG_TO_ROLLING);
                        }
Severity: Major
Found in e107_handlers/upload_handler.php - About 45 mins to fix

    Avoid too many return statements within this method.
    Open

                    return 9; // Never accept these! Whatever the user thinks!
    Severity: Major
    Found in e107_handlers/upload_handler.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                          return 4; // exif_imagetype didn't recognize the image mime
      Severity: Major
      Found in e107_handlers/upload_handler.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                return array(); // Just an empty array
        Severity: Major
        Found in e107_handlers/upload_handler.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                              return ($unknown ? true : 8);
          Severity: Major
          Found in e107_handlers/upload_handler.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return true; // Accepted here
            Severity: Major
            Found in e107_handlers/upload_handler.php - About 30 mins to fix

              Argument 7 (target_logs) is false but \e_admin_log::addEvent() takes int defined at /code/e107_handlers/admin_log_class.php:237
              Open

                              addEvent(10, __FILE__."|".__FUNCTION__."@".__LINE__, "DEBUG", "Upload Handler test", "Final max upload size: {$max_upload_size}", FALSE, FALSE);
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Argument 7 (target_logs) is false but \e_admin_log::addEvent() takes int defined at /code/e107_handlers/admin_log_class.php:237
              Open

                          addEvent(10, __FILE__."|".__FUNCTION__."@".__LINE__, "DEBUG", "Upload Handler test", "Legacy call, directory ".$uploaddir, FALSE, FALSE);
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Argument 7 (target_logs) is false but \e_admin_log::addEvent() takes int defined at /code/e107_handlers/admin_log_class.php:237
              Open

                              addEvent(10, __FILE__."|".__FUNCTION__."@".__LINE__, "DEBUG", "Upload Handler test", "Legacy return FALSE", FALSE, FALSE);
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Call to deprecated function \get_XML_filetypes() defined at /code/e107_handlers/upload_handler.php:799
              Open

                              return get_XML_filetypes($filename, $file_mask);
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Default value for string $fileinfo can't be false
              Open

              function process_uploaded_files($uploaddir, $fileinfo = FALSE, $options = NULL)
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Argument 1 (source) is int but \file_size_decode() takes string defined at /code/e107_handlers/upload_handler.php:782
              Open

                          $max_upload_size = file_size_decode($max_up, $max_upload_size, 'lt');
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Suspicious array access to nullable ?array
              Open

                  $max_file_count = varset($options['max_file_count'], 0);
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Argument 1 (filename) is ?'Unknowm mime-type'|?int|?string but \vet_file() takes string defined at /code/e107_handlers/upload_handler.php:593
              Open

                                  $tpos = (($file_status = vet_file($uploadfile, $name, $allowed_filetypes, varset($options['extra_file_types'], FALSE))) === TRUE);
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Default value for string $def_file can't be false
              Open

                  function get_XML_filetypes($def_file = FALSE, $file_mask = '')
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Argument 7 (target_logs) is false but \e_admin_log::addEvent() takes int defined at /code/e107_handlers/admin_log_class.php:237
              Open

                              e107::getLog()->addEvent(10, __FILE__."|".__FUNCTION__."@".__LINE__, "DEBUG", "Upload Handler test", "Process file {$name}, size ".$files['size'][$key], FALSE, FALSE);
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Argument 1 (haystack) is false but \strpos() takes string
              Open

                              if (strpos($fileinfo, "attachment") === 0)
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Argument 1 (filename) is ?'Unknowm mime-type'|?int|?string but \unlink() takes string
              Open

                              @unlink($uploadfile); // Don't leave the file on the server if error (although should be auto-deleted)
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Default value for string $def_file can't be false
              Open

                  function get_allowed_filetypes($def_file = FALSE, $file_mask = '')
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Suspicious array access to nullable ?array
              Open

                  $max_upload_size     = calc_max_upload_size(varset($options['max_upload_size'], -1)); // Find overriding maximum upload size
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Argument 2 (str) is false but \explode() takes string
              Open

                                  $addbit = explode('+', $fileinfo, 2);
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Argument 1 (path) is ?'Unknowm mime-type'|?int|?string but \basename() takes string
              Open

                                      $uploadfile = $ul_temp_dir.basename($uploadfile);
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Argument 1 (path_to_file) is ?'Unknowm mime-type'|?int|?string but \e_file::getFileInfo() takes string defined at /code/e107_handlers/file_class.php:466
              Open

                              $uploaded[$c] = e107::getFile()->getFileInfo($uploadfile, true, false);
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Argument 7 (target_logs) is false but \e_admin_log::addEvent() takes int defined at /code/e107_handlers/admin_log_class.php:237
              Open

                                  e107::getLog()->addEvent(10, __FILE__."|".__FUNCTION__."@".__LINE__, "DEBUG", "Upload Handler test", "Main routine error {$first_error} file {$c}: ".$uploaded[$c]['message'], FALSE, FALSE);
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Call to deprecated function \get_XML_filetypes() defined at /code/e107_handlers/upload_handler.php:799
              Open

                          return get_XML_filetypes(e_READ_FILETYPES, $file_mask);
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Default value for array $allowed_filetypes can't be string
              Open

                  function vet_file($filename, $target_name, $allowed_filetypes = '', $unknown = false)
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Argument 7 (target_logs) is false but \e_admin_log::addEvent() takes int defined at /code/e107_handlers/admin_log_class.php:237
              Open

                          e107::getLog()->addEvent(10, __FILE__."|".__FUNCTION__."@".__LINE__, "DEBUG", "Upload Handler test", "No files uploaded", FALSE, FALSE);
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Suspicious array access to nullable ?array
              Open

                  $allowed_filetypes     = get_filetypes(varset($options['file_mask'], ''), varset($options['filetypes'], ''));
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Argument 1 (haystack) is bool|false but \strpos() takes string
              Open

                  if (strpos($avatar, '=') !== FALSE)
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Argument 7 (target_logs) is false but \e_admin_log::addEvent() takes int defined at /code/e107_handlers/admin_log_class.php:237
              Open

                          addEvent(10, __FILE__."|".__FUNCTION__."@".__LINE__, "DEBUG", "Upload Handler test", "Legacy return with ".count($ret)." files", FALSE, FALSE);
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Argument 1 (haystack) is false but \strpos() takes string
              Open

                              elseif (strpos($fileinfo, "prefix") === 0)
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Argument 2 (str) is bool|false but \explode() takes string
              Open

                      list($avatar, $param) = explode('=', $avatar, 2);
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Argument 2 (str) is false but \explode() takes string
              Open

                                  $addbit = explode('+', $fileinfo, 2);
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Argument 1 (old_name) is ?'Unknowm mime-type'|?int|?string but \rename() takes string
              Open

                              if ((!$ul_temp_dir && @move_uploaded_file($uploadfile, $destination_file)) || ($ul_temp_dir && @rename($uploadfile, $destination_file))) // This should work on all hosts
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Suspicious array access to nullable ?array
              Open

                                  $tpos = (($file_status = vet_file($uploadfile, $name, $allowed_filetypes, varset($options['extra_file_types'], FALSE))) === TRUE);
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Argument 7 (target_logs) is false but \e_admin_log::addEvent() takes int defined at /code/e107_handlers/admin_log_class.php:237
              Open

                                      e107::getLog()->addEvent(10, __FILE__."|".__FUNCTION__."@".__LINE__, "DEBUG", "Upload Handler test", "Final chmod() file {$destination_file} to {$final_chmod} ", FALSE, FALSE);
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Argument 7 (target_logs) is false but \e_admin_log::addEvent() takes int defined at /code/e107_handlers/admin_log_class.php:237
              Open

                                      e107::getLog()->addEvent(10, __FILE__."|".__FUNCTION__."@".__LINE__, "DEBUG", "Upload Handler test", "Saved file {$c} OK: ".$uploaded[$c]['name'], FALSE, FALSE);
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Argument 1 (path) is ?'Unknowm mime-type'|?int|?string but \move_uploaded_file() takes string
              Open

                                      @move_uploaded_file($tempfilename, $uploadfile); // This should work on all hosts
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Argument 1 (filename) is ?'Unknowm mime-type'|?int|?string but \is_file() takes string
              Open

                          if (is_file($uploadfile))
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Suspicious type false of a variable or expression used to build a string. (Expected type to be able to cast to a string)
              Open

                      e107::getLog()->addEvent(10, debug_backtrace(), "DEBUG", "Upload Handler test", "Process uploads to {$uploaddir}, fileinfo  ".$fileinfo, FALSE, LOG_TO_ROLLING);
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Argument 1 (path) is ?'Unknowm mime-type'|?int|?string but \move_uploaded_file() takes string
              Open

                              if ((!$ul_temp_dir && @move_uploaded_file($uploadfile, $destination_file)) || ($ul_temp_dir && @rename($uploadfile, $destination_file))) // This should work on all hosts
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Argument 7 (target_logs) is false but \e_admin_log::addEvent() takes int defined at /code/e107_handlers/admin_log_class.php:237
              Open

                              addEvent(10, __FILE__."|".__FUNCTION__."@".__LINE__, "DEBUG", "Upload Handler test", "File size limits - user set: ".$pref['upload_maxfilesize']." Post_max_size: ".ini_get('post_max_size')." upload_max_size: ".ini_get('upload_max_size'), FALSE, FALSE);
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Call to deprecated function \get_image_mime() defined at /code/e107_handlers/upload_handler.php:562
              Open

                              $ret = get_image_mime($filename);
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Default value for string $file_mask can't be false
              Open

                  function get_filetypes($file_mask = FALSE, $filename = '')
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              Argument 1 (str) is bool but \strtolower() takes string
              Open

                          if (strtolower(substr($filename, -4) == '.xml'))
              Severity: Minor
              Found in e107_handlers/upload_handler.php by phan

              There are no issues that match your filters.

              Category
              Status