Packages » Package freeformdemo » Class FDLocationRewriter1

Class FDLocationRewriter1

Declaration:
<? class FDLocationRewriter1 implements LocationRewriter ?>

Description:
This is a sample LocationRewriter implementation that will rewrite the URLs of the Locations using the base64 recode functions, so that un URL like http://localhost:80/index.php5?action=FDWelcome will be rewritten to http://localhost:80/YWN0aW9uPUZEV2VsY29tZQ==. To enable this rewriter, you'll have to modify the .htaccess or httpd.conf file and add this line: ErrorDocument 404 /error.php5. This will redirect all erroneous requests to a special wrapper launcher (error.php5, you can find it in the resources folder of this package. It has to be placed in the same directory where you placed the index.php5, Freeform loader file). Then open the .config file of the freeform package (located at {FREEFORM_HOME_DIR}/packages/freeform) and add this line: locationRewriter=FDLocationRewriter1. To disable the rewriter, simply undo the above changes. Note: if you employ this rewriter, please see the comments in the error.php5 file to learn about possible modes of using that file and about possible side-effects of such use. Also note that this rewriter cannot be used with GET forms as there is no way to force the user agent to rewrite the query string. Either you will have to provide a way of detecting whether the submitted URL is not encrypted or you should not use the GET forms with this rewriter.

Implemented Interfaces:
LocationRewriter

See also:

Authors:
  • Dennis Popel

Methods:
  • decode()
    This method is called from Request::parseHTTP() method to decode the rewritten URLs as received from the remote user. This method should decode URLs only if the web server doesn't do this itself; owherwise this method can safely return the $_GET array.

    Note: this method is called for GET requests only as there is no way to rewrite POST requests
  • rewrite()
    This method will be called by the Location::toURL() to return the rewritten URL, as it will appear in the browser. This method should return the fully-qualified URL, including protocol, host port and path of the rewritten URL.
    Note: this method cannot call the Location::toURL() method; to retrieve the default URL of a location, the Location::rewrite() static method should be called instead.