• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP file_modify_html_header函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中file_modify_html_header函数的典型用法代码示例。如果您正苦于以下问题:PHP file_modify_html_header函数的具体用法?PHP file_modify_html_header怎么用?PHP file_modify_html_header使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了file_modify_html_header函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: send_stored_file


//.........这里部分代码省略.........
        }
        die;
    }
    if ($dontdie) {
        ignore_user_abort(true);
    }
    \core\session\manager::write_close();
    // Unlock session during file serving.
    $filename = is_null($filename) ? $stored_file->get_filename() : $filename;
    // Use given MIME type if specified.
    $mimetype = $stored_file->get_mimetype();
    // Otherwise guess it.
    if (!$mimetype || $mimetype === 'document/unknown') {
        $mimetype = get_mimetype_for_sending($filename);
    }
    // if user is using IE, urlencode the filename so that multibyte file name will show up correctly on popup
    if (core_useragent::is_ie()) {
        $filename = rawurlencode($filename);
    }
    if ($forcedownload) {
        header('Content-Disposition: attachment; filename="' . $filename . '"');
    } else {
        if ($mimetype !== 'application/x-shockwave-flash') {
            // If this is an swf don't pass content-disposition with filename as this makes the flash player treat the file
            // as an upload and enforces security that may prevent the file from being loaded.
            header('Content-Disposition: inline; filename="' . $filename . '"');
        }
    }
    if ($lifetime > 0) {
        $cacheability = ' public,';
        if (!empty($options['cacheability']) && $options['cacheability'] === 'public') {
            // This file must be cache-able by both browsers and proxies.
            $cacheability = ' public,';
        } else {
            if (!empty($options['cacheability']) && $options['cacheability'] === 'private') {
                // This file must be cache-able only by browsers.
                $cacheability = ' private,';
            } else {
                if (isloggedin() and !isguestuser()) {
                    $cacheability = ' private,';
                }
            }
        }
        header('Cache-Control:' . $cacheability . ' max-age=' . $lifetime . ', no-transform');
        header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $lifetime) . ' GMT');
        header('Pragma: ');
    } else {
        // Do not cache files in proxies and browsers
        if (is_https()) {
            // HTTPS sites - watch out for IE! KB812935 and KB316431.
            header('Cache-Control: private, max-age=10, no-transform');
            header('Expires: ' . gmdate('D, d M Y H:i:s', 0) . ' GMT');
            header('Pragma: ');
        } else {
            //normal http - prevent caching at all cost
            header('Cache-Control: private, must-revalidate, pre-check=0, post-check=0, max-age=0, no-transform');
            header('Expires: ' . gmdate('D, d M Y H:i:s', 0) . ' GMT');
            header('Pragma: no-cache');
        }
    }
    // Allow cross-origin requests only for Web Services.
    // This allow to receive requests done by Web Workers or webapps in different domains.
    if (WS_SERVER) {
        header('Access-Control-Allow-Origin: *');
    }
    if (empty($filter)) {
        // send the contents
        readfile_accel($stored_file, $mimetype, !$dontdie);
    } else {
        // Try to put the file through filters
        if ($mimetype == 'text/html' || $mimetype == 'application/xhtml+xml') {
            $options = new stdClass();
            $options->noclean = true;
            $options->nocache = true;
            // temporary workaround for MDL-5136
            $text = $stored_file->get_content();
            $text = file_modify_html_header($text);
            $output = format_text($text, FORMAT_HTML, $options, $COURSE->id);
            readstring_accel($output, $mimetype, false);
        } else {
            if ($mimetype == 'text/plain' and $filter == 1) {
                // only filter text if filter all files is selected
                $options = new stdClass();
                $options->newlines = false;
                $options->noclean = true;
                $text = $stored_file->get_content();
                $output = '<pre>' . format_text($text, FORMAT_MOODLE, $options, $COURSE->id) . '</pre>';
                readstring_accel($output, $mimetype, false);
            } else {
                // Just send it out raw
                readfile_accel($stored_file, $mimetype, !$dontdie);
            }
        }
    }
    if ($dontdie) {
        return;
    }
    die;
    //no more chars to output!!!
}
开发者ID:IFPBMoodle,项目名称:moodle,代码行数:101,代码来源:filelib.php


示例2: send_stored_file


//.........这里部分代码省略.........
            send_file($CFG->dirroot . '/pix/' . $fileicon . '.png', basename($fileicon) . '.png');
        } else {
            // preview images have fixed cache lifetime and they ignore forced download
            // (they are generated by GD and therefore they are considered reasonably safe).
            $stored_file = $preview_file;
            $lifetime = DAYSECS;
            $filter = 0;
            $forcedownload = false;
        }
    }
    // handle external resource
    if ($stored_file && $stored_file->is_external_file() && !isset($options['sendcachedexternalfile'])) {
        $stored_file->send_file($lifetime, $filter, $forcedownload, $options);
        die;
    }
    if (!$stored_file or $stored_file->is_directory()) {
        // nothing to serve
        if ($dontdie) {
            return;
        }
        die;
    }
    if ($dontdie) {
        ignore_user_abort(true);
    }
    \core\session\manager::write_close();
    // Unlock session during file serving.
    // Use given MIME type if specified, otherwise guess it using mimeinfo.
    // IE, Konqueror and Opera open html file directly in browser from web even when directed to save it to disk :-O
    // only Firefox saves all files locally before opening when content-disposition: attachment stated
    $filename = is_null($filename) ? $stored_file->get_filename() : $filename;
    $isFF = core_useragent::is_firefox();
    // only FF properly tested
    $mimetype = ($forcedownload and !$isFF) ? 'application/x-forcedownload' : ($stored_file->get_mimetype() ? $stored_file->get_mimetype() : mimeinfo('type', $filename));
    // if user is using IE, urlencode the filename so that multibyte file name will show up correctly on popup
    if (core_useragent::is_ie()) {
        $filename = rawurlencode($filename);
    }
    if ($forcedownload) {
        header('Content-Disposition: attachment; filename="' . $filename . '"');
    } else {
        header('Content-Disposition: inline; filename="' . $filename . '"');
    }
    if ($lifetime > 0) {
        $private = '';
        if (isloggedin() and !isguestuser()) {
            $private = ' private,';
        }
        header('Cache-Control:' . $private . ' max-age=' . $lifetime . ', no-transform');
        header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $lifetime) . ' GMT');
        header('Pragma: ');
    } else {
        // Do not cache files in proxies and browsers
        if (strpos($CFG->wwwroot, 'https://') === 0) {
            //https sites - watch out for IE! KB812935 and KB316431
            header('Cache-Control: private, max-age=10, no-transform');
            header('Expires: ' . gmdate('D, d M Y H:i:s', 0) . ' GMT');
            header('Pragma: ');
        } else {
            //normal http - prevent caching at all cost
            header('Cache-Control: private, must-revalidate, pre-check=0, post-check=0, max-age=0, no-transform');
            header('Expires: ' . gmdate('D, d M Y H:i:s', 0) . ' GMT');
            header('Pragma: no-cache');
        }
    }
    if (empty($filter)) {
        // send the contents
        readfile_accel($stored_file, $mimetype, !$dontdie);
    } else {
        // Try to put the file through filters
        if ($mimetype == 'text/html') {
            $options = new stdClass();
            $options->noclean = true;
            $options->nocache = true;
            // temporary workaround for MDL-5136
            $text = $stored_file->get_content();
            $text = file_modify_html_header($text);
            $output = format_text($text, FORMAT_HTML, $options, $COURSE->id);
            readstring_accel($output, $mimetype, false);
        } else {
            if ($mimetype == 'text/plain' and $filter == 1) {
                // only filter text if filter all files is selected
                $options = new stdClass();
                $options->newlines = false;
                $options->noclean = true;
                $text = $stored_file->get_content();
                $output = '<pre>' . format_text($text, FORMAT_MOODLE, $options, $COURSE->id) . '</pre>';
                readstring_accel($output, $mimetype, false);
            } else {
                // Just send it out raw
                readfile_accel($stored_file, $mimetype, !$dontdie);
            }
        }
    }
    if ($dontdie) {
        return;
    }
    die;
    //no more chars to output!!!
}
开发者ID:ruddj,项目名称:moodle,代码行数:101,代码来源:filelib.php


示例3: send_stored_file


//.........这里部分代码省略.........
        if (strpos($CFG->wwwroot, 'https://') === 0) {
            //https sites - watch out for IE! KB812935 and KB316431
            header('Cache-Control: max-age=10');
            header('Expires: ' . gmdate('D, d M Y H:i:s', 0) . ' GMT');
            header('Pragma: ');
        } else {
            //normal http - prevent caching at all cost
            header('Cache-Control: private, must-revalidate, pre-check=0, post-check=0, max-age=0');
            header('Expires: ' . gmdate('D, d M Y H:i:s', 0) . ' GMT');
            header('Pragma: no-cache');
        }
        header('Accept-Ranges: none');
        // Do not allow byteserving when caching disabled
    }
    if (empty($filter)) {
        $filtered = false;
        if ($mimetype == 'text/html' && !empty($CFG->usesid)) {
            //cookieless mode - rewrite links
            header('Content-Type: text/html');
            $text = $stored_file->get_content();
            $text = sid_ob_rewrite($text);
            $filesize = strlen($text);
            $filtered = true;
        } else {
            if ($mimetype == 'text/plain') {
                header('Content-Type: Text/plain; charset=utf-8');
                //add encoding
            } else {
                header('Content-Type: ' . $mimetype);
            }
        }
        header('Content-Length: ' . $filesize);
        //flush the buffers - save memory and disable sid rewrite
        //this also disables zlib compression
        prepare_file_content_sending();
        // send the contents
        if ($filtered) {
            echo $text;
        } else {
            $stored_file->readfile();
        }
    } else {
        // Try to put the file through filters
        if ($mimetype == 'text/html') {
            $options = new stdClass();
            $options->noclean = true;
            $options->nocache = true;
            // temporary workaround for MDL-5136
            $text = $stored_file->get_content();
            $text = file_modify_html_header($text);
            $output = format_text($text, FORMAT_HTML, $options, $COURSE->id);
            if (!empty($CFG->usesid)) {
                //cookieless mode - rewrite links
                $output = sid_ob_rewrite($output);
            }
            header('Content-Length: ' . strlen($output));
            header('Content-Type: text/html');
            //flush the buffers - save memory and disable sid rewrite
            //this also disables zlib compression
            prepare_file_content_sending();
            // send the contents
            echo $output;
        } else {
            if ($mimetype == 'text/plain' and $filter == 1) {
                // only filter text if filter all files is selected
                $options = new stdClass();
                $options->newlines = false;
                $options->noclean = true;
                $text = $stored_file->get_content();
                $output = '<pre>' . format_text($text, FORMAT_MOODLE, $options, $COURSE->id) . '</pre>';
                if (!empty($CFG->usesid)) {
                    //cookieless mode - rewrite links
                    $output = sid_ob_rewrite($output);
                }
                header('Content-Length: ' . strlen($output));
                header('Content-Type: text/html; charset=utf-8');
                //add encoding
                //flush the buffers - save memory and disable sid rewrite
                //this also disables zlib compression
                prepare_file_content_sending();
                // send the contents
                echo $output;
            } else {
                // Just send it out raw
                header('Content-Length: ' . $filesize);
                header('Content-Type: ' . $mimetype);
                //flush the buffers - save memory and disable sid rewrite
                //this also disables zlib compression
                prepare_file_content_sending();
                // send the contents
                $stored_file->readfile();
            }
        }
    }
    if ($dontdie) {
        return;
    }
    die;
    //no more chars to output!!!
}
开发者ID:hatone,项目名称:moodle,代码行数:101,代码来源:filelib.php


示例4: send_file


//.........这里部分代码省略.........
            @header('Accept-Ranges: none');
        }
    } else {
        // Do not cache files in proxies and browsers
        if (strpos($CFG->wwwroot, 'https://') === 0) {
            //https sites - watch out for IE! KB812935 and KB316431
            @header('Cache-Control: max-age=10');
            @header('Expires: ' . gmdate('D, d M Y H:i:s', 0) . ' GMT');
            @header('Pragma: ');
        } else {
            //normal http - prevent caching at all cost
            @header('Cache-Control: private, must-revalidate, pre-check=0, post-check=0, max-age=0');
            @header('Expires: ' . gmdate('D, d M Y H:i:s', 0) . ' GMT');
            @header('Pragma: no-cache');
        }
        @header('Accept-Ranges: none');
        // Do not allow byteserving when caching disabled
    }
    if (empty($filter)) {
        if ($mimetype == 'text/html' && !empty($CFG->usesid) && empty($_COOKIE['MoodleSession' . $CFG->sessioncookie])) {
            //cookieless mode - rewrite links
            @header('Content-Type: text/html');
            $path = $pathisstring ? $path : implode('', file($path));
            $path = sid_ob_rewrite($path);
            $filesize = strlen($path);
            $pathisstring = true;
        } else {
            if ($mimetype == 'text/plain') {
                @header('Content-Type: Text/plain; charset=utf-8');
                //add encoding
            } else {
                @header('Content-Type: ' . $mimetype);
            }
        }
        @header('Content-Length: ' . $filesize);
        while (@ob_end_flush()) {
        }
        //flush the buffers - save memory and disable sid rewrite
        if ($pathisstring) {
            echo $path;
        } else {
            readfile_chunked($path);
        }
    } else {
        // Try to put the file through filters
        if ($mimetype == 'text/html') {
            $options = new object();
            $options->noclean = true;
            $options->nocache = true;
            // temporary workaround for MDL-5136
            $text = $pathisstring ? $path : implode('', file($path));
            $text = file_modify_html_header($text);
            $output = format_text($text, FORMAT_HTML, $options, $COURSE->id);
            if (!empty($CFG->usesid) && empty($_COOKIE['MoodleSession' . $CFG->sessioncookie])) {
                //cookieless mode - rewrite links
                $output = sid_ob_rewrite($output);
            }
            @header('Content-Length: ' . strlen($output));
            @header('Content-Type: text/html');
            while (@ob_end_flush()) {
            }
            //flush the buffers - save memory and disable sid rewrite
            echo $output;
            // only filter text if filter all files is selected
        } else {
            if ($mimetype == 'text/plain' and $filter == 1) {
                $options = new object();
                $options->newlines = false;
                $options->noclean = true;
                $text = htmlentities($pathisstring ? $path : implode('', file($path)));
                $output = '<pre>' . format_text($text, FORMAT_MOODLE, $options, $COURSE->id) . '</pre>';
                if (!empty($CFG->usesid) && empty($_COOKIE['MoodleSession' . $CFG->sessioncookie])) {
                    //cookieless mode - rewrite links
                    $output = sid_ob_rewrite($output);
                }
                @header('Content-Length: ' . strlen($output));
                @header('Content-Type: text/html; charset=utf-8');
                //add encoding
                while (@ob_end_flush()) {
                }
                //flush the buffers - save memory and disable sid rewrite
                echo $output;
            } else {
                // Just send it out raw
                @header('Content-Length: ' . $filesize);
                @header('Content-Type: ' . $mimetype);
                while (@ob_end_flush()) {
                }
                //flush the buffers - save memory and disable sid rewrite
                if ($pathisstring) {
                    echo $path;
                } else {
                    readfile_chunked($path);
                }
            }
        }
    }
    die;
    //no more chars to output!!!
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:101,代码来源:filelib.php



注:本文中的file_modify_html_header函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP file_move函数代码示例发布时间:2022-05-15
下一篇:
PHP file_mode_info函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap