Example #1
0
 /**
  * @see \cms\system\content\type\IContentType::getFormTemplate()
  */
 public function getFormTemplate()
 {
     $contentData = RequestHandler::getInstance()->getActiveRequest()->getRequestObject()->contentData;
     if (isset($contentData['fileID'])) {
         $file = new File($contentData['fileID']);
         if ($file->fileID) {
             WCF::getTPL()->assign(array('file' => $file));
         }
     }
     return parent::getFormTemplate();
 }
 /**
  * @see \cms\system\content\type\IContentType::getFormTemplate()
  */
 public function getFormTemplate()
 {
     $contentData = RequestHandler::getInstance()->getActiveRequest()->getRequestObject()->contentData;
     if (isset($contentData['imageIDs'])) {
         $imageList = new FileList();
         $imageList->getConditionBuilder()->add('fileID in (?)', array($contentData['imageIDs']));
         $imageList->readObjects();
         WCF::getTPL()->assign(array('imageList' => $imageList));
     }
     return parent::getFormTemplate();
 }
 /**
  * @see	\cms\system\content\type\IContentType::getOutput()
  */
 public function getOutput(Content $content)
 {
     $boxes = DashboardBoxCacheBuilder::getInstance()->getData(array(), 'boxes');
     if (!isset($boxes[$content->box])) {
         // dashboard box doesn't exist anymore
         return '';
     }
     $className = $boxes[$content->box]->className;
     $box = new $className();
     $box->init($boxes[$content->box], RequestHandler::getInstance()->getActiveRequest()->getRequestObject());
     return $box->getTemplate();
 }
Example #4
0
 /**
  * @see	\wcf\page\IPage::assignVariables()
  */
 public function assignVariables()
 {
     parent::assignVariables();
     $usersAwaitingApproval = 0;
     if (REGISTER_ACTIVATION_METHOD == 2) {
         $sql = "SELECT\tCOUNT(*) AS count\n\t\t\t\tFROM\twcf" . WCF_N . "_user\n\t\t\t\tWHERE\tactivationCode <> 0";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute();
         $row = $statement->fetchArray();
         $usersAwaitingApproval = $row['count'];
     }
     WCF::getTPL()->assign(array('inRescueMode' => RequestHandler::getInstance()->inRescueMode(), 'server' => $this->server, 'usersAwaitingApproval' => $usersAwaitingApproval));
 }
 /**
  * @see	\cms\system\content\type\IContentType::validate()
  */
 public function validate($data)
 {
     if (!isset($data['text']) || empty($data['text'])) {
         throw new UserInputException('text');
     }
     // check template code
     try {
         $compiled = WCF::getTPL()->getCompiler()->compileString('de.codequake.cms.content.type.template', $data['text'], array(), true);
         // cache compiled template with content
         RequestHandler::getInstance()->getActiveRequest()->getRequestObject()->contentData['compiled'][WCF::getLanguage()->languageCode] = $compiled;
     } catch (SystemException $e) {
         WCF::getTPL()->assign(array('compileError' => $e->_getMessage()));
         throw new UserInputException('text', 'compileError');
     }
 }
 /**
  * @see	\wcf\system\condition\IContentCondition::showContent()
  */
 public function showContent(Condition $condition)
 {
     $requestClassName = RequestHandler::getInstance()->getActiveRequest()->getClassName();
     $requestClassName = ltrim($requestClassName, '\\');
     // remove leading backslash
     $pageControllers = $condition->pageControllers;
     foreach ($pageControllers as $objectTypeID) {
         $objectType = ObjectTypeCache::getInstance()->getObjectType($objectTypeID);
         if ($objectType === null) {
             return false;
         }
         if ($requestClassName == $objectType->className) {
             return true;
         }
     }
     return false;
 }
 /**
  * @inheritDoc
  */
 protected function loadContent()
 {
     // get categories
     $categoryTree = new LinklistCategoryNodeTree('de.incendium.linklist.category');
     $categoryList = $categoryTree->getIterator();
     $categoryList->setMaxDepth(0);
     if (iterator_count($categoryList)) {
         // get active category
         $activeCategory = null;
         if (RequestHandler::getInstance()->getActiveRequest()->getRequestObject() instanceof EntryListPage) {
             if (RequestHandler::getInstance()->getActiveRequest()->getRequestObject()->category !== null) {
                 $activeCategory = RequestHandler::getInstance()->getActiveRequest()->getRequestObject()->category;
             }
         }
         $this->content = WCF::getTPL()->fetch('boxCategories', 'linklist', ['categoryList' => $categoryList, 'activeCategory' => $activeCategory]);
     }
 }
Example #8
0
 /**
  * @see \cms\system\content\type\IContentType::getFormTemplate()
  */
 public function getFormTemplate()
 {
     $username = '';
     $contentData =& RequestHandler::getInstance()->getActiveRequest()->getRequestObject()->contentData;
     if (isset($contentData['name'])) {
         $username = $contentData['name'];
     } else {
         if (isset($contentData['userID'])) {
             $userID = $contentData['userID'];
             $user = new User($userID);
             if ($user->userID) {
                 $username = $user->username;
             }
         }
     }
     WCF::getTPL()->assign(array('username' => $username));
     return parent::getFormTemplate();
 }
Example #9
0
 /**
  * Returns a relative link.
  * 
  * @param	string		$controller
  * @param 	array		$parameters
  * @param 	string		$url
  * @return	string
  */
 public function getLink($controller = null, array $parameters = array(), $url = '')
 {
     $abbreviation = 'wcf';
     $anchor = '';
     $isRaw = false;
     if (isset($parameters['application'])) {
         $abbreviation = $parameters['application'];
         unset($parameters['application']);
     }
     if (isset($parameters['isRaw'])) {
         $isRaw = $parameters['isRaw'];
         unset($parameters['isRaw']);
     }
     // remove anchor before parsing
     if (($pos = strpos($url, '#')) !== false) {
         $anchor = substr($url, $pos);
         $url = substr($url, 0, $pos);
     }
     // build route
     if ($controller !== null) {
         // handle object
         if (isset($parameters['object'])) {
             if (!$parameters['object'] instanceof \wcf\system\request\IRouteController && $parameters['object'] instanceof \wcf\data\DatabaseObjectDecorator && $parameters['object']->getDecoratedObject() instanceof \wcf\system\request\IRouteController) {
                 $parameters['object'] = $parameters['object']->getDecoratedObject();
             }
             if ($parameters['object'] instanceof \wcf\system\request\IRouteController) {
                 $parameters['id'] = $parameters['object']->getID();
                 $parameters['title'] = $parameters['object']->getTitle();
             }
             unset($parameters['object']);
         }
         if (isset($parameters['title'])) {
             // remove illegal characters
             $parameters['title'] = trim(preg_replace('/[\\x0-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7F]+/', '-', $parameters['title']), '-');
         }
         $parameters['controller'] = $controller;
         $routeURL = RouteHandler::getInstance()->buildRoute($parameters);
         if (!$isRaw && !empty($url)) {
             $routeURL .= strpos($routeURL, '?') === false ? '?' : '&';
         }
         $url = $routeURL . $url;
     }
     // append session id
     $url .= strpos($url, '?') === false ? SID_ARG_1ST : SID_ARG_2ND_NOT_ENCODED;
     // handle application groups
     $applicationGroup = ApplicationHandler::getInstance()->getActiveGroup();
     if ($applicationGroup !== null) {
         // try to resolve abbreviation
         $application = null;
         if ($abbreviation != 'wcf') {
             $application = ApplicationHandler::getInstance()->getApplication($abbreviation);
         }
         // fallback to primary application if abbreviation is 'wcf' or unknown
         if ($application === null) {
             $application = ApplicationHandler::getInstance()->getPrimaryApplication();
         }
         $url = $application->domainName . $application->domainPath . (RequestHandler::getInstance()->isACPRequest() ? 'acp/' : '') . $url;
     }
     // append previously removed anchor
     $url .= $anchor;
     return $url;
 }
Example #10
0
	/**
	 * Returns the HTML tag to include current stylesheet.
	 * 
	 * @todo	Add RTL support
	 * 
	 * @return	string
	 */
	public function getStylesheet() {
		if (RequestHandler::getInstance()->isACPRequest()) {
			// ACP
			$filename = 'acp/style/style.css';
			if (!file_exists(WCF_DIR.$filename)) {
				StyleCompiler::getInstance()->compileACP();
			}
		}
		else {
			// frontend
			$filename = 'style/style-'.$this->getStyle()->styleID.'.css';
			if (!file_exists(WCF_DIR.$filename)) {
				StyleCompiler::getInstance()->compile($this->getStyle()->getDecoratedObject());
			}
		}
		
		return '<link rel="stylesheet" type="text/css" href="'.WCF::getPath().$filename.'?m='.filemtime(WCF_DIR.$filename).'" />';
	}
Example #11
0
<?php

/**
 * @author		Markus Zhang <*****@*****.**>
 * @copyright	2014 Markus Zhang
 * @license		GNU Lesser General Public License <http://www.gnu.org/licenses/lgpl.html>
 * @package		info.codingcorner.ict
 * @category	Icy Tracker
 */
require_once __DIR__ . '/global.php';
\wcf\system\request\RequestHandler::getInstance()->handle('ict');
Example #12
0
 /**
  * Updates user session on shutdown.
  */
 public function update()
 {
     if ($this->doNotUpdate) {
         return;
     }
     // set up data
     $data = array('ipAddress' => UserUtil::getIpAddress(), 'userAgent' => $this->userAgent, 'requestURI' => $this->requestURI, 'requestMethod' => $this->requestMethod, 'lastActivityTime' => TIME_NOW);
     if (!class_exists('wcf\\system\\CLIWCF', false) && PACKAGE_ID && RequestHandler::getInstance()->getActiveRequest() && RequestHandler::getInstance()->getActiveRequest()->getRequestObject() instanceof ITrackablePage && RequestHandler::getInstance()->getActiveRequest()->getRequestObject()->isTracked()) {
         $data['controller'] = RequestHandler::getInstance()->getActiveRequest()->getRequestObject()->getController();
         $data['parentObjectType'] = RequestHandler::getInstance()->getActiveRequest()->getRequestObject()->getParentObjectType();
         $data['parentObjectID'] = RequestHandler::getInstance()->getActiveRequest()->getRequestObject()->getParentObjectID();
         $data['objectType'] = RequestHandler::getInstance()->getActiveRequest()->getRequestObject()->getObjectType();
         $data['objectID'] = RequestHandler::getInstance()->getActiveRequest()->getRequestObject()->getObjectID();
     }
     if ($this->variablesChanged) {
         $data['sessionVariables'] = serialize($this->variables);
     }
     // update session
     $sessionEditor = new $this->sessionEditorClassName($this->session);
     $sessionEditor->update($data);
     if ($this->virtualSession instanceof SessionVirtual) {
         $virtualSessionEditor = new SessionVirtualEditor($this->virtualSession);
         $virtualSessionEditor->updateLastActivityTime();
     }
 }
Example #13
0
 /**
  * Updates user session on shutdown.
  */
 public function update()
 {
     if ($this->doNotUpdate) {
         return;
     }
     // set up data
     $data = array('ipAddress' => $this->ipAddress, 'userAgent' => $this->userAgent, 'requestURI' => $this->requestURI, 'requestMethod' => $this->requestMethod, 'lastActivityTime' => TIME_NOW, 'packageID' => PACKAGE_ID, 'controller' => PACKAGE_ID && RequestHandler::getInstance()->getActiveRequest() ? RequestHandler::getInstance()->getActiveRequest()->getClassName() : '');
     if ($this->variablesChanged) {
         $data['sessionVariables'] = serialize($this->variables);
     }
     // update session
     $sessionEditor = new $this->sessionEditorClassName($this->session);
     $sessionEditor->update($data);
 }
Example #14
0
 /**
  * Returns the transformed controller name.
  *
  * @param	string		$application
  * @param	string		$controller
  * @return	string
  */
 protected function getControllerName($application, $controller)
 {
     if (!isset(self::$controllerNames[$controller])) {
         $controllerName = RequestHandler::getTokenizedController($controller);
         $alias = !$this->isACP ? RequestHandler::getInstance()->getAliasByController($controllerName) : null;
         self::$controllerNames[$controller] = $alias ?: $controllerName;
     }
     return self::$controllerNames[$controller];
 }
 /**
  * Check pages and set parse status.
  */
 public static function parseFootnotes()
 {
     $request = RequestHandler::getInstance()->getActiveRequest();
     $pageName = StringUtil::toLowerCase($request->getPageName());
     $allowedPages = ArrayUtil::trim(explode("\n", StringUtil::toLowerCase(BBCODES_FOOTNOTE_PARSE_PAGE)));
     if (in_array($pageName, $allowedPages)) {
         static::$parse = true;
     } else {
         static::$parse = false;
     }
 }
Example #16
0
 /**
  * Builds a route based upon route components, this is nothing
  * but a reverse lookup.
  * 
  * @param	array		$components
  * @return	string
  */
 public function buildRoute(array $components)
 {
     foreach ($this->routes as $route) {
         if (RequestHandler::getInstance()->isACPRequest() != $route->isACP()) {
             continue;
         }
         if ($route->canHandle($components)) {
             return $route->buildLink($components);
         }
     }
     throw new SystemException("Unable to build route, no available route is satisfied.");
 }
Example #17
0
	/**
	 * Returns a relative link.
	 * 
	 * @param	string		$controller
	 * @param	array		$parameters
	 * @param	string		$url
	 * @return	string
	 */
	public function getLink($controller = null, array $parameters = array(), $url = '') {
		$abbreviation = 'wcf';
		$anchor = '';
		$isACP = $originIsACP = RequestHandler::getInstance()->isACPRequest();
		$isRaw = false;
		$appendSession = true;
		if (isset($parameters['application'])) {
			$abbreviation = $parameters['application'];
			unset($parameters['application']);
		}
		if (isset($parameters['isRaw'])) {
			$isRaw = $parameters['isRaw'];
			unset($parameters['isRaw']);
		}
		if (isset($parameters['appendSession'])) {
			$appendSession = $parameters['appendSession'];
			unset($parameters['appendSession']);
		}
		if (isset($parameters['isACP'])) {
			$isACP = (bool) $parameters['isACP'];
			unset($parameters['isACP']);
			
			// drop session id if link leads to ACP from frontend or vice versa
			if ($originIsACP != $isACP) {
				$appendSession = false;
			}
		}
		
		// remove anchor before parsing
		if (($pos = strpos($url, '#')) !== false) {
			$anchor = substr($url, $pos);
			$url = substr($url, 0, $pos);
		}
		
		// build route
		if ($controller === null) {
			// build link to landing page
			$landingPage = PageMenu::getInstance()->getLandingPage();
			$controller = $landingPage->getController();
			$abbreviation = $landingPage->getApplication();
			$url = $landingPage->menuItemLink;
		}
		
		// handle object
		if (isset($parameters['object'])) {
			if (!($parameters['object'] instanceof IRouteController) && $parameters['object'] instanceof DatabaseObjectDecorator && $parameters['object']->getDecoratedObject() instanceof IRouteController) {
				$parameters['object'] = $parameters['object']->getDecoratedObject();
			}
			
			if ($parameters['object'] instanceof IRouteController) {
				$parameters['id'] = $parameters['object']->getObjectID();
				$parameters['title'] = $parameters['object']->getTitle();
			}
			
			unset($parameters['object']);
		}
		
		if (isset($parameters['title'])) {
			// remove illegal characters
			$parameters['title'] = trim($this->titleRegex->replace($parameters['title'], '-'), '-');
		}
		
		$parameters['controller'] = $controller;
		$routeURL = RouteHandler::getInstance()->buildRoute($parameters);
		if (!$isRaw && !empty($url)) {
			$routeURL .= (strpos($routeURL, '?') === false) ? '?' : '&';
		}
		$url = $routeURL . $url;
		
		// append session id
		if ($appendSession) {
			$url .= (strpos($url, '?') === false) ? SID_ARG_1ST : SID_ARG_2ND_NOT_ENCODED;
		}
		
		// handle applications
		if (!PACKAGE_ID) {
			$url = RouteHandler::getHost() . RouteHandler::getPath(array('acp')) . ($isACP ? 'acp/' : '') . $url;
		}
		else {
			// try to resolve abbreviation
			$application = null;
			if ($abbreviation != 'wcf') {
				$application = ApplicationHandler::getInstance()->getApplication($abbreviation);
			}
			
			// fallback to primary application if abbreviation is 'wcf' or unknown
			if ($application === null) {
				$application = ApplicationHandler::getInstance()->getPrimaryApplication();
			}
			
			$url = $application->getPageURL() . ($isACP ? 'acp/' : '') . $url;
		}
		
		// append previously removed anchor
		$url .= $anchor;
		
		return $url;
	}
Example #18
0
 /**
  * Returns a relative link.
  * 
  * @param	string		$controller
  * @param	array		$parameters
  * @param	string		$url
  * @return	string
  */
 public function getLink($controller = null, array $parameters = array(), $url = '')
 {
     $abbreviation = 'wcf';
     $anchor = '';
     $isACP = $originIsACP = RequestHandler::getInstance()->isACPRequest();
     $forceWCF = $isRaw = false;
     $appendSession = $encodeTitle = true;
     // enforce a certain level of sanitation and protection for links embedded in emails
     if (isset($parameters['isEmail']) && (bool) $parameters['isEmail']) {
         $parameters['forceFrontend'] = true;
         $parameters['appendSession'] = false;
         unset($parameters['isEmail']);
     }
     if (isset($parameters['application'])) {
         $abbreviation = $parameters['application'];
     }
     if (isset($parameters['isRaw'])) {
         $isRaw = $parameters['isRaw'];
         unset($parameters['isRaw']);
     }
     if (isset($parameters['appendSession'])) {
         $appendSession = $parameters['appendSession'];
         unset($parameters['appendSession']);
     }
     if (isset($parameters['isACP'])) {
         $isACP = (bool) $parameters['isACP'];
         unset($parameters['isACP']);
         // drop session id if link leads to ACP from frontend or vice versa
         if ($originIsACP != $isACP) {
             $appendSession = false;
         }
     }
     if (isset($parameters['forceFrontend'])) {
         if ($parameters['forceFrontend'] && $isACP) {
             $isACP = false;
             $appendSession = false;
         }
         unset($parameters['forceFrontend']);
     }
     if (isset($parameters['forceWCF'])) {
         if ($parameters['forceWCF'] && $isACP) {
             $forceWCF = true;
         }
         unset($parameters['forceWCF']);
     }
     if (isset($parameters['encodeTitle'])) {
         $encodeTitle = $parameters['encodeTitle'];
         unset($parameters['encodeTitle']);
     }
     // remove anchor before parsing
     if (($pos = strpos($url, '#')) !== false) {
         $anchor = substr($url, $pos);
         $url = substr($url, 0, $pos);
     }
     // build route
     if ($controller === null) {
         if ($isACP) {
             $controller = 'Index';
         } else {
             return PageMenu::getInstance()->getLandingPage()->getProcessor()->getLink();
         }
     }
     // handle object
     if (isset($parameters['object'])) {
         if (!$parameters['object'] instanceof IRouteController && $parameters['object'] instanceof DatabaseObjectDecorator && $parameters['object']->getDecoratedObject() instanceof IRouteController) {
             $parameters['object'] = $parameters['object']->getDecoratedObject();
         }
         if ($parameters['object'] instanceof IRouteController) {
             $parameters['id'] = $parameters['object']->getObjectID();
             $parameters['title'] = $parameters['object']->getTitle();
         }
     }
     unset($parameters['object']);
     if (isset($parameters['title'])) {
         // component replacement
         if (!empty($this->titleSearch)) {
             $parameters['title'] = str_replace($this->titleSearch, $this->titleReplace, $parameters['title']);
         }
         // remove illegal characters
         $parameters['title'] = trim($this->titleRegex->replace($parameters['title'], '-'), '-');
         // trim to 80 characters
         $parameters['title'] = rtrim(mb_substr($parameters['title'], 0, 80), '-');
         if (!URL_LEGACY_MODE) {
             $parameters['title'] = mb_strtolower($parameters['title']);
         }
         // encode title
         if ($encodeTitle) {
             $parameters['title'] = rawurlencode($parameters['title']);
         }
     }
     $parameters['controller'] = $controller;
     $routeURL = RouteHandler::getInstance()->buildRoute($parameters, $isACP);
     if (!$isRaw && !empty($url)) {
         $routeURL .= strpos($routeURL, '?') === false ? '?' : '&';
     }
     // encode certain characters
     if (!empty($url)) {
         $url = str_replace(array('[', ']'), array('%5B', '%5D'), $url);
     }
     $url = $routeURL . $url;
     // append session id
     if ($appendSession) {
         $url .= strpos($url, '?') === false ? SID_ARG_1ST : SID_ARG_2ND_NOT_ENCODED;
     }
     // handle applications
     if (!PACKAGE_ID) {
         $url = RouteHandler::getHost() . RouteHandler::getPath(array('acp')) . ($isACP ? 'acp/' : '') . $url;
     } else {
         if (RequestHandler::getInstance()->inRescueMode()) {
             $pageURL = RouteHandler::getHost() . str_replace('//', '/', RouteHandler::getPath(array('acp')));
         } else {
             // try to resolve abbreviation
             $application = null;
             if ($abbreviation != 'wcf') {
                 $application = ApplicationHandler::getInstance()->getApplication($abbreviation);
             }
             // fallback to primary application if abbreviation is 'wcf' or unknown
             if ($forceWCF) {
                 $application = ApplicationHandler::getInstance()->getWCF();
             } else {
                 if ($application === null) {
                     $application = ApplicationHandler::getInstance()->getPrimaryApplication();
                 }
             }
             $pageURL = $application->getPageURL();
         }
         $url = $pageURL . ($isACP ? 'acp/' : '') . $url;
     }
     // append previously removed anchor
     $url .= $anchor;
     return $url;
 }
Example #19
0
 /**
  * @see	\wcf\form\IForm::save()
  */
 public function save()
 {
     parent::save();
     // change user
     WCF::getSession()->changeUser($this->user);
     $this->saved();
     if (!empty($this->url)) {
         // append session
         if (mb_strpos($this->url, '?') !== false) {
             $this->url .= SID_ARG_2ND_NOT_ENCODED;
         } else {
             $this->url .= SID_ARG_1ST;
         }
         HeaderUtil::redirect($this->url);
     } else {
         if (RequestHandler::getInstance()->inRescueMode()) {
             $path = RouteHandler::getHost() . RouteHandler::getPath() . SID_ARG_1ST;
         } else {
             $application = ApplicationHandler::getInstance()->getActiveApplication();
             $path = $application->getPageURL() . 'acp/' . SID_ARG_1ST;
         }
         HeaderUtil::redirect($path);
     }
     exit;
 }
 /**
  * @todo	This whole page is carzy, it's manipulating the requested page, but RequestHandler does not work this way
  * @see wcf\page\IPage::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['loginUsername'])) {
         $this->loginUsername = $_REQUEST['loginUsername'];
     }
     if (isset($_REQUEST['loginPassword'])) {
         $this->loginPassword = $_REQUEST['loginPassword'];
     }
     if (isset($_REQUEST['saveAuthData'])) {
         $this->saveAuthData = intval($_REQUEST['saveAuthData']);
     }
     if ($this->packageUpdateServerID == 0 && isset($_REQUEST['packageUpdateServerID'])) {
         $this->packageUpdateServerID = intval($_REQUEST['packageUpdateServerID']);
     }
     if (!empty($_REQUEST['requestedPage']) || !empty($_REQUEST['requestedForm']) || !empty($_REQUEST['requestedAction'])) {
         // get update server
         $updateServer = new PackageUpdateServer($this->packageUpdateServerID);
         if (!$updateServer->packageUpdateServerID) {
             throw new IllegalLinkException();
         }
         // update update server
         if ($this->saveAuthData) {
             $updateServerEditor = new PackageUpdateServerEditor($updateServer);
             $updateServerEditor->update(array('loginUsername' => $this->loginUsername, 'loginPassword' => $this->loginPassword));
         }
         // save auth data in session
         $authData = array('authType' => 'Basic', 'loginUsername' => $this->loginUsername, 'loginPassword' => $this->loginPassword);
         // session data
         $packageUpdateAuthData = WCF::getSession()->getVar('packageUpdateAuthData');
         if ($packageUpdateAuthData === null) {
             $packageUpdateAuthData = array();
         }
         $packageUpdateAuthData[$this->packageUpdateServerID] = $authData;
         WCF::getSession()->register('packageUpdateAuthData', $packageUpdateAuthData);
         // remove form=PackageUpdateAuth
         unset($_REQUEST['form'], $_GET['form'], $_POST['form']);
         // set page/form/action
         if (!empty($_REQUEST['requestedPage'])) {
             $_POST['page'] = $_REQUEST['requestedPage'];
         } else {
             if (!empty($_REQUEST['requestedForm'])) {
                 $_POST['form'] = $_REQUEST['requestedForm'];
             } else {
                 $_POST['action'] = $_REQUEST['requestedAction'];
             }
         }
         // remove requestedPage...
         unset($_REQUEST['requestedPage'], $_REQUEST['requestedForm'], $_REQUEST['requestedAction']);
         // start request handler
         /**
          * TODO: This is not working anymore, find a solution!
          */
         global $packageDirs;
         RequestHandler::handle(ArrayUtil::appendSuffix(!empty($packageDirs) ? $packageDirs : array(WCF_DIR), 'lib/acp/'));
         exit;
     }
 }
Example #21
0
 /**
  * Returns current path info component.
  * 
  * @return	string
  */
 public static function getPathInfo()
 {
     if (self::$pathInfo === null) {
         self::$pathInfo = '';
         if (!URL_LEGACY_MODE || RequestHandler::getInstance()->isACPRequest()) {
             // WCF 2.1: ?Foo/Bar/
             if (!empty($_SERVER['QUERY_STRING'])) {
                 // don't use parse_str as it replaces dots with underscores
                 $components = explode('&', $_SERVER['QUERY_STRING']);
                 for ($i = 0, $length = count($components); $i < $length; $i++) {
                     $component = $components[$i];
                     $pos = mb_strpos($component, '=');
                     if ($pos !== false && $pos + 1 === mb_strlen($component)) {
                         $component = mb_substr($component, 0, -1);
                         $pos = false;
                     }
                     if ($pos === false) {
                         self::$pathInfo = urldecode($component);
                         break;
                     }
                 }
             }
         }
         // WCF 2.0: index.php/Foo/Bar/
         if (URL_LEGACY_MODE && !RequestHandler::getInstance()->isACPRequest() || RequestHandler::getInstance()->isACPRequest() && empty(self::$pathInfo)) {
             if (isset($_SERVER['PATH_INFO'])) {
                 self::$pathInfo = $_SERVER['PATH_INFO'];
             } else {
                 if (isset($_SERVER['ORIG_PATH_INFO'])) {
                     self::$pathInfo = $_SERVER['ORIG_PATH_INFO'];
                     // in some configurations ORIG_PATH_INFO contains the path to the file
                     // if the intended PATH_INFO component is empty
                     if (!empty(self::$pathInfo)) {
                         if (isset($_SERVER['SCRIPT_NAME']) && self::$pathInfo == $_SERVER['SCRIPT_NAME']) {
                             self::$pathInfo = '';
                         }
                         if (isset($_SERVER['PHP_SELF']) && self::$pathInfo == $_SERVER['PHP_SELF']) {
                             self::$pathInfo = '';
                         }
                         if (isset($_SERVER['SCRIPT_URL']) && self::$pathInfo == $_SERVER['SCRIPT_URL']) {
                             self::$pathInfo = '';
                         }
                     }
                 }
             }
         }
     }
     return self::$pathInfo;
 }
Example #22
0
 /**
  * Validates permissions and parameters.
  */
 public function validateUpdate()
 {
     // read objects
     if (empty($this->objects)) {
         $this->readObjects();
         if (empty($this->objects)) {
             throw new UserInputException('objectIDs');
         }
     }
     // disallow updating of anything except for options outside of ACP
     if (RequestHandler::getInstance()->isACPRequest() && (count($this->parameters) != 1 || !isset($this->parameters['options']))) {
         throw new PermissionDeniedException();
     }
     try {
         WCF::getSession()->checkPermissions($this->permissionsUpdate);
     } catch (PermissionDeniedException $e) {
         // check if we're editing ourselves
         if (count($this->objects) == 1 && $this->objects[0]->userID == WCF::getUser()->userID) {
             $count = count($this->parameters);
             if ($count > 1 || $count == 1 && !isset($this->parameters['options'])) {
                 throw new PermissionDeniedException();
             }
         }
         throw new PermissionDeniedException();
     }
 }
Example #23
0
	/**
	 * Builds a link upon route components.
	 * 
	 * @param	array		$components
	 * @return	string
	 */
	public function buildLink(array $components) {
		$link = '';
		
		// handle default values for controller
		$buildRoute = true;
		if (count($components) == 1 && isset($components['controller'])) {
			$ignoreController = false;
			if (isset($this->parameterOptions['controller']) && strcasecmp($this->parameterOptions['controller']['default'], $components['controller']) == 0) {
				// only the controller was given and matches default, omit routing
				$ignoreController = true;
			}
			else if (!RequestHandler::getInstance()->isACPRequest()) {
				$landingPage = PageMenu::getInstance()->getLandingPage();
				if ($landingPage !== null && ($landingPage->getController() == $components['controller'])) {
					$ignoreController = true;
				}
			}
			
			// drops controller from route
			if ($ignoreController) {
				$buildRoute = false;
				
				// unset the controller, since it would otherwise added with http_build_query()
				unset($components['controller']);
			}
		}
		
		if ($buildRoute) {
			foreach ($this->routeSchema as $component) {
				if (!isset($components[$component])) {
					continue;
				}
				
				// handle built-in SEO
				if ($component === 'id' && isset($components['title'])) {
					$link .= $components[$component] . '-' . $components['title'] . '/';
					unset($components['title']);
				}
				else {
					$link .= $components[$component] . '/';
				}
				unset($components[$component]);
			}
		}
		
		if (!empty($link)) {
			$link = 'index.php/' . $link;
		}
		
		if (!empty($components)) {
			$link .= '?' . http_build_query($components, '', '&');
		}
		
		return $link;
	}
Example #24
0
 /**
  * Sets the active menu item of the page.
  */
 protected function setActiveMenuItem()
 {
     if (!empty($this->activeMenuItem)) {
         if (RequestHandler::getInstance()->isACPRequest()) {
             ACPMenu::getInstance()->setActiveMenuItem($this->activeMenuItem);
         } else {
             PageMenu::getInstance()->setActiveMenuItem($this->activeMenuItem);
         }
     }
 }
 /**
  * @see	\wcf\data\IDatabaseObjectAction::validateAction()
  */
 public function validateAction()
 {
     // validate if user is logged in
     if (!WCF::getUser()->userID && !in_array($this->getActionName(), $this->allowGuestAccess)) {
         throw new PermissionDeniedException();
     } else {
         if (!RequestHandler::getInstance()->isACPRequest() && in_array($this->getActionName(), $this->requireACP)) {
             // attempt to invoke method, but origin is not the ACP
             throw new PermissionDeniedException();
         }
     }
     // validate action name
     if (!method_exists($this, $this->getActionName())) {
         throw new SystemException("unknown action '" . $this->getActionName() . "'");
     }
     $actionName = 'validate' . StringUtil::firstCharToUpperCase($this->getActionName());
     if (!method_exists($this, $actionName)) {
         throw new PermissionDeniedException();
     }
     // execute action
     call_user_func_array(array($this, $actionName), $this->getParameters());
     // fire event action
     EventHandler::getInstance()->fireAction($this, 'validateAction');
 }