?
avatar cyberprashant
cyberprashant
27 Feb 2015

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
/**

  • @package Joomla.Site *
  • @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
  • @license GNU General Public License version 2 or later; see LICENSE.txt */

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!');
}

/**

  • Constant that is checked in included files to prevent direct access.
  • define() is used in the installation folder rather than "const" to not error for PHP 5.2 and lower

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

?>

avatar cyberprashant cyberprashant - open - 27 Feb 2015
avatar joomla-cms-bot joomla-cms-bot - change - 27 Feb 2015
Labels Added: ?
avatar zero-24 zero-24 - change - 27 Feb 2015
Category Libraries
avatar cyberprashant
cyberprashant - comment - 28 Feb 2015

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

 $credentials = array( 'username' => $username, 'password' => $password);
 $options=array( 'remember' => 'boolean' );
 $login_site =& JFactory::getApplication('site');
 $login_site->initialise();
 $login_site->login($credentials, $options);

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

avatar phproberto
phproberto - comment - 28 Feb 2015

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.

avatar cyberprashant
cyberprashant - comment - 1 Mar 2015

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

avatar cyberprashant
cyberprashant - comment - 3 Mar 2015

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);

avatar cyberprashant
cyberprashant - comment - 4 Mar 2015

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);


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6205.
avatar brianteeman
brianteeman - comment - 14 Mar 2015

Closing as you have resolved your issue

avatar brianteeman brianteeman - change - 14 Mar 2015
Status New Closed
Closed_Date 0000-00-00 00:00:00 2015-03-14 10:54:58
avatar brianteeman brianteeman - close - 14 Mar 2015

Add a Comment

Login with GitHub to post a comment