예제 #1
0
파일: fix.php 프로젝트: Ruud68/Kunena-Forum
 /**
  *
  */
 protected static function build()
 {
     if (!isset(self::$structure)) {
         self::$structure = array();
         foreach (self::$items as $item) {
             if (!is_object($item)) {
                 continue;
             }
             $itemid = null;
             $view = null;
             if ($item->type == 'alias' && !empty($item->query['Itemid'])) {
                 $realitem = empty(self::$items[$item->query['Itemid']]) ? null : self::$items[$item->query['Itemid']];
                 if (is_object($realitem) && $realitem->type == 'component' && $realitem->component == 'com_kunena') {
                     $itemid = $item->query['Itemid'];
                     self::$aliases[$item->id] = $itemid;
                 } elseif (!$realitem) {
                     $itemid = 0;
                     self::$invalid[$item->id] = $itemid;
                 }
                 $view = 'alias';
             } elseif ($item->type == 'component' && $item->component == 'com_kunena') {
                 $itemid = $item->id;
                 $view = empty($item->query['view']) ? 'legacy' : $item->query['view'];
             }
             if ($itemid !== null && $view) {
                 $language = isset($item->language) ? strtolower($item->language) : '*';
                 $home = self::getHome($item);
                 self::$filtered[$item->id] = $itemid;
                 self::$same[$item->route][$item->id] = $item;
                 self::$structure[$language][$home ? $home->id : 0][$view][$item->id] = $itemid;
                 if (KunenaRouteLegacy::isLegacy($view)) {
                     self::$legacy[$item->id] = $item->id;
                 }
             }
         }
     }
 }
예제 #2
0
 protected static function prepare($uri = null)
 {
     static $current = array();
     KUNENA_PROFILER ? KunenaProfiler::instance()->start('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
     if (!$uri || is_string($uri) && $uri[0] == '&') {
         if (!isset($current[$uri])) {
             $get = self::$current->getQuery(true);
             $uri = $current[$uri] = JUri::getInstance('index.php?' . http_build_query($get) . $uri);
             self::setItemID($uri);
             $uri->delVar('defaultmenu');
             $uri->delVar('language');
         } else {
             $uri = $current[$uri];
         }
     } elseif (is_numeric($uri)) {
         if (!isset(self::$menu[intval($uri)])) {
             KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
             return false;
         }
         $item = self::$menu[intval($uri)];
         $uri = JUri::getInstance("{$item->link}&Itemid={$item->id}");
     } elseif ($uri instanceof JUri) {
         // Nothing to do
     } else {
         $uri = new JUri((string) $uri);
     }
     $option = $uri->getVar('option');
     $Itemid = $uri->getVar('Itemid');
     if (!$option && !$Itemid) {
         KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
         return false;
     } elseif ($option && $option != 'com_kunena') {
         KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
         return false;
     } elseif ($Itemid && (!isset(self::$menu[$Itemid]) || self::$menu[$Itemid]->component != 'com_kunena')) {
         KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
         return false;
     }
     // Support legacy URIs
     if ($uri->getVar('func')) {
         $result = KunenaRouteLegacy::convert($uri);
         KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
         if (!$result) {
             return false;
         }
         return $uri;
     }
     // Check URI
     switch ($uri->getVar('view', 'home')) {
         case 'announcement':
             KunenaRouteLegacy::convert($uri);
             $r = array();
             break;
         case 'category':
             $r = array('catid', 'limitstart', 'limit');
             break;
         case 'common':
             $r = array();
             break;
         case 'credits':
             $r = array();
             break;
         case 'home':
             $r = array();
             break;
         case 'misc':
             $r = array();
             break;
         case 'search':
             $r = array('q', 'query', 'titleonly', 'searchuser', 'starteronly', 'exactname', 'replyless', 'replylimit', 'searchdate', 'beforeafter', 'sortby', 'order', 'childforums', 'catids', 'show', 'limitstart', 'limit');
             break;
         case 'statistics':
             $r = array();
             break;
         case 'topic':
             $r = array('catid', 'id', 'mesid', 'limitstart', 'limit');
             break;
         case 'topics':
             $r = array('mode', 'userid', 'sel', 'limitstart', 'limit');
             break;
         case 'user':
             $r = array('userid');
             break;
         case 'users':
             $r = array('search', 'limitstart', 'limit');
             break;
         default:
             $result = KunenaRouteLegacy::convert($uri);
             if (!$result) {
                 KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
                 return false;
             }
     }
     KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
     return $uri;
 }
예제 #3
0
파일: route.php 프로젝트: BillVGN/PortalPRP
	protected static function prepare($uri = null)
	{
		static $current = array();
		KUNENA_PROFILER ? KunenaProfiler::instance()->start('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;

		if (!$uri || (is_string($uri) && $uri[0] == '&'))
		{
			if (!isset($current[$uri]))
			{
				$get = self::$current->getQuery(true);
				$uri = $current[$uri] = JUri::getInstance('index.php?'.http_build_query($get).$uri);
				self::setItemID($uri);
				$uri->delVar ( 'defaultmenu' );
				$uri->delVar ( 'language' );
			}
			else
			{
				$uri = $current[$uri];
			}
		}
		elseif (is_numeric($uri))
		{
			if (!isset(self::$menu[intval($uri)]))
			{
				KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;

				return false;
			}

			$item = self::$menu[intval($uri)];
			$uri = JUri::getInstance ( "{$item->link}&Itemid={$item->id}" );
		}
		elseif ($uri instanceof JUri)
		{
			// Nothing to do
		}
		else {
			$uri = new JUri((string) $uri);
		}

		$option = $uri->getVar('option');
		$Itemid = $uri->getVar('Itemid');

		if (!$option && !$Itemid)
		{
			KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;

			return false;
		}
		elseif ($option && $option != 'com_kunena')
		{
			KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;

			return false;
		}
		elseif ($Itemid && (!isset(self::$menu[$Itemid]) || self::$menu[$Itemid]->component != 'com_kunena'))
		{
			KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;

			return false;
		}

		// Support legacy URIs
		$legacy_urls = self::$config->get('legacy_urls', 1);

		if ($legacy_urls && $uri->getVar('func'))
		{
			$result = KunenaRouteLegacy::convert($uri);
			KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;

			if (!$result)
			{
				return false;
			}

			return $uri;
		}

		// Check URI
		switch ($uri->getVar('view', 'home')) {
			case 'announcement':
				if ($legacy_urls) KunenaRouteLegacy::convert($uri);
				break;

			case 'attachment':
			case 'category':
			case 'common':
			case 'credits':
			case 'home':
			case 'misc':
			case 'search':
			case 'statistics':
			case 'topic':
			case 'topics':
			case 'user':
			case 'users':
				break;

			default:
				if (!$legacy_urls || !KunenaRouteLegacy::convert($uri))
				{
					KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
					return false;
				}
		}
		KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;

		return $uri;
	}
예제 #4
0
 protected static function prepare($uri = null)
 {
     static $current = array();
     KUNENA_PROFILER ? KunenaProfiler::instance()->start('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
     if (!$uri || is_string($uri) && $uri[0] == '&') {
         if (!isset($current[$uri])) {
             $get = array();
             // If values are both in GET and POST, they are only stored in POST
             foreach (JRequest::get('post') as $key => $value) {
                 if (($key == 'view' || $key == 'layout' || $key == 'task') && !preg_match('/[^a-zA-Z0-9_ ]/i', $value)) {
                     $get[$key] = $value;
                 }
             }
             // Make sure that request URI is not broken
             foreach (JRequest::get('get') as $key => $value) {
                 if (preg_match('/[^a-zA-Z]/', $key)) {
                     continue;
                 }
                 if ($key == 'q' || $key == 'searchuser') {
                     // Allow all values
                 } elseif (preg_match('/[^a-zA-Z0-9_ ]/i', $value)) {
                     // Illegal value
                     continue;
                 }
                 $get[$key] = $value;
             }
             $uri = $current[$uri] = JURI::getInstance('index.php?' . http_build_query($get) . $uri);
             self::setItemID($uri);
             $uri->delVar('defaultmenu');
             $uri->delVar('language');
         } else {
             $uri = $current[$uri];
         }
     } elseif (is_numeric($uri)) {
         if (!isset(self::$menu[intval($uri)])) {
             KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
             return false;
         }
         $item = self::$menu[intval($uri)];
         $uri = JURI::getInstance("{$item->link}&Itemid={$item->id}");
     } elseif ($uri instanceof JURI) {
         // Nothing to do
     } else {
         $uri = JURI::getInstance((string) $uri);
     }
     $option = $uri->getVar('option');
     $Itemid = $uri->getVar('Itemid');
     if (!$option && !$Itemid) {
         KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
         return false;
     } elseif ($option && $option != 'com_kunena') {
         KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
         return false;
     } elseif ($Itemid && (!isset(self::$menu[$Itemid]) || self::$menu[$Itemid]->component != 'com_kunena')) {
         KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
         return false;
     }
     // Support legacy URIs
     if ($uri->getVar('func')) {
         $result = KunenaRouteLegacy::convert($uri);
         KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
         if (!$result) {
             return false;
         }
         return $uri;
     }
     // Check URI
     switch ($uri->getVar('view', 'home')) {
         case 'announcement':
             KunenaRouteLegacy::convert($uri);
             $r = array();
             break;
         case 'category':
             $r = array('catid', 'limitstart', 'limit');
             break;
         case 'common':
             $r = array();
             break;
         case 'credits':
             $r = array();
             break;
         case 'home':
             $r = array();
             break;
         case 'misc':
             $r = array();
             break;
         case 'search':
             $r = array('q', 'titleonly', 'searchuser', 'starteronly', 'exactname', 'replyless', 'replylimit', 'searchdate', 'beforeafter', 'sortby', 'order', 'childforums', 'catids', 'show', 'limitstart', 'limit');
             break;
         case 'statistics':
             $r = array();
             break;
         case 'topic':
             $r = array('catid', 'id', 'mesid', 'limitstart', 'limit');
             break;
         case 'topics':
             $r = array('mode', 'userid', 'sel', 'limitstart', 'limit');
             break;
         case 'user':
             $r = array('userid');
             break;
         case 'users':
             $r = array('search', 'limitstart', 'limit');
             break;
         default:
             $result = KunenaRouteLegacy::convert($uri);
             if (!$result) {
                 KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
                 return false;
             }
     }
     KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
     return $uri;
 }