/** * 通过URL分析模块、控制器、动作名及参数列表 * @access private * @return void */ private function _start() { if ($this->_final_uri != '' && $this->_final_uri != '/' && $this->_final_uri != '/index.php') { $tmp = explode('/', $this->_final_uri); XF_Functions::arrayDeleteEmptyValue($tmp, TRUE); $count = count($tmp); $isDefaultModule = FALSE; $setController = false; $binds = $this->getAllBindModuleName(); $domainModuleName = null; if (key_exists($this->_request_http_host, $this->_bin_domain)) { $domainModuleName = $this->_bin_domain[$this->_request_http_host]; } if ($domainModuleName != null) { $isDefaultModule = TRUE; $this->_request->setModule($domainModuleName); //2013-10-17 if ($count >= 1 && is_array($this->_bin_domain_allow_modules) && isset($this->_bin_domain_allow_modules[$domainModuleName]) && in_array($tmp[0], $this->_bin_domain_allow_modules[$domainModuleName])) { //是否为自身当前绑定应用的控制器 if (!file_exists(APPLICATION_PATH . '/modules/' . $domainModuleName . '/' . ucfirst($tmp[0]) . 'Controller.php')) { if (is_dir(APPLICATION_PATH . '/modules/' . $tmp[0])) { $isDefaultModule = FALSE; $this->_request->setModule($tmp[0]); } } } } elseif ($count == 1) { if (strtolower($tmp[0]) == 'index') { throw new XF_Exception('Access denied', 404); } //是否为默认module中的控制器 if (is_file(APPLICATION_PATH . '/controllers/' . ucfirst($tmp[0]) . 'Controller.php')) { $setController = $isDefaultModule = TRUE; $this->_request->setModule('default')->setController($tmp[0]); } elseif (is_dir(APPLICATION_PATH . '/modules/' . $tmp[0] . '/controllers/') && !in_array($tmp[0], $binds)) { $this->_request->setModule($tmp[0]); } else { $this->_request->setModule('unknown'); } return; } else { //是否存在此Module if (isset($tmp[1]) && is_file(APPLICATION_PATH . '/modules/' . $tmp[0] . '/controllers/' . ucfirst($tmp[1]) . 'Controller.php') && !in_array($tmp[0], $binds)) { $this->_request->setModule($tmp[0]); } else { //是否为默module中的控制器(controller) if (is_file(APPLICATION_PATH . '/controllers/' . ucfirst($tmp[0]) . 'Controller.php')) { $setController = $isDefaultModule = TRUE; $this->_request->setModule('default')->setController($tmp[0]); } else { $this->_request->setModule('unknown'); } } } $index = 0; if (!$isDefaultModule) { $index++; } if ($setController == false) { $this->_request->setController(isset($tmp[$index]) ? $tmp[$index] : 'index'); } $this->_request->setAction(isset($tmp[$index + 1]) ? $tmp[$index + 1] : 'index'); //分析参数列表 if (isset($tmp[$index + 2])) { $params = array_slice($tmp, $index + 2); if ($this->_save_uri_value === true) { for ($i = 0; $i < count($params); $i++) { $this->_request->setParam('$' . ($i + 1), urldecode($params[$i])); } } else { for ($i = 0; $i <= count($params); $i += 2) { if (isset($params[$i]) && !is_numeric($params[$i])) { $this->_request->setParam($params[$i], isset($params[$i + 1]) ? urldecode($params[$i + 1]) : ''); } } } } } else { $this->_setDefault(); } }