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


PHP JResponse::clearHeaders方法代码示例

本文整理汇总了PHP中JResponse::clearHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP JResponse::clearHeaders方法的具体用法?PHP JResponse::clearHeaders怎么用?PHP JResponse::clearHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JResponse的用法示例。


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

示例1: testRender

	/**
	 * Test...
	 *
	 * @todo Implement testRender().
	 *
	 * @return void
	 */
	public function testRender()
	{
		$this->object = new JDocumentRaw;
		JResponse::clearHeaders();

		$this->object->setBuffer('Unit Test Buffer');

		$this->assertThat(
			$this->object->render(),
			$this->equalTo('Unit Test Buffer')
		);

		$headers = JResponse::getHeaders();

		foreach ($headers as $head)
		{
			if ($head['name'] == 'Expires')
			{
				$this->assertThat(
					$head['value'],
					$this->stringContains('GMT')
				);
			}
		}
	}
开发者ID:robschley,项目名称:joomla-platform,代码行数:32,代码来源:JDocumentRAWTest.php

示例2: resetDocumentType

 /**
  * Resets the document type to format=raw 
  *
  * @return void
  * @since 0.1
  * @todo Figure out if there is a better way to do this
  */
 private function resetDocumentType()
 {
     $document =& JFactory::getDocument();
     $raw =& JDocument::getInstance('raw');
     $document = $raw;
     JResponse::clearHeaders();
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:14,代码来源:http.php

示例3: append

 /**
  * Method for to append new track into database
  *
  */
 function append()
 {
     $dispatcher = JDispatcher::getInstance();
     // Send the appropriate error code response.
     JResponse::clearHeaders();
     JResponse::setHeader('Content-Type', 'application/json; charset=utf-8');
     JResponse::sendHeaders();
     $total = $_GET['total'];
     $one_procent = 1 / ($total / 100);
     $curr_index = number_format($_GET['total'] * $_GET['status'] / 100, 0, '', '');
     $path_from_cache = explode('*|*', JFactory::getApplication()->getUserState('com_playjoom.path.array'));
     $php_array['status'] = $_GET['status'] + $one_procent;
     //$dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__.":".__LINE__, 'message' => 'Add track no '.$curr_index.' in path: '.base64_decode(($path_from_cache[$curr_index] - 1)), 'priority' => JLog::INFO, 'section' => 'admin')));
     if (isset($path_from_cache[$curr_index])) {
         $model = $this->getModel('savetracks');
         $model->AddTrackItem(base64_decode($path_from_cache[$curr_index]), 'audio');
     }
     // Bei 100% ist Schluss ;)
     if ($php_array['status'] > 100) {
         $php_array['status'] = 100;
     }
     if ($php_array['status'] != 100 && isset($path_from_cache[$curr_index])) {
         $php_array['message'] = JText::_('COM_PLAYJOOM_SAVETRACKS_CURRENT_STATUS') . ' ' . ($curr_index + 1) . ' / ' . $total . ' - ' . round($php_array['status'], 1) . '%';
         $php_array['message_path'] = JText::_('COM_PLAYJOOM_SAVETRACKS_PATH_STATUS') . ' ' . base64_decode($path_from_cache[$curr_index]);
     } else {
         //Clear UserStates in session
         JFactory::getApplication()->setUserState('com_playjoom.savetracks', null);
         JFactory::getApplication()->setUserState('com_playjoom.path.array', null);
         JFactory::getApplication()->setUserState('com_playjoom.path.data', null);
         $php_array['message'] = 'done';
     }
     // Output as PHP arrays as JSON Objekt
     echo json_encode($php_array);
 }
开发者ID:TFToto,项目名称:playjoom-builds,代码行数:38,代码来源:savetracks.raw.php

示例4: render

 /**
  * Display the application.
  */
 public function render()
 {
     $user = JFactory::getUser();
     $conf = JFactory::getConfig();
     if ($user->guest || !JFactory::getUser()->authorise('core.admin', 'com_cache')) {
         //TODO change this to the the proper access acl
         echo JText::_('Unauthorized');
         exit;
     }
     $logfile = $this->input->getPath('logfile', null);
     if (is_null($logfile)) {
         echo JText::_('Log not found.');
         exit;
     }
     $logfile_path = JPATH_ROOT . '/logs/' . $logfile;
     if (!is_file($logfile_path)) {
         echo JText::_('Log not found.');
         exit;
     }
     JResponse::clearHeaders();
     header('Content-type: application/octet-stream');
     header('Content-Disposition: attachment; filename=' . pathinfo($logfile, PATHINFO_FILENAME) . '.log');
     header('Content-Length: ' . filesize($logfile_path) . ';');
     header('Content-Transfer-Encoding: binary');
     readfile($logfile_path);
     exit;
 }
开发者ID:interfaceslivres,项目名称:ccmd-ufpb,代码行数:30,代码来源:application.php

示例5: display

 function display()
 {
     $doDisplay = true;
     // Set a default view if none exists
     if (!JRequest::getCmd('view')) {
         JRequest::setVar('view', 'tickets');
     }
     // Handle displaying an attachment
     if (JRequest::getCmd('view') == 'attachment') {
         $model = $this->getModel('attachment');
         $result = $model->download(JRequest::getVar('ArticleID', '', '', 'integer'), JRequest::getVar('AtmID', '', '', 'integer'));
         if (array_key_exists('data', $result)) {
             $document =& JFactory::getDocument();
             $doc =& JDocument::getInstance('raw');
             $document = $doc;
             JResponse::clearHeaders();
             $document->setMimeEncoding($result['data']->ContentType);
             JResponse::setHeader('Content-length', $result['data']->FilesizeRaw, true);
             $fn = preg_replace('/"/', '\\"', $result['data']->Filename);
             JResponse::setHeader('Content-disposition', sprintf('attachment;filename="%s"', $fn), true);
             $document->render();
             echo $result['data']->Content;
             $doDisplay = false;
         }
     }
     if ($doDisplay) {
         parent::display();
     }
 }
开发者ID:noamk,项目名称:OTRS-Joomla-Gateway,代码行数:29,代码来源:controller.php

示例6: display

 function display($tpl = null)
 {
     $this->msg = $this->get('Msg');
     $document = JFactory::getDocument();
     $document->setMimeEncoding('text/plain');
     # $document->setType('xml');
     # $document->setBase('tournament');
     JResponse::clearHeaders();
     # JResponse::setHeader('Content-Disposition', 'attachment; filename="tournament.xml";');
     parent::display($tpl);
 }
开发者ID:ChessLeagueManager,项目名称:com_clm_android,代码行数:11,代码来源:view.raw.php

示例7: display

 /**
  * Execute and display a template script.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise a JError object.
  */
 public function display($tpl = Null)
 {
     $app = JFactory::getApplication();
     $jinput = JFactory::getApplication()->input;
     $date = JFactory::getDate();
     $layout = $jinput->get('layout');
     if ($layout == 'saveTables') {
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select($db->quoteName('manifest_cache'));
         $query->from($db->quoteName('#__extensions'));
         $query->where($db->quoteName('element') . " = " . $db->quote('com_bwpostman'));
         $db->SetQuery($query);
         $manifest = json_decode($db->loadResult(), true);
         $version = str_replace('.', '_', $manifest['version']);
         $filename = "BwPostman_" . $version . "_Tables_" . $date->format("Y-m-d_H:i") . '.xml';
         $mime_type = "application/xml";
         // Maybe we need other headers depending on browser type...
         jimport('joomla.environment.browser');
         $browser = JBrowser::getInstance();
         $user_browser = $browser->getBrowser();
         JResponse::clearHeaders();
         JResponse::setHeader('Content-Type', $mime_type, true);
         // Joomla will overwrite this...
         JResponse::setHeader('Content-Disposition', "attachment; filename=\"{$filename}\"", true);
         JResponse::setHeader('Expires', gmdate('D, d M Y H:i:s') . ' GMT', true);
         JResponse::setHeader('Pragma', 'no-cache', true);
         if ($user_browser == "msie") {
             JResponse::setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
             JResponse::setHeader('Pragma', 'public', true);
         }
         // Joomla overwrites content-type, we can't use JResponse::setHeader()
         $document = JFactory::getDocument();
         $document->setMimeEncoding("application/xml");
         @ob_end_clean();
         ob_start();
         JResponse::sendHeaders();
         // Get the export data
         $model = $this->getModel('maintenance');
         readfile($model->saveTables(false));
     }
     if ($layout == 'doRestore') {
         $model = $this->getModel();
         $dest = $app->getUserState('com_bwpostman.maintenance.dest', '');
         $model->restoreTables($dest);
     }
     if ($layout == 'checkTables') {
         $model = $this->getModel();
         echo '<div class="modal" rel="{size: {x: 700, y: 500}}">';
         $model->checkTables();
         echo '</div>';
     }
 }
开发者ID:RomanaBW,项目名称:BwPostman,代码行数:60,代码来源:view.raw.php

示例8: testRender

 /**
  * Test Render
  *
  * @todo Implement testRender().
  *
  * @return void
  */
 public function testRender()
 {
     JResponse::clearHeaders();
     $this->object->setBuffer('Unit Test Buffer');
     $this->assertThat($this->object->render(), $this->equalTo('Unit Test Buffer'), 'We did not get the buffer back properly');
     $headers = JResponse::getHeaders();
     $disposition = false;
     foreach ($headers as $head) {
         if ($head['name'] == 'Content-disposition') {
             $this->assertThat($head['value'], $this->stringContains('.xml'), 'The content disposition did not include json extension');
             $disposition = true;
         }
     }
     $this->assertThat($disposition, $this->equalTo(true), 'No Content-disposition headers');
 }
开发者ID:ZerGabriel,项目名称:joomla-platform,代码行数:22,代码来源:JDocumentXMLTest.php

示例9: testRender

	/**
	 * Test...
	 *
	 * @todo Implement testRender().
	 *
	 * @return void
	 */
	public function testRender()
	{
		JResponse::clearHeaders();
		JResponse::allowCache(true);

		$this->object->setBuffer('Unit Test Buffer');

		$this->assertThat(
			$this->object->render(),
			$this->equalTo('Unit Test Buffer'),
			'We did not get the buffer back properly'
		);

		$headers = JResponse::getHeaders();

		$expires = false;
		$disposition = false;

		foreach ($headers as $head)
		{
			if ($head['name'] == 'Expires')
			{
				$this->assertThat(
					$head['value'],
					$this->stringContains('GMT'),
					'The expires header was not set properly (was parent::render called?)'
				);
				$expires = true;
			}

			if ($head['name'] == 'Content-disposition')
			{
				$this->assertThat(
					$head['value'],
					$this->stringContains('.json'),
					'The content disposition did not include json extension'
				);
				$disposition = true;
			}
		}
		$this->assertThat(
			JResponse::allowCache(),
			$this->isFalse(),
			'Caching was not disabled'
		);
	}
开发者ID:robschley,项目名称:joomla-platform,代码行数:53,代码来源:JDocumentJSONTest.php

示例10: testRender

 /**
  * Tests the JDocumentImage::render method.
  *
  * @covers  JDocumentImage::render
  *
  * @return  void
  */
 public function testRender()
 {
     JResponse::clearHeaders();
     $testFiles = array('jpg' => array('file' => 'logo.jpg', 'mime' => 'image/jpeg'), 'jpeg' => array('file' => 'logo.jpeg', 'mime' => 'image/jpeg'), 'gif' => array('file' => 'logo.gif', 'mime' => 'image/gif'), 'png' => array('file' => 'logo.png', 'mime' => 'image/png'), 'bmp' => array('file' => 'logo.png', 'mime' => 'image/png'));
     foreach ($testFiles as $type => $info) {
         // Set type
         JFactory::$application->input->set('type', $type);
         $buffer = file_get_contents(__DIR__ . '/' . $info['file']);
         // Render
         $this->object->setBuffer($buffer);
         $returnBuffer = $this->object->render();
         // Check buffer return
         $this->assertThat($returnBuffer, $this->equalTo($buffer), 'JDocumentImage::render: Buffer does not match for type `' . $type . '`');
         // Check Mime
         $this->assertThat($this->object->_mime, $this->equalTo($info['mime']), 'JDocumentImage::render: Mime does not match for type `' . $type . '`');
     }
     // Chek Charset
     $this->assertThat($this->object->_charset, $this->isNull(), 'JDocumentImage::render Charset is not null');
 }
开发者ID:ZerGabriel,项目名称:joomla-platform,代码行数:26,代码来源:JDocumentImageTest.php

示例11: setHeader

 /**
  * Method for sending the page header
  *
  * @param string $playlistFileName Name of the playlist file
  * @param string $playlistType     Mimetype of the playlist
  * @param int    $playlistSize     Data size of the created playlist
  *
  * @return void
  */
 public function setHeader($filename, $archiveType, $archiveSize)
 {
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Set Header for download filename: ' . $filename . ', archive type: ' . $archiveType . ', archive size: ' . $archiveSize, 'priority' => JLog::ERROR, 'section' => 'site')));
     //Setup web server
     if (isset($_SERVER['SERVER_SOFTWARE'])) {
         $sf = $_SERVER['SERVER_SOFTWARE'];
     } else {
         $sf = getenv('SERVER_SOFTWARE');
     }
     if (!strpos($sf, 'IIS')) {
         @apache_setenv('no-gzip', 1);
     }
     @ini_set('zlib.output_compression', 0);
     ignore_user_abort(false);
     JResponse::clearHeaders();
     header("HTTP/1.1 200 OK");
     JResponse::setHeader('Accept-Range', 'bytes', true);
     JResponse::setHeader('X-Pad', 'avoid browser bug');
     JResponse::setHeader('Content-Type', $archiveType, true);
     JResponse::setHeader('Content-Disposition', 'inline; filename=' . $filename . ';', true);
     JResponse::setHeader('Content-Range', 'bytes 0-' . ($archiveSize - 1) . '/' . $archiveSize, true);
     JResponse::setHeader('Content-Length', (string) $archiveSize, true);
     JResponse::setHeader('Content-Transfer-Encoding', 'binary', true);
     JResponse::setHeader('Cache-Control', 'no-cache, must-revalidate', true);
     JResponse::setHeader('Pragma', 'no-cache', true);
     JResponse::setHeader('Connection', 'close', true);
     JResponse::sendHeaders();
 }
开发者ID:TFToto,项目名称:playjoom-builds,代码行数:38,代码来源:download.php

示例12: download

 function download()
 {
     jimport('joomla.filesystem.file');
     $session = JFactory::getSession();
     $mainframe = JFactory::getApplication();
     jimport('joomla.filesystem.file');
     $k2_params = JComponentHelper::getParams('com_k2');
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2/tables');
     $id = JRequest::getInt('orderItem');
     $attachment = JTable::getInstance('K2Attachment', 'Table');
     if ($mainframe->isSite()) {
         $token = JRequest::getVar('orderItem');
         $check = JString::substr($token, JString::strpos($token, '_') + 1);
         if ($check != JApplication::getHash($id . $session->getToken())) {
             JError::raiseError(404, JText::_('K2_NOT_FOUND'));
         }
     }
     $attachment->load($id);
     $path = $k2_params->get('attachmentsFolder', NULL);
     if (is_null($path)) {
         $savepath = JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'attachments';
     } else {
         $savepath = $path;
     }
     $file = $savepath . DS . $attachment->filename;
     if (JFile::exists($file)) {
         require_once JPATH_ADMINISTRATOR . '/components/com_k2/lib/class.upload.php';
         $handle = new Upload($file);
         if ($mainframe->isSite()) {
             $attachment->hit();
         }
         $len = filesize($file);
         $filename = basename($file);
         ob_end_clean();
         JResponse::clearHeaders();
         JResponse::setHeader('Pragma', 'public', true);
         JResponse::setHeader('Expires', '0', true);
         JResponse::setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
         JResponse::setHeader('Content-Type', $handle->file_src_mime, true);
         JResponse::setHeader('Content-Disposition', 'attachment; filename=' . $filename . ';', true);
         JResponse::setHeader('Content-Transfer-Encoding', 'binary', true);
         JResponse::setHeader('Content-Length', $len, true);
         JResponse::sendHeaders();
         echo JFile::read($file);
     } else {
         echo JText::_('K2_FILE_DOES_NOT_EXIST');
     }
     $mainframe->close();
 }
开发者ID:A-Bush,项目名称:pprod,代码行数:49,代码来源:downloads.php

示例13: explode

$file = $pieces[$count - 1];
$pieces = explode('?', $file);
$file = $pieces[0];
//$file	= str_replace( JURI::root() , '', $file); var_dump($file);
$file = JPATH::clean(JPATH_BASE . '/' . urldecode($file));
$fileName = JFile::getName($file);
if (!JFile::exists($file)) {
    echo 'file not found: ' . $fileName;
    exit;
}
$fh = fopen($file, 'rb') or die('cannot open file: ' . $fileName);
$fileSize = filesize($file) - ($pos > 0 ? $pos + 1 : 0);
fseek($fh, $pos);
$binary_header = strtoupper(JFile::getExt($file)) . pack('C', 1) . pack('C', 1) . pack('N', 9) . pack('N', 9);
session_cache_limiter('none');
JResponse::clearHeaders();
JResponse::setHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT', true);
JResponse::setHeader('Last-Modified', gmdate("D, d M Y H:i:s") . ' GMT', true);
JResponse::setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true);
JResponse::setHeader('Pragma', 'no-cache', true);
JResponse::setHeader('Content-Disposition', 'attachment; filename="' . $fileName . '"', true);
JResponse::setHeader('Content-Length', $pos > 0 ? $fileSize + 13 : $fileSize, true);
JResponse::setHeader('Content-Type', 'video/x-flv', true);
JResponse::sendHeaders();
if ($pos > 0) {
    print $binary_header;
}
$limit_bw = true;
$packet_size = 90 * 1024;
$packet_interval = 0.3;
while (!feof($fh)) {
开发者ID:Jougito,项目名称:DynWeb,代码行数:31,代码来源:streamer.php

示例14: download

 function download()
 {
     $mainframe = JFactory::getApplication();
     $user = JFactory::getUser();
     jimport('joomla.filesystem.file');
     $params = JComponentHelper::getParams('com_k2');
     $id = JRequest::getInt('id');
     JPluginHelper::importPlugin('k2');
     $dispatcher = JDispatcher::getInstance();
     $attachment = JTable::getInstance('K2Attachment', 'Table');
     if ($mainframe->isSite()) {
         $token = JRequest::getVar('id');
         $check = JString::substr($token, JString::strpos($token, '_') + 1);
         $hash = version_compare(JVERSION, '3.0', 'ge') ? JApplication::getHash($id) : JUtility::getHash($id);
         if ($check != $hash) {
             JError::raiseError(404, JText::_('K2_NOT_FOUND'));
         }
     }
     $attachment->load($id);
     // For front-end ensure that user has access to the item
     if ($mainframe->isSite()) {
         $item = JTable::getInstance('K2Item', 'Table');
         $item->load($attachment->itemID);
         $category = JTable::getInstance('K2Category', 'Table');
         $category->load($item->catid);
         if (!$item->id || !$category->id) {
             JError::raiseError(404, JText::_('K2_NOT_FOUND'));
         }
         if (K2_JVERSION == '15' && ($item->access > $user->get('aid', 0) || $category->access > $user->get('aid', 0))) {
             JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
         }
         if (K2_JVERSION != '15' && (!in_array($category->access, $user->getAuthorisedViewLevels()) || !in_array($item->access, $user->getAuthorisedViewLevels()))) {
             JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
         }
     }
     $dispatcher->trigger('onK2BeforeDownload', array(&$attachment, &$params));
     $path = $params->get('attachmentsFolder', NULL);
     if (is_null($path)) {
         $savepath = JPATH_ROOT . DS . 'media' . DS . 'k2' . DS . 'attachments';
     } else {
         $savepath = $path;
     }
     $file = $savepath . DS . $attachment->filename;
     if (JFile::exists($file)) {
         require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'lib' . DS . 'class.upload.php';
         $handle = new Upload($file);
         $dispatcher->trigger('onK2AfterDownload', array(&$attachment, &$params));
         if ($mainframe->isSite()) {
             $attachment->hit();
         }
         $len = filesize($file);
         $filename = basename($file);
         ob_end_clean();
         JResponse::clearHeaders();
         JResponse::setHeader('Pragma', 'public', true);
         JResponse::setHeader('Expires', '0', true);
         JResponse::setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
         JResponse::setHeader('Content-Type', $handle->file_src_mime, true);
         JResponse::setHeader('Content-Disposition', 'attachment; filename=' . $filename . ';', true);
         JResponse::setHeader('Content-Transfer-Encoding', 'binary', true);
         JResponse::setHeader('Content-Length', $len, true);
         JResponse::sendHeaders();
         echo JFile::read($file);
     } else {
         echo JText::_('K2_FILE_DOES_NOT_EXIST');
     }
     $mainframe->close();
 }
开发者ID:educakanchay,项目名称:educa,代码行数:68,代码来源:item.php

示例15: testClearHeaders

 /**
  * Test...
  *
  * @return void
  */
 public function testClearHeaders()
 {
     JResponse::setHeader('somename', 'somevalue');
     JResponse::clearHeaders();
     $this->assertThat(count(JResponse::getHeaders()), $this->equalTo(0));
 }
开发者ID:shoffmann52,项目名称:install-from-web-server,代码行数:11,代码来源:JResponseTest.php


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