⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newuser.cgi

📁 上传网站信息
💻 CGI
字号:
#!/usr/bin/perl 


eval {
	require "variables.pl";
};

if ($@) {
	print "Content-type: text/html\n\n";
	&header;
print <<EOF;
A Fatal Error has occurred in the running of Top Sites.
<BR><BR>
Something is wrong with your variables.pl file. Please look carefully at the error
listed below and double check the settings in the variables.pl file.<BR><BR>
The error is:
<BR><font color=red>
$@</FONT>
<BR><BR>
EOF
	&error_footer("error_variables.shtml");

exit;
}

$version ="2.01";

print "Content-type: text/html\n\n";

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;
	if ($fields{$name}) { $fields{$name} = $fields{$name}.",".$value; }
	else { $fields{$name} = $value; }
}

unless ($ENV{'CONTENT_LENGTH'}) {
&header;

print <<EOF;
<center>
<font size=2><B>请填写下面的表格加入 $topsite_name</B></FONT>
<BR>
<FORM METHOD="POST" ACTION="newuser.cgi">
<table cellspacing =0 bgcolor =white border=0 cellpadding =5>
<TR><TD>
<FONT SIZE="-1" FACE="Verdana">网站名称</TD><TD>&nbsp;&nbsp;&nbsp;<INPUT TYPE="text" NAME="name" ></TD> </TR>
<TR><TD>
<FONT SIZE="-1" FACE="Verdana">网址</TD><TD>&nbsp;&nbsp;&nbsp;<INPUT TYPE="text" NAME="url" ></TD></TR>
<TR><TD>
<FONT SIZE="-1" FACE="Verdana">您的Email</TD><TD>&nbsp;&nbsp;&nbsp;<INPUT TYPE="text" NAME="email" ></TD></TR>
<TR><TD>
<FONT SIZE="-1" FACE="Verdana">您网站的图标(468*60)</TD><TD>&nbsp;&nbsp;&nbsp;<INPUT TYPE="text" NAME="banner"></TD></TR> 
<TR><TD colspan=2 align=center>
<input type=submit value="  加入 $topsite_name  "></TD></TR> 
</TABLE><BR></form><br>
EOF
&footer;
exit;

}


unless ($fields{'url'}=~/\http:/) { 
	$error_url =1;	
}
unless ($fields{'email'}=~/\@/) { 
	$error_email =1;
}
unless ($fields{'name'}) { 
	$error_name =1;
}

if ($error_email || $error_url || $error_name) {

&header;

print "<B>Errors have been detected in your sign up form.</B><br><br>\n";
print "Please go back and fix the following:<BR><font color=red>\n";
if ($error_name) {
	print "You must enter a name for your web site<br>";
}
if ($error_email) {
	print "Invalid email address: $fields{'email'}<br>";
}
if ($error_url) {
	print "Invalid website url: $fields{'url'}<br>";
}

print "</FONT><BR><BR>";
&footer;
exit;

}

open (ID,"counts.txt");
if ($use_flock) {
	flock ID, 2; 
}
$new_id = <ID> ;
$new_id++;
close (ID);

open (NEWID,">counts.txt") || &error(1);
if ($use_flock) {
	flock NEWID, 2; 
}
print NEWID "$new_id";
close (NEWID);

$newline = join ("\|",0,0,0,$fields{'url'},$fields{'banner'},$fields{'name'},$fields{'email'},0,0,$new_id);
$newline .= "\n";

open(DB, ">>members.db") || &error(2);
if ($use_flock) {
	flock DB, 2; 
}
print DB $newline;
close (DB);

$code = "<A HREF=\"$topsite_location_cgi/topsites.cgi?ID=$new_id\">\n";
$code .= "<IMG SRC=\"$topsite_image\" border=0 width=$image_width height=$image_height></A>\n";

$html_code = $code;
$html_code =~ s/</\&lt\;/g;
$html_code =~ s/>/\&gt\;/g;
$html_code =~ s/\n//g;

&header;
print <<EOF;
<center><font size=2><B>谢谢您加入 $topsite_name</B></FONT><BR><BR></CENTER>
您想把你的网站显示在此排行榜上,需要完成以下三步.<BR><BR>
<font color=red>1.</FONT> 把下面的 html 代码放在您的网页上.以获得更前的排名.<BR><BR>
<font color=blue>
$html_code
</FONT>
<BR><BR>
<font color=red>2.</FONT> 排行榜的图标将在您的网站上显示,
点击此图标系统将记录你一次访问,您的排名将提升.
<BR><BR>
<font color=red>3.</font> 更多的人将通过本排行榜访问到你的网站,增加您的访问量!
<a href="$topsite_location/topsites.html"><B>按此看最新排行>>></B></A> 希望你网站访问量急升....
<BR><BR>
如有任何问题请来信:<a href="mailto:$your_email"><B>$your_email</B></a>
<BR><BR>
EOF
&footer;

if ($mail_prog) {
	open(MAIL,"|$mail_prog -t") || &error(3);
	print MAIL "To: $fields{'email'}\n";
	print MAIL "From: $your_email\n";
	print MAIL "Subject: 欢迎您加入 $topsite_name \n\n";
	print MAIL "Thank you for submitting your site to $topsite_name \n\n";
	print MAIL "请您把下面这段html代码加入您的网页以启动您加入本排行榜:\n\n";
	print MAIL "$code\n";
	print MAIL "Once this has been done, click on the image that appears to activate your account.\n\n";
	print MAIL "You site will then be included in $topsite_name in the next update\n\n";
	print MAIL "View the $topsite_name rankings at $topsite_location/topsites.html \n\n";
	print MAIL "Created with Top Sites v2.01 http://solutionscripts.com\n\n;汉化[轩辕工作室]http://www.21xyz.com";
	print MAIL "\n\n";
	close (MAIL);
}
exit;


sub error{

$errors = $_[0] ;
&header;
if ($errors == 1) {
print <<EOF;
<b>An error has occured trying to write/create to counts.txt</B><BR><BR>
More information on the problem:<BR>
<font color=red>$!</FONT>
<BR><BR>

EOF
	&error_footer("wc_counts.shtml");
}
elsif ($errors == 2) {
print <<EOF;
<b>An error has occured trying to write/create the file members.db</B><BR><BR>
More information on the problem:<BR>
<font color=red>$!</FONT>
<BR><BR>

EOF
	&error_footer("wc_members.shtml");
}
elsif ($errors == 3) {
print <<EOF;
<b>An error has occured trying to send out the welcome email</B><BR><BR>
More information on the problem:<BR>
<font color=red>$!</FONT>
<BR><BR>

EOF
	&error_footer("mail_prog.shtml");
}
exit;
}

sub header {
print <<EOF;
<HTML><HEAD>
<TITLE>Top Sites -- From Solution Scripts</TITLE></HEAD>
<BODY bgcolor=white text=black link=slateblue vlink=slateblue>
<CENTER>
<TABLE CELLPADDING=2 CELLSPACING=0 BORDER=0 BGCOLOR=#778899 WIDTH=500>
<TR><TD>
<TABLE CELLPADDING=8 CELLSPACING=0 WIDTH=100\% BGCOLOR=white BORDER=0><TR><TD>
<font face="Verdana" size="1">
EOF
}

sub error_footer {
$error_url = $_[0];
print <<EOF;
If you need more assistance, come take a look at our online manual. The frontpage
of the manual can be found at:<BR>
<a href="http://solutionscripts.com/man/top_sites"><B>http://solutionscripts.com/man/top_sites</B></A><BR><BR>
or you jump straight to the page containing more information on your error at:
<a href="http://solutionscripts.com/man/top_sites/$error_url"><B>http://solutionscripts.com/man/top_sites/$error_url</B></A>
<BR><BR>We also host a Help Forum where people can come and ask questions about Solution Scripts' scripts and
questions they are having about them. The url for the Help Forum is:<BR>
<a href="http://solutionscripts.com/forum"><B>http://solutionscripts.com/forum</B></A><BR><BR>
Who knows, someone might have the posted the same question you have and the answer might already be there.
<BR><BR><HR NOSHADE SIZE=1>
<CENTER>
Top Sites, created by <a href="http://solutionscripts.com"><B>Solution Scripts</B></A><BR>
"Enhancing the web with cgi"<BR>
</TD></TR></TABLE>
</TD></TR></TABLE>
EOF
}

sub footer {
$error_url = $_[0];
print <<EOF;
<HR NOSHADE SIZE=1>
<CENTER>
Top Sites v$version, created by <a href="http://solutionscripts.com"><B>Solution Scripts</B></A><BR>
"Enhancing the web with cgi"<BR>
</TD></TR></TABLE>
</TD></TR></TABLE>
</BODY></HTML>
EOF
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -