You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Dave Morgan <dv...@telusplanet.net> on 2002/01/09 05:41:31 UTC

Sample Code for CGI initialization problem

Hi All,
	I have attached sample code that illustrates the problem

	Load COMMON.pm on startup, put html and cgi in proper places,
	configure to run the cgi as an Apache::Registry script.

	In a browser, load index html, fill out the fields and submit.
	Your input will not be echoed back

	Stop apache, remove the BEGIN block from COMMON.pm, restart, test.

	Input is now echoed back.

HTH
Dave

#######################################
package COMMON;

require Exporter;

use strict;

use CGI qw/:standard/;

our (@ISA, @EXPORT);

our ($USERID, $PASSWORD, $select_list);

@ISA	= qw(Exporter);
@EXPORT	= qw($USERID $PASSWORD $select_list);
	  
BEGIN{
	$select_list = scrolling_list(-name=>'TEST',
                                -values=>[1,2,3,4],
                                -default=>'1',
                                -size=> 1);
}

1;
# END
############################################
#login.cgi
#!/opt/bin/perl -T

use strict;

use CGI qw/:standard :cgi-lib/;
use COMMON;

# Get Form Values
$USERID			= param("USERID");
$PASSWORD               = param("PASSWORD"); 

print header;
print "$USERID, $PASSWORD";

#END
###############################################
#index.html
<html>
<BODY BGCOLOR="white">

<form action="/cgi-bin/login.cgi" method="POST">
<table BORDER="0" cellspacing="0" cellpadding="0" width="250">
<tr><td colspan="2" ><font size="2" FACE="helvetica,arial">
Login Name:
</td><td>
<input type="text" name="USERID" size="20" maxlength="20">
</td></tr>
<tr><td colspan="2" ><font size="2" FACE="helvetica,arial">
Password
</td><td>
<input type="password" name="PASSWORD" size="20" maxlength="20">
</td></tr>
<tr><td colspan="4" >
----------------------------------
</td></tr> 
<tr><td>
<input type="submit" value="Log in">
</td> <td colspan="2" ><font size="2" FACE="helvetica,arial">
Test
</td></tr></table>
</form>
</body>
</html>
#END


-- 
Dave Morgan
dvmrgn@telusplanet.net
403 399 2442

Re: Ip Address On Outbound

Posted by Luciano Miguel Ferreira Rocha <st...@nsk.yi.org>.
On Wed, Jan 09, 2002 at 12:27:12AM -0500, John Buwa wrote:
> How would i changed outgoing requests
> to reflect the invoking users ip and not my systems ip?

You can't just change the ip you use to connect to other systems...

But you may have some luck in using the Via: and X-Forwarded-For: headers:
GET / HTTP/1.0
Via: 1.0 agent.mydmn.net:3128 (Yet Another Agent/0.0.1.0a)
X-Forwarded-For: 192.168.0.1

Regards,
Luciano Rocha

-- 
Luciano Rocha, strange@nsk.yi.org

The trouble with computers is that they do what you tell them, not what
you want.
                -- D. Cohen

Re: Ip Address On Outbound

Posted by "Doran L. Barton" <fo...@iodynamics.com>.
Not long ago, John Buwa proclaimed...
> I havea question on outbound ips. I am writing a program that a user can
> enter an address and a spider will go and retrieve only the information that
> was request and then display the results to the enquiring user. My question
> is though, i have grabed the users ip address as the initiator of the
> request and i would like to use that ip address (The users) to send the http
> request instead of my systems addres. How would i changed outgoing requests
> to reflect the invoking users ip and not my systems ip?

Being as how the IP address is part of the TCP/IP protocols and not HTTP,
I can't see how Apache (or mod_perl) can do anything about that. You can't
spoof IPs at the application layer if you're doing network transactions.

-=Fozz

-- 
-------------------------------------------------------------------------
Doran L. Barton <fo...@iodynamics.com> - Chief Super Hero - Iodynamics LLC
< http://www.iodynamics.com/ > - Linux solutions and dynamic websites
 "Pepsi brings your ancestors back from the grave."
    -- 'Pepsi Comes Alive' as originally translated into Chinese

Ip Address On Outbound

Posted by John Buwa <jo...@tcpbbs.net>.
 Hello,

I havea question on outbound ips. I am writing a program that a user can
enter an address and a spider will go and retrieve only the information that
was request and then display the results to the enquiring user. My question
is though, i have grabed the users ip address as the initiator of the
request and i would like to use that ip address (The users) to send the http
request instead of my systems addres. How would i changed outgoing requests
to reflect the invoking users ip and not my systems ip?

Thanks in advance,
John