Simulating an automatic post in PHP

Collins Richey crichey
Thu Jun 15 17:58:48 PDT 2006


On 6/14/06, Man-wai CHANG <mwchang at i-cable.com> wrote:
>
> I called the script directly by:
>
> http://server/haha.php?ip=192.168.1.1
>
> And the script entered an endless loop. What's wrong with it?
>
>
> --
>   .~.    http://changmw.homeip.net
>  / v \   May the Force and Farce be with you! Linux 2.6.16.20
> /( _ )\  (Ubuntu 6.06)  10:58:01 up 8 days 20:41
>   ^ ^    1 user load average: 1.10 1.04 1.01
> news://news.3home.net news://news.hkpcug.org news://news.newsgroup.com.hk
>
>
> <html><head></head>
> <body onload=document.myform.submit()>
> <?php
>
> function getLocationCaidaNetGeo($ip)
> {
>         $NetGeoURL = "http://netgeo.caida.org/perl/netgeo.cgi?target=".$ip;
>         if($NetGeoFP = fopen($NetGeoURL,r))
>         {
>                 ob_start();
>                 fpassthru($NetGeoFP);
>                 $NetGeoHTML = ob_get_contents();
>                 ob_end_clean();
>                 fclose($NetGeoFP);
>         }
>         return $NetGeoHTML;
> }
>
> if ($HTTP_POST_VARS['btnsubmit']) {
>                 print_r(getLocationCaidaNetGeo($_POST['ip']));
>         } else {
> ?>
> <form method="post" enctype="multipart/form-data" name="myform" action="<?php echo($PHP_SELF); ?>">
> <input type="text" name="ip">
> <input type="submit" name="btnsubmit" action="submit">
> </form>
> <?php
> }
> ?>
> </body></html>
>

Unless you're using a much older PHP, post variables are now in the
$_POST array, ie $_POST['btnsubmit']. That's all I can see at first
glance.

-- 
Collins Richey
     If you fill your heart with regrets of yesterday and the worries
     of tomorrow, you have no today to be thankful for.



More information about the Linux-users mailing list