PHP as web proxy ?

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 ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-21-2004
Bogdan Zamfir
 
Posts: n/a
Default PHP as web proxy ?

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


Reply With Quote
  #2 (permalink)  
Old 07-22-2004
Colin McKinnon
 
Posts: n/a
Default Re: PHP as web proxy ?

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.
Reply With Quote
  #3 (permalink)  
Old 07-23-2004
Chung Leong
 
Posts: n/a
Default Re: PHP as web proxy ?


"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.


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:37 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0