免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1621 | 回复: 1
打印 上一主题 下一主题

请大家帮我看一下啊 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-09-26 03:09 |只看该作者 |倒序浏览
各位高手请帮我解释一下下面的 东东啊 THANKS
#!/usr/bin/perl

$WEBLEN = 8;
require "ctime2.pl";
chop($date = &ctime(time));

$method = $ENV{"REQUEST_METHOD"};
$type = $ENV{"CONTENT_TYPE"};
$ipaddr = $ENV{"REMOTE_ADDR"};

if($method eq "GET" {
&system_error("lease press the BACK button on your browser and try again.";
exit;
}
if($method ne "OST" || $type ne "application/x-www-form-urlencoded" {
&system_error("Web authorization code must come from a form!\n";
exit;
}
%input_values = &break_input;
$number = &normalize_query($input_values{"number"});
$trans = &normalize_query($input_values{"trans"});
$sub = &normalize_query($input_values{"sub"});
$email = &normalize_query($input_values{"email"});
$code = &normalize_query($input_values{"code"});
$ptype = &normalize_query($input_values{"type"});
$data = &normalize_query($input_values{"data"});
$cost = &normalize_query($input_values{"cost"});
$site = &normalize_query($input_values{"site"});

$oordir = "/export/home/$code";
$logfile = "$oordir/signup.log";
$timelimt = "$oordir/timelim.log";
$htpasswd = "$oordir/newuser";
$userlist = "$oordir/users";
$maillog = "/dev/null";
$hours = "0";

if($ptype eq "web" {
$webfile = "/export/home/lovejungle/web$data.data";
if($data eq "1" { $hours = "24"; }
if($data eq "30" { $hours = "720"; }
if($data eq "90" { $hours = "2160"; }
# if($data eq "180" { $hours = "4320"; }
} else {
$webfile = "$oordir/credit$data.data";
}

if(length($number) != 7) {
&system_error("Sorry, that is not a valid number.\n";
exit;
}
unless(open(WEB,"+<$webfile")) {
&system_error("Could not open web data file $webfile.\n");
exit;
}
seek(WEB, 0, 0);
unless(open(WLOG,">;>;$logfile")) {
&system_error("Could not open log file $logfile.\n");
exit;
}
unless(open(TLOG,">;>;$timelimt")) {
&system_error("Could not open time limit file $timelim.\n");
exit;
}

$goodbad = 0;
SEARCH:
for ($recnum = 0; read(WEB, $goodnum, $WEBLEN); $recnum++) {
$goodnum =~ tr/0-9//cd;
if($number eq $goodnum) {
$goodbad = 1;
if($ptype eq "web") {
seek(TLOG, 0, 2);
print (TLOG $number, " $hours\n");
seek(WLOG, 0, 2);
print (WLOG $cost," ", $date, " ", $number, " ", $email, "\n");
} else {
seek(WLOG, 0, 2);
print (WLOG $cost," ", $date, " ", $number, " Sub # ", $sub," Trans # ", $trans,"\n");
}
(open(SALES,">;>; /home/david/newsales.txt") && (print SALES "$cost\n") && close(SALES)) || die("!Sales\n");
(open(MAIL,">;>; $maillog") && (print MAIL "$email\n") && close(MAIL)) || die("Unable to open $maillog");
$encrypted_passwd = &encrypt_passwd($number,$number);
(open(PASSWD,">;>; $userlist") && (print PASSWD "$numberencrypted_passwd\n") && close(PASSWD)) || die("Unable to open users!\n");
seek(WEB, -$WEBLEN, 1);
$goodnum =~ tr/0-9/x/;
print WEB $goodnum;
last SEARCH;
}
seek(WEB, $recnum*$WEBLEN, 0);
}
close(WEB);
close(WLOG);
close(TLOG);
chmod(0666, $logfile);
if($goodbad != 1) {
print "Content-type: text/html\n\n";
print "\n";
print "\n";
print "\n";
print "ACCESS DENIED!\n";
print "\n"; print "\n"; print "There has been an error in the set-up of your account. Either you entered an invalid\n"; print "IN or there was an error processing your credit card transaction. Please send "; print "e-mail to our service department\n"; print "with as much information about your membership as possible.\n"; print "Your IP address ($ipaddr) has been recorded, along with this attempt\n"; print "to create an account. Continued failed attempts will result in your entire\n"; print "domain being blocked from this site automatically.\n"; print " \n";
} else {
print "Content-type: text/html\n\n";
print "\n";
print "\n";
print "\n";
print "ACCOUNT CREATED!\n";
print "\n"; print "\n"; print "Your membership has been created and you can now login to the site. Please note\n"; print "that only one person is allowed to use this account at a time. Multiple\n"; print "logins from different domains will result in your account being automatically suspended!\n"; print "Questions or problems should be sent to "; print "tina\@$site.com\n"; print "Be sure to bookmark the next page to re-enter the site!\n"; print "\n"; print "http://www.$site.com/members/\n"; print ""; print " \n";
print "ENTER HERE\n";
print " Your username is $number\n";
print "Your password is $number \n";
print "\n";
}
exit;

##
## SUBROUTINES
##

sub break_input {
local ($i);
read(STDIN,$input,$ENV{'CONTENT_LENGTH'});
@form_names = split('&',$input);
foreach $i(@form_names) {
($html_name,$html_value) = split('=',$i);
$input_values{$html_name} = $html_value;
}
return %input_values;
}

sub system_error {
local($errmsg) = @_;
&print_header("System Error");
print $errmsg;
&print_footer;
}

sub print_header {
local($title) = @_;
print "Content-type: text/html\n\n";
print "\n";
print "\n";
print "\n";
print "\n";
print "\n";
print "$title\n";
}

sub print_footer {
print "\n";
print "\n";
}

sub encrypt_passwd {
local($user,$pass)=@_;
local($nslat,$week,$now,$pert1,$pert2);
local(@salt_set)=('a'..'z','A'..'Z','0'..'9','.','/'); $now=time;
($pert1,$per2) = unpack("C2",$user);
$week = $now / (60*60*24*7) + $pert1 + $pert2;
$nsalt = $salt_set[$week % 64] . $salt_set[$now %64];
return crypt($pass,$nsalt);
}

sub normalize_query {
local($value) = @_;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
return $value;
}

sub send_file {
local($file) = @_;
unless(open(FILE,$file)) {
&system_error("Failed to open file $file\n");
exit;
}
print "Content-type: text/html\n\n";
while () {
print;
}
close(FILE);
}

论坛徽章:
0
2 [报告]
发表于 2003-09-26 09:57 |只看该作者

请大家帮我看一下啊

从头到尾都解释一遍么??  
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP