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

📄 cgi.pm

📁 MSYS在windows下模拟了一个类unix的终端
💻 PM
📖 第 1 页 / 共 5 页
字号:
END_OF_FUNC'TIEHASH' => <<'END_OF_FUNC',sub TIEHASH {     return $_[1] if defined $_[1];    return $Q ||= new shift;}END_OF_FUNC'STORE' => <<'END_OF_FUNC',sub STORE {    my $self = shift;    my $tag  = shift;    my $vals = shift;    my @vals = index($vals,"\0")!=-1 ? split("\0",$vals) : $vals;    $self->param(-name=>$tag,-value=>\@vals);}END_OF_FUNC'FETCH' => <<'END_OF_FUNC',sub FETCH {    return $_[0] if $_[1] eq 'CGI';    return undef unless defined $_[0]->param($_[1]);    return join("\0",$_[0]->param($_[1]));}END_OF_FUNC'FIRSTKEY' => <<'END_OF_FUNC',sub FIRSTKEY {    $_[0]->{'.iterator'}=0;    $_[0]->{'.parameters'}->[$_[0]->{'.iterator'}++];}END_OF_FUNC'NEXTKEY' => <<'END_OF_FUNC',sub NEXTKEY {    $_[0]->{'.parameters'}->[$_[0]->{'.iterator'}++];}END_OF_FUNC'EXISTS' => <<'END_OF_FUNC',sub EXISTS {    exists $_[0]->{$_[1]};}END_OF_FUNC'DELETE' => <<'END_OF_FUNC',sub DELETE {    $_[0]->delete($_[1]);}END_OF_FUNC'CLEAR' => <<'END_OF_FUNC',sub CLEAR {    %{$_[0]}=();}####END_OF_FUNC##### Append a new value to an existing query####'append' => <<'EOF',sub append {    my($self,@p) = @_;    my($name,$value) = rearrange([NAME,[VALUE,VALUES]],@p);    my(@values) = defined($value) ? (ref($value) ? @{$value} : $value) : ();    if (@values) {	$self->add_parameter($name);	push(@{$self->{$name}},@values);    }    return $self->param($name);}EOF#### Method: delete_all# Delete all parameters####'delete_all' => <<'EOF',sub delete_all {    my($self) = self_or_default(@_);    undef %{$self};}EOF'Delete' => <<'EOF',sub Delete {    my($self,@p) = self_or_default(@_);    $self->delete(@p);}EOF'Delete_all' => <<'EOF',sub Delete_all {    my($self,@p) = self_or_default(@_);    $self->delete_all(@p);}EOF#### Method: autoescape# If you want to turn off the autoescaping features,# call this method with undef as the argument'autoEscape' => <<'END_OF_FUNC',sub autoEscape {    my($self,$escape) = self_or_default(@_);    $self->{'dontescape'}=!$escape;}END_OF_FUNC#### Method: version# Return the current version####'version' => <<'END_OF_FUNC',sub version {    return $VERSION;}END_OF_FUNC#### Method: url_param# Return a parameter in the QUERY_STRING, regardless of# whether this was a POST or a GET####'url_param' => <<'END_OF_FUNC',sub url_param {    my ($self,@p) = self_or_default(@_);    my $name = shift(@p);    return undef unless exists($ENV{QUERY_STRING});    unless (exists($self->{'.url_param'})) {	$self->{'.url_param'}={}; # empty hash	if ($ENV{QUERY_STRING} =~ /=/) {	    my(@pairs) = split(/[&;]/,$ENV{QUERY_STRING});	    my($param,$value);	    foreach (@pairs) {		($param,$value) = split('=',$_,2);		$param = unescape($param);		$value = unescape($value);		push(@{$self->{'.url_param'}->{$param}},$value);	    }	} else {	    $self->{'.url_param'}->{'keywords'} = [$self->parse_keywordlist($ENV{QUERY_STRING})];	}    }    return keys %{$self->{'.url_param'}} unless defined($name);    return () unless $self->{'.url_param'}->{$name};    return wantarray ? @{$self->{'.url_param'}->{$name}}                     : $self->{'.url_param'}->{$name}->[0];}END_OF_FUNC#### Method: Dump# Returns a string in which all the known parameter/value # pairs are represented as nested lists, mainly for the purposes # of debugging.####'Dump' => <<'END_OF_FUNC',sub Dump {    my($self) = self_or_default(@_);    my($param,$value,@result);    return '<UL></UL>' unless $self->param;    push(@result,"<UL>");    foreach $param ($self->param) {	my($name)=$self->escapeHTML($param);	push(@result,"<LI><STRONG>$param</STRONG>");	push(@result,"<UL>");	foreach $value ($self->param($param)) {	    $value = $self->escapeHTML($value);            $value =~ s/\n/<BR>\n/g;	    push(@result,"<LI>$value");	}	push(@result,"</UL>");    }    push(@result,"</UL>\n");    return join("\n",@result);}END_OF_FUNC#### Method as_string## synonym for "dump"####'as_string' => <<'END_OF_FUNC',sub as_string {    &Dump(@_);}END_OF_FUNC#### Method: save# Write values out to a filehandle in such a way that they can# be reinitialized by the filehandle form of the new() method####'save' => <<'END_OF_FUNC',sub save {    my($self,$filehandle) = self_or_default(@_);    $filehandle = to_filehandle($filehandle);    my($param);    local($,) = '';  # set print field separator back to a sane value    local($\) = '';  # set output line separator to a sane value    foreach $param ($self->param) {	my($escaped_param) = escape($param);	my($value);	foreach $value ($self->param($param)) {	    print $filehandle "$escaped_param=",escape("$value"),"\n";	}    }    foreach (keys %{$self->{'.fieldnames'}}) {          print $filehandle ".cgifields=",escape("$_"),"\n";    }    print $filehandle "=\n";    # end of record}END_OF_FUNC#### Method: save_parameters# An alias for save() that is a better name for exportation.# Only intended to be used with the function (non-OO) interface.####'save_parameters' => <<'END_OF_FUNC',sub save_parameters {    my $fh = shift;    return save(to_filehandle($fh));}END_OF_FUNC#### Method: restore_parameters# A way to restore CGI parameters from an initializer.# Only intended to be used with the function (non-OO) interface.####'restore_parameters' => <<'END_OF_FUNC',sub restore_parameters {    $Q = $CGI::DefaultClass->new(@_);}END_OF_FUNC#### Method: multipart_init# Return a Content-Type: style header for server-push# This has to be NPH on most web servers, and it is advisable to set $| = 1## Many thanks to Ed Jordan <ed@fidalgo.net> for this# contribution, updated by Andrew Benham (adsb@bigfoot.com)####'multipart_init' => <<'END_OF_FUNC',sub multipart_init {    my($self,@p) = self_or_default(@_);    my($boundary,@other) = rearrange([BOUNDARY],@p);    $boundary = $boundary || '------- =_aaaaaaaaaa0';    $self->{'separator'} = "$CRLF--$boundary$CRLF";    $self->{'final_separator'} = "$CRLF--$boundary--$CRLF";    $type = SERVER_PUSH($boundary);    return $self->header(	-nph => 1,	-type => $type,	(map { split "=", $_, 2 } @other),    ) . "WARNING: YOUR BROWSER DOESN'T SUPPORT THIS SERVER-PUSH TECHNOLOGY." . $self->multipart_end;}END_OF_FUNC#### Method: multipart_start# Return a Content-Type: style header for server-push, start of section## Many thanks to Ed Jordan <ed@fidalgo.net> for this# contribution, updated by Andrew Benham (adsb@bigfoot.com)####'multipart_start' => <<'END_OF_FUNC',sub multipart_start {    my(@header);    my($self,@p) = self_or_default(@_);    my($type,@other) = rearrange([TYPE],@p);    $type = $type || 'text/html';    push(@header,"Content-Type: $type");    # rearrange() was designed for the HTML portion, so we    # need to fix it up a little.    foreach (@other) {        next unless my($header,$value) = /([^\s=]+)=\"?(.+?)\"?$/;	($_ = $header) =~ s/^(\w)(.*)/$1 . lc ($2) . ': '.$self->unescapeHTML($value)/e;    }    push(@header,@other);    my $header = join($CRLF,@header)."${CRLF}${CRLF}";    return $header;}END_OF_FUNC#### Method: multipart_end# Return a MIME boundary separator for server-push, end of section## Many thanks to Ed Jordan <ed@fidalgo.net> for this# contribution####'multipart_end' => <<'END_OF_FUNC',sub multipart_end {    my($self,@p) = self_or_default(@_);    return $self->{'separator'};}END_OF_FUNC#### Method: multipart_final# Return a MIME boundary separator for server-push, end of all sections## Contributed by Andrew Benham (adsb@bigfoot.com)####'multipart_final' => <<'END_OF_FUNC',sub multipart_final {    my($self,@p) = self_or_default(@_);    return $self->{'final_separator'} . "WARNING: YOUR BROWSER DOESN'T SUPPORT THIS SERVER-PUSH TECHNOLOGY." . $CRLF;}END_OF_FUNC#### Method: header# Return a Content-Type: style header#####'header' => <<'END_OF_FUNC',sub header {    my($self,@p) = self_or_default(@_);    my(@header);    return undef if $self->{'.header_printed'}++ and $HEADERS_ONCE;    my($type,$status,$cookie,$target,$expires,$nph,$charset,$attachment,@other) = 	rearrange([['TYPE','CONTENT_TYPE','CONTENT-TYPE'],			    'STATUS',['COOKIE','COOKIES'],'TARGET',                            'EXPIRES','NPH','CHARSET',                            'ATTACHMENT'],@p);    $nph     ||= $NPH;    if (defined $charset) {      $self->charset($charset);    } else {      $charset = $self->charset;    }    # rearrange() was designed for the HTML portion, so we    # need to fix it up a little.    foreach (@other) {        next unless my($header,$value) = /([^\s=]+)=\"?(.+?)\"?$/;	($_ = $header) =~ s/^(\w)(.*)/$1 . lc ($2) . ': '.$self->unescapeHTML($value)/e;    }    $type ||= 'text/html' unless defined($type);    $type .= "; charset=$charset" if $type ne '' and $type =~ m!^text/! and $type !~ /\bcharset\b/;    # Maybe future compatibility.  Maybe not.    my $protocol = $ENV{SERVER_PROTOCOL} || 'HTTP/1.0';    push(@header,$protocol . ' ' . ($status || '200 OK')) if $nph;    push(@header,"Server: " . &server_software()) if $nph;    push(@header,"Status: $status") if $status;    push(@header,"Window-Target: $target") if $target;    # push all the cookies -- there may be several    if ($cookie) {	my(@cookie) = ref($cookie) && ref($cookie) eq 'ARRAY' ? @{$cookie} : $cookie;	foreach (@cookie) {            my $cs = UNIVERSAL::isa($_,'CGI::Cookie') ? $_->as_string : $_;	    push(@header,"Set-Cookie: $cs") if $cs ne '';	}    }    # if the user indicates an expiration time, then we need    # both an Expires and a Date header (so that the browser is    # uses OUR clock)    push(@header,"Expires: " . expires($expires,'http'))	if $expires;    push(@header,"Date: " . expires(0,'http')) if $expires || $cookie || $nph;    push(@header,"Pragma: no-cache") if $self->cache();    push(@header,"Content-Disposition: attachment; filename=\"$attachment\"") if $attachment;    push(@header,@other);    push(@header,"Content-Type: $type") if $type ne '';    my $header = join($CRLF,@header)."${CRLF}${CRLF}";    if ($MOD_PERL and not $nph) {	my $r = Apache->request;	$r->send_cgi_header($header);	return '';    }    return $header;}END_OF_FUNC#### Method: cache# Control whether header() will produce the no-cache# Pragma directive.####'cache' => <<'END_OF_FUNC',sub cache {    my($self,$new_value) = self_or_default(@_);    $new_value = '' unless $new_value;    if ($new_value ne '') {	$self->{'cache'} = $new_value;    }    return $self->{'cache'};}END_OF_FUNC#### Method: redirect# Return a Location: style header#####'redirect' => <<'END_OF_FUNC',sub redirect {    my($self,@p) = self_or_default(@_);    my($url,$target,$cookie,$nph,@other) = rearrange([[LOCATION,URI,URL],TARGET,COOKIE,NPH],@p);    $url ||= $self->self_url;    my(@o);    foreach (@other) { tr/\"//d; push(@o,split("=",$_,2)); }    unshift(@o,	 '-Status'=>'302 Moved',	 '-Location'=>$url,	 '-nph'=>$nph);    unshift(@o,'-Target'=>$target) if $target;    unshift(@o,'-Cookie'=>$cookie) if $cookie;    unshift(@o,'-Type'=>'');    return $self->header(@o);}END_OF_FUNC#### Method: start_html# Canned HTML header## Parameters:# $title -> (optional) The title for this HTML document (-title)# $author -> (optional) e-mail address of the author (-author)# $base -> (optional) if set to true, will enter the BASE address of this document

⌨️ 快捷键说明

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