5

Does somebody know how to send data to the PHP CGI executable directly and how to receive it (stdin/stdout)?
Or point me to a useful resource?
In a side project (just for fun) I try to implement the interface on NodeJS so I could process PHP through ExpressJS (long story).
I've been able to send and receive stuff, but the PHP CGI always tells me that I am "not allowed" to use this interface...
Docs/mailinglists seem reeeally old and don't want to go through the Apache source code 😅
Or does Node not have enough privileges for communicatig with PHP CGI exe?

Comments
  • 0
    @linuxxx are you familiar with this?
  • 1
    You’re weird. I like you like that.
  • 2
    @C0D4 @AleCx04 this feels like something you'd muck with
  • 4
    I haven't mucked with cgi mode since the early days, long lost relic in my books.

    I can have a dig around and see if I can get it working.

    @AleCx04 or maybe even @linuxxx might have some more recent exposure but I'm doubtful.
  • 1
    @PonySlaystation Not really but I'm intrigued now 😄
  • 1
  • 2
    I can think of a couple of ways of doing this, all thanks to the amazing amount of "you should not be doing that".fuckery.php that the language lets us do.

    Is your data being sent through http ($_GET, $_POST)? we might be able to work with that, mind you, I cannot possibly imagine someone wanting to fuck with that stream of data for anything real since it involves fucking directly with the stdin output of said requests through the php-cgi executable. It will also require some configuration, since the php-cgi by default only lets you process get requests.
  • 0
    @sbiewald Thx! It looks like I have some serious work to do 😄

    @AleCx04 Yeah, some stackoverflow meantioned to not be doing this too, but you can't hold me back 😄
  • 1
    Using cgi means that you have to convert headers to env vars before you execute the cgi i guess. Php-cgi will split it up to the $_SERVER & $_GET globals i guess. Maybe it's even better to use the not cgi version? `Php -i` > get the stuff?

    I would do this personally: run an rpc or queue in another docker container. Or just post the code to execute and Eval it. Probably fast because it doesn't have to boot the executable every time. Can do some fpm stuff
Add Comment