[geeklog-cvs] Geeklog-1.x/public_html lib-common.php, 1.641, 1.642 users.php, 1.155, 1.156

Dirk Haun dhaun at qs1489.pair.com
Sat May 26 15:32:01 EDT 2007


Update of /cvsroot/geeklog/Geeklog-1.x/public_html
In directory qs1489.pair.com:/tmp/cvs-serv1378/public_html

Modified Files:
	lib-common.php users.php 
Log Message:
OpenID support, provided by Choplair


Index: users.php
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/public_html/users.php,v
retrieving revision 1.155
retrieving revision 1.156
diff -C2 -d -r1.155 -r1.156
*** users.php	13 Feb 2007 02:07:52 -0000	1.155
--- users.php	26 May 2007 19:31:59 -0000	1.156
***************
*** 613,617 ****
      $user_templates->set_var('lang_login', $LANG04[80]);
      $user_templates->set_var('end_block', COM_endBlock());
!     if ($_CONF['remoteauthentication'] && !$_CONF['usersubmission']) {
          /* Build select */
          $select = '<select name="service"><option value="">' .
--- 613,619 ----
      $user_templates->set_var('lang_login', $LANG04[80]);
      $user_templates->set_var('end_block', COM_endBlock());
! 
!     // 3rd party remote authentification.
!     if ($_CONF['user_logging_method']['3rdparty'] && !$_CONF['usersubmission']) {
          /* Build select */
          $select = '<select name="service"><option value="">' .
***************
*** 633,641 ****
          $user_templates->set_var('select_service', $select);
          $user_templates->parse('output', 'services');
!         $user_templates->set_var('services', $user_templates->finish($user_templates->get_var('output')));
      } else {
          $user_templates->set_var('services', '');
      }
      $user_templates->parse('output', 'login');
      $retval .= $user_templates->finish($user_templates->get_var('output'));
  
--- 635,659 ----
          $user_templates->set_var('select_service', $select);
          $user_templates->parse('output', 'services');
!         $user_templates->set_var('services',
!                $user_templates->finish($user_templates->get_var('output')));
      } else {
          $user_templates->set_var('services', '');
      }
+ 
+     // OpenID remote authentification.
+     if ($_CONF['user_logging_method']['openid'] && !$_CONF['usersubmission']) {
+         $user_templates->set_file('openid_login', '../loginform_openid.thtml');
+         $user_templates->set_var('lang_openid_login', $LANG01[128]);
+         $app_url = isset($_SERVER['SCRIPT_URI']) ? $_SERVER['SCRIPT_URI'] : 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
+         $user_templates->set_var('app_url', $app_url);
+         $user_templates->parse('output', 'openid_login');
+         $user_templates->set_var('openid_login',
+             $user_templates->finish($user_templates->get_var('output')));
+     } else {
+         $user_templates->set_var('openid_login', '');
+     }
+ 
      $user_templates->parse('output', 'login');
+ 
      $retval .= $user_templates->finish($user_templates->get_var('output'));
  
***************
*** 986,993 ****
      if (!empty($loginname) && !empty($passwd) && empty($service)) {
          $status = SEC_authenticate($loginname, $passwd, $uid);
!     } elseif(( $_CONF['usersubmission'] == 0) && $_CONF['remoteauthentication'] && ($service != '')) {
          /* Distributed Authentication */
          //pass $loginname by ref so we can change it ;-)
          $status = SEC_remoteAuthentication($loginname, $passwd, $service, $uid);
      } else {
          $status = -1;
--- 1004,1064 ----
      if (!empty($loginname) && !empty($passwd) && empty($service)) {
          $status = SEC_authenticate($loginname, $passwd, $uid);
! 
!     } elseif (( $_CONF['usersubmission'] == 0) && $_CONF['user_logging_method']['3rdparty'] && ($service != '')) {
          /* Distributed Authentication */
          //pass $loginname by ref so we can change it ;-)
          $status = SEC_remoteAuthentication($loginname, $passwd, $service, $uid);
+ 
+     } elseif (($_CONF['usersubmission'] == 0) && $_CONF['user_logging_method']['openid'] && (isset($_GET['openid_login']) && ($_GET['openid_login'] == '1'))) {
+         // Here we go with the handling of OpenID authentification.
+ 
+         require_once $_CONF['path_system'] . 'classes/openidhelper.class.php';
+ 
+         $query = array_merge($_GET, $_POST);
+         $consumer = new SimpleConsumer();
+         $handler = new SimpleActionHandler($query, $consumer);
+ 
+         if (isset($query['identity_url']) && $query['identity_url'] != 'http://') {
+             $identity_url = $query['identity_url'];
+             $ret = $consumer->find_identity_info($identity_url);
+             if (!$ret) {
+                 COM_errorLog('Unable to find an OpenID server for the identity URL ' . $identity_url);
+                 echo COM_refresh($_CONF['site_url'] . '/users.php?msg=89');
+                 exit;
+             } else {
+                 // Found identity server info.
+                 list($identity_url, $server_id, $server_url) = $ret;
+ 
+                 // Redirect the user-agent to the OpenID server
+                 // which we are requesting information from.
+                 header('Location: ' . $consumer->handle_request(
+                         $server_id, $server_url,
+                         oidUtil::append_args($_CONF['site_url'] . '/users.php',
+                             array('openid_login' => '1',
+                                   'open_id' => $identity_url)), // Return to.
+                         $_CONF['site_url'], // Trust root.
+                         null,
+                         "email,nickname,fullname")); // Required fields.
+             }
+         } elseif (isset($query['openid.mode']) || isset($query['openid_mode'])) {
+             $openid_mode = '';
+             if (isset($query['openid.mode'])) {
+                 $openid_mode = $query['openid.mode'];
+             } else if(isset($query['openid_mode'])) {
+                 $openid_mode = $query['openid_mode'];
+             }
+             if ($openid_mode == 'cancel') {
+                 echo COM_refresh($_CONF['site_url'] . '/users.php?msg=90');
+                 exit;
+             } else {
+                $openid = $handler->getOpenID();
+                $req = new ConsumerRequest($openid, $query, 'GET');
+                $response = $consumer->handle_response($req);
+                $response->doAction($handler);
+             }
+         } else {
+             echo COM_refresh($_CONF['site_url'] . '/users.php?msg=91');
+             exit;
+         }
      } else {
          $status = -1;
***************
*** 997,1001 ****
          DB_change($_TABLES['users'],'pwrequestid',"NULL",'uid',$uid);
          $userdata = SESS_getUserDataFromId($uid);
!         $_USER=$userdata;
          $sessid = SESS_newSession($_USER['uid'], $_SERVER['REMOTE_ADDR'], $_CONF['session_cookie_timeout'], $_CONF['cookie_ip']);
          SESS_setSessionCookie($sessid, $_CONF['session_cookie_timeout'], $_CONF['cookie_session'], $_CONF['cookie_path'], $_CONF['cookiedomain'], $_CONF['cookiesecure']);
--- 1068,1072 ----
          DB_change($_TABLES['users'],'pwrequestid',"NULL",'uid',$uid);
          $userdata = SESS_getUserDataFromId($uid);
!         $_USER = $userdata;
          $sessid = SESS_newSession($_USER['uid'], $_SERVER['REMOTE_ADDR'], $_CONF['session_cookie_timeout'], $_CONF['cookie_ip']);
          SESS_setSessionCookie($sessid, $_CONF['session_cookie_timeout'], $_CONF['cookie_session'], $_CONF['cookie_path'], $_CONF['cookiedomain'], $_CONF['cookiesecure']);
***************
*** 1048,1052 ****
                     $_CONF['cookiesecure']);
  
!         if (!empty ($_SERVER['HTTP_REFERER']) && (strstr ($_SERVER['HTTP_REFERER'], '/users.php') === false)) {
              $indexMsg = $_CONF['site_url'] . '/index.php?msg=';
              if (substr ($_SERVER['HTTP_REFERER'], 0, strlen ($indexMsg)) == $indexMsg) {
--- 1119,1126 ----
                     $_CONF['cookiesecure']);
  
!         if (!empty($_SERVER['HTTP_REFERER'])
!                 && (strstr($_SERVER['HTTP_REFERER'], '/users.php') === false)
!                 && (substr($_SERVER['HTTP_REFERER'], 0,
!                         strlen($_CONF['site_url'])) == $_CONF['site_url'])) {
              $indexMsg = $_CONF['site_url'] . '/index.php?msg=';
              if (substr ($_SERVER['HTTP_REFERER'], 0, strlen ($indexMsg)) == $indexMsg) {

Index: lib-common.php
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/public_html/lib-common.php,v
retrieving revision 1.641
retrieving revision 1.642
diff -C2 -d -r1.641 -r1.642
*** lib-common.php	12 May 2007 20:28:26 -0000	1.641
--- lib-common.php	26 May 2007 19:31:58 -0000	1.642
***************
*** 2176,2180 ****
              $login->set_var( 'lang_signup', $LANG01[59] );
          }
!         if( $_CONF['remoteauthentication'] && !$_CONF['usersubmission'] )
          {
              // Build select
--- 2176,2182 ----
              $login->set_var( 'lang_signup', $LANG01[59] );
          }
! 
!         // 3rd party remote authentification.
!         if( $_CONF['user_logging_method']['3rdparty'] && !$_CONF['usersubmission'] )
          {
              // Build select
***************
*** 2203,2211 ****
              $login->set_var( 'services',
                               $login->finish( $login->get_var( 'output' )));
          }
!         else
!         {
!             $login->set_var( 'services', '' );
          }
          $retval .= $login->parse( 'output', 'form' );
  
--- 2205,2224 ----
              $login->set_var( 'services',
                               $login->finish( $login->get_var( 'output' )));
+         } else {
+            $login->set_var('services', '');
          }
! 
!         // OpenID remote authentification.
!         if ($_CONF['user_logging_method']['openid'] && !$_CONF['usersubmission']) {
!             $login->set_file('openid_login', 'loginform_openid.thtml');
!             $login->set_var('lang_openid_login', $LANG01[128]);
!             $login->set_var('app_url', $_CONF['site_url']."/users.php");
!             $login->parse('output', 'openid_login');
!             $login->set_var('openid_login',
!                 $login->finish($login->get_var('output')));
!         } else {
!             $login->set_var('openid_login', '');
          }
+ 
          $retval .= $login->parse( 'output', 'form' );
  
***************
*** 3653,3661 ****
          return $fullname;
      }
!     else if( $_CONF['remoteauthentication'] && $_CONF['show_servicename'] &&
!                     !empty( $remoteusername ))
      {
          return "$remoteusername@$remoteservice";
      }
  
      return $username;
--- 3666,3685 ----
          return $fullname;
      }
!     else if(( $_CONF['user_logging_method']['3rdparty'] || $_CONF['user_logging_method']['openid'] ) && !empty( $remoteusername ))
!     {
!         if( !empty( $username ))
!         {
!             $remoteusername = $username;
!         }
! 
!         if( $_CONF['show_servicename'] )
      {
          return "$remoteusername@$remoteservice";
      }
+         else
+         {
+             return $remoteusername;
+         }
+     }
  
      return $username;
***************
*** 4388,4392 ****
          $byname .= ',fullname';
      }
!     if( $_CONF['remoteauthentication'] )
      {
          $byname .= ',remoteusername,remoteservice';
--- 4412,4416 ----
          $byname .= ',fullname';
      }
!     if( $_CONF['user_logging_method']['openid'] || $_CONF['user_logging_method']['3rdparty'] )
      {
          $byname .= ',remoteusername,remoteservice';
***************
*** 4410,4414 ****
                  $fullname = $A['fullname'];
              }
!             if( $_CONF['remoteauthentication'] )
              {
                  $username = COM_getDisplayName( $A['uid'], $A['username'],
--- 4434,4438 ----
                  $fullname = $A['fullname'];
              }
!             if( $_CONF['user_logging_method']['openid'] || $_CONF['user_logging_method']['3rdparty'] )
              {
                  $username = COM_getDisplayName( $A['uid'], $A['username'],




More information about the geeklog-cvs mailing list