start() $options = new ezcAuthenticationSessionOptions(); $session = new ezcAuthenticationSession( $options ); $session->start(); // URL after returning from OpenID authentication $url = isset( $_GET['openid_identity'] ) ? $_GET['openid_identity'] : $session->load(); if ( $url === null ) { // URL at the start of authentication $url = isset( $_GET['openid_identifier'] ) ? $_GET['openid_identifier'] : $session->load(); } $action = isset( $_GET['action'] ) ? strtolower( $_GET['action'] ) : null; $credentials = new ezcAuthenticationIdCredentials( $url ); $authentication = new ezcAuthentication( $credentials ); $authentication->session = $session; if ( $action === 'logout' ) { $session->destroy(); } else { $options = new ezcAuthenticationOpenidOptions(); $options->mode = ezcAuthenticationOpenidFilter::MODE_SMART; $options->openidVersion = ezcAuthenticationOpenidFilter::VERSION_2_0; $options->store = new ezcAuthenticationOpenidFileStore( '/tmp/store' ); $filter = new ezcAuthenticationOpenidFilter( $options ); $filter->registerFetchData( array( 'fullname', 'gender', 'country', 'language' ) ); $authentication->addFilter( $filter ); } if ( !$authentication->run() ) { // authentication did not succeed, so inform the user $status = $authentication->getStatus(); $err = array(); $err["user"] = ""; $err["session"] = ""; for ( $i = 0; $i < count( $status ); $i++ ) { list( $key, $value ) = each( $status[$i] ); switch ( $key ) { case 'ezcAuthenticationOpenidFilter': if ( $value === ezcAuthenticationOpenidFilter::STATUS_SIGNATURE_INCORRECT ) { $err["user"] = "OpenID said the provided identifier was incorrect."; } if ( $value === ezcAuthenticationOpenidFilter::STATUS_CANCELLED ) { $err["user"] = "The OpenID authentication was cancelled, please re-login."; } if ( $value === ezcAuthenticationOpenidFilter::STATUS_URL_INCORRECT ) { $err["user"] = "The identifier you provided is empty or invalid. It must be a URL (eg. www.example.com or http://www.example.com)"; } break; case 'ezcAuthenticationSessionFilter': if ( $value === ezcAuthenticationSessionFilter::STATUS_EXPIRED ) { $err["session"] = "Session expired"; } break; } } ?> Please login with your OpenID identifier (an URL, eg. www.example.com or http://www.example.com):
You are logged-in as | Logout