Home > Archive > PHP Language > July 2004 > PHP as web proxy ?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
PHP as web proxy ?
|
|
| Bogdan Zamfir 2004-07-21, 3:56 pm |
| 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
| |
| Colin McKinnon 2004-07-22, 8:55 am |
| 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.
| |
| Chung Leong 2004-07-23, 3:55 am |
|
"Colin McKinnon" <colin.deletethis@andthis.mms3.com> wrote in message
news:cdnuh7$okq$1$8302bc10@news.demon.co.uk...
> Bogdan Zamfir wrote:
webserver[color=darkred]
form's[color=darkred]
> 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.
|
|
|
|
|