EOpenID - Undefined index: HTTPS

Hi.

I’have tried EOpenID extension and got following error:




PHP Error


Description


Undefined index: HTTPS


Source File


/srv/http/yii/demos/test/protected/components/EOpenID.php(72)


00060:         'contact/email'           => 'email',

00061:         'namePerson'              => 'fullname',

00062:         'birthDate'               => 'dob',

00063:         'person/gender'           => 'gender',

00064:         'contact/postalCode/home' => 'postcode',

00065:         'contact/country/home'    => 'country',

00066:         'pref/language'           => 'language',

00067:         'pref/timezone'           => 'timezone',

00068:         );

00069: 

00070:     function __construct()

00071:     {

00072:         $this->trustRoot = ($_SERVER['HTTPS']=='on' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'];

00073:         $this->returnUrl = $this->trustRoot . $_SERVER['REQUEST_URI'];

00074: 

00075:         if (!function_exists('curl_exec')) {

00076:             throw new ErrorException('Curl extension is required.');

00077:         }

00078: 

00079:         $this->data = $_POST + $_GET; # OPs may send data as POST or GET.

00080:     }

00081: 

00082:     public function setIdentity($value){

00083:             if (strlen($value = trim($value))) {

00084:                 if (preg_match('#^xri:/*#i', $value, $m)) {

Stack Trace


#0 /srv/http/yii/demos/test/protected/controllers/SiteController.php(109): EOpenID->__construct()

#1 /srv/http/yii/framework/web/actions/CInlineAction.php(32): SiteController->actionOpenIDLogin()

#2 /srv/http/yii/framework/web/CController.php(300): CInlineAction->run()

#3 /srv/http/yii/framework/web/CController.php(278): SiteController->runAction()

#4 /srv/http/yii/framework/web/CController.php(257): SiteController->runActionWithFilters()

#5 /srv/http/yii/framework/web/CWebApplication.php(324): SiteController->run()

#6 /srv/http/yii/framework/web/CWebApplication.php(121): CWebApplication->runController()

#7 /srv/http/yii/framework/base/CApplication.php(135): CWebApplication->processRequest()

#8 /srv/http/yii/demos/test/index.php(13): CWebApplication->run()

2010-08-18 21:58:39 Apache/2.2.15 (Unix) mod_ssl/2.2.15 OpenSSL/1.0.0a DAV/2 PHP/5.3.3 with Suhosin-Patch Yii Framework/1.1.3



I’ve fixed it as:




 72         if( isset( $_SERVER['HTTPS'] ) )

 73          $this->trustRoot = ($_SERVER['HTTPS']=='on' ? 'https' : 'http') . '://' . $_SERVE    R['HTTP_HOST'];

 74         else

 75          $this->trustRoot = 'http://' . $_SERVER['HTTP_HOST'];

Could you, please, check if it is correct?

Thanks a lot.

The documentation for $_SERVER[‘HTTPS’] ( http://php.net/manua...bles.server.php )says:

So if the script was not queried through the HTTPS protocol this element will not be set… and PHP 5.3 will issue the error

Undefined index: HTTPS

You can solve this by changing the _construct function to first check if $_SERVER[‘HTTPS’] is set like:




function __construct()

{

    $this->trustRoot='http';


    if( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on' )

       $this->trustRoot = 'https'


    $this->trustRoot.='://' . $_SERVER['HTTP_HOST'];


    $this->returnUrl = $this->trustRoot . $_SERVER['REQUEST_URI'];


    if (!function_exists('curl_exec')) {

      throw new ErrorException('Curl extension is required.');

    }


    $this->data = $_POST + $_GET; # OPs may send data as POST or GET.

}