$value){ if($key<>'username' && $key<>'passwd') $_POST['jform'][$key]=$value; } $_POST['id']=0; define( '_JEXEC', 1 ); define('DS', DIRECTORY_SEPARATOR); if (file_exists(dirname(__FILE__) . '/defines.php')) { include_once dirname(__FILE__) . '/defines.php'; } if (!defined('_JDEFINES')) { define('JPATH_BASE', dirname(__FILE__)); require_once JPATH_BASE.'/includes/defines.php'; } //require_once( JPATH_BASE .DS.'includes'.DS.'framework.php' ); // No direct access. defined('_JEXEC') or die; /* * Joomla! system checks. */ @ini_set('magic_quotes_runtime', 0); @ini_set('zend.ze1_compatibility_mode', '0'); /* * Installation check, and check on removal of the install directory. */ /* if (!file_exists(JPATH_CONFIGURATION.'/configuration.php') || (filesize(JPATH_CONFIGURATION.'/configuration.php') < 10) || file_exists(JPATH_INSTALLATION.'/index.php')) { header( 'Location: ../installation/index.php' ); exit(); } */ /* * Joomla! system startup */ // Import the cms version library if necessary. if (!class_exists('JVersion')) { require JPATH_ROOT.'/includes/version.php'; } // System includes. //require_once JPATH_LIBRARIES.'/import.php'; defined('_JEXEC') or die; // Set the platform root path as a constant if necessary. if (!defined('JPATH_PLATFORM')) { //define('JPATH_PLATFORM', dirname(__FILE__)); define('JPATH_PLATFORM', JPATH_ROOT . '/libraries'); //zzcity modi } // Set the directory separator define if necessary. if (!defined('DS')) { define('DS', DIRECTORY_SEPARATOR); } // Detect the native operating system type. $os = strtoupper(substr(PHP_OS, 0, 3)); if (!defined('IS_WIN')) { define('IS_WIN', ($os === 'WIN') ? true : false); } if (!defined('IS_MAC')) { define('IS_MAC', ($os === 'MAC') ? true : false); } if (!defined('IS_UNIX')) { define('IS_UNIX', (($os !== 'MAC') && ($os !== 'WIN')) ? true : false); } // Import the platform version library if necessary. if (!class_exists('JPlatform')) { require_once JPATH_PLATFORM.'/platform.php'; } // Import the library loader if necessary. if (!class_exists('JLoader')) { require_once JPATH_PLATFORM.'/loader.php'; } /** * Import the base Joomla Platform libraries. */ //zzcity add 从jfactory中提出来定义的类文件joomla.application.application jimport('joomla.application.input'); jimport('joomla.event.dispatcher'); jimport('joomla.environment.response'); jimport('joomla.log.log'); //zzcity add 从japplication提上来定义的类文件/administrator/includes/application.php //jimport('joomla.application.component.helper'); //zzcity modi 此处替换该类定义源码 class JComponentHelper { /** * The component list cache * * @var array * @since 11.1 */ protected static $_components = array(); /** * Get the component information. * * @param string $option The component option. * @param boolean $strict If set and the component does not exist, the enabled attribue will be set to false. * * @return object An object with the information for the component. * @since 11.1 */ public static function getComponent($option, $strict = false) { if (!isset(self::$_components[$option])) { if (self::_load($option)){ $result = self::$_components[$option]; } else { $result = new stdClass; $result->enabled = $strict ? false : true; $result->params = new JRegistry; } } else { $result = self::$_components[$option]; } return $result; } /** * Checks if the component is enabled * * @param string $option The component option. * @param boolean $strict If set and the component does not exist, false will be returned. * * @return boolean * @since 11.1 */ public static function isEnabled($option, $strict = false) { $result = self::getComponent($option, $strict); return ($result->enabled | JFactory::getApplication()->isAdmin()); } /** * Gets the parameter object for the component * * @param string $option The option for the component. * @param boolean $strict If set and the component does not exist, false will be returned * * @return JRegistry A JRegistry object. * * @see JRegistry * @since 11.1 */ public static function getParams($option, $strict = false) { $component = self::getComponent($option, $strict); return $component->params; } /** * Render the component. * * @param string $option The component option. * @param array $params The component parameters * * @return void * @since 11.1 */ public static function renderComponent($option, $params = array()) { // Initialise variables. $app = JFactory::getApplication(); // Load template language files. $template = $app->getTemplate(true)->template; $lang = JFactory::getLanguage(); $lang->load('tpl_'.$template, JPATH_BASE, null, false, false) || $lang->load('tpl_'.$template, JPATH_THEMES."/$template", null, false, false) || $lang->load('tpl_'.$template, JPATH_BASE, $lang->getDefault(), false, false) || $lang->load('tpl_'.$template, JPATH_THEMES."/$template", $lang->getDefault(), false, false); if (empty($option)) { // Throw 404 if no component JError::raiseError(404, JText::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND')); return; } // Record the scope $scope = $app->scope; // Set scope to component name $app->scope = $option; // Build the component path. $option = preg_replace('/[^A-Z0-9_\.-]/i', '', $option); $file = substr($option, 4); // Define component path. define('JPATH_COMPONENT', JPATH_BASE . '/components/' . $option); define('JPATH_COMPONENT_SITE', JPATH_SITE . '/components/' . $option); define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR . '/components/' . $option); // Get component path if ($app->isAdmin() && file_exists(JPATH_COMPONENT . '/admin.'.$file.'.php')) { $path = JPATH_COMPONENT . '/admin.'.$file.'.php'; } else { $path = JPATH_COMPONENT . '/' . $file.'.php'; } // If component is disabled throw error if (!self::isEnabled($option) || !file_exists($path)) { JError::raiseError(404, JText::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND')); } $task = JRequest::getString('task'); // Load common and local language files. $lang->load($option, JPATH_BASE, null, false, false) || $lang->load($option, JPATH_COMPONENT, null, false, false) || $lang->load($option, JPATH_BASE, $lang->getDefault(), false, false) || $lang->load($option, JPATH_COMPONENT, $lang->getDefault(), false, false); // Handle template preview outlining. $contents = null; // Execute the component. ob_start(); //require_once $path; 此处替换为该文件源码/administrator/components/com_content/content.php // Access check. if (!JFactory::getUser()->authorise('core.manage', 'com_content')) { return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); } // Include dependencies jimport('joomla.application.component.controller'); $controller = JController::getInstance('Content'); $controller->execute(JRequest::getCmd('task')); //zzcity \administrator\components\com_content\models\articel.php 中的save $controller->redirect(); //-------------require_once结束 exit;//zzcity add $contents = ob_get_contents(); ob_end_clean(); // Build the component toolbar jimport('joomla.application.helper'); if (($path = JApplicationHelper::getPath('toolbar')) && $app->isAdmin()) { // Get the task again, in case it has changed $task = JRequest::getString('task'); // Make the toolbar include_once $path; } // Revert the scope $app->scope = $scope; return $contents; } /** * Load the installed components into the _components property. * * @param string $option The element value for the extension * * @return boolean True on success * @since 11.1 */ protected static function _load($option) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('extension_id AS "id", element AS "option", params, enabled'); $query->from('#__extensions'); $query->where($query->qn('type').' = '.$db->quote('component')); $query->where($query->qn('element').' = '.$db->quote($option)); $db->setQuery($query); $cache = JFactory::getCache('_system', 'callback'); self::$_components[$option] = $cache->get(array($db, 'loadObject'), null, $option, false); if ($error = $db->getErrorMsg() || empty(self::$_components[$option])) { // Fatal error. JError::raiseWarning(500, JText::sprintf('JLIB_APPLICATION_ERROR_COMPONENT_NOT_LOADING', $option, $error)); return false; } // Convert the params to an object. if (is_string(self::$_components[$option]->params)) { $temp = new JRegistry; $temp->loadString(self::$_components[$option]->params); self::$_components[$option]->params = $temp; } return true; } } //--------------jimport('joomla.application.component.helper');结束 // Import the base object library. JLoader::import('joomla.base.object'); //zzcity 从下面移动到这里定义(import.php文件) /** * Base class for a Joomla! application. * * Acts as a Factory class for application specific objects and provides many * supporting API functions. Derived clases should supply the route(), dispatch() * and render() functions. * * @package Joomla.Platform * @subpackage Application * @since 11.1 */ class JApplication extends JObject { /** * The client identifier. * * @var integer * @since 11.1 */ protected $_clientId = null; /** * The application message queue. * * @var array * @since 11.1 */ protected $_messageQueue = array(); /** * The name of the application. * * @var array * @since 11.1 */ protected $_name = null; /** * The scope of the application. * * @var string * @since 11.1 */ public $scope = null; /** * The time the request was made. * * @var date * @since 11.1 */ public $requestTime = null; /** * The time the request was made as Unix timestamp. * * @var integer * @since 11.1 */ public $startTime = null; /** * The application input object. * * @var JInput * @since 11.2 */ public $input = null; /** * Class constructor. * * @param array $config A configuration array including optional elements such as session * session_name, clientId and others. This is not exhaustive. * * @since 11.1 */ public function __construct($config = array()) { jimport('joomla.utilities.utility'); jimport('joomla.error.profiler'); // Set the view name. $this->_name = $this->getName(); // Only set the clientId if available. if (isset($config['clientId'])) { $this->_clientId = $config['clientId']; } // Enable sessions by default. if (!isset($config['session'])) { $config['session'] = true; } // Create the input object if (class_exists('JInput')) { $this->input = new JInput; } // Set the session default name. if (!isset($config['session_name'])) { $config['session_name'] = $this->_name; } // Set the default configuration file. if (!isset($config['config_file'])) { $config['config_file'] = 'configuration.php'; } // Create the configuration object. if (file_exists(JPATH_CONFIGURATION . '/' . $config['config_file'])) { $this->_createConfiguration(JPATH_CONFIGURATION . '/' . $config['config_file']); } // Create the session if a session name is passed. if ($config['session'] !== false) { $this->_createSession(JUtility::getHash($config['session_name'])); } $this->set('requestTime', gmdate('Y-m-d H:i')); // Used by task system to ensure that the system doesn't go over time. $this->set('startTime', JProfiler::getmicrotime()); } /** * Returns the global JApplication object, only creating it if it * doesn't already exist. * * @param mixed $client A client identifier or name. * @param array $config An optional associative array of configuration settings. * @param strong $prefx A prefix for class names * * @return JApplication A JApplication object. * * @since 11.1 */ public static function getInstance($client, $config = array(), $prefix = 'J') { static $instances; if (!isset($instances)) { $instances = array(); } if (empty($instances[$client])) { // Load the router object. jimport('joomla.application.helper'); $info = JApplicationHelper::getClientInfo($client, true); $path = $info->path . '/includes/application.php'; if (file_exists($path)) { //require_once $path; //zzcity modi 类文件/administrator/includes/application.php移到上面定义以便修改 // Create a JRouter object. $classname = $prefix.ucfirst($client); $instance = new $classname($config); } else { $error = JError::raiseError(500, JText::sprintf('JLIB_APPLICATION_ERROR_APPLICATION_LOAD', $client)); return $error; } $instances[$client] = &$instance; } return $instances[$client]; } /** * Initialise the application. * * @param array $options An optional associative array of configuration settings. * * @since 11.1 */ public function initialise($options = array()) { jimport('joomla.plugin.helper'); // Set the language in the class. $config = JFactory::getConfig(); // Check that we were given a language in the array (since by default may be blank). if (isset($options['language'])) { $config->set('language', $options['language']); } // Set user specific editor. $user = JFactory::getUser(); $editor = $user->getParam('editor', $this->getCfg('editor')); if (!JPluginHelper::isEnabled('editors', $editor)) { $editor = $this->getCfg('editor'); if (!JPluginHelper::isEnabled('editors', $editor)) { $editor = 'none'; } } $config->set('editor', $editor); // Trigger the onAfterInitialise event. JPluginHelper::importPlugin('system'); $this->triggerEvent('onAfterInitialise'); } /** * Route the application. * * Routing is the process of examining the request environment to determine which * component should receive the request. The component optional parameters * are then set in the request object to be processed when the application is being * dispatched. * * @return void; * * @since 11.1 */ public function route() { // Get the full request URI. $uri = clone JURI::getInstance(); $router = $this->getRouter(); $result = $router->parse($uri); JRequest::set($result, 'get', false); // Trigger the onAfterRoute event. JPluginHelper::importPlugin('system'); $this->triggerEvent('onAfterRoute'); } /** * Dispatch the applicaiton. * * Dispatching is the process of pulling the option from the request object and * mapping them to a component. If the component does not exist, it handles * determining a default component to dispatch. * * @param string $component The component to dispatch. * * @return void * * @since 11.1 */ public function dispatch($component = null) { $document = JFactory::getDocument(); $document->setTitle($this->getCfg('sitename'). ' - ' .JText::_('JADMINISTRATION')); $document->setDescription($this->getCfg('MetaDesc')); $contents = JComponentHelper::renderComponent($component); $document->setBuffer($contents, 'component'); // Trigger the onAfterDispatch event. JPluginHelper::importPlugin('system'); $this->triggerEvent('onAfterDispatch'); } /** * Render the application. * * Rendering is the process of pushing the document buffers into the template * placeholders, retrieving data from the document and pushing it into * the JResponse buffer. * * @return void * * @since 11.1 */ public function render() { $params = array( 'template' => $this->getTemplate(), 'file' => 'index.php', 'directory' => JPATH_THEMES, 'params' => $template->params ); // Parse the document. $document = JFactory::getDocument(); $document->parse($params); // Trigger the onBeforeRender event. JPluginHelper::importPlugin('system'); $this->triggerEvent('onBeforeRender'); // Render the document. $caching = ($this->getCfg('caching') >= 2) ? true : false; JResponse::setBody($document->render($caching, $params)); // Trigger the onAfterRender event. $this->triggerEvent('onAfterRender'); } /** * Exit the application. * * @param integer $code Exit code * * @return void Exits the application. * * @since 11.1 */ public function close($code = 0) { exit($code); } /** * Redirect to another URL. * * Optionally enqueues a message in the system message queue (which will be displayed * the next time a page is loaded) using the enqueueMessage method. If the headers have * not been sent the redirect will be accomplished using a "301 Moved Permanently" * code in the header pointing to the new location. If the headers have already been * sent this will be accomplished using a JavaScript statement. * * @param string $url The URL to redirect to. Can only be http/https URL * @param string $msg An optional message to display on redirect. * @param string $msgType An optional message type. Defaults to message. * @param boolean $moved True if the page is 301 Permanently Moved, otherwise 303 See Other is assumed. * * @return void Calls exit(). * * @since 11.1 * * @see JApplication::enqueueMessage() */ public function redirect($url, $msg='', $msgType='message', $moved = false) { //zzcity add if($msgType=='error'){ echo('[err]'.$msg.'[/err]'); }else{ echo('[ok]'.$msg); } exit; //--------zzcity // Check for relative internal links. if (preg_match('#^index2?\.php#', $url)) { $url = JURI::base() . $url; } // Strip out any line breaks. $url = preg_split("/[\r\n]/", $url); $url = $url[0]; // If we don't start with a http we need to fix this before we proceed. // We could validly start with something else (e.g. ftp), though this would // be unlikely and isn't supported by this API. if (!preg_match('#^http#i', $url)) { $uri = JURI::getInstance(); $prefix = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port')); if ($url[0] == '/') { // We just need the prefix since we have a path relative to the root. $url = $prefix . $url; } else { // It's relative to where we are now, so lets add that. $parts = explode('/', $uri->toString(array('path'))); array_pop($parts); $path = implode('/', $parts).'/'; $url = $prefix . $path . $url; } } // If the message exists, enqueue it. if (trim($msg)) { $this->enqueueMessage($msg, $msgType); } // Persist messages if they exist. if (count($this->_messageQueue)) { $session = JFactory::getSession(); $session->set('application.queue', $this->_messageQueue); } // If the headers have been sent, then we cannot send an additional location header // so we will output a javascript redirect statement. if (headers_sent()) { echo "\n"; } else { $document = JFactory::getDocument(); jimport('joomla.environment.browser'); $navigator = JBrowser::getInstance(); jimport('phputf8.utils.ascii'); if ($navigator->isBrowser('msie') && !utf8_is_ascii($url)) { // MSIE type browser and/or server cause issues when url contains utf8 character,so use a javascript redirect method echo '
'; } elseif (!$moved and $navigator->isBrowser('konqueror')) { // WebKit browser (identified as konqueror by Joomla!) - Do not use 303, as it causes subresources reload (https://bugs.webkit.org/show_bug.cgi?id=38690) echo ''; } else { // All other browsers, use the more efficient HTTP header method header($moved ? 'HTTP/1.1 301 Moved Permanently' : 'HTTP/1.1 303 See other'); header('Location: '.$url); header('Content-Type: text/html; charset='.$document->getCharset()); } } $this->close(); } /** * Enqueue a system message. * * @param string $msg The message to enqueue. * @param string $type The message type. Default is message. * * @return void * * @since 11.1 */ public function enqueueMessage($msg, $type = 'message') { // For empty queue, if messages exists in the session, enqueue them first. if (!count($this->_messageQueue)) { $session = JFactory::getSession(); $sessionQueue = $session->get('application.queue'); if (count($sessionQueue)) { $this->_messageQueue = $sessionQueue; $session->set('application.queue', null); } } // Enqueue the message. $this->_messageQueue[] = array('message' => $msg, 'type' => strtolower($type)); } /** * Get the system message queue. * * @return array The system message queue. * * @since 11.1 */ public function getMessageQueue() { // For empty queue, if messages exists in the session, enqueue them. if (!count($this->_messageQueue)) { $session = JFactory::getSession(); $sessionQueue = $session->get('application.queue'); if (count($sessionQueue)) { $this->_messageQueue = $sessionQueue; $session->set('application.queue', null); } } return $this->_messageQueue; } /** * Gets a configuration value. * * An example is in application/japplication-getcfg.php Getting a configuration * * @param string The name of the value to get. * @param string Default value to return * * @return mixed The user state. * * @since 11.1 */ public function getCfg($varname, $default=null) { $config = JFactory::getConfig(); return $config->get('' . $varname, $default); } /** * Method to get the application name. * * The dispatcher name is by default parsed using the classname, or it can be set * by passing a $config['name'] in the class constructor. * * @return string The name of the dispatcher. * * @since 11.1 */ public function getName() { $name = $this->_name; if (empty($name)) { $r = null; if (!preg_match('/J(.*)/i', get_class($this), $r)) { JError::raiseError(500, JText::_('JLIB_APPLICATION_ERROR_APPLICATION_GET_NAME')); } $name = strtolower($r[1]); } return $name; } /** * Gets a user state. * * @param string The path of the state. * @param mixed Optional default value, returned if the internal value is null. * * @return mixed The user state or null. * * @since 11.1 */ public function getUserState($key, $default = null) { $session = JFactory::getSession(); $registry = $session->get('registry'); if (!is_null($registry)) { return $registry->get($key, $default); } return $default; } /** * Sets the value of a user state variable. * * @param string The path of the state. * @param string The value of the variable. * * @return mixed The previous state, if one existed. * * @since 11.1 */ public function setUserState($key, $value) { $session = JFactory::getSession(); $registry = $session->get('registry'); if (!is_null($registry)) { return $registry->set($key, $value); } return null; } /** * Gets the value of a user state variable. * * @param string $key The key of the user state variable. * @param string $request The name of the variable passed in a request. * @param string $default The default value for the variable if not found. Optional. * @param string $type Filter for the variable, for valid values see {@link JFilterInput::clean()}. Optional. * * @return The request user state. * * @since 11.1 */ public function getUserStateFromRequest($key, $request, $default = null, $type = 'none') { $cur_state = $this->getUserState($key, $default); $new_state = JRequest::getVar($request, null, 'default', $type); // Save the new value only if it was set in this request. if ($new_state !== null) { $this->setUserState($key, $new_state); } else { $new_state = $cur_state; } return $new_state; } /** * Registers a handler to a particular event group. * * @param string $event The event name. * @param mixed $handler The handler, a function or an instance of a event object. * * @return void * * @since 11.1 */ public static function registerEvent($event, $handler) { $dispatcher = JDispatcher::getInstance(); $dispatcher->register($event, $handler); } /** * Calls all handlers associated with an event group. * * @param string $event The event name. * @param array $args An array of arguments. * * @return array An array of results from each function call. * * @since 11.1 */ function triggerEvent($event, $args=null) { $dispatcher = JDispatcher::getInstance(); return $dispatcher->trigger($event, $args); } /** * Login authentication function. * * Username and encoded password are passed the onUserLogin event which * is responsible for the user validation. A successful validation updates * the current session record with the user's details. * * Username and encoded password are sent as credentials (along with other * possibilities) to each observer (authentication plugin) for user * validation. Successful validation will update the current session with * the user details. * * @param array $credentials Array('username' => string, 'password' => string) * @param array $options Array('remember' => boolean) * * @return boolean True on success. * * @since 11.1 */ public function login($credentials, $options = array()) { // Get the global JAuthentication object. jimport('joomla.user.authentication'); $authenticate = JAuthentication::getInstance(); $response = $authenticate->authenticate($credentials, $options); if ($response->status === JAuthentication::STATUS_SUCCESS) { // validate that the user should be able to login (different to being authenticated) // this permits authentication plugins blocking the user $authorisations = $authenticate->authorise($response, $options); foreach ($authorisations as $authorisation) { $denied_states = array(JAuthentication::STATUS_EXPIRED, JAuthentication::STATUS_DENIED); if(in_array($authorisation->status, $denied_states)) { // Trigger onUserAuthorisationFailure Event. $this->triggerEvent('onUserAuthorisationFailure', array((array)$authorisation)); // If silent is set, just return false. if (isset($options['silent']) && $options['silent']) { return false; } // Return the error. switch($authorisation->status) { case JAuthentication::STATUS_EXPIRED: return JError::raiseWarning('102002', JText::_('JLIB_LOGIN_EXPIRED')); break; case JAuthentication::STATUS_DENIED: return JError::raiseWarning('102003', JText::_('JLIB_LOGIN_DENIED')); break; default: return JError::raiseWarning('102004', JText::_('JLIB_LOGIN_AUTHORISATION')); break; } } } // Import the user plugin group. JPluginHelper::importPlugin('user'); // OK, the credentials are authenticated and user is authorised. Lets fire the onLogin event. $results = $this->triggerEvent('onUserLogin', array((array)$response, $options)); /* * If any of the user plugins did not successfully complete the login routine * then the whole method fails. * * Any errors raised should be done in the plugin as this provides the ability * to provide much more information about why the routine may have failed. */ if (!in_array(false, $results, true)) { // Set the remember me cookie if enabled. if (isset($options['remember']) && $options['remember']) { jimport('joomla.utilities.simplecrypt'); jimport('joomla.utilities.utility'); // Create the encryption key, apply extra hardening using the user agent string. $agent = @$_SERVER['HTTP_USER_AGENT']; // Ignore empty and crackish user agents if ($agent != '' && $agent != 'JLOGIN_REMEMBER') { $key = JUtility::getHash($agent); $crypt = new JSimpleCrypt($key); $rcookie = $crypt->encrypt(serialize($credentials)); $lifetime = time() + 365*24*60*60; // Use domain and path set in config for cookie if it exists. $cookie_domain = $this->getCfg('cookie_domain', ''); $cookie_path = $this->getCfg('cookie_path', '/'); setcookie( JUtility::getHash('JLOGIN_REMEMBER'), $rcookie, $lifetime, $cookie_path, $cookie_domain ); } } return true; } } // Trigger onUserLoginFailure Event. $this->triggerEvent('onUserLoginFailure', array((array)$response)); // If silent is set, just return false. if (isset($options['silent']) && $options['silent']) { return false; } // If status is success, any error will have been raised by the user plugin if ($response->status !== JAuthentication::STATUS_SUCCESS) { JError::raiseWarning('102001', JText::_('JLIB_LOGIN_AUTHENTICATE')); } return false; } /** * Logout authentication function. * * Passed the current user information to the onUserLogout event and reverts the current * session record back to 'anonymous' parameters. * If any of the authentication plugins did not successfully complete * the logout routine then the whole method fails. Any errors raised * should be done in the plugin as this provides the ability to give * much more information about why the routine may have failed. * * @param integer $userid The user to load - Can be an integer or string - If string, it is converted to ID automatically * @param array $options Array('clientid' => array of client id's) * * @return boolean True on success * * @since 11.1 */ public function logout($userid = null, $options = array()) { // Initialise variables. $retval = false; // Get a user object from the JApplication. $user = JFactory::getUser($userid); // Build the credentials array. $parameters['username'] = $user->get('username'); $parameters['id'] = $user->get('id'); // Set clientid in the options array if it hasn't been set already. if (!isset($options['clientid'])) { $options['clientid']= $this->getClientId(); } // Import the user plugin group. JPluginHelper::importPlugin('user'); // OK, the credentials are built. Lets fire the onLogout event. $results = $this->triggerEvent('onUserLogout', array($parameters, $options)); // Check if any of the plugins failed. If none did, success. if (!in_array(false, $results, true)) { // Use domain and path set in config for cookie if it exists. $cookie_domain = $this->getCfg('cookie_domain', ''); $cookie_path = $this->getCfg('cookie_path', '/'); setcookie(JUtility::getHash('JLOGIN_REMEMBER'), false, time() - 86400, $cookie_path, $cookie_domain); return true; } // Trigger onUserLoginFailure Event. $this->triggerEvent('onUserLogoutFailure', array($parameters)); return false; } /** * Gets the name of the current template. * * @param array $params An optional associative array of configuration settings * * @return string System is the fallback. * * @since 11.1 */ public function getTemplate($params = false) { return 'system'; } /** * Returns the application JRouter object. * * @param string $name The name of the application. * @param array $options An optional associative array of configuration settings. * * @return JRouter A JRouter object * * @since 11.1 */ static public function getRouter($name = null, array $options = array()) { if (!isset($name)) { $app = JFactory::getApplication(); $name = $app->getName(); } jimport('joomla.application.router'); $router = JRouter::getInstance($name, $options); if (JError::isError($router)) { return null; } return $router; } /** * This method transliterates a string into an URL * safe string or returns a URL safe UTF-8 string * based on the global configuration * * @param string $string String to process * * @return string Processed string * * @since 11.1 */ static public function stringURLSafe($string) { if (JFactory::getConfig()->get('unicodeslugs') == 1) { $output = JFilterOutput::stringURLUnicodeSlug($string); } else { $output = JFilterOutput::stringURLSafe($string); } return $output; } /** * Returns the application JPathway object. * * @param string $name The name of the application. * @param array $options An optional associative array of configuration settings. * * @return JPathway A JPathway object * * @since 11.1 */ public function getPathway($name = null, $options = array()) { if (!isset($name)) { $name = $this->_name; } jimport('joomla.application.pathway'); $pathway = JPathway::getInstance($name, $options); if (JError::isError($pathway)) { return null; } return $pathway; } /** * Returns the application JPathway object. * * @param string $name The name of the application/client. * @param array $options An optional associative array of configuration settings. * * @return JMenu JMenu object. * * @since 11.1 */ public function getMenu($name = null, $options = array()) { if (!isset($name)) { $name = $this->_name; } jimport('joomla.application.menu'); $menu = JMenu::getInstance($name, $options); if (JError::isError($menu)) { return null; } return $menu; } /** * Provides a secure hash based on a seed * * @param string $seed Seed string. * * @return string A secure hash * * @since 11.1 */ public static function getHash($seed) { $conf = JFactory::getConfig(); return md5($conf->get('secret').$seed); } /** * Create the configuration registry. * * @param string $file The path to the configuration file * * @return object A JConfig object * * @since 11.1 */ protected function _createConfiguration($file) { jimport('joomla.registry.registry'); require_once $file; // Create the JConfig object. $config = new JConfig; // Get the global configuration object. $registry = JFactory::getConfig(); // Load the configuration values into the registry. $registry->loadObject($config); return $config; } /** * Create the user session. * * Old sessions are flushed based on the configuration value for the cookie * lifetime. If an existing session, then the last access time is updated. * If a new session, a session id is generated and a record is created in * the #__sessions table. * * @param string $name The sessions name. * * @return JSession JSession on success. May call exit() on database error. * * @since 11.1 */ protected function _createSession($name) { $options = array(); $options['name'] = $name; switch($this->_clientId) { case 0: if ($this->getCfg('force_ssl') == 2) { $options['force_ssl'] = true; } break; case 1: if ($this->getCfg('force_ssl') >= 1) { $options['force_ssl'] = true; } break; } $session = JFactory::getSession($options); //TODO: At some point we need to get away from having session data always in the db. $db = JFactory::getDBO(); // Remove expired sessions from the database. $time = time(); if ($time % 2) { // The modulus introduces a little entropy, making the flushing less accurate // but fires the query less than half the time. $query = $db->getQuery(true); $db->setQuery( 'DELETE FROM '.$query->qn('#__session') . ' WHERE '.$query->qn('time').' < '.(int) ($time - $session->getExpire()) ); $db->query(); } // Check to see the the session already exists. if (($this->getCfg('session_handler') != 'database' && ($time % 2 || $session->isNew())) || ($this->getCfg('session_handler') == 'database' && $session->isNew()) ) { $this->checkSession(); } return $session; } /** * Checks the user session. * * If the session record doesn't exist, initialise it. * If session is new, create session variables * * @return void * * @since 11.1 */ public function checkSession() { $db = JFactory::getDBO(); $session = JFactory::getSession(); $user = JFactory::getUser(); $query = $db->getQuery(true); $db->setQuery( 'SELECT '.$query->qn('session_id') . ' FROM '.$query->qn('#__session') . ' WHERE '.$query->qn('session_id').' = '.$query->q($session->getId()), 0, 1 ); $exists = $db->loadResult(); // If the session record doesn't exist initialise it. if (!$exists) { if ($session->isNew()) { $db->setQuery( 'INSERT INTO '.$query->qn('#__session').' ('.$query->qn('session_id').', '.$query->qn('client_id').', '.$query->qn('time').')' . ' VALUES ('.$query->q($session->getId()).', '.(int) $this->getClientId().', '.(int) time().')' ); } else { $db->setQuery( 'INSERT INTO `#__session` (`session_id`, `client_id`, `guest`, `time`, `userid`, `username`)' . ' VALUES ('.$db->quote($session->getId()).', '.(int) $this->getClientId().', '.(int) $user->get('guest').', '.(int) $session->get('session.timer.start').', '.(int) $user->get('id').', '.$db->quote($user->get('username')).')' ); } // If the insert failed, exit the application. if (!$db->query()) { jexit($db->getErrorMSG()); } // Session doesn't exist yet, so create session variables if ($session->isNew()) { $session->set('registry', new JRegistry('session')); $session->set('user', new JUser()); } } } /** * Gets the client id of the current running application. * * @return integer A client identifier. * * @since 11.1 */ public function getClientId() { return $this->_clientId; } /** * Is admin interface? * * @return boolean True if this application is administrator. * * @since 11.1 */ public function isAdmin() { return ($this->_clientId == 1); } /** * Is site interface? * * @return boolean True if this application is site. * * @since 11.1 */ public function isSite() { return ($this->_clientId == 0); } /** * Method to determine if the host OS is Windows * * @return boolean True if Windows OS * * @since 11.1 */ static function isWinOS() { return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'; } /** * Returns the response as a string. * * @return string The response * * @since 11.1 */ public function __toString() { $compress = $this->getCfg('gzip', false); return JResponse::toString($compress); } } //----------------------class JApplication 结束 /** * Joomla! Application class * * Provide many supporting API functions * * @package Joomla.Administrator * @final * @since 1.5 */ class JAdministrator extends JApplication { /** * Class constructor * * @param array An optional associative array of configuration settings. * Recognized key values include 'clientId' (this list is not meant to be comprehensive). * * @since 1.5 */ public function __construct($config = array()) { $config['clientId'] = 1; parent::__construct($config); //Set the root in the URI based on the application name JURI::root(null, str_ireplace('/'.$this->getName(), '', JURI::base(true))); } /** * Initialise the application. * * @param array $options An optional associative array of configuration settings. * * @return void * @since 1.5 */ function initialise($options = array()) { $config = JFactory::getConfig(); // if a language was specified it has priority // otherwise use user or default language settings if (empty($options['language'])) { $user = JFactory::getUser(); $lang = $user->getParam('admin_language'); // Make sure that the user's language exists if ($lang && JLanguage::exists($lang)) { $options['language'] = $lang; } else { $params = JComponentHelper::getParams('com_languages'); $client = JApplicationHelper::getClientInfo($this->getClientId()); $options['language'] = $params->get($client->name, $config->get('language','en-GB')); } } // One last check to make sure we have something if (!JLanguage::exists($options['language'])) { $lang = $config->get('language','en-GB'); if (JLanguage::exists($lang)) { $options['language'] = $lang; } else { $options['language'] = 'en-GB'; // as a last ditch fail to english } } // Execute the parent initialise method. parent::initialise($options); // Load Library language $lang = JFactory::getLanguage(); $lang->load('lib_joomla', JPATH_ADMINISTRATOR); } /** * Route the application * * @return void * @since 1.5 */ public function route() { $uri = JURI::getInstance(); if ($this->getCfg('force_ssl') >= 1 && strtolower($uri->getScheme()) != 'https') { //forward to https $uri->setScheme('https'); $this->redirect((string)$uri); } // Trigger the onAfterRoute event. JPluginHelper::importPlugin('system'); $this->triggerEvent('onAfterRoute'); } /** * Return a reference to the JRouter object. * * @return JRouter * @since 1.5 */ static public function getRouter($name = null, array $options = array()) { $router = parent::getRouter('administrator'); return $router; } /** * Dispatch the application * * @param string $component The component to dispatch. * * @return void * @since 1.5 */ public function dispatch($component = null) { try { if ($component === null) { $component = JAdministratorHelper::findOption(); } $document = JFactory::getDocument(); $user = JFactory::getUser(); switch ($document->getType()) { case 'html': $document->setMetaData('keywords', $this->getCfg('MetaKeys')); break; default: break; } $document->setTitle($this->getCfg('sitename'). ' - ' .JText::_('JADMINISTRATION')); $document->setDescription($this->getCfg('MetaDesc')); $contents = JComponentHelper::renderComponent($component); $document->setBuffer($contents, 'component'); // Trigger the onAfterDispatch event. JPluginHelper::importPlugin('system'); $this->triggerEvent('onAfterDispatch'); } // Mop up any uncaught exceptions. catch (Exception $e) { $code = $e->getCode(); JError::raiseError($code ? $code : 500, $e->getMessage()); } } /** * Display the application. * * @return void * @since 1.5 */ public function render() { $component = JRequest::getCmd('option', 'com_login'); $template = $this->getTemplate(true); $file = JRequest::getCmd('tmpl', 'index'); if ($component == 'com_login') { $file = 'login'; } // Safety check for when configuration.php root_user is in use. $config = JFactory::getConfig(); $rootUser = $config->get('root_user'); if (property_exists('JConfig', 'root_user') && (JFactory::getUser()->get('username') == $rootUser || JFactory::getUser()->id === (string) $rootUser)) { JError::raiseNotice(200, JText::sprintf('JWARNING_REMOVE_ROOT_USER', 'index.php?option=com_config&task=application.removeroot&'. JUtility::getToken() .'=1')); } $params = array( 'template' => $template->template, 'file' => $file.'.php', 'directory' => JPATH_THEMES, 'params' => $template->params ); $document = JFactory::getDocument(); $document->parse($params); $this->triggerEvent('onBeforeRender'); $data = $document->render(false, $params); JResponse::setBody($data); $this->triggerEvent('onAfterRender'); } /** * Login authentication function * * @param array Array('username' => string, 'password' => string) * @param array Array('remember' => boolean) * * @return boolean True on success. * @see JApplication::login * @since 1.5 */ public function login($credentials, $options = array()) { //The minimum group $options['group'] = 'Public Backend'; //Make sure users are not autoregistered $options['autoregister'] = false; //Set the application login entry point if (!array_key_exists('entry_url', $options)) { $options['entry_url'] = JURI::base().'index.php?option=com_users&task=login'; } // Set the access control action to check. $options['action'] = 'core.login.admin'; $result = parent::login($credentials, $options); if (!JError::isError($result)) { $lang = JRequest::getCmd('lang'); $lang = preg_replace('/[^A-Z-]/i', '', $lang); $this->setUserState('application.lang', $lang ); JAdministrator::purgeMessages(); } return $result; } /** * Get the template * * @return string The template name * @since 1.0 */ public function getTemplate($params = false) { static $template; if (!isset($template)) { $admin_style = JFactory::getUser()->getParam('admin_style'); // Load the template name from the database $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('template, s.params'); $query->from('#__template_styles as s'); $query->leftJoin('#__extensions as e ON e.type='.$db->quote('template').' AND e.element=s.template AND e.client_id=s.client_id'); if ($admin_style) { $query->where('s.client_id = 1 AND id = '.(int)$admin_style. ' AND e.enabled = 1','OR'); } $query->where('s.client_id = 1 AND home = 1','OR'); $query->order('home'); $db->setQuery($query); $template = $db->loadObject(); $template->template = JFilterInput::getInstance()->clean($template->template, 'cmd'); $template->params = new JRegistry($template->params); if (!file_exists(JPATH_THEMES . '/' . $template->template . '/index.php')) { $template->params = new JRegistry(); $template->template = 'bluestork'; } } if ($params) { return $template; } return $template->template; } /** * Purge the jos_messages table of old messages * * @return void * @since 1.5 */ public static function purgeMessages() { $db = JFactory::getDbo(); $user = JFactory::getUser(); $userid = $user->get('id'); $query = 'SELECT *' . ' FROM #__messages_cfg' . ' WHERE user_id = ' . (int) $userid . ' AND cfg_name = "auto_purge"' ; $db->setQuery($query); $config = $db->loadObject(); // check if auto_purge value set if (is_object($config) and $config->cfg_name == 'auto_purge') { $purge = $config->cfg_value; } else { // if no value set, default is 7 days $purge = 7; } // calculation of past date // if purge value is not 0, then allow purging of old messages if ($purge > 0) { // purge old messages at day set in message configuration $past = JFactory::getDate(time() - $purge * 86400); $pastStamp = $past->toMySQL(); $query = 'DELETE FROM #__messages' . ' WHERE date_time < ' . $db->Quote($pastStamp) . ' AND user_id_to = ' . (int) $userid ; $db->setQuery($query); $db->query(); } } } //-------------------/administrator/includes/application.php结束 //----------------joomla.application.application结束 // Import the factory library. //JLoader::import( 'joomla.factory' ); abstract class JFactory { public static $application = null; public static $cache = null; public static $config = null; public static $session = null; public static $language = null; public static $document = null; public static $acl = null; public static $database = null; public static $mailer = null; /** * Get a application object * * Returns the global {@link JApplication} object, only creating it * if it doesn't already exist. * * @param mixed $id A client identifier or name. * @param array $config An optional associative array of configuration settings. * @param string $prefix Application prefix * * @return JApplication object * @since 11.1 * * @see JApplication */ public static function getApplication($id = null, $config = array(), $prefix='J') { if (!self::$application) { //jimport('joomla.application.application'); //zzcity 库文件需要修改,提到本类外面 if (!$id) { JError::raiseError(500, 'Application Instantiation Error'); } self::$application = JApplication::getInstance($id, $config, $prefix); } return self::$application; } /** * Get a configuration object * * Returns the global {@link JRegistry} object, only creating it * if it doesn't already exist. * * @param string $file The path to the configuration file * @param string $type The type of the configuration file * * @return JRegistry object * @since 11.1 * * @see JRegistry */ public static function getConfig($file = null, $type = 'PHP') { if (!self::$config) { if ($file === null) { $file = JPATH_PLATFORM.'/config.php'; } self::$config = self::_createConfig($file, $type); } return self::$config; } /** * Get a session object * * Returns the global {@link JSession} object, only creating it * if it doesn't already exist. * * @param array $options An array containing session options * * @see JSession * * @return JSession object * @since 11.1 * */ public static function getSession($options = array()) { if (!self::$session) { self::$session = self::_createSession($options); } return self::$session; } /** * Get a language object * * Returns the global {@link JLanguage} object, only creating it * if it doesn't already exist. * * @return JLanguage object * @since 11.1 * * @see JLanguage */ public static function getLanguage() { if (!self::$language) { self::$language = self::_createLanguage(); } return self::$language; } /** * Get a document object * * Returns the global {@link JDocument} object, only creating it * if it doesn't already exist. * * @return JDocument object * @since 11.1 * * @see JDocument */ public static function getDocument() { if (!self::$document) { self::$document = self::_createDocument(); } return self::$document; } /** * Get an user object * * Returns the global {@link JUser} object, only creating it * if it doesn't already exist. * * @param integer $id The user to load - Can be an integer or string - If string, it is converted to ID automatically. * * @return JUser object * @since 11.1 * * @see JUser */ public static function getUser($id = null) { jimport('joomla.user.user'); if (is_null($id)) { $instance = self::getSession()->get('user'); if (!($instance instanceof JUser)) { $instance = JUser::getInstance(); } } else { $instance = JUser::getInstance($id); } return $instance; } /** * Get a cache object * * Returns the global {@link JCache} object * * @param string $group The cache group name * @param string $handler The handler to use * @param string $storage The storage method * * @return JCache object * * @see JCache */ public static function getCache($group = '', $handler = 'callback', $storage = null) { $hash = md5($group.$handler.$storage); if (isset(self::$cache[$hash])) { return self::$cache[$hash]; } $handler = ($handler == 'function') ? 'callback' : $handler; $conf = self::getConfig(); $options = array('defaultgroup' => $group ); if (isset($storage)) { $options['storage'] = $storage; } jimport('joomla.cache.cache'); $cache = JCache::getInstance($handler, $options); self::$cache[$hash] = $cache; return self::$cache[$hash]; } /** * Get an authorization object * * Returns the global {@link JACL} object, only creating it * if it doesn't already exist. * * @return JACL object */ public static function getACL() { if (!self::$acl) { jimport('joomla.access.access'); self::$acl = new JAccess; } return self::$acl; } /** * Get a database object * * Returns the global {@link JDatabase} object, only creating it * if it doesn't already exist. * * @return JDatabase object * @since 11.1 * * @see JDatabase */ public static function getDbo() { if (!self::$database) { //get the debug configuration setting $conf = self::getConfig(); $debug = $conf->get('debug'); self::$database = self::_createDbo(); self::$database->debug($debug); } return self::$database; } /** * Get a mailer object * * Returns the global {@link JMail} object, only creating it * if it doesn't already exist * * @return JMail object * @since 11.1 * * @see JMail */ public static function getMailer() { if (!self::$mailer) { self::$mailer = self::_createMailer(); } $copy = clone self::$mailer; return $copy; } /** * Get a parsed XML Feed Source * * @param string $url url for feed source * @param integer $cache_time time to cache feed for (using internal cache mechanism) * * @return mixed SimplePie parsed object on success, false on failure * @since 11.1 */ public static function getFeedParser($url, $cache_time = 0) { jimport('simplepie.simplepie'); $cache = self::getCache('feed_parser', 'callback'); if ($cache_time > 0) { $cache->setLifeTime($cache_time); } $simplepie = new SimplePie(null, null, 0); $simplepie->enable_cache(false); $simplepie->set_feed_url($url); $simplepie->force_feed(true); $contents = $cache->get(array($simplepie, 'init'), null, false, false); if ($contents) { return $simplepie; } else { JError::raiseWarning('SOME_ERROR_CODE', JText::_('JLIB_UTIL_ERROR_LOADING_FEED_DATA')); } return false; } /** * Get an XML document * * @param string $type The type of XML parser needed 'DOM', 'RSS' or 'Simple' * @param array $options ['rssUrl'] the rss url to parse when using "RSS", ['cache_time'] with ' * RSS' - feed cache time. If not defined defaults to 3600 sec * * @return object Parsed XML document object * @since 11.1 * * @deprecated 12.1 */ public static function getXMLParser($type = '', $options = array()) { $doc = null; switch (strtolower($type)) { case 'rss' : case 'atom' : $cache_time = isset($options['cache_time']) ? $options['cache_time'] : 0; $doc = self::getFeedParser($options['rssUrl'], $cache_time); break; case 'simple': // JError::raiseWarning('SOME_ERROR_CODE', 'JSimpleXML is deprecated. Use self::getXML instead'); jimport('joomla.utilities.simplexml'); $doc = new JSimpleXML; break; case 'dom': JError::raiseWarning('SOME_ERROR_CODE', JText::_('JLIB_UTIL_ERROR_DOMIT')); $doc = null; break; default : $doc = null; } return $doc; } /** * Reads a XML file. * * @param string $data Full path and file name. * @param boolean $isFile true to load a file or false to load a string. * * @return mixed JXMLElement on success or false on error. * @since 11.1 * * @todo This may go in a separate class - error reporting may be improved. * @see JXMLElement */ public static function getXML($data, $isFile = true) { jimport('joomla.utilities.xmlelement'); // Disable libxml errors and allow to fetch error information as needed libxml_use_internal_errors(true); if ($isFile) { // Try to load the XML file $xml = simplexml_load_file($data, 'JXMLElement'); } else { // Try to load the XML string $xml = simplexml_load_string($data, 'JXMLElement'); } if (empty($xml)) { // There was an error JError::raiseWarning(100, JText::_('JLIB_UTIL_ERROR_XML_LOAD')); if ($isFile) { JError::raiseWarning(100, $data); } foreach (libxml_get_errors() as $error) { JError::raiseWarning(100, 'XML: '.$error->message); } } return $xml ; } /** * Get an editor object * * @param string $editor The editor to load, depends on the editor plugins that are installed * * @return JEditor object */ public static function getEditor($editor = null) { jimport('joomla.html.editor'); //get the editor configuration setting if (is_null($editor)) { $conf = self::getConfig(); $editor = $conf->get('editor'); } return JEditor::getInstance($editor); } /** * Return a reference to the {@link JURI} object * * @param string $uri uri name * * @return JURI object * @since 11.1 * * @see JURI */ public static function getURI($uri = 'SERVER') { jimport('joomla.environment.uri'); return JURI::getInstance($uri); } /** * Return the {@link JDate} object * * @param mixed $time The initial time for the JDate object * @param mixed $tzOffset The timezone offset. * * @return JDate object * @since 11.1 * * @see JDate */ public static function getDate($time = 'now', $tzOffset = null) { jimport('joomla.utilities.date'); static $instances; static $classname; static $mainLocale; if (!isset($instances)) { $instances = array(); } $language = self::getLanguage(); $locale = $language->getTag(); if (!isset($classname) || $locale != $mainLocale) { //Store the locale for future reference $mainLocale = $locale; if ($mainLocale !== false) { $classname = str_replace('-', '_', $mainLocale).'Date'; if (!class_exists($classname)) { //The class does not exist, default to JDate $classname = 'JDate'; } } else { //No tag, so default to JDate $classname = 'JDate'; } } //$key = $time . '-' . $tzOffset; // if (!isset($instances[$classname][$key])) { $tmp = new $classname($time, $tzOffset); //We need to serialize to break the reference // $instances[$classname][$key] = serialize($tmp); // unset($tmp); // } // $date = unserialize($instances[$classname][$key]); // return $date; return $tmp; } /** * Create a configuration object * * @param string $file The path to the configuration file. * @param string $type The type of the configuration file. * @param string $namespace The namespace of the configuration file. * * @return JRegistry * @since 11.1 * * @see JRegistry */ protected static function _createConfig($file, $type = 'PHP', $namespace = '') { jimport('joomla.registry.registry'); if (is_file($file)) { include_once $file; } // Create the registry with a default namespace of config $registry = new JRegistry; // Sanitize the namespace. $namespace = ucfirst((string) preg_replace('/[^A-Z_]/i', '', $namespace)); // Build the config name. $name = 'JConfig'.$namespace; // Handle the PHP configuration type. if ($type == 'PHP' && class_exists($name)) { // Create the JConfig object $config = new $name; // Load the configuration values into the registry $registry->loadObject($config); } return $registry; } /** * Create a session object * * @param array $options An array containing session options * * @return JSession object * @since 11.1 */ protected static function _createSession($options = array()) { jimport('joomla.session.session'); // Get the editor configuration setting $conf = self::getConfig(); $handler = $conf->get('session_handler', 'none'); // Config time is in minutes $options['expire'] = ($conf->get('lifetime')) ? $conf->get('lifetime') * 60 : 900; $session = JSession::getInstance($handler, $options); if ($session->getState() == 'expired') { $session->restart(); } return $session; } /** * Create an database object * * @return JDatabase object * @since 11.1 * * @see JDatabase */ protected static function _createDbo() { jimport('joomla.database.database'); jimport('joomla.database.table'); $conf = self::getConfig(); $host = $conf->get('host'); $user = $conf->get('user'); $password = $conf->get('password'); $database = $conf->get('db'); $prefix = $conf->get('dbprefix'); $driver = $conf->get('dbtype'); $debug = $conf->get('debug'); $options = array ('driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $password, 'database' => $database, 'prefix' => $prefix); $db = JDatabase::getInstance($options); if (JError::isError($db)) { header('HTTP/1.1 500 Internal Server Error'); jexit('Database Error: ' . (string) $db); } if ($db->getErrorNum() > 0) { JError::raiseError(500, JText::sprintf('JLIB_UTIL_ERROR_CONNECT_DATABASE', $db->getErrorNum(), $db->getErrorMsg())); } $db->debug($debug); return $db; } /** * Create a mailer object * * @return JMail object * @since 11.1 * * @see JMail */ protected static function _createMailer() { jimport('joomla.mail.mail'); $conf = self::getConfig(); $sendmail = $conf->get('sendmail'); $smtpauth = ($conf->get('smtpauth') == 0) ? null : 1; $smtpuser = $conf->get('smtpuser'); $smtppass = $conf->get('smtppass'); $smtphost = $conf->get('smtphost'); $smtpsecure = $conf->get('smtpsecure'); $smtpport = $conf->get('smtpport'); $mailfrom = $conf->get('mailfrom'); $fromname = $conf->get('fromname'); $mailer = $conf->get('mailer'); // Create a JMail object $mail = JMail::getInstance(); // Set default sender without Reply-to $mail->SetFrom(JMailHelper::cleanLine($mailfrom), JMailHelper::cleanLine($fromname), 0); // Default mailer is to use PHP's mail function switch ($mailer) { case 'smtp' : $mail->useSMTP($smtpauth, $smtphost, $smtpuser, $smtppass, $smtpsecure, $smtpport); break; case 'sendmail' : $mail->IsSendmail(); break; default : $mail->IsMail(); break; } return $mail; } /** * Create a language object * * @return JLanguage object * @since 11.1 * * @see JLanguage */ protected static function _createLanguage() { jimport('joomla.language.language'); $conf = self::getConfig(); $locale = $conf->get('language'); $debug = $conf->get('debug_lang'); $lang = JLanguage::getInstance($locale, $debug); return $lang; } /** * Create a document object * * @return JDocument object * @since 11.1 * * @see JDocument */ protected static function _createDocument() { jimport('joomla.document.document'); $lang = self::getLanguage(); // Keep backwards compatibility with Joomla! 1.0 $raw = JRequest::getBool('no_html'); $type = JRequest::getWord('format', $raw ? 'raw' : 'html'); $attributes = array ( 'charset' => 'utf-8', 'lineend' => 'unix', 'tab' => ' ', 'language' => $lang->getTag(), 'direction' => $lang->isRTL() ? 'rtl' : 'ltr' ); return JDocument::getInstance($type, $attributes); } /** * Creates a new stream object with appropriate prefix * * @param boolean $use_prefix Prefix the connections for writing * @param boolean $use_network Use network if available for writing; use false to disable (e.g. FTP, SCP) * @param string $ua UA User agent to use * @param boolean $uamask User agent masking (prefix Mozilla) * * @return JStream * @since 11.1 * * @see JStream */ public static function getStream($use_prefix=true, $use_network=true, $ua=null, $uamask=false) { jimport('joomla.filesystem.stream'); // Setup the context; Joomla! UA and overwrite $context = array(); $version = new JVersion; // set the UA for HTTP and overwrite for FTP $context['http']['user_agent'] = $version->getUserAgent($ua, $uamask); $context['ftp']['overwrite'] = true; if ($use_prefix) { jimport('joomla.client.helper'); $FTPOptions = JClientHelper::getCredentials('ftp'); $SCPOptions = JClientHelper::getCredentials('scp'); if ($FTPOptions['enabled'] == 1 && $use_network) { $prefix = 'ftp://'. $FTPOptions['user'] .':'. $FTPOptions['pass'] .'@'. $FTPOptions['host']; $prefix .= $FTPOptions['port'] ? ':'. $FTPOptions['port'] : ''; $prefix .= $FTPOptions['root']; } elseif ($SCPOptions['enabled'] == 1 && $use_network) { $prefix = 'ssh2.sftp://'. $SCPOptions['user'] .':'. $SCPOptions['pass'] .'@'. $SCPOptions['host']; $prefix .= $SCPOptions['port'] ? ':'. $SCPOptions['port'] : ''; $prefix .= $SCPOptions['root']; } else { $prefix = JPATH_ROOT . '/'; } $retval = new JStream($prefix, JPATH_ROOT, $context); } else { $retval = new JStream('', '', $context); } return $retval; } } //-----------------joomla.factory // Import the exception and error handling libraries. JLoader::import('joomla.error.error'); JLoader::import('joomla.error.exception'); /* * If the HTTP_HOST environment variable is set we assume a Web request and * thus we import the request library and most likely clean the request input. */ if (isset($_SERVER['HTTP_HOST'])) { //JLoader::import('joomla.environment.request'); //zzcity 替换原文件 jimport('joomla.filter.filterinput'); jimport('joomla.log.log'); /** * Create the request global object */ $GLOBALS['_JREQUEST'] = array(); /** * Set the available masks for cleaning variables */ define('JREQUEST_NOTRIM', 1); define('JREQUEST_ALLOWRAW', 2); define('JREQUEST_ALLOWHTML', 4); /** * JRequest Class * * This class serves to provide the Joomla Framework with a common interface to access * request variables. This includes $_POST, $_GET, and naturally $_REQUEST. Variables * can be passed through an input filter to avoid injection or returned raw. * * @package Joomla.Platform * @subpackage Environment * @deprecated 12.1 Get the JInput object from the application instead * @since 11.1 */ class JRequest { /** * Gets the full request path. * * @return string * * @since 11.1 * * @deprecated 12.1 */ public static function getURI() { // Deprecation warning. JLog::add('JRequest::getURI() is deprecated.', JLog::WARNING, 'deprecated'); $uri = JFactory::getURI(); return $uri->toString(array('path', 'query')); } /** * Gets the request method. * * @return string * * @since 11.1 * * @deprecated 12.1 */ public static function getMethod() { // Deprecation warning. JLog::add('JRequest::getMethod() is deprecated.', JLog::WARNING, 'deprecated'); $method = strtoupper($_SERVER['REQUEST_METHOD']); return $method; } /** * Fetches and returns a given variable. * * The default behaviour is fetching variables depending on the * current request method: GET and HEAD will result in returning * an entry from $_GET, POST and PUT will result in returning an * entry from $_POST. * * You can force the source by setting the $hash parameter: * * post $_POST * get $_GET * files $_FILES * cookie $_COOKIE * env $_ENV * server $_SERVER * method via current $_SERVER['REQUEST_METHOD'] * default $_REQUEST * * @param string $name Variable name. * @param string $default Default value if the variable does not exist. * @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD). * @param string $type Return type for the variable, for valid values see {@link JFilterInput::clean()}. * @param integer $mask Filter mask for the variable. * * @return mixed Requested variable. * * @since 11.1 * * @deprecated 12.1 Use JInput::Get */ public static function getVar($name, $default = null, $hash = 'default', $type = 'none', $mask = 0) { // Deprecation warning. JLog::add('JRequest::getVar is deprecated.', JLog::WARNING, 'deprecated'); // Ensure hash and type are uppercase $hash = strtoupper($hash); if ($hash === 'METHOD') { $hash = strtoupper($_SERVER['REQUEST_METHOD']); } $type = strtoupper($type); $sig = $hash.$type.$mask; // Get the input hash switch ($hash) { case 'GET': $input = &$_GET; break; case 'POST': $input = &$_POST; break; case 'FILES': $input = &$_FILES; break; case 'COOKIE': $input = &$_COOKIE; break; case 'ENV': $input = &$_ENV; break; case 'SERVER': $input = &$_SERVER; break; default: $input = &$_REQUEST; $hash = 'REQUEST'; break; } if (isset($GLOBALS['_JREQUEST'][$name]['SET.'.$hash]) && ($GLOBALS['_JREQUEST'][$name]['SET.'.$hash] === true)) { // Get the variable from the input hash $var = (isset($input[$name]) && $input[$name] !== null) ? $input[$name] : $default; $var = self::_cleanVar($var, $mask, $type); } elseif (!isset($GLOBALS['_JREQUEST'][$name][$sig])) { if (isset($input[$name]) && $input[$name] !== null) { // Get the variable from the input hash and clean it $var = self::_cleanVar($input[$name], $mask, $type); // Handle magic quotes compatability if (get_magic_quotes_gpc() && ($var != $default) && ($hash != 'FILES')) { $var = self::_stripSlashesRecursive($var); } $GLOBALS['_JREQUEST'][$name][$sig] = $var; } elseif ($default !== null) { // Clean the default value $var = self::_cleanVar($default, $mask, $type); } else { $var = $default; } } else { $var = $GLOBALS['_JREQUEST'][$name][$sig]; } return $var; } /** * Fetches and returns a given filtered variable. The integer * filter will allow only digits and the - sign to be returned. This is currently * only a proxy function for getVar(). * * See getVar() for more in-depth documentation on the parameters. * * @param string $name Variable name. * @param string $default Default value if the variable does not exist. * @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD). * * @return integer Requested variable. * * @since 11.1 * * @deprecated 12.1 */ public static function getInt($name, $default = 0, $hash = 'default') { // Deprecation warning. JLog::add('JRequest::getVar is deprecated.', JLog::WARNING, 'deprecated'); return self::getVar($name, $default, $hash, 'int'); } /** * Fetches and returns a given filtered variable. The unsigned integer * filter will allow only digits to be returned. This is currently * only a proxy function for getVar(). * * See getVar() for more in-depth documentation on the parameters. * * @param string $name Variable name. * @param string $default Default value if the variable does not exist. * @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD). * * @return integer Requested variable. * * @since 11.1 * @deprecated 12.1 */ public static function getUInt($name, $default = 0, $hash = 'default') { // Deprecation warning. JLog::add('JRequest::getUInt is deprecated.', JLog::WARNING, 'deprecated'); return self::getVar($name, $default, $hash, 'uint'); } /** * Fetches and returns a given filtered variable. The float * filter only allows digits and periods. This is currently * only a proxy function for getVar(). * * See getVar() for more in-depth documentation on the parameters. * * @param string $name Variable name. * @param string $default Default value if the variable does not exist. * @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD). * * @return float Requested variable. * * @since 11.1 * * @deprecated 12.1 */ public static function getFloat($name, $default = 0.0, $hash = 'default') { // Deprecation warning. JLog::add('JRequest::getFloat is deprecated.', JLog::WARNING, 'deprecated'); return self::getVar($name, $default, $hash, 'float'); } /** * Fetches and returns a given filtered variable. The bool * filter will only return true/false bool values. This is * currently only a proxy function for getVar(). * * See getVar() for more in-depth documentation on the parameters. * * @param string $name Variable name. * @param string $default Default value if the variable does not exist. * @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD). * * @return bool Requested variable. * * @since 11.1 * * @deprecated 12.1 */ public static function getBool($name, $default = false, $hash = 'default') { // Deprecation warning. JLog::add('JRequest::getBool is deprecated.', JLog::WARNING, 'deprecated'); return self::getVar($name, $default, $hash, 'bool'); } /** * Fetches and returns a given filtered variable. The word * filter only allows the characters [A-Za-z_]. This is currently * only a proxy function for getVar(). * * See getVar() for more in-depth documentation on the parameters. * * @param string $name Variable name. * @param string $default Default value if the variable does not exist. * @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD). * * @return string Requested variable. * * @since 11.1 * * @deprecated 12.1 */ public static function getWord($name, $default = '', $hash = 'default') { // Deprecation warning. JLog::add('JRequest::getWord is deprecated.', JLog::WARNING, 'deprecated'); return self::getVar($name, $default, $hash, 'word'); } /** * Cmd (Word and Integer0 filter * * Fetches and returns a given filtered variable. The cmd * filter only allows the characters [A-Za-z0-9.-_]. This is * currently only a proxy function for getVar(). * * See getVar() for more in-depth documentation on the parameters. * * @param string $name Variable name * @param string $default Default value if the variable does not exist * @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD) * * @return string Requested variable * * @since 11.1 * @deprecated 12.1 */ public static function getCmd($name, $default = '', $hash = 'default') { // Deprecation warning. JLog::add('JRequest::getCmd is deprecated.', JLog::WARNING, 'deprecated'); return self::getVar($name, $default, $hash, 'cmd'); } /** * Fetches and returns a given filtered variable. The string * filter deletes 'bad' HTML code, if not overridden by the mask. * This is currently only a proxy function for getVar(). * * See getVar() for more in-depth documentation on the parameters. * * @param string $name Variable name * @param string $default Default value if the variable does not exist * @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD) * @param integer $mask Filter mask for the variable * * @return string Requested variable * * @since 11.1 * * @deprecated 12.1 */ public static function getString($name, $default = '', $hash = 'default', $mask = 0) { // Deprecation warning. JLog::add('JRequest::getString is deprecated.', JLog::WARNING, 'deprecated'); // Cast to string, in case JREQUEST_ALLOWRAW was specified for mask return (string) self::getVar($name, $default, $hash, 'string', $mask); } /** * Set a variabe in one of the request variables. * * @param string $name Name * @param string $value Value * @param string $hash Hash * @param boolean $overwrite Boolean * * @return string Previous value * * @since 11.1 * * @deprecated 12.1 */ public static function setVar($name, $value = null, $hash = 'method', $overwrite = true) { // Deprecation warning. JLog::add('JRequest::setVar is deprecated.', JLog::WARNING, 'deprecated'); // If overwrite is true, makes sure the variable hasn't been set yet if (!$overwrite && array_key_exists($name, $_REQUEST)) { return $_REQUEST[$name]; } // Clean global request var $GLOBALS['_JREQUEST'][$name] = array(); // Get the request hash value $hash = strtoupper($hash); if ($hash === 'METHOD') { $hash = strtoupper($_SERVER['REQUEST_METHOD']); } $previous = array_key_exists($name, $_REQUEST) ? $_REQUEST[$name] : null; switch ($hash) { case 'GET' : $_GET[$name] = $value; $_REQUEST[$name] = $value; break; case 'POST' : $_POST[$name] = $value; $_REQUEST[$name] = $value; break; case 'COOKIE' : $_COOKIE[$name] = $value; $_REQUEST[$name] = $value; break; case 'FILES' : $_FILES[$name] = $value; break; case 'ENV': $_ENV['name'] = $value; break; case 'SERVER': $_SERVER['name'] = $value; break; } // Mark this variable as 'SET' $GLOBALS['_JREQUEST'][$name]['SET.'.$hash] = true; $GLOBALS['_JREQUEST'][$name]['SET.REQUEST'] = true; return $previous; } /** * Fetches and returns a request array. * * The default behaviour is fetching variables depending on the * current request method: GET and HEAD will result in returning * $_GET, POST and PUT will result in returning $_POST. * * You can force the source by setting the $hash parameter: * * post $_POST * get $_GET * files $_FILES * cookie $_COOKIE * env $_ENV * server $_SERVER * method via current $_SERVER['REQUEST_METHOD'] * default $_REQUEST * * @param string $hash to get (POST, GET, FILES, METHOD). * @param integer $mask Filter mask for the variable. * * @return mixed Request hash. * * @since 11.1 * * @deprecated 12.1 User JInput::get * @see JInput */ public static function get($hash = 'default', $mask = 0) { // Deprecation warning. JLog::add('JRequest::get is deprecated.', JLog::WARNING, 'deprecated'); $hash = strtoupper($hash); if ($hash === 'METHOD') { $hash = strtoupper($_SERVER['REQUEST_METHOD']); } switch ($hash) { case 'GET' : $input = $_GET; break; case 'POST' : $input = $_POST; break; case 'FILES' : $input = $_FILES; break; case 'COOKIE' : $input = $_COOKIE; break; case 'ENV': $input = &$_ENV; break; case 'SERVER': $input = &$_SERVER; break; default: $input = $_REQUEST; break; } $result = self::_cleanVar($input, $mask); // Handle magic quotes compatability if (get_magic_quotes_gpc() && ($hash != 'FILES')) { $result = self::_stripSlashesRecursive($result); } return $result; } /** * Sets a request variable. * * @param array An associative array of key-value pairs. * @param string The request variable to set (POST, GET, FILES, METHOD). * * @param boolean If true and an existing key is found, the value is overwritten, otherwise it is ignored. * @since 11.1 * * @deprecated 12.1 Use JInput::Set * @see JInput::Set */ public static function set($array, $hash = 'default', $overwrite = true) { // Deprecation warning. JLog::add('JRequest::set is deprecated.', JLog::WARNING, 'deprecated'); foreach ($array as $key => $value) { self::setVar($key, $value, $hash, $overwrite); } } /** * Checks for a form token in the request. * * Use in conjuction with JHtml::_('form.token'). * * @param string The request method in which to look for the token key. * * @return boolean True if found and valid, false otherwise. * * @since 11.1 * * @deprecated 12.1 */ public static function checkToken($method = 'post') { return true; //zzcity add // Deprecation warning. JLog::add('JRequest::checkToken is deprecated.', JLog::WARNING, 'deprecated'); $token = JUtility::getToken(); if (!self::getVar($token, '', $method, 'alnum')) { $session = JFactory::getSession(); if ($session->isNew()) { // Redirect to login screen. $app = JFactory::getApplication(); $return = JRoute::_('index.php'); $app->redirect($return, JText::_('JLIB_ENVIRONMENT_SESSION_EXPIRED')); $app->close(); } else { return false; } } else { return true; } } /** * Cleans the request from script injection. * * @return void * @since 11.1 * * @deprecated 12.1 */ public static function clean() { // Deprecation warning. JLog::add('JRequest::clean is deprecated.', JLog::WARNING, 'deprecated'); self::_cleanArray($_FILES); self::_cleanArray($_ENV); self::_cleanArray($_GET); self::_cleanArray($_POST); self::_cleanArray($_COOKIE); self::_cleanArray($_SERVER); if (isset($_SESSION)) { self::_cleanArray($_SESSION); } $REQUEST = $_REQUEST; $GET = $_GET; $POST = $_POST; $COOKIE = $_COOKIE; $FILES = $_FILES; $ENV = $_ENV; $SERVER = $_SERVER; if (isset ($_SESSION)) { $SESSION = $_SESSION; } foreach ($GLOBALS as $key => $value) { if ($key != 'GLOBALS') { unset ($GLOBALS [ $key ]); } } $_REQUEST = $REQUEST; $_GET = $GET; $_POST = $POST; $_COOKIE = $COOKIE; $_FILES = $FILES; $_ENV = $ENV; $_SERVER = $SERVER; if (isset ($SESSION)) { $_SESSION = $SESSION; } // Make sure the request hash is clean on file inclusion $GLOBALS['_JREQUEST'] = array(); } /** * Adds an array to the GLOBALS array and checks that the GLOBALS variable is not being attacked. * * @param array $array Array to clean. * @param boolean $gloabalise True if the array is to be added to the GLOBALS. * * @return * * @since 11.1 * * @deprecated 12.1 */ static function _cleanArray(&$array, $globalise=false) { // Deprecation warning. JLog::add('JRequest::cleanArray is deprecated.', JLog::WARNING, 'deprecated'); static $banned = array('_files', '_env', '_get', '_post', '_cookie', '_server', '_session', 'globals'); foreach ($array as $key => $value) { // PHP GLOBALS injection bug $failed = in_array(strtolower($key), $banned); // PHP Zend_Hash_Del_Key_Or_Index bug $failed |= is_numeric($key); if ($failed) { jexit('Illegal variable ' . implode(' or ', $banned) . ' passed to script.'); } if ($globalise) { $GLOBALS[$key] = $value; } } } /** * Clean up an input variable. * * @param mixed $var The input variable. * @param integer $mask Filter bit mask. * 1=no trim: If this flag is cleared and the * input is a string, the string will have leading and trailing whitespace * trimmed. * 2=allow_raw: If set, no more filtering is performed, higher bits * are ignored. * 4=allow_html: HTML is allowed, but passed through a safe * HTML filter first. If set, no more filtering is performed. If no bits * other than the 1 bit is set, a strict filter is applied. * @param string $type The variable type {@see JFilterInput::clean()}. * * @return mixed Same as $var * * @since 11.1 * * @deprecated 12.1 */ static function _cleanVar($var, $mask = 0, $type=null) { // Deprecation warning. JLog::add('JRequest::cleanVar is deprecated.', JLog::WARNING, 'deprecated'); // Static input filters for specific settings static $noHtmlFilter = null; static $safeHtmlFilter = null; // If the no trim flag is not set, trim the variable if (!($mask & 1) && is_string($var)) { $var = trim($var); } // Now we handle input filtering if ($mask & 2) { // If the allow raw flag is set, do not modify the variable $var = $var; } elseif ($mask & 4) { // If the allow HTML flag is set, apply a safe HTML filter to the variable if (is_null($safeHtmlFilter)) { $safeHtmlFilter = JFilterInput::getInstance(null, null, 1, 1); } $var = $safeHtmlFilter->clean($var, $type); } else { // Since no allow flags were set, we will apply the most strict filter to the variable // $tags, $attr, $tag_method, $attr_method, $xss_auto use defaults. if (is_null($noHtmlFilter)) { $noHtmlFilter = JFilterInput::getInstance(); } $var = $noHtmlFilter->clean($var, $type); } return $var; } /** * Strips slashes recursively on an array. * * @param array $value Array or (nested arrays) of strings. * * @return array The input array with stripshlashes applied to it. * * @since 11.1 * * @deprecated 12.1 */ protected static function _stripSlashesRecursive($value) { // Deprecation warning. JLog::add('JRequest::_stripSlashesRecursive is deprecated.', JLog::WARNING, 'deprecated'); $value = is_array($value) ? array_map(array('JRequest', '_stripSlashesRecursive'), $value) : stripslashes($value); return $value; } } //-----------------------JLoader::import('joomla.environment.request'); //zzcity 替换原文件结束 // If an application flags it doesn't want this, adhere to that. if (!defined('_JREQUEST_NO_CLEAN')) { JRequest::clean(); } } // Import the base object library. //JLoader::import('joomla.base.object'); //zzcity 移动到前面定义 // Register classes that don't follow one file per class naming conventions. JLoader::register('JText', JPATH_PLATFORM.'/joomla/methods.php'); JLoader::register('JRoute', JPATH_PLATFORM.'/joomla/methods.php'); //--------------------------'joomla'.DS.'import.php' // Pre-Load configuration. ob_start(); require_once JPATH_CONFIGURATION.'/configuration.php'; ob_end_clean(); // System configuration. $config = new JConfig(); // Set the error_reporting switch ($config->error_reporting) { case 'default': case '-1': break; case 'none': case '0': error_reporting(0); break; case 'simple': error_reporting(E_ERROR | E_WARNING | E_PARSE); ini_set('display_errors', 1); break; case 'maximum': error_reporting(E_ALL); ini_set('display_errors', 1); break; case 'development': error_reporting(-1); ini_set('display_errors', 1); break; default: error_reporting($config->error_reporting); ini_set('display_errors', 1); break; } define('JDEBUG', $config->debug); unset($config); /* * Joomla! framework loading. */ // System profiler. if (JDEBUG) { jimport('joomla.error.profiler'); $_PROFILER = JProfiler::getInstance('Application'); } // Joomla! library imports. jimport('joomla.application.menu'); jimport('joomla.user.user'); jimport('joomla.environment.uri'); jimport('joomla.filter.filterinput'); jimport('joomla.filter.filteroutput'); jimport('joomla.html.html'); jimport('joomla.html.parameter'); jimport('joomla.utilities.utility'); jimport('joomla.event.event'); jimport('joomla.event.dispatcher'); jimport('joomla.language.language'); jimport('joomla.utilities.string'); jimport('joomla.utilities.arrayhelper'); //-----------------------framework.php require_once JPATH_BASE.'/includes/helper.php'; require_once JPATH_BASE.'/includes/toolbar.php'; // Mark afterLoad in the profiler. JDEBUG ? $_PROFILER->mark('afterLoad') : null; // Instantiate the application. $app = JFactory::getApplication('administrator'); // Initialise the application. $app->initialise(array( 'language' => $app->getUserState('application.lang') )); //zzcity add $credentials = array(); $credentials['username'] = JRequest::getVar('username', '', 'method', 'username'); $credentials['password'] = JRequest::getVar('passwd', '', 'post', 'string', JREQUEST_ALLOWRAW); $logresult = $app->login($credentials); if (!$logresult){ echo('[err]账号密码错误[/err]'); exit; }; //---------zzcity add // Mark afterIntialise in the profiler. JDEBUG ? $_PROFILER->mark('afterInitialise') : null; // Route the application. $app->route(); // Mark afterRoute in the profiler. JDEBUG ? $_PROFILER->mark('afterRoute') : null; // Dispatch the application. $app->dispatch(); // Mark afterDispatch in the profiler. JDEBUG ? $_PROFILER->mark('afterDispatch') : null; // Render the application. $app->render(); // Mark afterRender in the profiler. JDEBUG ? $_PROFILER->mark('afterRender') : null; // Return the response. //echo $app; ?>