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

📄 html.pm

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 PM
📖 第 1 页 / 共 5 页
字号:
    } elsif( 0 && $nocode ){	$res = $linktext;    } else {	$res = "<code>$linktext</code>";    }    return $res;}## html_escape: make text safe for HTML#sub html_escape {    my $rest = $_[0];    $rest   =~ s/&/&amp;/g;    $rest   =~ s/</&lt;/g;    $rest   =~ s/>/&gt;/g;    $rest   =~ s/"/&quot;/g;    # &apos; is only in XHTML, not HTML4.  Be conservative    #$rest   =~ s/'/&apos;/g;    return $rest;}## dosify - convert filenames to 8.3#sub dosify {    my($str) = @_;    return lc($str) if $^O eq 'VMS';     # VMS just needs casing    if ($Is83) {        $str = lc $str;        $str =~ s/(\.\w+)/substr ($1,0,4)/ge;        $str =~ s/(\w+)/substr ($1,0,8)/ge;    }    return $str;}## page_sect - make a URL from the text of a L<>#sub page_sect($$) {    my( $page, $section ) = @_;    my( $linktext, $page83, $link);	# work strings    # check if we know that this is a section in this page    if (!defined $Pages{$page} && defined $Sections{$page}) {	$section = $page;	$page = "";        ### print STDERR "reset page='', section=$section\n";    }    $page83=dosify($page);    $page=$page83 if (defined $Pages{$page83});    if ($page eq "") {        $link = "#" . anchorify( $section );    } elsif ( $page =~ /::/ ) {	$page =~ s,::,/,g;	# Search page cache for an entry keyed under the html page name,	# then look to see what directory that page might be in.  NOTE:	# this will only find one page. A better solution might be to produce	# an intermediate page that is an index to all such pages.	my $page_name = $page ;	$page_name =~ s,^.*/,,s ;	if ( defined( $Pages{ $page_name } ) &&	     $Pages{ $page_name } =~ /([^:]*$page)\.(?:pod|pm):/	   ) {	    $page = $1 ;	}	else {	    # NOTE: This branch assumes that all A::B pages are located in	    # $Htmlroot/A/B.html . This is often incorrect, since they are	    # often in $Htmlroot/lib/A/B.html or such like. Perhaps we could	    # analyze the contents of %Pages and figure out where any	    # cousins of A::B are, then assume that.  So, if A::B isn't found,	    # but A::C is found in lib/A/C.pm, then A::B is assumed to be in	    # lib/A/B.pm. This is also limited, but it's an improvement.	    # Maybe a hints file so that the links point to the correct places	    # nonetheless?	}	$link = "$Htmlroot/$page.html";	$link .= "#" . anchorify( $section ) if ($section);    } elsif (!defined $Pages{$page}) {	$link = "";    } else {	$section = anchorify( $section ) if $section ne "";        ### print STDERR "...section=$section\n";	# if there is a directory by the name of the page, then assume that an	# appropriate section will exist in the subdirectory#	if ($section ne "" && $Pages{$page} =~ /([^:]*[^(\.pod|\.pm)]):/) {	if ($section ne "" && $Pages{$page} =~ /([^:]*(?<!\.pod)(?<!\.pm)):/) {	    $link = "$Htmlroot/$1/$section.html";            ### print STDERR "...link=$link\n";	# since there is no directory by the name of the page, the section will	# have to exist within a .html of the same name.  thus, make sure there	# is a .pod or .pm that might become that .html	} else {	    $section = "#$section" if $section;            ### print STDERR "...section=$section\n";	    # check if there is a .pod with the page name.	    # for L<Foo>, Foo.(pod|pm) is preferred to A/Foo.(pod|pm)	    if ($Pages{$page} =~ /([^:]*)\.(?:pod|pm):/) {		$link = "$Htmlroot/$1.html$section";	    } else {		$link = "";	    }	}    }    if ($link) {	# Here, we take advantage of the knowledge that $Htmlfileurl ne ''	# implies $Htmlroot eq ''. This means that the link in question	# needs a prefix of $Htmldir if it begins with '/'. The test for	# the initial '/' is done to avoid '#'-only links, and to allow	# for other kinds of links, like file:, ftp:, etc.        my $url ;        if (  $Htmlfileurl ne '' ) {            $link = "$Htmldir$link" if $link =~ m{^/}s;            $url = relativize_url( $link, $Htmlfileurl );# print( "  b: [$link,$Htmlfileurl,$url]\n" );	}	else {            $url = $link ;	}	return $url;    } else {	return undef();    }}## relativize_url - convert an absolute URL to one relative to a base URL.# Assumes both end in a filename.#sub relativize_url {    my ($dest,$source) = @_ ;    my ($dest_volume,$dest_directory,$dest_file) =        File::Spec::Unix->splitpath( $dest ) ;    $dest = File::Spec::Unix->catpath( $dest_volume, $dest_directory, '' ) ;    my ($source_volume,$source_directory,$source_file) =        File::Spec::Unix->splitpath( $source ) ;    $source = File::Spec::Unix->catpath( $source_volume, $source_directory, '' ) ;    my $rel_path = '' ;    if ( $dest ne '' ) {       $rel_path = File::Spec::Unix->abs2rel( $dest, $source ) ;    }    if ( $rel_path ne ''                &&         substr( $rel_path, -1 ) ne '/' &&         substr( $dest_file, 0, 1 ) ne '#'        ) {        $rel_path .= "/$dest_file" ;    }    else {        $rel_path .= "$dest_file" ;    }    return $rel_path ;}## coderef - make URL from the text of a C<>#sub coderef($$){    my( $page, $item ) = @_;    my( $url );    my $fid = fragment_id( $item );        if( defined( $page ) && $page ne "" ){	# we have been given a $page...	$page =~ s{::}{/}g;        Carp::confess("Undefined fragment '$item' from fragment_id() in coderef() in $Podfile")            if !defined $fid;    	# Do we take it? Item could be a section!	my $base = $Items{$fid} || "";	$base =~ s{[^/]*/}{};	if( $base ne "$page.html" ){            ###   print STDERR "coderef( $page, $item ): items{$fid} = $Items{$fid} = $base => discard page!\n";	    $page = undef();	}    } else {        # no page - local items precede cached items	if( defined( $fid ) ){	    if(  exists $Local_Items{$fid} ){		$page = $Local_Items{$fid};	    } else {		$page = $Items{$fid};	    }	}    }    # if there was a pod file that we found earlier with an appropriate    # =item directive, then create a link to that page.    if( defined $page ){	if( $page ){            if( exists $Pages{$page} and $Pages{$page} =~ /([^:.]*)\.[^:]*:/){		$page = $1 . '.html';	    }	    my $link = "$Htmlroot/$page#" . anchorify($fid);	    # Here, we take advantage of the knowledge that $Htmlfileurl	    # ne '' implies $Htmlroot eq ''.	    if (  $Htmlfileurl ne '' ) {		$link = "$Htmldir$link" ;		$url = relativize_url( $link, $Htmlfileurl ) ;	    } else {		$url = $link ;	    }	} else {	    $url = "#" . anchorify($fid);	}	confess "url has space: $url" if $url =~ /"[^"]*\s[^"]*"/;    }    return( $url, $fid );}## Adapted from Nick Ing-Simmons' PodToHtml package.sub relative_url {    my $source_file = shift ;    my $destination_file = shift;    my $source = URI::file->new_abs($source_file);    my $uo = URI::file->new($destination_file,$source)->abs;    return $uo->rel->as_string;}## finish_list - finish off any pending HTML lists.  this should be called# after the entire pod file has been read and converted.#sub finish_list {    while ($Listlevel > 0) {	print HTML "</dl>\n";	$Listlevel--;    }}## htmlify - converts a pod section specification to a suitable section# specification for HTML. Note that we keep spaces and special characters# except ", ? (Netscape problem) and the hyphen (writer's problem...).#sub htmlify {    my( $heading) = @_;    $heading =~ s/(\s+)/ /g;    $heading =~ s/\s+\Z//;    $heading =~ s/\A\s+//;    # The hyphen is a disgrace to the English language.    # $heading =~ s/[-"?]//g;    $heading =~ s/["?]//g;    $heading = lc( $heading );    return $heading;}## similar to htmlify, but turns non-alphanumerics into underscores#sub anchorify {    my ($anchor) = @_;    $anchor = htmlify($anchor);    $anchor =~ s/\W/_/g;    return $anchor;}## depod - convert text by eliminating all interior sequences# Note: can be called with copy or modify semantics#my %E2c;$E2c{lt}     = '<';$E2c{gt}     = '>';$E2c{sol}    = '/';$E2c{verbar} = '|';$E2c{amp}    = '&'; # in Tk's podssub depod1($;$$);sub depod($){    my $string;    if( ref( $_[0] ) ){	$string =  ${$_[0]};        ${$_[0]} = depod1( \$string );    } else {	$string =  $_[0];        depod1( \$string );    }}sub depod1($;$$){  my( $rstr, $func, $closing ) = @_;  my $res = '';  return $res unless defined $$rstr;  if( ! defined( $func ) ){      # skip to next begin of an interior sequence      while( $$rstr =~ s/\A(.*?)([BCEFILSXZ])<(<+[^\S\n]+)?//s ){         # recurse into its text	  $res .= $1 . depod1( $rstr, $2, closing $3);      }      $res .= $$rstr;  } elsif( $func eq 'E' ){      # E<x> - convert to character      $$rstr =~ s/^([^>]*)>//;      $res .= $E2c{$1} || "";  } elsif( $func eq 'X' ){      # X<> - ignore      $$rstr =~ s/^[^>]*>//;  } elsif( $func eq 'Z' ){      # Z<> - empty      $$rstr =~ s/^>//;  } else {      # all others: either recurse into new function or      # terminate at closing angle bracket      my $term = pattern $closing;      while( $$rstr =~ s/\A(.*?)(([BCEFILSXZ])<(<+[^\S\n]+)?|$term)//s ){	  $res .= $1;	  last unless $3;          $res .= depod1( $rstr, $3, closing $4 );      }      ## If we're here and $2 ne '>': undelimited interior sequence.      ## Ignored, as this is called without proper indication of where we are.      ## Rely on process_text to produce diagnostics.  }  return $res;}{    my %seen;   # static fragment record hashsub fragment_id_readable {    my $text     = shift;    my $generate = shift;   # optional flag    my $orig = $text;    # leave the words for the fragment identifier,    # change everything else to underbars.    $text =~ s/[^A-Za-z0-9_]+/_/g; # do not use \W to avoid locale dependency.    $text =~ s/_{2,}/_/g;    $text =~ s/\A_//;    $text =~ s/_\Z//;    unless ($text)    {        # Nothing left after removing punctuation, so leave it as is        # E.g. if option is named: "=item -#"        $text = $orig;    }    if ($generate) {        if ( exists $seen{$text} ) {            # This already exists, make it unique            $seen{$text}++;            $text = $text . $seen{$text};        } else {            $seen{$text} = 1;  # first time seen this fragment        }    }    $text;}}my @HC;sub fragment_id_obfuscated {  # This was the old "_2d_2d__"    my $text     = shift;    my $generate = shift;   # optional flag    # text? Normalize by obfuscating the fragment id to make it unique    $text =~ s/\s+/_/sg;    $text =~ s{(\W)}{        defined( $HC[ord($1)] ) ? $HC[ord($1)]        : ( $HC[ord($1)] = sprintf( "%%%02X", ord($1) ) ) }gxe;    $text = substr( $text, 0, 50 );    $text;}## fragment_id - construct a fragment identifier from:#   a) =item text#   b) contents of C<...>#sub fragment_id {    my $text     = shift;    my $generate = shift;   # optional flag    $text =~ s/\s+\Z//s;    if( $text ){	# a method or function?	return $1 if $text =~ /(\w+)\s*\(/;	return $1 if $text =~ /->\s*(\w+)\s*\(?/;	# a variable name?	return $1 if $text =~ /^([\$\@%*]\S+)/;	# some pattern matching operator?	return $1 if $text =~ m|^(\w+/).*/\w*$|;	# fancy stuff... like "do { }"	return $1 if $text =~ m|^(\w+)\s*{.*}$|;	# honour the perlfunc manpage: func [PAR[,[ ]PAR]...]	# and some funnies with ... Module ...	return $1 if $text =~ m{^([a-z\d_]+)(\s+[A-Z,/& ][A-Z\d,/& ]*)?$};	return $1 if $text =~ m{^([a-z\d]+)\s+Module(\s+[A-Z\d,/& ]+)?$};	return fragment_id_readable($text, $generate);    } else {	return;    }}## make_URL_href - generate HTML href from URL# Special treatment for CGI queries.#sub make_URL_href($){    my( $url ) = @_;    if( $url !~        s{^(http:[-\w/#~:.+=&%@!]+)(\?.*)$}{<a href="$1$2">$1</a>}i ){        $url = "<a href=\"$url\">$url</a>";    }    return $url;}1;

⌨️ 快捷键说明

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