Guest

John Reese

By: a guest on Jun 21st, 2010  |  syntax: Diff  |  size: 1.46 KB  |  hits: 192  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. From 414e35a07b1808d0f58f033759e501af3a569be9 Mon Sep 17 00:00:00 2001
  2. From: John Reese <JohnMichael.Reese@ge.com>
  3. Date: Mon, 21 Jun 2010 13:43:03 -0400
  4. Subject: [PATCH 1/3] Added form_action_self() API function
  5.  
  6. Helper function to generate a form action value when forms are designed
  7. to be submitted to the same url that's is currently being used, such as
  8. helper_ensure_confirmed() or auth_reauthenticate().
  9.  
  10. Designed to fix issues with using reverse proxies that rewrite URLs for
  11. the application server.  By using a standard self-relative form action,
  12. it prevents issues where SCRIPT_NAME on the application server does not
  13. match the URL that the client is using.
  14. ---
  15.  core/form_api.php |   10 ++++++++++
  16.  1 files changed, 10 insertions(+), 0 deletions(-)
  17.  
  18. diff --git a/core/form_api.php b/core/form_api.php
  19. index b1144c7..d723492 100644
  20. --- a/core/form_api.php
  21. +++ b/core/form_api.php
  22. @@ -29,6 +29,16 @@
  23.   */
  24.  
  25.  /**
  26. + * Helper function to generate a form action value when forms are designed
  27. + * to be submitted to the same url that's is currently being used, such as
  28. + * helper_ensure_confirmed() or auth_reauthenticate().
  29. + * @return string Form action value
  30. + */
  31. +function form_action_self() {
  32. +       return basename($_SERVER['PHP_SELF']);
  33. +}
  34. +
  35. +/**
  36.   * Generate a random security token, prefixed by date, store it in the
  37.   * user's session, and then return the string to be used as a form element
  38.   * element with the security token as the value.
  39. --
  40. 1.7.0.4