Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.10 KB | None | 0 0
  1. <?php
  2. $path_extra = dirname(dirname(dirname(__FILE__)));
  3. $path = ini_get('include_path');
  4. $path = $path_extra . PATH_SEPARATOR . $path;
  5. ini_set('include_path', $path);
  6. function displayError($message) {
  7. $error = $message;
  8. include 'index.php';
  9. exit(0);
  10. }
  11. function doIncludes() {
  12. // Require the OpenID consumer code.
  13. require_once "Auth/OpenID/Consumer.php";
  14. // Require the "file store" module, which we'll need to store
  15. // OpenID information.
  16. require_once "Auth/OpenID/FileStore.php";
  17. // Require the Attribute Exchange extension API.
  18. require_once "Auth/OpenID/AX.php";
  19. // Require the PAPE extension module.
  20. require_once "Auth/OpenID/PAPE.php";
  21. }
  22. doIncludes();
  23. global $pape_policy_uris;
  24. $pape_policy_uris = array(
  25. PAPE_AUTH_MULTI_FACTOR_PHYSICAL,
  26. PAPE_AUTH_MULTI_FACTOR,
  27. PAPE_AUTH_PHISHING_RESISTANT
  28. );
  29. function &getStore() {
  30. #store data here
  31. $store_path = "/tmp/_php_consumer_test";
  32. if (!file_exists($store_path) &&
  33. !mkdir($store_path)) {
  34. print "Could not create the FileStore directory '$store_path'. ".
  35. " Please check the effective permissions.";
  36. exit(0);
  37. }
  38. return new Auth_OpenID_FileStore($store_path);
  39. }
  40. function getScheme() {
  41. $scheme = 'http';
  42. if (isset($_SERVER['HTTPS']) and $_SERVER['HTTPS'] == 'on') {
  43. $scheme .= 's';
  44. }
  45. return $scheme;
  46. }
  47. function getReturnTo() {
  48. if ($_SERVER['SERVER_PORT'] == 80) {
  49. return sprintf("%s://%s%s/finish_auth.php",
  50. getScheme(), $_SERVER['SERVER_NAME'],
  51. dirname($_SERVER['PHP_SELF']));
  52. } else {
  53. return sprintf("%s://%s:%s%s/finish_auth.php",
  54. getScheme(), $_SERVER['SERVER_NAME'],
  55. $_SERVER['SERVER_PORT'],
  56. dirname($_SERVER['PHP_SELF']));
  57. }
  58. }
  59. function getTrustRoot() {
  60. if ($_SERVER['SERVER_PORT'] == 80) {
  61. return sprintf("%s://%s%s/",
  62. getScheme(), $_SERVER['SERVER_NAME'],
  63. dirname($_SERVER['PHP_SELF']));
  64. } else {
  65. return sprintf("%s://%s:%s%s/",
  66. getScheme(), $_SERVER['SERVER_NAME'],
  67. $_SERVER['SERVER_PORT'],
  68. dirname($_SERVER['PHP_SELF']));
  69. }
  70. }
  71.  
  72. function &getConsumer() {
  73. /**
  74. * Create a consumer object using the store object created
  75. * earlier.
  76. */
  77. $store = getStore();
  78. $consumer =& new Auth_OpenID_Consumer($store);
  79. return $consumer;
  80. }
  81. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement