This is a discussion on PHP as web proxy ? within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi, I need to use a PHP app as a sort of a web proxy To be more specific: I ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi,
I need to use a PHP app as a sort of a web proxy To be more specific: I have a mailserver with own web server and web interface. What want it to be able to dynamically change its output pages (but I cannot interface directly PHP with its web browser) So, suppose the web mail server runs on http://www.webserver.com and I have my site at http://www.myphpserver.com What I need is user to connect to http://www.myphpserver.com/webserver/index.htm, and when my PHP webserver receive this request, it will request the page from http://www.webserver.com/index.htm. Then it will make some processing on the returned HTML page (like changing CSS, adding banners, rewrite form's Action parameter, etc), and will return this page to client. When client will post a page (like clicking on a submit button), my php page will receive it, and pass it to original action URL together with all POST-ed data Any thoughts how t do this? Thanks, Bogdan |
|
|||
|
Bogdan Zamfir wrote:
> > So, suppose the web mail server runs on > > http://www.webserver.com > > and I have my site at > > http://www.myphpserver.com > > What I need is user to connect to > http://www.myphpserver.com/webserver/index.htm, and when my PHP webserver > receive this request, it will request the page from > http://www.webserver.com/index.htm. Then it will make some processing on > the returned HTML page (like changing CSS, adding banners, rewrite form's > Action parameter, etc), and will return this page to client. > err... something like: $replace=array('GET'); $with=array('POST'); foreach($_POST as $name=>$val) { $params.=$name . '=' . urlencode($val) . '&'; } $params=substring($params,0,-1); $in=file_get_contents("http://www.webserver.com/index.htm?$params"); $out=preg_replace($replace,$with,$in); print $out; If you want to POST to the back-end, you'll need a lot more code. HTH C. |
|
|||
|
"Colin McKinnon" <colin.deletethis@andthis.mms3.com> wrote in message news:cdnuh7$okq$1$8302bc10@news.demon.co.uk... > Bogdan Zamfir wrote: > > > > So, suppose the web mail server runs on > > > > http://www.webserver.com > > > > and I have my site at > > > > http://www.myphpserver.com > > > > What I need is user to connect to > > http://www.myphpserver.com/webserver/index.htm, and when my PHP webserver > > receive this request, it will request the page from > > http://www.webserver.com/index.htm. Then it will make some processing on > > the returned HTML page (like changing CSS, adding banners, rewrite form's > > Action parameter, etc), and will return this page to client. > > > err... something like: > > $replace=array('GET'); > $with=array('POST'); > > foreach($_POST as $name=>$val) { > $params.=$name . '=' . urlencode($val) . '&'; > } > $params=substring($params,0,-1); > $in=file_get_contents("http://www.webserver.com/index.htm?$params"); > $out=preg_replace($replace,$with,$in); > print $out; > > If you want to POST to the back-end, you'll need a lot more code. Not really, with a recent version of PHP. Now you can do HTTP posts fairly easily with the help of stream_context_create(). And there's no need to loop through $_POST and reencode the form input. A simple file_get_contents("php://input") will get you want you need. |