2005-06-21 23:44:49 +00:00
|
|
|
<?php
|
2005-08-21 06:49:02 +00:00
|
|
|
/* SVN FILE: $Id$ */
|
2005-06-21 23:44:49 +00:00
|
|
|
|
|
|
|
/**
|
2005-12-24 07:56:48 +00:00
|
|
|
* Dispatcher takes the URL information, parses it for paramters and
|
2005-09-17 02:22:07 +00:00
|
|
|
* tells the involved controllers what to do.
|
2005-12-24 07:56:48 +00:00
|
|
|
*
|
|
|
|
* This is the heart of Cake's operation.
|
2005-08-21 06:49:02 +00:00
|
|
|
*
|
|
|
|
* PHP versions 4 and 5
|
|
|
|
*
|
|
|
|
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
2006-01-20 07:46:14 +00:00
|
|
|
* Copyright (c) 2006, Cake Software Foundation, Inc.
|
2005-12-23 21:57:26 +00:00
|
|
|
* 1785 E. Sahara Avenue, Suite 490-204
|
|
|
|
* Las Vegas, Nevada 89104
|
2005-08-21 06:49:02 +00:00
|
|
|
*
|
2005-12-23 21:57:26 +00:00
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
2005-08-21 06:49:02 +00:00
|
|
|
*
|
2005-12-24 07:56:48 +00:00
|
|
|
* @filesource
|
2006-01-20 07:46:14 +00:00
|
|
|
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
|
2005-12-23 21:57:26 +00:00
|
|
|
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
2005-08-21 06:49:02 +00:00
|
|
|
* @package cake
|
2005-10-09 01:56:21 +00:00
|
|
|
* @subpackage cake.cake
|
2005-08-21 06:49:02 +00:00
|
|
|
* @since CakePHP v 0.2.9
|
|
|
|
* @version $Revision$
|
|
|
|
* @modifiedby $LastChangedBy$
|
2005-06-21 23:44:49 +00:00
|
|
|
* @lastmodified $Date$
|
2005-08-21 06:49:02 +00:00
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
2005-06-21 23:44:49 +00:00
|
|
|
*/
|
|
|
|
|
2005-07-04 04:16:20 +00:00
|
|
|
/**
|
2005-10-18 22:27:39 +00:00
|
|
|
* List of helpers to include
|
2005-07-04 04:16:20 +00:00
|
|
|
*/
|
2006-01-12 02:10:47 +00:00
|
|
|
uses('router', DS.'controller'.DS.'controller');
|
2005-06-21 23:44:49 +00:00
|
|
|
|
|
|
|
/**
|
2005-10-18 22:27:39 +00:00
|
|
|
* Dispatcher translates URLs to controller-action-paramter triads.
|
2005-12-22 01:07:28 +00:00
|
|
|
*
|
2005-06-21 23:44:49 +00:00
|
|
|
* Dispatches the request, creating appropriate models and controllers.
|
|
|
|
*
|
2005-08-21 06:49:02 +00:00
|
|
|
* @package cake
|
2005-10-09 01:56:21 +00:00
|
|
|
* @subpackage cake.cake
|
2005-08-21 06:49:02 +00:00
|
|
|
* @since CakePHP v 0.2.9
|
2005-06-21 23:44:49 +00:00
|
|
|
*/
|
|
|
|
class Dispatcher extends Object
|
|
|
|
{
|
2005-07-10 05:08:19 +00:00
|
|
|
/**
|
|
|
|
* Base URL
|
|
|
|
* @var string
|
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
var $base = false;
|
2005-12-22 01:07:28 +00:00
|
|
|
|
2005-10-28 08:25:31 +00:00
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
var $admin = false;
|
2005-07-10 05:08:19 +00:00
|
|
|
|
2005-12-22 01:07:28 +00:00
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
var $webservices = null;
|
2005-12-22 01:07:28 +00:00
|
|
|
|
2006-02-01 13:26:23 +00:00
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
var $plugin = null;
|
2006-02-01 13:26:23 +00:00
|
|
|
|
2005-07-10 05:08:19 +00:00
|
|
|
/**
|
2005-09-17 02:22:07 +00:00
|
|
|
* Constructor.
|
2005-07-10 05:08:19 +00:00
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
function __construct()
|
|
|
|
{
|
2005-07-10 05:08:19 +00:00
|
|
|
parent::__construct();
|
2006-02-18 23:42:21 +00:00
|
|
|
}
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
|
|
/**
|
2005-09-17 02:22:07 +00:00
|
|
|
* Dispatches and invokes given URL, handing over control to the involved controllers, and then renders the results (if autoRender is set).
|
|
|
|
*
|
2005-12-22 01:07:28 +00:00
|
|
|
* If no controller of given name can be found, invoke() shows error messages in
|
|
|
|
* the form of Missing Controllers information. It does the same with Actions (methods of Controllers are called
|
2005-09-17 02:22:07 +00:00
|
|
|
* Actions).
|
2005-07-10 05:08:19 +00:00
|
|
|
*
|
2005-12-27 03:33:44 +00:00
|
|
|
* @param string $url URL information to work on.
|
|
|
|
* @return boolean Success
|
2005-07-10 05:08:19 +00:00
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
function dispatch($url, $additionalParams=array())
|
|
|
|
{
|
2005-09-19 20:07:16 +00:00
|
|
|
$params = array_merge($this->parseParams($url), $additionalParams);
|
2005-07-10 05:08:19 +00:00
|
|
|
$missingController = false;
|
|
|
|
$missingAction = false;
|
2006-02-18 23:42:21 +00:00
|
|
|
$missingView = false;
|
2005-10-18 22:27:39 +00:00
|
|
|
$privateAction = false;
|
2006-02-03 02:37:59 +00:00
|
|
|
$this->base = $this->baseUrl();
|
2005-07-10 05:08:19 +00:00
|
|
|
if (empty($params['controller']))
|
|
|
|
{
|
|
|
|
$missingController = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$ctrlName = Inflector::camelize($params['controller']);
|
|
|
|
$ctrlClass = $ctrlName.'Controller';
|
|
|
|
|
2005-12-27 17:14:32 +00:00
|
|
|
if(!class_exists($ctrlClass))
|
2005-07-10 05:08:19 +00:00
|
|
|
{
|
2005-12-27 17:14:32 +00:00
|
|
|
if (!loadController($ctrlName))
|
2005-10-09 01:56:21 +00:00
|
|
|
{
|
2006-02-01 13:26:23 +00:00
|
|
|
$plugin = $ctrlName;
|
|
|
|
$pluginName = Inflector::camelize($params['action']);
|
|
|
|
$pluginClass = $pluginName.'Controller';
|
|
|
|
|
|
|
|
if (!loadPluginController(Inflector::underscore($ctrlName), $pluginName))
|
2005-12-27 17:14:32 +00:00
|
|
|
{
|
2006-02-01 13:26:23 +00:00
|
|
|
if(preg_match('/([\\.]+)/', $ctrlName))
|
|
|
|
{
|
|
|
|
return $this->cakeError('error404',array(array('url' => strtolower($ctrlName),
|
|
|
|
'message' => 'Was not found on this server')));
|
2006-02-02 23:01:23 +00:00
|
|
|
exit();
|
2006-02-01 13:26:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$missingController = true;
|
|
|
|
}
|
2005-12-27 17:14:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-02-01 13:26:23 +00:00
|
|
|
$ctrlClass = $pluginClass;
|
2006-02-18 23:42:21 +00:00
|
|
|
$oldAction = $params['action'];
|
2006-02-01 13:26:23 +00:00
|
|
|
$params = $this->_restructureParams($params);
|
2006-02-03 03:46:27 +00:00
|
|
|
$plugin = Inflector::underscore($ctrlName);
|
|
|
|
$this->plugin = $plugin.DS;
|
|
|
|
loadPluginModels($plugin);
|
2006-02-03 02:37:59 +00:00
|
|
|
$this->base = $this->base.'/'.Inflector::underscore($ctrlName);
|
2006-02-18 23:42:21 +00:00
|
|
|
if(empty($params['controller']) || !class_exists($pluginClass))
|
|
|
|
{
|
|
|
|
$params['controller'] = Inflector::underscore($ctrlName);
|
|
|
|
$ctrlClass = $ctrlName.'Controller';
|
|
|
|
$params['action'] = $oldAction;
|
|
|
|
}
|
2005-12-27 17:14:32 +00:00
|
|
|
}
|
2005-10-09 01:56:21 +00:00
|
|
|
}
|
2005-07-10 05:08:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-01 13:26:23 +00:00
|
|
|
if(defined('CAKE_ADMIN'))
|
|
|
|
{
|
|
|
|
if(isset($params[CAKE_ADMIN]))
|
|
|
|
{
|
|
|
|
$this->admin = '/'.CAKE_ADMIN ;
|
|
|
|
$url = preg_replace('/'.CAKE_ADMIN.'\//', '', $url);
|
|
|
|
if (empty($params['action']))
|
|
|
|
{
|
|
|
|
$params['action'] = CAKE_ADMIN.'_'.'index';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$params['action'] = CAKE_ADMIN.'_'.$params['action'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-03 02:37:59 +00:00
|
|
|
|
2006-02-01 13:26:23 +00:00
|
|
|
|
2005-07-10 05:08:19 +00:00
|
|
|
if ($missingController)
|
|
|
|
{
|
2006-01-12 02:10:47 +00:00
|
|
|
return $this->cakeError('missingController',array(array('className' => Inflector::camelize($params['controller']."Controller"),
|
2006-02-18 23:42:21 +00:00
|
|
|
'webroot' => $this->webroot)));
|
2005-07-10 05:08:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-10-03 04:48:00 +00:00
|
|
|
$controller =& new $ctrlClass($this);
|
2005-07-10 05:08:19 +00:00
|
|
|
}
|
2005-12-22 01:07:28 +00:00
|
|
|
|
2005-09-18 18:58:45 +00:00
|
|
|
$classMethods = get_class_methods($controller);
|
|
|
|
$classVars = get_object_vars($controller);
|
2005-12-22 01:07:28 +00:00
|
|
|
|
2005-09-19 20:07:16 +00:00
|
|
|
if (empty($params['action']))
|
2005-07-10 05:08:19 +00:00
|
|
|
{
|
2005-09-18 18:58:45 +00:00
|
|
|
$params['action'] = 'index';
|
2005-07-10 05:08:19 +00:00
|
|
|
}
|
2005-12-22 01:07:28 +00:00
|
|
|
|
2005-12-24 07:56:48 +00:00
|
|
|
if((in_array($params['action'], $classMethods) || in_array(strtolower($params['action']), $classMethods)) && strpos($params['action'], '_', 0) === 0)
|
2005-10-18 22:27:39 +00:00
|
|
|
{
|
|
|
|
$privateAction = true;
|
|
|
|
}
|
2005-12-22 01:07:28 +00:00
|
|
|
|
2005-12-24 07:56:48 +00:00
|
|
|
if(!in_array($params['action'], $classMethods) && !in_array(strtolower($params['action']), $classMethods))
|
2005-07-10 05:08:19 +00:00
|
|
|
{
|
2005-09-18 18:58:45 +00:00
|
|
|
$missingAction = true;
|
2005-07-10 05:08:19 +00:00
|
|
|
}
|
2005-12-22 01:07:28 +00:00
|
|
|
|
2005-12-29 06:45:33 +00:00
|
|
|
if(in_array('return', array_keys($params)) && $params['return'] == 1)
|
2005-12-29 05:07:12 +00:00
|
|
|
{
|
2005-12-29 06:45:33 +00:00
|
|
|
$controller->autoRender = false;
|
2005-12-29 05:07:12 +00:00
|
|
|
}
|
|
|
|
|
2005-07-10 05:08:19 +00:00
|
|
|
$controller->base = $this->base;
|
|
|
|
$controller->here = $this->base.'/'.$url;
|
2005-10-03 04:48:00 +00:00
|
|
|
$controller->webroot = $this->webroot;
|
2005-07-10 05:08:19 +00:00
|
|
|
$controller->params = $params;
|
|
|
|
$controller->action = $params['action'];
|
|
|
|
$controller->data = empty($params['data'])? null: $params['data'];
|
|
|
|
$controller->passed_args = empty($params['pass'])? null: $params['pass'];
|
2006-02-01 13:26:23 +00:00
|
|
|
$controller->autoLayout = empty($params['bare'])?$controller->autoLayout:!$params['bare'];
|
2005-12-22 01:07:28 +00:00
|
|
|
$controller->webservices = $params['webservices'];
|
2006-02-01 13:26:23 +00:00
|
|
|
$controller->plugin = $this->plugin;
|
2005-09-18 18:58:45 +00:00
|
|
|
|
2005-12-22 01:07:28 +00:00
|
|
|
if(!is_null($controller->webservices))
|
[1285]
Author: phpnut
Date: 10:09:03 PM, Monday, October 31, 2005
Message:
Removed references in the Session class
[1283]
Author: phpnut
Date: 8:47:37 PM, Monday, October 31, 2005
Message:
Added fix to the Controller::constructClassess().
The database should have an instance available if a component will use it.
[1282]
Author: phpnut
Date: 8:36:07 PM, Monday, October 31, 2005
Message:
Updated the Model association methods to correct and error I introduced when reactoring last week.
Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented.
Updated scaffold and dipatcher with changes to the session class.
Fixed problem with session not working properly.
Added a regenrate id for sessions.
When CAKE_SECURITY is set to high this will regenrate a new session key on each request.
The old session file will be removed from the file system. This is a added security measure.
[1270]
Author: phpnut
Date: 1:55:28 PM, Sunday, October 30, 2005
Message:
Updated Session class to regenrate a new session key on each request when security level set to high.
Updated doc comments in some classes
[1269]
Author: phpnut
Date: 9:49:43 AM, Sunday, October 30, 2005
Message:
Added a fix for Ticket #105
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-01 04:20:28 +00:00
|
|
|
{
|
2005-12-22 01:07:28 +00:00
|
|
|
array_push($controller->components, $controller->webservices);
|
|
|
|
array_push($controller->helpers, $controller->webservices);
|
[1285]
Author: phpnut
Date: 10:09:03 PM, Monday, October 31, 2005
Message:
Removed references in the Session class
[1283]
Author: phpnut
Date: 8:47:37 PM, Monday, October 31, 2005
Message:
Added fix to the Controller::constructClassess().
The database should have an instance available if a component will use it.
[1282]
Author: phpnut
Date: 8:36:07 PM, Monday, October 31, 2005
Message:
Updated the Model association methods to correct and error I introduced when reactoring last week.
Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented.
Updated scaffold and dipatcher with changes to the session class.
Fixed problem with session not working properly.
Added a regenrate id for sessions.
When CAKE_SECURITY is set to high this will regenrate a new session key on each request.
The old session file will be removed from the file system. This is a added security measure.
[1270]
Author: phpnut
Date: 1:55:28 PM, Sunday, October 30, 2005
Message:
Updated Session class to regenrate a new session key on each request when security level set to high.
Updated doc comments in some classes
[1269]
Author: phpnut
Date: 9:49:43 AM, Sunday, October 30, 2005
Message:
Added a fix for Ticket #105
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-01 04:20:28 +00:00
|
|
|
}
|
|
|
|
|
2005-09-19 20:07:16 +00:00
|
|
|
if((in_array('scaffold', array_keys($classVars))) && ($missingAction === true))
|
2005-09-17 07:56:32 +00:00
|
|
|
{
|
2005-12-27 03:33:44 +00:00
|
|
|
uses(DS.'controller'.DS.'scaffold');
|
2006-01-12 02:10:47 +00:00
|
|
|
return new Scaffold($controller, $params);
|
2005-09-17 07:56:32 +00:00
|
|
|
}
|
2005-09-18 18:58:45 +00:00
|
|
|
|
2005-09-18 13:25:20 +00:00
|
|
|
$controller->constructClasses();
|
2005-12-22 01:07:28 +00:00
|
|
|
|
2005-09-17 07:56:32 +00:00
|
|
|
if ($missingAction)
|
|
|
|
{
|
2006-01-12 02:10:47 +00:00
|
|
|
return $this->cakeError('missingAction',
|
|
|
|
array(array('className' => Inflector::camelize($params['controller']."Controller"),
|
|
|
|
'action' => $params['action'],
|
|
|
|
'webroot' => $this->webroot)));
|
2005-09-17 07:56:32 +00:00
|
|
|
}
|
2005-12-22 01:07:28 +00:00
|
|
|
|
2005-10-18 22:27:39 +00:00
|
|
|
if ($privateAction)
|
|
|
|
{
|
2006-01-12 02:10:47 +00:00
|
|
|
return $this->cakeError('privateAction',
|
|
|
|
array(array('className' => Inflector::camelize($params['controller']."Controller"),
|
|
|
|
'action' => $params['action'],
|
|
|
|
'webroot' => $this->webroot)));
|
2005-10-18 22:27:39 +00:00
|
|
|
}
|
2005-12-22 01:07:28 +00:00
|
|
|
|
2006-02-02 11:48:29 +00:00
|
|
|
return $this->_invoke($controller, $params);
|
2006-02-18 23:42:21 +00:00
|
|
|
}
|
2005-12-22 01:07:28 +00:00
|
|
|
|
2005-09-19 20:07:16 +00:00
|
|
|
/**
|
2005-10-18 22:27:39 +00:00
|
|
|
* Invokes given controller's render action if autoRender option is set. Otherwise the contents of the operation are returned as a string.
|
2005-09-19 20:07:16 +00:00
|
|
|
*
|
2005-10-18 22:27:39 +00:00
|
|
|
* @param object $controller
|
|
|
|
* @param array $params
|
|
|
|
* @return string
|
2005-09-19 20:07:16 +00:00
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
function _invoke (&$controller, $params)
|
|
|
|
{
|
|
|
|
if (!empty($controller->beforeFilter))
|
|
|
|
{
|
|
|
|
if(is_array($controller->beforeFilter))
|
|
|
|
{
|
|
|
|
foreach($controller->beforeFilter as $filter)
|
|
|
|
{
|
|
|
|
if(is_callable(array($controller,$filter)) && $filter != 'beforeFilter')
|
|
|
|
{
|
|
|
|
$controller->$filter();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(is_callable(array($controller, $controller->beforeFilter)) && $controller->beforeFilter != 'beforeFilter')
|
|
|
|
{
|
|
|
|
$controller->{$controller->beforeFilter}();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$controller->beforeFilter();
|
|
|
|
|
|
|
|
foreach($controller->components as $c)
|
|
|
|
{
|
|
|
|
if (isset($controller->{$c}) && is_object($controller->{$c}) && is_callable(array($controller->{$c}, 'startup')))
|
|
|
|
{
|
|
|
|
$controller->{$c}->startup($controller);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$output = call_user_func_array(array(&$controller, $params['action']), empty($params['pass'])? null: $params['pass']);
|
|
|
|
if ($controller->autoRender)
|
|
|
|
{
|
|
|
|
$output = $controller->render();
|
|
|
|
}
|
|
|
|
$controller->output =& $output;
|
|
|
|
$controller->afterFilter();
|
|
|
|
return $controller->output;
|
|
|
|
}
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns array of GET and POST parameters. GET parameters are taken from given URL.
|
|
|
|
*
|
2005-12-27 03:33:44 +00:00
|
|
|
* @param string $from_url URL to mine for parameter information.
|
2005-07-10 05:08:19 +00:00
|
|
|
* @return array Parameters found in POST and GET.
|
|
|
|
*/
|
2006-02-18 23:42:21 +00:00
|
|
|
function parseParams($from_url)
|
|
|
|
{
|
|
|
|
// load routes config
|
|
|
|
$Route = new Router();
|
|
|
|
include CONFIGS.'routes.php';
|
|
|
|
$params = $Route->parse ($from_url);
|
|
|
|
|
|
|
|
if (ini_get('magic_quotes_gpc') == 1)
|
|
|
|
{
|
|
|
|
if(!empty($_POST))
|
|
|
|
{
|
|
|
|
$params['form'] = stripslashes_deep($_POST);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$params['form'] = $_POST;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($params['form']['data']))
|
|
|
|
{
|
|
|
|
$params['data'] = $params['form']['data'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($_GET))
|
|
|
|
{
|
|
|
|
if (ini_get('magic_quotes_gpc') == 1)
|
|
|
|
{
|
|
|
|
$params['url'] = stripslashes_deep($_GET);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$params['url'] = $_GET;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($_FILES as $name => $data)
|
|
|
|
{
|
|
|
|
$params['form'][$name] = $data;
|
|
|
|
}
|
|
|
|
$params['bare'] = empty($params['ajax'])? (empty($params['bare'])? 0: 1): 1;
|
|
|
|
|
|
|
|
$params['webservices'] = empty($params['webservices']) ? null : $params['webservices'];
|
|
|
|
|
|
|
|
return $params;
|
|
|
|
}
|
2005-07-10 05:08:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a base URL.
|
|
|
|
*
|
2005-12-27 03:33:44 +00:00
|
|
|
* @return string Base URL
|
2005-07-10 05:08:19 +00:00
|
|
|
*/
|
2006-02-19 06:10:12 +00:00
|
|
|
function baseUrl()
|
2005-10-04 06:39:40 +00:00
|
|
|
{
|
2006-02-18 23:42:21 +00:00
|
|
|
$htaccess = null;
|
|
|
|
$base = $this->admin;
|
|
|
|
$this->webroot = '';
|
|
|
|
if (defined('BASE_URL'))
|
|
|
|
{
|
|
|
|
$base = BASE_URL.$this->admin;
|
|
|
|
}
|
|
|
|
$docRoot = env('DOCUMENT_ROOT');
|
|
|
|
$scriptName = env('PHP_SELF');
|
2006-02-19 03:56:54 +00:00
|
|
|
$r = null;
|
2006-02-18 23:42:21 +00:00
|
|
|
|
2006-02-19 03:56:54 +00:00
|
|
|
if (preg_match('/'.APP_DIR.'\\'.DS.WEBROOT_DIR.'/', $docRoot))
|
|
|
|
{
|
|
|
|
$this->webroot = '/';
|
|
|
|
if (preg_match('/^(.*)\/index\.php$/', $scriptName, $r))
|
|
|
|
{
|
|
|
|
if(!empty($r[1]))
|
|
|
|
{
|
|
|
|
return $base.$r[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (defined('BASE_URL'))
|
|
|
|
{
|
|
|
|
$webroot =setUri();
|
|
|
|
$htaccess = preg_replace('/(?:'.APP_DIR.'(.*)|index\\.php(.*))/i', '', $webroot).APP_DIR.'/'.WEBROOT_DIR.'/';
|
|
|
|
}
|
2006-02-19 06:10:12 +00:00
|
|
|
if (preg_match('/^(.*)\\/'.APP_DIR.'\\/'.WEBROOT_DIR.'\\/index\\.php$/', $scriptName, $regs))
|
2006-02-19 03:56:54 +00:00
|
|
|
{
|
2006-02-19 06:10:12 +00:00
|
|
|
!empty($htaccess)? $this->webroot = $htaccess : $this->webroot = $regs[1].'/'.APP_DIR.'/';
|
|
|
|
return $base.$regs[1].'/'.APP_DIR;
|
|
|
|
}
|
|
|
|
elseif (preg_match('/^(.*)\\/'.WEBROOT_DIR.'([^\/i]*)|index\\\.php$/', $scriptName, $regs))
|
|
|
|
{
|
|
|
|
!empty($htaccess)? $this->webroot = $htaccess : $this->webroot = $regs[0].'/';
|
|
|
|
return $base.$regs[0];
|
2006-02-19 03:56:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-02-19 06:10:12 +00:00
|
|
|
!empty($htaccess)? $this->webroot = $htaccess : $this->webroot = '/';
|
|
|
|
return $base;
|
2006-02-19 03:56:54 +00:00
|
|
|
}
|
|
|
|
}
|
2006-02-18 23:42:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function _restructureParams($params)
|
|
|
|
{
|
|
|
|
$params['controller'] = $params['action'];
|
|
|
|
if(isset($params['pass'][0]))
|
|
|
|
{
|
|
|
|
$params['action'] = $params['pass'][0];
|
|
|
|
array_shift($params['pass']);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$params['action'] = null;
|
|
|
|
}
|
|
|
|
return $params;
|
|
|
|
}
|
2005-07-21 04:02:32 +00:00
|
|
|
}
|
|
|
|
?>
|