flat assembler
Message board for the users of flat assembler.

Index > Heap > PHP.exe, how to integrate it into web server

Author
Thread Post new topic Reply to topic
sleepsleep



Joined: 05 Oct 2006
Posts: 8902
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
i always wonder how to integrate the PHP functionality into a self-created web server.
Post 10 Mar 2008, 04:19
View user's profile Send private message Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6034
Location: Poland
MHajduk
I suppose that for integration PHP script interpreter with your server you could use for example php4ts.dll library (I have this one on my local computer). Search the net to find newer versions of PHP engine DLLs.
Post 10 Mar 2008, 08:29
View user's profile Send private message Visit poster's website Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav
what web-server you want to use? there're good manual inside php package
Post 10 Mar 2008, 13:32
View user's profile Send private message Reply with quote
drhowarddrfine



Joined: 10 Jul 2007
Posts: 535
drhowarddrfine
When a browser requests a PHP page, it opens the script file and starts reading the first few characters. The first line points to the path to the interpreter program. Then the server calls the interpreter, passing along the args for the PHP file and lets the interpreter do its thing. The interpreter sends the output to standard output which, in turn, should be sending things to the server.
Post 10 Mar 2008, 16:26
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
drhowarddrfine: umm, .php files don't keep the path-to-interpreter, that's what shell scripts do.

PHP can generally be included in your web server in two ways: either as an in-process parser (mod_php for apache, for instance), or by invoking an external php instance... the second approach is pretty slow (process creation overhead etc.), so there's a "2b" option - FastCGI.
Post 11 Mar 2008, 00:37
View user's profile Send private message Visit poster's website Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 8902
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
i been spending some hours yesterday and today,
studying his code.

Charlotte: A Simple Web Server for Microsoft Windows
http://www.acm.org/crossroads/xrds6-4/charlotte.html

and to my astonishment, it doesn't looks so hard to code a usable http server Razz
and u know, i don't really into C++ garbage collector sort of.
so, i convert his code to use plain C only. the compiler i use is TCC.

i attached with my unfinished C code. (it is around 40% something *should be)
then some ideas struck me.

why don't we just modulizing everything?
let say.
eg. we let users (coders) to send a pointer to modify watever they want to change. eg. if they want to customize the void OutputError( const char *emsg ) or void httpRequestHandler( CINFO *pci ) , so they just register their pointer into this server variable then, all call to it will passes to them.

maybe it is more like fastcgi, idk, perhaps i need to try a little bit coding to test.


Description: AServer C source file.
Download
Filename: aserver.txt
Filesize: 4.89 KB
Downloaded: 239 Time(s)

Post 07 Aug 2009, 22:33
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
sleepsleep: C++ garbage collector? which kinds of mushrooms have you been eating? Smile

Writing a simple HTTP server can be done pretty easily. Writing a usable daemon requires a lot more code. Writing something that scales to a lot of connections... good luck Wink

Why use TCC and get suboptimal output, btw? Either use a proper C compiler or write in assembly.
Post 07 Aug 2009, 22:38
View user's profile Send private message Visit poster's website Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 8902
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
hehe

i was thinking something like this.

if let say, when my webserver running. and let say user wanna change the pointer of function httpRequestHandler to call his own coded one.

he would do something like this.

eg. he browser http://localhost/SYSTEM!!PID=HIS_APPLICATION_PROCESS_ID&FUNC=httpRequestHandler&VAL=2348732432

so, i mean, passing information through http, and when server detected such request, server would check the validity of process id, then act accordingly.

we could add another layer of security for preventing people wildguess and bruteforce, by, let the user supplying a pointer for 1 function that we will try to call for verify.

hmm, it shouldn't be hard, maybe i will try to code it.

and now i wonder,
why they don't use web server (like middle man) to function like windows api message system?

eg. to start notepad.
u just need to http://localhost!SYSTEM!NOTEPAD.exe
or copy/delete file
http://localhost!SYSTEM!DELETE!C:\ntldr (evil)
Post 07 Aug 2009, 23:03
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1288
Location: behind the arc
Picnic
sleepsleep wrote:
i been spending some hours yesterday and today,
studying his code.

Charlotte: A Simple Web Server for Microsoft Windows
http://www.acm.org/crossroads/xrds6-4/charlotte.html

Nice little server Charlotte is.
I have also spend some hours studying the code and tried a Fasm re-wrote.
My -near to final- code looked so similar to the original C++ version that i asked myself 'Hell, why i did that for...', and drop it, too much cinvoke, too lazy not to use cinvoke Laughing

sleepsleep take a look at Fire web server written in C++, it's more advanced than Charlotte in about 500 code lines. Article - Code
Post 21 Aug 2009, 11:33
View user's profile Send private message Reply with quote
drhowarddrfine



Joined: 10 Jul 2007
Posts: 535
drhowarddrfine
f0dder wrote:
drhowarddrfine: umm, .php files don't keep the path-to-interpreter, that's what shell scripts do.
umm, that's what I was referring to by "it".
Post 21 Aug 2009, 11:50
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
drhowarddrfine wrote:
f0dder wrote:
drhowarddrfine: umm, .php files don't keep the path-to-interpreter, that's what shell scripts do.
umm, that's what I was referring to by "it".
Umm, come again?

drhowarddrfine wrote:
When a browser requests a PHP page, it opens the script file and starts reading the first few characters. The first line points to the path to the interpreter program. Then the server calls the interpreter, passing along the args for the PHP file and lets the interpreter do its thing. The interpreter sends the output to standard output which, in turn, should be sending things to the server.

.php files != shell scripts. (theoretically you could use them that way, but why would you?)

_________________
Image - carpe noctem
Post 21 Aug 2009, 12:02
View user's profile Send private message Visit poster's website Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1160
Azu
Look up "httpdASM". It supports PHP via ISAPI. I forget who made it, sorry. It's in FASM and is open source, though. Pretty basic but should teach you everything you need to know about integrating PHP.
Post 21 Aug 2009, 15:55
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
It's not written in FASM syntax, it's written in MASM syntax. It even says so in the readme:
wrote:

As its name suggests httpdASM is written in ASM (MASM syntax).

_________________
----> * <---- My star, won HERE
Post 21 Aug 2009, 16:36
View user's profile Send private message Reply with quote
drhowarddrfine



Joined: 10 Jul 2007
Posts: 535
drhowarddrfine
f0dder wrote:

.php files != shell scripts.
Oops. Yep. My mistake. Not that I didn't know but I wasn't thinking.
Post 22 Aug 2009, 00:00
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1160
Azu
windwakr wrote:
It's not written in FASM syntax, it's written in MASM syntax. It even says so in the readme:
wrote:

As its name suggests httpdASM is written in ASM (MASM syntax).
Oops, sorry. It's still closer than C though.. ^^
Post 22 Aug 2009, 03:04
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
Why do people use MASM, it's one of the worst assemblers out there Confused
Post 22 Aug 2009, 15:19
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 8902
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
Quote:

Look up "httpdASM". It supports PHP via ISAPI. I forget who made it, sorry. It's in FASM and is open source, though. Pretty basic but should teach you everything you need to know about integrating PHP.

thanks.!!! been searching for something like that for decades.
Post 22 Aug 2009, 17:19
View user's profile Send private message Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1160
Azu
Borsuc wrote:
Why do people use MASM, it's one of the worst assemblers out there Confused
Because Microsoft pushes it.


sleepsleep wrote:
Quote:

Look up "httpdASM". It supports PHP via ISAPI. I forget who made it, sorry. It's in FASM and is open source, though. Pretty basic but should teach you everything you need to know about integrating PHP.

thanks.!!! been searching for something like that for decades.
Smile
Post 23 Aug 2009, 00:07
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 8902
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
i found this,
Mongoose web server (not for WOW)
simple, lite and MIT license.

http://code.google.com/p/mongoose/
Post 11 Jan 2010, 18:15
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 8902
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 334455
sleepsleep
when i trying use it (mongoose), it fails me.
sigh.
Post 12 Jan 2010, 00:04
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.