本文整理汇总了PHP中fpassthru函数的典型用法代码示例。如果您正苦于以下问题:PHP fpassthru函数的具体用法?PHP fpassthru怎么用?PHP fpassthru使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fpassthru函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deliverFile
function deliverFile($file, $contentEncoding)
{
if (file_exists($file) && ($filehandle = fopen($file, 'r'))) {
$fileCTime = filectime($file);
// We don't need to deliver the file, if it hasn't been modified
// since the last time it has been requested.
if (array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) {
$sinceTime = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']);
if ($sinceTime !== false && $sinceTime >= $fileCTime) {
# header('Debug-Requested-File: ' . $file);
header('Debug-Last-Modified: ' . date('r', $fileCTime));
header('Debug-If-Modified-Since: ' . date('r', $sinceTime));
header('HTTP/1.0 304 Not Modified');
exit;
}
}
header('Last-Modified: ' . date('r', $fileCTime));
# header('Debug-Requested-File: ' . $file);
header('Content-Type: application/x-java-archive');
header('Content-Length :' . filesize($file));
if ($contentEncoding != null) {
header('Content-Encoding: ' . $contentEncoding);
}
fpassthru($filehandle);
fclose($filehandle);
} else {
header('HTTP/1.0 404 Not Found');
}
exit;
}
示例2: index
public function index()
{
$this->auto_render = FALSE;
if ($this->service == "" && $this->host == "") {
url::redirect("graph", 302);
}
$this->data->readXML($this->host, $this->service);
if ($this->auth->is_authorized($this->data->MACRO['AUTH_HOSTNAME'], $this->data->MACRO['AUTH_SERVICEDESC']) === FALSE) {
header('Content-Type: application/xml');
print "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
print "<NAGIOS>\n";
print "<ERROR>not authorized</ERROR>\n";
print "</NAGIOS>\n";
exit;
} else {
$xmlfile = $this->config->conf['rrdbase'] . $this->host . "/" . $this->service . ".xml";
if (is_readable($xmlfile)) {
$fh = fopen($xmlfile, 'r');
header('Content-Type: application/xml');
fpassthru($fh);
fclose($fh);
exit;
} else {
header('Content-Type: application/xml');
print "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
print "<NAGIOS>\n";
print "<ERROR>file not found</ERROR>\n";
print "</NAGIOS>\n";
}
}
}
示例3: graph_error
function graph_error($string)
{
global $vars, $config, $debug, $graphfile;
$vars['bg'] = 'FFBBBB';
include 'includes/graphs/common.inc.php';
$rrd_options .= ' HRULE:0#555555';
$rrd_options .= " --title='" . $string . "'";
rrdtool_graph($graphfile, $rrd_options);
if ($height > '99') {
shell_exec($rrd_cmd);
d_echo('<pre>' . $rrd_cmd . '</pre>');
if (is_file($graphfile) && !$debug) {
header('Content-type: image/png');
$fd = fopen($graphfile, 'r');
fpassthru($fd);
fclose($fd);
unlink($graphfile);
exit;
}
} else {
if (!$debug) {
header('Content-type: image/png');
}
$im = imagecreate($width, $height);
$px = (imagesx($im) - 7.5 * strlen($string)) / 2;
imagestring($im, 3, $px, $height / 2 - 8, $string, imagecolorallocate($im, 128, 0, 0));
imagepng($im);
imagedestroy($im);
exit;
}
}
示例4: dump
/**
* Dump the contents of the file using fpassthru().
*
* @return void
* @throws Exception if no file or contents.
*/
function dump()
{
if (!$this->data) {
// hmmm .. must be a file that needs to read in
if ($this->inFile) {
$fp = @fopen($this->inFile, "rb");
if (!$fp) {
throw new Exception('Unable to open file: ' . $this->inFile);
}
fpassthru($fp);
@fclose($fp);
} else {
throw new Exception('No data to dump');
}
} else {
$realdocuroot = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']);
$docuroot = explode('/', $realdocuroot);
array_pop($docuroot);
$pathhome = implode('/', $docuroot) . '/';
array_pop($docuroot);
$pathTrunk = implode('/', $docuroot) . '/';
require_once $pathTrunk . 'gulliver/system/class.inputfilter.php';
$filter = new InputFilter();
$data = $filter->xssFilterHard($this->data);
echo $data;
}
}
示例5: download
private function download($dir, $file)
{
chdir($dir);
// if the filename is in the array
if (preg_match("/\\.zip\$/", $file)) {
// and it exists
if (file_exists($file)) {
// and is readable
if (is_readable($file)) {
// get its size
$size = filesize($file);
// open it for reading
if ($fp = @fopen("{$file}", 'r')) {
// send the headers
header('Content-type: application/zip');
header("Content-Length: {$size}");
header("Content-Disposition: attachment; filename=\"{$file}\"");
// send the file content
fpassthru($fp);
// close the file
fclose($fp);
// and quit
exit;
}
}
}
}
}
示例6: ShowAction
public function ShowAction($id = '')
{
global $CONFIG;
$id += 0;
if (!$id) {
throw new ApplicationException("404 File Not Found");
}
$size = reqs('size');
$is_preview = reqi('preview');
if ($is_preview) {
$item = $this->model->one($id);
if ($item['is_image']) {
$this->model->transmit_file($id, $size, 'inline');
} else {
#if it's not an image and requested preview - return std image
$filepath = $CONFIG['site_root'] . '/img/att_file.png';
# TODO move to web.config or to model?
header('Content-type: ' . UploadUtils::get_mime4ext($item['ext']));
$fp = fopen($filepath, 'rb');
fpassthru($fp);
}
} else {
$this->model->transmit_file($id, $size, 'inline');
}
}
示例7: output
/**
* Output json
*
* @param array data to output
* @return void
* @author Dmitry (dio) Levashov
**/
protected function output(array $data)
{
$header = isset($data['header']) ? $data['header'] : $this->header;
unset($data['header']);
$headers = array();
if ($header) {
foreach ((array) $header as $headerString) {
if (strpos($headerString, ':') !== false) {
list($key, $value) = explode(':', $headerString, 2);
$headers[$key] = $value;
}
}
}
if (isset($data['pointer'])) {
$this->response = new StreamedResponse(function () use($data) {
if (stream_get_meta_data($data['pointer'])['seekable']) {
rewind($data['pointer']);
}
fpassthru($data['pointer']);
if (!empty($data['volume'])) {
$data['volume']->close($data['pointer'], $data['info']['hash']);
}
}, 200, $headers);
} else {
if (!empty($data['raw']) && !empty($data['error'])) {
$this->response = new JsonResponse($data['error'], 500);
} else {
$this->response = new JsonResponse($data, 200, $headers);
}
}
}
示例8: output
/**
* Output a file to the browser
*
* @param string $file The file to output
*
* @since 1.0.0
*/
public function output($file)
{
@error_reporting(E_ERROR);
$name = basename($file);
$type = $this->getContentType($name);
$size = @filesize($file);
$mod = date('r', filemtime($file));
while (@ob_end_clean()) {
}
// required for IE, otherwise Content-disposition is ignored
if (ini_get('zlib.output_compression')) {
ini_set('zlib.output_compression', 'Off');
}
// set header
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Expires: 0");
header("Content-Transfer-Encoding: binary");
header('Content-Type: ' . $type);
header('Content-Disposition: attachment;' . ' filename="' . $name . '";' . ' modification-date="' . $mod . '";' . ' size=' . $size . ';');
header("Content-Length: " . $size);
// set_time_limit doesn't work in safe mode
if (!ini_get('safe_mode')) {
@set_time_limit(0);
}
// output file
$handle = fopen($file, 'rb');
fpassthru($handle);
fclose($handle);
}
示例9: streamContent
function streamContent($file, $type)
{
if ($type == "image") {
$file_bits = preg_split('/\\./', $file);
if (count($file_bits) == 2) {
if ($file_bits[1] == "png") {
$content = "image/png";
} else {
if ($file_bits[1] == "gif") {
$content = "image/gif";
}
}
}
}
if (!isset($content)) {
errorOut("Invalid Static Content", 404, array("Type specified - {$type}", "File specified - {$file}"));
}
$real_file = BASEPATH . "static/{$type}/" . $file;
if (is_file($real_file)) {
header("Content-Length:" . filesize($real_file));
header("Content-Type: " . $content);
$fh = fopen($real_file, "r");
fpassthru($fh);
fclose($fh);
} else {
errorOut("Invalid Static Content", 404, array("Filename - {$real_file}"));
}
exit;
}
示例10: execute
public function execute(InputInterface $input, OutputInterface $output)
{
$solrRoot = $this->getContainer()->getParameter('room13.solr.config.solr_root');
$schemaRoot = $this->getContainer()->getParameter('room13.solr.config.schema_root');
$p = popen("cd {$solrRoot} && java -Dsolr.solr.home={$schemaRoot} -jar start.jar", "r");
fpassthru($p);
}
示例11: generate_csv
protected function generate_csv()
{
extract($this->args);
$csv = fopen('php://memory', 'w');
$col_names = array();
$count = 0;
// Generate CSV lines
foreach ($data as $line) {
if ($column_names && $count < 1) {
foreach ($line as $col_name => $col_value) {
array_push($col_names, $col_name);
}
fputcsv($csv, $col_names, $delimiter);
}
fputcsv($csv, $line, $delimiter);
$count++;
}
// Rewind the CSV file
fseek($csv, 0);
// Set CSV file headers
header('Content-Type: application/csv');
header('Content-Disposition: attachement; filename="' . $filename . '.csv"');
header('Content-Cache: no-cache, must-revalidate');
header('Pragma: no-cache');
// Send the generated CSV to the browser
fpassthru($csv);
exit;
}
示例12: handle_file_cache
function handle_file_cache($file_cache_r, $isThumbnail = FALSE)
{
if ($file_cache_r !== FALSE) {
if ($file_cache_r['cache_type'] == 'ITEM') {
if ($isThumbnail) {
$file = file_cache_open_thumbnail_file($file_cache_r);
}
// fallback on big image
if (!$file) {
if ($file_cache_r['upload_file_ind'] != 'Y') {
$file = file_cache_open_file($file_cache_r);
}
}
} else {
$file = file_cache_open_file($file_cache_r);
}
if ($file) {
header("Content-disposition: inline; filename=" . $file_cache_r['cache_file']);
header("Content-type: " . $file_cache_r['content_type']);
fpassthru($file);
fclose($file);
} else {
// final fallback
output_cache_file($file_cache_r['url']);
}
return TRUE;
} else {
return FALSE;
}
}
示例13: testRequestToOutputFile
function testRequestToOutputFile()
{
$client = new ProxyClient();
$client->URL = df_absolute_url('tests/test_ProxyClient/test1.html');
$outputFile = tempnam(sys_get_temp_dir(), 'test_ProxyClient');
$client->outputFile = $outputFile;
$client->process();
$this->assertEquals(null, $client->content, 'Content should be written to output file, not saved to variable.');
$expected = file_get_contents('tests/test_ProxyClient/test1.html');
$doc = new DOMDocument();
@$doc->loadHtml($expected);
$expected = $doc->saveHtml();
$actual = file_get_contents($outputFile);
$actual = '';
$fh = fopen($outputFile, 'r');
while (!feof($fh) and trim($line = fgets($fh, 1024))) {
// We skip the headers
}
ob_start();
fpassthru($fh);
fclose($fh);
$actual = ob_get_contents();
ob_end_clean();
unset($doc);
$doc = new DOMDocument();
@$doc->loadHtml($actual);
$actual = $doc->saveHtml();
unset($doc);
$this->assertEquals($expected, $actual);
}
示例14: makethumbnail
function makethumbnail($src_file, $newSize, $method)
{
global $CONFIG;
$content_type = array(IMAGETYPE_GIF => 'gif', IMAGETYPE_JPEG => 'jpeg', IMAGETYPE_PNG => 'png');
// Checks that file exists and is readable
if (!filesize($src_file) || !is_readable($src_file)) {
header("Content-type: image/gif");
fpassthru(fopen(READ_ERROR_ICON, 'rb'));
exit;
}
// find the image size, no size => unknow type
$imginfo = getimagesize($src_file);
if ($imginfo == null) {
header("Content-type: image/gif");
fpassthru(fopen(UNKNOW_ICON, 'rb'));
exit;
}
// GD can't handle gif images
if ($imginfo[2] == IMAGETYPE_GIF && ($method == 'gd1' || $method == 'gd2') && !function_exists('imagecreatefromgif')) {
header("Content-type: image/gif");
fpassthru(fopen(GIF_ICON, 'rb'));
exit;
}
// height/width
$ratio = max(max($imginfo[0], $imginfo[1]) / $newSize, 1.0);
$dest_info[0] = intval($imginfo[0] / $ratio);
$dest_info[1] = intval($imginfo[1] / $ratio);
$dest_info['quality'] = intval($CONFIG['jpeg_qual']);
require_once 'includes/imaging/imaging.inc';
if (!Graphic::show($src_file, $dest_info)) {
return false;
}
}
示例15: send
public function send()
{
$fp = fopen($this->content, 'rb');
header("Content-Type:" . $this->contentType, true, $this->status);
header("Content-Length: " . filesize($this->content));
fpassthru($fp);
}