discover.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. require_once "consumer/common.php";
  3. require_once "Auth/OpenID/Discover.php";
  4. require_once "Auth/Yadis/Yadis.php";
  5. function getOpenIDIdentifier()
  6. {
  7. return $_GET['openid_identifier'];
  8. }
  9. function escape($x)
  10. {
  11. return htmlentities($x);
  12. }
  13. $identifier = getOpenIDIdentifier();
  14. ?>
  15. <html>
  16. <head>
  17. <title>OpenID discovery</title>
  18. </head>
  19. <body>
  20. <h2>OpenID discovery tool</h2>
  21. <p>
  22. Enter an OpenID URL to begin discovery:
  23. </p>
  24. <form>
  25. <input type="text" name="openid_identifier" size="40" />
  26. <input type="submit" value="Begin" />
  27. </form>
  28. <?php
  29. if ($identifier) {
  30. $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
  31. list($normalized_identifier, $endpoints) = Auth_OpenID_discover(
  32. $identifier, $fetcher);
  33. ?>
  34. <h3>Discovery Results for <?php echo escape($identifier) ?></h3>
  35. <table cellpadding="7" cellspacing="0">
  36. <tbody>
  37. <tr>
  38. <th>Claimed Identifier</th>
  39. <td><?php echo escape($normalized_identifier) ?></td>
  40. </tr>
  41. <?php
  42. if (!$endpoints) {
  43. ?>
  44. <tr>
  45. <td colspan="2">No OpenID services discovered.</td>
  46. </tr>
  47. <?php
  48. } else {
  49. ?>
  50. <tr>
  51. <td colspan="2">Discovered OpenID services:</td>
  52. </tr>
  53. <?php
  54. foreach ($endpoints as $endpoint) {
  55. ?>
  56. <tr>
  57. <td colspan="2"><hr/></td>
  58. </tr>
  59. <tr>
  60. <th>Server URL</th>
  61. <td><tt><?php echo escape($endpoint->server_url) ?></tt></td>
  62. </tr>
  63. <tr>
  64. <th>Local ID</th>
  65. <td><tt><?php echo escape($endpoint->local_id) ?></tt></td>
  66. </tr>
  67. <tr>
  68. <td colspan="2">
  69. <h3>Service types:</h3>
  70. <ul>
  71. <?php
  72. foreach ($endpoint->type_uris as $type_uri) {
  73. ?>
  74. <li><tt><?php echo escape($type_uri) ?></tt></li>
  75. <?php
  76. }
  77. ?>
  78. </ul>
  79. </td>
  80. </tr>
  81. <?php
  82. }
  83. }
  84. ?>
  85. </tbody>
  86. </table>
  87. <?php
  88. }
  89. ?>
  90. </body>
  91. </html>