English 中文(简体)
如何在外部脚本中包含Joomla 2.5的JAuthentication类
原标题:How to include the JAuthentication class of Joomla 2.5 in external scripts

我想制作一个脚本,让用户登录Joomla,但在http://api.joomla.org/Joomla-Platform/User/JAuthentication.html一

问题回答

我遇到了一个类似的问题,有人要求我从外部自定义HTML表单登录Joomla 2.5网站。我是这件事的初学者,但我发现了一个非常有用的脚本,因为它按照我需要的方式工作(这个网站)。

我不使用JAuthentication类,而是使用JFactory::getApplication对象及其登录方法对Joomla:

<?
if(isset($_POST[ Submit ])){
    define( _JEXEC , 1 );
    define( DS , DIRECTORY_SEPARATOR);
    define( JPATH_BASE , dirname(__FILE__));

    require_once (JPATH_BASE .DS. includes .DS. defines.php  );
    require_once (JPATH_BASE .DS. includes .DS. framework.php  );
    $app =& JFactory::getApplication( site );
    $app->initialise();

    //echo "<br>";print_r($app);

    $credentials = array();
    $credentials[ username ] = $_POST[ username ];
    $credentials[ password ] = $_POST[ password ];

    //echo "<br>Login res: ".$app->login($credentials);

    if($app->login($credentials) == 1)
        header( location: http://www.johnabril.com/seguro_desmp );      
}
?>

如您所见,您只需从HTML表单中发送用户名和密码字符串,即可完成。

希望它能有所帮助。





相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Remotely authenticating client Windows user on demand

Suppose I am writing a server for a particular network protocol. If I know that the client is running on a Windows machine, is it possible for my server to authenticate the Windows user that owns the ...

Role/Permission based forms authorizing/authentication?

While looking into forms authorizing/authentication, I found that it is possible to do role based authorizing by adding an array of roles to a FormsAuthenticationTicket. That way I can write User....

热门标签