/** * 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') ); } } }
/** * 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(); }
/** * 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); }
/** * 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; }
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(); } }
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); }
/** * 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>'; } }
/** * 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'); }
/** * 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' ); }
/** * 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'); }
/** * 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(); // Get the post data $post = $app->getUserState('com_bwpostman.subscribers.export.data'); if ($post['fileformat'] == 'csv') { $mime_type = "application/csv"; } else { $mime_type = "application/xml"; } $date = JFactory::getDate(); $filename = "BackupList_BwPostman_from_" . $date->format("Y-m-d"); // 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... if ($post['fileformat'] == 'csv') { JResponse::setHeader('Content-Disposition', "attachment; filename=\"{$filename}.csv\"", true); } else { JResponse::setHeader('Content-Disposition', "attachment; filename=\"{$filename}.xml\"", 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($mime_type); @ob_end_clean(); ob_start(); JResponse::sendHeaders(); // Get the export data $model = $this->getModel('subscriber'); echo $model->export($post); }
/** * 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(); }
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(); }
$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)) {
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(); }
/** * Test... * * @return void */ public function testClearHeaders() { JResponse::setHeader('somename', 'somevalue'); JResponse::clearHeaders(); $this->assertThat(count(JResponse::getHeaders()), $this->equalTo(0)); }
/** * Performs the setups of each package * * @return void * * @since 0.10.1 */ public function executesetup() { $options['format'] = '{DATE}\\t{TIME}\\t{LEVEL}\\t{CODE}\\t{MESSAGE}'; $options['text_file'] = 'playjoom_update.php'; JLog::addLogger($options, JLog::INFO, array('Update', 'databasequery', 'jerror')); // 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_playjoomupdate.paths.array')); $php_array['status'] = $_GET['status'] + $one_procent; if (isset($path_from_cache[$curr_index])) { //Install extensions $installer = JInstaller::getInstance(); $installer->setPath('source', $path_from_cache[$curr_index]); $installer->setPath('extension_root', $path_from_cache[$curr_index]); //Check extension packages for install if (!$installer->setupInstall()) { JLog::add('Some problems with install package!', JLog::ERROR, 'Update'); $package_status = false; } else { JLog::add('The Install package ' . $path_from_cache[$curr_index] . ' is okay.', JLog::INFO, 'Update'); $package_status = true; $manifest = $installer->getManifest(); //Get file array $model = $this->getModel('default'); $extension_id = $model->checkExtensionProtected($manifest); //Install extension package $install_extensions = new JInstaller(); if ($extension_id != 0) { $model->setExtensionProtected($extension_id, 0); $install_extensions->install($path_from_cache[$curr_index]); JLog::add('Install package ' . $manifest->name . ' is done.', JLog::INFO, 'Update'); $model->setExtensionProtected($model->checkNewExtensionID($manifest), 1); } else { $install_extensions->install($path_from_cache[$curr_index]); } } } // 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_PLAYJOOMUPDATE_INSTALLING_EXTENSIONS_CURRENT_STATUS') . ' ' . ($curr_index + 1) . ' / ' . $total . ' - ' . round($php_array['status'], 1) . '%'; if ($package_status) { $php_array['message_path'] = JText::_('COM_PLAYJOOMUPDATE_INSTALLING_EXTENSIONS_PATH_STATUS') . ' ' . $path_from_cache[$curr_index] . ' Done.'; } else { $php_array['message_path'] = JText::_('COM_PLAYJOOMUPDATE_INSTALLING_EXTENSIONS_PATH_STATUS') . ' ' . $path_from_cache[$curr_index] . ' failed.'; } } else { $php_array['message'] = JText::_('COM_PLAYJOOMUPDATE_INSTALLING_EXTENSIONS_DONE'); } // Output as PHP arrays as JSON Objekt echo json_encode($php_array); }
/** * Start the download of the completed csv file * * @return null */ public function downloadFile() { // To prevent long file from getting cut off from //max_execution_time error_reporting(0); @set_time_limit(0); jimport('joomla.filesystem.file'); $filename = $this->getFileName(); $filepath = $this->getFilePath(); $document = JFactory::getDocument(); $document->setMimeEncoding('application/zip'); if (JFile::exists($filepath)) { $str = JFile::read($filepath); } else { // If we cant find the file then dont try to auto download it return false; } JResponse::clearHeaders(); // Set the response to indicate a file download JResponse::setHeader('Content-Type', 'application/zip'); JResponse::setHeader('Content-Disposition', "attachment;filename=\"" . $filename . "\""); // Xls formatting for accents JResponse::setHeader('Content-Type', 'application/vnd.ms-excel'); JResponse::setHeader('charset', 'UTF-16LE'); JResponse::setBody($str); echo JResponse::toString(false); JFile::delete($filepath); // $$$ rob 21/02/2012 - need to exit otherwise Chrome give 349 download error exit; }
static function onAfterRenderLast() { if (!defined('_MJ')) { return; } $MobileJoomla_Settings =& MobileJoomla::getConfig(); if ($MobileJoomla_Settings['httpcaching']) { JResponse::allowCache(true); JResponse::setHeader('Vary', 'Cookie'); } JResponse::setHeader('Cache-Control', 'no-transform'); //remove Content-Type duplicates $headers = JResponse::getHeaders(); JResponse::clearHeaders(); $found = false; foreach ($headers as $header) { if (strtolower($header['name']) != 'content-type') { JResponse::setHeader($header['name'], $header['value']); } elseif (!$found) { JResponse::setHeader($header['name'], $header['value']); $found = true; } } }
function onAfterRoute() { if (!$this->initCheck()) { return; } else { if (JRequest::getVar('fu_ajax') == 1) { JResponse::clearHeaders(); JResponse::setBody(""); $this->doAjax(); $app =& JFactory::getApplication(); exit; } else { if (JRequest::getVar('fu_off') == 1) { exit; } } } }
function download($front = false) { $mainframe =& JFactory::getApplication(); jimport('joomla.filesystem.file'); $params =& JComponentHelper::getParams('com_k2'); $id = JRequest::getInt('id'); JPluginHelper::importPlugin('k2'); $dispatcher =& JDispatcher::getInstance(); $attachment =& JTable::getInstance('K2Attachment', 'Table'); $attachment->load($id); $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 ($front) { $attachment->hit(); } $len = filesize($file); $filename = basename($file); 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::_('File does not exist'); } $mainframe->close(); }
/** * 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() { JResponse::clearHeaders(); }
function ajaxSwitchEditor() { doSwitchEditor(false); JResponse::clearHeaders(); JResponse::setHeader('Pragma', 'public', true); JResponse::setHeader('Expires', 'Sat, 26 Jul 1997 05:00:00 GMT', true); // Date in the past JResponse::setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT', true); JResponse::setHeader('Cache-Control', 'no-store, no-cache, must-revalidate', true); // HTTP/1.1 JResponse::setHeader('Cache-Control: pre-check=0, post-check=0, max-age=0', true); // HTTP/1.1 JResponse::setHeader('Pragma', 'no-cache', true); JResponse::setHeader('Expires', '0', true); JResponse::setHeader('Content-Transfer-Encoding', 'none', true); JResponse::setHeader('Content-Type', 'text/xml', true); // joomla will overwrite this... $d = JFactory::getDocument(); $d->setMimeEncoding('text/xml'); JResponse::sendHeaders(); }
/** * 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(); }