php code from plsql using owa htp.p

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • marvado@hotmail.com

    #1

    php code from plsql using owa htp.p

    Hi,

    can I run phpinfo(); or any php code from an oracle plsql package using

    htp.p from the oracle web toolkit owa?

    what I need is to run any php code using htp.p()
    I might be missing something, in my oracle/apache/php configuration I
    can only run flat .php files from /htdocs but can't run any php from a
    plsql procedure to display on a browser with htp.p


    anyone has ideas?

    thanks in advance,
    -- pedro.

  • Mark C. Stock

    #2
    Re: php code from plsql using owa htp.p


    <marvado@hotmai l.com> wrote in message
    news:1141167185 .093454.28210@j 33g2000cwa.goog legroups.com...
    : Hi,
    :
    : can I run phpinfo(); or any php code from an oracle plsql package using
    :
    : htp.p from the oracle web toolkit owa?
    :
    : what I need is to run any php code using htp.p()
    : I might be missing something, in my oracle/apache/php configuration I
    : can only run flat .php files from /htdocs but can't run any php from a
    : plsql procedure to display on a browser with htp.p
    :
    :
    : anyone has ideas?
    :
    : thanks in advance,
    : -- pedro.
    :

    i'll take a stab at it...

    php is server-side processing, and, in essence, so is mod_plsql (htp.p, et
    al)

    so the output from htp.p is not being furhter processed on the server, it is
    being streamed back to the user -- the same as if you generated PHP code
    from a PHP page ... it would go back to the user not to the server-side
    processor

    ++ mcs


    Comment

    • Maxim Demenko

      #3
      Re: php code from plsql using owa htp.p

      Mark C. Stock schrieb:[color=blue]
      > <marvado@hotmai l.com> wrote in message
      > news:1141167185 .093454.28210@j 33g2000cwa.goog legroups.com...
      > : Hi,
      > :
      > : can I run phpinfo(); or any php code from an oracle plsql package using
      > :
      > : htp.p from the oracle web toolkit owa?
      > :
      > : what I need is to run any php code using htp.p()
      > : I might be missing something, in my oracle/apache/php configuration I
      > : can only run flat .php files from /htdocs but can't run any php from a
      > : plsql procedure to display on a browser with htp.p
      > :
      > :
      > : anyone has ideas?
      > :
      > : thanks in advance,
      > : -- pedro.
      > :
      >
      > i'll take a stab at it...
      >
      > php is server-side processing, and, in essence, so is mod_plsql (htp.p, et
      > al)
      >
      > so the output from htp.p is not being furhter processed on the server, it is
      > being streamed back to the user -- the same as if you generated PHP code
      > from a PHP page ... it would go back to the user not to the server-side
      > processor
      >
      > ++ mcs
      >
      >[/color]

      Not being familiar with php, but the output of mod_plsql can be
      redirected via mod_external to php processor, so theoretically , if
      security restrictions could be disregarded, it should be possible...

      Best regards

      Maxim

      Comment

      • marvado@hotmail.com

        #4
        Re: php code from plsql using owa htp.p

        how exactly would I do that Max?

        Comment

        • Maxim Demenko

          #5
          Re: php code from plsql using owa htp.p

          marvado@hotmail .com schrieb:[color=blue]
          > how exactly would I do that Max?
          >[/color]

          I was most likely wrong with my suggestion,
          the idea was to run additional Apache (as proxy, because OHS comes
          without mod_ext_filter. so ) with mod_ext_filter and output filter
          defined as "/usr/local/bin/php" . I made some tests with another simple
          filter, such as sed - it seems to work with mod_plsql together, but in
          case of php - i got "No input file specified", which i don't know how to
          overcome.

          Best regards

          Maxim

          Comment

          • daust_de

            #6
            Re: php code from plsql using owa htp.p

            Hi Pedro,

            two other common approaches to incorporating output from technologies
            are:

            (1) using an IFRAME to call your PHP code using a different http
            request
            (2) using UTL_HTTP to call your PHP code from the backend and display
            the result using htp.p

            ~Dietmar.

            Comment

            • marvado@hotmail.com

              #7
              Re: php code from plsql using owa htp.p

              Hi Dietmar,

              thanks for the tip, but I'm using exactly UTL_HTTP for that with htp.p
              and it doesn't seem to be showing back the php result.
              This is what I have in a plsql package:

              begin
              htp.p('phpinfo( );');
              end;

              it gives me a blank page when I call the package from the browser. What
              I expect is to see the environment variables for PHP with the
              phpinfo(); function call.

              my setup:
              - oracle 9i
              - Oracle's HTTP Server with Apache 1.3
              - php 5

              anything I'm missing?
              thanks.

              Comment

              • Frank van Bortel

                #8
                Re: php code from plsql using owa htp.p

                marvado@hotmail .com wrote:[color=blue]
                > Hi Dietmar,
                >
                > thanks for the tip, but I'm using exactly UTL_HTTP for that with htp.p
                > and it doesn't seem to be showing back the php result.
                > This is what I have in a plsql package:
                >
                > begin
                > htp.p('phpinfo( );');
                > end;
                >
                > it gives me a blank page when I call the package from the browser. What
                > I expect is to see the environment variables for PHP with the
                > phpinfo(); function call.
                >
                > my setup:
                > - oracle 9i
                > - Oracle's HTTP Server with Apache 1.3
                > - php 5
                >
                > anything I'm missing?
                > thanks.
                >[/color]

                1) Your browser requests http://yourserver/plsql_dad/your_procedure
                2) Apache by Oracle recognizes the plsql_dad bit, and hands the request
                off to mod_plsql.
                3) mod_plsql has some login processing, define in the Database
                Access Descriptor (dad), but will eventually call your procedure.
                4) Your procedure sends the string phpinfo(); back to mod_plsql, that
                faithfully hands it off to Apache, that will send it back to your
                browser.
                5) Your browser does not understand phpinfo(); and displays a blank
                page. Hint: check page source

                What did *I* forget here? Do you understand the sequence of
                events above? If you do, you should be able to understand why
                you do not get what you expected.

                Now, as we already established, I know nothing about php, but it
                seems to me, that:
                1) Your browser needs to send phpinfo(); (not *receive* it)
                2) And it needs to be sent to the php environment, not the
                Oracle pl/sql stack.

                So, we're back at what was suggested before: link those two.
                --
                Regards,
                Frank van Bortel

                Top-posting is one way to shut me up...

                Comment

                • daust_de

                  #9
                  Re: php code from plsql using owa htp.p

                  Yep, something missing ;).

                  The following sample should get you started, I just picked a random
                  php-url from the web:

                  create or replace procedure test_utl_http is
                  req utl_http.req;
                  resp utl_http.resp;
                  value VARCHAR2(1024);
                  BEGIN
                  --utl_http.set_pr oxy('proxy.my-company.com', 'corp.my-company.com');

                  req :=
                  utl_http.begin_ request('http://www.yessoftware .com/products/product_detail. php?product_id= 1');
                  --utl_http.set_he ader(req, 'User-Agent', 'Mozilla/4.0');
                  resp := utl_http.get_re sponse(req);
                  LOOP
                  utl_http.read_l ine(resp, value, TRUE);
                  htp.p(value);
                  END LOOP;
                  utl_http.end_re sponse(resp);
                  EXCEPTION
                  WHEN utl_http.end_of _body THEN
                  utl_http.end_re sponse(resp);
                  END;
                  /
                  grant execute on test_utl_http to public
                  /


                  Do some research on UTL_HTTP and how to use it. There are plenty of
                  samples out there.

                  ~Dietmar.

                  Comment

                  • Jerry Stuckle

                    #10
                    Re: php code from plsql using owa htp.p

                    Frank van Bortel wrote:[color=blue]
                    > marvado@hotmail .com wrote:
                    >[color=green]
                    >>Hi Dietmar,
                    >>
                    >>thanks for the tip, but I'm using exactly UTL_HTTP for that with htp.p
                    >>and it doesn't seem to be showing back the php result.
                    >>This is what I have in a plsql package:
                    >>
                    >>begin
                    >> htp.p('phpinfo( );');
                    >>end;
                    >>
                    >>it gives me a blank page when I call the package from the browser. What
                    >>I expect is to see the environment variables for PHP with the
                    >>phpinfo(); function call.
                    >>
                    >>my setup:
                    >>- oracle 9i
                    >>- Oracle's HTTP Server with Apache 1.3
                    >>- php 5
                    >>
                    >>anything I'm missing?
                    >>thanks.
                    >>[/color]
                    >
                    >
                    > 1) Your browser requests http://yourserver/plsql_dad/your_procedure
                    > 2) Apache by Oracle recognizes the plsql_dad bit, and hands the request
                    > off to mod_plsql.
                    > 3) mod_plsql has some login processing, define in the Database
                    > Access Descriptor (dad), but will eventually call your procedure.
                    > 4) Your procedure sends the string phpinfo(); back to mod_plsql, that
                    > faithfully hands it off to Apache, that will send it back to your
                    > browser.
                    > 5) Your browser does not understand phpinfo(); and displays a blank
                    > page. Hint: check page source
                    >
                    > What did *I* forget here? Do you understand the sequence of
                    > events above? If you do, you should be able to understand why
                    > you do not get what you expected.
                    >
                    > Now, as we already established, I know nothing about php, but it
                    > seems to me, that:
                    > 1) Your browser needs to send phpinfo(); (not *receive* it)[/color]

                    PHP is a server-side language. The browser never sees the PHP code, and
                    cannot "send" phpinfo().
                    [color=blue]
                    > 2) And it needs to be sent to the php environment, not the
                    > Oracle pl/sql stack.
                    >[/color]

                    Yes. I'm not sure how to do it (I don't know mod_plsql) - but the code
                    needs to be processed throught the PHP parser as well as mod_plsql.
                    [color=blue]
                    > So, we're back at what was suggested before: link those two.[/color]


                    --
                    =============== ===
                    Remove the "x" from my email address
                    Jerry Stuckle
                    JDS Computer Training Corp.
                    jstucklex@attgl obal.net
                    =============== ===

                    Comment

                    • marvado@hotmail.com

                      #11
                      Re: php code from plsql using owa htp.p

                      well, that does the job presenting a php page, but the approach I'd
                      like to have is to code php right on the package and just have the
                      htp.p spitting out php, without the need to retrieve an existing php
                      flat file.

                      thanks again.

                      Comment

                      • daust_de

                        #12
                        Re: php code from plsql using owa htp.p

                        Well, how should this be possible?

                        This would mean that htp.p would have a PHP processor embedded, right?
                        This is not how web applications work.

                        Have you ever seen a Java servlet where you can just embed Perl syntax,
                        PHP or whatever other *server side* language?

                        You can only achieve this through another http request which is served
                        by a webserver/appserver running the request through the appropriate
                        engine to execute it.

                        ~Dietmar.

                        Comment

                        • Frank van Bortel

                          #13
                          Re: php code from plsql using owa htp.p

                          daust_de wrote:[color=blue]
                          > Yep, something missing ;).
                          >[/color]

                          You cheat :)
                          utp_http != htp.p

                          --
                          Regards,
                          Frank van Bortel

                          Top-posting is one way to shut me up...

                          Comment

                          • Gerard H. Pille

                            #14
                            Re: php code from plsql using owa htp.p

                            marvado@hotmail .com wrote:[color=blue]
                            > Hi,
                            >
                            > can I run phpinfo(); or any php code from an oracle plsql package using
                            >
                            > htp.p from the oracle web toolkit owa?
                            >
                            > what I need is to run any php code using htp.p()
                            > I might be missing something, in my oracle/apache/php configuration I
                            > can only run flat .php files from /htdocs but can't run any php from a
                            > plsql procedure to display on a browser with htp.p
                            >
                            >
                            > anyone has ideas?
                            >
                            > thanks in advance,
                            > -- pedro.
                            >[/color]
                            Would you mind telling us why you'd want to do that, Pedro?

                            Comment

                            • marvado@hotmail.com

                              #15
                              Re: php code from plsql using owa htp.p

                              it's a project from work, I have to migrate some of our php code to
                              plsql packages and centralize in plsql packages

                              Comment

                              Working...