function wfSpecialOpenIDServer($par) { global $wgOut; $server =& self::getOpenIDServer(); //pretty_print_r($_SERVER); switch ($par) { case 'Login': if (empty($_REQUEST['user_id'])) { throw new Exception('user_id must be present'); } $user = User::getObject($_REQUEST['user_id']); list($request, $sreg) = self::serverSessionFetchValues(); $result = self::serverLogin($request); if ($result) { if (is_string($result)) { self::serverLoginForm($request, $result, $user); return; } else { self::outputServerResponse($server, $result); return; } } break; case 'Trust': list($request, $sreg) = self::serverSessionFetchValues(); $result = OpenIDServerTrust($request, $sreg); if ($result) { if (is_string($result)) { OpenIDServerTrustForm($request, $sreg, $result); return; } else { self::outputServerResponse($server, $result); return; } } break; default: $method = $_SERVER['REQUEST_METHOD']; $query = null; if ($method == 'GET') { $query = $_GET; } else { $query = $_POST; } $request = $server->decodeRequest(); $sreg = self::getServerSregFromQuery($query); //pretty_print_r($sreg); $response = NULL; break; } //pretty_print_r($request); if (!isset($request)) { throw new exception("OpenID request parameters missing"); return; } else { if (get_class($request) == 'Auth_OpenID_ServerError') { //throw new exception("OpenID error: ".$request->text); } } switch ($request->mode) { case "checkid_setup": $response = self::ServerCheck($server, $request, $sreg, false); break; case "checkid_immediate": $response = self::ServerCheck($server, $request, $sreg, true); break; default: # For all the other parts, just let the libs do it $response =& $server->handleRequest($request); } # self::ServerCheck returns NULL if some output (like a form) # has been done if (isset($response)) { # We're done; clear values self::serverSessionClearValues(); self::outputServerResponse($server, $response); } }
function wfSpecialOpenIDServer($par) { global $wgOut; $server =& OpenIDServer(); switch ($par) { case 'Login': list($request, $sreg) = OpenIDServerFetchValues(); $result = OpenIDServerLogin($request); if ($result) { if (is_string($result)) { OpenIDServerLoginForm($request, $result); return; } else { OpenIDServerResponse($server, $result); return; } } break; case 'Trust': list($request, $sreg) = OpenIDServerFetchValues(); $result = OpenIDServerTrust($request, $sreg); if ($result) { if (is_string($result)) { OpenIDServerTrustForm($request, $sreg, $result); return; } else { OpenIDServerResponse($server, $result); return; } } break; default: if (strlen($par)) { $wgOut->errorpage('openiderror', 'openiderrortext'); return; } else { $method = $_SERVER['REQUEST_METHOD']; $query = null; if ($method == 'GET') { $query = $_GET; } else { $query = $_POST; } $query = Auth_OpenID::fixArgs($query); $request = $server->decodeRequest($query); $sreg = OpenIdServerSregFromQuery($query); $response = NULL; break; } } if (!isset($request)) { $wgOut->errorpage('openiderror', 'openiderrortext'); return; } global $wgUser; switch ($request->mode) { case "checkid_setup": $response = OpenIDServerCheck($server, $request, $sreg, false); break; case "checkid_immediate": $response = OpenIDServerCheck($server, $request, $sreg, true); break; default: # For all the other parts, just let the libs do it $response =& $server->handleRequest($request); } # OpenIDServerCheck returns NULL if some output (like a form) # has been done if (isset($response)) { # We're done; clear values OpenIDServerClearValues(); OpenIDServerResponse($server, $response); } }