PHP OpenID consumer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sreg.ext.php 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?PHP
  2. /* Poidsy 0.6 - http://chris.smith.name/projects/poidsy
  3. * Copyright (c) 2008-2010 Chris Smith
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6. * of this software and associated documentation files (the "Software"), to deal
  7. * in the Software without restriction, including without limitation the rights
  8. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. * copies of the Software, and to permit persons to whom the Software is
  10. * furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in
  13. * all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. * SOFTWARE.
  22. */
  23. define('SREG_NICKNAME', 'nickname');
  24. define('SREG_EMAIL', 'email');
  25. define('SREG_FULLNAME', 'fullname');
  26. define('SREG_DOB', 'dob');
  27. define('SREG_GENDER', 'gender');
  28. define('SREG_POSTCODE', 'postcode');
  29. define('SREG_COUNTRY', 'country');
  30. define('SREG_LANGUAGE', 'language');
  31. define('SREG_TIMEZONE', 'timezone');
  32. define('SREG_ALL', SREG_NICKNAME . ',' . SREG_EMAIL . ',' . SREG_FULLNAME
  33. . ',' . SREG_DOB . ',' . SREG_GENDER . ',' . SREG_POSTCODE . ','
  34. . SREG_COUNTRY . ',' . SREG_LANGUAGE . ', ' . SREG_TIMEZONE);
  35. class SReg {
  36. public function parseResponse() {
  37. foreach (explode(',', SREG_ALL) as $reg) {
  38. $reg = 'openid_sreg_' . $reg;
  39. if (isset($_REQUEST[$reg])) {
  40. $_SESSION['openid']['sreg'][substr($reg, 12)] = $_REQUEST[$reg];
  41. }
  42. }
  43. }
  44. public function decorate(&$args, $ns) {
  45. if (defined('OPENID_SREG_REQUEST')) {
  46. $args['openid.sreg.required'] = OPENID_SREG_REQUEST;
  47. }
  48. if (defined('OPENID_SREG_OPTIONAL')) {
  49. $args['openid.sreg.optional'] = OPENID_SREG_OPTIONAL;
  50. }
  51. if (defined('OPENID_SREG_POLICY')) {
  52. $args['openid.sreg.policy_url'] = OPENID_SREG_POLICY;
  53. }
  54. }
  55. }
  56. $sreg = new SReg();
  57. $_POIDSY['decorators'][] = $sreg;
  58. $_POIDSY['handlers'][] = $sreg;
  59. ?>