views:

50

answers:

1

Hello!

I have downloaded some sample code for openId in Joomla 1.5. I am learning as I go with this Joomla thing and re-learning some PHP things. So I'm basically terribly new to this entire Content Manager world. I am trying to make a little plug-in for authentication with openid but it seems to be just wrong.

I have successfully debugged the project in eclipse and found that the error comes from my jimport.

class plgAuthenticationOpenId extends JPlugin{
    /**
     * OpenId Atributes.
     */
    private static $attribute;

    private static $proxyHost;
    private static $proxyPort;
    private static $proxyUser;
    private static $proxyPassword;
    private static $appId;
    private static $appPassword;


function plgAuthenticationOpenId(& $subject, $config){
        parent::__construct($subject, $config);


         plgAuthenticationOpenId::$appId=$this->params->get('userKey', '');
         plgAuthenticationOpenId::$appPassword = $this->params->get('apiKey', '');

        define('Auth_OpenID_RAND_SOURCE', null);

        jimport('openid.consumer'); 
        jimport('openid.Auth.OpenID.AX');

        //Basic Attributes
        plgAuthenticationOpenId::$attribute = array();

        //more code messing with plgAuthenticationOpenId [...]

I have tried to put the library in the php include path, put it in the PEAR path, I have tried the required_once (it brakes there instead of in the jimport), I have tried to jimport the whole path and tried to use include directly. I have also defined the directory separator and the JPATH_BASE. Nothing seems to work.

I think this should have a very easy solution, as I have copy/pasted the code (not created it myself) and is a simple jimport. But nevertheless I’m new to this and stuck. So please, help.

Thanks a lot.

+1  A: 

Problem is that jimport('openid.consumer'); changed include_path

Here is a test to demonstrate it.

<?php
// I executed code below in the view to obtain output
var_dump(ini_get('include_path'));
jimport('openid.consumer');
jimport('openid.Auth.OpenID.AX');
var_dump(ini_get('include_path'));

// OUTPUT
string '.:/opt/lampp/lib/php' (length=20)
string '/opt/lampp/htdocs/promark_eblaster/libraries/openid/.:/opt/lampp/lib/php' (length=72)
?>

As you can see the include_path changed.

You can try the following workaround.

<?php 
// Remember the Original Path
$oldPath = ini_get('include_path');

// Include OpenID Stuff
jimport('openid.consumer');
jimport('openid.Auth.OpenID.AX');

// Set back the include_path so Joomla can import files with old include path
ini_set('include_path', $oldPath);

// Check if Success
JFactory::getApplication()->enqueueMessage("Hellow World");

// The rest of your code...
?>
Alex
Thanks for the response. But I fail to see how I can change my code to make it work. I have outputted the include_path (it's in php/PEAR inside my xampp), I have changed it in my php.ini to the Joomla library folder of the project. I have copy/pasted the openid folder to the PEAR path and it is in my Joomla library folder. Neither works. Thanks for your help! :)
Random
after the include path changes for the first time because of `jimport('openid.cunsumer')` it is not good for Joomla. Solution is simple, after `jimport('openid.consumer');` and `jimport('openid.Auth.OpenID.AX');` change the include path to the old path. Basically reuse the code that I posted.
Alex
I must apologize. I have not explained myself correctly. My problem is that when it executes the instruction jimport('openid.consumer') the code breaks. It doesn’t change my include_path because it simply fails to do anything after that instruction.
Random
Really weird. I tested this code, after `jimport('openid.******')` the regular `jimport('joomla.***')` crashes with many failed to open stream errors. Including openid changes your path, look at `libraries/openid/consumer.php`. Try wrapping the `jimport('openid.***')` the way I am suggesting in my workaround, it worked for me... If for some reason it does not work, try moving the `jimport` outside of the class (with and without include_path workaround)
Alex
So I have debugged a little bit more, my bad, should have done this first, and found a very looong way down. First I looked up to consuer.php witch directed me to a Consumer.php (in a required_once instruction), down this way I have gone through OpenId, PlainHTTPFetcher, HTTPFetcher and finally BigMath.php where I have this little if (@dl($module . "." . PHP_SHLIB_SUFFIX)) (line 383).
Random
(continue from above) I have echoed the $module . “.” . PHP_SHLIB_SUFFIX which outputs me a pretty gmp.dll…. Which I have no idea what is for but it seems to not be there, since it breaks terribly. The doc of the dl function doesn’t say much, since I already have safe_mode turned off and enable_dl turned on. Any ideas? Thanks for your help!
Random
I assume you are running Windows... we found the problem =), jk. I do not think the problem is in code, most likely your configs are messed up or missing extensions. Uncomment `;extension=php_gmp.dll` in your php.ini, as per http://php.net/manual/en/gmp.installation.php . If that does not help look through the errors that you get to figure out what is missing.
Alex
I uncommented the extension and it works wonders! Thanks a lot!
Random
great! Glad I could help.
Alex