/** * Returns absolute page URL. * * @return string */ public function getPageURL() { if (empty($this->pageURL)) { $this->pageURL = RouteHandler::getProtocol() . $this->domainName . $this->domainPath; } return $this->pageURL; }
/** * @see \wcf\system\bbcode\IBBCode::getParsedTag() */ public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser) { if ($parser->getOutputType() == 'text/html') { $quoteLink = !empty($openingTag['attributes'][1]) ? $openingTag['attributes'][1] : ''; $externalQuoteLink = !empty($openingTag['attributes'][1]) ? !ApplicationHandler::getInstance()->isInternalURL($openingTag['attributes'][1]) : false; if (!$externalQuoteLink) { $quoteLink = preg_replace('~^https?://~', RouteHandler::getProtocol(), $quoteLink); } $quoteAuthor = !empty($openingTag['attributes'][0]) ? $openingTag['attributes'][0] : ''; $quoteAuthorObject = null; if ($quoteAuthor && !$externalQuoteLink) { $quoteAuthorLC = mb_strtolower(StringUtil::decodeHTML($quoteAuthor)); foreach (MessageEmbeddedObjectManager::getInstance()->getObjects('com.woltlab.wcf.quote') as $user) { if (mb_strtolower($user->username) == $quoteAuthorLC) { $quoteAuthorObject = $user; break; } } } WCF::getTPL()->assign(array('content' => $content, 'quoteLink' => $quoteLink, 'quoteAuthor' => $quoteAuthor, 'quoteAuthorObject' => $quoteAuthorObject, 'isExternalQuoteLink' => $externalQuoteLink)); return WCF::getTPL()->fetch('quoteBBCodeTag'); } else { if ($parser->getOutputType() == 'text/simplified-html') { return WCF::getLanguage()->getDynamicVariable('wcf.bbcode.quote.text', array('content' => $content, 'cite' => !empty($openingTag['attributes'][0]) ? $openingTag['attributes'][0] : '')) . "\n"; } } }
private function getSchemeURL(&$location) { $params = array(); $baseUrl = str_replace(RouteHandler::getProtocol(), 'tapatalk://', WCF::getPath('wbb')) . '?'; $routeData = RouteHandler::getInstance()->getRouteData(); $controller = strtolower(isset($routeData['controller']) ? $routeData['controller'] : ''); $userID = WCF::getUser()->userID; if ($userID) { $params['user_id'] = $userID; } if (!empty($this->eventObj->pageNo)) { $params['page'] = intval($this->eventObj->pageNo); } if (!empty($this->eventObj->itemsPerPage)) { $params['perpage'] = intval($this->eventObj->itemsPerPage); } switch ($controller) { case 'thread': $params['location'] = $location = 'topic'; $params['tid'] = intval($this->eventObj->threadID); $params['fid'] = intval($this->eventObj->board->boardID); break; case 'board': $params['location'] = $location = 'forum'; $params['fid'] = intval($this->eventObj->boardID); break; case 'user': $params['location'] = $location = 'profile'; $params['uid'] = intval($this->eventObj->userID); break; case 'conversation': $params['location'] = $location = 'message'; $params['mid'] = intval($this->eventObj->conversationID); break; case 'users-online-list': case 'usersonlinelist': $params['location'] = $location = 'online'; break; case 'search-result': case 'searchresult': $params['location'] = $location = 'search'; $params['search_id'] = intval($this->eventObj->searchID); break; case 'login': $params['location'] = $location = 'login'; break; default: $params['location'] = $location = 'home'; break; } return $baseUrl . http_build_query($params, '&'); }
/** * Creates a new LoginForm object. */ public function __run() { if (WCF::getUser()->userID) { throw new PermissionDeniedException(); } else { if (PACKAGE_ID == 1 && PACKAGE_ID != ApplicationHandler::getInstance()->getPrimaryApplication()->packageID) { $application = ApplicationHandler::getInstance()->getPrimaryApplication(); HeaderUtil::redirect(RouteHandler::getProtocol() . $application->domainName . $application->domainPath . 'acp/?Login/'); exit; } } parent::__run(); }
/** * Does the user authentication. */ protected function initAuth() { // this is a work-around since neither RequestHandler // nor RouteHandler are populated right now $pathInfo = RouteHandler::getPathInfo(); if (empty($pathInfo) || !preg_match('~^/?(acp-?captcha|login|logout)/~i', $pathInfo)) { if (WCF::getUser()->userID == 0) { // work-around for AJAX-requests within ACP if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') { throw new AJAXException(WCF::getLanguage()->get('wcf.ajax.error.sessionExpired'), AJAXException::SESSION_EXPIRED, ''); } // build redirect path $application = ApplicationHandler::getInstance()->getActiveApplication(); if ($application === null) { throw new SystemException("You have aborted the installation, therefore this installation is unusable. You are required to reinstall the software."); } // fallback for unknown host (rescue mode) if ($application->domainName != $_SERVER['HTTP_HOST']) { $pageURL = RouteHandler::getProtocol() . $_SERVER['HTTP_HOST'] . RouteHandler::getPath(array('acp')); } else { $pageURL = $application->getPageURL(); } // drop session id $redirectURI = preg_replace('~[&\\?]s=[a-f0-9]{40}(&|$)~', '', WCF::getSession()->requestURI); $path = $pageURL . 'acp/index.php?login/' . SID_ARG_2ND_NOT_ENCODED . '&url=' . rawurlencode(RouteHandler::getProtocol() . $_SERVER['HTTP_HOST'] . $redirectURI); HeaderUtil::redirect($path); exit; } else { // work-around for AJAX-requests within ACP if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') { try { WCF::getSession()->checkPermissions(array('admin.general.canUseAcp')); } catch (PermissionDeniedException $e) { throw new AJAXException(self::getLanguage()->get('wcf.ajax.error.permissionDenied'), AJAXException::INSUFFICIENT_PERMISSIONS, $e->getTraceAsString()); } } else { WCF::getSession()->checkPermissions(array('admin.general.canUseAcp')); } // force debug mode if in ACP and authenticated self::$overrideDebugMode = true; } } }
/** * Installs current package. * * @param array $nodeData */ protected function installPackage(array $nodeData) { $installationStep = new PackageInstallationStep(); // check requirements if (!empty($nodeData['requirements'])) { foreach ($nodeData['requirements'] as $package => $requirementData) { // get existing package if ($requirementData['packageID']) { $sql = "SELECT packageName, packageVersion FROM wcf".WCF_N."_package WHERE packageID = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($requirementData['packageID'])); } else { // try to find matching package $sql = "SELECT packageName, packageVersion FROM wcf".WCF_N."_package WHERE package = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($package)); } $row = $statement->fetchArray(); // package is required but not available if ($row === false) { throw new SystemException("Package '".$package."' is required by '".$nodeData['packageName']."', but is neither installed nor shipped."); } // check version requirements if ($requirementData['minVersion']) { if (Package::compareVersion($row['packageVersion'], $requirementData['minVersion']) < 0) { throw new SystemException("Package '".$nodeData['packageName']."' requires the package '".$row['packageName']."' in version '".$requirementData['minVersion']."', but version '".$row['packageVersion']."'"); } } } } unset($nodeData['requirements']); if (!$this->queue->packageID) { // create package entry $package = PackageEditor::create($nodeData); // update package id for current queue $queueEditor = new PackageInstallationQueueEditor($this->queue); $queueEditor->update(array( 'packageID' => $package->packageID )); // save excluded packages if (count($this->getArchive()->getExcludedPackages()) > 0) { $sql = "INSERT INTO wcf".WCF_N."_package_exclusion (packageID, excludedPackage, excludedPackageVersion) VALUES (?, ?, ?)"; $statement = WCF::getDB()->prepareStatement($sql); foreach ($this->getArchive()->getExcludedPackages() as $excludedPackage) { $statement->execute(array($package->packageID, $excludedPackage['name'], (!empty($excludedPackage['version']) ? $excludedPackage['version'] : ''))); } } // if package is plugin to com.woltlab.wcf it must not have any other requirement $requirements = $this->getArchive()->getRequirements(); // insert requirements and dependencies $requirements = $this->getArchive()->getAllExistingRequirements(); if (!empty($requirements)) { $sql = "INSERT INTO wcf".WCF_N."_package_requirement (packageID, requirement) VALUES (?, ?)"; $statement = WCF::getDB()->prepareStatement($sql); foreach ($requirements as $identifier => $possibleRequirements) { if (count($possibleRequirements) == 1) { $requirement = array_shift($possibleRequirements); } else { $requirement = $possibleRequirements[$this->selectedRequirements[$identifier]]; } $statement->execute(array($package->packageID, $requirement['packageID'])); } } // reload queue $this->queue = new PackageInstallationQueue($this->queue->queueID); $this->package = null; if ($package->isApplication) { $host = StringUtil::replace(RouteHandler::getProtocol(), '', RouteHandler::getHost()); $path = RouteHandler::getPath(array('acp')); // insert as application ApplicationEditor::create(array( 'domainName' => $host, 'domainPath' => $path, 'cookieDomain' => $host, 'cookiePath' => $path, 'packageID' => $package->packageID )); } } if ($this->getPackage()->isApplication && $this->getPackage()->package != 'com.woltlab.wcf' && $this->getAction() == 'install') { if (empty($this->getPackage()->packageDir)) { $document = $this->promptPackageDir(); if ($document !== null && $document instanceof FormDocument) { $installationStep->setDocument($document); } $installationStep->setSplitNode(); } } return $installationStep; }
/** * Generates an anchor tag from given URL. * * @param string $url * @param string $title * @param boolean $encodeTitle * @return string anchor tag */ public static function getAnchorTag($url, $title = '', $encodeTitle = true) { $url = self::trim($url); $external = true; if (ApplicationHandler::getInstance()->isInternalURL($url)) { $external = false; $url = preg_replace('~^https?://~', RouteHandler::getProtocol(), $url); } // cut visible url if (empty($title)) { // use URL and remove protocol and www subdomain $title = preg_replace('~^(?:https?|ftps?)://(?:www\\.)?~i', '', $url); if (mb_strlen($title) > 60) { $title = mb_substr($title, 0, 30) . self::HELLIP . mb_substr($title, -25); } if (!$encodeTitle) { $title = self::encodeHTML($title); } } return '<a href="' . self::encodeHTML($url) . '"' . ($external ? ' class="externalURL"' . (EXTERNAL_LINK_REL_NOFOLLOW ? ' rel="nofollow"' : '') . (EXTERNAL_LINK_TARGET_BLANK ? ' target="_blank"' : '') : '') . '>' . ($encodeTitle ? self::encodeHTML($title) : $title) . '</a>'; }
/** * Builds a new request. * * @param string $application */ protected function buildRequest($application) { try { $routeData = RouteHandler::getInstance()->getRouteData(); // handle landing page for frontend requests if (!$this->isACPRequest()) { $this->handleDefaultController($application, $routeData); // check if accessing from the wrong domain (e.g. "www." omitted but domain was configured with) if (!defined('WCF_RUN_MODE') || WCF_RUN_MODE != 'embedded') { $applicationObject = ApplicationHandler::getInstance()->getApplication($application); if ($applicationObject->domainName != $_SERVER['HTTP_HOST']) { // build URL, e.g. http://example.net/forum/ $url = FileUtil::addTrailingSlash(RouteHandler::getProtocol() . $applicationObject->domainName . RouteHandler::getPath()); if (URL_LEGACY_MODE) { // add path info, e.g. index.php/Board/2/ $pathInfo = RouteHandler::getPathInfo(); if (!empty($pathInfo)) { $url .= 'index.php' . $pathInfo; } } // query string, e.g. ?foo=bar if (!empty($_SERVER['QUERY_STRING'])) { $url .= '?' . $_SERVER['QUERY_STRING']; } HeaderUtil::redirect($url, true); exit; } } // handle controller aliasing if (empty($routeData['isImplicitController']) && !URL_LEGACY_MODE && isset($routeData['controller'])) { $ciController = mb_strtolower($routeData['controller']); // aliased controller, redirect to new URL $alias = $this->getAliasByController($ciController); if ($alias !== null) { $this->redirect($routeData, $application); } $controller = $this->getControllerByAlias($ciController); if ($controller !== null) { // check if controller was provided explicitly as it should $alias = $this->getAliasByController($controller); if ($alias != $routeData['controller']) { $routeData['controller'] = $controller; $this->redirect($routeData, $application); } $routeData['controller'] = $controller; } } } else { if (empty($routeData['controller'])) { $routeData['controller'] = 'Index'; } } $controller = $routeData['controller']; // validate class name if (!preg_match('~^[a-z0-9-]+$~i', $controller)) { throw new SystemException("Illegal class name '" . $controller . "'"); } // work-around for WCFSetup if (!PACKAGE_ID) { $parts = explode('-', $controller); $parts = array_map(function ($part) { return ucfirst($part); }, $parts); $controller = implode('', $parts); } // find class $classData = $this->getClassData($controller, 'page', $application); if ($classData === null) { $classData = $this->getClassData($controller, 'form', $application); } if ($classData === null) { $classData = $this->getClassData($controller, 'action', $application); } if ($classData === null) { throw new SystemException("unable to find class for controller '" . $controller . "'"); } else { if (!class_exists($classData['className'])) { throw new SystemException("unable to find class '" . $classData['className'] . "'"); } } // check if controller was provided exactly as it should if (!URL_LEGACY_MODE && !$this->isACPRequest()) { if (preg_match('~([A-Za-z0-9]+)(?:Action|Form|Page)$~', $classData['className'], $matches)) { $realController = self::getTokenizedController($matches[1]); if ($controller != $realController) { $this->redirect($routeData, $application, $matches[1]); } } } $this->activeRequest = new Request($classData['className'], $classData['controller'], $classData['pageType']); } catch (SystemException $e) { throw new IllegalLinkException(); } }