/** * Method to return list of users by ajax request for userlist and search user * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @since K4.0 * @return JSon */ public function displayListMention($tpl = null) { $response = array(); if ($this->me->exists()) { $users = $this->get('Items'); foreach ($users as $user) { $user_obj = new stdClass(); $user_obj->id = $user->id; $user_obj->photo = $user->getAvatarURL(); $user_obj->name = $user->username; $response[] = $user_obj; } } // Set the MIME type and header for JSON output. $this->document->setMimeEncoding('application/json'); JResponse::setHeader('Content-Disposition', 'attachment; filename="' . $this->getName() . '.' . $this->getLayout() . '.json"'); echo json_encode($response); }
private function sendError($exception) { JResponse::setHeader('status', $exception->getCode()); $error = new APIException($exception->getMessage(), $exception->getCode()); JFactory::getDocument()->setMimeEncoding('application/json'); return json_encode($error->toArray()); }
/** * Render the document * * @param boolean $cache If true, cache the output * @param array $params Associative array of attributes * * @return string The rendered data * * @since 11.1 */ public function render($cache = false, $params = array()) { // If no error object is set return null if (!isset($this->_error)) { return; } //Set the status header JResponse::setHeader('status', $this->_error->getCode() . ' ' . str_replace("\n", ' ', $this->_error->getMessage())); $file = 'error.php'; // check template $directory = isset($params['directory']) ? $params['directory'] : 'templates'; $template = isset($params['template']) ? JFilterInput::getInstance()->clean($params['template'], 'cmd') : 'system'; if (!file_exists($directory . '/' . $template . '/' . $file)) { $template = 'system'; } //set variables $this->baseurl = JURI::base(true); $this->template = $template; $this->debug = isset($params['debug']) ? $params['debug'] : false; $this->error = $this->_error; // load $data = $this->_loadTemplate($directory . '/' . $template, $file); parent::render(); return $data; }
function calc() { //decode incoming JSON string $jsonRequest = JRequest::getVar("jsonString", "", "get"); $jsonRequest = json_decode($jsonRequest); $calc_result = $this->_model->calcPrice($jsonRequest); $data = new stdclass(); $data->amount = $calc_result['amount']; $data->amount_value = $calc_result['amount_value']; $data->tax = $calc_result['tax']; $data->tax_value = $calc_result['tax_value']; $data->discount_sign = $calc_result['discount_sign']; $data->discount = $calc_result['discount']; $data->total = $calc_result['total']; $data->total_value = $calc_result['total_value']; $data->currency = $calc_result['currency']; // Get the document object. $document = JFactory::getDocument(); // Set the MIME type for JSON output. $document->setMimeEncoding('application/json'); // Change the suggested filename. JResponse::setHeader('Content-Disposition', 'attachment;filename="orders.json"'); // Output the JSON data. echo json_encode($data); JFactory::getApplication()->close(); }
public final function getErrorResponse($code = 400, $message = '', $set_status = true) { if (true === $set_status) { JResponse::setHeader('status', $code, true); } return (object) array('error' => true, 'code' => $code, 'message' => JText::_($message)); }
/** * Render the document. * * @param boolean $cache If true, cache the output * @param array $params Associative array of attributes * * @return The rendered data * * @since 11.1 */ public function render($cache = false, $params = array()) { parent::render(); JResponse::setHeader('Content-disposition', 'inline; filename="' . $this->getName() . '.xml"', true); return $this->getBuffer(); }
/** * 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); }
/** * Render the document. * * @param boolean $cache If true, cache the output * @param array $params Associative array of attributes * * @return The rendered data * * @since 11.1 */ public function render($cache = false, $params = array()) { JResponse::allowCache(false); JResponse::setHeader('Content-disposition', 'attachment; filename="' . $this->getName() . '.json"', true); parent::render(); return $this->getBuffer(); }
/** * Display the view * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return void */ public function display($tpl = null) { $basename = $this->get('BaseName'); $filetype = $this->get('FileType'); $mimetype = $this->get('MimeType'); $content = $this->get('Content'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $document = JFactory::getDocument(); $document->setMimeEncoding($mimetype); // Joomla 3 if (version_compare(JVERSION, '3.0', 'ge')) { JFactory::getApplication()->setHeader('Content-disposition', 'attachment; filename="' . $basename . '.' . $filetype . '"; creation-date="' . JFactory::getDate()->toRFC822() . '"', true); } else { JResponse::setHeader('Content-disposition', 'attachment; filename="' . $basename . '.' . $filetype . '"; creation-date="' . JFactory::getDate()->toRFC822() . '"', true); } // Open file pointer to standard output // $fp = fopen('php://output', 'w'); // Add BOM to fix UTF-8 in Excel // fputs($fp, $bom =( chr(0xEF) . chr(0xBB) . chr(0xBF) )); // fclose($fp); echo $content; }
/** * Display the template * * @param sting $tpl template * * @return void */ public function display($tpl = null) { if (parent::display($tpl) !== false) { $app = JFactory::getApplication(); if (!$app->isAdmin()) { $this->state = $this->get('State'); $this->params = $this->state->get('params'); $this->document = JFactory::getDocument(); if ($this->params->get('menu-meta_description')) { $this->document->setDescription($this->params->get('menu-meta_description')); } if ($this->params->get('menu-meta_keywords')) { $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } if ($this->params->get('robots')) { $this->document->setMetadata('robots', $this->params->get('robots')); } } // Set the response to indicate a file download JResponse::setHeader('Content-Type', 'application/vnd.ms-word'); $name = $this->getModel()->getTable()->label; $name = JStringNormalise::toDashSeparated($name); JResponse::setHeader('Content-Disposition', "attachment;filename=\"" . $name . ".doc\""); $this->document->setMimeEncoding('text/html; charset=Windows-1252', false); $this->output(); } }
public function display() { // Get model data. $state = $this->get('State'); $item = $this->get('Item'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } $doc = JFactory::getDocument(); $doc->setMetaData('Content-Type', 'text/directory', true); // Initialise variables. $app = JFactory::getApplication(); $params = $app->getParams(); $user = JFactory::getUser(); $dispatcher = JEventDispatcher::getInstance(); // Compute lastname, firstname and middlename $item->name = trim($item->name); // "Lastname, Firstname Midlename" format support // e.g. "de Gaulle, Charles" $namearray = explode(',', $item->name); if (count($namearray) > 1) { $lastname = $namearray[0]; $card_name = $lastname; $name_and_midname = trim($namearray[1]); $firstname = ''; if (!empty($name_and_midname)) { $namearray = explode(' ', $name_and_midname); $firstname = $namearray[0]; $middlename = count($namearray) > 1 ? $namearray[1] : ''; $card_name = $firstname . ' ' . ($middlename ? $middlename . ' ' : '') . $card_name; } } else { $namearray = explode(' ', $item->name); $middlename = count($namearray) > 2 ? $namearray[1] : ''; $firstname = array_shift($namearray); $lastname = count($namearray) ? end($namearray) : ''; $card_name = $firstname . ($middlename ? ' ' . $middlename : '') . ($lastname ? ' ' . $lastname : ''); } $rev = date('c', strtotime($item->modified)); JResponse::setHeader('Content-disposition', 'attachment; filename="' . $card_name . '.vcf"', true); $vcard = array(); $vcard[] .= 'BEGIN:VCARD'; $vcard[] .= 'VERSION:3.0'; $vcard[] = 'N:' . $lastname . ';' . $firstname . ';' . $middlename; $vcard[] = 'FN:' . $item->name; $vcard[] = 'TITLE:' . $item->con_position; $vcard[] = 'TEL;TYPE=WORK,VOICE:' . $item->telephone; $vcard[] = 'TEL;TYPE=WORK,FAX:' . $item->fax; $vcard[] = 'TEL;TYPE=WORK,MOBILE:' . $item->mobile; $vcard[] = 'ADR;TYPE=WORK:;;' . $item->address . ';' . $item->suburb . ';' . $item->state . ';' . $item->postcode . ';' . $item->country; $vcard[] = 'LABEL;TYPE=WORK:' . $item->address . "\n" . $item->suburb . "\n" . $item->state . "\n" . $item->postcode . "\n" . $item->country; $vcard[] = 'EMAIL;TYPE=PREF,INTERNET:' . $item->email_to; $vcard[] = 'URL:' . $item->webpage; $vcard[] = 'REV:' . $rev . 'Z'; $vcard[] = 'END:VCARD'; echo implode("\n", $vcard); return true; }
/** * Render the document. * * @param boolean $cache If true, cache the output * @param array $params Associative array of attributes * * @return The rendered data * * @since 3.1 */ public function render($cache = false, $params = array()) { JResponse::allowCache($cache); JResponse::setHeader('Content-disposition', 'attachment; filename="' . $this->getName() . '.json"', true); // Unfortunately, the exact syntax of the Content-Type header // is not defined, so we have to try to be a bit clever here. $contentType = $this->_mime; if (stripos($contentType, 'json') === false) { $contentType .= '+' . $this->_type; } $this->_mime = $contentType; parent::render(); // Get the HAL object from the buffer. $hal = $this->getBuffer(); // If required, change relative links to absolute. if ($this->absoluteHrefs && is_object($hal) && isset($hal->_links)) { // Adjust hrefs in the _links object. $this->relToAbs($hal->_links); // Adjust hrefs in the _embedded object (if there is one). if (isset($hal->_embedded)) { foreach ($hal->_embedded as $rel => $resources) { foreach ($resources as $id => $resource) { if (isset($resource->_links)) { $this->relToAbs($resource->_links); } } } } } // Return it as a JSON string. return json_encode($hal); }
/** * Return statistics XLS file * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return void */ function display($tpl = null) { $this->item = $this->get('Item'); // Get parameters $jinput = JFactory::getApplication()->input; $type = $jinput->get('type', null, 'string'); $begin = $jinput->get('begin', null, 'string'); $end = $jinput->get('end', null, 'string'); // Convert date strings to JDate objects $beginDate = new JDate($begin); $endDate = new JDate($end . ' 23:59:59'); // Get statistic model $statisticModel = JModelLegacy::getInstance('statistic', 'IsbnregistryModel'); // Get statistics $data = $statisticModel->getStats($type, $beginDate, $endDate); // Set document properties $document = JFactory::getDocument(); $document->setMimeEncoding('application/vnd.ms-excel; charset="UTF-8"'); JResponse::setHeader('Content-disposition', 'attachment; filename="statistics.xml"', true); // Get Excel helper require_once JPATH_COMPONENT . '/helpers/php-export-data.class.php'; // Create new Excled worksheet $excel = new ExportDataExcel('browser'); $excel->filename = "statistics.xml"; $excel->initialize(); // Loop through data array foreach ($data as $row) { // Add rows $excel->addRow($row); } // Finalize $excel->finalize(); }
/** * Generates a list of JSON items. * * @return void */ function display($tpl = null) { $ta = (int) JRequest::getUInt('typeahead'); $s2 = (int) JRequest::getUInt('select2'); $resp = array(); // Get model data $rows = $this->get('Items'); if ($ta) { $tmp_rows = array(); foreach ($rows as &$row) { $id = (int) $row->id; $tmp_rows[$id] = $this->escape($row->title); } $rows = $tmp_rows; } elseif ($s2) { $tmp_rows = array(); foreach ($rows as &$row) { $id = (int) $row->id; $item = new stdClass(); $item->id = $id; $item->text = $this->escape($row->title); $tmp_rows[] = $item; } $rows = $tmp_rows; $total = (int) $this->get('Total'); $rows = array('total' => $total, 'items' => $rows); } // Set the MIME type for JSON output. JFactory::getDocument()->setMimeEncoding('application/json'); // Change the suggested filename. JResponse::setHeader('Content-Disposition', 'attachment;filename="' . $this->getName() . '.json"'); // Output the JSON data. echo json_encode($rows); jexit(); }
/** * Output a correct response code when site is offline * to let know search engines that site data * should not be discarded or discounted */ function plgSh404sefofflinecode() { $app = JFactory::getApplication(); // are we in the backend, or not offline ? if (!defined('SH404SEF_IS_RUNNING') || $app->isAdmin() || !$app->getCfg('offline')) { return; } // get plugin params $plugin =& JPluginHelper::getPlugin('sh404sefcore', 'sh404sefofflinecode'); $pluginParams = new JRegistry(); $pluginParams->loadString($plugin->params); $disallowAdminAccess = $pluginParams->get('disallowAdminAccess', 0); if (!$disallowAdminAccess) { // admins are allowed, lets check if current user // is an admin, or if user is trying to log in $user =& JFactory::getUser(); $option = JRequest::getCmd('option'); $task = JRequest::getCmd('task'); if ($option == 'com_users' && $task == 'user.login') { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); $loggingIn = true; } else { $loggingIn = false; } // if already logged inadmin, or admin logging in, let it go if ($user->authorize('core.manage', 'com_sh404sef') || $loggingIn) { return; } } // need to render offline screen if ($disallowAdminAccess) { // admins not allowed, use our own // simplified template. Most likely being hacked so // close doors as much as possible $template = ''; $file = 'sh404sef_offline_template.php'; $directory = JPATH_ROOT . DS . 'plugins' . DS . 'sh404sefcore'; } else { // admin can access, use Joomla! offline template, // that includes a login form $template = $app->getTemplate(); $file = 'offline.php'; $directory = JPATH_THEMES; } $params = array('template' => $template, 'file' => $file, 'directory' => $directory); $document =& JFactory::getDocument(); $data = $document->render($app->getCfg('caching'), $params); // header : service unavailable JResponse::setHeader('HTTP/1.0 503', true); // give it some time $retryAfter = $pluginParams->get('retry_after_delay', 7400); // set header Jresponse::setheader('Retry-After', gmdate('D, d M Y H:i:s', time() + $retryAfter) . ' GMT'); // echo document JResponse::setBody($data); echo JResponse::toString($app->getCfg('gzip')); // and terminate $app->close(); }
public function cancel() { // Makes sure SiteGround's SuperCache doesn't cache the subscription page JResponse::setHeader('X-Cache-Control', 'False', true); $msg = null; $type = null; $subid = $this->input->getInt('sid'); // No subscription id? Let's stop here if (!$subid) { $url = 'index.php'; $msg = JText::_('COM_AKEEBASUBS_SUBSCRIPTIONS_FAILED_CANCELLING'); $type = 'error'; } else { $sub = F0FModel::getTmpInstance('Subscriptions', 'AkeebasubsModel')->getTable(); $sub->load($subid); $level = F0FModel::getTmpInstance('Levels', 'AkeebasubsModel')->getTable(); $level->load($sub->akeebasubs_level_id); $url = JRoute::_('index.php?option=com_akeebasubs&view=message&slug=' . $level->slug . '&layout=cancel&subid=' . $subid); $result = F0FModel::getTmpInstance('Subscribes', 'AkeebasubsModel')->paymentmethod($this->input->getCmd('paymentmethod', 'none'))->runCancelRecurring(); if (!$result) { $msg = JText::_('COM_AKEEBASUBS_SUBSCRIPTIONS_FAILED_CANCELLING'); $type = 'error'; } } $this->setRedirect($url, $msg, $type); }
public function cron($cachable = false) { // Makes sure SiteGround's SuperCache doesn't cache the CRON view JResponse::setHeader('X-Cache-Control', 'False', true); require_once F0FTemplateUtils::parsePath('admin://components/com_akeebasubs/helpers/cparams.php', true); $configuredSecret = AkeebasubsHelperCparams::getParam('secret', ''); if (empty($configuredSecret)) { header('HTTP/1.1 503 Service unavailable due to configuration'); JFactory::getApplication()->close(); } $secret = $this->input->get('secret', null, 'raw'); if ($secret != $configuredSecret) { header('HTTP/1.1 403 Forbidden'); JFactory::getApplication()->close(); } $command = $this->input->get('command', null, 'raw'); $command = trim(strtolower($command)); if (empty($command)) { header('HTTP/1.1 501 Not implemented'); JFactory::getApplication()->close(); } F0FPlatform::getInstance()->importPlugin('system'); F0FPlatform::getInstance()->runPlugins('onAkeebasubsCronTask', array($command, array('time_limit' => 10))); echo "{$command} OK"; JFactory::getApplication()->close(); }
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(); } }
public function edit() { try { // Check for request forgeries. if (!JRequest::checkToken()) { throw new Exception(JText::_('JINVALID_TOKEN'), 500); } // Check for authorisation. if (!JFactory::getUser()->authorise('edit', 'com_slicomments')) { throw new Exception(JText::_('COM_COMMENTS_NO_AUTH'), 403); } $model = $this->getModel('comments'); $data = JRequest::get('post', JREQUEST_ALLOWRAW); $id = (int) $data['id']; $data = $model->filter($data); if ($model->validate($data) && $model->save($id, $data)) { echo nl2br(htmlentities($data['raw'], ENT_QUOTES, 'UTF-8')); } else { throw new Exception((string) $model->getError(), 500); } } catch (Exception $e) { JResponse::setHeader('status', $e->getCode()); echo $e->getMessage(); } }
/** * Raw view display method, outputs one image * * @param string $tpl The name of the template file to parse * @return void * @since 1.5.5 */ public function display($tpl = null) { jimport('joomla.filesystem.file'); $type = JRequest::getWord('type', 'thumb'); $image = $this->get('Data'); $img = $this->_ambit->getImg($type . '_path', $image); if (!JFile::exists($img)) { $this->_mainframe->redirect(JRoute::_('index.php', false), JText::_('COM_JOOMGALLERY_COMMON_MSG_IMAGE_NOT_EXIST'), 'error'); } $info = getimagesize($img); switch ($info[2]) { case 1: $mime = 'image/gif'; break; case 2: $mime = 'image/jpeg'; break; case 3: $mime = 'image/png'; break; default: JError::raiseError(404, JText::sprintf('COM_JOOMGALLERY_COMMON_MSG_MIME_NOT_ALLOWED', $info[2])); break; } // Set mime encoding $this->_doc->setMimeEncoding($mime); // Set header to specify the file name $disposition = 'inline'; JResponse::setHeader('Content-disposition', $disposition . '; filename=' . basename($img)); echo JFile::read($img); }
/** * Return statistics CSV file * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return void */ function display($tpl = null) { $this->item = $this->get('Item'); // Get parameters $jinput = JFactory::getApplication()->input; $type = $jinput->get('type', null, 'string'); $begin = $jinput->get('begin', null, 'string'); $end = $jinput->get('end', null, 'string'); // Convert date strings to JDate objects $beginDate = new JDate($begin); $endDate = new JDate($end . ' 23:59:59'); // Get statistic model $statisticModel = JModelLegacy::getInstance('statistic', 'IssnregistryModel'); // Get statistics $csv = $statisticModel->getStats($type, $beginDate, $endDate); // Set document properties $document = JFactory::getDocument(); $document->setMimeEncoding('text/csv; charset="UTF-8"'); JResponse::setHeader('Content-disposition', 'attachment; filename="statistics.csv"', true); // Write to output $out = fopen('php://output', 'w'); // Loop through CSV data and write each row to output foreach ($csv as $row) { // Columns are tab separated fputcsv($out, $row, "\t"); } // Close output fclose($out); }
function displayDefault($tpl = null) { $response = array(); $response['topiclist'] = array(); if ($this->me->exists()) { $this->category = $this->get('Category'); if (!$this->category->authorise('read')) { $response['error'] = $this->category->getError(); } else { $topics = $this->get('Topics'); foreach ($topics as $topic) { $item = new StdClass(); $item->id = $topic->id; $item->subject = $topic->subject; $response['topiclist'][] = $item; } } } // Set the MIME type and header for JSON output. $this->document->setMimeEncoding('application/json'); JResponse::setHeader('Content-Disposition', 'attachment; filename="' . $this->getName() . '.' . $this->getLayout() . '.json"'); echo json_encode($response); }
public function read($cachable = false) { // Makes sure SiteGround's SuperCache doesn't cache the subscription page JResponse::setHeader('X-Cache-Control', 'False', true); $data = $this->getThisModel()->action('validate')->getValidation(); echo json_encode($data); JFactory::getApplication()->close(); }
function onAfterRender() { $app = JFactory::getApplication(); t3import('core.admin.util'); $util = new JAT3_AdminUtil(); if ($app->isAdmin()) { ob_start(); $util->show_button_clearCache(); $content = ob_get_clean(); $buffer = JResponse::getBody(); $buffer = preg_replace('/<\\/body>/', $content . "\n</body>", $buffer); JResponse::setBody($buffer); } if ($util->checkPermission()) { if (JAT3_AdminUtil::checkCondition_for_Menu()) { // HTML= Parser lib require_once T3Path::path(T3_CORE) . DS . 'libs' . DS . "html_parser.php"; $_body = JResponse::getBody(); require_once T3Path::path(T3_CORE) . DS . 'admin' . DS . "util.php"; // Replace content $jat3core = new JAT3_AdminUtil(); $_body = $jat3core->replaceContent($_body); if ($_body) { JResponse::setBody($_body); } } } if (!T3Common::detect()) { return; } if ($util->checkPermission()) { if ($util->checkCondition()) { $params = T3Path::path(T3_CORE) . DS . 'admin' . DS . 'index.php'; if (file_exists($params)) { ob_start(); include $params; $content = ob_get_clean(); $buffer = JResponse::getBody(); $buffer = preg_replace('/<\\/body>/', $content . "\n</body>", $buffer); JResponse::setBody($buffer); } } return; } if (!$app->isAdmin()) { //Expires date set to very long //JResponse::setHeader( 'Expires', gmdate( 'D, d M Y H:i:s', time() + 3600000 ) . ' GMT', true ); //JResponse::setHeader( 'Last-Modified', gmdate( 'D, d M Y H:i:s', time()) . ' GMT', true ); JResponse::setHeader('Expires', '', true); JResponse::setHeader('Cache-Control', 'private', true); //Update cache in case of the whole page is cached $key = T3Cache::getPageKey(); if (($data = T3Cache::get($key)) && !preg_match('#<jdoc:include\\ type="([^"]+)" (.*)\\/>#iU', $data)) { $buffer = JResponse::getBody(); T3Cache::store($buffer, $key); } } }
/** * 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)); }
function raiseError($code, $msg, $info = null, $backtrace = false) { jimport('joomla.error.exception'); $exception = new JException($msg, $code, E_ERROR, $info, $backtrace); JResponse::setHeader('status', $exception->code . ' ' . str_replace("\n", ' ', $exception->message)); JResponse::setBody(json_encode($exception)); echo JResponse::toString(); exit; }
public function handler() { // Check for request forgeries. JSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN')); JFactory::getDocument()->setMimeEncoding('application/json'); JResponse::setHeader('Content-Disposition', 'attachment;filename="test.json"'); $options = array('script_url' => JRoute::_(JURI::root(true) . '/administrator/index.php?option=com_citybranding&task=upload.handler&format=json&id=' . JRequest::getVar('id') . '&imagedir=' . JRequest::getVar('imagedir') . '&' . JSession::getFormToken() . '=1'), 'upload_dir' => JPATH_ROOT . '/' . JRequest::getVar('imagedir') . '/' . JRequest::getVar('id') . '/', 'upload_url' => JURI::root(true) . '/' . JRequest::getVar('imagedir') . '/' . JRequest::getVar('id') . '/'); $upload_handler = new UploadHandler($options); JFactory::getApplication()->close(); }
function exportmissing($tpl = null) { $document =& JFactory::getDocument(); $document->setMimeEncoding('text/plain'); $date = gmdate('D, d M Y H:i:s', time()) . ' GMT'; $document->setModifiedDate($date); $target = basename($this->get('Target')); JResponse::setHeader('Content-Disposition', 'attachment; filename=' . $target); $data =& $this->get('ResultMissing'); echo $data; }
public function put() { // Simply call post as Joomla will just save an article with an id $this->post(); $response = $this->plugin->get('response'); if (isset($response->success) && $response->success) { JResponse::setHeader('status', 200, true); $response->code = 200; $this->plugin->setResponse($response); } }
function onAfterInitialise() { // Get the header $header = $this->params->get('header', 'NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'); $header = trim($header); // Bail out on empty header (why would anyone do that?!) if (empty($header)) { return; } // Replace any existing P3P headers in the response JResponse::setHeader('P3P', 'CP="' . $header . '"', true); }