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


PHP JResponse::sendHeaders方法代码示例

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


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

示例1: 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

示例2: send

 /**
  * Send response in JSON-format
  * @param array $data
  * @param bool  $result
  */
 public function send(array $data = array(), $result = true)
 {
     $data['result'] = $result;
     JResponse::allowCache(false);
     JResponse::setHeader('Last-Modified', gmdate('D, d M Y H:i:s', time()) . ' GMT', true);
     JResponse::setHeader('Content-Type', 'application/json; charset=utf-8', true);
     JResponse::sendHeaders();
     jexit(json_encode($data));
 }
开发者ID:JBZoo,项目名称:JBZoo-CCK-Free,代码行数:14,代码来源:jbajax.php

示例3: 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

示例4: sendResponse

 /**
  * Method to handle a send a JSON response. The body parameter
  * can be a JException object for when an error has occurred or
  * a JObject for a good response.
  *
  * @param	object	$body	JObject on success, JException on failure.
  * @return	void
  */
 public function sendResponse($body)
 {
     // Check if we need to send an error code.
     if (JError::isError($body)) {
         // Send the appropriate error code response.
         JResponse::setHeader('status', $body->getCode());
         JResponse::sendHeaders();
     }
     // Send the JSON response.
     echo json_encode(new UsersLevelResponse($body));
     // Close the application.
     $app = JFactory::getApplication();
     $app->close();
 }
开发者ID:joebushi,项目名称:joomla,代码行数:22,代码来源:level.json.php

示例5: __construct

 public function __construct()
 {
     parent::__construct();
     $stateModel = VmModel::getModel('state');
     $states = array();
     //retrieving countries id
     $countries = vRequest::getString('virtuemart_country_id');
     $countries = explode(',', $countries);
     foreach ($countries as $country) {
         $states[$country] = $stateModel->getStates((int) $country, true, true);
     }
     JResponse::setHeader("Content-type", "application/json");
     JResponse::sendHeaders();
     echo json_encode($states);
     jExit();
 }
开发者ID:virtuemart-fr,项目名称:virtuemart-fr,代码行数:16,代码来源:state.php

示例6: display

 /**
  * Method to render the plugin datas
  * this is an entry point to plugin to easy renders json or html
  *
  *
  * @access    public
  */
 function display($cachable = false, $urlparams = false)
 {
     if (!($type = vRequest::getCmd('vmtype', NULL))) {
         $type = vRequest::getCmd('type', 'vmcustom');
     }
     $typeWhiteList = array('vmcustom', 'vmcalculation', 'vmuserfield', 'vmpayment', 'vmshipment');
     if (!in_array($type, $typeWhiteList)) {
         return FALSE;
     }
     $name = vRequest::getCmd('name', 'none');
     $nameBlackList = array('plgVmValidateCouponCode', 'plgVmRemoveCoupon', 'none');
     if (in_array($name, $nameBlackList)) {
         echo 'You got logged';
         return FALSE;
     }
     JPluginHelper::importPlugin($type, $name);
     $dispatcher = JDispatcher::getInstance();
     // if you want only one render simple in the plugin use jExit();
     // or $render is an array of code to echo as html or json Objects!
     $render = NULL;
     $dispatcher->trigger('plgVmOnSelfCallFE', array($type, $name, &$render));
     if ($render) {
         // Get the document object.
         $document = JFactory::getDocument();
         if (vRequest::getCmd('cache') == 'no') {
             JResponse::setHeader('Cache-Control', 'no-cache, must-revalidate');
             JResponse::setHeader('Expires', 'Mon, 6 Jul 2000 10:00:00 GMT');
         }
         $format = vRequest::getCmd('format', 'json');
         if ($format == 'json') {
             $document->setMimeEncoding('application/json');
             // Change the suggested filename.
             JResponse::setHeader('Content-Disposition', 'attachment;filename="' . $type . '.json"');
             JResponse::setHeader("Content-type", "application/json");
             JResponse::sendHeaders();
             echo json_encode($render);
             jExit();
         } else {
             echo $render;
             jExit();
         }
     } else {
     }
 }
开发者ID:virtuemart-fr,项目名称:virtuemart-fr,代码行数:51,代码来源:plugin.php

示例7: send

 /**
  * Send response in JSON-format
  * @param array $data
  * @param bool  $result
  */
 public function send(array $data = array(), $result = true)
 {
     $data['result'] = $result;
     if (!isset($data['message'])) {
         $data['message'] = false;
     }
     if ($this->app->jbversion->joomla('3')) {
         $app = JFactory::getApplication();
         $app->allowCache(false);
         $app->setHeader('Last-Modified', gmdate('D, d M Y H:i:s', time()) . ' GMT', true);
         $app->setHeader('Content-Type', 'application/json; charset=utf-8', true);
         $app->sendHeaders();
     } else {
         JResponse::allowCache(false);
         JResponse::setHeader('Last-Modified', gmdate('D, d M Y H:i:s', time()) . ' GMT', true);
         JResponse::setHeader('Content-Type', 'application/json; charset=utf-8', true);
         JResponse::sendHeaders();
     }
     if (JDEBUG) {
         $data['mpu'] = round(memory_get_peak_usage(true) / 1024 / 1024, 2) . ' M';
     }
     jexit(json_encode($data));
 }
开发者ID:alexmixaylov,项目名称:real,代码行数:28,代码来源:jbajax.php

示例8: sendHeaders

 public function sendHeaders()
 {
     if (version_compare($this->version, '3.2', 'ge')) {
         JFactory::getApplication()->sendHeaders();
     } else {
         JResponse::sendHeaders();
     }
 }
开发者ID:01J,项目名称:topm,代码行数:8,代码来源:platform.php

示例9: download

 public function download()
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationAdministrator */
     $type = $this->input->get->getCmd("type");
     $model = $this->getModel();
     try {
         switch ($type) {
             case "locations":
                 $output = $model->getLocations();
                 $fileName = "locations.xml";
                 break;
             case "currencies":
                 $output = $model->getCurrencies();
                 $fileName = "currencies.xml";
                 break;
             case "countries":
                 $output = $model->getCountries();
                 $fileName = "countries.xml";
                 break;
             case "states":
                 $output = $model->getStates();
                 $fileName = "states.xml";
                 break;
             default:
                 // Error
                 $output = "";
                 $fileName = "error.xml";
                 break;
         }
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception(JText::_('COM_VIRTUALCURRENCY_ERROR_SYSTEM'));
     }
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.path');
     jimport('joomla.filesystem.archive');
     $tmpFolder = JPath::clean($app->get("tmp_path"));
     $date = new JDate();
     $date = $date->format("d_m_Y_H_i_s");
     $archiveName = JFile::stripExt(basename($fileName)) . "_" . $date;
     $archiveFile = $archiveName . ".zip";
     $destination = $tmpFolder . DIRECTORY_SEPARATOR . $archiveFile;
     // compression type
     $zipAdapter = JArchive::getAdapter('zip');
     $filesToZip[] = array('name' => $fileName, 'data' => $output);
     $zipAdapter->create($destination, $filesToZip, array());
     $filesize = filesize($destination);
     JResponse::setHeader('Content-Type', 'application/octet-stream', true);
     JResponse::setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
     JResponse::setHeader('Content-Transfer-Encoding', 'binary', true);
     JResponse::setHeader('Pragma', 'no-cache', true);
     JResponse::setHeader('Expires', '0', true);
     JResponse::setHeader('Content-Disposition', 'attachment; filename=' . $archiveFile, true);
     JResponse::setHeader('Content-Length', $filesize, true);
     $doc = JFactory::getDocument();
     $doc->setMimeEncoding('application/octet-stream');
     JResponse::sendHeaders();
     echo file_get_contents($destination);
     JFactory::getApplication()->close();
 }
开发者ID:bellodox,项目名称:VirtualCurrency,代码行数:62,代码来源:export.raw.php

示例10: toString

 /**
  * Sends all headers prior to returning the string
  *
  * @access public
  * @param boolean 	$compress	If true, compress the data
  * @return string
  */
 function toString($compress = false)
 {
     $data = JResponse::getBody();
     // Don't compress something if the server is going todo it anyway. Waste of time.
     if ($compress && !ini_get('zlib.output_compression') && ini_get('output_handler') != 'ob_gzhandler') {
         $data = JResponse::_compress($data);
     }
     if (JResponse::allowCache() === false) {
         JResponse::setHeader('Expires', 'Mon, 1 Jan 2001 00:00:00 GMT', true);
         // Expires in the past
         JResponse::setHeader('Last-Modified', gmdate("D, d M Y H:i:s") . ' GMT', true);
         // Always modified
         JResponse::setHeader('Cache-Control', 'no-store, no-cache, must-revalidate', true);
         // Extra CYA
         JResponse::setHeader('Cache-Control', 'post-check=0, pre-check=0', false);
         // HTTP/1.1
         JResponse::setHeader('Pragma', 'no-cache');
         // HTTP 1.0
     }
     JResponse::sendHeaders();
     return $data;
 }
开发者ID:kaantunc,项目名称:MYK-BOR,代码行数:29,代码来源:response.php

示例11: sendHeaders

 public function sendHeaders()
 {
     JResponse::sendHeaders();
 }
开发者ID:01J,项目名称:skazkipronebo,代码行数:4,代码来源:platform.php

示例12: fopen

    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)) {
    if (!$limit_bw) {
        print fread($fh, filesize($file));
    } else {
        $time_start = microtime(true);
        print fread($fh, $packet_size);
        $time_stop = microtime(true);
        $time_difference = $time_stop - $time_start;
        if ($time_difference < $packet_interval) {
开发者ID:Jougito,项目名称:DynWeb,代码行数:31,代码来源:streamer.php

示例13: 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

示例14: sendResponse

	/**
	 * Method to handle a send a JSON response. The data parameter
	 * can be a JException object for when an error has occurred or
	 * a JObject for a good response.
	 *
	 * @param	object	$response	JObject on success, JException on failure.
	 *
	 * @return	void
	 * @since	1.6
	 */
	public function sendResponse($response)
	{
		// Check if we need to send an error code.
		if (JError::isError($response)) {
			// Send the appropriate error code response.
			JResponse::setHeader('status', $response->getCode());
			JResponse::setHeader('Content-Type', 'application/json; charset=utf-8');
			JResponse::sendHeaders();
		}

		// Send the JSON response.
		echo json_encode(new JInstallationJsonResponse($response));

		// Close the application.
		$app = JFactory::getApplication();
		$app->close();
	}
开发者ID:realityking,项目名称:JAJAX,代码行数:27,代码来源:setup.json.php

示例15: 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($playlistFileName, $playlistType, $playlistSize)
 {
     //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', $playlistType, true);
     JResponse::setHeader('Content-Disposition', 'inline; filename=' . $playlistFileName . ';', true);
     JResponse::setHeader('Content-Range', 'bytes 0-' . ($playlistSize - 1) . '/' . $playlistSize, true);
     JResponse::setHeader('Content-Length', (string) $playlistSize, 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,代码行数:36,代码来源:playlist.php


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