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

📄 cgi.pm

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 PM
📖 第 1 页 / 共 5 页
字号:
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></li>");	push(@result,"<ul>");	foreach $value ($self->param($param)) {	    $value = $self->escapeHTML($value);            $value =~ s/\n/<br \/>\n/g;	    push(@result,"<li>$value</li>");	}	push(@result,"</ul>");    }    push(@result,"</ul>");    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 => 0,	-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) {        # Don't use \s because of perl bug 21951        next unless my($header,$value) = /([^ \r\n\t=]+)=\"?(.+?)\"?$/;	($_ = $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 "" if $self->{'.header_printed'}++ and $HEADERS_ONCE;    my($type,$status,$cookie,$target,$expires,$nph,$charset,$attachment,$p3p,@other) = 	rearrange([['TYPE','CONTENT_TYPE','CONTENT-TYPE'],			    'STATUS',['COOKIE','COOKIES'],'TARGET',                            'EXPIRES','NPH','CHARSET',                            'ATTACHMENT','P3P'],@p);    $nph     ||= $NPH;    $type ||= 'text/html' unless defined($type);    if (defined $charset) {      $self->charset($charset);    } else {      $charset = $self->charset if $type =~ /^text\//;    }   $charset ||= '';    # rearrange() was designed for the HTML portion, so we    # need to fix it up a little.    foreach (@other) {        # Don't use \s because of perl bug 21951        next unless my($header,$value) = /([^ \r\n\t=]+)=\"?(.+?)\"?$/;        ($_ = $header) =~ s/^(\w)(.*)/"\u$1\L$2" . ': '.$self->unescapeHTML($value)/e;    }    $type .= "; charset=$charset"      if     $type ne ''         and $type !~ /\bcharset\b/         and defined $charset         and $charset ne '';    # 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;    if ($p3p) {       $p3p = join ' ',@$p3p if ref($p3p) eq 'ARRAY';       push(@header,qq(P3P: policyref="/w3c/p3p.xml", CP="$p3p"));    }    # 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,map {ucfirst $_} @other);    push(@header,"Content-Type: $type") if $type ne '';    my $header = join($CRLF,@header)."${CRLF}${CRLF}";    if ($MOD_PERL and not $nph) {        $self->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,$status,$cookie,$nph,@other) =          rearrange([[LOCATION,URI,URL],TARGET,STATUS,['COOKIE','COOKIES'],NPH],@p);    $status = '302 Found' unless defined $status;    $url ||= $self->self_url;    my(@o);    foreach (@other) { tr/\"//d; push(@o,split("=",$_,2)); }    unshift(@o,	 '-Status'  => $status,	 '-Location'=> $url,	 '-nph'     => $nph);    unshift(@o,'-Target'=>$target) if $target;    unshift(@o,'-Type'=>'');    my @unescaped;    unshift(@unescaped,'-Cookie'=>$cookie) if $cookie;    return $self->header((map {$self->unescapeHTML($_)} @o),@unescaped);}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#          for resolving relative references (-base) # $xbase -> (optional) alternative base at some remote location (-xbase)# $target -> (optional) target window to load all links into (-target)# $script -> (option) Javascript code (-script)# $no_script -> (option) Javascript <noscript> tag (-noscript)# $meta -> (optional) Meta information tags# $head -> (optional) any other elements you'd like to incorporate into the <head> tag#           (a scalar or array ref)# $style -> (optional) reference to an external style sheet# @other -> (optional) any other named parameters you'd like to incorporate into#           the <body> tag.####'start_html' => <<'END_OF_FUNC',sub start_html {    my($self,@p) = &self_or_default(@_);    my($title,$author,$base,$xbase,$script,$noscript,        $target,$meta,$head,$style,$dtd,$lang,$encoding,$declare_xml,@other) = 	rearrange([TITLE,AUTHOR,BASE,XBASE,SCRIPT,NOSCRIPT,TARGET,                   META,HEAD,STYLE,DTD,LANG,ENCODING,DECLARE_XML],@p);    $self->element_id(0);    $self->element_tab(0);    $encoding = lc($self->charset) unless defined $encoding;    # Need to sort out the DTD before it's okay to call escapeHTML().    my(@result,$xml_dtd);    if ($dtd) {        if (defined(ref($dtd)) and (ref($dtd) eq 'ARRAY')) {            $dtd = $DEFAULT_DTD unless $dtd->[0] =~ m|^-//|;        } else {            $dtd = $DEFAULT_DTD unless $dtd =~ m|^-//|;        }    } else {        $dtd = $XHTML ? XHTML_DTD : $DEFAULT_DTD;    }    $xml_dtd++ if ref($dtd) eq 'ARRAY' && $dtd->[0] =~ /\bXHTML\b/i;    $xml_dtd++ if ref($dtd) eq '' && $dtd =~ /\bXHTML\b/i;    push @result,qq(<?xml version="1.0" encoding="$encoding"?>) if $xml_dtd && $declare_xml;    if (ref($dtd) && ref($dtd) eq 'ARRAY') {        push(@result,qq(<!DOCTYPE html\n\tPUBLIC "$dtd->[0]"\n\t "$dtd->[1]">));	$DTD_PUBLIC_IDENTIFIER = $dtd->[0];    } else {        push(@result,qq(<!DOCTYPE html\n\tPUBLIC "$dtd">));	$DTD_PUBLIC_IDENTIFIER = $dtd;    }    # Now that we know whether we're using the HTML 3.2 DTD or not, it's okay to    # call escapeHTML().  Strangely enough, the title needs to be escaped as    # HTML while the author needs to be escaped as a URL.    $title = $self->escapeHTML($title || 'Untitled Document');    $author = $self->escape($author);    if ($DTD_PUBLIC_IDENTIFIER =~ /[^X]HTML (2\.0|3\.2)/i) {	$lang = "" unless defined $lang;	$XHTML = 0;    }    else {	$lang = 'en-US' unless defined $lang;    }    my $lang_bits = $lang ne '' ? qq( lang="$lang" xml:lang="$lang") : '';    my $meta_bits = qq(<meta http-equiv="Content-Type" content="text/html; charset=$encoding" />)                     if $XHTML && $encoding && !$declare_xml;    push(@result,$XHTML ? qq(<html xmlns="http://www.w3.org/1999/xhtml"$lang_bits>\n<head>\n<title>$title</title>)                        : ($lang ? qq(<html lang="$lang">) : "<html>")	                  . "<head><title>$title</title>");	if (defined $author) {    push(@result,$XHTML ? "<link rev=\"made\" href=\"mailto:$author\" />"			: "<link rev=\"made\" href=\"mailto:$author\">");	}    if ($base || $xbase || $target) {	my $href = $xbase || $self->url('-path'=>1);	my $t = $target ? qq/ target="$target"/ : '';	push(@result,$XHTML ? qq(<base href="$href"$t />) : qq(<base href="$href"$t>));    }    if ($meta && ref($meta) && (ref($meta) eq 'HASH')) {	foreach (keys %$meta) { push(@result,$XHTML ? qq(<meta name="$_" content="$meta->{$_}" />) 			: qq(<meta name="$_" content="$meta->{$_}">)); }    }    push(@result,ref($head) ? @$head : $head) if $head;    # handle the infrequently-used -style and -script parameters    push(@result,$self->_style($style))   if defined $style;    push(@result,$self->_script($script)) if defined $script;    push(@result,$meta_bits)              if defined $meta_bits;    # handle -noscript parameter    push(@result,<<END) if $noscript;<noscript>$noscript</noscript>END    ;    my($other) = @other ? " @other" : '';    push(@result,"</head>\n<body$other>\n");    return join("\n",@result);}END_OF_FUNC### Method: _style# internal method for generating a CSS style section####'_style' => <<'END_OF_FUNC',sub _style {    my ($self,$style) = @_;    my (@result);    my $type = 'text/css';    my $rel  = 'stylesheet';    my $cdata_start = $XHTML ? "\n<!--/* <![CDATA[ */" : "\n<!-- ";    my $cdata_end   = $XHTML ? "\n/* ]]> */-->\n" : " -->\n";    my @s = ref($style) eq 'ARRAY' ? @$style : $style;    for my $s (@s) {      if (ref($s)) {       my($src,$code,$verbatim,$stype,$alternate,$foo,@other) =           rearrange([qw(SRC CODE VERBATIM TYPE ALTERNATE FOO)],                      ('-foo'=>'bar',                       ref($s) eq 'ARRAY' ? @$s : %$s));       my $type = defined $stype ? $stype : 'text/css';       my $rel  = $alternate ? 'alternate stylesheet' : 'stylesheet';       my $other = @other ? join ' ',@other : '';

⌨️ 快捷键说明

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