当前位置: 首页>>代码示例>>PHP>>正文


PHP header_remove函数代码示例

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


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

示例1: sendHeaders

 protected function sendHeaders()
 {
     // setup the status code
     http_response_code($this->response_status_code);
     // collect current headers into array
     $headers = headers_list();
     foreach ($headers as $h) {
         $h_parts = explode(":", $h);
         if (array_key_exists($h_parts[0], $this->response_headers)) {
             continue;
         }
         $this->response_headers[$h_parts[0]] = $h_parts[1];
     }
     // response type
     $this->response_headers["Content-Type"] = $this->response_content_type;
     if (!is_null($this->response_content_charset)) {
         $this->response_headers["Content-Type"] .= "; charset=" . $this->response_content_charset;
     }
     // put own headers
     header_remove();
     foreach ($this->response_headers as $key => $value) {
         header($key . ":" . $value);
     }
     return;
 }
开发者ID:hax4,项目名称:foundation,代码行数:25,代码来源:Response.php

示例2: bootstrap

/**
 * Example of function that defines a setup process common to all the
 * application. May be take as a template, or used as-is. Suggestions on new
 * things to include or ways to improve it are welcome :)
 */
function bootstrap(int $env = Env::PROD)
{
    // Set the encoding of the mb_* functions
    mb_internal_encoding('UTF-8');
    // Set the same timezone as the one used by the database
    date_default_timezone_set('UTC');
    // Get rid of PHP's default custom header
    header_remove('X-Powered-By');
    // Determine the current environment
    Env::set($env);
    // Control which errors are fired depending on the environment
    if (Env::isProd()) {
        error_reporting(0);
        ini_set('display_errors', '0');
    } else {
        error_reporting(E_ALL & ~E_NOTICE);
        ini_set('display_errors', '1');
    }
    // Handling errors from exceptions
    set_exception_handler(function (\Throwable $e) {
        $data = ['title' => 'Unexpected exception', 'detail' => $e->getMessage() ?: ''];
        if (Env::isDev()) {
            $data['debug'] = ['exception' => get_class($e) . ' (' . $e->getCode() . ')', 'file' => $e->getFile() . ':' . $e->getLine(), 'trace' => $e->getTrace()];
        }
        (new Response(HttpStatus::InternalServerError, [], $data))->send();
    });
    // Handling errors from trigger_error and the alike
    set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline, array $errcontext) {
        $data = ['title' => 'Unexpected error', 'detail' => $errstr ?: ''];
        if (Env::isDev()) {
            $data['debug'] = ['error' => $errno, 'file' => $errfile . ':' . $errline, 'context' => $errcontext];
        }
        (new Response(HttpStatus::InternalServerError, [], $data))->send();
    });
}
开发者ID:inad9300,项目名称:bed.php,代码行数:40,代码来源:bootstrap.php

示例3: init

 public static function init($timezone)
 {
     mb_internal_encoding('utf-8');
     if (!empty($timezone)) {
         @date_default_timezone_set($timezone);
     }
     header('Content-type: text/html; charset=utf-8');
     // prevent caching/storage of sensitive data
     header('Expires: Mon, 24 Mar 2008 00:00:00 GMT');
     header('Cache-Control: no-cache, no-store');
     // prevent clickjacking
     header('X-Frame-Options: sameorigin');
     // prevent content sniffing (MIME sniffing)
     header('X-Content-Type-Options: nosniff');
     if (self::FORCE_HTTPS) {
         // use HTTP Strict Transport Security (HSTS) with a period of three months
         header('Strict-Transport-Security: max-age=7884000');
     }
     // remove unnecessary HTTP headers
     header_remove('X-Powered-By');
     // present a link to the project's bug bounty to people who check the HTTP headers
     header('X-Bug-Bounty: http://security.localize.im/');
     if (self::ERROR_REPORTING_ON) {
         error_reporting(E_ALL);
         ini_set('display_errors', 'stdout');
     } else {
         error_reporting(0);
         ini_set('display_errors', 'stderr');
     }
     self::$page = isset($_GET['p']) && is_string($_GET['p']) ? trim($_GET['p']) : '';
     self::$actionPOST = isset($_POST) ? $_POST : array();
     self::$actionGET = isset($_GET) ? $_GET : array();
     self::$breadcrumbPath = array();
     self::$breadcrumbDisabled = false;
 }
开发者ID:jeckel420,项目名称:Localize,代码行数:35,代码来源:UI.php

示例4: __construct

 public function __construct()
 {
     $this->stack[] = function (RequestInterface $req) : ResponseInterface {
         try {
             ob_start();
             $res = $this->run($req->getUrl()->getPath(), $req->getMethod());
             if (!$res instanceof ResponseInterface) {
                 $body = ob_get_contents();
                 $headers = headers_list();
                 $code = http_response_code();
                 @header_remove();
                 $res = (new Response($code ? $code : 200))->setBody(strlen($body) ? $body : (string) $res);
                 foreach ($headers as $header) {
                     $header = array_map('trim', explode(':', $header, 2));
                     $res->setHeader($header[0], $header[1]);
                 }
             }
             ob_end_clean();
         } catch (\Exception $e) {
             ob_end_clean();
             throw $e;
         }
         return $res;
     };
 }
开发者ID:vakata,项目名称:httprouter,代码行数:25,代码来源:Router.php

示例5: buildOutput

 public function buildOutput()
 {
     // Must have controller
     if (is_null($this->controller)) {
         return '';
     }
     $controller = $this->controller;
     $responseCode = $controller->getResponseCode();
     $contentType = $controller->getContentType();
     $controllerHeaderList = $controller->getHeaderList();
     $headersList = headers_list();
     // Always remove the Content-Type header, let Jolt handle it
     header_remove('Content-Type');
     header("Content-Type: {$contentType}", true, $responseCode);
     // Go through the list of headers to send, if they exist in the
     // $controllerHeaderList, unset them
     foreach ($headersList as $fullHeader) {
         foreach ($controllerHeaderList as $header => $value) {
             if (false !== stripos($fullHeader, $header)) {
                 header_remove($header);
             }
             header("{$header}: {$value}", true, $responseCode);
         }
     }
     $renderedController = $this->controller->getRenderedController();
     return $renderedController;
 }
开发者ID:kennyma,项目名称:Jolt,代码行数:27,代码来源:Client.php

示例6: make_export

 function make_export()
 {
     if ($this->request->isset_GET('download') && ($this->request->isset_GET('page') && $this->request->GET('page') == 'tf_export')) {
         remove_filter('the_title_rss', 'strip_tags');
         remove_filter('the_title_rss', 'ent2ncr', 8);
         remove_filter('the_title_rss', 'esc_html');
         add_filter('the_title_rss', array($this, 'tfuse_post_title_export'), 99, 1);
         ob_start();
         require_once './includes/export.php';
         export_wp(array('content' => 'all'));
         if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
             header_remove('Content-Description');
             header_remove('Content-Disposition');
         } else {
             header("Content-Description: ");
             header("Content-Disposition: ");
         }
         $buffer = ob_get_contents();
         ob_end_clean();
         $buffer = explode('</rss>', $buffer);
         $tmp = explode('/', site_url());
         $multi = is_multisite() ? '-' . end($tmp) : '';
         $this->export_wp_filename = 'wordpress-' . TF_THEME_PREFIX . $multi . '.xml_.txt';
         $this->content = $buffer[0] . $this->tfuse_options_export() . '</rss>';
         //            $this->download_export($this->content);
         //            die();
     }
 }
开发者ID:shimion,项目名称:stlucks,代码行数:28,代码来源:TF_EXPORT.php

示例7: template_redirect

 /**
  * Unset the X-Pingback HTTP header.
  *
  * @hook
  *
  * @priority 20
  */
 public function template_redirect()
 {
     $headers = headers_list();
     if (preg_grep('/X-Pingback:/', $headers)) {
         header_remove('X-Pingback');
     }
 }
开发者ID:ssnepenthe,项目名称:hygieia,代码行数:14,代码来源:XMLRPCApi.php

示例8: start

 public function start($filename)
 {
     $ext = strtolower(strrchr($filename, '.'));
     $type = $this->mime_types[$ext];
     if ($ext == '.csv') {
         $this->seperator = ',';
     }
     set_time_limit(0);
     header('Content-Type: application/octet-stream');
     header('Content-Description: File Transfer');
     header('Content-Type: ' . $type);
     header('Content-Disposition: attachment;filename="' . $filename . '"');
     $seconds = 30;
     header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $seconds) . ' GMT');
     header('Cache-Control: max-age=' . $seconds . ', s-maxage=' . $seconds . ', must-revalidate, proxy-revalidate');
     session_cache_limiter(false);
     // Disable session_start() caching headers
     if (session_id()) {
         // Remove Pragma: no-cache generated by session_start()
         if (function_exists('header_remove')) {
             header_remove('Pragma');
         } else {
             header('Pragma:');
         }
     }
 }
开发者ID:speedwork,项目名称:helpers,代码行数:26,代码来源:Stream.php

示例9: renderRaw

 public function renderRaw()
 {
     $attachment = $this->_params['attachment'];
     if (!headers_sent() && function_exists('header_remove')) {
         header_remove('Expires');
         header('Cache-control: private');
     }
     $extension = XenForo_Helper_File::getFileExtension($attachment['filename']);
     $imageTypes = array('svg' => 'image/svg+xml', 'gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'png' => 'image/png');
     if (isset($imageTypes[$extension]) && ($attachment['width'] && $attachment['height'])) {
         $this->_response->setHeader('Content-type', $imageTypes[$extension], true);
         $this->setDownloadFileName($attachment['filename'], true);
     } else {
         $this->_response->setHeader('Content-type', 'application/octet-stream', true);
         $this->setDownloadFileName($attachment['filename']);
     }
     $this->_response->setHeader('ETag', '"' . $attachment['attach_date'] . '"', true);
     $this->_response->setHeader('Content-Length', $attachment['file_size'], true);
     $this->_response->setHeader('X-Content-Type-Options', 'nosniff');
     $attachmentFile = $this->_params['attachmentFile'];
     $options = XenForo_Application::getOptions();
     if ($options->SV_AttachImpro_XAR) {
         if (SV_AttachmentImprovements_AttachmentHelper::ConvertFilename($attachmentFile)) {
             if (XenForo_Application::debugMode() && $options->SV_AttachImpro_log) {
                 XenForo_Error::debug('X-Accel-Redirect:' . $attachmentFile);
             }
             $this->_response->setHeader('X-Accel-Redirect', $attachmentFile);
             return '';
         }
         if (XenForo_Application::debugMode() && $options->SV_AttachImpro_log) {
             XenForo_Error::debug('X-Accel-Redirect skipped');
         }
     }
     return new XenForo_FileOutput($attachmentFile);
 }
开发者ID:Xon,项目名称:XenForo-AttachmentImprovements,代码行数:35,代码来源:View.php

示例10: downloadFile

 function downloadFile()
 {
     global $wp_query;
     if ($wp_query->get('private_file_post_type') && $wp_query->get('private_file_meta_name') && $wp_query->get('private_file_post_id')) {
         $post_type = $wp_query->get('private_file_post_type');
         $post_id = $wp_query->get('private_file_post_id');
         $meta_name = $wp_query->get('private_file_meta_name');
         if ($post_type == $this->_config['post_type'] && $meta_name == $this->_config['meta_name']) {
             $access_function = $this->_config['access_control'];
             if (!$access_function()) {
                 header_remove();
                 http_response_code(403);
                 die('403');
             }
             $filename = $this->getFilePath($post_id);
             if (!$filename || !file_exists($filename)) {
                 header_remove();
                 http_response_code(404);
                 die('404');
             }
             $finfo = finfo_open(FILEINFO_MIME_TYPE);
             $mime_type = finfo_file($finfo, $filename);
             header('Content-type: ' . $mime_type);
             header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
             readfile($filename);
             do_action('download_private_file', array('post_type' => $post_type, 'meta_name' => $meta_name, 'post_id' => $post_id));
             add_post_meta($post_id, $this->_config['meta_name'] . ':download', get_current_user_id());
             die;
         }
     }
 }
开发者ID:hacklabr,项目名称:portal-timtec,代码行数:31,代码来源:PrivateFile.php

示例11: EventSkin

 protected function EventSkin()
 {
     $aParams = $this->GetParams();
     $sSkinName = array_shift($aParams);
     $sRelPath = implode('/', $aParams);
     $sOriginalFile = Config::Get('path.skins.dir') . $sSkinName . '/' . $sRelPath;
     if (F::File_Exists($sOriginalFile)) {
         $sAssetFile = F::File_GetAssetDir() . 'skin/' . $sSkinName . '/' . $sRelPath;
         if (F::File_Copy($sOriginalFile, $sAssetFile)) {
             if (headers_sent($sFile, $nLine)) {
                 $sUrl = F::File_GetAssetUrl() . 'skin/' . $sSkinName . '/' . $sRelPath;
                 if (strpos($sUrl, '?')) {
                     $sUrl .= '&' . uniqid();
                 } else {
                     $sUrl .= '?' . uniqid();
                 }
                 R::Location($sUrl);
             } else {
                 header_remove();
                 if ($sMimeType = F::File_MimeType($sAssetFile)) {
                     header('Content-Type: ' . $sMimeType);
                 }
                 echo file_get_contents($sAssetFile);
                 exit;
             }
         }
     }
     F::HttpHeader('404 Not Found');
     exit;
 }
开发者ID:AntiqS,项目名称:altocms,代码行数:30,代码来源:ActionAsset.class.php

示例12: GetFile

 private function GetFile($contentType, $cacheLife, $directory, $plugin, $filename)
 {
     $cacheDir = \Application::$pluginDirectory;
     $file = $cacheDir . "{$plugin}/{$directory}/{$filename}";
     if (is_file($file)) {
         $last_modified_time = filemtime($file);
         $etag = md5_file($file);
         header('Last-modified: ' . gmdate('D, d M Y H:i:s', $_SERVER['REQUEST_TIME']) . ' GMT');
         header("Etag: {$etag}");
         if ((isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && @strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) == $last_modified_time || isset($_SERVER['HTTP_IF_NONE_MATCH']) && @trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) {
             header("HTTP/1.1 304 Not Modified");
             exit;
         } else {
             header("Content-Type: {$contentType}");
             header('Cache-Control: public, max-age=' . $cacheLife * 60);
             header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $cacheLife * 60) . ' GMT');
             header_remove('Pragma');
         }
         return file_get_contents($file);
     } elseif (method_exists($this->application->GetPlugin($plugin), 'HookJSON')) {
         $file = $this->application->GetPlugin($plugin)->HookJSON($filename);
         if ($file != null && $file != false) {
             header("Content-Type: {$contentType}");
             header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
             return $file;
         }
     }
     return false;
 }
开发者ID:ehamrin,项目名称:cmsPlugin,代码行数:29,代码来源:PublicController.php

示例13: cache

 public static function cache($contentType = 'text/plain')
 {
     header_remove('Expires');
     header_remove('Pragma');
     header('Cache-Control: private, max-age=31415926');
     header('Content-Type: ' . $contentType);
 }
开发者ID:rlaskey,项目名称:dm-track,代码行数:7,代码来源:headers.php

示例14: indexAction

 /**
  * indexAction
  *
  * @param string $url
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function indexAction($url)
 {
     // pass Dependency Injection Container
     Zend_Registry::set('dic', $this->container);
     $rootDir = $this->get('kernel')->getRootDir();
     $bootstrap = $this->container->getParameter('zf1wrapper_bootstrap_path');
     // capture content from legacy application
     ob_start();
     include $rootDir . '/' . $bootstrap;
     $content = ob_get_clean();
     // capture http response code (requires PHP >= 5.4.0)
     if (function_exists('http_response_code') && http_response_code() > 0) {
         $code = http_response_code();
     } else {
         $code = 200;
     }
     // capture headers
     $headersSent = headers_list();
     $headers = array();
     array_walk($headersSent, function ($value, $key) use(&$headers) {
         $parts = explode(': ', $value);
         $headers[$parts[0]][] = $parts[1];
     });
     header_remove();
     return new Response($content, $code, $headers);
 }
开发者ID:mainlycode,项目名称:zf1wrapperbundle,代码行数:33,代码来源:DefaultController.php

示例15: logError

 /**
  * Logs PHP errors properly
  *
  * @access public
  * @param string $title    Error title
  * @param string $message  Short descriptive message
  * @param string $details  Advanced technical details
  * @param bool   $critical Stop script here
  * @return void
  */
 public function logError($title, $message, $details, $critical = false)
 {
     // Save log (error or critical error)
     $this->_saveLog($title, $message, $details, $critical ? 3 : 2);
     // Stop script if critical
     if ($critical) {
         // Remove any previous header
         header_remove();
         // Create header
         header('HTTP/1.0 500 Internal Server Error');
         // In development mode show errors on browser
         if ($this->_mode == 'development') {
             print "<!doctype html><html><head>";
             print "<style>body{font-family:Arial;}</style>";
             print "</head><body>";
             // Show the error in a nice box
             print "<div style='text-align: center;'>";
             print "<h1 style='color: #ff4800;'>" . $title . "</h1>";
             print "<p>" . $message . '</p><hr>';
             print "<p>" . $details . '</p>';
             print "</div>";
             // Close BODY and HTML tags
             print "</body></html>";
         } else {
             // If template defined and found, show
             if (ERROR_TEMPLATE && @file_exists(ERROR_TEMPLATE)) {
                 include_once ERROR_TEMPLATE;
             }
         }
         // Be done with it
         die;
     }
 }
开发者ID:roman-huliak,项目名称:log-system,代码行数:43,代码来源:logsystem.php


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