📄 rand_text.cgi
字号:
#!/usr/bin/perl
####################################################
##########################
# Random Text Version 1.0
#
# Copyright 1996 Matt Wright
mattw@worldwidemart.com #
# Created 7/13/96 Last Modified
7/13/96 #
# Scripts Archive at:
http://www.worldwidemart.com/scripts/ #
####################################################
##########################
# COPYRIGHT NOTICE
#
# Copyright 1996 Matthew M. Wright All Rights
Reserved. #
#
#
# Random Text may be used and modified free of
charge by anyone so long as #
# this copyright notice and the comments above
remain intact. By using this #
# code you agree to indemnify Matthew M. Wright from
any liability that #
# might arise from it's use.
#
#
#
# Selling the code for this program without prior
written consent is #
# expressly forbidden. In other words, please ask
first before you try and #
# make money off of my program.
#
#
#
# Obtain permission before redistributing this
software over the Internet or #
# in any other medium. In all cases copyright and
header must remain intact #
####################################################
##########################
####################################################
##########################
# 文字转换器 版本 1.0
#
####################################################
##########################
# COPYRIGHT NOTICE
#
# Copyright 1996 Matthew M. Wright All Rights
Reserved. #
#
#
# 此版本为作者 Matthew M. Wright 所有,
#
# 不得做销售用途。为方便中文使用者,太阳黑子已获作者
请准, #
# 得以翻译留言簿作非商业用途。
#
#
#
# 请网友使用时勿删除以上著作权申明
#
# 讨论区位於 http://cgiperl.asits.net/bbs/, 欢迎网友
们踊跃讨论。 #
####################################################
##########################
#
#
# 太阳黑子 CGI 网路教学
#
# http://cgiperl.asits.net
#
#
#
# CGI 权限开放, 10MB 空间, 加入会员只 NT999 一年。
#
# http://999.asits.net/~会员帐号
#
#
#
####################################################
##########################
# Define Variables 变数设定
#
$random_file = "/myweb/cgi-bin/random.txt"; #文字内容转换档的绝对路
径
$delimiter = "\n\%\%\n";
# Done 设定完成
#
####################################################
##########################
# Open the file containing phrases and read it in.
open(FILE,"$random_file") ||
&error('open->random_file',$random_file);
@FILE = <FILE>;
close(FILE);
# Join these lines from the file into one large
string.
$phrases = join('',@FILE);
# Now split the large string according to the
$delimiter.
@phrases = split(/$delimiter/,$phrases);
# Invoke srand; with a seed of the time and pid. If
you are on a machine
# which doesn't put the pid into $$ (ie. Macintosh,
Win NT, etc...), change
# this line to: srand(time ^ 22/7);
srand(time ^ $$);
# Now pluck our random phrase out of the @phrases
array! But wait! This
# only returns a number.
$phrase = rand(@phrases);
# Print out the Content-type header, so the browser
knows what's going on.
print "Content-type: text/html\n\n";
# Change this number into the text we want to return
and print it!
print $phrases[$phrase];
# All Done!
exit;
# Was there an error? If so, let's report that
sucker so it can get fixed!
sub error {
($error,$file) = @_;
print <<"END_ERROR";
Content-type: text/html
<html>
<head>
<title>错误: 无法开启文字内容转换档</title>
</head>
<body bgcolor=#FFFFFF text=#000000>
<center>
<h1>错误: 无发开启文字内容转换档</h1>
</center>
无法开启 \$random_file 内的档案<p>
END_ERROR
if (-e $random_file) {
print "发现档案存在, 唯不能读取, 必
<B>chmod 744 \$random_file</B>\n";
}
else {
print "查无此档案, 请确定 \$trrandom_file 内
的档案\n";
}
exit;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -