Friday 15 July 2011

php - How to log into joomla through an external script? -


There is a standalone script on our site that sits around a Joomla 1.5 installation. We are using Joomla authentication to restrict access to our scripts. At this time we are redirecting any unauthorized users to log in to the Joomla site. We want to add a login capability within our script, however. Does anyone know that using an username / password is to log in to Joomla from an external script? Thanks!

  & lt? Php // Http://domain.com/script/script.php?username=username&passwd=password Define ('_JEXEC', 1); Define ('JPATH_BASE', '../'); Define ('d', DIRECTORY_SEPARATOR); Require_once ('../configuration.php'); Need_once (JPATH_BASE .DD. 'Contains' DD. 'Defines.php'); Need_once (JPATH_BASE.DD. 'Included' .ds 'framework .php'); Need_once (JPATH_BASE .DD. 'Library'. D. 'Joomla' .des. 'Factor.php'); / * Create Application * / $ Mainframe = & amp; JFactory :: getApplication ('site'); Jimport ('joomla.plugin.helper'); $ Credentials = array (); $ Credentials ['usernames'] = jrevieve :: getVar ('username', '', 'method', 'username'); $ Credentials ['password'] = jrevieve :: getVar ('passwd', '', 'method', 'passwood'); // log in action $ error = $ mainframe- & gt; Login ($ credentials); $ User = JFactory :: getUser (); // Now you have $ mainframe-> Logout () are logged in; // You are now logged out    

No comments:

Post a Comment