Hello all, I hope this is the right place to write about this. I've been
trying now for quite some time to integrate php into my non-apache server
(completely c++ written by me). Right now I have it working partially using
the CLI. My application generates a shell script when a .php page is
requested and executes it through p_open so I can pipe standard output back
to the user that requested it. The script generated looks something exactly
like:
#!/bin/bash
cd /path/to/server/ant/httpd/phpBB2/

export REQUEST_METHOD="GET"
export SCRIPT_NAME="/phpBB2/index.php"
export SERVER_NAME="localhost:5555"
export SERVER_PORT="5555"
export REMOTE_ADDR="127.0.0.1"
export DOCUMENT_ROOT="/path/to/server/ant/httpd"
export DOCUMENT_URI="/phpBB2/index.php"
export DOCUMENT_NAME="index.php"
export SERVER_PROTOCOL="HTTP/1.1"
export SERVER_SOFTWARE="ANT-1.0"
export GATEWAY_INTERFACE="CGI/1.1"
export HTTP_USER_AGENT="User-Agent: Mozilla/5.0 (X11; U; Linux x86_64;
en-US; rv:1.7.8) Gecko/20050524 Fedora/1.0.4-4 Firefox/1.0.4 "
export HTTP_ACCEPT="text/xml,application/xml,application/xhtml
xml,text/html;q 0.9,text/plain;q=0.8,image/png,*/*;q=0.5"
export HTTP_ACCEPT_LANGUAGE="en-us,en;q 0.5"
export HTTP_ACCEPT_CHARSET="ISO-8859-1,utf-8;q 0.7,*;q=0.7"
export HTTP_ACCEPT_ENCODING="gzip,deflate"
php -f /path/to/server/ant/httpd/phpBB2/index.php
cd /path/to/server/ant/
export > ExportsAfterScript

with path/to/server/ant being automatically generated by "pwd", and httpd
being inserted as the base httpd directory. 


I tried doing it this way, because this seems to be how CGI scripts work
(from what I could gather from the tons of documents I've tried reading on
the web), so I figured maybe this would work, of course it doesn't. I also
read cgi scripts may export values to the enviorment after it finish's so I
thought php might too, which is why export > ExportsAfterScript is there.

This method works fine and dandy for simple scripts like <?php Print "Hello
World\n"?> or whatever that is, but it doesn't work with a little more
advanced things like phpBB.

Now I'm wondering, can I simply link the library in at compile time, do a
#include <php.h>, create a structure with all the exported data and pass it
to a function in php? Can anyone provide me with some pointers like, the
object I need to create, the function I need to call to get parse a file 


This is what I'm looking for (general psuedo to pass the idea):
{
#include <php.h>
void runPhP(HttpdUserObject *userobject, char *file, size_t &filesize) {
   struct phpHeader header = CreateHeaderFrom(userobject); 
   char *result = PHPProc(file, filesize, header);
   struct phpResultHeader headerback = PHPResultHeader();
   Send_To_User(userobject, headerback, result);
   free(result);
   return;
}; // and call that from my file loading routines if a .php extension is
found?
and something like: In makefile.am add -lphp and -i/usr/include/php-X/
}
Any help would be greatly appreciated, thanks!

Matthew Adams

http://www.sf.net/projects/ante

---------------------------------
Long live free and open software!

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to