我们的网站上有一个独立的脚本,与Joomla 1.5安装相邻.我们使用Joomla身份验证来限制对脚本的访问.此时,我们将任何未经授权的用户重定向到Joomla站点以进行登录.但我们希望在我们的脚本中添加登录功能.有谁知道如何使用用户名/密码从外部脚本登录joomla?谢谢!
<?PHP //http://domain.com/script/script.PHP?username=username&passwd=password define( '_JEXEC',1 ); define('JPATH_BASE','../' ); define( 'DS',DIRECTORY_SEPARATOR ); require_once('../configuration.PHP'); require_once ( JPATH_BASE .DS.'includes'.DS.'defines.PHP' ); require_once ( JPATH_BASE .DS.'includes'.DS.'framework.PHP' ); require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'factory.PHP' ); /* Create the Application */ $mainframe =& JFactory::getApplication('site'); jimport('joomla.plugin.helper'); $credentials = array(); $credentials['username'] = JRequest::getVar('username','','method','username'); $credentials['password'] = JRequest::getVar('passwd','passwd'); //perform the login action $error = $mainframe->login($credentials); $user = JFactory::getUser(); //now you are logged in $mainframe->logout(); //now you are logged out