common.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. /**
  13. * Require the OpenID consumer code.
  14. */
  15. require_once "Auth/OpenID/Consumer.php";
  16. /**
  17. * Require the "file store" module, which we'll need to store
  18. * OpenID information.
  19. */
  20. require_once "Auth/OpenID/FileStore.php";
  21. /**
  22. * Require the Simple Registration extension API.
  23. */
  24. require_once "Auth/OpenID/SReg.php";
  25. /**
  26. * Require the PAPE extension module.
  27. */
  28. require_once "Auth/OpenID/PAPE.php";
  29. }
  30. doIncludes();
  31. global $pape_policy_uris;
  32. $pape_policy_uris = array(
  33. PAPE_AUTH_MULTI_FACTOR_PHYSICAL,
  34. PAPE_AUTH_MULTI_FACTOR,
  35. PAPE_AUTH_PHISHING_RESISTANT
  36. );
  37. function &getStore() {
  38. /**
  39. * This is where the example will store its OpenID information.
  40. * You should change this path if you want the example store to be
  41. * created elsewhere. After you're done playing with the example
  42. * script, you'll have to remove this directory manually.
  43. */
  44. $store_path = "/tmp/_php_consumer_test";
  45. if (!file_exists($store_path) &&
  46. !mkdir($store_path)) {
  47. print "Could not create the FileStore directory '$store_path'. ".
  48. " Please check the effective permissions.";
  49. exit(0);
  50. }
  51. return new Auth_OpenID_FileStore($store_path);
  52. }
  53. function &getConsumer() {
  54. /**
  55. * Create a consumer object using the store object created
  56. * earlier.
  57. */
  58. $store = getStore();
  59. $consumer =& new Auth_OpenID_Consumer($store);
  60. return $consumer;
  61. }
  62. function getScheme() {
  63. $scheme = 'http';
  64. if (isset($_SERVER['HTTPS']) and $_SERVER['HTTPS'] == 'on') {
  65. $scheme .= 's';
  66. }
  67. return $scheme;
  68. }
  69. function getReturnTo() {
  70. return sprintf("%s://%s:%s%s/finish_auth.php",
  71. getScheme(), $_SERVER['SERVER_NAME'],
  72. $_SERVER['SERVER_PORT'],
  73. dirname($_SERVER['PHP_SELF']));
  74. }
  75. function getTrustRoot() {
  76. return sprintf("%s://%s:%s%s/",
  77. getScheme(), $_SERVER['SERVER_NAME'],
  78. $_SERVER['SERVER_PORT'],
  79. dirname($_SERVER['PHP_SELF']));
  80. }
  81. ?>