1. Fabrik 3.8.1 has been released. It is mostly bug fixes and feature enhancements, but does include two new plugins (push notifications, and the sequence element). As usual we strongly recommend testing the new release on a sandbox if your application is mission critical, and always do an Akeeba backup before updating.

How to call for connections data

Discussion in 'Professional Support' started by jfquestiaux, Apr 16, 2018 at 4:16 PM.

Thread Status:
Not open for further replies.
  1. jfquestiaux

    jfquestiaux Well-Known Member

    Level: Professional
    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?
     
  2. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    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 (Text):

    // 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
     
    jfquestiaux likes this.
  3. jfquestiaux

    jfquestiaux Well-Known Member

    Level: Professional
    Thanks. I was wondering how you were doing the encryption.
    "Deprecated" means that for J! 4, it will need to use namespaces, right?
     
  4. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    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
     
  5. jfquestiaux

    jfquestiaux Well-Known Member

    Level: Professional
    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).
     
  6. jfquestiaux

    jfquestiaux Well-Known Member

    Level: Professional
    OK. I solved it with $db = JDatabaseDriver::getInstance( $option );
     
Thread Status:
Not open for further replies.

Share This Page