TonysDesigns
03-14-2006, 04:41 AM
Hey people. I currently use a perl script for our contact us form page(seen below). The use from this script comes from an HTML page. I am interested in passing the user's IP address to our form that is emailed to us when the user hits submit. In other words, how can I display the user's Ip address on the "thanks page" AND pass it to our mail we receive?
Here is the code:
#!/usr/bin/perl
use Cwd;
$cgipath='/www1/makeuptalk.com/cgi-bin';
$ftproot=GetFTPRoot($cgipath);
SetIncludePath($cgipath);
require 'municacgi.cgi';
$scripturl="http://$ENV{'SERVER_NAME'}$ENV{'SCRIPT_NAME'}";
$m_pos=rindex($scripturl, "/");
$cgiurl=substr($scripturl, 0, $m_pos);
$cgipath='/www1/makeuptalk.com/cgi-bin';
$ftproot=GetFTPRoot($cgipath);
$cgipath=FTP2System($cgipath);
$WWW_APPNAME="FormPAL";
$_str_valid="Email=EMAIL&";
ParseForm();
if (defined($FORM{'Submit'})||($FORM{'Trigger'}[0] eq "Submit"))
{
ValidateForm($_str_valid);
SendMail("Action1", "@{$FORM{'First Name'}}", "@{$FORM{'Email'}}", "EMAILADDYHERE", $cc, $subject, "@{$FORM{'Subject'}}", "", "");
PostUrl("Action2", 0, "", "http://www.makeuptalk.com/contact/thanks.php");
exit(0);
}
Info();
sub SetIncludePath
{
my($m_cgipath)=shift;
$m_cgipath="$ftproot/$m_cgipath" if ($m_cgipath =~ /^\//);
$m_cgipath=~ s/\\/\//g;
$m_cgipath=~ s/(\/)+/\//g;
pop(@INC);
push(@INC, $_) if ($_ ne '.');
push(@INC, "$m_cgipath");
push(@INC, ".");
$cc = qw(EMAILADDYHERE);
$subject = qw(From_MakeupTalk_Contact_Us_page);
}
sub GetCGIPath
{
my ($m_cgipath)=shift;
my ($m_cwd);
if ($ENV{'PATH_TRANSLATED'} ne "")
{
$m_cwd=$ENV{'PATH_TRANSLATED'};
$m_pos=rindex($m_cwd, "/");
$m_pos=rindex($m_cwd, "\\") if ($m_pos<0);
$m_cwd=substr($m_cwd, 0, $m_pos);
}elsif ($ENV{'SCRIPT_FILENAME'} ne "")
{
$m_cwd=$ENV{'SCRIPT_FILENAME'};
$m_pos=rindex($m_cwd, "/");
$m_pos=rindex($m_cwd, "\\") if ($m_pos<0);
$m_cwd=substr($m_cwd, 0, $m_pos);
}else
{
$m_cwd=getcwd();
}
$m_cwd=~ s/\\/\//g;
$m_cwd=~ s/(\/)+/\//g;
return $m_cwd;
}
sub GetFTPRoot
{
my ($m_cgipath)=shift;
my ($m_cwd);
$m_cwd=GetCGIPath();
$m_cgipath=~ s/(\/)+/\//g;
$m_pos=rindex($m_cgipath, "/");
$m_pos=rindex($m_cgipath, "\\") if ($m_pos<0);
$m_cgipath=substr($m_cgipath, 0, $m_pos) if ($m_pos==(length($m_cgipath)-1));
if (length($m_cgipath)>=length($m_cwd))
{
return "";
}elsif ($m_cwd=~/($m_cgipath)$/)
{
return $`;
}elsif ($m_cwd=~/($m_cgipath)\//)
{
return $`;
}else
{
return $m_cwd;
}
}
Many Thanks
Here is the code:
#!/usr/bin/perl
use Cwd;
$cgipath='/www1/makeuptalk.com/cgi-bin';
$ftproot=GetFTPRoot($cgipath);
SetIncludePath($cgipath);
require 'municacgi.cgi';
$scripturl="http://$ENV{'SERVER_NAME'}$ENV{'SCRIPT_NAME'}";
$m_pos=rindex($scripturl, "/");
$cgiurl=substr($scripturl, 0, $m_pos);
$cgipath='/www1/makeuptalk.com/cgi-bin';
$ftproot=GetFTPRoot($cgipath);
$cgipath=FTP2System($cgipath);
$WWW_APPNAME="FormPAL";
$_str_valid="Email=EMAIL&";
ParseForm();
if (defined($FORM{'Submit'})||($FORM{'Trigger'}[0] eq "Submit"))
{
ValidateForm($_str_valid);
SendMail("Action1", "@{$FORM{'First Name'}}", "@{$FORM{'Email'}}", "EMAILADDYHERE", $cc, $subject, "@{$FORM{'Subject'}}", "", "");
PostUrl("Action2", 0, "", "http://www.makeuptalk.com/contact/thanks.php");
exit(0);
}
Info();
sub SetIncludePath
{
my($m_cgipath)=shift;
$m_cgipath="$ftproot/$m_cgipath" if ($m_cgipath =~ /^\//);
$m_cgipath=~ s/\\/\//g;
$m_cgipath=~ s/(\/)+/\//g;
pop(@INC);
push(@INC, $_) if ($_ ne '.');
push(@INC, "$m_cgipath");
push(@INC, ".");
$cc = qw(EMAILADDYHERE);
$subject = qw(From_MakeupTalk_Contact_Us_page);
}
sub GetCGIPath
{
my ($m_cgipath)=shift;
my ($m_cwd);
if ($ENV{'PATH_TRANSLATED'} ne "")
{
$m_cwd=$ENV{'PATH_TRANSLATED'};
$m_pos=rindex($m_cwd, "/");
$m_pos=rindex($m_cwd, "\\") if ($m_pos<0);
$m_cwd=substr($m_cwd, 0, $m_pos);
}elsif ($ENV{'SCRIPT_FILENAME'} ne "")
{
$m_cwd=$ENV{'SCRIPT_FILENAME'};
$m_pos=rindex($m_cwd, "/");
$m_pos=rindex($m_cwd, "\\") if ($m_pos<0);
$m_cwd=substr($m_cwd, 0, $m_pos);
}else
{
$m_cwd=getcwd();
}
$m_cwd=~ s/\\/\//g;
$m_cwd=~ s/(\/)+/\//g;
return $m_cwd;
}
sub GetFTPRoot
{
my ($m_cgipath)=shift;
my ($m_cwd);
$m_cwd=GetCGIPath();
$m_cgipath=~ s/(\/)+/\//g;
$m_pos=rindex($m_cgipath, "/");
$m_pos=rindex($m_cgipath, "\\") if ($m_pos<0);
$m_cgipath=substr($m_cgipath, 0, $m_pos) if ($m_pos==(length($m_cgipath)-1));
if (length($m_cgipath)>=length($m_cwd))
{
return "";
}elsif ($m_cwd=~/($m_cgipath)$/)
{
return $`;
}elsif ($m_cwd=~/($m_cgipath)\//)
{
return $`;
}else
{
return $m_cwd;
}
}
Many Thanks