public function actionIndex() { $options = GFNLinkProxy_Options::getInstance(); if ($referer = $this->_request->getHeader('referer')) { if ($options->get('blockInvalidReferrer')) { if ($host = parse_url($referer, PHP_URL_HOST)) { if (!in_array($host, array($this->_request->getServer('SERVER_NAME'), parse_url(XenForo_Application::getOptions()->get('boardUrl'), PHP_URL_HOST)))) { return $this->responseNoPermission(); } } } } $url = base64_decode($this->_input->filterSingle('to', XenForo_Input::STRING)); if (!$url) { return $this->responseNoPermission(); } if (!parse_url($url)) { return $this->responseNoPermission(); } if ($options->get('enableAutoRedirect')) { if ($options->get('autoRedirectDelay') == 0) { return $this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_CANONICAL, $url); } $title = $options->get('autoRedirectTitle'); $message = $this->_parseMessage($options->get('autoRedirectMessage'), array('board' => XenForo_Application::getOptions()->get('boardTitle'), 'boardUrl' => XenForo_Application::getOptions()->get('boardUrl'), 'url' => $url, 'delay' => '<span class="delay">' . $options->get('autoRedirectDelay') . '</span>')); } else { $title = $options->get('title'); $message = $this->_parseMessage($options->get('message'), array('board' => XenForo_Application::getOptions()->get('boardTitle'), 'boardUrl' => XenForo_Application::getOptions()->get('boardUrl'), 'url' => $url)); } $viewParams = array('url' => $url, 'referer' => $referer ? $referer : XenForo_Application::getOptions()->get('boardUrl'), 'title' => $title, 'message' => $message, 'autoRedirect' => $options->get('enableAutoRedirect'), 'delay' => $options->get('autoRedirectDelay')); return $this->responseView('GFNLinkProxy_ViewPublic_Redirect', 'gfnlinkproxy_redirect', $viewParams); }
protected static function _protocolWhiteListed($link) { static $whiteList = null; if ($whiteList === null) { $whiteList = GFNLinkProxy_Options::getInstance()->get('whiteListProtocol'); $whiteList = preg_split('/\\r?\\n/', $whiteList, PREG_SPLIT_NO_EMPTY); foreach ($whiteList as $k => &$v) { $v = trim($v); if (empty($v)) { unset($whiteList[$k]); } } } foreach ($whiteList as $check) { if (strpos($link, $check) === 0) { return true; } } return false; }