Hi to all. I'm using this script. A visitor can select a file to download but he must also type a requested password.
This password is send to the visitor by email.
This is my download.pl:
#!/usr/local/bin/perl
# -------------
# Links
# -------------
# Links Manager
#
# File: downloads.pl
# Description: Lets a visitor select a file to download
# Author: Alex Krohn
# Email: alex@gossamer-threads.com
# Web: http://www.gossamer-threads.com/
# Version: 2.0
#
# (c) 1998 Gossamer Threads Inc.
#
# This script is not freeware! Please read the README for full details
# on registration and terms of use.
# =====================================================================
#
# Setup Notes:
# Make sure the require statement below points to the config file.
# Required Librariers
# --------------------------------------------------------
eval {
($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); # Get the script location: UNIX /
($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); # Get the script location: Windows \
require "c:/inetpub/wwwroot/cgi-bin/admin/download.conf";
require "c:/inetpub/wwwroot/cgi-bin/admin/links.cfg"; # Change this to full path to links.cfg if you have problems.
require "$db_lib_path/db_utils.pl";
require "$db_lib_path/links.def";
$build_use_templates ?
require "$db_lib_path/site_html_templates.pl" :
require "$db_lib_path/site_html.pl";
};
if ($@) {
print "Content-type: text/plain\n\n";
print "Error including libraries: $@\n";
print "Make sure they exist, permissions are set properly, and paths are set correctly.";
exit;
}
# ========================================================================================================
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/~!/ ~!/g;
$FORM{$name} = $value;}
if ($FORM{'source'} eq "Select One") {
print "Content-type:text/html\n\n";
print "You didn't choose from please select one...<p>\n";
}
if ($FORM{'pass'} eq $password) {
print "Content-type:text/html\n\n";
print "Correct password!<p>\n";
print "$send Password: $password - Formpass: $FORM{'pass'} - Source: $FORM{'source'} <p>\n"; #check strings
print "Location: $file\n\n"; #file automatically starts to download
exit;
}
else {
print "Content-type:text/html\n\n";
print "Invalid Password! Please hit back on on your browser and try again! $password";
}
########################################################################################################################
This is my download.conf:
%file=( 'Download1' , 'http://195.66.30.215/pages/downloads/download1.zip',
'Download2' , 'http://195.66.30.215/pages/downloads/download2.zip',
'Download3' , 'http://195.66.30.215/pages/downloads/download3.zip' );
$password = "test";
########################################################################################################################
and my download.html:
<form method="post" action="http://195.66.30.215/cgi-bin/download.pl">
<font size="2" face="Verdana,Arial,Helvetica" COLOR="#FF0000"><B>Please select the file to download:</b>
<INPUT type=hidden value="Select One"> <SELECT name="source"> <OPTION selected>Select
One<OPTION>Download1<OPTION>Download2<OPTION>Download3</OPTION></SELECT></p>
<font size="2" face="Verdana,Arial,Helvetica" COLOR="#FF0000"><B>Please type the requested password:</b>
<input type="password" name="pass" size="25"></p>
<input type="submit" value="Send"></br>
</form>
Thats All
This password is send to the visitor by email.
This is my download.pl:
#!/usr/local/bin/perl
# -------------
# Links
# -------------
# Links Manager
#
# File: downloads.pl
# Description: Lets a visitor select a file to download
# Author: Alex Krohn
# Email: alex@gossamer-threads.com
# Web: http://www.gossamer-threads.com/
# Version: 2.0
#
# (c) 1998 Gossamer Threads Inc.
#
# This script is not freeware! Please read the README for full details
# on registration and terms of use.
# =====================================================================
#
# Setup Notes:
# Make sure the require statement below points to the config file.
# Required Librariers
# --------------------------------------------------------
eval {
($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); # Get the script location: UNIX /
($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); # Get the script location: Windows \
require "c:/inetpub/wwwroot/cgi-bin/admin/download.conf";
require "c:/inetpub/wwwroot/cgi-bin/admin/links.cfg"; # Change this to full path to links.cfg if you have problems.
require "$db_lib_path/db_utils.pl";
require "$db_lib_path/links.def";
$build_use_templates ?
require "$db_lib_path/site_html_templates.pl" :
require "$db_lib_path/site_html.pl";
};
if ($@) {
print "Content-type: text/plain\n\n";
print "Error including libraries: $@\n";
print "Make sure they exist, permissions are set properly, and paths are set correctly.";
exit;
}
# ========================================================================================================
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/~!/ ~!/g;
$FORM{$name} = $value;}
if ($FORM{'source'} eq "Select One") {
print "Content-type:text/html\n\n";
print "You didn't choose from please select one...<p>\n";
}
if ($FORM{'pass'} eq $password) {
print "Content-type:text/html\n\n";
print "Correct password!<p>\n";
print "$send Password: $password - Formpass: $FORM{'pass'} - Source: $FORM{'source'} <p>\n"; #check strings
print "Location: $file\n\n"; #file automatically starts to download
exit;
}
else {
print "Content-type:text/html\n\n";
print "Invalid Password! Please hit back on on your browser and try again! $password";
}
########################################################################################################################
This is my download.conf:
%file=( 'Download1' , 'http://195.66.30.215/pages/downloads/download1.zip',
'Download2' , 'http://195.66.30.215/pages/downloads/download2.zip',
'Download3' , 'http://195.66.30.215/pages/downloads/download3.zip' );
$password = "test";
########################################################################################################################
and my download.html:
<form method="post" action="http://195.66.30.215/cgi-bin/download.pl">
<font size="2" face="Verdana,Arial,Helvetica" COLOR="#FF0000"><B>Please select the file to download:</b>
<INPUT type=hidden value="Select One"> <SELECT name="source"> <OPTION selected>Select
One<OPTION>Download1<OPTION>Download2<OPTION>Download3</OPTION></SELECT></p>
<font size="2" face="Verdana,Arial,Helvetica" COLOR="#FF0000"><B>Please type the requested password:</b>
<input type="password" name="pass" size="25"></p>
<input type="submit" value="Send"></br>
</form>
Thats All