mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 20:00:37 +02:00
index.php is now system entry point, front page detection moved to index controller; various stabillity fixes and url admin interface improvements; htaccess template modfied to meet entry point changes; front page preference values (Front Page admin page) prefixed with 'url:' and 'route:' now accepted and recognized; full backward compatibility so far.
This commit is contained in:
@@ -24,6 +24,6 @@
|
||||
RewriteCond %{REQUEST_FILENAME} !-l
|
||||
|
||||
### Single entry point ###
|
||||
RewriteRule .* rewrite.php [L]
|
||||
RewriteRule .* index.php [L]
|
||||
|
||||
</IfModule>
|
||||
|
@@ -441,12 +441,33 @@ class eurl_admin_form_ui extends e_admin_form_ui
|
||||
|
||||
foreach ($modules as $module => $obj)
|
||||
{
|
||||
$cfg = $obj->config->config();
|
||||
if(isset($cfg['config']['noSingleEntry']) && $cfg['config']['noSingleEntry']) continue;
|
||||
|
||||
if($module == 'index')
|
||||
{
|
||||
$text .= "
|
||||
<tr>
|
||||
<td class='label'>
|
||||
".LAN_EURL_CORE_INDEX."
|
||||
</td>
|
||||
<td class='control'>
|
||||
".LAN_EURL_CORE_INDEX_INFO."
|
||||
</td>
|
||||
<td class='control'>
|
||||
".LAN_EURL_FORM_HELP_EXAMPLE." <br /><strong>".e107::getUrl()->create('/', '', array('full' => 1))."</strong>
|
||||
</td>
|
||||
</tr>
|
||||
";
|
||||
continue;
|
||||
}
|
||||
$help = array();
|
||||
$admin = $obj->config->admin();
|
||||
$lan = $lanDef[0];
|
||||
$url = e107::getUrl()->create($module, '', array('full' => 1));
|
||||
$defVal = isset($currentAliases[$lan]) && in_array($module, $currentAliases[$lan]) ? array_search($module, $currentAliases[$lan]) : $module;
|
||||
$section = vartrue($admin['labels'], array());
|
||||
|
||||
$text .= "
|
||||
<tr>
|
||||
<td class='label'>
|
||||
@@ -458,9 +479,9 @@ class eurl_admin_form_ui extends e_admin_form_ui
|
||||
<td class='control'>
|
||||
";
|
||||
|
||||
|
||||
|
||||
// default language
|
||||
|
||||
|
||||
$text .= $this->text('eurl_aliases['.$lanDef[0].']['.$module.']', $defVal).' ['.$lanDef[1].']'.$this->help(LAN_EURL_FORM_HELP_DEFAULT);
|
||||
$help[] = '['.$lanDef[1].'] '.LAN_EURL_FORM_HELP_EXAMPLE.'<br /><strong>'.$url.'</strong>';
|
||||
|
||||
@@ -468,6 +489,7 @@ class eurl_admin_form_ui extends e_admin_form_ui
|
||||
{
|
||||
foreach ($lans as $code => $lan)
|
||||
{
|
||||
|
||||
$url = e107::getUrl()->create($module, '', array('lan' => $code, 'full' => 1));
|
||||
$defVal = isset($currentAliases[$code]) && in_array($module, $currentAliases[$code]) ? array_search($module, $currentAliases[$code]) : $module;
|
||||
$text .= "<div class='spacer'><!-- --></div>";
|
||||
@@ -476,6 +498,11 @@ class eurl_admin_form_ui extends e_admin_form_ui
|
||||
}
|
||||
}
|
||||
|
||||
if(e107::getUrl()->router()->isMainModule($module))
|
||||
{
|
||||
$help = array(LAN_EURL_CORE_MAIN);
|
||||
}
|
||||
|
||||
$text .= "
|
||||
</td>
|
||||
<td class='control'>
|
||||
|
181
e107_core/controllers/index/index.php
Normal file
181
e107_core/controllers/index/index.php
Normal file
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2011 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* Front page controller
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*/
|
||||
class core_index_index_controller extends eController
|
||||
{
|
||||
/**
|
||||
* Do frontpage checks
|
||||
* Valid formats for frontpage preference value:
|
||||
* - url:Blog/My Blog Title.html (no redirect)
|
||||
* - url:news.php?extend.2 (no redirect)
|
||||
* - route:news/view/item?id=2 (no redirect)
|
||||
* - news.php?extend.2 (no redirect)
|
||||
* - http://mysite.com/news.php?extend.2 (redirect)
|
||||
* - http://mysite.com/Blog/My Blog Title.html (redirect)
|
||||
* - http://NotMysite.com/someurl/ (redirect) - really not sure who'd need that...
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$pref = eFront::app()->getPref();
|
||||
$tp = e107::getParser();
|
||||
$indexRoute = 'index/index/index';
|
||||
|
||||
if (file_exists(e_BASE.'index_include.php'))
|
||||
{
|
||||
include (e_BASE.'index_include.php');
|
||||
}
|
||||
|
||||
$location = '';
|
||||
$class_list = explode(',', USERCLASS_LIST);
|
||||
|
||||
if (isset($pref['frontpage']['all']) && $pref['frontpage']['all'])
|
||||
{ // 0.7 method
|
||||
$location = $pref['frontpage']['all'];
|
||||
}
|
||||
else
|
||||
{ // This is the 'new' method - assumes $pref['frontpage'] is an ordered list of rules
|
||||
if(vartrue($pref['frontpage']))
|
||||
{
|
||||
foreach ($pref['frontpage'] as $fk=>$fp)
|
||||
{
|
||||
if (in_array($fk, $class_list))
|
||||
{
|
||||
$location = $fp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$location)
|
||||
{ // Try and use the 'old' method (this bit can go later)
|
||||
if (ADMIN)
|
||||
{
|
||||
$location = $pref['frontpage'][e_UC_ADMIN];
|
||||
}
|
||||
elseif (USER)
|
||||
{ // This is the key bit - what to do for a 'normal' logged in user
|
||||
// We have USERCLASS_LIST - comma separated. Also e_CLASS_REGEXP
|
||||
foreach ($class_list as $fp_class)
|
||||
{
|
||||
$inclass = false;
|
||||
if (!$inclass && check_class($fp_class['userclass_id']))
|
||||
{
|
||||
$location = $pref['frontpage'][$fp_class['userclass_id']];
|
||||
$inclass = true;
|
||||
}
|
||||
}
|
||||
$location = $location ? $location : $pref['frontpage'][e_UC_MEMBER];
|
||||
}
|
||||
else
|
||||
{
|
||||
$location = $pref['frontpage'][e_UC_GUEST];
|
||||
}
|
||||
}
|
||||
|
||||
$location = trim($location);
|
||||
$request = $this->getRequest();
|
||||
|
||||
// Defaults to news
|
||||
if(!$location) $location = 'url:/news';
|
||||
// Former Welcome Message front-page. Should be handled by current theme layout
|
||||
elseif($location == 'index.php' || $location == 'url:/' || $location == 'route:/' || $location == '/')
|
||||
{
|
||||
$this->_forward('front');
|
||||
return;
|
||||
}
|
||||
elseif($location[0] === '{')
|
||||
{
|
||||
$location = $tp->replaceConstants($location, true);
|
||||
}
|
||||
|
||||
// new url format; if set to 'url:' only it'll resolve current main module (if any)
|
||||
if(strpos($location, 'url:') === 0)
|
||||
{
|
||||
$url = substr($location, 4);
|
||||
$request->setPathInfo($url)->setRequestParams(array());
|
||||
$router = eFront::instance()->getRouter();
|
||||
|
||||
if($router->route($request, true))
|
||||
{
|
||||
if($request->getRoute() == $indexRoute)
|
||||
{
|
||||
throw new eException('Infinite loop detected while dispatching front page.', 2);
|
||||
}
|
||||
$this->_forward($request->getRoute());
|
||||
return;
|
||||
}
|
||||
$this->_forward('system/error/notfound', array('frontPageErorr' => null));
|
||||
}
|
||||
// route is provided
|
||||
elseif(strpos($location, 'route:') === 0)
|
||||
{
|
||||
list($route, $qstr) = explode('?', substr($location, 6).'?');
|
||||
|
||||
if(!$qstr) $qstr = array();
|
||||
else parse_str($qstr, $qstr);
|
||||
|
||||
$request->setRoute($route);
|
||||
$request->setRequestParams($qstr);
|
||||
|
||||
if($request->getRoute() == $indexRoute)
|
||||
{
|
||||
throw new eException('Infinite loop detected while dispatching front page.', 2);
|
||||
}
|
||||
|
||||
$this->_forward($request->getRoute(), $qstr);
|
||||
|
||||
return;
|
||||
}
|
||||
// redirect to this address
|
||||
elseif(strpos($location, 'http://') === 0 || strpos($location, 'https://') === 0)
|
||||
{
|
||||
if(e_REQUEST_URL != $location)
|
||||
{
|
||||
header("Location: {$location}");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
// Enter in legacy mod, include the front page
|
||||
elseif(strpos($location, '.php') !== false)
|
||||
{
|
||||
list($page, $qstr) = explode("?", $location."?");
|
||||
|
||||
$request->setLegacyPage($page)
|
||||
->setLegacyQstring($qstr);
|
||||
|
||||
$request->routed = true;
|
||||
|
||||
eFront::isLegacy('{e_BASE}'.$page);
|
||||
return $this;
|
||||
}
|
||||
// Redirect
|
||||
else
|
||||
{
|
||||
$location = SITEURL.$location;
|
||||
if(e_REQUEST_URL != $location)
|
||||
{
|
||||
header("Location: {$location}");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// we can't do much
|
||||
$this->_forward('system/error/notfound', array('frontPageErorr' => null));
|
||||
}
|
||||
|
||||
public function actionFront()
|
||||
{
|
||||
// we could notify current theme we are in front page controlled by the theme layout only...
|
||||
}
|
||||
}
|
@@ -1,5 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2011 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* System error controller
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*/
|
||||
class core_system_error_controller extends eController
|
||||
{
|
||||
function preAction()
|
||||
|
@@ -1,10 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2011 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
* System index controller
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*/
|
||||
class core_system_index_controller extends eController
|
||||
{
|
||||
/**
|
||||
* Temporary redirect to site Index
|
||||
* XXX - move the index.php Front page detection to index/index/index, make index.php the entry point and _forward here
|
||||
* Redirect to site Index
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
|
@@ -88,7 +88,7 @@ class core_news_rewrite_url extends eUrlConfig
|
||||
{
|
||||
// news/Category/Category-Name?page=xxx
|
||||
// news/Short/Category-Name?page=xxx
|
||||
$r[0] = $route[1] == 'category' ? 'Short' : 'Category';
|
||||
$r[0] = $route[1] == 'category' ? 'Category' : 'Short';
|
||||
$r[1] = $params['name'] ? $params['name'] : $params['id'];
|
||||
if($page) $parm = array('page' => $page);
|
||||
}
|
||||
|
@@ -79,14 +79,50 @@ class eFront
|
||||
/**
|
||||
* Dispatch
|
||||
*/
|
||||
public function dispatch(eRequest $request, eResponse $response, eDispatcher $dispatcher)
|
||||
public function dispatch(eRequest $request = null, eResponse $response = null, eDispatcher $dispatcher = null)
|
||||
{
|
||||
if(null === $request)
|
||||
{
|
||||
if(null === $this->getRequest())
|
||||
{
|
||||
$request = new eRequest();
|
||||
$this->setRequest($request);
|
||||
}
|
||||
else $request = $this->getRequest();
|
||||
}
|
||||
elseif(null === $this->getRequest()) $this->setRequest($request);
|
||||
|
||||
// set dispatched status false
|
||||
$request->setDispatched(false);
|
||||
if(null === $response)
|
||||
{
|
||||
if(null === $this->getResponse())
|
||||
{
|
||||
$response = new eResponse();
|
||||
$this->setResponse($response);
|
||||
}
|
||||
else $response = $this->getResponse();
|
||||
}
|
||||
elseif(null === $this->getRequest()) $this->setRequest($request);
|
||||
|
||||
|
||||
if(null === $dispatcher)
|
||||
{
|
||||
if(null === $this->getDispatcher())
|
||||
{
|
||||
$dispatcher = new eDispatcher();
|
||||
$this->setDispatcher($dispatcher);
|
||||
}
|
||||
else $dispatcher = $this->getDispatcher();
|
||||
}
|
||||
elseif(null === $this->getDispatcher()) $this->setDispatcher($dispatcher);
|
||||
|
||||
|
||||
// set dispatched status true, required for checkLegacy()
|
||||
$request->setDispatched(true);
|
||||
|
||||
$router = $this->getRouter();
|
||||
$router->route($request); // route current request
|
||||
|
||||
// If current request not already routed outside the dispatch method, route it
|
||||
if(!$request->routed) $router->route($request);
|
||||
|
||||
$c = 0;
|
||||
// dispatch loop
|
||||
@@ -98,33 +134,38 @@ class eFront
|
||||
throw new eException("Too much dispatch loops", 1);
|
||||
}
|
||||
|
||||
$request->setDispatched(true);
|
||||
if((bool) self::isLegacy()) return;
|
||||
// dispatched status true on first loop
|
||||
$router->checkLegacy($request);
|
||||
|
||||
// dispatched by default - don't allow legacy to alter dsiaptch status
|
||||
$request->setDispatched(true);
|
||||
|
||||
// legacy mod - return control to the bootstrap
|
||||
if(self::isLegacy())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// for the good players - dispatch loop - no more BC!
|
||||
try
|
||||
{
|
||||
$dispatcher->dispatch($request, $response);
|
||||
}
|
||||
catch(eException $e)
|
||||
{
|
||||
echo /*$request->getRoute().' - '.*/$e->getMessage();
|
||||
echo $request->getRoute().' - '.$e->getMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
// check forward to legacy module
|
||||
if(!$request->isDispatched())
|
||||
{
|
||||
$router->checkLegacy($request);
|
||||
}
|
||||
|
||||
|
||||
} while (!$request->isDispatched());
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch
|
||||
* Init all objects required for request dispatching
|
||||
* @return eFront
|
||||
*/
|
||||
public function run()
|
||||
public function init()
|
||||
{
|
||||
$request = new eRequest();
|
||||
$this->setRequest($request);
|
||||
@@ -138,7 +179,30 @@ class eFront
|
||||
$response = new eResponse();
|
||||
$this->setResponse($response);
|
||||
|
||||
$this->dispatch($request, $response, $dispatcher);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch
|
||||
* @param string|eRequest $route
|
||||
*/
|
||||
public function run($route = null)
|
||||
{
|
||||
if($route)
|
||||
{
|
||||
if(is_object($route) && ($route instanceof eRequest)) $this->setRequest($route);
|
||||
elseif(null !== $route && null !== $this->getRequest()) $this->getRequest()->setRoute($route);
|
||||
}
|
||||
try
|
||||
{
|
||||
$this->dispatch();
|
||||
}
|
||||
catch(eException $e)
|
||||
{
|
||||
echo $e->getMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -695,7 +759,7 @@ class eRouter
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $_urlFormat = self::FORMAT_GET;
|
||||
private $_urlFormat = self::FORMAT_PATH;
|
||||
|
||||
/**
|
||||
* Not found route
|
||||
@@ -825,7 +889,7 @@ class eRouter
|
||||
$_config['config']['location'] = $location;
|
||||
if(!isset($_config['config']['format']) || !in_array($_config['config']['format'], array(self::FORMAT_GET, self::FORMAT_PATH)))
|
||||
{
|
||||
$_config['config']['format'] = self::FORMAT_GET;
|
||||
$_config['config']['format'] = $this->getUrlFormat();
|
||||
}
|
||||
|
||||
if(!isset($_config['rules'])) $_config['rules'] = array();
|
||||
@@ -1409,14 +1473,17 @@ class eRouter
|
||||
else
|
||||
{
|
||||
$rawPathInfo = rawurldecode($request->getPathInfo());
|
||||
$this->_urlFormat = self::FORMAT_PATH;
|
||||
//$this->_urlFormat = self::FORMAT_PATH;
|
||||
}
|
||||
|
||||
// Switch to main url namespace
|
||||
if(!$rawPathInfo)
|
||||
// Route to front page - index/index/index route
|
||||
if(!$rawPathInfo && (!$this->getMainModule() || empty($_GET)))
|
||||
{
|
||||
// XXX show site index page possible only when rewrite.php is moved to index.php
|
||||
// most probably we'll route to system/index/index where front page settings will be detected and front page will be rendered
|
||||
// front page settings will be detected and front page will be rendered
|
||||
$request->setRoute('index/index/index');
|
||||
$request->addRouteHistory($rawPathInfo);
|
||||
$request->routed = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
// max number of parts is actually 4 - module/controller/action/[additional/pathinfo/vars], here for reference only
|
||||
@@ -1443,20 +1510,26 @@ class eRouter
|
||||
// we have valid module
|
||||
$config = $this->getConfig($module);
|
||||
|
||||
// set legacy state
|
||||
eFront::isLegacy(varset($config['legacy']));
|
||||
|
||||
// Don't allow single entry if required by module config
|
||||
if(vartrue($config['noSingleEntry']))
|
||||
{
|
||||
$request->routed = true;
|
||||
if(!eFront::isLegacy())
|
||||
{
|
||||
$request->setRoute($this->notFoundRoute);
|
||||
$request->addRouteHistory($rawPathInfo);
|
||||
return false;
|
||||
}
|
||||
// legacy entry point - include it later in the bootstrap, legacy query string will be set to current
|
||||
$request->addRouteHistory($rawPathInfo);
|
||||
return true;
|
||||
}
|
||||
|
||||
// URL format - the one set by current config overrides the auto-detection
|
||||
$format = isset($config['format']) && $config['format'] ? $config['format'] : $this->getUrlFormat();
|
||||
|
||||
// set legacy state
|
||||
eFront::isLegacy(varset($config['legacy']));
|
||||
|
||||
//remove leading module, unnecessary overhead while matching
|
||||
array_shift($parts);
|
||||
$rawPathInfo = $parts ? implode('/', $parts) : '';
|
||||
@@ -1528,7 +1601,7 @@ class eRouter
|
||||
// append module to be registered in the request object
|
||||
if(false !== $route)
|
||||
{
|
||||
// don't modify - request directly modified by config callback
|
||||
// don't modify if true - request directly modified by config callback
|
||||
if(!$request->routed)
|
||||
{
|
||||
if(eFront::isLegacy()) $this->configCallback($module, 'legacy', array($route, $request), $config['location']);
|
||||
@@ -1555,6 +1628,7 @@ class eRouter
|
||||
{
|
||||
$route = $this->notFoundRoute;
|
||||
eFront::isLegacy(''); // reset legacy - not found route isn't legacy call
|
||||
$request->routed = true;
|
||||
if($checkOnly) return false;
|
||||
## Global redirect on error option
|
||||
if(e107::getPref('url_error_redirect', false) && $this->notFoundUrl)
|
||||
@@ -1568,6 +1642,7 @@ class eRouter
|
||||
|
||||
$request->setRoute($route);
|
||||
$request->addRouteHistory($route);
|
||||
$request->routed = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1580,50 +1655,20 @@ class eRouter
|
||||
public function checkLegacy(eRequest $request)
|
||||
{
|
||||
$module = $request->getModule();
|
||||
$rules = $this->getRules($module);
|
||||
|
||||
// Simple match current request
|
||||
if($rules)
|
||||
// forward from controller to a legacy module - bad stuff
|
||||
if(!$request->isDispatched() && $this->getConfigValue($module, 'legacy'))
|
||||
{
|
||||
foreach ($rules as $value)
|
||||
{
|
||||
$route = $rules->route;
|
||||
if($route == $request->getController().'/'.$request->getAction())
|
||||
{
|
||||
$config = $rules->getData();
|
||||
}
|
||||
}
|
||||
}
|
||||
else $config = $module ? $router->getConfig() : array();
|
||||
eFront::isLegacy($this->getConfigValue($module, 'legacy'));
|
||||
|
||||
// Modify legacy query string. NOTE - parseCallback not called here - forwarding controller should set all request parameters proper!
|
||||
if(isset($config['legacyQuery']))
|
||||
{
|
||||
$obj = eDispatcher::getConfigObject($module, $config['location']);
|
||||
// eUrlConfig::legacyQueryString set as legacy string by default in eUrlConfig::legacy() method
|
||||
$vars = new e_vars($request->getRequestParams());
|
||||
$vars->module = $module;
|
||||
$vars->controller = $request->getController();
|
||||
$vars->action = $request->getAction();
|
||||
if(vartrue($config['allowVars']))
|
||||
{
|
||||
foreach ($config['allowVars'] as $key => $value)
|
||||
{
|
||||
if(isset($_GET[$key]) && !$request->isRequestParam($key))
|
||||
{
|
||||
// sanitize
|
||||
$vars->$key = preg_replace('/[^\d\w]/', '', $_GET[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$obj->legacyQueryString = e107::getParser()->simpleParse($config['legacyQuery'], $vars, '0');
|
||||
unset($vars, $obj);
|
||||
}
|
||||
$url = $this->assemble($request->getRoute(), $request->getRequestParams());
|
||||
$request->setRequestInfo($url)->setPathInfo(null)->setRoute(null);
|
||||
|
||||
if(vartrue($config['legacy']))
|
||||
{
|
||||
eFront::isLegacy($config['legacy']);
|
||||
$this->configCallback($module, 'legacy', array($request->getController().'/'.$request->getAction(), $request, 'dispatch'), $config['location']);
|
||||
$_GET = $request->getRequestParams();
|
||||
$_SERVER['QUERY_STRING'] = http_build_query($request->getRequestParams(), null, '&');
|
||||
|
||||
// Infinite loop impossible, as dispatcher will break because of the registered legacy path
|
||||
$this->route($request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1714,7 +1759,7 @@ class eRouter
|
||||
return $base.implode('/', $route);
|
||||
}
|
||||
|
||||
# fill in index when needed
|
||||
# fill in index when needed - XXX not needed, may be removed soon
|
||||
switch (count($route))
|
||||
{
|
||||
case 1:
|
||||
@@ -1773,13 +1818,15 @@ class eRouter
|
||||
$params[$this->routeVar] = implode('/', $route);
|
||||
$route = array();
|
||||
}
|
||||
$route = implode('/', $route);
|
||||
if(!$route || $route == $alias) $urlSuffix = '';
|
||||
if($params)
|
||||
{
|
||||
$params = $this->createPathInfo($params, $options);
|
||||
return $base.implode('/', $route).$urlSuffix.'?'.$params.$anc;
|
||||
return $base.$route.$urlSuffix.'?'.$params.$anc;
|
||||
}
|
||||
if(!$route) $urlSuffix = '';
|
||||
return $base.implode('/', $route).$urlSuffix.$anc;
|
||||
|
||||
return $base.$route.$urlSuffix.$anc;
|
||||
}
|
||||
|
||||
|
||||
@@ -1846,11 +1893,13 @@ class eRouter
|
||||
$route = array();
|
||||
}
|
||||
$params = $this->createPathInfo($params, $options);
|
||||
if(!$route) $urlSuffix = '';
|
||||
return $base.implode('/', $route).$urlSuffix.'?'.$params.$anc;
|
||||
$route = implode('/', $route);
|
||||
if(!$route || $route == $alias) $urlSuffix = '';
|
||||
return $base.$route.$urlSuffix.'?'.$params.$anc;
|
||||
}
|
||||
if(!$route) $urlSuffix = '';
|
||||
return $format === self::FORMAT_GET ? $base.'?'.$this->routeVar.'='.implode('/', $route).$anc : $base.implode('/', $route).$urlSuffix.$anc;
|
||||
$route = implode('/', $route);
|
||||
if(!$route || $route == $alias) $urlSuffix = '';
|
||||
return $format === self::FORMAT_GET ? $base.'?'.$this->routeVar.'='.implode('/', $route).$anc : $base.$route.$urlSuffix.$anc;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1863,10 +1912,10 @@ class eRouter
|
||||
|
||||
/**
|
||||
* Creates a path info based on the given parameters.
|
||||
* XXX - maybe we can switch to http_build_query(), should be able to do everything we need in a much better way
|
||||
*
|
||||
* @param array $params list of GET parameters
|
||||
* @param string $equal the separator between name and value
|
||||
* @param string $ampersand the separator between name-value pairs
|
||||
* @param boolean $encode apply rawurlencode to the key/value pairs
|
||||
* @param array $options rawurlencode, equal, encode and amp settings
|
||||
* @param string $key this is used internally for recursive calls
|
||||
*
|
||||
* @return string the created path info
|
||||
@@ -1884,6 +1933,15 @@ class eRouter
|
||||
if (is_array($v)) $pairs[] = $this->createPathInfo($v, $options, $k);
|
||||
else
|
||||
{
|
||||
if(null === $v)
|
||||
{
|
||||
if($encode)
|
||||
{
|
||||
$k = rawurlencode($k);
|
||||
}
|
||||
$pairs[] = $k;
|
||||
continue;
|
||||
}
|
||||
if($encode)
|
||||
{
|
||||
$k = rawurlencode($k);
|
||||
@@ -1898,7 +1956,7 @@ class eRouter
|
||||
/**
|
||||
* Parses a path info into URL segments
|
||||
* Be sure to not use non-unique chars for equal and ampersand signs, or you'll break your URLs
|
||||
* XXX - maybe we can switch to http_build_query(), should be able to do everything we need in a much better way
|
||||
*
|
||||
* @param eRequest $request
|
||||
* @param string $pathInfo path info
|
||||
* @param string $equal
|
||||
@@ -2501,10 +2559,6 @@ class eController
|
||||
|
||||
if($request->isDispatched())
|
||||
{
|
||||
// more legacy :/
|
||||
$request->setLegacyQstring();
|
||||
$request->setLegacyPage();
|
||||
|
||||
if(method_exists($this, $actionMethodName))
|
||||
{
|
||||
$this->$actionMethodName();
|
||||
@@ -2542,13 +2596,18 @@ class eController
|
||||
{
|
||||
$url = eFront::instance()->getRouter()->assemble($url, '', 'encode=0');
|
||||
}
|
||||
if(strpos($url, 'http://') !== 0 && strpos($url, 'http://') !== 0)
|
||||
if(strpos($url, 'http://') !== 0 && strpos($url, 'https://') !== 0)
|
||||
{
|
||||
$url = $url[0] == '/' ? SITEURLBASE.$url : SITEURL.$url;
|
||||
}
|
||||
$redirect->redirect($url, true, $code);
|
||||
}
|
||||
|
||||
/**
|
||||
* System forward
|
||||
* @param string $route
|
||||
* @param array $params
|
||||
*/
|
||||
protected function _forward($route, $params = array())
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
@@ -2563,14 +2622,14 @@ class eController
|
||||
|
||||
switch (count($route)) {
|
||||
case 3:
|
||||
if($route[2] !== '*') $request->setModule($route[2]);
|
||||
if($route[2] !== '*') $request->setModule($route[0]);
|
||||
if($route[1] !== '*') $request->setController($route[1]);
|
||||
$request->setAction($route[0]);
|
||||
$request->setAction($route[2]);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if($route[1] !== '*') $request->setController($route[1]);
|
||||
$request->setAction($route[0]);
|
||||
if($route[1] !== '*') $request->setController($route[0]);
|
||||
$request->setAction($route[1]);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
@@ -2584,7 +2643,7 @@ class eController
|
||||
|
||||
$request->addRouteHistory($oldRoute);
|
||||
|
||||
if($params) $request->setRequestParams($params);
|
||||
if(false !== $params) $request->setRequestParams($params);
|
||||
$request->setDispatched(false);
|
||||
}
|
||||
|
||||
@@ -2648,6 +2707,12 @@ class eRequest
|
||||
*/
|
||||
protected $_pathInfo;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_requestInfo;
|
||||
|
||||
/**
|
||||
* Pathinfo string used for initial system routing
|
||||
*/
|
||||
@@ -2667,7 +2732,7 @@ class eRequest
|
||||
* Name of the bootstrap file
|
||||
* @var string
|
||||
*/
|
||||
public $singleEntry = 'rewrite.php';
|
||||
public $singleEntry = 'index.php';
|
||||
|
||||
/**
|
||||
* Request constructor
|
||||
@@ -2716,12 +2781,13 @@ class eRequest
|
||||
{
|
||||
if(null == $this->_pathInfo)
|
||||
{
|
||||
|
||||
if($this->getBasePath() == e_REQUEST_HTTP)
|
||||
if($this->getBasePath() == $this->getRequestInfo())
|
||||
$this->_pathInfo = ''; // map to indexRoute
|
||||
|
||||
else
|
||||
$this->_pathInfo = substr(e_REQUEST_HTTP, strlen($this->getBasePath()));
|
||||
$this->_pathInfo = substr($this->getRequestInfo(), strlen($this->getBasePath()));
|
||||
|
||||
if($this->_pathInfo && trim($this->_pathInfo, '/') == trim($this->singleEntry, '/')) $this->_pathInfo = '';
|
||||
}
|
||||
|
||||
return $this->_pathInfo;
|
||||
@@ -2738,6 +2804,41 @@ class eRequest
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string request info
|
||||
*/
|
||||
public function getRequestInfo()
|
||||
{
|
||||
if(null === $this->_requestInfo)
|
||||
{
|
||||
$this->_requestInfo = e_REQUEST_HTTP;
|
||||
}
|
||||
return $this->_requestInfo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Override request info
|
||||
* @param string $pathInfo
|
||||
* @return eRequest
|
||||
*/
|
||||
public function setRequestInfo($requestInfo)
|
||||
{
|
||||
$this->_requestInfo = $requestInfo;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick front page check
|
||||
*/
|
||||
public static function isFrontPage($entryScript = 'index.php', $currentPathInfo = e_REQUEST_HTTP)
|
||||
{
|
||||
$basePath = e_HTTP;
|
||||
if(!e107::getPref('url_disable_pathinfo')) $basePath .= $entryScript.'/';
|
||||
|
||||
return ($basePath == $currentPathInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current controller string
|
||||
* @return string
|
||||
@@ -2873,16 +2974,24 @@ class eRequest
|
||||
*/
|
||||
public function setRoute($route)
|
||||
{
|
||||
if(null === $route)
|
||||
{
|
||||
$this->_module = null;
|
||||
$this->_controller = null;
|
||||
$this->_action = null;
|
||||
}
|
||||
return $this->initFromRoute($route);
|
||||
}
|
||||
|
||||
/**
|
||||
* System routing track, used in controllers forwarder
|
||||
* @param string $route
|
||||
* @return eRequest
|
||||
*/
|
||||
public function addRouteHistory($route)
|
||||
{
|
||||
$this->_routeHistory[] = $route;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2943,7 +3052,7 @@ class eRequest
|
||||
->setController(vartrue($parts[1], 'index'))
|
||||
->setAction(vartrue($parts[2], 'index'));
|
||||
|
||||
return $this->getRoute(true);
|
||||
return $this;//->getRoute(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3015,10 +3124,12 @@ class eRequest
|
||||
|
||||
/**
|
||||
* More BC
|
||||
* @param string $qstring
|
||||
* @return eRequest
|
||||
*/
|
||||
public function setLegacyQstring($qstring = null)
|
||||
{
|
||||
if(defined('e_QUERY')) return;
|
||||
if(defined('e_QUERY')) return $this;;
|
||||
|
||||
if(null === $qstring)
|
||||
{
|
||||
@@ -3028,27 +3139,32 @@ class eRequest
|
||||
define("e_SELF", e_REQUEST_SELF);
|
||||
define("e_QUERY", $qstring);
|
||||
$_SERVER['QUERY_STRING'] = e_QUERY;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* And More BC :/
|
||||
* @param string $page
|
||||
* @return eRequest
|
||||
*/
|
||||
public function setLegacyPage($page = null)
|
||||
{
|
||||
if(defined('e_PAGE')) return;
|
||||
if(defined('e_PAGE')) return $this;
|
||||
if(null === $page)
|
||||
{
|
||||
$page = eFront::isLegacy();
|
||||
}
|
||||
if(!$page)
|
||||
{
|
||||
define('e_PAGE', 'rewrite.php');
|
||||
define('e_PAGE', $this->singleEntry);
|
||||
}
|
||||
else define('e_PAGE', basename(str_replace(array('{', '}'), '/', $page)));
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* And More from the same - BC :/
|
||||
* @return string
|
||||
*/
|
||||
public static function getQueryString()
|
||||
{
|
||||
|
@@ -2395,6 +2395,7 @@ class e107
|
||||
|
||||
|
||||
// START New - request uri/url detection, XSS protection
|
||||
// TODO - move it to a separate method
|
||||
$requestUri = $requestUrl = '';
|
||||
if (isset($_SERVER['HTTP_X_REWRITE_URL']))
|
||||
{
|
||||
@@ -2413,10 +2414,10 @@ class e107
|
||||
{
|
||||
// go back to e_SELF
|
||||
$requestUri = $eSelf;
|
||||
$requestUrl = e_SELF;
|
||||
$requestUrl = $_self;
|
||||
if (e_QUERY)
|
||||
{
|
||||
$requestUri .= '?'.e_QUERY;
|
||||
$requestUri .= '?'.e_QUERY; // TODO e_SINGLE_ENTRY check, separate static method for cleaning QUERY_STRING
|
||||
$requestUrl .= '?'.e_QUERY;
|
||||
}
|
||||
}
|
||||
|
@@ -56,7 +56,7 @@ define("LAN_EURL_MENU_HELP", "Help");
|
||||
define("LAN_EURL_UC", "Under Construction");
|
||||
|
||||
|
||||
// define("LAN_EURL_CORE_MAIN", "Main");
|
||||
define("LAN_EURL_CORE_MAIN", "Site Root Namespace - alias not in use.");
|
||||
|
||||
// News
|
||||
define("LAN_EURL_CORE_NEWS", "News");
|
||||
@@ -90,4 +90,7 @@ define("LAN_EURL_SYSTEM_DEFAULT_DESCR", "URLs for pages like Not Found, Acess de
|
||||
define("LAN_EURL_SYSTEM_REWRITE_LABEL", "User Friendly URL (mod_rewrite)");
|
||||
define("LAN_EURL_SYSTEM_REWRITE_DESCR", "URLs for pages like Not Found, Acess denied, etc.<br />Example: http://yoursite.com/system/error404");
|
||||
|
||||
// System
|
||||
define("LAN_EURL_CORE_INDEX", "Front Page");
|
||||
define("LAN_EURL_CORE_INDEX_INFO", "Front Page can't have an alias.");
|
||||
//define("LAN_EURL_", "");
|
126
index.php
126
index.php
@@ -14,99 +14,51 @@
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
require_once ('class2.php');
|
||||
// BOOTSTRAP START
|
||||
|
||||
|
||||
if($_GET['elan'])
|
||||
{
|
||||
header('location: '.SITEURL);
|
||||
define('e_SINGLE_ENTRY', TRUE);
|
||||
|
||||
$_E107['single_entry'] = true; // TODO - notify class2.php
|
||||
|
||||
define('ROOT', dirname(__FILE__));
|
||||
set_include_path(ROOT.PATH_SEPARATOR.get_include_path());
|
||||
|
||||
require_once("class2.php");
|
||||
|
||||
$front = eFront::instance();
|
||||
$front->init()
|
||||
->run();
|
||||
|
||||
$inc = $front->isLegacy();
|
||||
if($inc)
|
||||
{
|
||||
// last chance to set legacy env
|
||||
$request = $front->getRequest();
|
||||
$request->setLegacyQstring();
|
||||
$request->setLegacyPage();
|
||||
if(!is_file($inc) || !is_readable($inc))
|
||||
{
|
||||
echo 'Bad request - destination unreachable - '.$inc;
|
||||
}
|
||||
include($inc);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists('index_include.php'))
|
||||
{
|
||||
include ('index_include.php');
|
||||
}
|
||||
|
||||
$query = (e_QUERY && e_QUERY != '' && !$_GET['elan']) ? '?'.e_QUERY : '';
|
||||
$location = '';
|
||||
|
||||
if ($pref['membersonly_enabled'] && !USER)
|
||||
{
|
||||
header('location: '.e_LOGIN);
|
||||
$response = $front->getResponse();
|
||||
if(e_AJAX_REQUEST)
|
||||
{
|
||||
$response->setParam('meta', false)
|
||||
->setParam('render', false)
|
||||
->send('default', false, true);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$response->sendMeta();
|
||||
|
||||
$class_list = explode(',', USERCLASS_LIST);
|
||||
|
||||
if (isset($pref['frontpage']['all']) && $pref['frontpage']['all'])
|
||||
{ // 0.7 method
|
||||
$location = ((strpos($pref['frontpage']['all'], 'http') === FALSE) ? e_BASE : '').$pref['frontpage']['all'].$query;
|
||||
}
|
||||
else
|
||||
{ // This is the 'new' method - assumes $pref['frontpage'] is an ordered list of rules
|
||||
if(vartrue($pref['frontpage']))
|
||||
{
|
||||
foreach ($pref['frontpage'] as $fk=>$fp)
|
||||
{
|
||||
if (in_array($fk, $class_list))
|
||||
{
|
||||
// Debateable whether we should append $query - we may be redirecting to a custom page, for example
|
||||
if (strpos($fp, '{') !== FALSE)
|
||||
{
|
||||
$location = $tp->replaceConstants($fp).$query;
|
||||
}
|
||||
else
|
||||
{
|
||||
$location = ((strpos($fp, 'http') === FALSE) ? e_BASE : '').$fp.$query;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$location)
|
||||
{ // Try and use the 'old' method (this bit can go later)
|
||||
if (ADMIN)
|
||||
{
|
||||
$location = ((strpos($pref['frontpage'][e_UC_ADMIN], 'http') === FALSE) ? e_BASE : '').$pref['frontpage'][e_UC_ADMIN].$query;
|
||||
}
|
||||
elseif (USER)
|
||||
{ // This is the key bit - what to do for a 'normal' logged in user
|
||||
// We have USERCLASS_LIST - comma separated. Also e_CLASS_REGEXP
|
||||
foreach ($class_list as $fp_class)
|
||||
{
|
||||
$inclass = false;
|
||||
if (!$inclass && check_class($fp_class['userclass_id']))
|
||||
{
|
||||
$location = ((strpos($pref['frontpage'][$fp_class['userclass_id']], 'http') === FALSE) ? e_BASE : '').$pref['frontpage'][$fp_class['userclass_id']].$query;
|
||||
$inclass = true;
|
||||
}
|
||||
}
|
||||
$location = $location ? $location : ((strpos($pref['frontpage'][e_UC_MEMBER], 'http') === FALSE) ? e_BASE : '').$pref['frontpage'][e_UC_MEMBER].$query;
|
||||
}
|
||||
else
|
||||
{
|
||||
$location = ((strpos($pref['frontpage'][e_UC_GUEST], 'http') === FALSE) ? e_BASE : '').$pref['frontpage'][e_UC_GUEST].$query;
|
||||
}
|
||||
}
|
||||
|
||||
if (!trim($location))
|
||||
$location = 'news.php';
|
||||
|
||||
list($page, $str) = explode("?", $location."?"); // required to prevent infinite looping when queries are used on index.php.
|
||||
if ($page == "index.php") // Welcome Message is the front-page.
|
||||
{
|
||||
require_once (HEADERF);
|
||||
require_once (FOOTERF);
|
||||
include_once(HEADERF);
|
||||
eFront::instance()->getResponse()->send('default', false, true);
|
||||
include_once(FOOTERF);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{ // redirect to different frontpage.
|
||||
header("Location: {$location}");
|
||||
}
|
||||
exit();
|
||||
|
||||
// BOOTSTRAP END
|
||||
|
||||
?>
|
Reference in New Issue
Block a user