Does PHP have anything like Java/JSP "filters" or Zope's acquisition?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Soefara

    Does PHP have anything like Java/JSP "filters" or Zope's acquisition?

    What I'd like to have a request to, say, http://www.mydomain.com/Aaaa/Bbbb/Cccc

    be handled by http://www.mydomain.com/Aaaa/index.php

    but with the "Bbbb" and "Cccc" stored in a request variable or attribute.
    This becomes very very useful when building multi-lingual websites.

    This can be done in JSP/servlets using 'filters' and it is
    provided in Zope through 'acquisition'.

    Is there any way of making this happen with PHP ?

    Thank you very much,

    Soefara
  • Pedro Graca

    #2
    Re: Does PHP have anything like Java/JSP "filters&q uot; or Zope's acquisition?

    Soefara wrote:[color=blue]
    > What I'd like to have a request to, say, http://www.mydomain.com/Aaaa/Bbbb/Cccc
    >
    > be handled by http://www.mydomain.com/Aaaa/index.php
    >
    > but with the "Bbbb" and "Cccc" stored in a request variable or attribute.
    > This becomes very very useful when building multi-lingual websites.[/color]
    [color=blue]
    > Is there any way of making this happen with PHP ?[/color]

    I do that with Apache's ErrorDocument

    0. Be sure Apache AllowOverride is set to include FileInfo
    1. Create Directory "Aaaa"
    2. Create an .htaccess there with
    ErrorDocument 404 /Aaaa/index.php
    3. Create /Aaaa/index.php as (for example):
    <?php
    echo $_SERVER['REQUEST_URI'];
    ?>
    4. Go to http://www.mydomain.com/Aaaa/Bbbb/Cccc

    5. and see the resulting page:
    /Aaaa/Bbbb/Cccc

    HTH
    --
    USENET would be a better place if everybody read: : mail address :
    http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
    http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
    http://www.expita.com/nomime.html : to 10K bytes :

    Comment

    • Soefara

      #3
      Re: Does PHP have anything like Java/JSP &quot;filters&q uot; or Zope's acquisition?

      Wow, that's a really interesting hack, Pedro :)

      I've never seen people actually use .htaccess and ErrorDocument
      to filter requests like that. Thanks for sharing this - it looks
      like it will do what I want :)

      Soefara

      [color=blue]
      > I do that with Apache's ErrorDocument
      >
      > 0. Be sure Apache AllowOverride is set to include FileInfo
      > 1. Create Directory "Aaaa"
      > 2. Create an .htaccess there with
      > ErrorDocument 404 /Aaaa/index.php
      > 3. Create /Aaaa/index.php as (for example):
      > <?php
      > echo $_SERVER['REQUEST_URI'];
      > ?>
      > 4. Go to http://www.mydomain.com/Aaaa/Bbbb/Cccc
      >
      > 5. and see the resulting page:
      > /Aaaa/Bbbb/Cccc
      >
      > HTH[/color]

      Comment

      • Henk Verhoeven

        #4
        Re: Does PHP have anything like Java/JSP &quot;filters&q uot; or Zope's acquisition?

        Hi Soefara,

        We also use a .htaccess trick to get the requests to our index.php script:

        RewriteEngine on
        RewriteRule ^index_php/(.*) index.php?$1

        (this requires your internet provider to make a setting to allow url
        rewriting).

        But down from index php we use request handlers, which are objects, much
        like servlets, only we create a new request handler for each request (In
        Java, servlets may be reused, of even handle multiple requests at the
        same time). In combination with request forwarding request handlers can
        act like filters: For example, this is how our website's
        LicenseAgreemen tAction reacts to accepting the the license agreement
        before downloading:

        function doAgreed()
        {
        $this->useClass('Menu ', 'beheer');
        $forwardData = array(
        'pntType' => 'Menu',
        'id' => Menu::getDownlo adMenuId(),
        'download' => $this->requestData['download'],
        'pntHandler' => 'WebStartDownlo adPage'
        );
        $this->forwardRequest ($forwardData, 'agreed');
        }

        This creates an instance of the class WebStartDownloa dPage and forwards
        the requestData. The page then produces the output that starts the
        download. As you can see it creates new requestData for forwarding
        (makes the page show the download menu), only 'download' is copied from
        the original requestData.

        Greetings,

        Henk Verhoeven,
        www.phpPeanuts.org.


        Soefara wrote:
        [color=blue]
        > Wow, that's a really interesting hack, Pedro :)
        >
        > I've never seen people actually use .htaccess and ErrorDocument
        > to filter requests like that. Thanks for sharing this - it looks
        > like it will do what I want :)
        >
        > Soefara
        >
        >
        >[color=green]
        >>I do that with Apache's ErrorDocument
        >>
        >>0. Be sure Apache AllowOverride is set to include FileInfo
        >>1. Create Directory "Aaaa"
        >>2. Create an .htaccess there with
        >> ErrorDocument 404 /Aaaa/index.php
        >>3. Create /Aaaa/index.php as (for example):
        >> <?php
        >> echo $_SERVER['REQUEST_URI'];
        >> ?>
        >>4. Go to http://www.mydomain.com/Aaaa/Bbbb/Cccc
        >>
        >>5. and see the resulting page:
        >> /Aaaa/Bbbb/Cccc
        >>
        >>HTH[/color][/color]

        Comment

        Working...