e107inc/e107

View on GitHub
e107_handlers/file_class.php

Summary

Maintainability
B
6 hrs
Test Coverage
D
62%

Consider simplifying this complex logical expression.
Open

            if(($file != '.') && ($file != '..') && !in_array($file, $this->dirFilter) && !in_array($file, $omit) && is_dir($path . '/' . $file) && ($fmask == '' || preg_match("#" . $fmask . "#", $file)))
            {
                $ret[] = $file;
            }
Severity: Major
Found in e107_handlers/file_class.php - About 1 hr to fix

    Avoid deeply nested control flow statements.
    Open

                            if(!unlink($dir . $obj))
                            {
                                return false;
                            }
    Severity: Major
    Found in e107_handlers/file_class.php - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if(rename($path_to_file, $newFile) === true)
                              {
                                  $finfo['pathinfo'] = pathinfo($newFile);
                                  $path_to_file = $newFile;
                              }
      Severity: Major
      Found in e107_handlers/file_class.php - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if(!$this->rmtree($dir . $obj))
                                {
                                    return false;
                                }
        Severity: Major
        Found in e107_handlers/file_class.php - About 45 mins to fix

          Avoid too many return statements within this method.
          Open

                          return false;
          Severity: Major
          Found in e107_handlers/file_class.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return false;
            Severity: Major
            Found in e107_handlers/file_class.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return $fileContents;
              Severity: Major
              Found in e107_handlers/file_class.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return false;
                Severity: Major
                Found in e107_handlers/file_class.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return round($size / $tb, 2) . " " . CORE_LAN_TB;
                  Severity: Major
                  Found in e107_handlers/file_class.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/file_class.php - About 30 mins to fix

                      Argument 1 (ch) is \CurlHandle|false but \curl_setopt() takes resource
                      Open

                              curl_setopt($cp, CURLOPT_TIMEOUT, $timeout);
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Default value for string $opts can't be array{}
                      Open

                          function send($file, $opts = array())
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Returning type string but getErrorMessage() is declared to return null
                      Open

                              return $this->error;
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Reference to undeclared constant \PCLZIP_OPT_PATH
                      Open

                              $unarc = ($fileList = $archive->extract(PCLZIP_OPT_PATH, e_TEMP, PCLZIP_OPT_SET_CHMOD, 0755)); // Store in TEMP first.
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Returning type false but getMime() is declared to return string
                      Open

                                  return false;
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Call to method file from undeclared class \finfo
                      Open

                                      list($mime, $other) = explode(";", $fin->file($path_to_file));
                      Severity: Critical
                      Found in e107_handlers/file_class.php by phan

                      Argument 1 (ch) is \CurlHandle|false but \curl_close() takes resource
                      Open

                              curl_close($cp);
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Argument 1 (ch) is \CurlHandle|false but \curl_exec() takes resource
                      Open

                              $buffer = curl_exec($cp);
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Returning type false but unzipArchive() is declared to return string
                      Open

                                      return false;
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Call to method __construct from undeclared class \PclZip
                      Open

                              $archive = new PclZip(e_TEMP . $localfile);
                      Severity: Critical
                      Found in e107_handlers/file_class.php by phan

                      Call to method extract from undeclared class \PclZip
                      Open

                              $unarc = ($fileList = $archive->extract(PCLZIP_OPT_PATH, e_TEMP, PCLZIP_OPT_SET_CHMOD, 0755)); // Store in TEMP first.
                      Severity: Critical
                      Found in e107_handlers/file_class.php by phan

                      Reference to undeclared constant \PCLZIP_OPT_SET_CHMOD
                      Open

                              $unarc = ($fileList = $archive->extract(PCLZIP_OPT_PATH, e_TEMP, PCLZIP_OPT_SET_CHMOD, 0755)); // Store in TEMP first.
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Argument 2 (mode) is null but \e_file::mkDir() takes int defined at /code/e107_handlers/file_class.php:2068
                      Open

                                  if(($options & FILE_CREATE_DIRECTORY) && @$this->mkDir($directory, null, true))
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Variable $finfo was undeclared, but array fields are being added to it.
                      Open

                                                          $finfo['path'] = $path . '/';  // important: leave this slash here and update other file instead.
                      Severity: Info
                      Found in e107_handlers/file_class.php by phan

                      Reference to undeclared constant \FILEINFO_MIME
                      Open

                                      $fin = new finfo(FILEINFO_MIME);
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Reference to undeclared constant \e_CURL_PROXYUSERPWD
                      Open

                                  curl_setopt($cu, CURLOPT_PROXYUSERPWD, e_CURL_PROXYUSERPWD);   // Use if proxy have username and password
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Invalid offset "disposition" of array type array{}
                      Open

                                      $contentDisp = vartrue($opts['disposition'], 'attachment');
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Argument 1 (ch) is \CurlHandle|false but \curl_error() takes resource
                      Open

                                      $this->error = "Curl error: " . $errorCode . ", " . curl_error($cu);
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Reference to undeclared constant \e_CURL_PROXYTYPE
                      Open

                                  curl_setopt($cu, CURLOPT_PROXYTYPE, e_CURL_PROXYTYPE); // If expected to cal
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Argument 1 (ch) is \CurlHandle|false but \curl_errno() takes resource
                      Open

                                      $errorCode = curl_errno($cu);
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Variable $current_perms was undeclared, but array fields are being added to it.
                      Open

                                      $current_perms[$v['name']] = array('type' => $v['type'], 'maxupload' => $v['maxupload']);
                      Severity: Info
                      Found in e107_handlers/file_class.php by phan

                      Argument 1 (ch) is \CurlHandle|false but \curl_errno() takes resource
                      Open

                              if(curl_errno($cp)) // Fixes curl_error output - here see #1936
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Reference to undeclared constant \e_CURL_PROXY
                      Open

                                  curl_setopt($cu, CURLOPT_PROXY, e_CURL_PROXY);     // PROXY details with port
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Returning type false but getRemoteContent() is declared to return string
                      Open

                                      return false;
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Returning type false but unzipArchive() is declared to return string
                      Open

                                      return false;
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Argument 1 (ch) is \CurlHandle|false but \curl_error() takes resource
                      Open

                                  error_log('cURL error: ' . curl_error($cp));
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Argument 2 (newvalue) is 5 but \ini_set() takes string
                      Open

                                  $old_timeout = ini_set('default_socket_timeout', $timeout);
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Argument 3 (omit) is array|array<int>|array<int>|array{0:string}</int></int> but \e_file::get_files() takes string defined at /code/e107_handlers/file_class.php:245
                      Open

                                          $xx = $this->get_files($path . '/' . $file, $fmask, $omit, $recurse_level - 1);
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Return type of initCurl() is undeclared type \CurlHandle
                      Open

                          public function initCurl($address, $options = null)
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Returning type false but getRemoteContent() is declared to return string
                      Open

                                  return false;
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Returning type false but getRemoteContent() is declared to return string
                      Open

                                      return false;
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Argument 3 (subject) is null but \str_replace() takes array|string
                      Open

                              $ext = str_replace(",", "|", $extensions);
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Returning type false but unzipArchive() is declared to return string
                      Open

                                  return false;
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Returning type false but unzipArchive() is declared to return string
                      Open

                              return false;
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      string passed to foreach instead of array
                      Open

                              foreach($temp_vars['class'] as $v1)
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Call to method __construct from undeclared class \finfo
                      Open

                                      $fin = new finfo(FILEINFO_MIME);
                      Severity: Critical
                      Found in e107_handlers/file_class.php by phan

                      Argument 1 (ch) is \CurlHandle|false but \curl_exec() takes resource
                      Open

                                  $fileContents = curl_exec($cu);
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Argument 1 (ch) is \CurlHandle|false but \curl_close() takes resource
                      Open

                                  curl_close($cu);
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Call with 2 arg(s) to \user_class::getClassFromKey() which only takes 1 arg(s) defined at /code/e107_handlers/userclass_class.php:122
                      Open

                                      $v['name'] = e107::getUserClass()->getClassFromKey($v['name'], $v['name']); // convert 'admin' etc to numeric equivalent.
                      Severity: Info
                      Found in e107_handlers/file_class.php by phan

                      When fetching an array index from a value of type string, found an array index of type 'class', but expected the index to be of type int
                      Open

                              foreach($temp_vars['class'] as $v1)
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Argument 2 (newvalue) is 600 but \ini_set() takes string
                      Open

                      @ini_set("max_execution_time", 10 * 60);
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Argument 1 (ch) is \CurlHandle|false but \curl_error() takes resource
                      Open

                                  if(curl_error($cu))
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Returning type false but getRemoteContent() is declared to return string
                      Open

                                  return false;
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Argument 2 (newvalue) is 5 but \ini_set() takes string
                      Open

                                  $old_timeout = ini_set('default_socket_timeout', $timeout);
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

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

                          public function getUploaded($uploaddir, $fileinfo = false, $options = array())
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Returning type false but getRemoteContent() is declared to return string
                      Open

                                      return false;
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Argument 1 (ch) is \CurlHandle|false but \curl_setopt() takes resource
                      Open

                              curl_setopt($cp, CURLOPT_FILE, $fp);
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Argument 2 (newvalue) is 600 but \ini_set() takes string
                      Open

                              @ini_set("max_execution_time", 10 * 60);
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Invalid offset "type" of array type array{}
                      Open

                                      $contentType = vartrue($opts['type'], 'application/force-download');
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      Argument 2 (newvalue) is 1 but \ini_set() takes string
                      Open

                              ini_set('default_socket_timeout', 1);
                      Severity: Minor
                      Found in e107_handlers/file_class.php by phan

                      There are no issues that match your filters.

                      Category
                      Status