Hello, after joomla 3.4 an external login script that is cruicial to my site is no longer working. External login is used as I have a number of custom php pages outside of Joomla that are using shared login credentials.
Error I get:
Fatal error: Call to undefined function Composer\Autoload\includeFile() in /home4/chiefres/public_html/cms/libraries/ClassLoader.php on line 43
Code producing error below - any ideas on what is going on? I tried a full install (this was an upgrade from 3.3 originally) and that didn't help either. Cleared caches etc no help.
this code is located in the root of the site and joomla is in the cms subdirectory.
<?php
/**
if (version_compare(PHP_VERSION, '5.3.1', '<'))
{
die('Your host needs to use PHP 5.3.1 or higher to run this version of Joomla!');
}
/**
define('_JEXEC', 1);
if (file_exists(DIR . '/cms/defines.php'))
{
include_once DIR . '/cms/defines.php';
}
if (!defined('JDEFINES'))
{
//define('JPATH_BASE', __DIR_);
define('JPATH_BASE', "./cms");
require_once JPATH_BASE . '/includes/defines.php';
}
require_once JPATH_BASE . '/includes/framework.php';
// Mark afterLoad in the profiler.
JDEBUG ? $_PROFILER->mark('afterLoad') : null;
// Instantiate the application.
$app = JFactory::getApplication('site');
// Initialise the application.
$app->initialise();
//echo($username);
//echo($password);
$credentials = array( 'username' => $username, 'password' => $password);
$options=array( 'remember' => boolean );
$login_site =& JFactory::getApplication('site');
$login_site->login($credentials, $options);
// $app->redirect("xxxxxxxxxxxxxxxxxxxxxxxxx"); // you can redirect anywhere
?>
Labels |
Added:
?
|
Category | ⇒ | Libraries |
This:
$options=array( 'remember' => 'boolean' );
Should use a boolean value (true or false) not the string 'boolean'. For example:
$options = array('remember' => false);
This:
$login_site =& JFactory::getApplication('site');
Should be:
$login_site = JFactory::getApplication('site');
And finally about the error I guess your user has an empty password in the database? The error is caused when trying to get the first char of the password stored in the database:
elseif ($hash[0] == '$')
So I guess someone managed to save an empty password.
so in my setup I'm using phpbb3auth plugin to authenticate against phpbb. so maybe that's why I get the empty password error not sure.
I even added an echo statement - and there is a password being passed (a hash) and that is not blank so not sure why then the error. Didn't have the problem in Joomla 3.3.6 so this is not a password issue but there is some subtle change to the API
in any case I got it working (able to login now) using the following code:
// Instantiate the application.
$app = JFactory::getApplication('site');
// Initialise the application.
$app->initialise();
JPluginHelper::importPlugin('user');
$options = array();
$options['action'] = 'core.login.site';
$options['remember'] = boolean ;
$response->username = new stdClass;
$response->username = $username;
$result = $app->triggerEvent('onUserLogin', array((array)$response, $options));
But I still can't get remember me option to work - not sure if this API call even supports it. tried using TRUE instead of the word boolean or 'boolean' and didnt work
regarding this below
elseif ($hash[0] == '$')
So I guess someone managed to save an empty password.
it works if I hardcode test with the actual plaintext password but not the hash. The external database has the password stored as a hash and this worked up til 3.3.6. Is there some way to signify a hash is being passed?
$credentials = array( 'username' => $username, 'password' => $password);
$options=array( 'remember' => 'boolean' );
$login_site =& JFactory::getApplication('site');
$login_site->initialise();
$login_site->login($credentials, $options);
i was able to get remember me working by following tips at this site to fix session.cookie lifetime on the server settings: http://forum.joomla.org/viewtopic.php?f=470&t=457307&start=30
added following to index.php in joomla - hopefully helps others out.
ini_set('session.cookie_lifetime', 5366060);
Closing as you have resolved your issue
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2015-03-14 10:54:58 |
found that the problem was I was trying to login to phpbb and joomla in the same script. Worked until 3.4 joomla. Apparently phpbb common.php has something that causes the fatal classloader.php error. Removing the phpbb include for common.php solved the error.
Still having trouble completing login to joomla this code snip doesn't work anymore
and instead now gives:
Notice: Uninitialized string offset: 0 in /cms/libraries/joomla/user/helper.php on line 341
Can someone post an example of working external login code for 3.4