Skip to content

Instantly share code, notes, and snippets.

@progerio
Last active April 2, 2020 22:43
Show Gist options
  • Save progerio/ddfad29652ec63fda58e439c37c4ddd5 to your computer and use it in GitHub Desktop.
Save progerio/ddfad29652ec63fda58e439c37c4ddd5 to your computer and use it in GitHub Desktop.
Login externo no joomla framework
<?php
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');
$mainframe = JFactory::getApplication('site');
$mainframe->initialise();
$login = '<SeuLogin>';
$email = '<SeuEmail>';
function getUser($login, $email)
{
$db = JFactory::getDbo();
$query = $db
->getQuery(true)
->select('*')
->from($db->quoteName('#__users'))
->where($db->quoteName('username') . " = " . $db->quote($login))
->andWhere($db->quoteName('email') . " = " . $db->quote($email));
$db->setQuery($query);
return $db->loadObject();
}
$user = getUser($login, $email);
var_dump($user);
$credentials = array(
'username' => $user->username,
'password' => '<PASSWORD>'
);
$logged = $mainframe->login($credentials);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment