小
小雨哥
Unregistered / Unconfirmed
GUEST, unregistred user!
#!c:/Program Files/Apache Group/Perl/bin/perl
use strict;
use CGI qwall);
use Fcntl qwflock);
#信息文件存放位置和文件
my $gbdata="C:/Program Files/Apache Group/MsgBook.txt";
#临时文件,可以是任意的文件名
my $semaphore_file="C:/Program Files/Apache Group/BookMsg.sem";
#加锁
sub get_lock{
open(SEM,">$semaphore_file")
|| die "无法存入文件:$!";
flock SEM,LOCK_EX;
}
#解锁
sub release_lock {
close(SEM);
}
sub save {
get_lock();
open(GB,">>$gbdata")|| die "无法打开文件 $gbdata:$!";
print GB "姓名:",param('name'),"/n";
print GB "类型:",param('probtype'),"/n";
print GB "内容:",param('problem'),"/n";
close(GB);
release_lock();
}
#显示(你的问题
sub display{
# print "<html>","/n";
# print "<head>","/n";
# print '<meta http-equiv="Content-Type" content="text/html;
charset=gb2312">',"/n";
# print "<title>结果</title>","/n";
# print "</head>";
# print "<body>","/n";
## print header;
open(GB,$gbdata) || die "不能打开 $gbdata:$!";
while(<GB>){
print "<B>$_</B><BR>";
my($type,$prob);
$type=<GB>;
$prob=<GB>;
print "$type<BR>";
print "$prob<BR><HR size=1 color=#0000FF><P>";
}
close(GB);
# print "</body>","/n";
# print "</html>";
}
#显示表头
print header;
if (defined param('submit')){
save;
display;
} else
{
display;
}
############### FORM.HTML ###############
#<div align="center">
# <center>
# <table border="0" height="306" width="343">
# <tr>
# <td width="19" height="16"> </td>
# <td width="304" height="16"> </td>
# <td width="23" height="16"> </td>
# </tr>
# <tr>
# <td width="19" height="16"> </td>
# <td width="304" height="16"> </td>
# <td width="23" height="16"> </td>
# </tr>
# <tr>
# <td width="19" height="16"> </td>
# <td width="304" height="16">
# <p align="center">你遇到问题了?</p>
# </td>
# <td width="23" height="16"> </td>
# </tr>
# <tr>
# <td width="19" height="212"> </td>
# <td width="304" height="212">
# <FORM action="script/Msgbook.cgi" name="Msgbook">
#问题类型:
#<INPUT TYPE=radio name=probtype value=硬件方面>硬件
#<INPUT TYPE=radio name=probtype value=软件方面>软件
#<INPUT TYPE=radio name=probtype value=其它方面>其它
#<BR>
#<TEXTAREA name=problem rows=5 cols=40>
#</TEXTAREA><BR>
#你的名字:
#<INPUT TYPE=text width=40 name=name><BR>
#<p align="center">
#<INPUT TYPE=submit name=submit value="发送问题">
#</FORM>
# </td>
# <td width="23" height="212"> </td>
# <tr>
# <td width="19" height="16"> </td>
# <td width="304" height="16"> </td>
# <td width="23" height="16"> </td>
# </tr>
# </table></div>
程序正常执行,但语言测试始终为:Charset=ISO-8859-1,显示为乱码,需要手工从浏览器
端改变编码才能看懂。我反复试验都不能完成,查 Apache 的配置文件,根本也没有 ISO-8859-1
的语言配置,它是从哪里来的?如果知道,请告诉我,谢谢。
use strict;
use CGI qwall);
use Fcntl qwflock);
#信息文件存放位置和文件
my $gbdata="C:/Program Files/Apache Group/MsgBook.txt";
#临时文件,可以是任意的文件名
my $semaphore_file="C:/Program Files/Apache Group/BookMsg.sem";
#加锁
sub get_lock{
open(SEM,">$semaphore_file")
|| die "无法存入文件:$!";
flock SEM,LOCK_EX;
}
#解锁
sub release_lock {
close(SEM);
}
sub save {
get_lock();
open(GB,">>$gbdata")|| die "无法打开文件 $gbdata:$!";
print GB "姓名:",param('name'),"/n";
print GB "类型:",param('probtype'),"/n";
print GB "内容:",param('problem'),"/n";
close(GB);
release_lock();
}
#显示(你的问题
sub display{
# print "<html>","/n";
# print "<head>","/n";
# print '<meta http-equiv="Content-Type" content="text/html;
charset=gb2312">',"/n";
# print "<title>结果</title>","/n";
# print "</head>";
# print "<body>","/n";
## print header;
open(GB,$gbdata) || die "不能打开 $gbdata:$!";
while(<GB>){
print "<B>$_</B><BR>";
my($type,$prob);
$type=<GB>;
$prob=<GB>;
print "$type<BR>";
print "$prob<BR><HR size=1 color=#0000FF><P>";
}
close(GB);
# print "</body>","/n";
# print "</html>";
}
#显示表头
print header;
if (defined param('submit')){
save;
display;
} else
{
display;
}
############### FORM.HTML ###############
#<div align="center">
# <center>
# <table border="0" height="306" width="343">
# <tr>
# <td width="19" height="16"> </td>
# <td width="304" height="16"> </td>
# <td width="23" height="16"> </td>
# </tr>
# <tr>
# <td width="19" height="16"> </td>
# <td width="304" height="16"> </td>
# <td width="23" height="16"> </td>
# </tr>
# <tr>
# <td width="19" height="16"> </td>
# <td width="304" height="16">
# <p align="center">你遇到问题了?</p>
# </td>
# <td width="23" height="16"> </td>
# </tr>
# <tr>
# <td width="19" height="212"> </td>
# <td width="304" height="212">
# <FORM action="script/Msgbook.cgi" name="Msgbook">
#问题类型:
#<INPUT TYPE=radio name=probtype value=硬件方面>硬件
#<INPUT TYPE=radio name=probtype value=软件方面>软件
#<INPUT TYPE=radio name=probtype value=其它方面>其它
#<BR>
#<TEXTAREA name=problem rows=5 cols=40>
#</TEXTAREA><BR>
#你的名字:
#<INPUT TYPE=text width=40 name=name><BR>
#<p align="center">
#<INPUT TYPE=submit name=submit value="发送问题">
#</FORM>
# </td>
# <td width="23" height="212"> </td>
# <tr>
# <td width="19" height="16"> </td>
# <td width="304" height="16"> </td>
# <td width="23" height="16"> </td>
# </tr>
# </table></div>
程序正常执行,但语言测试始终为:Charset=ISO-8859-1,显示为乱码,需要手工从浏览器
端改变编码才能看懂。我反复试验都不能完成,查 Apache 的配置文件,根本也没有 ISO-8859-1
的语言配置,它是从哪里来的?如果知道,请告诉我,谢谢。