当前位置: 技术问答>linux和unix
perl问题请教
来源: 互联网 发布时间:2015-08-20
本文导语: 源码如下!是从一个IE网页提交的数据,执行此*.cgi程序处理,要求把接收到的数据写入一个新的文件,(该文件不在《/html/》、《/cgi-bin/》目录中),请问我该如何处理,下面的源码有问题吗!我试过直接执行可以生...
源码如下!是从一个IE网页提交的数据,执行此*.cgi程序处理,要求把接收到的数据写入一个新的文件,(该文件不在《/html/》、《/cgi-bin/》目录中),请问我该如何处理,下面的源码有问题吗!我试过直接执行可以生成,但是通过ie执行好象加不进去
#!/usr/bin/perl
use CGI;
$q=new CGI;
###################/处理由web通get方式传来的的表单数据/################
###
$string=$ENV{'QUERY_STRING'};
@temp = split(/&/,$string);
@temp1 = split(/=/,@temp[0]);
@temp2 = split(/=/,@temp[1]);
@temp3 = split(/=/,@temp[2]);
@temp4 = split(/=/,@temp[3]);
@temp5 = split(/=/,@temp[4]);
@temp6 = split(/=/,@temp[5]);
@temp7 = split(/=/,@temp[6]);
@temp8 = split(/=/,@temp[7]);
@temp9 = split(/=/,@temp[8]);
@temp10 = split(/=/,@temp[9]);
@temp11 = split(/=/,@temp[10]);
############################
$xiang_temp = @temp1[1];
$text_domain_temp = @temp2[1];
$record_select_temp = @temp3[1];
$text_record_temp = @temp4[1];
$text_server_temp = @temp5[1];
$text_check_temp = @temp6[1];
$text_email_temp = @temp7[1];
$text_reflash_temp = @temp8[1];
$text_outtime_temp = @temp9[1];
$text_trytime_temp = @temp10[1];
$text_defactive_temp = @temp11[1];
#############调用ToChnString函数解码###############
$xiang = ToChnString($xiang_temp);
$domains = ToChnString($text_domain_temp);
$recordsel = ToChnString($record_select_temp);
$records = ToChnString($text_record_temp);
$servers = ToChnString($text_server_temp);
$emails = ToChnString($text_email_temp);
$checkbox = ToChnString($text_check_temp);
$reflash = ToChnString($text_reflash_temp);
$outtime = ToChnString($text_outtime_temp);
$trytime = ToChnString($text_trytime_temp);
defactive = ToChnString($text_defactive_temp);
###################/处理由web通get方式传来的的表单数据/################
########把数据写入文件(如文件不存在则新建)############
$vars="$TTL86400ntSOAtausu.com.troot@localhost.t{n";
$logfile="/var/www/cgi-bin/aaa.cgi";
open AAAFILE,">>$logfile";
print AAAFILE $vars;
close AAAFILE;
########################################################
########################################################
print $q->header;
print $q->start_html();
print "操作成功";
print $q->end_html;
######################################################
#############解码函数定义############
sub ToChnString
{
my($i)=0;
my($chnstring)="";
my($code0)=0; my($code1)=0;
my($string)=@_;
for($i=0;$i
#!/usr/bin/perl
use CGI;
$q=new CGI;
###################/处理由web通get方式传来的的表单数据/################
###
$string=$ENV{'QUERY_STRING'};
@temp = split(/&/,$string);
@temp1 = split(/=/,@temp[0]);
@temp2 = split(/=/,@temp[1]);
@temp3 = split(/=/,@temp[2]);
@temp4 = split(/=/,@temp[3]);
@temp5 = split(/=/,@temp[4]);
@temp6 = split(/=/,@temp[5]);
@temp7 = split(/=/,@temp[6]);
@temp8 = split(/=/,@temp[7]);
@temp9 = split(/=/,@temp[8]);
@temp10 = split(/=/,@temp[9]);
@temp11 = split(/=/,@temp[10]);
############################
$xiang_temp = @temp1[1];
$text_domain_temp = @temp2[1];
$record_select_temp = @temp3[1];
$text_record_temp = @temp4[1];
$text_server_temp = @temp5[1];
$text_check_temp = @temp6[1];
$text_email_temp = @temp7[1];
$text_reflash_temp = @temp8[1];
$text_outtime_temp = @temp9[1];
$text_trytime_temp = @temp10[1];
$text_defactive_temp = @temp11[1];
#############调用ToChnString函数解码###############
$xiang = ToChnString($xiang_temp);
$domains = ToChnString($text_domain_temp);
$recordsel = ToChnString($record_select_temp);
$records = ToChnString($text_record_temp);
$servers = ToChnString($text_server_temp);
$emails = ToChnString($text_email_temp);
$checkbox = ToChnString($text_check_temp);
$reflash = ToChnString($text_reflash_temp);
$outtime = ToChnString($text_outtime_temp);
$trytime = ToChnString($text_trytime_temp);
defactive = ToChnString($text_defactive_temp);
###################/处理由web通get方式传来的的表单数据/################
########把数据写入文件(如文件不存在则新建)############
$vars="$TTL86400ntSOAtausu.com.troot@localhost.t{n";
$logfile="/var/www/cgi-bin/aaa.cgi";
open AAAFILE,">>$logfile";
print AAAFILE $vars;
close AAAFILE;
########################################################
########################################################
print $q->header;
print $q->start_html();
print "操作成功";
print $q->end_html;
######################################################
#############解码函数定义############
sub ToChnString
{
my($i)=0;
my($chnstring)="";
my($code0)=0; my($code1)=0;
my($string)=@_;
for($i=0;$i