File::show

Show file with header.

@return void
553029
public function show()
    {
        if ($mime = $this->getMime()) {
            $mime = is_array($mime) ? $mime[ 0 ] : $mime;
        } elseif (is_file($this->getRealPath())) {
            $mime = 'application/octet-stream';
        }

        $fileSize = filesize($this->getRealPath());
        $filename = pathinfo($this->getRealPath(), PATHINFO_BASENAME);

        // Common headers
        $expires = 604800; // (60*60*24*7)
        header('Expires:' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');

        header('Accept-Ranges: bytes', true);
        header("Cache-control: private", true);
        header('Pragma: private', true);

        header('Content-Type: ' . $mime);
        header('Content-Disposition: inline; filename="' . $filename . '"');
        header('Content-Transfer-Encoding: binary');
        header('Accept-Ranges: bytes');

        $ETag = '"' . md5($filename) . '"';

        if ( ! empty($_SERVER[ 'HTTP_IF_NONE_MATCH' ])
            && $_SERVER[ 'HTTP_IF_NONE_MATCH' ] == $ETag
        ) {
            header('HTTP/1.1 304 Not Modified');
            header('Content-Length: ' . $fileSize);
            exit;
        }

        $expires = 604800; // (60*60*24*7)
        header('ETag: ' . $ETag);
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
        header('Expires:' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');

        // Open file
        // @readfile($file_path);
        $file = @fopen($filename, "rb");
        if ($file) {
            while ( ! feof($file)) {
                print(fread($file, 1024 * 8));
                flush();
                if (connection_status() != 0) {
                    @fclose($file);
                    die();
                }
            }
            @fclose($file);
        }
    }
323660
public function header()
    {
        /** @var string $tabHeader Header html view */
        $tabSubHeader = '';

        // Set content of header view
        $tabHeader = $this->renderer->view($this->headerContentView)
            ->headName(t($this->name, true))
            ->headUrl('#'.$this->id)
            ->set($this->size, 'subTabsCount')
            ->output();

        // If tab has sub tabs
        if (count($this->subTabs) > 1) {
            // Render header of each sub tab inside parent tab
            foreach ($this->subTabs as $tab) {
                $tabSubHeader .= $tab->header();
            }
        }

        return $this->renderer->view($this->headerIndexView)
            ->tabHeader($tabHeader)
            ->tabSubHeader($tabSubHeader)
            ->output();
    }
1332550
protected function outputHeaders()
    {
        $headersSent = headers_sent($file, $line);
        if (!$headersSent) {
            $method = sprintf(
                "%s %d %s",
                $_SERVER['SERVER_PROTOCOL'],
                $this->getStatusCode(),
                $this->getStatusDescription()
            );
            header($method);
            foreach ($this->getHeaders() as $header => $value) {
                header("{$header}: {$value}", true, $this->getStatusCode());
            }
        } elseif ($this->getStatusCode() >= 300) {
            // It's critical that these status codes are sent; we need to report a failure if not.
            user_error(
                sprintf(
                    "Couldn't set response type to %d because of output on line %s of %s",
                    $this->getStatusCode(),
                    $line,
                    $file
                ),
                E_USER_WARNING
            );
        }
    }
1068264
public function PrintFilesToPack () {
		$this->PreRun();
		// complete $this->files as usual
		$this->completeAllFiles();
		$phpFiles = [];
		$staticFiles = [];
		foreach($this->files->all as $path => $fileItem){
			if ($fileItem->extension == 'php') {
				$phpFiles[] = $path;
			} else {
				$staticFiles[] = $path;
			}
		}
		$this->files->php = $phpFiles;
		$this->files->static = $staticFiles;
		unset($this->files->all);
		$this->notify("Files to pack notification");
	}
921533
static public function display()
    {
        Sorter::sort(Listing::$files);
        $content = '<!DOCTYPE html>';
        $content .= sprintf('
<html xmlns="http://www.w3.org/1999/xhtml" lang="%s">', Translation::getCanonicalLocale());
        $content .= '
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>' . sprintf(Translation::trans('index_of'), Main::getDir()) . '</title>';
        $content .= static::getStyle();
        $content .= '
    </head>
    <body>';
        $content .= static::getTitle();
        $content .= '
        <table align="center">';
        $content .= static::getHeader();
        foreach (Listing::$files as $file) {
            $content .= static::getRow($file);
        }
        $content .= static::getFooter();
        $content .= '
        </table>';
        $content .= '
    </body>
</html>';
        die($content);
    }
1292720
public function display(array $data = null): void
    {
        if ($this->fileHead != null) {
            $this->load($this->fileHead, $data);
        }

        $this->load($this->file, $data); // main file

        if ($this->fileFoot != null) {
            $this->load($this->fileFoot, $data);
        }
    }
361972
public function showAction($filename)
    {
        $message = $this->get('cocorico.swift_reader.message_manager')
            ->getOneByFileName($filename);

        return $this->render(
            'CocoricoSwiftReaderBundle:Message:_show.html.twig',
            array(
                'filename' => $filename,
                'message' => $message
            )
        );
    }
276290
public function displayHeaderCell()
    {
        if (!$this->visible) {
            return;
        }

        $th_tag = new SwatHtmlTag('th', $this->getThAttributes());
        $th_tag->scope = 'col';

        $colspan = $this->getXhtmlColspan();
        if ($colspan > 1) {
            $th_tag->colspan = $colspan;
        }

        $th_tag->open();
        $this->displayHeader();
        $th_tag->close();
    }
971872
function show()
    {
        //---Mostrar la imagen dependiendo del tipo de archivo
        switch($this->type)
        {
            case IMAGETYPE_JPEG:
                imagejpeg($this->image);
                break;
            case IMAGETYPE_GIF:
                imagegif($this->image);
                break;
            case IMAGETYPE_PNG:
                imagepng($this->image);
                break;
        }
    }
728687
public function show()
	{
		$package = $this->arguments->getOpt('package');
		if (!empty($package))
		{
			$versions = Composer::findRemotePackages($package, '*');
			$this->output->addRawFromAssocArray($versions);
		}
		else
		{
			$installed = Composer::getLocalPackages();
			$this->output->addRawFromAssocArray($installed);
		}
	}
974809
public function show()
	{
		//get the global $config array for site title
		global $config;

		//set the title variable
		$title = $config['title'];

		//the variable to be populated with the error message
		$msg = $this->getCode() . ': Error on line '.$this->getLine().' in '.$this->getFile() .': <b>  "'.$this->getMessage().' " </b> ';

		//load the template file
		include Path::sys() . 'Exceptions' . DIRECTORY_SEPARATOR . 'index.php';

		//stop further output
		exit();

	}
403326
public function display()
    {
        if (!$this->visible) {
            return;
        }

        parent::display();

        $input_tag = new SwatHtmlTag('input');
        $input_tag->type = 'file';
        $input_tag->name = $this->id;
        $input_tag->id = $this->id;
        $input_tag->class = $this->getCSSClassString();
        $input_tag->accesskey = $this->access_key;
        $input_tag->tabindex = $this->tab_index;
        $input_tag->size = $this->size;

        // note: the 'accept' attribute is part of the w3c standard, but
        //       is ignored by most browsers
        if ($this->accept_mime_types !== null) {
            $input_tag->accept = implode(',', $this->accept_mime_types);
        }

        if (!$this->isSensitive()) {
            $input_tag->disabled = 'disabled';
        }

        $input_tag->display();

        if ($this->display_maximum_upload_size) {
            $div_tag = new SwatHtmlTag('div');
            $div_tag->class = 'swat-note';
            $div_tag->setContent($this->getMaximumUploadSizeText());
            $div_tag->display();
        }
    }
1236121
public function show($path, $type = self::IMAGE_ORIGINAL)
    {
        if (!array_key_exists($type, $this->config)) {
            $type = self::IMAGE_ORIGINAL;
        }

        if ($this->checkPermission($type)) {
            if ($file = $this->detectPath($path)) {
                $image = Image::getImagine()
                    ->open($file)
                    ->copy();
                $actions = $this->config[$type];
                ArrayHelper::remove($actions, 'transparent');
                foreach ($actions as $action => $options) {
                    if (method_exists($this, $action)) {
                        $image = $this->$action($image, $options);
                    }
                }
                $cachePath = $this->getCachePath($path, $type);
                if (!file_exists($cachePath['system'])) {
                    $image->save($cachePath['system']);
                }
                $image->show($cachePath['extension']);
                Yii::$app->end();
            }
        }

        $this->show($this->noImage, $type);
    }
1204550
protected function header2fileinfo($header)
    {
        $fileinfo = new FileInfo();
        $fileinfo->setPath($header['filename']);
        $fileinfo->setMode($header['perm']);
        $fileinfo->setUid($header['uid']);
        $fileinfo->setGid($header['gid']);
        $fileinfo->setSize($header['size']);
        $fileinfo->setMtime($header['mtime']);
        $fileinfo->setOwner($header['uname']);
        $fileinfo->setGroup($header['gname']);
        $fileinfo->setIsdir((bool) $header['typeflag']);

        return $fileinfo;
    }
57834
protected function initFile()
    {
        if ($this->maxFileSize > 0 && file_exists($this->filename) && filesize($this->filename) >= $this->maxFileSize) {
            // need to reduce the file size
            $file = file($this->filename);
            $file = array_splice($file, ceil(count($file) * $this->reduceRatio));
            $this->filehandle = @fopen($this->filename, 'w');
            foreach ($file as $line) {
                @fwrite($this->filehandle, $line);
            }
        } else {
            $this->filehandle = @fopen($this->filename, 'a');
        }
    }
749530
public function showHelp()
    {
        $writer = $this->io()->writer();
        $header = "{$this->name}, version {$this->version}";
        $footer = 'Run `<command> --help` for specific help';

        if ($this->logo) {
            $writer->write($this->logo, true);
        }

        $this->outputHelper()->showCommandsHelp($this->commands(), $header, $footer);

        return ($this->onExit)();
    }
1314173
public function display()
    {
        // For a certain unmentionable browser
        if (ini_get('zlib.output_compression')) {
            ini_set('zlib.output_compression', 'Off');
        }

        // Remove php's time limit
        if (!ini_get('safe_mode')) {
            @set_time_limit(0);
        }

        // Mimetype
        // @TODO magic mimetypes
        if ($this->mimetype) {
            header('Content-type: '.$this->mimetype);
        }

        header('Content-Transfer-Encoding: binary');
        header('Accept-Ranges: bytes');

        // Prevent caching
        header('Pragma: public');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Expires: 0');

        // Clear buffer
        while (@ob_end_clean());

        $this->filename = basename($this->filename);

        if (!empty($this->output)) {
            // File body is passed as string

            if (empty($this->filename)) {
                throw new KViewException('No filename supplied');
            }

            $this->_setDisposition();
            $filesize = strlen($this->output);
            header('Content-Length: '.$filesize);
            flush();

            echo $this->output;
        } elseif (!empty($this->path)) {
            // File is read from disk

             if (empty($this->filename)) {
                 $this->filename = basename($this->path);
             }

            $filesize = @filesize($this->path);

            header('Content-Length: '.$filesize);

            $this->_setDisposition();

            flush();

            $this->_readChunked($this->path);
        } else {
            throw new KViewException('No output or path supplied');
        }

        die;
    }