How to call for connections data

Status
Not open for further replies.

jfquestiaux

Well-Known Member
I'm writing a Fabrik plugin for JSitemap Pro, to create XML sitemaps with records in Fabrik lists.

It's working fine for the default connection, but I need to add a feature to accomodate the case where the records come from another database than the default J! one. Getting these data is not a problem, except that the password is encrypted!

So I tried to use Fabrik itself to provide the data: I tried this:

include_once(JPATH_SITE . '/components/com_fabrik/models/connection.php');
$fabrikDb = new FabrikFEModelConnection;
$fabrikDb->getConnection($id);

but it crashes the system! Huge memory leak. So I'm stuck and don't know what else to try. Any idea?
 
You could just decrypt the passwords yourself. In 3.x we use the (deprecated) SimpleCrypt, with the site secret as the salt, so something like ...

Code:
// assumes encrypted password is in $password
jimport('joomla.crypt.crypt');
jimport('joomla.crypt.key');
$config = JFactory::getConfig();
$secret = $config->get('secret', '');
$key = new JCryptKey('simple', $secret, $secret);
$crypt = new JCrypt(new JCryptCipherSimple, $key);
$cleartext = $crypt->decrypt($password);

-- hugh
 
Thanks. I was wondering how you were doing the encryption.
"Deprecated" means that for J! 4, it will need to use namespaces, right?
 
Nope, it means the JCryptCipherSimple is insecure (easily decrypted without a key), was deprecated years ago, and has been removed from J! entirely in 4.0. In 4.0 I'm using a different cipher method. I've just never bothered changing it in 3.x because of the operation issues of switching a cipher method, which would of course invalidate all existing connections .... and because if someone has your #__connections table, you've got big problems with your database security anyway.

But as 4.0 looks like being a "breaking" install anyway (requiring some migration rather than just a simple update), and I don't have any choice ... connection passwords will need to be reset.

-- hugh
 
k.
I have another problem now:
I need to get data from another database than the default J! one.
In a Fabrik context, I would use $dbItem = FabrikWorker::getDbo(false, 2);, but this gives me an 500 error.
I guess it's because I need to import or use something, but I don't know what (or how).
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top