-
- function handler_idp_xrds(&$page)
- {
- $this->load('openid.inc.php');
- header('Content-type: application/xrds+xml');
- $page->changeTpl('openid/idp_xrds.tpl', NO_SKIN);
- $page->assign('type2', Auth_OpenID_TYPE_2_0_IDP);
- $page->assign('sreg', Auth_OpenID_SREG_URI);
- $page->assign('provider', get_openid_url());
- }
-
- function handler_user_xrds(&$page, $x = null)
- {
- $this->load('openid.inc.php');
-
- $user = get_user($x);
- if (is_null($user)) {
- return PL_NOT_FOUND;
- }
-
- header('Content-type: application/xrds+xml');
- $page->changeTpl('openid/user_xrds.tpl', NO_SKIN);
- $page->assign('type2', Auth_OpenID_TYPE_2_0);
- $page->assign('type1', Auth_OpenID_TYPE_1_1);
- $page->assign('sreg', Auth_OpenID_SREG_URI);
- $page->assign('provider', get_openid_url());
- $page->assign('local_id', $user->hruid);
- }
-
- function handler_melix(&$page, $x = null)
- {
- $this->load('openid.inc.php');
- $user = get_user_by_alias($x);
-
- // This will redirect to the canonic URL, which was not used
- // if this hook was triggered
- return $this->render_discovery_page(&$page, $user);
- }
-
- //--------------------------------------------------------------------//
-
- function render_discovery_page(&$page, $user)
- {
-
- // Show the documentation if this is not the OpenId page of an user
- if (is_null($user)) {
- pl_redirect('Xorg/OpenId');
- }
-
- // Redirect to the canonic URL if we are using an alias
- // There might be a risk of redirection loop here
- // if $_SERVER was not exactly what we expect
- $current_url = 'http' . (empty($_SERVER['HTTPS']) ? '' : 's') . '://'
- . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
- $canonic_url = get_user_openid_url($user);
- if ($current_url != $canonic_url) {
- http_redirect($canonic_url);
- }
-
- // Include X-XRDS-Location response-header for Yadis discovery
- header('X-XRDS-Location: ' . get_user_xrds_url($user));
-
- $page->changeTpl('openid/openid.tpl');
- $page->setTitle($user->fullName());
- // Set the <link> tags for HTML-Based Discovery
- $page->addLink('openid.server openid2.provider', get_openid_url());
- $page->addLink('openid.delegate openid2.local_id', $user->hruid);
- $page->assign_by_ref('user', $user);
-
- return;
- }
-
- function render_openid_response($webresponse)
- {
- if ($webresponse->code != AUTH_OPENID_HTTP_OK) {
- header(sprintf("HTTP/1.1 %d ", $webresponse->code),
- true, $webresponse->code);
- }
- foreach ($webresponse->headers as $k => $v) {
- header("$k: $v");
- }
- header('Connection: close');
- print $webresponse->body;
- exit;
- }