Smazani souboru
@secured
@param string $fileName
169298
public function handleDelete(string $fileName): void
	{
		if ($this->presenter->isAjax() && $this->editable) {
			$file = $this->getFileInfo($fileName);
			if ($file->isDir) {
				File::removeDir($this->getFullPath($file->name));
			} else {
				unlink($this->getFullPath($file->name));
			}
			$this->redrawControl('fileManagerContainer');
		} else {
			exit;
		}
	}
1219046
public function open($filename)
    {
        if (true === $this->openned) {
            $this->close();
        }
        if (!file_exists(self::TMP_DIR)) {
            mkdir(self::TMP_DIR);
        }
        $this->filename = $filename;
        $this->pclzip = new \PclZip($this->filename);
        $this->openned = true;
        return true;
    }
889416
protected function deleteFile($fileName)
    {
        if (null !== $fileName && $this->mediaStorageManager->exists($fileName)) {
            $this->mediaStorageManager->deleteContent($fileName);
        }
    }
820174
public function attachFile($file, $fileName = null)
    {
        if (gettype($file) == 'resource') {
            $this->file = ['fileName' => $fileName, 'fileContent' => $file];
        } else {
            $this->file = ['fileName' => $fileName, 'fileContent' => fopen($file, 'r')];
        }
    }
1186948
protected function loadFile($name, $filename)
    {
        $file = CompiledYamlFile::instance($filename);
        $this->object->join($name, $file->content(), '/');
        $file->free();
    }
740985
public function tokenize($filename) {
		$this->tokens = array();

		// Read the file
		if (filesize($filename)) {
			$fp = fopen($filename, "rb");
			$this->content = fread($fp, filesize($filename));
			$this->tokens = $this->_getAllTokens($this->content);
			fclose($fp);
		}
	}
991790
public function removeFile($filename)
    {

        if (!$filename) {
            trigger_error(ReporticoLang::templateXlate("UNABLE_TO_REMOVE") . templateXlate("SPECIFYXML"), E_USER_ERROR);
            return false;
        }

        if (!preg_match("/\.xml$/", $filename)) {
            $filename = $filename . ".xml";
        }

        $projdir = $this->query->projects_folder . "/" . ReporticoApp::getConfig("project");
        if (!is_file($projdir)) {
            ReporticoUtility::findFileToInclude($projdir, $projdir);
        }

        if ($projdir && is_dir($projdir)) {
            $fn = $projdir . "/" . $filename;
            if (!is_file($fn)) {
                trigger_error(ReporticoLang::templateXlate("UNABLE_TO_REMOVE") . " $filename  - " . templateXlate("NOFILE"), E_USER_ERROR);
            } else if (!is_writeable($fn)) {
                trigger_error(ReporticoLang::templateXlate("UNABLE_TO_REMOVE") . " $filename  - " . templateXlate("NOWRITE"), E_USER_ERROR);
            } else {
                if (!unlink($fn)) {
                    trigger_error(ReporticoLang::templateXlate("UNABLE_TO_REMOVE") . " $filename  - " . templateXlate("NOWRITE"), E_USER_ERROR);
                } else {
                    ReporticoApp::handleDebug(ReporticoLang::templateXlate("REPORTFILE") . " $filename " . templateXlate("DELETEOKACT"), 0);
                }

            }
        } else {
            trigger_error("Unable to open project area " . ReporticoApp::getConfig("project") . " to save file $filename " .
                $this->query->reports_path . "/" . $filename . " Not Found", E_USER_ERROR);
        }

    }
623748
private function sanitize($filename)
    {
        $filename = preg_replace('/[^A-Za-z0-9\-\._]/', '.', (string) $filename);
        return trim(substr(preg_replace('/[_\.\-]{2,}/', '.', $filename), 0, 40), '._-');
    }
1050048
public function remove($fileName)
    {
        $fileName = $this->getTargetDir() . DIRECTORY_SEPARATOR . $fileName;

        if (!file_exists($fileName)) {
            return;
        }

        unlink($fileName);
    }
1120491
public function open($fileName)
    {
        $this->tempDir = PHPExcel_Shared_File::sys_get_temp_dir();
        $this->zip = new PclZip($fileName);

        return true;
    }
154101
public function saveAsScript(string $filename): void
    {
        $config = clone $this;
        unset($config->i__loader);

        $export = str_replace('stdClass::__set_state', '(object)', var_export($config, true));
        $script = "<?php\nreturn $export;";

        $success = file_put_contents($filename, $script, str_contains($filename, ':') ? 0 : LOCK_EX);

        if ($success && function_exists('opcache_compile_file')) {
            // @codeCoverageIgnoreStart
            opcache_compile_file($filename);
            // @codeCoverageIgnoreEnd
        }
    }
555361
public static function delete($filename)
    {
        if (is_string($filename) && file_exists($filename)) {
            unlink($filename);
            return true;
        }

        return false;
    }
59878
public static function parseFromFile($filename)
    {
        if (file_exists($filename) && is_readable($filename)) {
            return new self(file_get_contents($filename));
        } else {
            throw new \RuntimeException(sprintf("File %s is not readable, or doesn't exist.", $filename));
        }
    }
848744
public function delete($filename)
    {
        $this->initialize();

        try {
            $file = $this->matcher->getFile($filename);
        } catch (FileNotFoundException $e) {
            return;
        }

        foreach ($this->files as $key => $item) {
            if ($item->getFullPath() === $file->getFullPath()) {
                unset($this->files[$key]);
                $this->files = array_values($this->files); // normalize indexes
                $this->persist();
                break;
            }
        }
    }
847163
private function tryRemoveWithLock(string $fileName): bool
    {
        if (strncasecmp(PHP_OS, 'WIN', 3) == 0) {
            // On Windows, unlinking a locked/opened file will not work, so we just attempt the delete straight away.
            // In the worst case, the unlink will just fail due to concurrent access and the caller needs to deal with that.
            return unlink($fileName);
        }
        $file = fopen($fileName, 'rb');
        if ($file === false) {
            return false;
        }

        $result = false;
        if (flock($file, LOCK_EX) !== false) {
            $result = unlink($fileName);
            flock($file, LOCK_UN);
        }
        fclose($file);

        return $result;
    }
650615
protected function resolveDispositionHeaderFilename($filename)
    {
        $userAgent = $this->request->headers->get('User-Agent');

        if (preg_match('#MSIE|Safari|Konqueror#', $userAgent)) {
            return "filename=".rawurlencode($filename);
        }

        return "filename*=UTF-8''".rawurlencode($filename);
    }
84623
protected function sendHeaders(string $filename)
    {
        if (strlen($filename) != strcspn($filename, '\\/')) {
            throw new Exception('The filename cannot contain the "/" and "\\" characters.');
        }

        $flag = FILTER_FLAG_STRIP_LOW;
        if (strlen($filename) !== mb_strlen($filename)) {
            $flag |= FILTER_FLAG_STRIP_HIGH;
        }

        $filenameFallback = str_replace('%', '', filter_var($filename, FILTER_SANITIZE_STRING, $flag));

        $disposition = sprintf('attachment; filename="%s"', str_replace('"', '\\"', $filenameFallback));
        if ($filename !== $filenameFallback) {
            $disposition .= sprintf("; filename*=utf-8''%s", rawurlencode($filename));
        }

        header('Content-Type: text/csv');
        header('Content-Transfer-Encoding: binary');
        header('Content-Description: File Transfer');
        header('Content-Disposition: '.$disposition);
    }