Running PHP in custom www server app

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

    Running PHP in custom www server app

    We are developing a (Win32) C++ application which among other things is
    able to generate some HTML pages and send them to an HTML client (in the
    same app actually). Now for more flexibility we would like to filter the
    generated pages through PHP. What should be the best/easiest way to
    proceed? I would like to avoid any temporary files as much as possible.

    1. Use _popen or CreateProcess to launch PHP-CGI.EXE, feed the input file
    in stdin and capture stdout. I'm afraid this will create nasty black
    windows on the screen.

    2. Include <php.h> etc and call php_execute_scr ipt() et al directly (are
    these documented somewhere?). Seems to be very file/stream-oriented, I
    would like string-in, string-out instead.

    3. Install php ActiveScript support and call it via COM interface. Seems
    to be the cleanest approach, but how to do it in C++? Any examples?

    4. ...?

    Also, what possibilities are there to pass data to php? Again, I would
    like to avoid temporary files. Possibly to inject variable/array creation
    PHP code directly in the passed script text?

    thanks in advance
    Paavo

  • Nikolai Chuvakhin

    #2
    Re: Running PHP in custom www server app

    Paavo Helde <nospam@ebi.e e> wrote in message
    news:<Xns956367 777B802paavo256 @194.126.101.12 4>...[color=blue]
    >
    > We are developing a (Win32) C++ application which among other things is
    > able to generate some HTML pages and send them to an HTML client (in the
    > same app actually). Now for more flexibility we would like to filter the
    > generated pages through PHP.[/color]

    Please clarify what you are referring to as "filtering" pages through
    PHP. It sounds like you want to generate PHP code to be executed, but
    I am not sure...

    Also, you forgot to mention what HTTP server you are using... PHP can
    be deployed on a variety of servers, quite often in more than one way
    (CGI binary vs. module on Apache, CGI executable vs. ISAPI module on
    IIS)...
    [color=blue]
    > What should be the best/easiest way to proceed?[/color]

    Assuming you want to generate (and then run) PHP code, the easiest way
    would be to pass a chunk of PHP code via POST to this simple snippet:

    <?php
    eval($_POST['code']);
    ?>

    Obviously, you may want to implement some security checks (i.e., send
    additional data to be used for authentication) .

    Cheers,
    NC

    Comment

    • Paavo Helde

      #3
      Re: Running PHP in custom www server app

      nc@iname.com (Nikolai Chuvakhin) wrote in message news:<32d7a63c. 0409131438.7ae3 4af6@posting.go ogle.com>...[color=blue]
      > Paavo Helde <nospam@ebi.e e> wrote in message
      > news:<Xns956367 777B802paavo256 @194.126.101.12 4>...[color=green]
      > >
      > > We are developing a (Win32) C++ application which among other things is
      > > able to generate some HTML pages and send them to an HTML client (in the
      > > same app actually). Now for more flexibility we would like to filter the
      > > generated pages through PHP.[/color]
      >
      > Please clarify what you are referring to as "filtering" pages through
      > PHP. It sounds like you want to generate PHP code to be executed, but
      > I am not sure...
      >
      > Also, you forgot to mention what HTTP server you are using... PHP can
      > be deployed on a variety of servers, quite often in more than one way
      > (CGI binary vs. module on Apache, CGI executable vs. ISAPI module on
      > IIS)...[/color]

      Sorry if I was unclear. There is no HTTP server, nor can we make use
      of one as the app will be distributed to end users who don't have it
      anyway.

      Instead, our app itself acts as a HTTP server. It listens on some port
      and provides HTML pages for the CHtmlView controls sitting in the same
      app. It's quite easy as there is (almost) no question of security,
      transaction speed, support of n+1 protocols, etc. However, now has
      arisen a need to add PHP support to our "server"...

      Regards
      Paavo

      Comment

      • Nikolai Chuvakhin

        #4
        Re: Running PHP in custom www server app

        paavo@ebi.ee (Paavo Helde) wrote in message
        news:<a5df4b39. 0409142254.7a5e 5902@posting.go ogle.com>...[color=blue]
        >
        > Sorry if I was unclear. There is no HTTP server, nor can we make use
        > of one as the app will be distributed to end users who don't have it
        > anyway.[/color]

        Oh, I see. In this case, you need to use the command-line interpreter,
        which does not require an HTTP server. You can pipe output of your
        application to the command-line interpreter's STDIN and receive the
        output via STDOUT.

        For more information, read The Manual:

        PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.


        Cheers,
        NC

        Comment

        Working...