📄 setup.pl
字号:
$cgipath="."; ##绝对路径 (如果是apache,则无须修改,如果是iis,则可能需要修改)
$WebDir="./gbook.cgi"; ##设置主文件 (不能修改)
$imagepath="$cgipath/images"; ##设置图片路径(不能修改)
$password="wubin"; #管理员密码
$topinfo=""; #设置第一页的欢迎信息
$pageview=8; #设置每页显示多少个留言
############################以下不能修改##################################
$Cookie_Exp_Date = '';#此处设置cookie的有效时间
$Cookie_Path = '';#此处设置cookie的有效路径,默认脚本存在的目录。
$Cookie_Domain = ''; #此处设置cookie的有效域名,默认脚本调用的域名。
$Secure_Cookie = '0';
@Cookie_Encode_Chars = ('\%', '\+', '\;', '\,', '\=', '\&', '\:\:', '\s');
%Cookie_Encode_Chars = ('\%', '%25',
'\+', '%2B',
'\;', '%3B',
'\,', '%2C',
'\=', '%3D',
'\&', '%26',
'\:\:', '%3A%3A',
'\s', '+');# 特殊字符的解码
@Cookie_Decode_Chars = ('\+', '\%3A\%3A', '\%26', '\%3D', '\%2C', '\%3B', '\%2B', '\%25');
%Cookie_Decode_Chars = ('\+', ' ',
'\%3A\%3A', '::',
'\%26', '&',
'\%3D', '=',
'\%2C', ',',
'\%3B', ';',
'\%2B', '+',
'\%25', '%');# 特殊字符的解码
#########获取cookie信息子程序#####################
sub GetCookies {
local(@ReturnCookies) = @_;
local($cookie_flag) = 0;
local($cookie,$value);
if ($ENV{'HTTP_COOKIE'}) {
if ($ReturnCookies[0] ne '') {
foreach (split(/; /,$ENV{'HTTP_COOKIE'})) {#分割HTTP_COOKIE变量的字符串
($cookie,$value) = split(/=/);
foreach $char (@Cookie_Decode_Chars) {
$cookie =~ s/$char/$Cookie_Decode_Chars{$char}/g;#调用转码函数
$value =~ s/$char/$Cookie_Decode_Chars{$char}/g;#调用转码函数
}
foreach $ReturnCookie (@ReturnCookies) {
if ($ReturnCookie eq $cookie) {
$Cookies{$cookie} = $value;
$cookie_flag = "1";
}
}
}
}
else {
foreach (split(/; /,$ENV{'HTTP_COOKIE'})) {
($cookie,$value) = split(/=/);
foreach $char (@Cookie_Decode_Chars) {
$cookie =~ s/$char/$Cookie_Decode_Chars{$char}/g;
$value =~ s/$char/$Cookie_Decode_Chars{$char}/g;
}
$Cookies{$cookie} = $value;
}
$cookie_flag = 1;
}
}
return $cookie_flag;
}
########## 设置Cookie信息子程序#######################
sub SetCookies {
local(@cookies) = @_;
local($cookie,$value,$char);
while( ($cookie,$value) = @cookies ) {
foreach $char (@Cookie_Encode_Chars) {
$cookie =~ s/$char/$Cookie_Encode_Chars{$char}/g;#调用转码函数
$value =~ s/$char/$Cookie_Encode_Chars{$char}/g;#调用转码函数
}
print 'Set-Cookie: ' . $cookie . '=' . $value . ';';#设置cookie值
if ($Cookie_Exp_Date) { print ' expires=' . $Cookie_Exp_Date . ';'; }#设置有效时间
if ($Cookie_Path) { print ' path=' . $Cookie_Path . ';'; }#设置有效路径
if ($Cookie_Domain) { print ' domain=' . $Cookie_Domain . ';'; }#设置有效域名
if ($Secure_Cookie) { print ' secure'; }
print "\n";
shift(@cookies); shift(@cookies);
}
}
sub getform
{
if ($ENV{'REQUEST_METHOD'} eq "POST")
{
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
}
else
{
$buffer = $ENV{'QUERY_STRING'};
}
@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/<!--(.|\n)*-->//g;
$value =~ s/\|//g;
$value =~ s/>/>/g;
$value =~ s/</</g;
$in{$name} = $value;
}
}
sub check #对注册信息的检查,不能含有影响程序运行的字符
{unless (($username=~/^\w{1,10}$/)&&($userpassword=~/^\w{4,10}$/)&&($userpasswd1=~/^\w{4,10}$/)) {&error ("username and password only are made of letter and number,and less than 10,bigger than 4.");}
if ($useraddress =~/=|\&|\#|\+|\/|\\|\^|\$|\%/) {&error ("all inputting data can't have wrong character");}
if ($userphone =~/=|\&|\#|\+|\/|\\|\^|\$|\%/) {&error ("all inputting data can't have wrong character");}
if ($userturename=~/=|\&|\#|\+|\/|\\|\^|\$|\%/) {&error ("all inputting data can't have wrong character");}
if ($userlike =~/=|\&|\#|\+|\/|\\|\^|\$|\%/) {&error ("all inputting data can't have wrong character");}
if ($userfrom =~/=|\&|\#|\+|\/|\\|\^|\$|\%/) {&error ("all inputting data can't have wrong character");}
if ($useroicq =~/=|\&|\#|\+|\/|\\|\^|\$|\%/) {&error ("all inputting data can't have wrong character");}
if ($usersex =~/=|\&|\#|\+|\/|\\|\^|\$|\%/) {&error ("all inputting data can't have wrong character");}
unless(($username)&&($userpassword)&&($userpasswd1)&&($useremail)&&($userphone)&&($userturename)&&($useraddress)){
&error ("Please fill in full,thank you!");}
if ($userpassword ne $userpasswd1){&error ("sorry,different password,please rewrite。thank you!");}
if ($useremail =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ || $useremail !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) {&error ("sorry,e-mail format error,please rewrite,thank you!");}
if (-e "$cgipath/data/$username.dat"){&error ("sorry,$username already registered,please rewrite,thank you!");}
}
sub error
{ print "Content-type: text/html\n\n";
print <<EOF;
<html><head><title>error</title></head><body>
EOF
print @_;
print <<HTML;
<br>
<p align="center">【<a href="javascript:history.go(-1);">BACK</a>】</p>
</body></html>
HTML
exit;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -