/** * Renders the view. * * @param XenForo_ControllerResponse_Abstract Controller response object from last controller * @param XenForo_ViewRenderer_Abstract View renderer for specified response type * @param array Extra container params (probably "sections" from routing) * * @return string View output */ public function renderView(XenForo_ControllerResponse_Abstract $controllerResponse, XenForo_ViewRenderer_Abstract $viewRenderer, array $containerParams = array(), $innerContent = "", $newParams = array()) { $this->_dependencies->preRenderView($controllerResponse); $this->_response->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT', true); if ($controllerResponse->responseCode) { $this->_response->setHttpResponseCode($controllerResponse->responseCode); } /* if ($controllerResponse instanceof XenForo_ControllerResponse_Error) { $innerContent = $viewRenderer->renderError($controllerResponse->errorText); } else if ($controllerResponse instanceof XenForo_ControllerResponse_Message) { $innerContent = $viewRenderer->renderMessage($controllerResponse->message); } else if ($controllerResponse instanceof XenForo_ControllerResponse_View) { $innerContent = $viewRenderer->renderView( $controllerResponse->viewName, $controllerResponse->params, $controllerResponse->templateName, $controllerResponse->subView ); } else if ($controllerResponse instanceof XenForo_ControllerResponse_Redirect) { $target = XenForo_Link::convertUriToAbsoluteUri($controllerResponse->redirectTarget); $innerContent = $viewRenderer->renderRedirect( $controllerResponse->redirectType, $target, $controllerResponse->redirectMessage, $controllerResponse->redirectParams ); } else { // generally shouldn't happen $innerContent = false; } if ($innerContent === false || $innerContent === null) { $innerContent = $viewRenderer->renderUnrepresentable(); } */ if ($viewRenderer->getNeedsContainer()) { $specificContainerParams = XenForo_Application::mapMerge($containerParams, $controllerResponse->containerParams); $containerParams = $this->_dependencies->getEffectiveContainerParams($specificContainerParams, $this->_request); return $viewRenderer->renderContainer($innerContent, $containerParams, $newParams); } else { return $innerContent; } }
/** * Intercept a request for a link redirect * * @param string|bool $error If non-false, an error that occurred when validating the request */ protected function _outputLinkRedirect($error) { if ($error === 'invalid_url') { header('Content-Type: text/html; utf-8', true, 500); die('Invalid URL'); } if (empty(XenForo_Application::getOptions()->imageLinkProxy['links'])) { $error = 'disabled'; } if (!$error) { /* @var $proxyModel XenForo_Model_LinkProxy */ $proxyModel = XenForo_Model::create('XenForo_Model_LinkProxy'); $linkId = $proxyModel->logVisit($this->_url); if ($linkId && !empty(XenForo_Application::getOptions()->imageLinkProxyReferrer['enabled']) && $this->_referrer) { $proxyModel->logLinkReferrer($linkId, $this->_referrer); } if ($this->_json) { header('Content-type: application/json; charset=UTF-8'); echo json_encode(array('logged' => true)); exit; } // this used to redirect, but we don't take this approach any longer, so we display an intersitial } $request = new Zend_Controller_Request_Http(); XenForo_Session::startPublicSession($request); $this->_dependencies->preRenderView(); if (!preg_match('#^https?://#i', $this->_url)) { throw new Exception('Unsafe proxy URL: ' . $this->_url); } $printable = urldecode($this->_url); if (!preg_match('/./u', $printable)) { $printable = $this->_url; } $renderer = new XenForo_ViewRenderer_HtmlPublic($this->_dependencies, $this->_response, $request); $contents = $renderer->createTemplateObject('link_redirect', array('url' => $this->_url, 'printable' => $printable, 'parts' => parse_url($this->_url))); $containerParams = $this->_dependencies->getEffectiveContainerParams(array(), $request); $output = $renderer->renderContainer($contents, $containerParams); $extraHeaders = XenForo_Application::gzipContentIfSupported($output); foreach ($extraHeaders as $extraHeader) { $this->_response->setHeader($extraHeader[0], $extraHeader[1], $extraHeader[2]); } $this->_response->setHeader('X-Proxy-Error', $error); $this->_response->sendHeaders(); echo $output; }
/** * Gets the effective set of container params. This includes combining * and specific container params with any global ones. For example, a specific * container param may refer to the section the page is in, so this function * could load the other options that are specific to this section. * * @param array $params Container params from the controller/view * @param Zend_Controller_Request_Http $request * * @return array */ public function getEffectiveContainerParams(array $params, Zend_Controller_Request_Http $request) { $visitor = XenForo_Visitor::getInstance(); if (!$visitor['is_admin'] && !isset($params['containerTemplate'])) { $params['containerTemplate'] = 'LOGIN_PAGE'; } $options = XenForo_Application::get('options'); $params['homeLink'] = $options->homePageUrl ? $options->homePageUrl : XenForo_Link::buildPublicLink('index'); $params['jQuerySource'] = self::getJquerySource(); $params = XenForo_Application::mapMerge($params, parent::getEffectiveContainerParams($params, $request), $this->_getCronContainerParams(), $this->_getNavigationContainerParams(empty($params['majorSection']) ? '' : $params['majorSection'])); XenForo_CodeEvent::fire('container_admin_params', array(&$params, $this)); return $params; }
/** * Gets the effective set of container params. This includes combining * and specific container params with any global ones. For example, a specific * container param may refer to the section the page is in, so this function * could load the other options that are specific to this section. * * @param array $params Container params from the controller/view * @param Zend_Controller_Request_Http $request * * @return array */ public function getEffectiveContainerParams(array $params, Zend_Controller_Request_Http $request) { $options = XenForo_Application::get('options'); $visitor = XenForo_Visitor::getInstance(); $params['canSearch'] = $visitor->canSearch(); $params['canUploadAvatar'] = $visitor->canUploadAvatar(); $params['canEditSignature'] = $visitor->canEditSignature(); $params['canEditProfile'] = $visitor->canEditProfile(); $params['canUpdateStatus'] = $visitor->canUpdateStatus(); $params['canStartConversation'] = $visitor->canStartConversations(); $params['canViewProfilePosts'] = $visitor->canViewProfilePosts(); $params['isAwaitingEmailConfirmation'] = $visitor['user_id'] && in_array($visitor['user_state'], array('email_confirm', 'email_confirm_edit')); $params['isEmailBouncing'] = $visitor['user_id'] && $visitor['user_state'] == 'email_bounce'; $params['tosUrl'] = self::getTosUrl(); $params['jQuerySource'] = self::getJquerySource(); $params['jQuerySourceLocal'] = self::getJquerySource(true); $params['javaScriptSource'] = XenForo_Application::$javaScriptUrl; $params['showBoardClosedNotice'] = !$options->boardActive && XenForo_Visitor::getInstance()->get('is_admin'); $params['showCookieNotice'] = $options->showFirstCookieNotice && XenForo_Helper_Cookie::getCookie('session') === false && XenForo_Helper_Cookie::getCookie('user') === false; $requestPaths = XenForo_Application::get('requestPaths'); $params['isIndexPage'] = $requestPaths['fullUri'] == XenForo_Link::buildPublicLink('full:index'); $params = XenForo_Application::mapMerge($params, parent::getEffectiveContainerParams($params, $request), $this->_getCronContainerParams(), $this->_getStyleLanguageChangerParams($request), $this->_getNavigationContainerParams(empty($params['majorSection']) ? '' : $params['majorSection'])); if ($options->enableNotices) { $this->_preloadNoticeTemplates($params, $request); } XenForo_CodeEvent::fire('container_public_params', array(&$params, $this)); return $params; }
/** * Gets the effective set of container params. This includes combining * and specific container params with any global ones. For example, a specific * container param may refer to the section the page is in, so this function * could load the other options that are specific to this section. * * @param array $params Container params from the controller/view * @param Zend_Controller_Request_Http $request * * @return array */ public function getEffectiveContainerParams(array $params, Zend_Controller_Request_Http $request) { $options = XenForo_Application::get('options'); $visitor = XenForo_Visitor::getInstance(); $params['canSearch'] = $visitor->canSearch(); $params['canUploadAvatar'] = $visitor->canUploadAvatar(); $params['canEditSignature'] = $visitor->canEditSignature(); $params['canUpdateStatus'] = $visitor->canUpdateStatus(); $params['isAwaitingEmailConfirmation'] = $visitor['user_id'] && in_array($visitor['user_state'], array('email_confirm', 'email_confirm_edit')); $params['tosUrl'] = self::getTosUrl(); $params['jQuerySource'] = self::getJquerySource(); $params['jQuerySourceLocal'] = self::getJquerySource(true); $params['javaScriptSource'] = $options->javaScriptSource; $params['showBoardClosedNoticed'] = !$options->boardActive && XenForo_Visitor::getInstance()->get('is_admin'); $params = XenForo_Application::mapMerge($params, parent::getEffectiveContainerParams($params, $request), $this->_getCronContainerParams(), $this->_getStyleLanguageChangerParams($request), $this->_getNavigationContainerParams(empty($params['majorSection']) ? '' : $params['majorSection'])); XenForo_CodeEvent::fire('container_public_params', array(&$params, $this)); return $params; }